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