ATLAS Offline Software
TileHitVecToCntTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //************************************************************
6 // FileName : TileHitVecToCntTool.cxx
7 // Author : Vishnu Zutshi
8 // Created : Dec. 2009
9 //************************************************************
10 
11 // Tile includes
18 
19 // Calo includes
20 #include "CaloIdentifier/TileID.h"
22 
23 // Athena includes
25 #include "StoreGate/WriteHandle.h"
29 // For the Athena-based random numbers.
32 
33 #include "CLHEP/Random/Randomize.h"
34 #include "CLHEP/Random/RandomEngine.h"
35 #include "TileSimEvent/TileHit.h"
36 
37 #include <algorithm>
38 #include <functional>
39 #include <memory>
40 
41 using CLHEP::RandFlat;
42 using CLHEP::RandGaussQ; // FIXME CLHEP::RandGaussZiggurat is faster and more accurate.
43 using CLHEP::RandPoissonT;
44 using CLHEP::RandGeneral;
45 
47  const std::string& name,
48  const IInterface* parent)
50 {
51 }
52 
54 
55  ATH_MSG_DEBUG("TileHitVecToCntTool initialization started");
56 
57  bool error = false;
58 
59  ATH_CHECK(m_rndmSvc.retrieve());
60 
61  // retrieve TileID helper from det store
63 
65 
67 
69 
70  ATH_CHECK(m_cablingSvc.retrieve());
71  m_cabling = m_cablingSvc->cablingService();
72 
75 
76  if (!m_usePhotoStatistics) {
77  ATH_MSG_INFO("No photostatistics effect will be simulated");
78  }
79 
80  if (m_rndmEvtOverlay) {
81  m_pileUp = false;
82  ATH_MSG_INFO("Zero-luminosity pile-up selected");
83  ATH_MSG_INFO("Taking hits from original event only");
84  }
85 
86  if (m_pileUp || m_rndmEvtOverlay) {
87  ATH_MSG_INFO("take events from PileUp service");
88 
90  ATH_CHECK(m_mergeSvc.retrieve());
91  }
92 
93  if (m_useTriggerTime) {
94  ATH_MSG_INFO(" In case of pileup, the trigger time subtraction is done in PileUpSvc");
95  ATH_MSG_INFO(" => TileHitVecToCnt will not apply Trigger Time ");
96  m_useTriggerTime = false;
97  }
98  m_timeFlag = 0;
99 
100  if (m_pileUp) {
102  }
103 
104  } else {
105 
106  ATH_MSG_INFO("no pile up");
107 
108  if (m_useTriggerTime) {
109 
110  m_timeFlag = 2;
111 
112  if (!m_triggerTimeKey.empty()) {
113  ATH_MSG_INFO( "Trigger time is taken from external ojbect '" << m_triggerTimeKey.key()
114  << "'; therefore set HitTimeFlag to 2");
116  }
117  }
118 
119  switch (m_timeFlag) {
120  case 2:
121  if (m_triggerTimeKey.empty()) {
122  if (m_triggerTime > 0.0) {
123  m_useTriggerTime = true;
124  ATH_MSG_INFO("Fixed trigger time of " << m_triggerTime << " ns will be used");
125  } else if (m_triggerTime < 0.0) {
126  m_useTriggerTime = false;
127  ATH_MSG_INFO( "Minimal hit time will be used as trigger time"
128  << " with random additional shift between 0 and " << -m_triggerTime << " ns");
129  } else {
130  m_useTriggerTime = false;
131  ATH_MSG_INFO("Average time will be calculated in every event");
132  }
133  }
134  break;
135  case 1:
136  ATH_MSG_INFO("Time of all hits will be reset to zero");
137  break;
138  default:
139  ATH_MSG_INFO("Time of all hits will be preserved during copy");
140  m_timeFlag = 0;
141  break;
142  }
143  }
144 
145  if (m_run2plus) {
147 
150 
151  for (int ros = 3; ros < 5; ++ros) {
152  for (int drawer = 0; drawer < 64; ++drawer) {
153  int frag_id = m_tileHWID->frag(ros, drawer);
154  IdentifierHash frag_hash = m_fragHashFunc(frag_id);
155  m_E1merged[frag_hash] = (m_cabling->E1_merged_with_run2plus(ros, drawer) != 0);
157  }
158  }
159  ATH_MSG_INFO("Number of E1 cell to be merged: " << std::count (m_E1merged.begin(), m_E1merged.end(), true));
160  ATH_MSG_INFO("Number of MBTS cell to be merged: " << std::count (m_MBTSmerged.begin(), m_MBTSmerged.end(), true));
161  }
162 
164  m_hitVectorNames = m_inputKeys.value();
165  }
166  else {
167  ATH_CHECK(m_hitVectorKeys.assign(m_inputKeys.value()));
168  }
169  ATH_MSG_DEBUG("Input objects in these containers : '" << m_hitVectorNames << "'");
170 
171  // Initialize ReadHandleKey
173 
176 
177  ATH_MSG_DEBUG("TileHitVecToCntTool initialization completed");
178 
179  if (error)
180  return StatusCode::RECOVERABLE;
181  else
182  return StatusCode::SUCCESS;
183 }
184 
186 
187  ATH_MSG_VERBOSE("TileHitVecToCntTool createContainers started");
188 
189  if (m_pileUp) {
190  m_hits = std::make_unique<TileHitNonConstContainer>(SG::VIEW_ELEMENTS);
191  if(m_doDigiTruth) m_hits_DigiHSTruth = std::make_unique<TileHitNonConstContainer>(SG::VIEW_ELEMENTS);
192 
193  if (m_allHits.empty()) {
194 
197 
198  } else {
199  for (std::unique_ptr<TileHit>& hit : m_allHits) {
200  hit->setZero();
201  }
202 
203  if(m_doDigiTruth){
204  for (std::unique_ptr<TileHit>& hit : m_allHits_DigiHSTruth) {
205  hit->setZero();
206  }
207  }
208  }
209  } else {
210  m_hits = std::make_unique<TileHitNonConstContainer>(SG::OWN_ELEMENTS);
211  if(m_doDigiTruth) m_hits_DigiHSTruth = std::make_unique<TileHitNonConstContainer>(SG::OWN_ELEMENTS);
212 
213  }
214 
215  ATH_MSG_VERBOSE("TileHitVecToCntTool createContainers finished");
216 
217  return StatusCode::SUCCESS;
218 
219 }
220 
221 StatusCode TileHitVecToCntTool::prepareEvent(const EventContext& ctx, unsigned int /*nInputEvents*/) {
222 
223  ATH_MSG_DEBUG("TileHitVecToCntTool prepareEvent initialization started");
224 
225  CHECK(this->createContainers());
226 
227  ATH_MSG_DEBUG("TileHitVecToCntTool prepareEvent finished");
228 
229  ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, m_randomStreamName);
230  rngWrapper->setSeed( m_randomStreamName, ctx );
231 
232  return StatusCode::SUCCESS;
233 }
234 
235 void TileHitVecToCntTool::processHitVectorForOverlay(const TileHitVector* inputHits, std::unique_ptr<TileHitNonConstContainer>& hits, int& nHit, double& eHitTot) const {
236 
237  TileHitVecConstIterator inpItr = inputHits->begin();
238  TileHitVecConstIterator end = inputHits->end();
239 
240  for (; inpItr != end; ++inpItr) {
241 
242  const TileHit * cinp = &(*inpItr);
243 
244  eHitTot += cinp->energy(); // not really correct if TileHit contains vector of energies
245  // but eHitTot is needed for debug purposes only
246  TileHit * pHit = new TileHit(*cinp);
247  hits->push_back(pHit);
248  ++nHit;
249 
250  if (msgLvl(MSG::VERBOSE)) {
251  int hitsize = cinp->size();
252  double eHit = 0.0;
253  double tHit = 0.0;
254  for (int i = 0; i < hitsize; ++i) {
255  eHit += cinp->energy(i);
256  tHit += cinp->time(i) * cinp->energy(i);
257  }
258  if (eHit > 0.0)
259  tHit /= eHit;
260  else
261  tHit = cinp->time();
262 
263  eHitTot += eHit - cinp->energy(); // put total energy instead of first hit energy
264 
265  msg(MSG::VERBOSE) << " nHit=" << nHit
266  << " id=" << m_tileID->to_string(cinp->identify(), -1)
267  << " eHit=" << eHit
268  << " tHit=" << tHit
269  << " Copy hit: ener=";
270  for (int i = 0; i < hitsize; ++i)
271  msg(MSG::VERBOSE) << cinp->energy(i) << " ";
272  msg(MSG::VERBOSE) << "time=";
273  for (int i = 0; i < hitsize; ++i)
274  msg(MSG::VERBOSE) << cinp->time(i) << " ";
275  msg(MSG::VERBOSE) << endmsg;
276  }
277  }
278  return;
279 }
280 
281 void TileHitVecToCntTool::processHitVectorForPileUp(const TileHitVector* inputHits, double SubEvtTimOffset,
282  std::vector<std::unique_ptr<TileHit>>& allHits,
283  std::vector<std::unique_ptr<TileHit>>& allHits_DigiHSTruth,
284  int& nHit, double& eHitTot, bool isSignal) const {
285 
286  IdContext pmt_context = m_tileID->pmt_context();
287  IdContext tbchannel_context = m_tileTBID->channel_context();
288  IdentifierHash hit_idhash;
289 
290  // Loop over hits in this HitVector
291  TileHitVecConstIterator inpItr = inputHits->begin();
292  TileHitVecConstIterator end = inputHits->end();
293 
294  for (; inpItr != end; ++inpItr) {
295 
296  const TileHit * cinp = &(*inpItr);
297  Identifier hit_id = cinp->identify();
298 
299  if (m_tileTBID->is_tiletb(hit_id)) {
300  int side = std::max(0, m_tileTBID->type(hit_id));
301  int phi = m_tileTBID->module(hit_id);
302  int eta = m_tileTBID->channel(hit_id);
303  if (eta < 2)
304  hit_idhash = mbts_index(side, phi, eta);
305  else
306  hit_idhash = e4pr_index(phi);
307  } else {
308  m_tileID->get_hash(hit_id, hit_idhash, &pmt_context);
309  }
310 
311  if (hit_idhash >= allHits.size()) {
312  // Seems to be E4pr or MBTS hit in minimum bias while geometry is used without them => skipping
313  continue;
314  }
315 
316  double ener = cinp->energy();
317  double time = cinp->time() + SubEvtTimOffset;
318 
319  ++nHit;
320  eHitTot += ener;
321 
322  std::unique_ptr<TileHit>& pHit = allHits[hit_idhash];
323  std::unique_ptr<TileHit> inValidHit(nullptr);
324  std::unique_ptr<TileHit>& pHit_DigiHSTruth = m_doDigiTruth ? allHits_DigiHSTruth[hit_idhash] : inValidHit;
325 
326  if (time < m_maxHitTime){
327  pHit->add(ener, time, m_deltaT);
328  if(m_doDigiTruth){
329  if(isSignal) {
330  pHit_DigiHSTruth->add(ener, time, m_deltaT);
331  } else {
332  pHit_DigiHSTruth->add(0,time, m_deltaT);
333  }
334  }
335  }
336 
337  if (msgLvl(MSG::VERBOSE)) {
338  if (pHit->size() > 1 || pHit->energy() != 0.0)
339  msg(MSG::VERBOSE) << " nHit=" << nHit
340  << " id=" << m_tileID->to_string(hit_id, -1)
341  << " ener=" << ener
342  << " time=" << time
343  << " offs=" << SubEvtTimOffset
344  << " double hit" << endmsg;
345  else
346  msg(MSG::VERBOSE) << " nH=" << nHit
347  << " id=" << m_tileID->to_string(hit_id, -1)
348  << " HWid=" << m_tileID->to_string(pHit->pmt_HWID())
349  << " e=" << ener
350  << " time=" << time
351  << " offs=" << SubEvtTimOffset
352  << " new hit" << endmsg;
353  }
354 
355  int hitsize = cinp->size();
356  for (int ind = 1; ind < hitsize; ++ind) { // if we have double hits in original hit
357  ener = cinp->energy(ind); // merge all of them with appropriate time
358  time = cinp->time(ind) + SubEvtTimOffset;
359 
360  ++nHit;
361  eHitTot += ener;
362 
363  if (time < m_maxHitTime){
364  pHit->add(ener, time, m_deltaT);
365  if(m_doDigiTruth){
366  if(isSignal)
367  pHit_DigiHSTruth->add(ener, time, m_deltaT);
368  else
369  pHit_DigiHSTruth->add(0, time, m_deltaT);
370  }
371  }
372 
373  if (msgLvl(MSG::VERBOSE))
374  msg(MSG::VERBOSE) << " nHit=" << nHit
375  << " id=" << m_tileID->to_string(hit_id, -1)
376  << " ener=" << ener
377  << " time=" << time
378  << " double hit from single hit" << endmsg;
379  }
380  } // loop over hits in one vector
381  return;
382 }
383 
384 void TileHitVecToCntTool::processHitVectorWithoutPileUp(const TileHitVector* inputHits, int& nHit, double& eHitTot, TileHitNonConstContainer* hitCont, CLHEP::HepRandomEngine * engine) const {
385 
386  TileHitVecConstIterator inpItr = inputHits->begin();
387  TileHitVecConstIterator end = inputHits->end();
388 
389  //**
390  //* Iterate over hits, creating new TileHits
391  //* Add each TileHit to the TileHitContainer.
392  //**
393 
394  switch (m_timeFlag) {
395 
396  case 0: {
397  for (; inpItr != end; ++inpItr) {
398  const TileHit * cinp = &(*inpItr);
399  eHitTot += cinp->energy(); // not really correct if TileHit contains vector of energies
400  // but eHitTot is needed for debug purposes only
401  TileHit * pHit = new TileHit(*cinp);
402  hitCont->push_back(pHit);
403  ++nHit;
404 
405  if (msgLvl(MSG::VERBOSE)) {
406  int hitsize = cinp->size();
407  double eHit = 0.0;
408  double tHit = 0.0;
409  for (int i = 0; i < hitsize; ++i) {
410  eHit += cinp->energy(i);
411  tHit += cinp->time(i) * cinp->energy(i);
412  }
413  if (eHit > 0.0)
414  tHit /= eHit;
415  else
416  tHit = cinp->time();
417 
418  eHitTot += eHit - cinp->energy(); // put total energy instead of first hit energy
419 
420  msg(MSG::VERBOSE) << " nHit=" << nHit
421  << " id=" << m_tileID->to_string(cinp->identify(), -1)
422  << " eHit=" << eHit
423  << " tHit=" << tHit
424  << " Copy hit: ener=";
425  for (int i = 0; i < hitsize; ++i)
426  msg(MSG::VERBOSE) << cinp->energy(i) << " ";
427  msg(MSG::VERBOSE) << "time=";
428  for (int i = 0; i < hitsize; ++i)
429  msg(MSG::VERBOSE) << cinp->time(i) << " ";
430  msg(MSG::VERBOSE) << endmsg;
431  }
432  }
433  break;
434  }
435 
436  case 1: {
437 
438  for (; inpItr != end; ++inpItr) {
439  const TileHit * cinp = &(*inpItr);
440  int size = cinp->size();
441  double eHit = 0.0;
442  for (int i = 0; i < size; ++i) {
443  eHit += cinp->energy(i);
444  }
445  eHitTot += eHit;
446 
447  // create hit with total energy at time=0 instead of original one
448  Identifier pmID = cinp->pmt_ID();
449  TileHit * pHit = new TileHit(pmID, eHit, 0.);
450 
451  hitCont->push_back(pHit);
452  ++nHit;
453 
454  if (msgLvl(MSG::VERBOSE)) {
455  int hitsize = cinp->size();
456  msg(MSG::VERBOSE) << " nHit=" << nHit
457  << " id=" << m_tileID->to_string(cinp->identify(), -1)
458  << " eHit=" << eHit
459  << " tHit=0.0"
460  << " Input hit: ener=";
461  for (int i = 0; i < hitsize; ++i)
462  msg(MSG::VERBOSE) << cinp->energy(i) << " ";
463  msg(MSG::VERBOSE) << "time=";
464  for (int i = 0; i < hitsize; ++i)
465  msg(MSG::VERBOSE) << cinp->time(i) << " ";
466  msg(MSG::VERBOSE) << endmsg;
467  }
468  }
469  break;
470 
471  }
472 
473  case 2: {
474 
475  double avtime = 0.0;
476 
477  if (m_useTriggerTime) {
478 
479  if (m_triggerTimeKey.empty()) {
480  avtime = m_triggerTime;
481  } else {
483  avtime = cosTriggerTime->time();
484  }
485  ATH_MSG_DEBUG("Trigger time used : " << avtime);
486 
487  } else {
488 
489  if (m_triggerTime < 0.0) {
490 
491  avtime = 1.0e20;
492 
493  // loop to find minimal time
494  for (; inpItr != end; ++inpItr) {
495  const TileHit * cinp = &(*inpItr);
496  int size = cinp->size();
497  for (int i = 0; i < size; ++i) {
498  if (cinp->time(i) < avtime) avtime = cinp->time(i);
499  }
500  }
501  ATH_MSG_DEBUG("Minimal time in input event " << avtime);
502  double shift = RandFlat::shoot(engine, m_triggerTime, 0.0);
503  ATH_MSG_DEBUG("Minimal time after random shift " << shift);
504  avtime -= shift; // subtracting negative shift value here
505 
506  } else {
507 
508  double weight = 0.0;
509 
510  // loop to calculate average time
511  for (; inpItr != end; ++inpItr) {
512  const TileHit * cinp = &(*inpItr);
513  int size = cinp->size();
514  for (int i = 0; i < size; ++i) {
515  avtime += cinp->time(i) * cinp->energy(i);
516  weight += cinp->energy(i);
517  }
518  }
519  if (weight > 0.0)
520  avtime /= weight;
521  else
522  avtime = 0.0;
523 
524  ATH_MSG_DEBUG("Average time used : " << avtime);
525  }
526 
527  // reset iterator to the first hit
528  inpItr = inputHits->begin();
529  }
530 
531  for (; inpItr != end; ++inpItr) {
532  const TileHit * cinp = &(*inpItr);
533  TileHit * pHit = new TileHit(*cinp);
534  // subract average time from all time bins in the hit
535  int size = pHit->size();
536  for (int i = 0; i < size; ++i) {
537  pHit->setTime(pHit->time(i) - avtime, i);
538  eHitTot += cinp->energy(i);
539  }
540 
541  hitCont->push_back(pHit);
542  ++nHit;
543 
544  if (msgLvl(MSG::VERBOSE)) {
545  int hitsize = pHit->size();
546  double eHit = 0.0;
547  double tHit = 0.0;
548  for (int i = 0; i < hitsize; ++i) {
549  eHit += pHit->energy(i);
550  tHit += pHit->time(i) * cinp->energy(i);
551  }
552  if (eHit > 0.0)
553  tHit /= eHit;
554  else
555  tHit = cinp->time(); // just first time
556 
557  msg(MSG::VERBOSE) << " nHit=" << nHit
558  << " id=" << m_tileID->to_string(pHit->identify(), -1)
559  << " eHit=" << eHit
560  << " tHit=" << tHit
561  << " Output hit: ener=";
562  for (int i = 0; i < hitsize; ++i)
563  msg(MSG::VERBOSE) << pHit->energy(i) << " ";
564  msg(MSG::VERBOSE) << "time=";
565  for (int i = 0; i < hitsize; ++i)
566  msg(MSG::VERBOSE) << pHit->time(i) << " ";
567  msg(MSG::VERBOSE) << endmsg;
568  }
569  }
570  break;
571  }
572 
573  default:
574  ATH_MSG_ERROR("unexpected value m_timeFlag=" << m_timeFlag);
575  break;
576  }
577 
578  return;
579 }
580 
582  , SubEventIterator bSubEvents
583  , SubEventIterator eSubEvents)
584 {
585 
586  ATH_MSG_DEBUG("Inside TileHitVecToCntTool processBunchXing" << bunchXing);
587  // setFilterPassed(true);
588 
589  ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, m_randomStreamName);
590  CLHEP::HepRandomEngine * engine = rngWrapper->getEngine(Gaudi::Hive::currentContext());
591 
592  SubEventIterator iEvt(bSubEvents);
593  if (m_rndmEvtOverlay && bunchXing != 0) iEvt = eSubEvents; // in overlay skip all events except BC=0
594 
595  while (iEvt != eSubEvents) {
596  /* zero all counters and sums */
597  int nHit(0);
598  double eHitTot(0.0);
599 
600  std::vector<std::string>::const_iterator hitVecNamesItr = m_hitVectorNames.begin();
601  std::vector<std::string>::const_iterator hitVecNamesEnd = m_hitVectorNames.end();
602  for (; hitVecNamesItr != hitVecNamesEnd; ++hitVecNamesItr) {
603 
604  const std::string hitVectorName(*hitVecNamesItr);
605 
606  if (m_pileUp || m_rndmEvtOverlay) {
607 
608  const TileHitVector* inputHits = nullptr;
609  if (!(m_mergeSvc->retrieveSingleSubEvtData(hitVectorName, inputHits, bunchXing, iEvt))){
610  ATH_MSG_ERROR(" Tile Hit container not found for event key " << hitVectorName);
611  }
612 
613  const double SubEvtTimOffset(iEvt->time());
614 
615  if (m_rndmEvtOverlay) { // overlay code
616  if (fabs(SubEvtTimOffset) > 0.1) {
617  ATH_MSG_ERROR("Wrong time for in-time event: " << SubEvtTimOffset << " Ignoring all hits ");
618  } else {
619  ATH_MSG_DEBUG(" New HitCont. TimeOffset=" << SubEvtTimOffset << ", size =" << inputHits->size());
620  this->processHitVectorForOverlay(inputHits, m_hits, nHit, eHitTot);
621  //if( m_doDigiTruth && iEvt == bSubEvents) this->processHitVectorWithoutPileUp(inputHits, nHit, eHitTot, m_signalHits, engine);
622  }
623  } else if (m_pileUp) { // pileup code
624  bool isSignal = false;
625  if(iEvt == bSubEvents) isSignal = true;
626  this->processHitVectorForPileUp(inputHits, SubEvtTimOffset, m_allHits, m_allHits_DigiHSTruth, nHit, eHitTot, isSignal);
627  }
628  } else { // no PileUp
629  //**
630  //* Get TileHits from TileHitVector
631  //**
632  const TileHitVector * inputHits = nullptr;
633  if (!(m_mergeSvc->retrieveSingleSubEvtData(hitVectorName, inputHits, bunchXing, iEvt))){
634  ATH_MSG_ERROR(" Tile Hit container not found for event key " << hitVectorName);
635  }
636 
637  this->processHitVectorWithoutPileUp(inputHits, nHit, eHitTot, m_hits.get(), engine);
638  if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits, nHit, eHitTot, m_hits_DigiHSTruth.get(), engine);
639  } // to pile-up or not
640 
641  } // end of the loop over different input hitVectorNames (normal hits and MBTS hits)
642 
643  ++iEvt;
644  if (m_rndmEvtOverlay) iEvt = eSubEvents; // in overlay skip all events except fisrt one
645  } // subEvent loop
646 
647  ATH_MSG_DEBUG("Exiting processBunchXing in TileHitVecToCntTool");
648 
649  return StatusCode::SUCCESS;
650 }
651 
653  return ((const TileHitVecToCntTool*) this)->processAllSubEvents(ctx);
654 }
655 
656 
657 StatusCode TileHitVecToCntTool::processAllSubEvents(const EventContext& ctx) const {
658 
659 
660  ATH_MSG_DEBUG("TileHitVecToCntTool processAllSubEvents started");
661  typedef PileUpMergeSvc::TimedList<TileHitVector>::type TimedHitContList;
662 
664 
665  std::vector<std::unique_ptr<TileHit>> allHits;
666  auto hits = std::make_unique<TileHitNonConstContainer>(ownPolicy);
667 
668  std::vector<std::unique_ptr<TileHit>> allHits_DigiHSTruth;
669  std::unique_ptr<TileHitNonConstContainer> hits_DigiHSTruth;
670  if (m_doDigiTruth) {
671  hits_DigiHSTruth = std::make_unique<TileHitNonConstContainer>(ownPolicy);
672  }
673  if (m_pileUp) {
674  prepareAllHits(allHits);
675  if (m_doDigiTruth) {
676  prepareAllHits(allHits_DigiHSTruth);
677  }
678  }
679 
680  /* zero all counters and sums */
681  int nHit(0);
682  double eHitTot(0.0);
683 
684  ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, m_randomStreamName);
685  rngWrapper->setSeed( name(), ctx );
686  CLHEP::HepRandomEngine * engine = rngWrapper->getEngine(ctx);
687 
689  auto hitVectorHandles = m_hitVectorKeys.makeHandles(ctx);
690  for (auto & inputHits : hitVectorHandles) {
691  if (!inputHits.isValid()) {
692  ATH_MSG_ERROR("Input Tile hit container is missing!");
693  return StatusCode::FAILURE;
694  }
695  const double SubEvtTimeOffset(0.0);
696  // get HitVector for this subevent
697  ATH_MSG_DEBUG(" New HitCont. TimeOffset=" << SubEvtTimeOffset << ", size =" << inputHits->size());
698  this->processHitVectorForOverlay(inputHits.cptr(), hits, nHit, eHitTot);
699  if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits.cptr(), nHit, eHitTot, hits_DigiHSTruth.get(), engine);
700  }
701  ATH_CHECK(commitContainers(ctx, hits, hits_DigiHSTruth, ownPolicy));
702  return StatusCode::SUCCESS;
703  }
704 
705  for (const auto& hitVectorName : m_hitVectorNames) {
706 
707  if (m_pileUp || m_rndmEvtOverlay) {
708  TimedHitContList hitContList;
709  // retrive list of pairs (time,container) from PileUp service
710  if (!(m_mergeSvc->retrieveSubEvtsData(hitVectorName, hitContList).isSuccess()) || hitContList.size() == 0) {
711  ATH_MSG_WARNING("Could not fill TimedHitContList for hit vector " << hitVectorName);
712  continue; // continue to the next hit vector
713  }
714 
715  // loop over this list
716  TimedHitContList::iterator iCont(hitContList.begin());
717  TimedHitContList::iterator iEndCont(hitContList.end());
718 
719  if (m_rndmEvtOverlay) { // overlay code
720  if (iCont != iEndCont) { // use only hits from first container
721  // get time for this subevent
722  const double SubEvtTimeOffset(iCont->first.time());
723  if (fabs(SubEvtTimeOffset) > 0.1) {
724  ATH_MSG_ERROR("Wrong time for in-time event: " << SubEvtTimeOffset << " Ignoring all hits ");
725  } else {
726  // get HitVector for this subevent
727  const TileHitVector* inputHits = &(*(iCont->second));
728  ATH_MSG_DEBUG(" New HitCont. TimeOffset=" << SubEvtTimeOffset << ", size =" << inputHits->size());
729  this->processHitVectorForOverlay(inputHits, hits, nHit, eHitTot);
730  if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits, nHit, eHitTot, hits_DigiHSTruth.get(), engine);
731  }
732  }
733  } else if (m_pileUp) { // pileup code
734 
735  for (; iCont != iEndCont; ++iCont) {
736  // get time for this subevent
737  const double SubEvtTimeOffset(iCont->first.time());
738  // get HitVector for this subevent
739  const TileHitVector* inputHits = &(*(iCont->second));
740  ATH_MSG_VERBOSE(" New HitCont. TimeOffset=" << SubEvtTimeOffset << ", size =" << inputHits->size());
741  bool isSignal = false;
742  if(iCont == hitContList.begin() ) isSignal = true;
743  this->processHitVectorForPileUp(inputHits, SubEvtTimeOffset, allHits, allHits_DigiHSTruth, nHit, eHitTot, isSignal);
744  }
745  } // loop over subevent list
746  } else { // no PileUp
747 
748  //**
749  //* Get TileHits from TileHitVector
750  //**
751  SG::ReadHandle<TileHitVector> inputHits(hitVectorName);
752  if (!inputHits.isValid()) {
753  ATH_MSG_WARNING("Hit Vector "<< hitVectorName << " not found in StoreGate");
754  continue; // continue to the next hit vector
755  }
756  this->processHitVectorWithoutPileUp(inputHits.cptr(), nHit, eHitTot, hits.get(), engine);
757  if(m_doDigiTruth) this->processHitVectorWithoutPileUp(inputHits.cptr(), nHit, eHitTot, hits_DigiHSTruth.get(), engine);
758  }
759 
760  } // end of the loop over different input hitVectorNames (normal hits and MBTS hits)
761 
762  if (m_pileUp) {
763  putAllHitsInContainer(allHits, allHits_DigiHSTruth, hits, hits_DigiHSTruth, ownPolicy);
764  }
765 
766  ATH_CHECK(commitContainers(ctx, hits, hits_DigiHSTruth, ownPolicy));
767 
768  return StatusCode::SUCCESS;
769 }
770 
771 void TileHitVecToCntTool::putAllHitsInContainer(std::vector<std::unique_ptr<TileHit>>& allHits,
772  std::vector<std::unique_ptr<TileHit>>& allHits_DigiHSTruth,
773  std::unique_ptr<TileHitNonConstContainer>& hits,
774  std::unique_ptr<TileHitNonConstContainer>& hits_DigiHSTruth,
775  SG::OwnershipPolicy ownPolicy) const {
776 
777  std::vector<std::unique_ptr<TileHit>>::iterator iHit = allHits.begin();
778  std::vector<std::unique_ptr<TileHit>>::iterator lastHit = allHits.end();
779  std::vector<std::unique_ptr<TileHit>>::iterator iHit_DigiHSTruth = allHits_DigiHSTruth.begin();
780 
781  int nHitUni = 0;
782  double eHitInTime = 0.0;
783 
784  ATH_MSG_DEBUG("Hits being stored in container");
785 
786  std::function<TileHit*(std::unique_ptr<TileHit>&)> getOrRelease(&std::unique_ptr<TileHit>::get);
787  if (ownPolicy == SG::OWN_ELEMENTS) getOrRelease = &std::unique_ptr<TileHit>::release;
788 
789  for (; iHit != lastHit; ++iHit) {
790  std::unique_ptr<TileHit>& hit = (*iHit);
791  if (hit->size() > 1 || hit->energy() != 0.0) { // hit exists
792  eHitInTime += hit->energy();
793  hits->push_back(getOrRelease(hit));
794  if(m_doDigiTruth) hits_DigiHSTruth->push_back(getOrRelease((*iHit_DigiHSTruth)));
795  ++nHitUni;
796  }
797  if(m_doDigiTruth) ++iHit_DigiHSTruth;
798  }
799 
800  ATH_MSG_DEBUG(" nHitUni=" << nHitUni << " eHitInTime="<< eHitInTime);
801 }
802 
804  std::unique_ptr<TileHitNonConstContainer>& hits,
805  std::unique_ptr<TileHitNonConstContainer>& hits_DigiHSTruth,
806  SG::OwnershipPolicy ownPolicy) const {
807 
808  ATH_MSG_DEBUG("Entering commitContainers");
809 
810  if (!m_pileUp) {
813  if (m_doDigiTruth) {
814  findAndMergeMultipleHitsInChannel(hits_DigiHSTruth);
815  }
816  }
817  }
818 
819  if (m_run2plus) {
820  // Merge MBTS and E1 where it is needed.
821 
822  for (std::unique_ptr<TileHitCollection>& coll : *hits ) {
823  int frag_id = coll->identify();
824  IdentifierHash frag_hash = m_fragHashFunc(frag_id);
825  if (m_E1merged[frag_hash])
826  findAndMergeE1(coll.get(), frag_id, hits.get());
827  else if (m_MBTSmerged[frag_hash]) findAndMergeMBTS(coll.get(), frag_id, hits.get());
828  }
829  if(m_doDigiTruth){
830  TileHitNonConstContainer::iterator collIt = hits_DigiHSTruth->begin();
831  TileHitNonConstContainer::iterator endcollIt = hits_DigiHSTruth->end();
832 
833  for (; collIt != endcollIt; ++collIt) {
834  int frag_id = (*collIt)->identify();
835  IdentifierHash frag_hash = m_fragHashFunc(frag_id);
836  if (m_E1merged[frag_hash]) findAndMergeE1((*collIt).get(), frag_id, hits_DigiHSTruth.get());
837  else if (m_MBTSmerged[frag_hash]) findAndMergeMBTS((*collIt).get(), frag_id, hits_DigiHSTruth.get());
838  }
839  }
840  }
841 
842  //photoelectron statistics.
843  //loop over all hits in TileHitContainer and take energy deposited in certain period of time
844  //std::vector<std::string>::const_iterator hitVecNamesEnd = m_hitVectorNames.end();
845 
846  ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, m_randomStreamName);
847  CLHEP::HepRandomEngine * engine = rngWrapper->getEngine(ctx);
848 
850  ATH_CHECK( samplingFraction.isValid() );
851 
852  TileHitNonConstContainer::iterator collIt_DigiHSTruth;
853  TileHitNonConstContainer::iterator endColl_DigiHSTruth;
854  if(m_doDigiTruth) {
855  collIt_DigiHSTruth = hits_DigiHSTruth->begin();
856  endColl_DigiHSTruth = hits_DigiHSTruth->end();
857  }
858 
859  for (std::unique_ptr<TileHitCollection>& coll : *hits ) {
860  TileHitCollection* coll_DigiHSTruth;
861  TileHitCollection::iterator hitItr_DigiHSTruth;
862  TileHitCollection::iterator hitEnd_DigiHSTruth;
863  if(m_doDigiTruth) {
864  coll_DigiHSTruth = (*collIt_DigiHSTruth).get();
865  hitItr_DigiHSTruth = coll_DigiHSTruth->begin();
866  hitEnd_DigiHSTruth = coll_DigiHSTruth->end();
867  }
868 
869  HWIdentifier drawer_id = m_tileHWID->drawer_id(coll->identify());
870  int ros = m_tileHWID->ros(drawer_id);
871  int drawer = m_tileHWID->drawer(drawer_id);
872  int drawerIdx = TileCalibUtils::getDrawerIdx(ros, drawer);
873 
874  for (TileHit* pHit : *coll) {
875  double ehit = 0.0;
876  int hitsize = pHit->size();
877  for (int i = 0; i < hitsize; ++i) {
878  double thit = pHit->time(i);
879  if (fabs(thit) < m_photoStatisticsWindow) ehit += pHit->energy(i);
880  }
881 
882  Identifier pmt_id = pHit->pmt_ID();
883  //HWIdentifier channel_id = (*hitItr)->pmt_HWID();
884  // for gap/crack scintillators
885  if (m_tileID->sample(pmt_id) == 3) {
886  pmt_id = m_tileID->pmt_id(m_tileID->cell_id(pmt_id), 0);
887  //channel_id = m_cabling->s2h_channel_id(pmt_id);
888  }
889 
890  double scaleFactor = 1.0;
891  if (m_usePhotoStatistics) {
892  scaleFactor = applyPhotoStatistics(ehit, pmt_id, engine, *samplingFraction, drawerIdx);
893  pHit->scale(scaleFactor);
894  }
895 
896  if(m_doDigiTruth){
897  TileHit *pHit_DigiHSTruth = (*hitItr_DigiHSTruth);
898  pHit_DigiHSTruth->scale(scaleFactor);
899 
900  ++hitItr_DigiHSTruth;
901  }
902  }
903 
904  if(m_doDigiTruth) ++collIt_DigiHSTruth;
905  }
906 
907 
908  /* Register the set of TileHits to the event store. */
909  auto hitCont = std::make_unique<TileHitContainer>(false, ownPolicy);
910  size_t hashId = 0;
911  for (std::unique_ptr<TileHitCollection>& coll : *hits ) {
912  CHECK(hitCont->addCollection (coll.release(), hashId++));
913  }
914 
916  ATH_CHECK( hitContainer.record(std::move(hitCont)) );
917 
918  ATH_MSG_DEBUG("TileHit container registered to the TES with name" << m_hitContainerKey.key());
919 
920  if(m_doDigiTruth){
921  auto hitCont_DigiHSTruth = std::make_unique<TileHitContainer>(false, ownPolicy);
922  size_t hashId_DigiHSTruth = 0;
923  for (std::unique_ptr<TileHitCollection>& coll : *hits_DigiHSTruth ) {
924  ATH_CHECK(hitCont_DigiHSTruth->addCollection (coll.release(), hashId_DigiHSTruth++));
925  }
926 
928  ATH_CHECK( hitContainer_DigiHSTruth.record(std::move(hitCont_DigiHSTruth)) );
929  }
930 
931  ATH_MSG_DEBUG("Exiting mergeEvent in TileHitVecToCntTool");
932  return StatusCode::SUCCESS;
933 }
934 
935 
936 StatusCode TileHitVecToCntTool::mergeEvent(const EventContext &ctx) {
938  if (m_pileUp) {
939  ownPolicy = SG::VIEW_ELEMENTS;
941  }
942  return commitContainers(ctx, m_hits, m_hits_DigiHSTruth, ownPolicy);
943 }
944 
946 
947  ATH_MSG_DEBUG("Finalizing TileHitVecToCntTool");
948 
949  ATH_MSG_DEBUG("TileHitVecToCntTool finalized");
950 
951  return StatusCode::SUCCESS;
952 
953 }
954 
955 double TileHitVecToCntTool::applyPhotoStatistics(double energy, Identifier pmt_id, CLHEP::HepRandomEngine* engine,
956  const TileSamplingFraction* samplingFraction, int drawerIdx) const {
957 
959  // take number of photoelectrons per GeV divide by 1000 to go to MeV
960  // and multiply by inverted sampling fraction (about 36, depends on G4 version, sampling and eta)
961  // to get number of photoelectrons per 1 MeV energy in scintillator
962  float nPhotoElectrons = samplingFraction->getNumberOfPhotoElectrons(drawerIdx, channel)
963  / (Gaudi::Units::GeV / Gaudi::Units::MeV) * samplingFraction->getSamplingFraction(drawerIdx, channel);
964 
965  nPhotoElectrons = std::round(nPhotoElectrons * 1000) / 1000;
966 
967  double pe = energy * nPhotoElectrons;
968  double pe_scale = 1., RndmPois = 1.;
969 
970  switch (m_photoElectronStatistics) {
971  case 2:
972  if (pe > 20.0) {
973  RndmPois = std::max(0.0, RandGaussQ::shoot(engine, pe, sqrt(pe))); // FIXME CLHEP::RandGaussZiggurat is faster and more accurate.
974  pe_scale = RndmPois / pe;
975  } else { // pe<=20
976 
977  if (pe > 0.) {
978  double singleMEAN = 1.0; //Parameterization of monoelectron spectra
979  double singleSIGMA = 1.0;
980  RndmPois = RandPoissonT::shoot(engine, pe);
981 
982  if (RndmPois > 0) {
983  pe_scale = 0;
984  for (int i = 0; i < RndmPois; i++)
985  pe_scale += 1 / (1.08332) * std::max(0., RandGaussQ::shoot(engine, singleMEAN, singleSIGMA)); // FIXME CLHEP::RandGaussZiggurat is faster and more accurate.
986 
987  pe_scale /= RndmPois;
988  } else
989  pe_scale = 0; //RndmPois==0
990  }
991  }
992  break;
993 
994  case 0:
995  if (pe > 0.0) {
996  RndmPois = RandPoissonT::shoot(engine, pe);
997  pe_scale = RndmPois / pe;
998  }
999  break;
1000 
1001  case 1:
1002  if (pe > 0.0) {
1003  if (pe > 10.0) {
1004  RndmPois = std::max(0.0, RandGaussQ::shoot(engine, pe, sqrt(pe))); // FIXME CLHEP::RandGaussZiggurat is faster and more accurate.
1005  } else {
1006  int nn = std::max(10, (int) (pe * 10.0));
1007  double * ProbFunc = new double[nn];
1008  ProbFunc[0] = exp(-pe);
1009  for (int i = 1; i < nn; ++i) {
1010  ProbFunc[i] = ProbFunc[i - 1] * pe / i;
1011  }
1012  RandGeneral* RandG = new RandGeneral(ProbFunc, nn, 0);
1013  RndmPois = RandG->shoot(engine) * nn;
1014  //here RndmPois is continuously distributed random value obtained from Poisson
1015  //distribution by approximation.
1016  delete RandG;
1017  delete[] ProbFunc;
1018  }
1019  pe_scale = RndmPois / pe;
1020  }
1021  break;
1022  } //end switch(m_PhElStat)
1023 
1024  ATH_MSG_VERBOSE( "PhotoElec: id=" << m_tileID->to_string(pmt_id,-1)
1025  << " totEne=" << energy
1026  << ", numPhElec=" << nPhotoElectrons
1027  << ", pe=" << pe
1028  << ", rndmPoisson=" << RndmPois
1029  << ", pe_scale=" << pe_scale);
1030 
1031  return pe_scale;
1032 }
1033 
1034 
1036  int module = frag_id & 0x3F;
1037 
1038  TileHitCollection::iterator hitIt = coll->begin();
1039  TileHitCollection::iterator endHitIt = coll->end();
1040 
1041  TileHitCollection::iterator fromHitIt = coll->end();
1042  TileHit* toHit(0);
1043 
1044  for (; hitIt != endHitIt; ++hitIt) {
1045  Identifier pmt_id = (*hitIt)->pmt_ID();
1046  if (m_tileID->tower(pmt_id) == E1_TOWER && m_tileID->sample(pmt_id) == TileID::SAMP_E) {
1047  if (module == m_tileID->module(pmt_id)) {
1048  toHit = *hitIt;
1049  } else {
1050  fromHitIt = hitIt; // need iterator to delete this hit later.
1051  }
1052  }
1053  }
1054 
1055  if (fromHitIt != coll->end()) {
1056  ATH_MSG_VERBOSE("Found TileHit (E1 cell) for merging [" << m_tileID->to_string((*fromHitIt)->pmt_ID(), -1)
1057  << "] in module: " << module);
1058  bool isToHitNew = false;
1059  if (toHit == 0) {
1060  int side = m_tileID->side((*fromHitIt)->pmt_ID());
1062  toHit = new TileHit(to_pmt_id);
1063  isToHitNew = true;
1064  ATH_MSG_VERBOSE("New TileHit (E1 cell) for merging added Id: " << m_tileID->to_string(toHit->pmt_ID(), -1) );
1065  } else {
1066  ATH_MSG_VERBOSE("Found TileHit (E1 cell) for merging Id: " << m_tileID->to_string(toHit->pmt_ID(), -1) );
1067  }
1068 
1069  ATH_MSG_DEBUG( "TileHit (E1 cell) Id: " << m_tileID->to_string((*fromHitIt)->pmt_ID(), -1)
1070  << " will be merged to " << m_tileID->to_string(toHit->pmt_ID(), -1) );
1071 
1072  if (msgLvl(MSG::VERBOSE)) {
1073  msg(MSG::VERBOSE) << "Before merging (E1 cell) => " << (std::string) (**fromHitIt) << endmsg;
1074  msg(MSG::VERBOSE) << "Before merging (E1 cell) => " << (std::string) (*toHit) << endmsg;
1075  }
1076 
1077  toHit->add(*fromHitIt, 0.1);
1078 
1079  if (msgLvl(MSG::VERBOSE)) {
1080  msg(MSG::VERBOSE) << "After merging (E1 cell) => " << (std::string) (*toHit) << endmsg;
1081  msg(MSG::VERBOSE) << "TileHit to be deleted Id (E1 cell): " << m_tileID->to_string((*fromHitIt)->pmt_ID(), -1) << endmsg;
1082  }
1083 
1084  coll->erase(fromHitIt);
1085 
1086  if (isToHitNew) {
1087  hitCont->push_back(toHit);
1088  }
1089  }
1090 }
1091 
1092 
1094  int module = frag_id & 0x3F;
1095 
1096  TileHitCollection::iterator hitIt = coll->begin();
1097  TileHitCollection::iterator endHitIt = coll->end();
1098 
1099  TileHitCollection::iterator fromHitIt = coll->end();
1100  TileHit* toHit(0);
1101 
1102  for (; hitIt != endHitIt; ++hitIt) {
1103  Identifier pmt_id = (*hitIt)->pmt_ID();
1104  if (m_tileTBID->is_tiletb(pmt_id)) {
1105  if (m_tileTBID->phi(pmt_id) % 2 == 0) {
1106  toHit = *hitIt;
1107  } else {
1108  fromHitIt = hitIt; // need iterator to delete this hit later.
1109  }
1110  }
1111  }
1112 
1113  if (fromHitIt != coll->end()) {
1114  ATH_MSG_VERBOSE("Found TileHit (MBTS) for merging [" << m_tileTBID->to_string((*fromHitIt)->pmt_ID(), 0)
1115  << "] in module: " << module);
1116  bool isToHitNew = false;
1117  if (toHit == 0) {
1118  int side = m_tileTBID->side((*fromHitIt)->pmt_ID());
1119  int phi = m_tileTBID->phi((*fromHitIt)->pmt_ID()) - 1;
1120  Identifier to_pmt_id = m_tileTBID->channel_id(side, phi, 1);
1121  toHit = new TileHit(to_pmt_id);
1122  isToHitNew = true;
1123  ATH_MSG_VERBOSE("New TileHit (MBTS) for merging added Id: " << m_tileTBID->to_string(toHit->pmt_ID(), 0) );
1124  } else {
1125  ATH_MSG_VERBOSE("Found TileHit (MBTS) for merging Id: " << m_tileTBID->to_string(toHit->pmt_ID(), 0) );
1126  }
1127 
1128  ATH_MSG_DEBUG( "TileHit (MBTS) Id: " << m_tileTBID->to_string((*fromHitIt)->pmt_ID(), 0)
1129  << " will be merged to " << m_tileTBID->to_string(toHit->pmt_ID(), 0) );
1130 
1131  if (msgLvl(MSG::VERBOSE)) {
1132  msg(MSG::VERBOSE) << "Before merging (MBTS) => " << (std::string) (**fromHitIt) << endmsg;
1133  msg(MSG::VERBOSE) << "Before merging (MBTS) => " << (std::string) (*toHit) << endmsg;
1134  }
1135 
1136  toHit->add(*fromHitIt, 0.1);
1137 
1138  if (msgLvl(MSG::VERBOSE)) {
1139  msg(MSG::VERBOSE) << "After merging (MBTS) => " << (std::string) (*toHit) << endmsg;
1140  msg(MSG::VERBOSE) << "TileHit to be deleted Id (MBTS): "
1141  << m_tileTBID->to_string((*fromHitIt)->pmt_ID(), 0) << endmsg;
1142  }
1143 
1144  coll->erase(fromHitIt);
1145 
1146  if (isToHitNew) {
1147  hitCont->push_back(toHit);
1148  }
1149  }
1150 }
1151 
1152 void TileHitVecToCntTool::findAndMergeMultipleHitsInChannel(std::unique_ptr<TileHitNonConstContainer>& hitCont) const {
1153  for (std::unique_ptr<TileHitCollection>& coll : *hitCont) {
1154 
1155  int frag_id = coll->identify();
1156  int module = frag_id & 0x3F;
1157  IdentifierHash frag_hash = m_fragHashFunc(frag_id);
1158  std::vector<TileHit*> hits(48, nullptr);
1159  std::vector<std::unique_ptr<TileHit>> otherModuleHits;
1160  coll->erase(std::remove_if(coll->begin(), coll->end(),
1161  [this, &hits, &otherModuleHits, module, frag_hash] (TileHit* hit) {
1162  Identifier pmt_id = hit->pmt_ID();
1163  int channel = m_tileHWID->channel(hit->pmt_HWID());
1164  TileHit* channelHit = hits[channel];
1165  if (channelHit) {
1166  mergeExtraHitToChannelHit(hit, channelHit);
1167  return true;
1168  } else if (m_run2plus // Special case for merged E1 and MBTS in Run 2+ geometries, which will be merged finally correctly later
1169  && ((m_E1merged[frag_hash] && m_tileID->module(pmt_id) != module
1170  && m_tileID->tower(pmt_id) == E1_TOWER && m_tileID->sample(pmt_id) == TileID::SAMP_E) // Merged E1 in Run 2+ from other module
1171  || (m_MBTSmerged[frag_hash] && m_tileTBID->is_tiletb(pmt_id) && (m_tileTBID->phi(pmt_id) % 2 == 1)))) { // Merged MBTS in Run 2+ from other module
1172  otherModuleHits.push_back(std::make_unique<TileHit>(*hit));
1173  return true;
1174  } else {
1175  hits[channel] = hit;
1176  return false;
1177  }}),
1178  coll->end());
1179 
1180  for (std::unique_ptr<TileHit>& hit : otherModuleHits) {
1181  int channel = m_tileHWID->channel(hit->pmt_HWID());
1182  TileHit* channelHit = hits[channel];
1183  if (channelHit) {
1184  mergeExtraHitToChannelHit(hit.get(), channelHit);
1185  } else {
1186  hits[channel] = hit.get();
1187  coll->push_back(std::move(hit));
1188  }
1189  }
1190  }
1191 }
1192 
1194 
1195  ATH_MSG_DEBUG("Found extra hit for channel Id: "
1196  << m_tileID->to_string(extraHit->pmt_ID(), -1) << ", will be merged to "
1197  << m_tileID->to_string(channelHit->pmt_ID(), -1));
1198  ATH_MSG_VERBOSE("Before merging => " << (std::string) (*extraHit));
1199  ATH_MSG_VERBOSE("Before merging => " << (std::string) (*channelHit));
1200 
1201  channelHit->add(extraHit, 0.1);
1202 
1203  ATH_MSG_VERBOSE("After merging => " << (std::string) (*channelHit));
1204 }
1205 
1206 
1207 void TileHitVecToCntTool::prepareAllHits(std::vector<std::unique_ptr<TileHit>>& allHits) const {
1208 
1209  int nHits = m_mbtsOffset + N_MBTS_CELLS;
1210  if (m_run2) nHits += N_E4PRIME_CELLS;
1211  allHits.reserve(nHits);
1212 
1213  Identifier hit_id;
1214  IdContext pmt_context = m_tileID->pmt_context();
1215  for (int i = 0; i < m_mbtsOffset; ++i) {
1216  m_tileID->get_id((IdentifierHash) i, hit_id, &pmt_context);
1217  allHits.emplace_back(std::make_unique<TileHit>(hit_id, 0., 0.));
1218  allHits.back()->reserve(71); // reserve max possible size for pileup
1219  }
1220 
1221  allHits.resize(allHits.size() + N_MBTS_CELLS);
1222  for (int side = 0; side < N_SIDE; ++side) {
1223  for (int phi = 0; phi < N_PHI; ++phi) {
1224  for (int eta = 0; eta < N_ETA; ++eta) {
1225  int mbtsIndex = mbts_index(side, phi, eta);
1226  hit_id = m_tileTBID->channel_id((side > 0) ? 1 : -1, phi, eta);
1227  allHits[mbtsIndex] = std::make_unique<TileHit>(hit_id, 0., 0.);
1228  allHits[mbtsIndex]->reserve(71); // reserve max possible size for pileup
1229  }
1230  }
1231  }
1232  if (m_run2) {
1233  allHits.resize(allHits.size() + N_E4PRIME_CELLS);
1234  for (int phi = 0; phi < E4_N_PHI; ++phi) {
1235  int e4prIndex = e4pr_index(phi);
1236  hit_id = m_tileTBID->channel_id(E4_SIDE, phi, E4_ETA);
1237  allHits[e4prIndex] = std::make_unique<TileHit>(hit_id, 0., 0.);
1238  allHits[e4prIndex]->reserve(71); // reserve max possible size for pileup
1239  }
1240  }
1241 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TileHit::scale
void scale(float coeff)
Scale energy of all sub-hits in a hit
Definition: TileHit.cxx:117
TileHitVecToCntTool::N_E4PRIME_CELLS
static const int N_E4PRIME_CELLS
Definition: TileHitVecToCntTool.h:196
TileHit::identify
Identifier identify(void) const
Return logical ID of the pmt.
Definition: TileSimEvent/TileSimEvent/TileHit.h:76
TileHitVecToCntTool::m_cabling
const TileCablingService * m_cabling
Definition: TileHitVecToCntTool.h:202
TileSamplingFraction::getSamplingFraction
float getSamplingFraction(unsigned int drawerIdx, unsigned int channel) const
Return Tile Calorimeter sampling fraction.
Definition: TileSamplingFraction.h:53
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition: RNGWrapper.h:169
TileTBID::channel_id
Identifier channel_id(int type, int module, int channel) const
identifer for one channel of a Tile testbeam detector
Definition: TileTBID.cxx:195
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:18
TileHitVecToCntTool::createContainers
StatusCode createContainers()
Definition: TileHitVecToCntTool.cxx:185
TileTBID::to_string
std::string to_string(const Identifier &id, int level=0) const
extract all fields from TileTB identifier Identifier get_all_fields ( const Identifier & id,...
Definition: TileTBID.cxx:47
TileHitVecToCntTool::E4_N_PHI
static const int E4_N_PHI
Definition: TileHitVecToCntTool.h:195
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
TileHitVecToCntTool::m_hitContainer_DigiHSTruthKey
SG::WriteHandleKey< TileHitContainer > m_hitContainer_DigiHSTruthKey
Definition: TileHitVecToCntTool.h:132
TileHitVecToCntTool::m_hitContainerKey
SG::WriteHandleKey< TileHitContainer > m_hitContainerKey
Definition: TileHitVecToCntTool.h:129
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
TileTBID::is_tiletb
bool is_tiletb(const Identifier &id) const
Test ID if it is TileTBID.
Definition: TileTBID.cxx:85
TileHitVecToCntTool::applyPhotoStatistics
double applyPhotoStatistics(double energy, Identifier pmt_id, CLHEP::HepRandomEngine *engine, const TileSamplingFraction *samplingFraction, int drawerIdx) const
Definition: TileHitVecToCntTool.cxx:955
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TileHitVecToCntTool::E4_SIDE
static const int E4_SIDE
Definition: TileHitVecToCntTool.h:193
TileHitVecToCntTool::m_samplingFractionKey
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
Definition: TileHitVecToCntTool.h:138
AthMsgStreamMacros.h
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
TileTBID::channel_context
IdContext channel_context() const
idContext for channels
Definition: TileTBID.cxx:313
TileHitCollection.h
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
TileHitVecToCntTool::m_tileTBID
const TileTBID * m_tileTBID
Pointer to TileID helper.
Definition: TileHitVecToCntTool.h:173
TileHitVecToCntTool::processHitVectorWithoutPileUp
void processHitVectorWithoutPileUp(const TileHitVector *inputHits, int &nHit, double &eHitTot, TileHitNonConstContainer *hitCont, CLHEP::HepRandomEngine *engine) const
Definition: TileHitVecToCntTool.cxx:384
TileHitVecConstIterator
AtlasHitsVector< TileHit >::const_iterator TileHitVecConstIterator
Definition: TileHitVector.h:30
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
TileHitVecToCntTool::m_mergeSvc
ServiceHandle< PileUpMergeSvc > m_mergeSvc
Definition: TileHitVecToCntTool.h:170
TileRawDataNonConstContainer::begin
iterator begin()
Definition: TileRawDataNonConstContainer.h:43
TileHitVecToCntTool::initialize
StatusCode initialize() override final
Definition: TileHitVecToCntTool.cxx:53
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
AtlasHitsVector
Definition: AtlasHitsVector.h:32
Tile_Base_ID::side
int side(const Identifier &id) const
Definition: Tile_Base_ID.cxx:153
TileHitVecToCntTool::m_hitVectorNames
std::vector< std::string > m_hitVectorNames
Definition: TileHitVecToCntTool.h:127
Tile_Base_ID::sample
int sample(const Identifier &id) const
Definition: Tile_Base_ID.cxx:171
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:210
TileHitVecToCntTool::m_pileUp
Gaudi::Property< bool > m_pileUp
if true => pileup mode is activated
Definition: TileHitVecToCntTool.h:143
TileHitVecToCntTool::m_timeFlag
Gaudi::Property< int > m_timeFlag
special options to deal with times of hits for cosmics and TB
Definition: TileHitVecToCntTool.h:147
TileHitVecToCntTool::processBunchXing
virtual StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
Definition: TileHitVecToCntTool.cxx:581
TileHitVecToCntTool::m_mbtsOffset
int m_mbtsOffset
Definition: TileHitVecToCntTool.h:185
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
TileHitVecToCntTool::TileHitVecToCntTool
TileHitVecToCntTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition: TileHitVecToCntTool.cxx:46
TileHitVecToCntTool::m_hits_DigiHSTruth
std::unique_ptr< TileHitNonConstContainer > m_hits_DigiHSTruth
pointer to hits container
Definition: TileHitVecToCntTool.h:183
TileHWID::frag
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
Definition: TileHWID.h:181
Tile_Base_ID::GAPDET
@ GAPDET
Definition: Tile_Base_ID.h:47
TileCalibUtils.h
Tile_Base_ID::tower
int tower(const Identifier &id) const
Definition: Tile_Base_ID.cxx:165
TileHitVecToCntTool::m_inputKeys
StringArrayProperty m_inputKeys
vector with the names of TileHitVectors to use
Definition: TileHitVecToCntTool.h:124
Tile_Base_ID::SAMP_E
@ SAMP_E
Definition: Tile_Base_ID.h:54
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
TileHitVecToCntTool::m_mergeMultipleHitsInChannel
Gaudi::Property< bool > m_mergeMultipleHitsInChannel
Definition: TileHitVecToCntTool.h:167
TileHitCollection
Definition: TileHitCollection.h:12
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
TileTBID::type
int type(const Identifier &id) const
extract type field from TileTB identifier
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:146
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
HWIdentifier
Definition: HWIdentifier.h:13
Tile_Base_ID::pmt_hash_max
size_type pmt_hash_max() const
Definition: Tile_Base_ID.cxx:1318
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:130
LArG4AODNtuplePlotter.pe
pe
Definition: LArG4AODNtuplePlotter.py:116
TileHitVecToCntTool::m_hitVectorKeys
SG::ReadHandleKeyArray< TileHitVector > m_hitVectorKeys
Definition: TileHitVecToCntTool.h:126
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
TileHit::size
int size(void) const
Return length of energy/time vectors
Definition: TileSimEvent/TileSimEvent/TileHit.h:94
XMLtoHeader.count
count
Definition: XMLtoHeader.py:84
ReadCondHandle.h
TileTBID::module
int module(const Identifier &id) const
extract module field from TileTB identifier
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:150
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
TileHitVecToCntTool::m_useTriggerTime
Gaudi::Property< bool > m_useTriggerTime
if true => take trigger time from external tool or from m_triggerTime
Definition: TileHitVecToCntTool.h:161
TileID.h
TileDetDescrManager.h
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
TileHitVecToCntTool::processHitVectorForPileUp
void processHitVectorForPileUp(const TileHitVector *inputHits, double SubEvtTimOffset, std::vector< std::unique_ptr< TileHit >> &allHits, std::vector< std::unique_ptr< TileHit >> &allHits_DigiHSTruth, int &nHit, double &eHitTot, bool isSignal=false) const
Definition: TileHitVecToCntTool.cxx:281
TileHitVecToCntTool::findAndMergeMBTS
void findAndMergeMBTS(TileHitCollection *coll, int frag_id, TileHitNonConstContainer *hitCont) const
Definition: TileHitVecToCntTool.cxx:1093
TileHWID::ros
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
Definition: TileHWID.h:167
python.SystemOfUnits.MeV
float MeV
Definition: SystemOfUnits.py:172
PileUpMergeSvc::TimedList::type
std::list< value_t > type
type of the collection of timed data object
Definition: PileUpMergeSvc.h:73
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
TRT::Hit::side
@ side
Definition: HitInfo.h:83
TileHitVecToCntTool::m_cablingSvc
ServiceHandle< TileCablingSvc > m_cablingSvc
Definition: TileHitVecToCntTool.h:201
TileSamplingFraction::getNumberOfPhotoElectrons
float getNumberOfPhotoElectrons(unsigned int drawerIdx, unsigned int channel) const
Return number of photoelectrons per 1 GeV in Tile Calorimeter scintilator.
Definition: TileSamplingFraction.h:58
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.PyAthena.module
module
Definition: PyAthena.py:131
TileHitVecToCntTool::m_run2plus
bool m_run2plus
if true => RUN2+ geometry with merged E1 (and E4' in RUN2)
Definition: TileHitVecToCntTool.h:142
TileHitVecToCntTool::N_MBTS_CELLS
static const int N_MBTS_CELLS
Definition: TileHitVecToCntTool.h:189
WriteHandle.h
Handle class for recording to StoreGate.
TileHitVecToCntTool::m_run2
bool m_run2
if true => RUN2 geometry with E4' and merged E1
Definition: TileHitVecToCntTool.h:141
TileTBID.h
TileCablingService::isRun2PlusCabling
bool isRun2PlusCabling() const
Definition: TileCablingService.h:278
Tile_Base_ID::get_id
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const
create compact id from hash id (return == 0 for OK)
Definition: Tile_Base_ID.cxx:1077
TileRawDataNonConstContainer::end
iterator end()
Definition: TileRawDataNonConstContainer.h:44
TileHWID.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TileRawDataNonConstContainer< TileHitCollection >::iterator
std::vector< std::unique_ptr< TileHitCollection > >::iterator iterator
Definition: TileRawDataNonConstContainer.h:42
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
Tile_Base_ID::module
int module(const Identifier &id) const
Definition: Tile_Base_ID.cxx:159
TileHitVecToCntTool::m_usePhotoStatistics
Gaudi::Property< bool > m_usePhotoStatistics
Definition: TileHitVecToCntTool.h:165
TileCablingService.h
TileSamplingFraction
Condition object to keep and provide Tile Calorimeter sampling fraction and number of photoelectrons.
Definition: TileSamplingFraction.h:16
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
TileHitVecToCntTool::m_tileHWID
const TileHWID * m_tileHWID
Pointer to TileID helper.
Definition: TileHitVecToCntTool.h:174
TileHitVecToCntTool::mergeEvent
virtual StatusCode mergeEvent(const EventContext &ctx) override final
Definition: TileHitVecToCntTool.cxx:936
CosTrigTime::time
float time() const
Definition: CosTrigTime.h:18
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TileHitVecToCntTool::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Random number generator engine to use.
Definition: TileHitVecToCntTool.h:176
TileHitVecToCntTool::m_onlyUseContainerName
Gaudi::Property< bool > m_onlyUseContainerName
Definition: TileHitVecToCntTool.h:123
TileHitVecToCntTool::m_rndmEvtOverlay
Gaudi::Property< bool > m_rndmEvtOverlay
If true => overlay with random event (zero-luminosity pile-up)
Definition: TileHitVecToCntTool.h:159
TileHitVecToCntTool::m_allHits_DigiHSTruth
std::vector< std::unique_ptr< TileHit > > m_allHits_DigiHSTruth
vector for all TileHits
Definition: TileHitVecToCntTool.h:181
TileHitVecToCntTool::m_deltaT
Gaudi::Property< double > m_deltaT
minimal time granularity for TileHit
Definition: TileHitVecToCntTool.h:145
TileHitVecToCntTool::m_fragHashFunc
TileFragHash m_fragHashFunc
Definition: TileHitVecToCntTool.h:203
TileHit::add
int add(float energy, float time)
Add sub-hit to a given hit.
Definition: TileHit.cxx:74
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TileHitVecToCntTool::prepareEvent
virtual StatusCode prepareEvent(const EventContext &ctx, unsigned int) override final
Definition: TileHitVecToCntTool.cxx:221
TileHitVecToCntTool::mergeExtraHitToChannelHit
void mergeExtraHitToChannelHit(TileHit *extraHit, TileHit *channelHit) const
Definition: TileHitVecToCntTool.cxx:1193
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
OwnershipPolicy.h
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
maskDeadModules.ros
ros
Definition: maskDeadModules.py:35
TileCablingService::isRun2Cabling
bool isRun2Cabling() const
Definition: TileCablingService.h:277
TileFragHash::initialize
void initialize(const TileHWID *tileHWID, TYPE type=Default)
Definition: TileFragHash.cxx:23
TileHitVecToCntTool::findAndMergeE1
void findAndMergeE1(TileHitCollection *coll, int frag_id, TileHitNonConstContainer *hitCont) const
Definition: TileHitVecToCntTool.cxx:1035
TileTBID::channel
int channel(const Identifier &id) const
extract channel field from TileTB identifier
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:154
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
PileUpToolBase
Definition: PileUpToolBase.h:18
TileHitVecToCntTool::putAllHitsInContainer
void putAllHitsInContainer(std::vector< std::unique_ptr< TileHit >> &allHits, std::vector< std::unique_ptr< TileHit >> &allHits_DigiHSTruth, std::unique_ptr< TileHitNonConstContainer > &hits, std::unique_ptr< TileHitNonConstContainer > &hits_DigiHSTruth, SG::OwnershipPolicy ownPolicy) const
Definition: TileHitVecToCntTool.cxx:771
Tile_Base_ID::get_hash
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const
create hash id from compact id (return == 0 for OK)
Definition: Tile_Base_ID.cxx:1151
TileHitVecToCntTool
This AlgTool merges TileHits from different AthenaHitVectors and stores the result in a TileHitContai...
Definition: TileHitVecToCntTool.h:85
TileHitVecToCntTool::processAllSubEvents
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
Definition: TileHitVecToCntTool.cxx:652
TileRawDataNonConstContainer::push_back
void push_back(element_t *rc)
Definition: TileRawDataNonConstContainer.h:68
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
TileHitVecToCntTool::e4pr_index
int e4pr_index(int phi) const
Definition: TileHitVecToCntTool.h:197
TileHitVecToCntTool::mbts_index
int mbts_index(int side, int phi, int eta) const
Definition: TileHitVecToCntTool.h:190
TileHitVecToCntTool::m_hits
std::unique_ptr< TileHitNonConstContainer > m_hits
pointer to hits container
Definition: TileHitVecToCntTool.h:182
TileHWID::drawer_hash_max
size_type drawer_hash_max() const
drawer hash table max size
Definition: TileHWID.h:268
TileHWID::drawer_id
HWIdentifier drawer_id(int frag) const
ROS HWIdentifer.
Definition: TileHWID.cxx:186
TileHit.h
python.EventInfoMgtInit.release
release
Definition: EventInfoMgtInit.py:23
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
TileCablingService::is_MBTS_merged_run2plus
bool is_MBTS_merged_run2plus(int module) const
Definition: TileCablingService.cxx:2453
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition: RNGWrapper.h:56
TileHitVecToCntTool::m_maxHitTime
Gaudi::Property< double > m_maxHitTime
all sub-hits with time above m_maxHitTime will be ignored
Definition: TileHitVecToCntTool.h:151
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TileHitVecToCntTool::N_ETA
static const int N_ETA
Definition: TileHitVecToCntTool.h:188
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TileHitVecToCntTool::processHitVectorForOverlay
void processHitVectorForOverlay(const TileHitVector *inputHits, std::unique_ptr< TileHitNonConstContainer > &hits, int &nHit, double &eHitTot) const
Definition: TileHitVecToCntTool.cxx:235
TileHit
Definition: TileSimEvent/TileSimEvent/TileHit.h:30
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition: RNGWrapper.h:134
RNGWrapper.h
TileHitVecToCntTool::m_allHits
std::vector< std::unique_ptr< TileHit > > m_allHits
vector for all TileHits
Definition: TileHitVecToCntTool.h:180
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
TileHitNonConstContainer
This is a minimal version of a TileHitContainer in which the saved collections remain non-const.
Definition: TileHitNonConstContainer.h:31
TileHitVecToCntTool::m_MBTSmerged
std::vector< bool > m_MBTSmerged
Definition: TileHitVecToCntTool.h:205
TileHitVecToCntTool::findAndMergeMultipleHitsInChannel
void findAndMergeMultipleHitsInChannel(std::unique_ptr< TileHitNonConstContainer > &hitCont) const
Definition: TileHitVecToCntTool.cxx:1152
TileHitVecToCntTool::m_photoStatisticsWindow
Gaudi::Property< double > m_photoStatisticsWindow
sum up energy in [-m_photoStatWindow,+m_photoStatWindow] and use it for photostatistics
Definition: TileHitVecToCntTool.h:153
TileHWID::drawer
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
Definition: TileHWID.h:171
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
TileHit::pmt_HWID
HWIdentifier pmt_HWID(void) const
Return pmt hardware ID (== channel ID)
Definition: TileHit.cxx:125
Tile_Base_ID::to_string
std::string to_string(const Identifier &id, int level=0) const
Definition: Tile_Base_ID.cxx:52
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TileHit::energy
float energy(int ind=0) const
Return energy of ind-th sub-hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:90
TileHitVecToCntTool::m_doDigiTruth
Gaudi::Property< bool > m_doDigiTruth
Definition: TileHitVecToCntTool.h:163
Tile_Base_ID::pmt_id
Identifier pmt_id(const Identifier &any_id) const
Definition: Tile_Base_ID.cxx:640
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:133
TileHitVecToCntTool::m_triggerTimeKey
SG::ReadHandleKey< CosTrigTime > m_triggerTimeKey
Definition: TileHitVecToCntTool.h:169
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
TileHit::setTime
void setTime(float t, int ind=0)
Set time of ind-th sub-hit in a hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:65
TileHitVecToCntTool::E4_ETA
static const int E4_ETA
Definition: TileHitVecToCntTool.h:194
TileHitVecToCntTool::m_photoElectronStatistics
Gaudi::Property< int > m_photoElectronStatistics
photoelectron statistics type: 0 - Poisson, 1 - "new" Poisson + Gauss, 2 - Poisson->Gauss
Definition: TileHitVecToCntTool.h:155
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:142
TileTBID::phi
int phi(const Identifier &id) const
extract phi field from MBTS identifier
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:165
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
TileCalibUtils::getDrawerIdx
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Definition: TileCalibUtils.cxx:60
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
DataVector::erase
iterator erase(iterator position)
Remove element at a given position.
TileHitVecToCntTool::m_tileID
const TileID * m_tileID
Pointer to TileID helper.
Definition: TileHitVecToCntTool.h:172
Tile_Base_ID::cell_id
Identifier cell_id(const Identifier &any_id) const
Definition: Tile_Base_ID.cxx:581
TileHit::time
float time(int ind=0) const
Return time of ind-th sub-hit
Definition: TileSimEvent/TileSimEvent/TileHit.h:92
TileHitVecToCntTool::E1_TOWER
@ E1_TOWER
Definition: TileHitVecToCntTool.h:206
error
Definition: IImpactPoint3dEstimator.h:70
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
TileHitVecToCntTool::m_randomStreamName
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Definition: TileHitVecToCntTool.h:178
TileHitVecToCntTool::m_E1merged
std::vector< bool > m_E1merged
Definition: TileHitVecToCntTool.h:204
TileHitVecToCntTool::commitContainers
StatusCode commitContainers(const EventContext &ctx, std::unique_ptr< TileHitNonConstContainer > &hits, std::unique_ptr< TileHitNonConstContainer > &hits_DigiHSTruth, SG::OwnershipPolicy ownPolicy) const
Definition: TileHitVecToCntTool.cxx:803
TileHitVecToCntTool.h
Tile_Base_ID::pmt_context
IdContext pmt_context() const
id for PMTs
Definition: Tile_Base_ID.cxx:1065
TileCablingService::E1_merged_with_run2plus
int E1_merged_with_run2plus(int ros, int module) const
Definition: TileCablingService.cxx:2457
TileHitVecToCntTool::finalize
StatusCode finalize() override final
Definition: TileHitVecToCntTool.cxx:945
TileHitVecToCntTool::N_PHI
static const int N_PHI
Definition: TileHitVecToCntTool.h:187
TileHit::pmt_ID
Identifier pmt_ID(void) const
Return logical ID of the pmt.
Definition: TileSimEvent/TileSimEvent/TileHit.h:78
TileHitVecToCntTool::m_triggerTime
Gaudi::Property< double > m_triggerTime
fixed trigger time value (default=0)
Definition: TileHitVecToCntTool.h:149
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
TileTBID::side
int side(const Identifier &id) const
define synonyms for minimum bias scintillators
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:161
TileCablingService::s2h_channel_id
HWIdentifier s2h_channel_id(const Identifier &id) const
Definition: TileCablingService.cxx:1076
IAthRNGSvc.h
TileHitVecToCntTool::N_SIDE
static const int N_SIDE
Definition: TileHitVecToCntTool.h:186
TileHitVecToCntTool::prepareAllHits
void prepareAllHits(std::vector< std::unique_ptr< TileHit >> &allHits) const
Definition: TileHitVecToCntTool.cxx:1207
Identifier
Definition: IdentifierFieldParser.cxx:14