Belle II Software development
TRGECLBGTCHitModule.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#define TRGECLBGTCHit_SHORT_NAMES
10
11//framework headers
12#include <framework/logging/Logger.h>
13
14//trg package headers
15#include "trg/ecl/modules/trgeclBGOverlay/TRGECLBGTCHitModule.h"
16
17#include <iostream>
18
19using namespace std;
20
21namespace Belle2 {
26//
27//
30//
31//
32//
33 string
35 {
36 return string("TRGECLBGTCHitModule 1.00");
37 }
38//
39//
40//
42 : Module::Module(),
43 m_TCEnergyCut(0.005),
44 m_TCTimingCutLow(-1500),
45 m_TCTimingCutHigh(1500),
46 m_debugLevel(0)
47 {
48 string desc = "TRGECLBGTCHitModule(" + version() + ")";
49 setDescription(desc);
51
52 addParam("TCEnergyCut",
53 m_TCEnergyCut,
54 "TC energy cut: TC(E)<X (GeV), X=",
55 m_TCEnergyCut);
56 addParam("TCTimingCutLow",
57 m_TCTimingCutLow,
58 "TC Timing cut low: TC(T)>X (ns), X=",
59 m_TCTimingCutLow);
60 addParam("TCTimingCutHigh",
61 m_TCTimingCutHigh,
62 "TC Timing cut high: TC(T)<X (ns), X=",
63 m_TCTimingCutHigh);
64 addParam("DebugLevel",
65 m_debugLevel,
66 "TRGECL debug level",
67 m_debugLevel);
68
69 m_TCMap = new TrgEclMapping();
70
71 B2DEBUG(100, "TRGECLBGTCHitModule ... created");
72 }
73//
74//
75//
77 {
78 B2DEBUG(100, "TRGECLBGTCHitModule ... destructed ");
79 }
80//
81//
82//
83 void
85 {
86 B2DEBUG(100, "TRGECLBGTCHitModule::initialize>");
87
88 B2INFO("[TRGECLBGTCHitModule] TCEnergyCut : TC(E) GeV = "
89 << m_TCEnergyCut);
90 B2INFO("[TRGECLBGTCHitModule] TCTimingCutLow : TC(T) ns = "
91 << m_TCTimingCutLow);
92 B2INFO("[TRGECLBGTCHitModule] TCTimingCutHigh : TC(T) ns = "
93 << m_TCTimingCutHigh);
94
95 m_eclHits.registerInDataStore();
96 m_trgeclUnpackerStores.registerInDataStore();
97 m_trgeclBGTCHits.registerInDataStore();
98 }
99//
100//
101//
102 void
104 {
105 B2DEBUG(200, "TRGECLBGTCHitModule ... beginRun called ");
106 }
107//
108//
109//
110 void
112 {
113 B2DEBUG(200, "TRGECLBGTCHitMoudle ... event called");
114
115 if (m_eclHits.getEntries() > 0) {
117 } else if (m_trgeclUnpackerStores.getEntries() > 0) {
118 genRandomTrgObj();
119 }
120 }
121//
122//
123//
124 void
126 {
127 B2DEBUG(200, "TRGECLBGTCHitModule ... endRun called ");
128 }
129//
130//
131//
132 void
134 {
135 B2DEBUG(100, "TRGECLBGTCHitModule ... terminate called ");
136 }
137//
138//
139//
140 void
142 {
143
144 struct hit_t { double e, t; };
145 map<int, hit_t> a;
146
147 for (const ECLHit& t : m_eclHits) {
148 double txtal = t.getTimeAve();
149 // timing cut, +-8ns, (almost) same as ECL in SensitiveDetector.cc
150 if (txtal >= 8000.0 || txtal < -8000.0) continue;
151 double edep = t.getEnergyDep();
152 int TimeIndex = (txtal + 8000.0) * (1. / 100);
153 int cellId = t.getCellId() - 1;
154 int iTCIdm = m_TCMap->getTCIdFromXtalId(cellId + 1) - 1;
155
156 int key = iTCIdm * 160 + TimeIndex;
157 hit_t& h = a[key];
158 double old_edep = h.e, old_txtal = h.t;
159 double new_edep = old_edep + edep;
160 h.e = new_edep;
161 h.t = (old_edep * old_txtal + edep * txtal) / new_edep;
162 }
163 // save TC data to dataobject
164 for (pair<int, hit_t> t : a) {
165 int key = t.first;
166 int tcid = key / 160;
167 const hit_t& h = t.second;
168 // TC energy cut to reduce object size
169 if (h.e < m_TCEnergyCut) { continue; }
170 // TC timing cut to reduce object size
171 if (h.t < m_TCTimingCutLow || h.t > m_TCTimingCutHigh) { continue; }
172 // store data
173 m_trgeclBGTCHits.appendNew(tcid + 1, h.e, h.t);
174 }
175
176 }
177 //
178 //
179 //
180 void
181 TRGECLBGTCHitModule::genRandomTrgObj()
182 {
183
184 for (const TRGECLUnpackerStore& ttt : m_trgeclUnpackerStores) {
185 int tcID = ttt.getTCId();
186 // TC energy(ADC)
187 double tcEnergyADC = (double) ttt.getTCEnergy();
188 // TC timing(ns)
189 double tcTime = (double) ttt.getTCTime();
190 if (tcID <= 0) {continue;}
191 // ADC to Energy(MeV) conversion
192 double adc2energy = 5.231;
193 // TC energy (GeV)
194 double tcEnergy = tcEnergyADC * (adc2energy / 1000);
195 // TC energy cut to reduce object size
196 if (tcEnergy < m_TCEnergyCut) { continue; }
197 // TC timing cut to reduce object size
198 if (tcTime < m_TCTimingCutLow || tcTime > m_TCTimingCutHigh) { continue; }
199 // store data
200 m_trgeclBGTCHits.appendNew(tcID,
201 tcEnergy,
202 tcTime);
203 }
204 }
205
207} // namespace Belle2
Class to store simulated hits which equate to average of ECLSImHit on crystals input for digitization...
Definition: ECLHit.h:25
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
Example Detector.
Definition: TRGECLBGTCHit.h:24
A class of TC Mapping.
Definition: TrgEclMapping.h:26
int getTCIdFromXtalId(int)
get [TC ID] from [Xtal ID]
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
virtual void initialize() override
Initilizes TRGECLBGTCHitModule.
virtual void event() override
Called event by event.
virtual void endRun() override
Called when run ended.
virtual void terminate() override
Called when processing ended.
virtual void beginRun() override
Called when new run started.
virtual ~TRGECLBGTCHitModule()
Destructor.
std::string version(void) const
returns version of TRGECLBGTCHitModule.
Abstract base class for different kinds of events.
STL namespace.