Belle II Software development
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// ROOT
17#include <TMath.h>
18
19//c++
20#include <string>
21#include <fstream>
22#include <vector>
23
24using namespace std;
25using namespace Belle2;
26using namespace dosi;
27
28
29//-----------------------------------------------------------------
30// Register the Module
31//-----------------------------------------------------------------
32REG_MODULE(DosiDigitizer);
33
34//-----------------------------------------------------------------
35// Implementation
36//-----------------------------------------------------------------
37
39{
40 // Set module properties
41 setDescription("Dosi digitizer module");
42
43}
44
46{
47}
48
50{
51 B2INFO("DosiDigitizer: Initializing");
52 m_dosiHit.registerInDataStore();
53
54 //get xml data
55 getXMLData();
56
57}
58
60{
61}
62
64{
65 StoreArray<DosiSimHit> DosiSimHits;
66 StoreArray<DosiHit> DosiHits;
67 int nentries = DosiSimHits.getEntries();
68 for (int i = 0; i < nentries; i++) {
69 DosiSimHit* aHit = DosiSimHits[i];
70 int m_cellID = aHit->getCellId();
71 int m_trackID = aHit->getTrackId();
72 int pdgCode = aHit->getPDGCode();
73 double m_Time = aHit->getFlightTime();
74 ROOT::Math::XYZVector m_Mom = aHit->getMomentum();
75 ROOT::Math::XYZVector m_Pos = aHit->getPosition();
76 double m_energyDeposit = aHit->getEnergyDep();
77 double erecdep = m_energyDeposit;
78 erecdep += gRandom->Gaus(0, GetEnergyResolutionGeV(m_energyDeposit, m_cellID));
79 DosiHits.appendNew(DosiHit(m_cellID, m_trackID, pdgCode, m_Time * m_energyDeposit / erecdep, m_energyDeposit, m_Mom,
80 m_Pos * (m_energyDeposit / erecdep), erecdep));
81 }
82
83}
84//read from DOSI.xml
86{
87 //GearDir content = GearDir("/Detector/DetectorComponent[@name=\"DOSI\"]/Content/");
88
89 B2INFO("DosiDigitizer: Aquired dosi locations and gas parameters");
90 B2INFO(" from DOSI.xml. There are " << nDOSI << " DOSIs implemented");
91
92}
93
94
95Double_t DosiDigitizerModule::GetEnergyResolutionGeV(Double_t pEnergy, int CellId)
96{
97 // Returns energy resolution in GeV when supplied Energy in GeV
98 return (m_EnergyResolutionFactor[CellId] * TMath::Sqrt(pEnergy) + m_EnergyResolutionConst[CellId] * pEnergy);
99
100}
101
102
104{
105}
106
108{
109}
110
111
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
ROOT::Math::XYZVector getMomentum() const
Get Momentum.
Definition: DosiSimHit.h:114
ROOT::Math::XYZVector 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.
DosiDigitizerModule()
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:650
Abstract base class for different kinds of events.
STL namespace.