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 <framework/logging/Logger.h>
13#include <framework/gearbox/GearDir.h>
14
15//c++
16#include <string>
17
18using namespace std;
19using namespace Belle2;
20using namespace qcsmonitor;
21
22
23//-----------------------------------------------------------------
24// Register the Module
25//-----------------------------------------------------------------
26REG_MODULE(QcsmonitorDigitizer);
27
28//-----------------------------------------------------------------
29// Implementation
30//-----------------------------------------------------------------
31
33{
34 // Set module properties
35 setDescription("Qcsmonitor digitizer module");
36
37 //Default values are set here. New values can be in QCSMONITOR.xml.
38 addParam("ScintCell", m_ScintCell, "Number of scintillator cell", 2);
39 addParam("TimeStep", m_TimeStep, "Time step", 0.8);
40 addParam("C_keV_to_MIP", m_C_keV_to_MIP, "C_keV_to_MIP", 241.65);
41 addParam("C_MIP_to_PE", m_C_MIP_to_PE, "C_MIP_to_PE", 15.0);
42 addParam("MinTime", m_MinTime, "Min. time", 0.0);
43 addParam("MaxTime", m_MaxTime, "Max. time", 750.0);
44 addParam("MIPthres", m_MIPthres, "Energy threshold in keV", 0.5);
45}
46
48{
49}
50
52{
53 B2INFO("QcsmonitorDigitizer: Initializing");
54 m_qcsmonitorHit.registerInDataStore();
55
56 //get the garfield drift data, gas, and QCSMONITOR parameters
57 getXMLData();
58
59}
60
62{
63}
64
66{
67
68 StoreArray<QcsmonitorSimHit> QcsmonitorSimHits;
69
70 //Skip events with no QcsmonitorSimHits, but continue the event counter
71 if (QcsmonitorSimHits.getEntries() == 0) {
72 return;
73 }
74
77
78 int number_of_timebins = (int)((m_MaxTime - m_MinTime) / m_TimeStep);
79
80 for (int i = 0; i < 1000; i ++)
81 for (int j = 0; j < 100; j ++)
82 hitsarrayinMIP[i][j] = 0;
83
84 for (const auto& SimHit : SimHits) {
85 const int detNb = SimHit.getCellId();
86 const double Edep = SimHit.getEnergyDep() * 1e6; //GeV -> keV
87 const double tof = SimHit.getFlightTime(); //ns
88 int TimeBin = tof / m_TimeStep;
89 double MIP = Edep / m_C_keV_to_MIP;
90 //double PE = MIP * m_C_MIP_to_PE;
91 if (m_MinTime < tof && tof < m_MaxTime && TimeBin < 1000 && detNb < 100)
92 hitsarrayinMIP[TimeBin][detNb] += MIP;
93 }
94
95 /*
96 for (const auto& SimHit : SimHits) {
97 const int detNb = SimHit.getCellId();
98 //int pdg = SimHit.getPDGCode();
99 const double Edep = SimHit.getEnergyDep() * 1e6; //GeV -> keV
100 const double tof = SimHit.getFlightTime(); //ns
101 int TimeBin = tof / m_TimeStep;
102 double MIP = Edep / m_C_keV_to_MIP;
103 double PE = MIP * m_C_MIP_to_PE;
104 if ((m_MinTime < tof && tof < m_MaxTime) && MIP > m_MIPthres)
105 //if (hitsarrayinMIP[TimeBin][detNb] > m_MIPthres)
106 Hits.appendNew(QcsmonitorHit(detNb, TimeBin, Edep, MIP, PE));
107 }
108 */
109
110 for (int i = 0; i < number_of_timebins; i ++) {
111 for (int j = 0; j < m_ScintCell; j ++) {
112 if (hitsarrayinMIP[i][j] > m_MIPthres) {
113 double MIP = hitsarrayinMIP[i][j];
114 double Edep = MIP * m_C_keV_to_MIP * 1e-6; //keV -> GeV.
115 double PE = MIP * m_C_MIP_to_PE;
116 Hits.appendNew(QcsmonitorHit(j, i, Edep, MIP, PE));
117 }
118 }
119 }
120
121}
122
123//read tube centers, impulse response, and garfield drift data filename from QCSMONITOR.xml
125{
126 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"QCSMONITOR\"]/Content/");
127
128 m_ScintCell = content.getInt("ScintCell");
129 m_TimeStep = content.getDouble("TimeStep");
130 m_MinTime = content.getDouble("MinTime");
131 m_MaxTime = content.getDouble("MaxTime");
132 m_MIPthres = content.getDouble("MIPthres");
133 m_C_keV_to_MIP = content.getDouble("C_keV_to_MIP");
134 m_C_MIP_to_PE = content.getDouble("C_MIP_to_PE");
135
136 B2INFO("QcsmonitorDigitizer: Acquired qcsmonitor locations and gas parameters");
137
138}
139
141{
142}
143
145{
146}
147
148
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
Converter 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:559
#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.