Belle II Software  release-08-01-10
DosiDigitizerModule.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/dosi/modules/DosiDigitizerModule.h>
10 #include <beast/dosi/dataobjects/DosiSimHit.h>
11 
12 #include <framework/logging/Logger.h>
13 #include <framework/gearbox/GearDir.h>
14 #include <framework/core/RandomNumbers.h>
15 
16 //c++
17 #include <string>
18 #include <fstream>
19 #include <vector>
20 
21 using namespace std;
22 using namespace Belle2;
23 using namespace dosi;
24 
25 
26 //-----------------------------------------------------------------
27 // Register the Module
28 //-----------------------------------------------------------------
29 REG_MODULE(DosiDigitizer);
30 
31 //-----------------------------------------------------------------
32 // Implementation
33 //-----------------------------------------------------------------
34 
35 DosiDigitizerModule::DosiDigitizerModule() : Module()
36 {
37  // Set module properties
38  setDescription("Dosi digitizer module");
39 
40 }
41 
43 {
44 }
45 
47 {
48  B2INFO("DosiDigitizer: Initializing");
49  m_dosiHit.registerInDataStore();
50 
51  //get xml data
52  getXMLData();
53 
54 }
55 
57 {
58 }
59 
61 {
62  StoreArray<DosiSimHit> DosiSimHits;
63  StoreArray<DosiHit> DosiHits;
64  int nentries = DosiSimHits.getEntries();
65  for (int i = 0; i < nentries; i++) {
66  DosiSimHit* aHit = DosiSimHits[i];
67  int m_cellID = aHit->getCellId();
68  int m_trackID = aHit->getTrackId();
69  int pdgCode = aHit->getPDGCode();
70  double m_Time = aHit->getFlightTime();
71  TVector3 m_Mom = aHit->getMomentum();
72  TVector3 m_Pos = aHit->getPosition();
73  double m_energyDeposit = aHit->getEnergyDep();
74  double erecdep = m_energyDeposit;
75  erecdep += gRandom->Gaus(0, GetEnergyResolutionGeV(m_energyDeposit, m_cellID));
76  DosiHits.appendNew(DosiHit(m_cellID, m_trackID, pdgCode, m_Time * m_energyDeposit / erecdep, m_energyDeposit, m_Mom,
77  m_Pos * (m_energyDeposit / erecdep), erecdep));
78  }
79 
80 }
81 //read from DOSI.xml
83 {
84  //GearDir content = GearDir("/Detector/DetectorComponent[@name=\"DOSI\"]/Content/");
85 
86  B2INFO("DosiDigitizer: Aquired dosi locations and gas parameters");
87  B2INFO(" from DOSI.xml. There are " << nDOSI << " DOSIs implemented");
88 
89 }
90 
91 
92 Double_t DosiDigitizerModule::GetEnergyResolutionGeV(Double_t pEnergy, int CellId)
93 {
94  // Returns energy resolution in GeV when supplied Energy in GeV
95  return (m_EnergyResolutionFactor[CellId] * TMath::Sqrt(pEnergy) + m_EnergyResolutionConst[CellId] * pEnergy);
96 
97 }
98 
99 
101 {
102 }
103 
105 {
106 }
107 
108 
ClassDosiHit - Geant4 ulated hit for the Dosi crystal in beast.
Definition: DosiHit.h:31
ClassDosiSimHit - Geant4 simulated hit for the Dosi crystal in beast.
Definition: DosiSimHit.h:31
int getPDGCode() const
Get Particle PDG (can be one of secondaries)
Definition: DosiSimHit.h:99
int getTrackId() const
Get Track ID.
Definition: DosiSimHit.h:94
int getCellId() const
Get Cell ID.
Definition: DosiSimHit.h:89
double getFlightTime() const
Get Flight time from IP.
Definition: DosiSimHit.h:104
double getEnergyDep() const
Get Deposit energy.
Definition: DosiSimHit.h:109
TVector3 getMomentum() const
Get Momentum.
Definition: DosiSimHit.h:114
TVector3 getPosition() const
Get Position.
Definition: DosiSimHit.h:124
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
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.
double m_EnergyResolutionConst[8]
Energy resolution constant.
virtual void event() override
Event processor.
virtual void endRun() override
End-of-run action.
virtual void getXMLData()
reads data from DOSI.xml: threshold in MeV, range in MeV, and resolution in %
double m_EnergyResolutionFactor[8]
Energy threshold.
virtual void terminate() override
Termination action.
virtual void beginRun() override
Called when entering a new run.
StoreArray< DosiHit > m_dosiHit
array for DosiHit
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.