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