Belle II Software development
CsiDigitizer_v2Module.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/csi/modules/CsiDigitizer_v2Module.h>
10#include <beast/csi/dataobjects/CsiSimHit.h>
11
12#include <framework/logging/Logger.h>
13#include <framework/gearbox/GearDir.h>
14
15#include <TMath.h>
16#include <TRandom.h>
17
18//c++
19#include <string>
20#include <vector>
21
22using namespace std;
23using namespace Belle2;
24using namespace csi;
25
26
27//-----------------------------------------------------------------
28// Register the Module
29//-----------------------------------------------------------------
30REG_MODULE(CsiDigitizer_v2);
31
32//-----------------------------------------------------------------
33// Implementation
34//-----------------------------------------------------------------
35
37{
38 // Set module properties
39 setDescription("Csi digitizer_v2 module");
40
41 //Default values are set here. New values can be in CSI.xml.
42 //addParam("EnergyResolutionPureCsIFactor", m_EnergyResolutionPureCsIFactor, "Energy resolution factor ", 1.4);
43 //addParam("EnergyResolutionPureCsIConst", m_EnergyResolutionPureCsIConst, "Energy resolution constant ", 1.4);
44}
45
47{
48}
49
51{
52 B2INFO("CsiDigitizer_v2: Initializing");
53 m_csiHit_v2.registerInDataStore();
54
55 //get xml data
56 getXMLData();
57
58}
59
61{
62}
63
65{
66 StoreArray<CsiSimHit> CsiSimHits;
67 StoreArray<CsiHit_v2> CsiHits_v2;
68 int nentries = CsiSimHits.getEntries();
69 for (int i = 0; i < nentries; i++) {
70 CsiSimHit* aHit = CsiSimHits[i];
71 int m_cellID = aHit->getCellId();
72 int m_box = (int)m_cellID / 6;
73 int m_cry = m_cellID - m_box * 3;
74 int m_trackID = aHit->getTrackId();
75 int pdgCode = aHit->getPDGCode();
76 double m_Time = aHit->getFlightTime();
77 ROOT::Math::XYZVector m_Mom = aHit->getMomentum();
78 ROOT::Math::XYZVector m_Pos = aHit->getPosition();
79 double m_energyDeposit = aHit->getEnergyDep();
80 double erecdep = m_energyDeposit;
81 erecdep += gRandom->Gaus(0, GetEnergyResolutionGeV(m_energyDeposit, m_cry));
82 //if (m_Threshold[m_cry] <= erecdep && erecdep <= m_Range[m_cry]) {
83 CsiHits_v2.appendNew(CsiHit_v2(m_cellID, m_trackID, pdgCode, m_Time * m_energyDeposit / erecdep, m_energyDeposit, m_Mom,
84 m_Pos * (m_energyDeposit / erecdep), erecdep));
85 //}
86 }
87
88}
89//read from CSI.xml
91{
92 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"CSI\"]/Content/");
93
94 int iEnergyResolutionConst = 0;
95 for (double EnergyResolutionConst : content.getArray("EnergyResolutionConst", {0})) {
96 m_EnergyResolutionConst[iEnergyResolutionConst] = EnergyResolutionConst;
97 iEnergyResolutionConst++;
98 }
99 int iEnergyResolutionFactor = 0;
100 for (double EnergyResolutionFactor : content.getArray("EnergyResolutionFactor", {0})) {
101 m_EnergyResolutionFactor[iEnergyResolutionFactor] = EnergyResolutionFactor;
102 iEnergyResolutionFactor++;
103 }
104 int iThres = 0;
105 for (double Threshold : content.getArray("Threshold", {0})) {
106 //Threshold *= CLHEP::GeV;
107 m_Threshold[iThres] = Threshold;
108 iThres++;
109 }
110 int iRange = 0;
111 for (double Range : content.getArray("Range", {0})) {
112 //Range *= CLHEP::GeV;
113 m_Range[iRange] = Range;
114 iRange++;
115 }
116
117 B2INFO("CsiDigitizer_V2: Acquired csi locations and gas parameters");
118 B2INFO(" from CSI.xml. There are " << nCSI << " CSIs implemented");
119
120}
121
122
123Double_t CsiDigitizer_v2Module::GetEnergyResolutionGeV(Double_t pEnergy, int pcry)
124{
125 // Returns energy resolution in GeV when supplied Energy in GeV
126 return (m_EnergyResolutionFactor[pcry] * TMath::Sqrt(pEnergy) + m_EnergyResolutionConst[pcry] * pEnergy);
127
128}
129
130
132{
133}
134
136{
137}
138
139
ClassCsiHit_v2 - Geant4 simulated hits in CsI crystals in BEAST.
Definition: CsiHit_v2.h:31
ClassCsiSimHit - Geant4 simulated hits in CsI crystals in BEAST.
Definition: CsiSimHit.h:31
int getPDGCode() const
Get Particle PDG (can be one of secondaries)
Definition: CsiSimHit.h:97
int getTrackId() const
Get Track ID.
Definition: CsiSimHit.h:92
int getCellId() const
Get Cell ID.
Definition: CsiSimHit.h:87
double getFlightTime() const
Get Flight time from IP.
Definition: CsiSimHit.h:102
double getEnergyDep() const
Get Deposit energy.
Definition: CsiSimHit.h:107
ROOT::Math::XYZVector getMomentum() const
Get Momentum.
Definition: CsiSimHit.h:112
ROOT::Math::XYZVector getPosition() const
Get Position.
Definition: CsiSimHit.h:122
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
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
double m_EnergyResolutionConst[18]
Energy resolution constant.
Double_t GetEnergyResolutionGeV(Double_t, int)
Fold energy resolution.
virtual void endRun() override
End-of-run action.
virtual void getXMLData()
reads data from CSI.xml: threshold in MeV, range in MeV, and resolution in %
virtual void terminate() override
Termination action.
StoreArray< CsiHit_v2 > m_csiHit_v2
array for CsiHit_v2
virtual void beginRun() override
Called when entering a new run.
double m_Threshold[18]
Energy threshold.
double m_EnergyResolutionFactor[18]
Energy resolution factor.
CsiDigitizer_v2Module()
Constructor: Sets the description, the properties and the parameters of the module.
#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.