Belle II Software  release-08-01-10
PXDBackgroundModule.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 
9 #pragma once
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 <pxd/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 PXD {
29 
45  class PXDBackgroundModule: public Module {
46 
47  public:
48 
49  // Reporting levels
50  static const unsigned short c_reportNone = 0;
51  static const unsigned short c_reportSummary = 1;
52  static const unsigned short c_reportNTuple = 2;
55  struct SensorData {
57  double m_expo;
59  double m_dose;
61  double m_neutronFlux;
63  double m_fired;
65  double m_occupancy;
66  };
67 
71  virtual ~PXDBackgroundModule();
72 
74  virtual void initialize() override;
76  virtual void beginRun() override;
78  virtual void event() override;
80  virtual void endRun() override;
82  virtual void terminate() override;
83 
84  private:
85 
86  // General
87  const double c_densitySi = 2.3290 * Unit::g_cm3;
88  const double c_smy = 1.0e7 * Unit::s;
90  const std::string c_niel_neutronFile = "/vxd/data/neutrons.csv";
92  const std::string c_niel_protonFile = "/vxd/data/protons.csv";
94  const std::string c_niel_pionFile = "/vxd/data/pions.csv";
96  const std::string c_niel_electronFile = "/vxd/data/electrons.csv";
97  // No NIEL for photons.
98 
103  inline const PXD::SensorInfo& getInfo(VxdID sensorID) const;
105  inline double getSensorThickness(VxdID sensorID) const;
107  inline double getSensorMass(VxdID sensorID) const;
109  inline double getSensorArea(VxdID sensorID) const;
110 
112  const ROOT::Math::XYZVector& pointToGlobal(VxdID sensorID, const ROOT::Math::XYZVector& local);
114  const ROOT::Math::XYZVector& vectorToGlobal(VxdID sensorID, const ROOT::Math::XYZVector& local);
115 
117  inline int getNumSensors(int layerNum);
119  inline int getTotalSensors();
120 
121  // Output directory
122  std::string m_outputDirectoryName;
124  std::string m_storeBgMetaDataName;
125  // StoreArrays
127  std::string m_storeSimHitsName;
128  std::string m_storeTrueHitsName;
130  std::string m_storeDigitsName;
133  std::string m_storeClustersName;
134  std::string m_relClusterDigitName;
141  unsigned short m_doseReportingLevel;
142  unsigned short m_nfluxReportingLevel;
143  unsigned short m_occupancyReportingLevel;
145  std::string m_componentName;
149  std::map<VxdID, SensorData> m_sensorData;
151  // NIEL tables
152  std::unique_ptr<TNiel> m_nielNeutrons;
153  std::unique_ptr<TNiel> m_nielProtons;
154  std::unique_ptr<TNiel> m_nielPions;
155  std::unique_ptr<TNiel> m_nielElectrons;
157  };
158 
159  inline const PXD::SensorInfo& PXDBackgroundModule::getInfo(VxdID sensorID) const
160  {
161  return dynamic_cast<const PXD::SensorInfo&>(VXD::GeoCache::get(sensorID));
162  }
163 
164  inline double PXDBackgroundModule::getSensorThickness(VxdID sensorID) const
165  {
166  return getInfo(sensorID).getThickness();
167  }
168 
169  inline double PXDBackgroundModule::getSensorMass(VxdID sensorID) const
170  {
171  const PXD::SensorInfo& info = getInfo(sensorID);
172  return info.getWidth() * info.getLength() * info.getThickness() * c_densitySi;
173  }
174 
175  inline double PXDBackgroundModule::getSensorArea(VxdID sensorID) const
176  {
177  const PXD::SensorInfo& info = getInfo(sensorID);
178  return info.getWidth() * info.getLength();
179  }
180 
181  inline int PXDBackgroundModule::getNumSensors(int layerNum)
182  {
183  VxdID layerID;
184  layerID.setLayerNumber(layerNum);
185  int result = 0;
186  for (auto ladderID : VXD::GeoCache::getInstance().getLadders(layerID))
187  result += VXD::GeoCache::getInstance().getSensors(ladderID).size();
188  return result;
189  }
190  } // namespace PXD
192 } // namespace Belle2
193 
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.
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
PXDEnergyDepositEvents StoreArray name.
const double c_smy
Seconds in snowmass year.
unsigned short m_doseReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
int getTotalSensors()
Get total number of sensors.
std::string m_storeOccupancyEventsName
PXDOccupancyEvents 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
PXDTrueHitsToPXDSimHits RelationArray name.
double m_integrationTime
Integration time of PXD.
std::string m_relDigitsMCParticlesName
StoreArray name of PXDDigits to MCParticles relation.
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
PXDClustersToPXDDigits 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
PXDNeutronFluxEvents StoreArray name.
std::string m_storeTrueHitsName
PXDTrueHits 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.
const PXD::SensorInfo & getInfo(VxdID sensorID) const
This is a shortcut to getting PXD::SensorInfo from the GeoCache.
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
PXDDigits StoreArray name.
std::string m_storeClustersName
PXDClusters StoreArray name.
std::unique_ptr< TNiel > m_nielElectrons
Pointer to Niel table for electrons.
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
MCParticlesToPXDTrueHits RelationArray name.
std::string m_componentName
Name of the current bg component.
double m_componentTime
Time of current component.
unsigned short m_occupancyReportingLevel
0 - no data, 1 - summary only, 2 - ntuple
std::string m_storeSimHitsName
PXDSimHits StoreArray name.
std::string m_relDigitsTrueHitsName
StoreArray name of PXDDigits to PXDTrueHits relation.
virtual ~PXDBackgroundModule()
Destructor.
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Definition: SensorInfo.h:23
static const double g_cm3
Practical units with the value set at 1.
Definition: Unit.h:60
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 PXD sensor.
double m_expo
Exposition (energy deposited per cm2 and 1 second)
double m_fired
Fired pixels per cm2 and second, zero-suppression threshold.