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 <fstream>
18#include <vector>
19
20using namespace std;
21using namespace Belle2;
22using namespace claws;
23
24
25//-----------------------------------------------------------------
26// Register the Module
27//-----------------------------------------------------------------
28REG_MODULE(ClawsDigitizer);
29
30//-----------------------------------------------------------------
31// Implementation
32//-----------------------------------------------------------------
33
35{
36 // Set module properties
37 setDescription("Claws digitizer module");
38
39 //Default values are set here. New values can be in CLAWS.xml.
40 addParam("ScintCell", m_ScintCell, "Number of scintillator cell", 16);
41 addParam("TimeStep", m_TimeStep, "Time step", 0.8);
42 addParam("C_keV_to_MIP", m_C_keV_to_MIP, "C_keV_to_MIP", 805.5);
43 addParam("C_MIP_to_PE", m_C_MIP_to_PE, "C_MIP_to_PE");
44 addParam("MinTime", m_MinTime, "Min. time", 0.0);
45 addParam("MaxTime", m_MaxTime, "Max. time", 750.0);
46 addParam("PEthres", m_PEthres, "Energy threshold in keV", 1.0);
47}
48
50{
51}
52
54{
55 B2INFO("ClawsDigitizer: Initializing");
56 m_clawsHit.registerInDataStore();
57
58 //get the garfield drift data, gas, and CLAWS paramters
59 getXMLData();
60
61}
62
64{
65}
66
68{
69
70 StoreArray<CLAWSSimHit> CLAWSSimHits;
71
72 //Skip events with no CLAWSSimHits, but continue the event counter
73 if (CLAWSSimHits.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 hitsarrayinPE[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 hitsarrayinPE[TimeBin][detNb] += PE;
95 }
96 */
97 for (const auto& SimHit : SimHits) {
98 int lad = SimHit.getLadder();
99 int sen = SimHit.getSensor();
100 //const int detNb = SimHit.getCellId();
101 //int pdg = SimHit.getPDGCode();
102 int detNb = (lad - 1) * 8 + sen - 1;
103 const double Edep = SimHit.getEnergyVisible() * 1e6; //GeV -> keV
104 const double tof = SimHit.getTime(); //ns
105 int TimeBin = tof / m_TimeStep;
106 double MIP = Edep / m_C_keV_to_MIP;
107 double PE = MIP * m_C_MIP_to_PE[detNb];
108 if ((m_MinTime < tof && tof < m_MaxTime) && PE > m_PEthres)
109 Hits.appendNew(ClawsHit(detNb, TimeBin, Edep, MIP, PE));
110 }
111 /*
112 for (int i = 0; i < number_of_timebins; i ++) {
113 for (int j = 0; j < m_ScintCell; j ++) {
114 if (hitsarrayinPE[i][j] > m_PEthres) {
115 double PE = hitsarrayinPE[i][j];
116 double MIP = PE / m_C_MIP_to_PE;
117 double Edep = MIP * m_C_keV_to_MIP * 1e-6; //keV -> GeV.
118 Hits.appendNew(ClawsHit(j, i, Edep, MIP, PE));
119 }
120 }
121 }
122 */
123}
124
125//read tube centers, impulse response, and garfield drift data filename from CLAWS.xml
127{
128 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"CLAWS\"]/Content/");
129
130 m_ScintCell = content.getInt("ScintCell");
131 m_TimeStep = content.getTime("TimeStep") / Unit::ns;
132 m_MinTime = content.getTime("MinTime") / Unit::ns;
133 m_MaxTime = content.getTime("MaxTime") / Unit::ns;
134 m_PEthres = content.getDouble("PEthres");
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 B2INFO("ClawsDigitizer: Aquired claws locations and gas parameters");
138
139}
140
142{
143}
144
146{
147}
148
149
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
Convertor 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
Convertor 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: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.