Belle II Software development
BgoDigitizerModule.cc
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#include <beast/bgo/modules/BgoDigitizerModule.h>
10#include <beast/bgo/dataobjects/BgoSimHit.h>
11
12#include <framework/logging/Logger.h>
13#include <framework/gearbox/GearDir.h>
14
15// ROOT
16#include <Math/Vector3D.h>
17#include <TMath.h>
18#include <TRandom.h>
19
20//c++
21#include <string>
22#include <vector>
23
24using namespace std;
25using namespace Belle2;
26using namespace bgo;
27
28
29//-----------------------------------------------------------------
30// Register the Module
31//-----------------------------------------------------------------
32REG_MODULE(BgoDigitizer);
33
34//-----------------------------------------------------------------
35// Implementation
36//-----------------------------------------------------------------
37
39{
40 // Set module properties
41 setDescription("Bgo digitizer module");
42
43 //Default values are set here. New values can be in BGO.xml.
44 //addParam("EnergyResolutionFactor", m_EnergyResolutionFactor, "Energy resolution factor ");
45 //addParam("EnergyResolutionConst", m_EnergyResolutionConst, "Energy resolution constant ");
46 //addParam("Threshold", m_Threshold, "Energy threshold");
47 //addParam("Range", m_Range, "Energy range")
48}
49
51{
52}
53
55{
56 B2INFO("BgoDigitizer: Initializing");
57 m_bgoHit.registerInDataStore();
58
59 //get xml data
60 getXMLData();
61
62}
63
65{
66}
67
69{
70 StoreArray<BgoSimHit> BgoSimHits;
71 StoreArray<BgoHit> BgoHits;
72 int nentries = BgoSimHits.getEntries();
73 for (int i = 0; i < nentries; i++) {
74 BgoSimHit* aHit = BgoSimHits[i];
75 int m_cellID = aHit->getCellId();
76 int m_trackID = aHit->getTrackId();
77 int pdgCode = aHit->getPDGCode();
78 double m_Time = aHit->getFlightTime();
79 ROOT::Math::XYZVector m_Mom = aHit->getMomentum();
80 ROOT::Math::XYZVector m_Pos = aHit->getPosition();
81 double m_energyDeposit = aHit->getEnergyDep();
82 double erecdep = m_energyDeposit;
83 erecdep += gRandom->Gaus(0, GetEnergyResolutionGeV(m_energyDeposit, m_cellID));
84 //if (m_Threshold[m_cellID] <= erecdep && erecdep <= m_Range[m_cellID]) {
85 BgoHits.appendNew(BgoHit(m_cellID, m_trackID, pdgCode, m_Time * m_energyDeposit / erecdep, m_energyDeposit, m_Mom,
86 m_Pos * (m_energyDeposit / erecdep), erecdep));
87 //}
88 }
89
90}
91//read from BGO.xml
93{
94 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"BGO\"]/Content/");
95
96 //m_EnergyResolutionConst = content.getDouble("EnergyResolutionConst");
97 //m_EnergyResolutionFactor = content.getDouble("EnergyResolutionFactor");
98 int iEnResConst = 0;
99 for (double EnResConst : content.getArray("EnergyResolutionConst", {0})) {
100 m_EnergyResolutionConst[iEnResConst] = EnResConst;
101 iEnResConst++;
102 }
103 int iEnResFac = 0;
104 for (double EnResFac : content.getArray("EnergyResolutionFactor", {0})) {
105 m_EnergyResolutionFactor[iEnResFac] = EnResFac / 100.;
106 iEnResFac++;
107 }
108 int iThres = 0;
109 for (double Threshold : content.getArray("Threshold", {0})) {
110 //Threshold *= CLHEP::GeV;
111 m_Threshold[iThres] = Threshold;
112 iThres++;
113 }
114 int iRange = 0;
115 for (double Range : content.getArray("Range", {0})) {
116 //Range *= CLHEP::GeV;
117 m_Range[iRange] = Range;
118 iRange++;
119 }
120
121 B2INFO("BgoDigitizer: Acquired bgo locations and gas parameters");
122 B2INFO(" from BGO.xml. There are " << nBGO << " BGOs implemented");
123
124}
125
126
127Double_t BgoDigitizerModule::GetEnergyResolutionGeV(Double_t pEnergy, int CellId)
128{
129 // Returns energy resolution in GeV when supplied Energy in GeV
130 return (m_EnergyResolutionFactor[CellId] * TMath::Sqrt(pEnergy) + m_EnergyResolutionConst[CellId] * pEnergy);
131
132}
133
134
136{
137}
138
140{
141}
142
143
ClassBgoHit - Geant4 ulated hit for the Bgo crystal in beast.
Definition: BgoHit.h:31
ClassBgoSimHit - Geant4 simulated hit for the Bgo crystal in beast.
Definition: BgoSimHit.h:31
int getPDGCode() const
Get Particle PDG (can be one of secondaries)
Definition: BgoSimHit.h:99
int getTrackId() const
Get Track ID.
Definition: BgoSimHit.h:94
int getCellId() const
Get Cell ID.
Definition: BgoSimHit.h:89
double getFlightTime() const
Get Flight time from IP.
Definition: BgoSimHit.h:104
double getEnergyDep() const
Get Deposit energy.
Definition: BgoSimHit.h:109
ROOT::Math::XYZVector getMomentum() const
Get Momentum.
Definition: BgoSimHit.h:114
ROOT::Math::XYZVector getPosition() const
Get Position.
Definition: BgoSimHit.h:124
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
Represents a range of arithmetic types.
Definition: Range.h:29
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
int nBGO
number of detectors.
BgoDigitizerModule()
Constructor: Sets the description, the properties and the parameters of the module.
virtual void initialize() override
Initialize the Module.
double m_EnergyResolutionConst[8]
Energy resolution constant.
virtual void event() override
Event processor.
virtual ~BgoDigitizerModule()
Destructor.
double m_Threshold[8]
Energy threshold.
virtual void endRun() override
End-of-run action.
virtual void getXMLData()
reads data from BGO.xml: threshold in MeV, range in MeV, and resolution in %
double m_EnergyResolutionFactor[8]
Energy resolution factor.
virtual void terminate() override
Termination action.
StoreArray< BgoHit > m_bgoHit
Array for Bgo Hits.
virtual void beginRun() override
Called when entering a new run.
double m_Range[8]
Energy range.
Double_t GetEnergyResolutionGeV(Double_t, Int_t)
Fold energy resolution.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:649
Abstract base class for different kinds of events.
STL namespace.