Belle II Software  release-08-01-10
SVDBackgroundModule.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #ifndef SVDBackgroundMODULE_H_
9 #define SVDBackgroundMODULE_H_
10 
11 #include <framework/core/Module.h>
12 #include <framework/gearbox/Unit.h>
13 #include <vxd/dataobjects/VxdID.h>
14 #include <vxd/geometry/SensorInfoBase.h>
15 #include <svd/geometry/SensorInfo.h>
16 #include <vxd/geometry/GeoCache.h>
17 #include <string>
18 #include <memory>
19 #include <map>
20 #include <vxd/background/niel_fun.h>
21 
22 namespace Belle2 {
28  namespace SVD {
29 
50  /* Modification Jan 2016:
51  * 1. Delete all histogramming, only produce n-tuples and text file
52  * with summaries. The HistogramFactory class is not used any longer.
53  * All drawing will be done in pandas.
54  * 2. Only process one background component at a time.
55  * 3. Add occupancy estimates and a separate ntuple to hold the data.
56  */
57  /* Modifications Feb 2016:
58  * Add more information on fired strips rate and related occupancy estmates:
59  * 1. Two strip firing rates:
60  * - one with threshold equal to threshold cut, to provide check for occupancy estimates
61  * - another with threshold equal to elNoise
62  * 2. Two occupancies:
63  * - one for time of 1 APV cycle, no SNR adjustment
64  * - one for trigger jitter of 5 ns + testbeam-based hit time error
65  *
66  * Make module functionality switchable:
67  * - Add module parameters to turn on/off dose, neutron flux, and occupancy data collection.
68  */
69 
73  class SVDBackgroundModule: public Module {
74 
75  public:
78  static const int c_nVXDLayers = 6;
79 
80  // Reporting levels
81  static const unsigned short c_reportNone = 0;
82  static const unsigned short c_reportSummary = 1;
83  static const unsigned short c_reportNTuple = 2;
86  struct SensorData {
88  double m_expo;
90  double m_dose;
92  double m_neutronFlux;
94  double m_firedU;
96  double m_firedV;
98  double m_firedU_t;
100  double m_firedV_t;
102  double m_occupancyU;
104  double m_occupancyV;
109  };
110 
114  virtual ~SVDBackgroundModule();
115 
117  virtual void initialize() override;
119  virtual void beginRun() override;
121  virtual void event() override;
123  virtual void endRun() override;
125  virtual void terminate() override;
126 
127  private:
128 
129  // General
130  const double c_densitySi = 2.3290 * Unit::g_cm3;
131  const double c_smy = 1.0e7 * Unit::s;
132  const double c_APVCycleTime = 31.44 * Unit::ns;
133  // NIEL file names - placed in vxd/data, so needn't be module parameters.
135  const std::string c_niel_neutronFile = "/vxd/data/neutrons.csv";
137  const std::string c_niel_protonFile = "/vxd/data/protons.csv";
139  const std::string c_niel_pionFile = "/vxd/data/pions.csv";
141  const std::string c_niel_electronFile = "/vxd/data/electrons.csv";
142  // No NIEL for photons.
143 
148  inline const SVD::SensorInfo& getInfo(VxdID sensorID) const;
150  inline double getSensorThickness(VxdID sensorID) const;
152  inline double getSensorMass(VxdID sensorID) const;
154  inline double getSensorArea(VxdID sensorID) const;
155 
157  const ROOT::Math::XYZVector& pointToGlobal(VxdID sensorID, const ROOT::Math::XYZVector& local);
159  const ROOT::Math::XYZVector& vectorToGlobal(VxdID sensorID, const ROOT::Math::XYZVector& local);
160 
162  inline int getNumSensors(int layerNum);
164  // cppcheck-suppress unusedPrivateFunction
165  inline int getTotalSensors();
166 
167  // Output directory
168  std::string m_outputDirectoryName;
170  std::string m_storeBgMetaDataName;
171  // StoreArrays
173  std::string m_storeSimHitsName;
174  std::string m_storeTrueHitsName;
176  std::string m_storeDigitsName;
179  std::string m_storeClustersName;
180  std::string m_relClusterDigitName;
187  unsigned short m_doseReportingLevel;
188  unsigned short m_nfluxReportingLevel;
189  unsigned short m_occupancyReportingLevel;
191  std::string m_componentName;
193  double m_triggerWidth;
196  std::map<VxdID, SensorData> m_sensorData;
198  // NIEL tables
199  std::unique_ptr<TNiel> m_nielNeutrons;
200  std::unique_ptr<TNiel> m_nielProtons;
201  std::unique_ptr<TNiel> m_nielPions;
202  std::unique_ptr<TNiel> m_nielElectrons;
204  };
205 
206  inline const SVD::SensorInfo& SVDBackgroundModule::getInfo(VxdID sensorID) const
207  {
208  return dynamic_cast<const SVD::SensorInfo&>(VXD::GeoCache::get(sensorID));
209  }
210 
211  inline double SVDBackgroundModule::getSensorThickness(VxdID sensorID) const
212  {
213  return getInfo(sensorID).getThickness();
214  }
215 
216  inline double SVDBackgroundModule::getSensorMass(VxdID sensorID) const
217  {
218  const SVD::SensorInfo& info = getInfo(sensorID);
219  return info.getWidth() * info.getLength() * info.getThickness() * c_densitySi;
220  }
221 
222  inline double SVDBackgroundModule::getSensorArea(VxdID sensorID) const
223  {
224  const SVD::SensorInfo& info = getInfo(sensorID);
225  return info.getWidth() * info.getLength();
226  }
227 
228  inline int SVDBackgroundModule::getNumSensors(int layerNum)
229  {
230  VxdID layerID;
231  layerID.setLayerNumber(layerNum);
232  int result = 0;
233  for (auto ladderID : VXD::GeoCache::getInstance().getLadders(layerID))
234  result += VXD::GeoCache::getInstance().getSensors(ladderID).size();
235  return result;
236  }
237 
240  {
241  int result = 0;
242  for (auto layerID : VXD::GeoCache::getInstance().getLayers(VXD::SensorInfoBase::SVD))
243  result += getNumSensors(layerID.getLayerNumber());
244  return result;
245  }
246  } // namespace SVD
248 } // namespace Belle2
249 #endif
250 
Base class for Modules.
Definition: Module.h:72
static const unsigned short c_reportNTuple
Summary and NTuple.
std::string m_storeFileMetaDataName
Name of the persistent FileMetaData object.
double m_triggerWidth
RMS of trigger time measurement.
static const unsigned short c_reportSummary
Summary only.
unsigned short m_nfluxReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
const ROOT::Math::XYZVector & vectorToGlobal(VxdID sensorID, const ROOT::Math::XYZVector &local)
Convert local vector coordinates to global.
const ROOT::Math::XYZVector & pointToGlobal(VxdID sensorID, const ROOT::Math::XYZVector &local)
Convert local sensor coordinates to global.
std::string m_storeEnergyDepositsName
SVDEnergyDepositEvents StoreArray name.
const double c_smy
Seconds in snowmass year.
const SVD::SensorInfo & getInfo(VxdID sensorID) const
This is a shortcut to getting SVD::SensorInfo from the GeoCache.
unsigned short m_doseReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
int getTotalSensors()
Get total number of sensors.
std::string m_storeOccupancyEventsName
SVDOccupancyEvents StoreArray name.
std::map< VxdID, SensorData > m_sensorData
Struct to hold sensor-wise background data.
virtual void initialize() override
Initialize module.
std::string m_relTrueHitsSimHitsName
SVDTrueHitsToSVDSimHits RelationArray name.
std::string m_relDigitsMCParticlesName
StoreArray name of SVDDigits to MCParticles relation.
double m_acceptanceWidth
A hit is accepted if arrived within +/- m_acceptanceWidth * RMS(hit time - trigger time).
static const int c_nVXDLayers
Number of VXD layers.
const std::string c_niel_neutronFile
NIEL-correction file for neutrons.
virtual void event() override
Event processing.
const double c_densitySi
Density of crystalline Silicon.
std::string m_relClusterDigitName
SVDClustersToSVDDigits RelationArray name.
double getSensorMass(VxdID sensorID) const
Return mass of the sensor with the given sensor ID.
static const unsigned short c_reportNone
No reporting.
virtual void endRun() override
End-of-run tasks.
std::string m_storeNeutronFluxesName
SVDNeutronFluxEvents StoreArray name.
std::string m_storeTrueHitsName
SVDTrueHits StoreArray name.
virtual void terminate() override
Final summary and cleanup.
std::unique_ptr< TNiel > m_nielNeutrons
Pointer to Niel table for neutrons.
std::string m_storeMCParticlesName
MCParticles StoreArray name.
std::unique_ptr< TNiel > m_nielProtons
Pointer to Niel table for protons.
double getSensorThickness(VxdID sensorID) const
Return thickness of the sensor with the given sensor ID.
std::unique_ptr< TNiel > m_nielPions
Pointer to Niel table for pions.
int getNumSensors(int layerNum)
Get number of sensors in a layer.
virtual void beginRun() override
Start-of-run initializations.
const std::string c_niel_electronFile
NIEL-correction file for electrons.
std::string m_storeBgMetaDataName
Name of the persistent BackgroundMetaDta object.
double getSensorArea(VxdID sensorID) const
Return area of the sensor with the given sensor ID.
std::string m_outputDirectoryName
Path to directory where output data will be stored.
std::string m_storeDigitsName
SVDDigits StoreArray name.
std::string m_storeClustersName
SVDClusters StoreArray name.
std::unique_ptr< TNiel > m_nielElectrons
Pointer to Niel table for electrons.
const double c_APVCycleTime
APV cycle time.
const std::string c_niel_protonFile
NIEL-correction file for protons.
const std::string c_niel_pionFile
NIEL-correction file for pions.
std::string m_relParticlesTrueHitsName
MCParticlesToSVDTrueHits RelationArray name.
std::string m_componentName
Name of the current component.
double m_componentTime
Time of current component.
unsigned short m_occupancyReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
std::string m_storeSimHitsName
SVDSimHits StoreArray name.
std::string m_relDigitsTrueHitsName
StoreArray name of SVDDigits to SVDTrueHits relation.
Specific implementation of SensorInfo for SVD Sensors which provides additional sensor specific infor...
Definition: SensorInfo.h:25
static const double g_cm3
Practical units with the value set at 1.
Definition: Unit.h:60
static const double ns
Standard of [time].
Definition: Unit.h:48
static const double s
[second]
Definition: Unit.h:95
const std::set< Belle2::VxdID > & getSensors(Belle2::VxdID ladder) const
Return a set of all sensor IDs belonging to a given ladder.
Definition: GeoCache.cc:204
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Definition: GeoCache.h:139
double getThickness() const
Return the thickness of the sensor.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
void setLayerNumber(baseType layer)
Set the layer id.
Definition: VxdID.h:107
Abstract base class for different kinds of events.
Struct to hold data of an SVD sensor.
double m_firedU_t
Fired pixels in U, occupied time per cm2 and second.
double m_firedV
Fired pixels in V, per cm2 and second, zero-suppression threshold.
double m_expo
Exposition (energy deposited per cm2 and 1 second)
double m_firedV_t
Fired pixels in V, occupied time per cm2 and second.
double m_firedU
Fired pixels in U, per cm2 and second, zero-suppression threshold.
double m_occupancyU_APV
Occupancy in U, for 1 APV cycle.
double m_occupancyV_APV
Occupancy in V, for 1 APV cycle.