Belle II Software development
QcsmonitorDigitizerModule.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/qcsmonitor/modules/QcsmonitorDigitizerModule.h>
10#include <beast/qcsmonitor/dataobjects/QcsmonitorSimHit.h>
11
12#include <mdst/dataobjects/MCParticle.h>
13#include <framework/logging/Logger.h>
14#include <framework/gearbox/GearDir.h>
15
16//c++
17#include <string>
18#include <fstream>
19
20using namespace std;
21using namespace Belle2;
22using namespace qcsmonitor;
23
24
25//-----------------------------------------------------------------
26// Register the Module
27//-----------------------------------------------------------------
28REG_MODULE(QcsmonitorDigitizer);
29
30//-----------------------------------------------------------------
31// Implementation
32//-----------------------------------------------------------------
33
35{
36 // Set module properties
37 setDescription("Qcsmonitor digitizer module");
38
39 //Default values are set here. New values can be in QCSMONITOR.xml.
40 addParam("ScintCell", m_ScintCell, "Number of scintillator cell", 2);
41 addParam("TimeStep", m_TimeStep, "Time step", 0.8);
42 addParam("C_keV_to_MIP", m_C_keV_to_MIP, "C_keV_to_MIP", 241.65);
43 addParam("C_MIP_to_PE", m_C_MIP_to_PE, "C_MIP_to_PE", 15.0);
44 addParam("MinTime", m_MinTime, "Min. time", 0.0);
45 addParam("MaxTime", m_MaxTime, "Max. time", 750.0);
46 addParam("MIPthres", m_MIPthres, "Energy threshold in keV", 0.5);
47}
48
50{
51}
52
54{
55 B2INFO("QcsmonitorDigitizer: Initializing");
56 m_qcsmonitorHit.registerInDataStore();
57
58 //get the garfield drift data, gas, and QCSMONITOR paramters
59 getXMLData();
60
61}
62
64{
65}
66
68{
69
70 StoreArray<QcsmonitorSimHit> QcsmonitorSimHits;
71
72 //Skip events with no QcsmonitorSimHits, but continue the event counter
73 if (QcsmonitorSimHits.getEntries() == 0) {
74 return;
75 }
76
79
80 int number_of_timebins = (int)((m_MaxTime - m_MinTime) / m_TimeStep);
81
82 for (int i = 0; i < 1000; i ++)
83 for (int j = 0; j < 100; j ++)
84 hitsarrayinMIP[i][j] = 0;
85
86 for (const auto& SimHit : SimHits) {
87 const int detNb = SimHit.getCellId();
88 const double Edep = SimHit.getEnergyDep() * 1e6; //GeV -> keV
89 const double tof = SimHit.getFlightTime(); //ns
90 int TimeBin = tof / m_TimeStep;
91 double MIP = Edep / m_C_keV_to_MIP;
92 //double PE = MIP * m_C_MIP_to_PE;
93 if (m_MinTime < tof && tof < m_MaxTime && TimeBin < 1000 && detNb < 100)
94 hitsarrayinMIP[TimeBin][detNb] += MIP;
95 }
96
97 /*
98 for (const auto& SimHit : SimHits) {
99 const int detNb = SimHit.getCellId();
100 //int pdg = SimHit.getPDGCode();
101 const double Edep = SimHit.getEnergyDep() * 1e6; //GeV -> keV
102 const double tof = SimHit.getFlightTime(); //ns
103 int TimeBin = tof / m_TimeStep;
104 double MIP = Edep / m_C_keV_to_MIP;
105 double PE = MIP * m_C_MIP_to_PE;
106 if ((m_MinTime < tof && tof < m_MaxTime) && MIP > m_MIPthres)
107 //if (hitsarrayinMIP[TimeBin][detNb] > m_MIPthres)
108 Hits.appendNew(QcsmonitorHit(detNb, TimeBin, Edep, MIP, PE));
109 }
110 */
111
112 for (int i = 0; i < number_of_timebins; i ++) {
113 for (int j = 0; j < m_ScintCell; j ++) {
114 if (hitsarrayinMIP[i][j] > m_MIPthres) {
115 double MIP = hitsarrayinMIP[i][j];
116 double Edep = MIP * m_C_keV_to_MIP * 1e-6; //keV -> GeV.
117 double PE = MIP * m_C_MIP_to_PE;
118 Hits.appendNew(QcsmonitorHit(j, i, Edep, MIP, PE));
119 }
120 }
121 }
122
123}
124
125//read tube centers, impulse response, and garfield drift data filename from QCSMONITOR.xml
127{
128 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"QCSMONITOR\"]/Content/");
129
130 m_ScintCell = content.getInt("ScintCell");
131 m_TimeStep = content.getDouble("TimeStep");
132 m_MinTime = content.getDouble("MinTime");
133 m_MaxTime = content.getDouble("MaxTime");
134 m_MIPthres = content.getDouble("MIPthres");
135 m_C_keV_to_MIP = content.getDouble("C_keV_to_MIP");
136 m_C_MIP_to_PE = content.getDouble("C_MIP_to_PE");
137
138 B2INFO("QcsmonitorDigitizer: Aquired qcsmonitor locations and gas parameters");
139
140}
141
143{
144}
145
147{
148}
149
150
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
ClassQcsmonitorHit - digitization simulated hit for the Qcsmonitor detector.
Definition: QcsmonitorHit.h:26
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.
QcsmonitorDigitizerModule()
Constructor: Sets the description, the properties and the parameters of the module.
virtual void event() override
Event processor.
virtual void endRun() override
End-of-run action.
StoreArray< QcsmonitorHit > m_qcsmonitorHit
Array for QcsmonitorHit.
virtual void getXMLData()
reads data from QCSMONITOR.xml: tube location, drift data filename, sigma of impulse response functio...
virtual void terminate() override
Termination action.
int m_ScintCell
Number of QCSMONITOR scintillator cell.
virtual void beginRun() override
Called when entering a new run.
double m_C_keV_to_MIP
Convertor factor keV to MIP.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#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.