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 <fstream>
17#include <vector>
18
19using namespace std;
20using namespace Belle2;
21using namespace claw;
22
23
24//-----------------------------------------------------------------
25// Register the Module
26//-----------------------------------------------------------------
27REG_MODULE(ClawDigitizer);
28
29//-----------------------------------------------------------------
30// Implementation
31//-----------------------------------------------------------------
32
34{
35 // Set module properties
36 setDescription("Claw digitizer module");
37
38 //Default values are set here. New values can be in CLAW.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("ClawDigitizer: Initializing");
55 m_clawHit.registerInDataStore();
56
57 //get the garfield drift data, gas, and CLAW paramters
58 getXMLData();
59
60}
61
63{
64}
65
67{
68
69 StoreArray<ClawSimHit> ClawSimHits;
70 //Skip events with no ClawSimHits, but continue the event counter
71 if (ClawSimHits.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 hitsarrayinPE[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 hitsarrayinPE[TimeBin][detNb] += PE;
93 }
94 */
95 for (const auto& SimHit : SimHits) {
96 const int detNb = SimHit.getCellId();
97 //int pdg = SimHit.getPDGCode();
98 const double Edep = SimHit.getEnergyDep() * 1e6; //GeV -> keV
99 const double tof = SimHit.getFlightTime(); //ns
100 int TimeBin = tof / m_TimeStep;
101 double MIP = Edep / m_C_keV_to_MIP;
102 double PE = MIP * m_C_MIP_to_PE[detNb];
103 if ((m_MinTime < tof && tof < m_MaxTime) && PE > m_PEthres)
104 Hits.appendNew(ClawHit(detNb, TimeBin, Edep, MIP, PE));
105 }
106 /*
107 for (int i = 0; i < number_of_timebins; i ++) {
108 for (int j = 0; j < m_ScintCell; j ++) {
109 if (hitsarrayinPE[i][j] > m_PEthres) {
110 double PE = hitsarrayinPE[i][j];
111 double MIP = PE / m_C_MIP_to_PE;
112 double Edep = MIP * m_C_keV_to_MIP * 1e-6; //keV -> GeV.
113 Hits.appendNew(ClawHit(j, i, Edep, MIP, PE));
114 }
115 }
116 }
117 */
118}
119
120//read tube centers, impulse response, and garfield drift data filename from CLAW.xml
122{
123 GearDir content = GearDir("/Detector/DetectorComponent[@name=\"CLAW\"]/Content/");
124
125 m_ScintCell = content.getInt("ScintCell");
126 m_TimeStep = content.getDouble("TimeStep");
127 m_MinTime = content.getDouble("MinTime");
128 m_MaxTime = content.getDouble("MaxTime");
129 m_PEthres = content.getDouble("PEthres");
130 m_C_keV_to_MIP = content.getDouble("C_keV_to_MIP");
131 //m_C_MIP_to_PE = content.getDouble("C_MIP_to_PE");
132
133 B2INFO("ClawDigitizer: Aquired claw locations and gas parameters");
134
135}
136
138{
139}
140
142{
143}
144
145
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
Convertor 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
Convertor 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: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.