Belle II Software  release-05-01-25
DosiDigitizerModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Igal Jaegle *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <beast/dosi/modules/DosiDigitizerModule.h>
12 #include <beast/dosi/dataobjects/DosiSimHit.h>
13 
14 #include <framework/logging/Logger.h>
15 #include <framework/gearbox/GearDir.h>
16 #include <framework/core/RandomNumbers.h>
17 
18 //c++
19 #include <string>
20 #include <fstream>
21 #include <vector>
22 
23 using namespace std;
24 using namespace Belle2;
25 using namespace dosi;
26 
27 
28 //-----------------------------------------------------------------
29 // Register the Module
30 //-----------------------------------------------------------------
31 REG_MODULE(DosiDigitizer)
32 
33 //-----------------------------------------------------------------
34 // Implementation
35 //-----------------------------------------------------------------
36 
38 {
39  // Set module properties
40  setDescription("Dosi digitizer module");
41 
42 }
43 
44 DosiDigitizerModule::~DosiDigitizerModule()
45 {
46 }
47 
48 void DosiDigitizerModule::initialize()
49 {
50  B2INFO("DosiDigitizer: Initializing");
51  m_dosiHit.registerInDataStore();
52 
53  //get xml data
54  getXMLData();
55 
56 }
57 
58 void DosiDigitizerModule::beginRun()
59 {
60 }
61 
62 void DosiDigitizerModule::event()
63 {
64  StoreArray<DosiSimHit> DosiSimHits;
65  StoreArray<DosiHit> DosiHits;
66  int nentries = DosiSimHits.getEntries();
67  for (int i = 0; i < nentries; i++) {
68  DosiSimHit* aHit = DosiSimHits[i];
69  int m_cellID = aHit->getCellId();
70  int m_trackID = aHit->getTrackId();
71  int pdgCode = aHit->getPDGCode();
72  double m_Time = aHit->getFlightTime();
73  TVector3 m_Mom = aHit->getMomentum();
74  TVector3 m_Pos = aHit->getPosition();
75  double m_energyDeposit = aHit->getEnergyDep();
76  double erecdep = m_energyDeposit;
77  erecdep += gRandom->Gaus(0, GetEnergyResolutionGeV(m_energyDeposit, m_cellID));
78  DosiHits.appendNew(DosiHit(m_cellID, m_trackID, pdgCode, m_Time * m_energyDeposit / erecdep, m_energyDeposit, m_Mom,
79  m_Pos * (m_energyDeposit / erecdep), erecdep));
80  }
81 
82 }
83 //read from DOSI.xml
84 void DosiDigitizerModule::getXMLData()
85 {
86  GearDir content = GearDir("/Detector/DetectorComponent[@name=\"DOSI\"]/Content/");
87 
88  B2INFO("DosiDigitizer: Aquired dosi locations and gas parameters");
89  B2INFO(" from DOSI.xml. There are " << nDOSI << " DOSIs implemented");
90 
91 }
92 
93 
94 Double_t DosiDigitizerModule::GetEnergyResolutionGeV(Double_t pEnergy, int CellId)
95 {
96  // Returns energy resolution in GeV when supplied Energy in GeV
97  return (m_EnergyResolutionFactor[CellId] * TMath::Sqrt(pEnergy) + m_EnergyResolutionConst[CellId] * pEnergy);
98 
99 }
100 
101 
102 void DosiDigitizerModule::endRun()
103 {
104 }
105 
106 void DosiDigitizerModule::terminate()
107 {
108 }
109 
110 
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::DosiSimHit::getFlightTime
double getFlightTime() const
Get Flight time from IP.
Definition: DosiSimHit.h:121
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::DosiSimHit::getEnergyDep
double getEnergyDep() const
Get Deposit energy.
Definition: DosiSimHit.h:126
Belle2::DosiSimHit::getPDGCode
int getPDGCode() const
Get Particle PDG (can be one of secondaries)
Definition: DosiSimHit.h:116
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DosiSimHit::getCellId
int getCellId() const
Get Cell ID.
Definition: DosiSimHit.h:106
Belle2::GearDir
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:41
Belle2::DosiSimHit::getTrackId
int getTrackId() const
Get Track ID.
Definition: DosiSimHit.h:111
Belle2::DosiSimHit
ClassDosiSimHit - Geant4 simulated hit for the Dosi crystal in beast.
Definition: DosiSimHit.h:41
Belle2::DosiSimHit::getMomentum
TVector3 getMomentum() const
Get Momentum.
Definition: DosiSimHit.h:131
Belle2::DosiSimHit::getPosition
TVector3 getPosition() const
Get Position.
Definition: DosiSimHit.h:141
Belle2::DosiHit
ClassDosiHit - Geant4 ulated hit for the Dosi crystal in beast.
Definition: DosiHit.h:41
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226
Belle2::dosi::DosiDigitizerModule
Dosi tube digitizer.
Definition: DosiDigitizerModule.h:41