Belle II Software  release-08-01-10
MCMatcherTRGECLModule.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 <trg/ecl/modules/MCMatcherTRGECL/MCMatcherTRGECLModule.h>
10 
11 //framework headers
12 #include <framework/gearbox/Unit.h>
13 
14 //ecl package header
15 #include <ecl/dataobjects/ECLHit.h>
16 
17 //ecl trg package header
18 #include "trg/ecl/dataobjects/TRGECLHit.h"
19 #include "trg/ecl/dataobjects/TRGECLDigi0.h"
20 
21 
22 #include <mdst/dataobjects/MCParticle.h>
23 #include <framework/datastore/RelationArray.h>
24 
25 
26 //root
27 #include <TVector3.h>
28 
29 //C++ STL
30 #include <cstdlib>
31 #include <time.h>
32 #include <utility> //contains pair
33 
34 
35 
36 using namespace std;
37 using namespace boost;
38 using namespace Belle2;
39 //using namespace ECL;
40 
41 //-----------------------------------------------------------------
42 // Register the Module
43 //-----------------------------------------------------------------
44 REG_MODULE(MCMatcherTRGECL);
45 
46 //-----------------------------------------------------------------
47 // Implementation
48 //-----------------------------------------------------------------
49 
50 MCMatcherTRGECLModule::MCMatcherTRGECLModule() : Module()
51 {
52  // Set description
53 
54  setDescription("MCMatcherTRGECLModule");
56  _TCMap = new TrgEclMapping();
57 
58 
59  for (int ii = 0; ii < 100; ii++) {
60  TCId[ii] = 0;
61  TCRawEnergy[ii] = 0;
62  TCRawTiming[ii] = 0;
63  SignalContribution[ii] = 0;
64  BKGContribution[ii] = 0;
65  TCIdHit[ii] = 0;
66  TCHitEnergy[ii] = 0;
67  TCHitTiming[ii] = 0;
68  SignalContributionHit[ii] = 0;
69  BKGContributionHit[ii] = 0;
70 
71  for (int icont = 0 ; icont < 3 ; icont ++) {
72 
73 
74  maxEnergy[ii][icont] = -1;
75  contribution[ii][icont] = 0;
76  TCPrimaryIndex[ii][icont] = -1;
77  XtalId[ii][icont] = -1 ;
78  px[ii][icont] = 0;
79  py[ii][icont] = 0;
80  pz[ii][icont] = 0;
81  pid[ii][icont] = 0;
82  trackId[ii][icont] = 0;
83  background_tag[ii][icont] = 0;
84  mother[ii][icont] = 0 ;
85  gmother[ii][icont] = 0;
86  ggmother[ii][icont] = 0;
87  gggmother[ii][icont] = 0;
88  MCEnergy[ii][icont] = 0;
89 
90  ieclhit[ii][icont] = 0 ;
91 
92  background_tagHit[ii][icont] = 0;
93  TCPrimaryIndexHit[ii][icont] = -1;
94  XtalIdHit[ii][icont] = -1 ;
95  pxHit[ii][icont] = 0;
96  pyHit[ii][icont] = 0;
97  pzHit[ii][icont] = 0;
98  pidHit[ii][icont] = 0;
99  trackIdHit[ii][icont] = 0;
100  background_tagHit[ii][icont] = 0;
101  motherHit[ii][icont] = 0 ;
102  gmotherHit[ii][icont] = 0;
103  ggmotherHit[ii][icont] = 0;
104  gggmotherHit[ii][icont] = 0;
105  MCEnergyHit[ii][icont] = 0;
106  contributionHit[ii][icont] = 0;
107 
108  }
109  }
110 }
111 
113 {
114  delete _TCMap;
115 }
116 
118 {
119  // Initialize variables
120  m_nRun = 0 ;
121  m_nEvent = 0 ;
122  // CPU time start
123  m_timeCPU = clock() * Unit::us;
124 
125  m_trgECLDigi0MC.registerInDataStore();
126  m_trgECLHitMC.registerInDataStore();
127  StoreArray<MCParticle> mcParticles;
128  StoreArray<ECLHit> eclHitArray;
129 
130  mcParticles.registerRelationTo(eclHitArray);
131  StoreArray<TRGECLDigi0> trgeclDigi0Array;
132  trgeclDigi0Array.registerRelationTo(mcParticles);
133  StoreArray<TRGECLHit> trgeclHitArray;
134  trgeclHitArray.registerRelationTo(mcParticles);
135 
136 }
137 
139 {
140 }
141 
143 {
144 
145 
146  StoreArray<MCParticle> mcParticles;
147  PrimaryTrackMap eclPrimaryMap;
148  eclPrimaryMap.clear();
149  int nParticles = mcParticles.getEntries();
150  // cout << nParticles << endl;
151  for (int iPart = 0; iPart < nParticles ; ++iPart) {
152  if (mcParticles[iPart]->getMother() == NULL) {
153  if (!mcParticles[iPart]->hasStatus(MCParticle::c_PrimaryParticle)) {
154  if (!mcParticles[iPart]->hasStatus(MCParticle::c_StableInGenerator)) {
155  continue;
156  }
157  }
158  }
159 
160 
161 
162  bool adhoc_StableInGeneratorFlag(mcParticles[iPart]->hasStatus(MCParticle::c_StableInGenerator));
163 
164  if (mcParticles[iPart]->hasStatus(MCParticle::c_PrimaryParticle)
165  && adhoc_StableInGeneratorFlag) {
166  if (mcParticles[iPart]->getArrayIndex() == -1) {
167  eclPrimaryMap.insert(pair<int, int>(iPart, iPart));
168  } else {
169  eclPrimaryMap.insert(pair<int, int>(mcParticles[iPart]->getArrayIndex(), mcParticles[iPart]->getArrayIndex()));
170  }
171  } else {
172  if (mcParticles[iPart]->getMother() == NULL) continue;
173  if (eclPrimaryMap.find(mcParticles[iPart]->getMother()->getArrayIndex()) != eclPrimaryMap.end()) {
174  eclPrimaryMap.insert(
175  pair<int, int>(mcParticles[iPart]->getArrayIndex(), eclPrimaryMap[mcParticles[iPart]->getMother()->getArrayIndex()]));
176 
177  }//if mother of mcParticles is stored.
178  }//if c_StableInGenerator and c_PrimaryParticle
179 
180  }//for mcParticles
181 
182  //Connect TRGECLDigi0 and MCParticle using ECLHit
183  StoreArray<ECLHit> eclHitArray("ECLHits");
184  RelationArray eclHitRel(mcParticles, eclHitArray);
185  StoreArray<TRGECLDigi0> trgeclDigi0Array;
186  RelationArray trgeclDigi0ToMCPart(trgeclDigi0Array, mcParticles);
187  int nHits_hit = eclHitArray.getEntries() - 1;
188  //
189  int ihit = 0;
190 
191  const int NofTCDigiHit = trgeclDigi0Array.getEntries();
192 
193  // cout << NofTCDigiHit << endl;
194 
195  for (int ii = 0; ii < NofTCDigiHit; ii++) {
196 
197 
198  TRGECLDigi0* aTRGECLDigi0 = trgeclDigi0Array[ii];
199  TCId[ihit] = (aTRGECLDigi0->getTCId() - 1);
200  TCRawTiming[ihit] = aTRGECLDigi0 ->getRawTiming();
201 
202  int itimeindex = (int)(TCRawTiming[ihit] / 100 + 40);
203  TCRawEnergy[ihit] = aTRGECLDigi0 ->getRawEnergy() / Unit::GeV;
204  if (TCRawEnergy[ihit] < 0.1) {continue;} //0.05 GeV cut to save time.
205  for (int hit = 0; hit < nHits_hit; hit++) {//Find relation of TRGECLDigi0 and ECLHit
206 
207  ECLHit* aECLHit = eclHitArray[hit];;
208 
209  double hitE = aECLHit->getEnergyDep() / Unit::GeV;
210  if (hitE < 0.1) {continue;} //to save time.
211  int hitCellId = aECLHit->getCellId() - 1;
212  int hitTCId = _TCMap->getTCIdFromXtalId(hitCellId + 1) - 1;
213  int timeindex = (int)((aECLHit ->getTimeAve()) / 100 + 40);
214  int backtag = aECLHit ->getBackgroundTag();
215 
216  if (hitTCId != TCId[ihit]) {continue;}
217  if (itimeindex != timeindex) {continue;}
218  if (backtag == 0) { SignalContribution[ihit] = SignalContribution[ihit] + hitE;}
219  else { BKGContribution[ihit] = BKGContribution[ihit] + hitE;}
220 
221 
222  if (TCId[ihit] == hitTCId && maxEnergy[ihit][0] < hitE) {
223 
224  ieclhit[ihit][0] = hit;
225  maxEnergy[ihit][0] = hitE;
226  contribution[ihit][0] = hitE;
227  XtalId[ihit][0] = hitCellId ;
228  background_tag[ihit][0] = backtag;
229 
230  }
231 
232 
233  if (TCId[ihit] == hitTCId && maxEnergy[ihit][1] < hitE && hitE < maxEnergy[ihit][0]) {
234  ieclhit[ihit][1] = hit;
235  maxEnergy[ihit][1] = hitE;
236  contribution[ihit][1] = hitE;
237  XtalId[ihit][1] = hitCellId ;
238  background_tag[ihit][1] = backtag;
239  }
240 
241 
242  if (TCId[ihit] == hitTCId && maxEnergy[ihit][2] < hitE && hitE < maxEnergy[ihit][1]) {
243  ieclhit[ihit][2] = hit;
244  maxEnergy[ihit][2] = hitE;
245  contribution[ihit][2] = hitE;
246  XtalId[ihit][2] = hitCellId ;
247  background_tag[ihit][2] = backtag;
248 
249  }
250  }
251  //Find the relation of TRGECLDigi0 and MCParticle using ECLHit
252  for (int index = 0; index < eclHitRel.getEntries(); index++) {
253  int PrimaryIndex = -1;
254 
255  map<int, int>::iterator iter = eclPrimaryMap.find(eclHitRel[index].getFromIndex());
256 
257  if (iter != eclPrimaryMap.end()) {
258  PrimaryIndex = iter->second;
259  }
260  int eclhitRelSize = eclHitRel[index].getToIndices().size();
261  for (int pri_hit = 0; pri_hit < eclhitRelSize ; pri_hit++) {
262  int ieclHitRel = eclHitRel[index].getToIndex(pri_hit);
263  if (ieclhit[ihit][0] == ieclHitRel) {
264  TCPrimaryIndex[ihit][0] = PrimaryIndex;
265 
266  }
267  if (ieclhit[ihit][1] == ieclHitRel) {
268  TCPrimaryIndex[ihit][1] = PrimaryIndex;
269 
270  }
271  if (ieclhit[ihit][2] == ieclHitRel) {
272  TCPrimaryIndex[ihit][2] = PrimaryIndex;
273 
274  }
275  }
276  }
277 
278 
279  trackId[ihit][0] = TCPrimaryIndex[ihit][0];
280  trackId[ihit][1] = TCPrimaryIndex[ihit][1];
281  trackId[ihit][2] = TCPrimaryIndex[ihit][2];
282 
283 
284  // cout <<ihit <<" " << trackId[ihit][0] << " " << trackId[ihit][1] << " " << trackId[ihit][2] << " " << endl;
285 
286 
287  int mclist = 0;
288 
289  if (TCPrimaryIndex[ihit][0] > 0) {
290 
291  MCEnergy[ihit][0] = mcParticles[TCPrimaryIndex[ihit][0]]->getEnergy();
292  pid[ihit][0] = mcParticles[TCPrimaryIndex[ihit][0]]->getPDG();
293  px[ihit][0] = (mcParticles[TCPrimaryIndex[ihit][0]]->getMomentum()).X();
294  py[ihit][0] = (mcParticles[TCPrimaryIndex[ihit][0]]->getMomentum()).Y();
295  pz[ihit][0] = (mcParticles[TCPrimaryIndex[ihit][0]]->getMomentum()).Z();
296  if (pid[ihit][0] != 0 && (mcParticles[TCPrimaryIndex[ihit][0]]->getMother())) {
297  mother[ihit][0] = mcParticles[TCPrimaryIndex[ihit][0]]->getMother() ->getPDG();
298  mclist = mcParticles[TCPrimaryIndex[ihit][0]]->getMother()-> getIndex();
299  }
300  if (mclist != 1 && mother[ihit][0] != 0 && (mcParticles[TCPrimaryIndex[ihit][0]]->getMother()->getMother())) {
301  gmother[ihit][0] = mcParticles[TCPrimaryIndex[ihit][0]]->getMother()->getMother() ->getPDG();
302  mclist = mcParticles[TCPrimaryIndex[ihit][0]]->getMother()->getMother()-> getIndex();
303 
304  }
305  if (mclist != 1 && gmother[ihit][0] != 0 && (mcParticles[TCPrimaryIndex[ihit][0]]->getMother()->getMother()->getMother())) {
306  ggmother[ihit][0] = mcParticles[TCPrimaryIndex[ihit][0]]->getMother()->getMother()->getMother() ->getPDG();
307  mclist = mcParticles[TCPrimaryIndex[ihit][0]]->getMother()->getMother()->getMother()-> getIndex();
308 
309 
310  }
311  if (mclist != 1 && ggmother[ihit][0] != 0) {
312  if (mcParticles[TCPrimaryIndex[ihit][0]]->getMother()->getMother()->getMother()->getMother()) {
313  gggmother[ihit][0] = mcParticles[TCPrimaryIndex[ihit][0]]->getMother()->getMother()->getMother()->getMother() ->getPDG();
314 
315  }
316  }
317 
318  }
319  mclist = 0;
320  if (TCPrimaryIndex[ihit][1] > 0) {
321 
322  MCEnergy[ihit][1] = mcParticles[TCPrimaryIndex[ihit][1]]->getEnergy();
323  pid[ihit][1] = mcParticles[TCPrimaryIndex[ihit][1]]->getPDG();
324  px[ihit][1] = (mcParticles[TCPrimaryIndex[ihit][1]]->getMomentum()).X();
325  py[ihit][1] = (mcParticles[TCPrimaryIndex[ihit][1]]->getMomentum()).Y();
326  pz[ihit][1] = (mcParticles[TCPrimaryIndex[ihit][1]]->getMomentum()).Z();
327  if (pid[ihit][1] != 0 && (mcParticles[TCPrimaryIndex[ihit][1]]->getMother())) {
328  mother[ihit][1] = mcParticles[TCPrimaryIndex[ihit][1]]->getMother() ->getPDG();
329  mclist = mcParticles[TCPrimaryIndex[ihit][1]]->getMother()-> getIndex();
330  }
331  if (mclist != 1 && mother[ihit][1] != 0 && (mcParticles[TCPrimaryIndex[ihit][1]]->getMother()->getMother())) {
332  gmother[ihit][1] = mcParticles[TCPrimaryIndex[ihit][1]]->getMother()->getMother() ->getPDG();
333  mclist = mcParticles[TCPrimaryIndex[ihit][1]]->getMother()->getMother()-> getIndex();
334 
335  }
336  if (mclist != 1 && gmother[ihit][1] != 0 && (mcParticles[TCPrimaryIndex[ihit][1]]->getMother()->getMother()->getMother())) {
337  ggmother[ihit][1] = mcParticles[TCPrimaryIndex[ihit][1]]->getMother()->getMother()->getMother() ->getPDG();
338  mclist = mcParticles[TCPrimaryIndex[ihit][1]]->getMother()->getMother()->getMother()-> getIndex();
339  }
340  if (mclist != 1 && ggmother[ihit][1] != 0) {
341  if (mcParticles[TCPrimaryIndex[ihit][1]]->getMother()->getMother()->getMother()->getMother()) {
342  gggmother[ihit][1] = mcParticles[TCPrimaryIndex[ihit][1]]->getMother()->getMother()->getMother()->getMother() ->getPDG();
343  }
344  }
345  }
346  mclist = 0;
347  if (TCPrimaryIndex[ihit][2] > 0) {
348 
349  MCEnergy[ihit][2] = mcParticles[TCPrimaryIndex[ihit][2]]->getEnergy();
350  pid[ihit][2] = mcParticles[TCPrimaryIndex[ihit][2]]->getPDG();
351  px[ihit][2] = (mcParticles[TCPrimaryIndex[ihit][2]]->getMomentum()).X();
352  py[ihit][2] = (mcParticles[TCPrimaryIndex[ihit][2]]->getMomentum()).Y();
353  pz[ihit][2] = (mcParticles[TCPrimaryIndex[ihit][2]]->getMomentum()).Z();
354  if (pid[ihit][2] != 0 && (mcParticles[TCPrimaryIndex[ihit][2]]->getMother())) {
355  mother[ihit][2] = mcParticles[TCPrimaryIndex[ihit][2]]->getMother() ->getPDG();
356  mclist = mcParticles[TCPrimaryIndex[ihit][2]]->getMother()-> getIndex();
357  }
358  if (mclist != 1 && mother[ihit][2] != 0 && (mcParticles[TCPrimaryIndex[ihit][2]]->getMother()->getMother())) {
359  gmother[ihit][2] = mcParticles[TCPrimaryIndex[ihit][2]]->getMother()->getMother() ->getPDG();
360  mclist = mcParticles[TCPrimaryIndex[ihit][2]]->getMother()->getMother()-> getIndex();
361 
362  }
363  if (mclist != 1 && gmother[ihit][2] != 0 && (mcParticles[TCPrimaryIndex[ihit][2]]->getMother()->getMother()->getMother())) {
364  ggmother[ihit][2] = mcParticles[TCPrimaryIndex[ihit][2]]->getMother()->getMother()->getMother() ->getPDG();
365  mclist = mcParticles[TCPrimaryIndex[ihit][2]]->getMother()->getMother()->getMother()-> getIndex();
366  }
367  if (mclist != 1 && ggmother[ihit][2] != 0) {
368  if (mcParticles[TCPrimaryIndex[ihit][2]]->getMother()->getMother()->getMother()->getMother()) {
369  gggmother[ihit][2] = mcParticles[TCPrimaryIndex[ihit][2]]->getMother()->getMother()->getMother()->getMother() ->getPDG();
370  }
371  }
372 
373  }
374  trgeclDigi0ToMCPart.add(ii, TCPrimaryIndex[ihit][0]);
375  ihit++;
376  }
377 
378 
379  StoreArray<TRGECLDigi0MC> TCDigiArray;
380  for (int ii = 0; ii < ihit; ++ii) {
381 
382  if (TCRawEnergy[ii] < 0.1) {continue;}
383  TCDigiArray.appendNew();
384  int m_hitNum = TCDigiArray.getEntries() - 1;
385 
386  TCDigiArray[m_hitNum]->setEventId(m_nEvent);
387  TCDigiArray[m_hitNum]->setTCId(TCId[ii]);
388 
389  TCDigiArray[m_hitNum]->setRawEnergy(TCRawEnergy[ii]);
390  TCDigiArray[m_hitNum]->setRawTiming(TCRawTiming[ii]);
391  TCDigiArray[m_hitNum]->setTrackId(trackId[ii]);
392  TCDigiArray[m_hitNum]->setCellId(XtalId[ii]);
393 
394  TCDigiArray[m_hitNum]->setPDG(pid[ii]);
395  TCDigiArray[m_hitNum]->setMother(mother[ii]);
396  TCDigiArray[m_hitNum]->setGMother(gmother[ii]);
397  TCDigiArray[m_hitNum]->setGGMother(ggmother[ii]);
398  TCDigiArray[m_hitNum]->setGGGMother(gggmother[ii]);
399 
400  TCDigiArray[m_hitNum]->setPX(px[ii]);
401  TCDigiArray[m_hitNum]->setPY(py[ii]);
402  TCDigiArray[m_hitNum]->setPZ(pz[ii]);
403  TCDigiArray[m_hitNum]->setMCEnergy(MCEnergy[ii]);
404  TCDigiArray[m_hitNum]->setContribution(contribution[ii]);
405  TCDigiArray[m_hitNum]->setBackgroundTag(background_tag[ii]);
406  TCDigiArray[m_hitNum]->setSignalContribution(SignalContribution[ii]);
407  TCDigiArray[m_hitNum]->setBKGContribution(BKGContribution[ii]);
408  }
409 
410  //Find relation of TRGECLHit and MCParticle using TRGECLDigi0
411 
412  StoreArray<TRGECLHit> trgeclHitArray;
413  RelationArray trgeclHitToMCPart(trgeclHitArray, mcParticles);
414  const int NofTCHit = trgeclHitArray.getEntries();
415 
416 
417  for (int ii = 0; ii < NofTCHit; ++ii) {
418 
419  TRGECLHit* aTRGECLHit = trgeclHitArray[ii];
420  TCIdHit[ii] = (aTRGECLHit->getTCId() - 1);
421  TCHitTiming[ii] = aTRGECLHit ->getTimeAve();
422  TCHitEnergy[ii] = aTRGECLHit -> getEnergyDep();
423  int itimeindex = (int)(TCHitTiming[ii] / 100 + 40);
424 
425  for (int index = 0; index < trgeclDigi0ToMCPart.getEntries(); ++index) {
426  int idigi = index;
427  int idigitimeindex = (int)(TCRawTiming[idigi] / 100 + 40);
428  if (TCId[idigi] != TCIdHit[ii]) {continue;}
429  if (itimeindex != idigitimeindex) {continue;}
430 
431  TCPrimaryIndexHit[ii][0] = TCPrimaryIndex[idigi][0];
432  contributionHit[ii][0] = contribution[idigi][0];
433  XtalIdHit[ii][0] = XtalId[idigi][0] ;
434 
435  TCPrimaryIndexHit[ii][1] = TCPrimaryIndex[idigi][1];
436  contributionHit[ii][1] = contribution[idigi][1];
437  XtalIdHit[ii][1] = XtalId[idigi][1] ;
438 
439  TCPrimaryIndexHit[ii][2] = TCPrimaryIndex[idigi][2];
440  contributionHit[ii][2] = contribution[idigi][2];
441  XtalIdHit[ii][2] = XtalId[idigi][2] ;
442 
443  background_tagHit[ii][0] = background_tag[idigi][0] ;
444  background_tagHit[ii][1] = background_tag[idigi][1] ;
445  background_tagHit[ii][2] = background_tag[idigi][2] ;
446 
448  ;
449  BKGContributionHit[ii] = BKGContribution[idigi];
450 
451 
452  trackIdHit[ii][0] = trackId[idigi][0];
453  trackIdHit[ii][1] = trackId[idigi][0];
454  trackIdHit[ii][2] = trackId[idigi][0];
455 
456  MCEnergyHit[ii][0] = MCEnergy[idigi][0];
457  pidHit[ii][0] = pid[idigi][0] ;
458  pxHit[ii][0] = px[idigi][0];
459  pyHit[ii][0] = py[idigi][0];
460  pzHit[ii][0] = pz[idigi][0];
461  gmotherHit[ii][0] = gmother[idigi][0];
462  ggmotherHit[ii][0] = ggmother[idigi][0];
463  gggmotherHit[ii][0] = gggmother[idigi][0];
464 
465  MCEnergyHit[ii][1] = MCEnergy[idigi][1];
466  pidHit[ii][1] = pid[idigi][1] ;
467  pxHit[ii][1] = px[idigi][1];
468  pyHit[ii][1] = py[idigi][1];
469  pzHit[ii][1] = pz[idigi][1];
470  gmotherHit[ii][1] = gmother[idigi][1];
471  ggmotherHit[ii][1] = ggmother[idigi][1];
472  gggmotherHit[ii][1] = gggmother[idigi][1];
473 
474  MCEnergyHit[ii][2] = MCEnergy[idigi][2];
475  pidHit[ii][2] = pid[idigi][2] ;
476  pxHit[ii][2] = px[idigi][2];
477  pyHit[ii][2] = py[idigi][2];
478  pzHit[ii][2] = pz[idigi][2];
479  gmotherHit[ii][2] = gmother[idigi][2];
480  ggmotherHit[ii][2] = ggmother[idigi][2];
481  gggmotherHit[ii][2] = gggmother[idigi][2];
482  }
483 
484 
485 
486  trgeclHitToMCPart.add(ii, TCPrimaryIndexHit[ii][0]);
487  }
488 
489  StoreArray<TRGECLHitMC> TCHitArray;
490  for (int ii = 0; ii < trgeclHitArray.getEntries(); ++ii) {
491  TCHitArray.appendNew();
492  int m_hitNum = TCHitArray.getEntries() - 1;
493 
494  TCHitArray[m_hitNum]->setEventId(m_nEvent);
495  TCHitArray[m_hitNum]-> setTCId(TCIdHit[ii]);
496  TCHitArray[m_hitNum]->setCellId(XtalIdHit[ii]);
497  TCHitArray[m_hitNum]->setEnergyDep(TCHitEnergy[ii]);
498  TCHitArray[m_hitNum]-> setTimeAve(TCHitTiming[ii]);
499  TCHitArray[m_hitNum]-> setTrackId(trackIdHit[ii]);
500  TCHitArray[m_hitNum]-> setPDG(pidHit[ii]);
501  TCHitArray[m_hitNum]->setMother(motherHit[ii]);
502  TCHitArray[m_hitNum]->setGMother(gmotherHit[ii]);
503  TCHitArray[m_hitNum]->setGGMother(ggmotherHit[ii]);
504  TCHitArray[m_hitNum]->setGGGMother(gggmotherHit[ii]);
505  TCHitArray[m_hitNum]->setPX(pxHit[ii]);
506  TCHitArray[m_hitNum]->setPY(pyHit[ii]);
507  TCHitArray[m_hitNum]->setPZ(pzHit[ii]);
508  TCHitArray[m_hitNum]->setMCEnergy(MCEnergyHit[ii]);
509  TCHitArray[m_hitNum]->setBackgroundTag(background_tagHit[ii]);
510  TCHitArray[m_hitNum]->setSignalContribution(SignalContributionHit[ii]);
511  TCHitArray[m_hitNum]->setBKGContribution(BKGContributionHit[ii]);
512  TCHitArray[m_hitNum]->setContribution(contributionHit[ii]);
513 
514  }
515 
516  ++m_nEvent;
517 
518 }
519 
520 
522 {
523  ++m_nRun;
524 }
525 
527 {
528 }
529 
530 
Class to store simulated hits which equate to average of ECLSImHit on crystals input for digitization...
Definition: ECLHit.h:25
int getCellId() const
Get Cell ID.
Definition: ECLHit.h:65
double getEnergyDep() const
Get deposit energy.
Definition: ECLHit.h:70
double pz[100][3]
Momentum Z of particle.
double BKGContribution[100]
Backgroun Contribution in a TC
int background_tag[100][3]
Beam background tag.
int gmotherHit[100][3]
Grand mother ID
double contributionHit[100][3]
particles contribution
virtual void initialize() override
Initialize variables, print info, and start CPU clock.
StoreArray< TRGECLDigi0MC > m_trgECLDigi0MC
output for TRGECLDigi0MC
double pxHit[100][3]
Momentum X of particle.
int ggmother[100][3]
Grand Grand Mother ID
double MCEnergy[100][3]
Raw Energy of particle
virtual void event() override
Actual digitization of all hits in the ECL.
double SignalContribution[100]
Signal Contibution in a TC.
double contribution[100][3]
particles contribution
double py[100][3]
Momentum Y of particle.
virtual void endRun() override
Nothing so far.
double BKGContributionHit[100]
Backgroun Contribution in a TC
int gggmotherHit[100][3]
Grand Grand Grand Mother ID
virtual void terminate() override
Stopping of CPU clock.
int gmother[100][3]
Grand mother ID
double TCHitEnergy[100]
TC Hit energy
int TCPrimaryIndexHit[100][3]
Primary Index in TC hit
double pzHit[100][3]
Momentum X of particle.
double MCEnergyHit[100][3]
Raw Energy of particle
double SignalContributionHit[100]
Signal Contibution in a TC.
int ggmotherHit[100][3]
Grand Grand Mother ID
int TCPrimaryIndex[100][3]
Primary Index in TC hit
StoreArray< TRGECLHitMC > m_trgECLHitMC
output for TRGECLHitMC
virtual void beginRun() override
Nothing so far.
int gggmother[100][3]
Grand Grand Grand Mother ID
double maxEnergy[100][3]
Energy of maximum contribtion particle
double TCRawEnergy[100]
TC raw energy.
virtual ~MCMatcherTRGECLModule()
Destructor.
int background_tagHit[100][3]
Beam background tag.
double pyHit[100][3]
Momentum X of particle.
double TCHitTiming[100]
TC Hit Timking
std::map< int, int > PrimaryTrackMap
define a map for Primary Track
int XtalIdHit[100][3]
XtalId in TC
double TCRawTiming[100]
TC raw timing.
double px[100][3]
Momentum X of particle.
TrgEclMapping * _TCMap
object of TC Mapping
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:47
@ c_StableInGenerator
bit 1: Particle is stable, i.e., not decaying in the generator.
Definition: MCParticle.h:49
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
Low-level class to create/modify relations between StoreArrays.
Definition: RelationArray.h:62
int getEntries() const
Get the number of elements.
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
virtual unsigned short getBackgroundTag() const
Get background tag.
Definition: SimHitBase.h:46
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
void clear() override
Delete all entries in this array.
Definition: StoreArray.h:207
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:140
Raw TC result nefor digitizing.
Definition: TRGECLDigi0.h:21
double getRawTiming() const
Get raw TC timing.
Definition: TRGECLDigi0.h:64
int getTCId() const
Get TC id.
Definition: TRGECLDigi0.h:57
double getRawEnergy() const
Get Energy and Timing Get raw TC energy.
Definition: TRGECLDigi0.h:62
Example Detector.
Definition: TRGECLHit.h:22
double getTimeAve() const
The method to get hit average time.
Definition: TRGECLHit.h:64
int getTCId() const
The method to get TC id.
Definition: TRGECLHit.h:58
A class of TC Mapping.
Definition: TrgEclMapping.h:26
int getTCIdFromXtalId(int)
get [TC ID] from [Xtal ID]
static const double us
[microsecond]
Definition: Unit.h:97
static const double GeV
Standard of [energy, momentum, mass].
Definition: Unit.h:51
#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.