Belle II Software development
ClawDigitizerModule.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/claw/modules/ClawDigitizerModule.h>
10#include <beast/claw/dataobjects/ClawSimHit.h>
11#include <framework/logging/Logger.h>
12#include <framework/gearbox/GearDir.h>
13
14//c++
15#include <string>
16#include <vector>
17
18using namespace std;
19using namespace Belle2;
20using namespace claw;
21
22
23//-----------------------------------------------------------------
24// Register the Module
25//-----------------------------------------------------------------
26REG_MODULE(ClawDigitizer);
27
28//-----------------------------------------------------------------
29// Implementation
30//-----------------------------------------------------------------
31
33{
34 // Set module properties
35 setDescription("Claw digitizer module");
36
37 //Default values are set here. New values can be in CLAW.xml.
38 addParam("ScintCell", m_ScintCell, "Number of scintillator cell", 16);
39 addParam("TimeStep", m_TimeStep, "Time step", 0.8);
40 addParam("C_keV_to_MIP", m_C_keV_to_MIP, "C_keV_to_MIP", 805.5);
41 addParam("C_MIP_to_PE", m_C_MIP_to_PE, "C_MIP_to_PE");
42 addParam("MinTime", m_MinTime, "Min. time", 0.0);
43 addParam("MaxTime", m_MaxTime, "Max. time", 750.0);
44 addParam("PEthres", m_PEthres, "Energy threshold in keV", 1.0);
45}
46
48{
49}
50
52{
53 B2INFO("ClawDigitizer: Initializing");
54 m_clawHit.registerInDataStore();
55
56 //get the garfield drift data, gas, and CLAW parameters
57 getXMLData();
58
59}
60
62{
63}
64
66{
67
68 StoreArray<ClawSimHit> ClawSimHits;
69 //Skip events with no ClawSimHits, but continue the event counter
70 if (ClawSimHits.getEntries() == 0) {
71 return;
72 }
73
76 /*
77 int number_of_timebins = (int)((m_MaxTime - m_MinTime) / m_TimeStep);
78
79 for (int i = 0; i < 1000; i ++)
80 for (int j = 0; j < 100; j ++)
81 hitsarrayinPE[i][j] = 0;
82
83 for (const auto& SimHit : SimHits) {
84 const int detNb = SimHit.getCellId();
85 const double Edep = SimHit.getEnergyDep() * 1e6; //GeV -> keV
86 const double tof = SimHit.getFlightTime(); //ns
87 int TimeBin = tof / m_TimeStep;
88 double MIP = Edep / m_C_keV_to_MIP;
89 double PE = MIP * m_C_MIP_to_PE;
90 if (m_MinTime < tof && tof < m_MaxTime && TimeBin < 1000 && detNb < 100)
91 hitsarrayinPE[TimeBin][detNb] += PE;
92 }
93 */
94 for (const auto& SimHit : SimHits) {
95 const int detNb = SimHit.getCellId();
96 //int pdg = SimHit.getPDGCode();
97 const double Edep = SimHit.getEnergyDep() * 1e6; //GeV -> keV
98 const double tof = SimHit.getFlightTime(); //ns
99 int TimeBin = tof / m_TimeStep;
100 double MIP = Edep / m_C_keV_to_MIP;
101 double PE = MIP * m_C_MIP_to_PE[detNb];
102 if ((m_MinTime < tof && tof < m_MaxTime) && PE > m_PEthres)
103 Hits.appendNew(ClawHit(detNb, TimeBin, Edep, MIP, PE));
104 }
105 /*
106 for (int i = 0; i < number_of_timebins; i ++) {
107 for (int j = 0; j < m_ScintCell; j ++) {
108 if (hitsarrayinPE[i][j] > m_PEthres) {
109 double PE = hitsarrayinPE[i][j];
110 double MIP = PE / m_C_MIP_to_PE;
111 double Edep = MIP * m_C_keV_to_MIP * 1e-6; //keV -> GeV.
112 Hits.appendNew(ClawHit(j, i, Edep, MIP, PE));
113 }
114 }
115 }
116 */
117}
118
119//read tube centers, impulse response, and garfield drift data filename from CLAW.xml
121{
122 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"CLAW\"]/Content/");
123
124 m_ScintCell = content.getInt("ScintCell");
125 m_TimeStep = content.getDouble("TimeStep");
126 m_MinTime = content.getDouble("MinTime");
127 m_MaxTime = content.getDouble("MaxTime");
128 m_PEthres = content.getDouble("PEthres");
129 m_C_keV_to_MIP = content.getDouble("C_keV_to_MIP");
130 //m_C_MIP_to_PE = content.getDouble("C_MIP_to_PE");
131
132 B2INFO("ClawDigitizer: Acquired claw locations and gas parameters");
133
134}
135
137{
138}
139
141{
142}
143
144
ClassClawHit - digitization simulated hit for the Claw detector.
Definition: ClawHit.h:26
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
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
std::vector< Double_t > m_C_MIP_to_PE
Converter factor MIP to PE.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
ClawDigitizerModule()
Constructor: Sets the description, the properties and the parameters of the module.
virtual void endRun() override
End-of-run action.
virtual void getXMLData()
reads data from CLAW.xml: tube location, drift data filename, sigma of impulse response function
virtual void terminate() override
Termination action.
int m_ScintCell
Number of CLAW scintillator cell.
virtual void beginRun() override
Called when entering a new run.
double m_C_keV_to_MIP
Converter factor keV to MIP.
StoreArray< ClawHit > m_clawHit
array for ClawHit
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.