Belle II Software  release-05-02-19
SVDBackgroundModule.h
1 #ifndef SVDBackgroundMODULE_H_
2 #define SVDBackgroundMODULE_H_
3 
4 #include <framework/core/Module.h>
5 #include <framework/gearbox/Unit.h>
6 #include <vxd/dataobjects/VxdID.h>
7 #include <vxd/geometry/SensorInfoBase.h>
8 #include <svd/geometry/SensorInfo.h>
9 #include <vxd/geometry/GeoCache.h>
10 #include <string>
11 #include <memory>
12 #include <map>
13 #include <vxd/background/niel_fun.h>
14 
15 namespace Belle2 {
21  namespace SVD {
22 
43  /* Modification Jan 2016:
44  * 1. Delete all histogramming, only produce n-tuples and text file
45  * with summaries. The HistogramFactory class is not used any longer.
46  * All drawing will be done in pandas.
47  * 2. Only process one background component at a time.
48  * 3. Add occupancy estimates and a separate ntuple to hold the data.
49  */
50  /* Modifications Feb 2016:
51  * Add more information on fired strips rate and related occupancy estmates:
52  * 1. Two strip firing rates:
53  * - one with threshold equal to threshold cut, to provide check for occupancy estimates
54  * - another with threshold equal to elNoise
55  * 2. Two occupancies:
56  * - one for time of 1 APV cycle, no SNR adjustment
57  * - one for trigger jitter of 5 ns + testbeam-based hit time error
58  *
59  * Make module functionality switchable:
60  * - Add module parameters to turn on/off dose, neutron flux, and occupancy data collection.
61  */
62 
66  class SVDBackgroundModule: public Module {
67 
68  public:
71  static const int c_nVXDLayers = 6;
72 
73  // Reporting levels
74  static const unsigned short c_reportNone = 0;
75  static const unsigned short c_reportSummary = 1;
76  static const unsigned short c_reportNTuple = 2;
79  struct SensorData {
81  double m_expo;
83  double m_dose;
85  double m_neutronFlux;
87  double m_firedU;
89  double m_firedV;
91  double m_firedU_t;
93  double m_firedV_t;
95  double m_occupancyU;
97  double m_occupancyV;
102  };
103 
107  virtual ~SVDBackgroundModule();
108 
109  /* Initialize module */
110  virtual void initialize() override;
111  /* Start-of-run initializations */
112  virtual void beginRun() override;
113  /* Event processing */
114  virtual void event() override;
115  /* End-of-run tasks */
116  virtual void endRun() override;
117  /* Final summary and cleanup */
118  virtual void terminate() override;
119 
120  private:
121 
122  // General
123  const double c_densitySi = 2.3290 * Unit::g_cm3;
124  const double c_smy = 1.0e7 * Unit::s;
125  const double c_APVCycleTime = 31.44 * Unit::ns;
126  // NIEL file names - placed in vxd/data, so needn't be module parameters.
128  const std::string c_niel_neutronFile = "/vxd/data/neutrons.csv";
130  const std::string c_niel_protonFile = "/vxd/data/protons.csv";
132  const std::string c_niel_pionFile = "/vxd/data/pions.csv";
134  const std::string c_niel_electronFile = "/vxd/data/electrons.csv";
135  // No NIEL for photons.
136 
141  inline const SVD::SensorInfo& getInfo(VxdID sensorID) const;
143  inline double getSensorThickness(VxdID sensorID) const;
145  inline double getSensorMass(VxdID sensorID) const;
147  inline double getSensorArea(VxdID sensorID) const;
148 
150  const TVector3& pointToGlobal(VxdID sensorID, const TVector3& local);
152  const TVector3& vectorToGlobal(VxdID sensorID, const TVector3& local);
153 
155  inline int getNumSensors(int layerNum);
157  inline int getTotalSensors();
158 
159  // Output directory
160  std::string m_outputDirectoryName;
162  std::string m_storeBgMetaDataName;
163  // StoreArrays
165  std::string m_storeSimHitsName;
166  std::string m_storeTrueHitsName;
168  std::string m_storeDigitsName;
171  std::string m_storeClustersName;
172  std::string m_relClusterDigitName;
179  unsigned short m_doseReportingLevel;
180  unsigned short m_nfluxReportingLevel;
181  unsigned short m_occupancyReportingLevel;
183  std::string m_componentName;
185  double m_triggerWidth;
188  std::map<VxdID, SensorData> m_sensorData;
190  // NIEL tables
191  std::unique_ptr<TNiel> m_nielNeutrons;
192  std::unique_ptr<TNiel> m_nielProtons;
193  std::unique_ptr<TNiel> m_nielPions;
194  std::unique_ptr<TNiel> m_nielElectrons;
196  };
197 
198  inline const SVD::SensorInfo& SVDBackgroundModule::getInfo(VxdID sensorID) const
199  {
200  return dynamic_cast<const SVD::SensorInfo&>(VXD::GeoCache::get(sensorID));
201  }
202 
203  inline double SVDBackgroundModule::getSensorThickness(VxdID sensorID) const
204  {
205  return getInfo(sensorID).getThickness();
206  }
207 
208  inline double SVDBackgroundModule::getSensorMass(VxdID sensorID) const
209  {
210  const SVD::SensorInfo& info = getInfo(sensorID);
211  return info.getWidth() * info.getLength() * info.getThickness() * c_densitySi;
212  }
213 
214  inline double SVDBackgroundModule::getSensorArea(VxdID sensorID) const
215  {
216  const SVD::SensorInfo& info = getInfo(sensorID);
217  return info.getWidth() * info.getLength();
218  }
219 
220  inline int SVDBackgroundModule::getNumSensors(int layerNum)
221  {
222  VxdID layerID;
223  layerID.setLayerNumber(layerNum);
224  int result = 0;
225  for (auto ladderID : VXD::GeoCache::getInstance().getLadders(layerID))
226  result += VXD::GeoCache::getInstance().getSensors(ladderID).size();
227  return result;
228  }
229 
232  {
233  int result = 0;
234  for (auto layerID : VXD::GeoCache::getInstance().getLayers(VXD::SensorInfoBase::SVD))
235  result += getNumSensors(layerID.getLayerNumber());
236  return result;
237  }
238  } // namespace SVD
240 } // namespace Belle2
241 #endif
242 
Belle2::Unit::s
static const double s
[second]
Definition: Unit.h:105
Belle2::SVD::SVDBackgroundModule::m_nielElectrons
std::unique_ptr< TNiel > m_nielElectrons
Pointer to Niel table for electrons.
Definition: SVDBackgroundModule.h:194
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::SVD::SVDBackgroundModule::getSensorThickness
double getSensorThickness(VxdID sensorID) const
Return thickness of the sensor with the given sensor ID.
Definition: SVDBackgroundModule.h:203
Belle2::Unit::ns
static const double ns
Standard of [time].
Definition: Unit.h:58
Belle2::SVD::SVDBackgroundModule::m_componentTime
double m_componentTime
Time of current component.
Definition: SVDBackgroundModule.h:184
Belle2::SVD::SVDBackgroundModule::m_storeOccupancyEventsName
std::string m_storeOccupancyEventsName
SVDOccupancyEvents StoreArray name.
Definition: SVDBackgroundModule.h:177
Belle2::VXD::GeoCache::get
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Definition: GeoCache.h:141
Belle2::SVD::SVDBackgroundModule::m_relParticlesTrueHitsName
std::string m_relParticlesTrueHitsName
MCParticlesToSVDTrueHits RelationArray name.
Definition: SVDBackgroundModule.h:167
Belle2::SVD::SVDBackgroundModule::getTotalSensors
int getTotalSensors()
Get total number of sensors.
Definition: SVDBackgroundModule.h:231
Belle2::SVD::SVDBackgroundModule::m_nielNeutrons
std::unique_ptr< TNiel > m_nielNeutrons
Pointer to Niel table for neutrons.
Definition: SVDBackgroundModule.h:191
Belle2::SVD::SVDBackgroundModule::m_storeNeutronFluxesName
std::string m_storeNeutronFluxesName
SVDNeutronFluxEvents StoreArray name.
Definition: SVDBackgroundModule.h:176
Belle2::SVD::SVDBackgroundModule::m_nfluxReportingLevel
unsigned short m_nfluxReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
Definition: SVDBackgroundModule.h:180
Belle2::SVD::SVDBackgroundModule::m_doseReportingLevel
unsigned short m_doseReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
Definition: SVDBackgroundModule.h:179
Belle2::SVD::SVDBackgroundModule::c_nVXDLayers
static const int c_nVXDLayers
Number of VXD layers.
Definition: SVDBackgroundModule.h:71
Belle2::SVD::SVDBackgroundModule::m_relClusterDigitName
std::string m_relClusterDigitName
SVDClustersToSVDDigits RelationArray name.
Definition: SVDBackgroundModule.h:172
Belle2::SVD::SVDBackgroundModule::c_APVCycleTime
const double c_APVCycleTime
APV cycle time.
Definition: SVDBackgroundModule.h:125
Belle2::VxdID::setLayerNumber
void setLayerNumber(baseType layer)
Set the layer id.
Definition: VxdID.h:117
Belle2::SVD::SVDBackgroundModule::SVDBackgroundModule
SVDBackgroundModule()
Constructor.
Definition: SVDBackgroundModule.cc:52
Belle2::SVD::SVDBackgroundModule::m_storeEnergyDepositsName
std::string m_storeEnergyDepositsName
SVDEnergyDepositEvents StoreArray name.
Definition: SVDBackgroundModule.h:175
Belle2::SVD::SVDBackgroundModule::getInfo
const SVD::SensorInfo & getInfo(VxdID sensorID) const
This is a shortcut to getting SVD::SensorInfo from the GeoCache.
Definition: SVDBackgroundModule.h:198
Belle2::SVD::SensorInfo
Specific implementation of SensorInfo for SVD Sensors which provides additional sensor specific infor...
Definition: SensorInfo.h:35
Belle2::SVD::SVDBackgroundModule::initialize
virtual void initialize() override
Initialize the Module.
Definition: SVDBackgroundModule.cc:103
Belle2::SVD::SVDBackgroundModule::SensorData::m_firedV_t
double m_firedV_t
Fired pixels in V, occupied time per cm2 and second.
Definition: SVDBackgroundModule.h:93
Belle2::SVD::SVDBackgroundModule::m_relDigitsTrueHitsName
std::string m_relDigitsTrueHitsName
StoreArray name of SVDDigits to SVDTrueHits relation.
Definition: SVDBackgroundModule.h:170
Belle2::SVD::SVDBackgroundModule::SensorData::m_occupancyV
double m_occupancyV
Occupancy in V.
Definition: SVDBackgroundModule.h:97
Belle2::SVD::SVDBackgroundModule::c_reportNone
static const unsigned short c_reportNone
No reporting.
Definition: SVDBackgroundModule.h:74
Belle2::SVD::SVDBackgroundModule::m_relDigitsMCParticlesName
std::string m_relDigitsMCParticlesName
StoreArray name of SVDDigits to MCParticles relation.
Definition: SVDBackgroundModule.h:169
Belle2::SVD::SVDBackgroundModule::m_storeSimHitsName
std::string m_storeSimHitsName
SVDSimHits StoreArray name.
Definition: SVDBackgroundModule.h:165
Belle2::SVD::SVDBackgroundModule::c_niel_neutronFile
const std::string c_niel_neutronFile
NIEL-correction file for neutrons.
Definition: SVDBackgroundModule.h:128
Belle2::SVD::SVDBackgroundModule::m_storeMCParticlesName
std::string m_storeMCParticlesName
MCParticles StoreArray name.
Definition: SVDBackgroundModule.h:164
Belle2::SVD::SVDBackgroundModule::endRun
virtual void endRun() override
This method is called if the current run ends.
Definition: SVDBackgroundModule.cc:425
Belle2::VXD::GeoCache::getSensors
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:205
Belle2::SVD::SVDBackgroundModule::c_reportNTuple
static const unsigned short c_reportNTuple
Summary and NTuple.
Definition: SVDBackgroundModule.h:76
Belle2::SVD::SVDBackgroundModule::SensorData::m_neutronFlux
double m_neutronFlux
Neutron flux.
Definition: SVDBackgroundModule.h:85
Belle2::SVD::SVDBackgroundModule::m_componentName
std::string m_componentName
Name of the current component.
Definition: SVDBackgroundModule.h:183
Belle2::SVD::SVDBackgroundModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: SVDBackgroundModule.cc:146
Belle2::SVD::SVDBackgroundModule::SensorData::m_firedU
double m_firedU
Fired pixels in U, per cm2 and second, zero-suppression threshold.
Definition: SVDBackgroundModule.h:87
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::SVD::SVDBackgroundModule::SensorData
Struct to hold data of an SVD sensor.
Definition: SVDBackgroundModule.h:79
Belle2::SVD::SVDBackgroundModule::m_storeTrueHitsName
std::string m_storeTrueHitsName
SVDTrueHits StoreArray name.
Definition: SVDBackgroundModule.h:166
Belle2::SVD::SVDBackgroundModule::terminate
virtual void terminate() override
This method is called at the end of the event processing.
Definition: SVDBackgroundModule.cc:430
Belle2::SVD::SVDBackgroundModule::vectorToGlobal
const TVector3 & vectorToGlobal(VxdID sensorID, const TVector3 &local)
Convert local vector coordinates to global.
Definition: SVDBackgroundModule.cc:90
Belle2::SVD::SVDBackgroundModule::SensorData::m_expo
double m_expo
Exposition (energy deposited per cm2 and 1 second)
Definition: SVDBackgroundModule.h:81
Belle2::SVD::SVDBackgroundModule::c_reportSummary
static const unsigned short c_reportSummary
Summary only.
Definition: SVDBackgroundModule.h:75
Belle2::SVD::SVDBackgroundModule::c_smy
const double c_smy
Seconds in snowmass year.
Definition: SVDBackgroundModule.h:124
Belle2::SVD::SVDBackgroundModule::c_niel_protonFile
const std::string c_niel_protonFile
NIEL-correction file for protons.
Definition: SVDBackgroundModule.h:130
Belle2::VXD::GeoCache::getInstance
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:215
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::VXD::SensorInfoBase::getThickness
double getThickness() const
Return the thickness of the sensor.
Definition: SensorInfoBase.h:121
Belle2::SVD::SVDBackgroundModule::SensorData::m_firedV
double m_firedV
Fired pixels in V, per cm2 and second, zero-suppression threshold.
Definition: SVDBackgroundModule.h:89
Belle2::SVD::SVDBackgroundModule::m_storeClustersName
std::string m_storeClustersName
SVDClusters StoreArray name.
Definition: SVDBackgroundModule.h:171
Belle2::SVD::SVDBackgroundModule::m_storeDigitsName
std::string m_storeDigitsName
SVDDigits StoreArray name.
Definition: SVDBackgroundModule.h:168
Belle2::SVD::SVDBackgroundModule::m_nielPions
std::unique_ptr< TNiel > m_nielPions
Pointer to Niel table for pions.
Definition: SVDBackgroundModule.h:193
Belle2::SVD::SVDBackgroundModule::m_nielProtons
std::unique_ptr< TNiel > m_nielProtons
Pointer to Niel table for protons.
Definition: SVDBackgroundModule.h:192
Belle2::SVD::SVDBackgroundModule
SVD Background module.
Definition: SVDBackgroundModule.h:66
Belle2::VXD::SensorInfoBase::SVD
@ SVD
SVD Sensor.
Definition: SensorInfoBase.h:45
Belle2::SVD::SVDBackgroundModule::SensorData::m_occupancyU
double m_occupancyU
Occupancy in U.
Definition: SVDBackgroundModule.h:95
Belle2::SVD::SVDBackgroundModule::getSensorArea
double getSensorArea(VxdID sensorID) const
Return area of the sensor with the given sensor ID.
Definition: SVDBackgroundModule.h:214
Belle2::SVD::SVDBackgroundModule::c_niel_electronFile
const std::string c_niel_electronFile
NIEL-correction file for electrons.
Definition: SVDBackgroundModule.h:134
Belle2::SVD::SVDBackgroundModule::m_triggerWidth
double m_triggerWidth
RMS of trigger time measurement.
Definition: SVDBackgroundModule.h:185
Belle2::SVD::SVDBackgroundModule::m_acceptanceWidth
double m_acceptanceWidth
A hit is accepted if arrived within +/- m_acceptanceWidth * RMS(hit time - trigger time).
Definition: SVDBackgroundModule.h:186
Belle2::SVD::SVDBackgroundModule::~SVDBackgroundModule
virtual ~SVDBackgroundModule()
Destructor.
Definition: SVDBackgroundModule.cc:99
Belle2::SVD::SVDBackgroundModule::m_storeBgMetaDataName
std::string m_storeBgMetaDataName
Name of the persistent BackgroundMetaDta object.
Definition: SVDBackgroundModule.h:162
Belle2::SVD::SVDBackgroundModule::m_outputDirectoryName
std::string m_outputDirectoryName
Path to directory where output data will be stored.
Definition: SVDBackgroundModule.h:160
Belle2::SVD::SVDBackgroundModule::m_occupancyReportingLevel
unsigned short m_occupancyReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
Definition: SVDBackgroundModule.h:181
Belle2::SVD::SVDBackgroundModule::SensorData::m_occupancyV_APV
double m_occupancyV_APV
Occupancy in V, for 1 APV cycle.
Definition: SVDBackgroundModule.h:101
Belle2::SVD::SVDBackgroundModule::c_niel_pionFile
const std::string c_niel_pionFile
NIEL-correction file for pions.
Definition: SVDBackgroundModule.h:132
Belle2::SVD::SVDBackgroundModule::SensorData::m_occupancyU_APV
double m_occupancyU_APV
Occupancy in U, for 1 APV cycle.
Definition: SVDBackgroundModule.h:99
Belle2::SVD::SVDBackgroundModule::m_relTrueHitsSimHitsName
std::string m_relTrueHitsSimHitsName
SVDTrueHitsToSVDSimHits RelationArray name.
Definition: SVDBackgroundModule.h:173
Belle2::SVD::SVDBackgroundModule::getSensorMass
double getSensorMass(VxdID sensorID) const
Return mass of the sensor with the given sensor ID.
Definition: SVDBackgroundModule.h:208
Belle2::SVD::SVDBackgroundModule::SensorData::m_firedU_t
double m_firedU_t
Fired pixels in U, occupied time per cm2 and second.
Definition: SVDBackgroundModule.h:91
Belle2::SVD::SVDBackgroundModule::m_sensorData
std::map< VxdID, SensorData > m_sensorData
Struct to hold sensor-wise background data.
Definition: SVDBackgroundModule.h:188
Belle2::SVD::SVDBackgroundModule::m_storeFileMetaDataName
std::string m_storeFileMetaDataName
Name of the persistent FileMetaData object.
Definition: SVDBackgroundModule.h:161
Belle2::SVD::SVDBackgroundModule::SensorData::m_dose
double m_dose
Dose (Gy/smy)
Definition: SVDBackgroundModule.h:83
Belle2::SVD::SVDBackgroundModule::c_densitySi
const double c_densitySi
Density of crystalline Silicon.
Definition: SVDBackgroundModule.h:123
Belle2::Unit::g_cm3
static const double g_cm3
Practical units with the value set at 1.
Definition: Unit.h:70
Belle2::SVD::SVDBackgroundModule::getNumSensors
int getNumSensors(int layerNum)
Get number of sensors in a layer.
Definition: SVDBackgroundModule.h:220
Belle2::SVD::SVDBackgroundModule::event
virtual void event() override
This method is the core of the module.
Definition: SVDBackgroundModule.cc:150
Belle2::SVD::SVDBackgroundModule::pointToGlobal
const TVector3 & pointToGlobal(VxdID sensorID, const TVector3 &local)
Convert local sensor coordinates to global.
Definition: SVDBackgroundModule.cc:81