Belle II Software  release-05-02-19
PXDBackgroundModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Benjamin Schwenker *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef PXDBackgroundMODULE_H_
12 #define PXDBackgroundMODULE_H_
13 
14 #include <framework/core/Module.h>
15 #include <framework/gearbox/Unit.h>
16 #include <vxd/dataobjects/VxdID.h>
17 #include <vxd/geometry/SensorInfoBase.h>
18 #include <pxd/geometry/SensorInfo.h>
19 #include <vxd/geometry/GeoCache.h>
20 #include <string>
21 #include <memory>
22 #include <map>
23 #include <vxd/background/niel_fun.h>
24 
25 namespace Belle2 {
31  namespace PXD {
32 
48  class PXDBackgroundModule: public Module {
49 
50  public:
51 
52  // Reporting levels
53  static const unsigned short c_reportNone = 0;
54  static const unsigned short c_reportSummary = 1;
55  static const unsigned short c_reportNTuple = 2;
58  struct SensorData {
60  double m_expo;
62  double m_dose;
64  double m_neutronFlux;
66  double m_fired;
68  double m_occupancy;
69  };
70 
75 
76  /* Initialize module */
77  virtual void initialize() override;
78  /* Start-of-run initializations */
79  virtual void beginRun() override;
80  /* Event processing */
81  virtual void event() override;
82  /* End-of-run tasks */
83  virtual void endRun() override;
84  /* Final summary and cleanup */
85  virtual void terminate() override;
86 
87  private:
88 
89  // General
90  const double c_densitySi = 2.3290 * Unit::g_cm3;
91  const double c_smy = 1.0e7 * Unit::s;
93  const std::string c_niel_neutronFile = "/vxd/data/neutrons.csv";
95  const std::string c_niel_protonFile = "/vxd/data/protons.csv";
97  const std::string c_niel_pionFile = "/vxd/data/pions.csv";
99  const std::string c_niel_electronFile = "/vxd/data/electrons.csv";
100  // No NIEL for photons.
101 
106  inline const PXD::SensorInfo& getInfo(VxdID sensorID) const;
108  inline double getSensorThickness(VxdID sensorID) const;
110  inline double getSensorMass(VxdID sensorID) const;
112  inline double getSensorArea(VxdID sensorID) const;
113 
115  const TVector3& pointToGlobal(VxdID sensorID, const TVector3& local);
117  const TVector3& vectorToGlobal(VxdID sensorID, const TVector3& local);
118 
120  inline int getNumSensors(int layerNum);
122  inline int getTotalSensors();
123 
124  // Output directory
125  std::string m_outputDirectoryName;
126  std::string m_storeFileMetaDataName;
127  std::string m_storeBgMetaDataName;
128  // StoreArrays
129  std::string m_storeMCParticlesName;
130  std::string m_storeSimHitsName;
131  std::string m_storeTrueHitsName;
132  std::string m_relParticlesTrueHitsName;
133  std::string m_storeDigitsName;
136  std::string m_storeClustersName;
137  std::string m_relClusterDigitName;
144  unsigned short m_doseReportingLevel;
145  unsigned short m_nfluxReportingLevel;
146  unsigned short m_occupancyReportingLevel;
148  std::string m_componentName;
152  std::map<VxdID, SensorData> m_sensorData;
154  // NIEL tables
155  std::unique_ptr<TNiel> m_nielNeutrons;
156  std::unique_ptr<TNiel> m_nielProtons;
157  std::unique_ptr<TNiel> m_nielPions;
158  std::unique_ptr<TNiel> m_nielElectrons;
160  };
161 
162  inline const PXD::SensorInfo& PXDBackgroundModule::getInfo(VxdID sensorID) const
163  {
164  return dynamic_cast<const PXD::SensorInfo&>(VXD::GeoCache::get(sensorID));
165  }
166 
167  inline double PXDBackgroundModule::getSensorThickness(VxdID sensorID) const
168  {
169  return getInfo(sensorID).getThickness();
170  }
171 
172  inline double PXDBackgroundModule::getSensorMass(VxdID sensorID) const
173  {
174  const PXD::SensorInfo& info = getInfo(sensorID);
175  return info.getWidth() * info.getLength() * info.getThickness() * c_densitySi;
176  }
177 
178  inline double PXDBackgroundModule::getSensorArea(VxdID sensorID) const
179  {
180  const PXD::SensorInfo& info = getInfo(sensorID);
181  return info.getWidth() * info.getLength();
182  }
183 
184  inline int PXDBackgroundModule::getNumSensors(int layerNum)
185  {
186  VxdID layerID;
187  layerID.setLayerNumber(layerNum);
188  int result = 0;
189  for (auto ladderID : VXD::GeoCache::getInstance().getLadders(layerID))
190  result += VXD::GeoCache::getInstance().getSensors(ladderID).size();
191  return result;
192  }
193  } // namespace PXD
195 } // namespace Belle2
196 #endif
197 
Belle2::PXD::PXDBackgroundModule::m_nielPions
std::unique_ptr< TNiel > m_nielPions
Pointer to Niel table for pions.
Definition: PXDBackgroundModule.h:165
Belle2::PXD::PXDBackgroundModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: PXDBackgroundModule.cc:131
Belle2::Unit::s
static const double s
[second]
Definition: Unit.h:105
Belle2::PXD::PXDBackgroundModule::m_outputDirectoryName
std::string m_outputDirectoryName
Path to directory where output data will be stored.
Definition: PXDBackgroundModule.h:133
Belle2::PXD::PXDBackgroundModule::vectorToGlobal
const TVector3 & vectorToGlobal(VxdID sensorID, const TVector3 &local)
Convert local vector coordinates to global.
Definition: PXDBackgroundModule.cc:76
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::PXD::PXDBackgroundModule::pointToGlobal
const TVector3 & pointToGlobal(VxdID sensorID, const TVector3 &local)
Convert local sensor coordinates to global.
Definition: PXDBackgroundModule.cc:67
Belle2::PXD::PXDBackgroundModule::SensorData::m_occupancy
double m_occupancy
Occupancy.
Definition: PXDBackgroundModule.h:76
Belle2::PXD::PXDBackgroundModule::m_relTrueHitsSimHitsName
std::string m_relTrueHitsSimHitsName
PXDTrueHitsToPXDSimHits RelationArray name.
Definition: PXDBackgroundModule.h:146
Belle2::PXD::PXDBackgroundModule::m_storeEnergyDepositsName
std::string m_storeEnergyDepositsName
PXDEnergyDepositEvents StoreArray name.
Definition: PXDBackgroundModule.h:148
Belle2::PXD::PXDBackgroundModule::m_nfluxReportingLevel
unsigned short m_nfluxReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
Definition: PXDBackgroundModule.h:153
Belle2::PXD::PXDBackgroundModule::getInfo
const PXD::SensorInfo & getInfo(VxdID sensorID) const
This is a shortcut to getting PXD::SensorInfo from the GeoCache.
Definition: PXDBackgroundModule.h:170
Belle2::PXD::PXDBackgroundModule::m_storeOccupancyEventsName
std::string m_storeOccupancyEventsName
PXDOccupancyEvents StoreArray name.
Definition: PXDBackgroundModule.h:150
Belle2::PXD::PXDBackgroundModule::m_storeMCParticlesName
std::string m_storeMCParticlesName
MCParticles StoreArray name.
Definition: PXDBackgroundModule.h:137
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::PXD::PXDBackgroundModule::c_reportSummary
static const unsigned short c_reportSummary
Summary only.
Definition: PXDBackgroundModule.h:62
Belle2::PXD::PXDBackgroundModule::m_relClusterDigitName
std::string m_relClusterDigitName
PXDClustersToPXDDigits RelationArray name.
Definition: PXDBackgroundModule.h:145
Belle2::PXD::PXDBackgroundModule::m_nielNeutrons
std::unique_ptr< TNiel > m_nielNeutrons
Pointer to Niel table for neutrons.
Definition: PXDBackgroundModule.h:163
Belle2::PXD::PXDBackgroundModule::m_storeClustersName
std::string m_storeClustersName
PXDClusters StoreArray name.
Definition: PXDBackgroundModule.h:144
Belle2::PXD::PXDBackgroundModule::c_niel_electronFile
const std::string c_niel_electronFile
NIEL-correction file for electrons.
Definition: PXDBackgroundModule.h:107
Belle2::PXD::PXDBackgroundModule::m_storeTrueHitsName
std::string m_storeTrueHitsName
PXDTrueHits StoreArray name.
Definition: PXDBackgroundModule.h:139
Belle2::VxdID::setLayerNumber
void setLayerNumber(baseType layer)
Set the layer id.
Definition: VxdID.h:117
Belle2::PXD::PXDBackgroundModule::getNumSensors
int getNumSensors(int layerNum)
Get number of sensors in a layer.
Definition: PXDBackgroundModule.h:192
Belle2::PXD::PXDBackgroundModule::m_doseReportingLevel
unsigned short m_doseReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
Definition: PXDBackgroundModule.h:152
Belle2::PXD::PXDBackgroundModule::m_relParticlesTrueHitsName
std::string m_relParticlesTrueHitsName
MCParticlesToPXDTrueHits RelationArray name.
Definition: PXDBackgroundModule.h:140
Belle2::PXD::PXDBackgroundModule::m_sensorData
std::map< VxdID, SensorData > m_sensorData
Struct to hold sensor-wise background data.
Definition: PXDBackgroundModule.h:160
Belle2::PXD::PXDBackgroundModule::c_reportNTuple
static const unsigned short c_reportNTuple
Summary and NTuple.
Definition: PXDBackgroundModule.h:63
Belle2::PXD::PXDBackgroundModule::m_occupancyReportingLevel
unsigned short m_occupancyReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
Definition: PXDBackgroundModule.h:154
Belle2::PXD::PXDBackgroundModule::getSensorArea
double getSensorArea(VxdID sensorID) const
Return area of the sensor with the given sensor ID.
Definition: PXDBackgroundModule.h:186
Belle2::PXD::PXDBackgroundModule::SensorData::m_neutronFlux
double m_neutronFlux
Neutron flux.
Definition: PXDBackgroundModule.h:72
Belle2::PXD::PXDBackgroundModule::m_relDigitsTrueHitsName
std::string m_relDigitsTrueHitsName
StoreArray name of PXDDigits to PXDTrueHits relation.
Definition: PXDBackgroundModule.h:143
Belle2::PXD::PXDBackgroundModule::m_nielProtons
std::unique_ptr< TNiel > m_nielProtons
Pointer to Niel table for protons.
Definition: PXDBackgroundModule.h:164
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::PXD::PXDBackgroundModule::m_nielElectrons
std::unique_ptr< TNiel > m_nielElectrons
Pointer to Niel table for electrons.
Definition: PXDBackgroundModule.h:166
Belle2::PXD::PXDBackgroundModule::c_niel_neutronFile
const std::string c_niel_neutronFile
NIEL-correction file for neutrons.
Definition: PXDBackgroundModule.h:101
Belle2::PXD::SensorInfo
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Definition: SensorInfo.h:34
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::PXD::PXDBackgroundModule::c_niel_protonFile
const std::string c_niel_protonFile
NIEL-correction file for protons.
Definition: PXDBackgroundModule.h:103
Belle2::PXD::PXDBackgroundModule::c_smy
const double c_smy
Seconds in snowmass year.
Definition: PXDBackgroundModule.h:99
Belle2::PXD::PXDBackgroundModule::m_storeBgMetaDataName
std::string m_storeBgMetaDataName
Name of the persistent BackgroundMetaDta object.
Definition: PXDBackgroundModule.h:135
Belle2::PXD::PXDBackgroundModule::m_componentTime
double m_componentTime
Time of current component.
Definition: PXDBackgroundModule.h:157
Belle2::PXD::PXDBackgroundModule::SensorData::m_dose
double m_dose
Dose (Gy/smy)
Definition: PXDBackgroundModule.h:70
Belle2::PXD::PXDBackgroundModule::getSensorMass
double getSensorMass(VxdID sensorID) const
Return mass of the sensor with the given sensor ID.
Definition: PXDBackgroundModule.h:180
Belle2::PXD::PXDBackgroundModule::m_integrationTime
double m_integrationTime
Integration time of PXD.
Definition: PXDBackgroundModule.h:158
Belle2::PXD::PXDBackgroundModule::initialize
virtual void initialize() override
Initialize the Module.
Definition: PXDBackgroundModule.cc:89
Belle2::PXD::PXDBackgroundModule::terminate
virtual void terminate() override
This method is called at the end of the event processing.
Definition: PXDBackgroundModule.cc:360
Belle2::PXD::PXDBackgroundModule::event
virtual void event() override
This method is the core of the module.
Definition: PXDBackgroundModule.cc:135
Belle2::PXD::PXDBackgroundModule::m_relDigitsMCParticlesName
std::string m_relDigitsMCParticlesName
StoreArray name of PXDDigits to MCParticles relation.
Definition: PXDBackgroundModule.h:142
Belle2::PXD::PXDBackgroundModule::~PXDBackgroundModule
virtual ~PXDBackgroundModule()
Destructor.
Definition: PXDBackgroundModule.cc:85
Belle2::PXD::PXDBackgroundModule::m_storeFileMetaDataName
std::string m_storeFileMetaDataName
Name of the persistent FileMetaData object.
Definition: PXDBackgroundModule.h:134
Belle2::PXD::PXDBackgroundModule::getSensorThickness
double getSensorThickness(VxdID sensorID) const
Return thickness of the sensor with the given sensor ID.
Definition: PXDBackgroundModule.h:175
Belle2::PXD::PXDBackgroundModule::getTotalSensors
int getTotalSensors()
Get total number of sensors.
Belle2::PXD::PXDBackgroundModule::c_reportNone
static const unsigned short c_reportNone
No reporting.
Definition: PXDBackgroundModule.h:61
Belle2::PXD::PXDBackgroundModule::SensorData::m_fired
double m_fired
Fired pixels per cm2 and second, zero-suppression threshold.
Definition: PXDBackgroundModule.h:74
Belle2::PXD::PXDBackgroundModule::PXDBackgroundModule
PXDBackgroundModule()
Constructor.
Definition: PXDBackgroundModule.cc:41
Belle2::PXD::PXDBackgroundModule::c_niel_pionFile
const std::string c_niel_pionFile
NIEL-correction file for pions.
Definition: PXDBackgroundModule.h:105
Belle2::PXD::PXDBackgroundModule::endRun
virtual void endRun() override
This method is called if the current run ends.
Definition: PXDBackgroundModule.cc:355
Belle2::PXD::PXDBackgroundModule::m_storeNeutronFluxesName
std::string m_storeNeutronFluxesName
PXDNeutronFluxEvents StoreArray name.
Definition: PXDBackgroundModule.h:149
Belle2::PXD::PXDBackgroundModule::m_storeSimHitsName
std::string m_storeSimHitsName
PXDSimHits StoreArray name.
Definition: PXDBackgroundModule.h:138
Belle2::PXD::PXDBackgroundModule::c_densitySi
const double c_densitySi
Density of crystalline Silicon.
Definition: PXDBackgroundModule.h:98
Belle2::PXD::PXDBackgroundModule::SensorData::m_expo
double m_expo
Exposition (energy deposited per cm2 and 1 second)
Definition: PXDBackgroundModule.h:68
Belle2::PXD::PXDBackgroundModule::m_componentName
std::string m_componentName
Name of the current bg component.
Definition: PXDBackgroundModule.h:156
Belle2::Unit::g_cm3
static const double g_cm3
Practical units with the value set at 1.
Definition: Unit.h:70
Belle2::PXD::PXDBackgroundModule::m_storeDigitsName
std::string m_storeDigitsName
PXDDigits StoreArray name.
Definition: PXDBackgroundModule.h:141