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#include <framework/core/RandomNumbers.h>
15
16// ROOT
17#include <Math/Vector3D.h>
18#include <TMath.h>
19
20//c++
21#include <string>
22#include <fstream>
23#include <vector>
24
25using namespace std;
26using namespace Belle2;
27using namespace bgo;
28
29
30//-----------------------------------------------------------------
31// Register the Module
32//-----------------------------------------------------------------
33REG_MODULE(BgoDigitizer);
34
35//-----------------------------------------------------------------
36// Implementation
37//-----------------------------------------------------------------
38
40{
41 // Set module properties
42 setDescription("Bgo digitizer module");
43
44 //Default values are set here. New values can be in BGO.xml.
45 //addParam("EnergyResolutionFactor", m_EnergyResolutionFactor, "Energy resolution factor ");
46 //addParam("EnergyResolutionConst", m_EnergyResolutionConst, "Energy resolution constant ");
47 //addParam("Threshold", m_Threshold, "Energy threshold");
48 //addParam("Range", m_Range, "Energy range")
49}
50
52{
53}
54
56{
57 B2INFO("BgoDigitizer: Initializing");
58 m_bgoHit.registerInDataStore();
59
60 //get xml data
61 getXMLData();
62
63}
64
66{
67}
68
70{
71 StoreArray<BgoSimHit> BgoSimHits;
72 StoreArray<BgoHit> BgoHits;
73 int nentries = BgoSimHits.getEntries();
74 for (int i = 0; i < nentries; i++) {
75 BgoSimHit* aHit = BgoSimHits[i];
76 int m_cellID = aHit->getCellId();
77 int m_trackID = aHit->getTrackId();
78 int pdgCode = aHit->getPDGCode();
79 double m_Time = aHit->getFlightTime();
80 ROOT::Math::XYZVector m_Mom = aHit->getMomentum();
81 ROOT::Math::XYZVector m_Pos = aHit->getPosition();
82 double m_energyDeposit = aHit->getEnergyDep();
83 double erecdep = m_energyDeposit;
84 erecdep += gRandom->Gaus(0, GetEnergyResolutionGeV(m_energyDeposit, m_cellID));
85 //if (m_Threshold[m_cellID] <= erecdep && erecdep <= m_Range[m_cellID]) {
86 BgoHits.appendNew(BgoHit(m_cellID, m_trackID, pdgCode, m_Time * m_energyDeposit / erecdep, m_energyDeposit, m_Mom,
87 m_Pos * (m_energyDeposit / erecdep), erecdep));
88 //}
89 }
90
91}
92//read from BGO.xml
94{
95 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"BGO\"]/Content/");
96
97 //m_EnergyResolutionConst = content.getDouble("EnergyResolutionConst");
98 //m_EnergyResolutionFactor = content.getDouble("EnergyResolutionFactor");
99 int iEnResConst = 0;
100 for (double EnResConst : content.getArray("EnergyResolutionConst", {0})) {
101 m_EnergyResolutionConst[iEnResConst] = EnResConst;
102 iEnResConst++;
103 }
104 int iEnResFac = 0;
105 for (double EnResFac : content.getArray("EnergyResolutionFactor", {0})) {
106 m_EnergyResolutionFactor[iEnResFac] = EnResFac / 100.;
107 iEnResFac++;
108 }
109 int iThres = 0;
110 for (double Threshold : content.getArray("Threshold", {0})) {
111 //Threshold *= CLHEP::GeV;
112 m_Threshold[iThres] = Threshold;
113 iThres++;
114 }
115 int iRange = 0;
116 for (double Range : content.getArray("Range", {0})) {
117 //Range *= CLHEP::GeV;
118 m_Range[iRange] = Range;
119 iRange++;
120 }
121
122 B2INFO("BgoDigitizer: Aquired bgo locations and gas parameters");
123 B2INFO(" from BGO.xml. There are " << nBGO << " BGOs implemented");
124
125}
126
127
128Double_t BgoDigitizerModule::GetEnergyResolutionGeV(Double_t pEnergy, int CellId)
129{
130 // Returns energy resolution in GeV when supplied Energy in GeV
131 return (m_EnergyResolutionFactor[CellId] * TMath::Sqrt(pEnergy) + m_EnergyResolutionConst[CellId] * pEnergy);
132
133}
134
135
137{
138}
139
141{
142}
143
144
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:650
Abstract base class for different kinds of events.
STL namespace.