ATLAS Offline Software
MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 //
7 // MdtDigitizationTool:
8 // Athena algorithm which produces MDTDigits out of MHits.
9 // ------------
10 // Authors:
11 // Daniela Rebuzzi (daniela.rebuzzi@pv.infn.it)
12 // Ketevi A. Assamagan (ketevi@lbn.gov)
13 // Modified by:
14 // 2004-03-02 Niels Van Eldik (nveldik@nikhef.nl)
15 // Modified by:
16 // 2004-04-05 Daniel Levin (dslevin@umich.edu)
17 // generate drift time deltas based on wire sag.
18 // first pass: assume wires are geomtrically centered-
19 // but have top/bottom RT functions that would obtain
20 // if the wire was off axis by an amount determined
21 // by the tube length, orientation, hit location and track angle
22 // Modified by:
23 // 2004-02-08 Daniel Levin (dslevin@umich.edu)
24 // generate new impact parameters based on physical wire sag.
25 // 2012-7-5 Shannon Walch (srwalch@umich.edu)
26 // implement bug fixes in RT wiresag calculations
27 // Modified by:
28 // Dinos Bachas (konstantinos.bachas@cern.ch)
29 //
31 
32 // MDT digitization includes
33 #include "MdtDigitizationTool.h"
34 
36 
37 // Gaudi - Core
39 
40 // Geometry
47 // Pile-up
48 
49 // Truth
50 #include "AtlasHepMC/GenParticle.h"
53 
54 // Random Numbers
56 
57 // Calibration Service
60 namespace {
61  // what about this? does this also need to be 1/m_signalSpeed ?
62  constexpr double s_inv_c_light(1. / Gaudi::Units::c_light);
63 } // namespace
64 MdtDigitizationTool::MdtDigitizationTool(const std::string& type, const std::string& name, const IInterface* pIID) :
65  PileUpToolBase(type, name, pIID) {}
66 
68  ATH_MSG_INFO("Configuration MdtDigitizationTool");
69  ATH_MSG_INFO("RndmSvc " << m_rndmSvc);
70  ATH_MSG_INFO("DigitizationTool " << m_digiTool);
71  ATH_MSG_INFO("OffsetTDC " << m_offsetTDC);
72  ATH_MSG_INFO("ns2TDCAMT " << m_ns2TDCAMT);
73  ATH_MSG_INFO("ns2TDCHPTDC " << m_ns2TDCHPTDC);
74  ATH_MSG_INFO("ResolutionTDC " << m_resTDC);
75  ATH_MSG_INFO("SignalSpeed " << m_signalSpeed);
76  ATH_MSG_INFO("InputObjectName " << m_inputObjectName);
77  ATH_MSG_INFO("OutputObjectName " << m_outputObjectKey.key());
78  ATH_MSG_INFO("OutputSDOName " << m_outputSDOKey.key());
79  ATH_MSG_INFO("UseAttenuation " << m_useAttenuation);
80  ATH_MSG_INFO("UseTof " << m_useTof);
81  ATH_MSG_INFO("UseProp " << m_useProp);
82  ATH_MSG_INFO("UseDeformations " << m_useDeformations);
83  ATH_MSG_INFO("UseTimeWindow " << m_useTimeWindow);
84  ATH_MSG_INFO("BunchCountOffset " << m_bunchCountOffset);
85  ATH_MSG_INFO("MatchingWindow " << m_matchingWindow);
86  ATH_MSG_INFO("MaskWindow " << m_maskWindow);
87  ATH_MSG_INFO("DeadTime " << m_deadTime);
88  ATH_MSG_INFO("DiscardEarlyHits " << m_DiscardEarlyHits);
89  ATH_MSG_INFO("CheckSimHits " << m_checkMDTSimHits);
90  ATH_MSG_INFO("UseTwin " << m_useTwin);
91  ATH_MSG_INFO("UseAllBOLTwin " << m_useAllBOLTwin);
92  ATH_MSG_INFO("ResolutionTwinTube " << m_resTwin);
93  ATH_MSG_INFO("DoQballCharge " << m_DoQballCharge);
94  if (!m_useTof) {
95  ATH_MSG_INFO("UseCosmicsOffSet1 " << m_useOffSet1);
96  ATH_MSG_INFO("UseCosmicsOffSet2 " << m_useOffSet2);
97  }
98  ATH_MSG_INFO("IncludePileUpTruth " << m_includePileUpTruth);
99  ATH_MSG_INFO("VetoPileUpTruthLinks " << m_vetoPileUpTruthLinks);
100 
101  // initialize transient detector store and MuonGeoModel OR MuonDetDescrManager
102  if (detStore()->contains<MuonGM::MuonDetectorManager>("Muon")) {
104  ATH_MSG_DEBUG("Retrieved MuonGeoModelDetectorManager from StoreGate");
105  }
106 
107  // initialize MuonIdHelperSvc
108  ATH_CHECK(m_idHelperSvc.retrieve());
109 
110  if (m_onlyUseContainerName) { ATH_CHECK(m_mergeSvc.retrieve()); }
111 
112  // check the input object name
113  if (m_hitsContainerKey.key().empty()) {
114  ATH_MSG_FATAL("Property InputObjectName not set !");
115  return StatusCode::FAILURE;
116  }
118  ATH_MSG_DEBUG("Input objects in container : '" << m_inputObjectName << "'");
119 
120  // Initialize ReadHandleKey
121  ATH_CHECK(m_hitsContainerKey.initialize());
123 
124  // initialize the output WriteHandleKeys
126  ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputObjectKey);
128  ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_outputSDOKey);
129  ATH_MSG_DEBUG("Output Digits: '" << m_outputObjectKey.key() << "'");
130 
131  // simulation identifier helper
132  m_muonHelper = MdtHitIdHelper::GetHelper(m_idHelperSvc->mdtIdHelper().tubeMax());
133 
134  // get the r->t conversion tool
135  ATH_CHECK(m_digiTool.retrieve());
136  ATH_MSG_DEBUG("Retrieved digitization tool!" << m_digiTool);
137 
138  ATH_CHECK(m_rndmSvc.retrieve());
140  return StatusCode::SUCCESS;
141 }
142 
143 StatusCode MdtDigitizationTool::prepareEvent(const EventContext& /*ctx*/, unsigned int nInputEvents) {
144  ATH_MSG_DEBUG("MdtDigitizationTool::prepareEvent() called for " << nInputEvents << " input events");
145 
146  m_MDTHitCollList.clear();
147  m_thpcMDT = std::make_unique<TimedHitCollection<MDTSimHit>>();
148 
149  return StatusCode::SUCCESS;
150 }
151 
153  ATH_MSG_DEBUG("MdtDigitizationTool::processBunchXing() " << bunchXing);
154 
156  TimedHitCollList hitCollList;
157 
158  if (!(m_mergeSvc->retrieveSubSetEvtData(m_inputObjectName, hitCollList, bunchXing, bSubEvents, eSubEvents).isSuccess()) &&
159  hitCollList.empty()) {
160  ATH_MSG_ERROR("Could not fill TimedHitCollList");
161  return StatusCode::FAILURE;
162  } else {
163  ATH_MSG_VERBOSE(hitCollList.size() << " MDTSimHitCollection with key " << m_inputObjectName << " found");
164  }
165 
166  TimedHitCollList::iterator iColl(hitCollList.begin());
167  TimedHitCollList::iterator endColl(hitCollList.end());
168 
169  // Iterating over the list of collections
170  for (; iColl != endColl; ++iColl) {
171  MDTSimHitCollection* hitCollPtr = new MDTSimHitCollection(*iColl->second);
172  PileUpTimeEventIndex timeIndex(iColl->first);
173 
174  ATH_MSG_DEBUG("MDTSimHitCollection found with " << hitCollPtr->size() << " hits");
175  ATH_MSG_VERBOSE("time index info. time: " << timeIndex.time() << " index: " << timeIndex.index() << " type: " << timeIndex.type());
176 
177  m_thpcMDT->insert(timeIndex, hitCollPtr);
178  m_MDTHitCollList.push_back(hitCollPtr);
179  }
180 
181  return StatusCode::SUCCESS;
182 }
183 
185  ATH_MSG_DEBUG("MdtDigitizationTool::getNextEvent()");
186 
187  // get the container(s)
189 
190  // In case of single hits container just load the collection using read handles
191  if (!m_onlyUseContainerName) {
193  if (!hitCollection.isValid()) {
194  ATH_MSG_ERROR("Could not get MDTSimHitCollection container " << hitCollection.name() << " from store "
195  << hitCollection.store());
196  return StatusCode::FAILURE;
197  }
198 
199  // create a new hits collection
200  m_thpcMDT = std::make_unique<TimedHitCollection<MDTSimHit>>(1);
201  m_thpcMDT->insert(0, hitCollection.cptr());
202  ATH_MSG_DEBUG("MDTSimHitCollection found with " << hitCollection->size() << " hits");
203 
204  return StatusCode::SUCCESS;
205  }
206 
207  // this is a list<info<time_t, DataLink<MDTSimHitCollection> > >
208  TimedHitCollList hitCollList;
209 
210  if (!(m_mergeSvc->retrieveSubEvtsData(m_inputObjectName, hitCollList).isSuccess())) {
211  ATH_MSG_ERROR("Could not fill TimedHitCollList");
212  return StatusCode::FAILURE;
213  }
214  if (hitCollList.empty()) {
215  ATH_MSG_ERROR("TimedHitCollList has size 0");
216  return StatusCode::FAILURE;
217  } else {
218  ATH_MSG_DEBUG(hitCollList.size() << " MDTSimHitCollections with key " << m_inputObjectName << " found");
219  }
220 
221  // create a new hits collection
222  m_thpcMDT = std::make_unique<TimedHitCollection<MDTSimHit>>();
223 
224  // now merge all collections into one
225  TimedHitCollList::iterator iColl(hitCollList.begin());
226  TimedHitCollList::iterator endColl(hitCollList.end());
227  while (iColl != endColl) {
228  const MDTSimHitCollection* p_collection(iColl->second);
229  m_thpcMDT->insert(iColl->first, p_collection);
230  ATH_MSG_DEBUG("MDTSimHitCollection found with " << p_collection->size() << " hits");
231  ++iColl;
232  }
233  return StatusCode::SUCCESS;
234 }
235 
236 CLHEP::HepRandomEngine* MdtDigitizationTool::getRandomEngine(const std::string& streamName, const EventContext& ctx) const {
237  ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, streamName);
238  std::string rngName = name() + streamName;
239  rngWrapper->setSeed(rngName, ctx);
240  return rngWrapper->getEngine(ctx);
241 }
242 
243 StatusCode MdtDigitizationTool::mergeEvent(const EventContext& ctx) {
244  ATH_MSG_DEBUG("MdtDigitizationTool::in mergeEvent()");
245 
246  // create and record the Digit container in StoreGate
248  ATH_CHECK(digitContainer.record(std::make_unique<MdtDigitContainer>(m_idHelperSvc->mdtIdHelper().module_hash_max())));
249  ATH_MSG_DEBUG("Recorded MdtDigitContainer called " << digitContainer.name() << " in store " << digitContainer.store());
250 
251  // create and record the SDO container in StoreGate
253  ATH_CHECK(sdoContainer.record(std::make_unique<MuonSimDataCollection>()));
254  ATH_MSG_DEBUG("Recorded MuonSimDataCollection called " << sdoContainer.name() << " in store " << sdoContainer.store());
255 
256  Collections_t collections;
257  StatusCode status = doDigitization(ctx, collections, sdoContainer.ptr());
258  if (status.isFailure()) { ATH_MSG_ERROR("doDigitization Failed"); }
259 
260  for (size_t coll_hash = 0; coll_hash < collections.size(); ++coll_hash) {
261  if (collections[coll_hash]) {
262  ATH_CHECK( digitContainer->addCollection (collections[coll_hash].release(), coll_hash) );
263  }
264  }
265 
266  // Clean-up
269  while (MDTHitColl != MDTHitCollEnd) {
270  delete (*MDTHitColl);
271  ++MDTHitColl;
272  }
273  m_MDTHitCollList.clear();
274 
275  return status;
276 }
277 
279  ATH_MSG_DEBUG("MdtDigitizationTool::processAllSubEvents()");
280 
281  // create and record the Digit container in StoreGate
283  ATH_CHECK(digitContainer.record(std::make_unique<MdtDigitContainer>(m_idHelperSvc->mdtIdHelper().module_hash_max())));
284  ATH_MSG_DEBUG("Recorded MdtDigitContainer called " << digitContainer.name() << " in store " << digitContainer.store());
285 
286  // create and record the SDO container in StoreGate
288  ATH_CHECK(sdoContainer.record(std::make_unique<MuonSimDataCollection>()));
289  ATH_MSG_DEBUG("Recorded MuonSimDataCollection called " << sdoContainer.name() << " in store " << sdoContainer.store());
290 
291  StatusCode status = StatusCode::SUCCESS;
292  if (!m_thpcMDT) {
293  status = getNextEvent(ctx);
294  if (StatusCode::FAILURE == status) {
295  ATH_MSG_INFO("There are no MDT hits in this event");
296  return status;
297  }
298  }
299 
300  Collections_t collections;
301  ATH_CHECK(doDigitization(ctx, collections, sdoContainer.ptr()));
302 
303  for (size_t coll_hash = 0; coll_hash < collections.size(); ++coll_hash) {
304  if (collections[coll_hash]) {
305  ATH_CHECK( digitContainer->addCollection (collections[coll_hash].release(), coll_hash) );
306  }
307  }
308 
309  return status;
310 }
311 
312 StatusCode MdtDigitizationTool::doDigitization(const EventContext& ctx, Collections_t& collections,
313  MuonSimDataCollection* sdoContainer) {
314  // Set the RNGs to use for this event.
315  CLHEP::HepRandomEngine* rndmEngine = getRandomEngine("", ctx);
316  CLHEP::HepRandomEngine* twinRndmEngine = getRandomEngine("Twin", ctx);
317  CLHEP::HepRandomEngine* toolRndmEngine = getRandomEngine(m_digiTool->name(), ctx);
318 
319  // get the iterator infos for this DetEl
320  // iterate over hits and fill id-keyed drift time map
322 
323  // Perform null check on m_thpcMDT
324  if (!m_thpcMDT) {
325  ATH_MSG_ERROR("m_thpcMDT is null");
326  return StatusCode::FAILURE;
327  }
328 
329  while (m_thpcMDT->nextDetectorElement(i, e)) {
330  // Loop over the hits:
331  while (i != e) {
332  handleMDTSimHit(ctx, *i, twinRndmEngine, toolRndmEngine);
333  ++i;
334  }
335  }
336 
337  // loop over drift time map entries, convert to tdc value and construct/store the digit
338  createDigits(ctx, collections, sdoContainer, rndmEngine);
339 
340  // reset hits
341  m_hits.clear();
342 
343  // reset the pointer if it is not null
344  m_thpcMDT.reset();
345 
346  return StatusCode::SUCCESS;
347 }
348 
349 bool MdtDigitizationTool::handleMDTSimHit(const EventContext& ctx,
350  const TimedHitPtr<MDTSimHit>& phit, CLHEP::HepRandomEngine* twinRndmEngine,
351  CLHEP::HepRandomEngine* toolRndmEngine) {
352  const MDTSimHit& hit(*phit);
353  MDTSimHit newSimhit(*phit); // hit can be modified later
354 
355  double globalHitTime(hitTime(phit));
356 
357  // Important checks for hits (global time, position along tube, masked chambers etc..) DO NOT SET THIS CHECK TO FALSE IF YOU DON'T KNOW
358  // WHAT YOU'RE DOING !
359  if (m_checkMDTSimHits && !checkMDTSimHit(ctx, hit)) return false;
360 
361  const int id = hit.MDTid();
362  double driftRadius = hit.driftRadius();
363  ATH_MSG_DEBUG("Hit bunch time " << globalHitTime - hit.globalTime() << " tot " << globalHitTime << " tof " << hit.globalTime()
364  << " driftRadius " << driftRadius);
365 
366  std::string stationName = m_muonHelper->GetStationName(id);
369  int multilayer = m_muonHelper->GetMultiLayer(id);
370  int layer = m_muonHelper->GetLayer(id);
371  int tube = m_muonHelper->GetTube(id);
372 
373  // construct Atlas identifier from components
374  Identifier DigitId = m_idHelperSvc->mdtIdHelper().channelID(stationName, stationEta, stationPhi, multilayer, layer, tube);
375 
376  // get distance to readout
377  double distRO(0.);
378 
379  // find the detector element associated to the hit
381 
382  if (!element) {
383  ATH_MSG_ERROR("MuonGeoManager does not return valid element for given id!");
384  return false;
385  } else {
386  distRO = element->tubeFrame_localROPos(DigitId).z();
387  }
388 
389  if (m_useDeformations) {
390  newSimhit = applyDeformations(hit, element, DigitId);
391  driftRadius = newSimhit.driftRadius();
392  }
393 
394  // store local hit position + sign
395  GeoCorOut result = correctGeometricalWireSag(hit, DigitId, element);
396  if (m_useDeformations) { result = correctGeometricalWireSag(newSimhit, DigitId, element); }
397 
398  // correctly set sign of drift radius
399  driftRadius *= result.trackingSign;
400 
401  //+Implementation for RT_Relation_DB_Tool
402  MdtDigiToolInput digiInput(std::abs(driftRadius), distRO, 0., 0., 0., 0., DigitId);
403  double qcharge = 1.;
404  double qgamma = -9999.;
405 
406  if (m_DoQballCharge) {
407  // BSM particles need to be treated specially in digitization because in the default simulation the particle gamma and charge are set to the SM muon values
408  // For heavy or multi-charged BSM particles the qgamma and QE are required as inputs to obtain the correct MDT ADC counts
409  const HepMcParticleLink trkParticle = HepMcParticleLink::getRedirectedLink(hit.particleLink(),phit.eventId(), ctx); // This link should now correctly resolve to the TruthEvent McEventCollection in the main StoreGateSvc.
410  HepMC::ConstGenParticlePtr genParticle = trkParticle.cptr();
411  if (genParticle) {
412  if ( MC::isBSM(genParticle) ) {
413  const double QE = genParticle->momentum().e();
414  const double QM2 = genParticle->momentum().m2();
415  if (QM2 >= 0.) {
416  qgamma = QE / std::sqrt(QM2);
417  }
418  }
419  qcharge = MC::fractionalCharge(genParticle);
420  }
421  digiInput = MdtDigiToolInput{std::abs(driftRadius), distRO, 0., 0., qcharge, qgamma, DigitId};
422  }
423 
424  // digitize input
425  MdtDigiToolOutput digiOutput(m_digiTool->digitize(ctx, digiInput, toolRndmEngine));
426  //-Implementation for RT_Relation_DB_Tool
427 
428  // simulate tube response, check if tube fired
429 
430  if (digiOutput.wasEfficient()) {
431  double driftTime = digiOutput.driftTime();
432  double adc = digiOutput.adc();
433 
434  ATH_MSG_VERBOSE("Tube efficient: driftTime " << driftTime << " adc value " << adc);
435 
436  if (m_useProp) {
437  double position_along_wire = hit.localPosition().z();
438  if (m_useDeformations) { position_along_wire = newSimhit.localPosition().z(); }
439 
440  // prop delay calculated with respect to the center of the tube
441  double sign(-1.);
442  if (distRO < 0.) sign = 1.;
443  double propagation_delay = sign * (1. / m_signalSpeed) * position_along_wire;
444  //------------------------------------------------------------
445  // calculate propagation delay, as readout side the side with
446  // negative local
447  // position along the wire is taken
448 
449  driftTime += propagation_delay; // add prop time
450  ATH_MSG_VERBOSE("Position along wire: " << position_along_wire << " propagation delay: " << propagation_delay
451  << " new driftTime " << driftTime);
452  }
453 
454  // add tof + bunch time
455  if (m_useTof) {
456  driftTime += globalHitTime;
457  ATH_MSG_VERBOSE("Time off Flight + bunch offset: " << globalHitTime << " new driftTime " << driftTime);
458  }
459  ATH_MSG_DEBUG(m_idHelperSvc->mdtIdHelper().show_to_string(DigitId)
460  << " Drift time computation " << driftTime << " radius " << driftRadius << " adc " << adc);
461 
462  // add hit to hit collection
463  m_hits.insert(mdt_hit_info(DigitId, driftTime, adc, driftRadius, &phit));
464  ATH_MSG_VERBOSE(" handleMDTSimHit() phit-" << &phit << " hit.localPosition().z() = " << hit.localPosition().z()
465  << " driftRadius = " << driftRadius);
466 
467  // + TWIN TUBES (A. Koutsman)
468  if (m_useTwin) {
469  // two chambers in ATLAS are installed with Twin Tubes; in detector coordinates BOL4A13 & BOL4C13; only INNER multilayer(=1) is
470  // with twin tubes
471  bool BOL4X13 = false;
472  // find these two chambers in identifier scheme coordinates as in MdtIdHelper
473  if (stationName == "BOL" && std::abs(stationEta) == 4 && stationPhi == 7 && multilayer == 1) { BOL4X13 = true; }
474 
475  // implement twin tubes digitizing either for all BOL (m_useAllBOLTwin = true) _OR_ only for two chambers really installed
476  if ((m_useAllBOLTwin && stationName == "BOL") || BOL4X13) {
477  int twin_tube = 0;
478  Identifier twin_DigitId{0};
479  double twin_sign_driftTime = 0.;
480  // twinpair is connected via a HV-jumper with a delay of ~6ns
481  constexpr double HV_delay = 6.;
482  double twin_tubeLength{0.}, twin_geo_pos_along_wire{0.},
483  twin_sign_pos_along_wire{0.}, twin_sign{-1.};
484 
485  // twinpair is interconnected with one tube in between, so modulo 4 they are identical
486  if (tube % 4 == 1 || tube % 4 == 2)
487  twin_tube = tube + 2;
488  else if (tube % 4 == 0 || tube % 4 == 3)
489  twin_tube = tube - 2;
490  // construct Atlas identifier from components for the twin
491  twin_DigitId = m_idHelperSvc->mdtIdHelper().channelID(stationName, stationEta, stationPhi, multilayer, layer, twin_tube);
492  // get twin tube length for propagation delay
493  twin_tubeLength = element->tubeLength(twin_DigitId);
494 
495  // prop delay calculated with respect to the center of the tube
496  if (distRO < 0.) twin_sign = 1.;
497  twin_geo_pos_along_wire = hit.localPosition().z();
498  if (m_useDeformations) { twin_geo_pos_along_wire = newSimhit.localPosition().z(); }
499  twin_sign_pos_along_wire = twin_sign * twin_geo_pos_along_wire;
500  double twin_propagation_delay = twin_sign * (1. / m_signalSpeed) * twin_geo_pos_along_wire;
501 
502  // calculate drift-time for twin from prompt driftTime + propagation delay + length of tube + hv-delay
503  // ( -2* for propagation_delay, cause prop_delay already in driftTime)
504  twin_sign_driftTime = driftTime + twin_tubeLength / m_signalSpeed - 2 * twin_propagation_delay + HV_delay;
505 
506  // smear the twin time by a gaussian with a stDev given by m_resTwin
507  double rand = CLHEP::RandGaussZiggurat::shoot(twinRndmEngine, twin_sign_driftTime, m_resTwin);
508  twin_sign_driftTime = rand;
509 
510  ATH_MSG_DEBUG(" TWIN TUBE stname " << stationName << " steta " << stationEta << " stphi " << stationPhi << " mLayer "
511  << multilayer << " layer " << layer << " tube " << tube
512  << " signed position along wire = " << twin_sign_pos_along_wire
513  << " propagation delay = " << twin_propagation_delay << " drifttime = " << driftTime
514  << " twin_driftTime = " << twin_sign_driftTime
515  << " TWIN time-difference = " << (twin_sign_driftTime - driftTime));
516 
517  // add twin-hit to hit collection
518  m_hits.insert(mdt_hit_info(twin_DigitId, twin_sign_driftTime, adc, driftRadius, &phit));
519 
520  } // end select all BOLs or installed chambers
521  } // end if(m_useTwin){
522  // - TWIN TUBES (A. Koutsman)
523  } else {
524  ATH_MSG_DEBUG(m_idHelperSvc->mdtIdHelper().show_to_string(DigitId) << " Tube not efficient "
525  << " radius " << driftRadius);
526  }
527 
528  return true;
529 }
530 
531 bool MdtDigitizationTool::checkMDTSimHit(const EventContext& ctx, const MDTSimHit& hit) const {
532  // get the hit Identifier and info
533  const int id = hit.MDTid();
534  std::string stationName = m_muonHelper->GetStationName(id);
537  int multilayer = m_muonHelper->GetMultiLayer(id);
538  int layer = m_muonHelper->GetLayer(id);
539  int tube = m_muonHelper->GetTube(id);
540 
541  Identifier DigitId = m_idHelperSvc->mdtIdHelper().channelID(stationName, stationEta, stationPhi, multilayer, layer, tube);
542  ATH_MSG_DEBUG("Working on hit: " << m_idHelperSvc->mdtIdHelper().show_to_string(DigitId) << " "
543  << m_idHelperSvc->mdtIdHelper().stationNameString(m_idHelperSvc->mdtIdHelper().stationName(DigitId))
544  << " " << stationEta << " " << stationPhi);
545 
546  //+MASKING OF DEAD/MISSING CHAMBERS
547  if (!m_readKey.empty()) {
549  if (!readCdo.isValid()) {
550  ATH_MSG_WARNING(m_readKey.fullKey() << " is not available.");
551  return false;
552  }
553  if (!readCdo->isGood(DigitId)) return false;
554  }
555  //-MASKING OF DEAD/MISSING CHAMBERS
556 
557  double tubeL{0.}, tubeR{0.};
559 
560  if (!element) {
561  ATH_MSG_ERROR("MuonGeoManager does not return valid element for given id!");
562  } else {
563  tubeL = element->tubeLength(DigitId);
564  tubeR = element->innerTubeRadius();
565  }
566 
567  bool ok(true);
568 
569  if (std::abs(hit.driftRadius()) > tubeR) {
570  ok = false;
571  ATH_MSG_DEBUG("MDTSimHit has invalid radius: " << hit.driftRadius() << " tubeRadius " << tubeR);
572  }
573 
574  if (std::abs(hit.localPosition().z()) > 0.5 * tubeL) {
575  ok = false;
576  ATH_MSG_DEBUG("MDTSimHit has invalid position along tube: " << hit.localPosition().z() << " tubeLength " << tubeL);
577  }
578 
579  if (m_useTof) {
580  double minTof = minimumTof(DigitId, m_MuonGeoMgr);
581  if ((hit.globalTime() < 0 || hit.globalTime() > 10 * minTof) && m_DiscardEarlyHits) {
582  ok = false;
583  ATH_MSG_DEBUG("MDTSimHit has invalid global time: " << hit.globalTime() << " minimum Tof " << minTof);
584  }
585  } else {
586  ATH_MSG_DEBUG("MDTSimHit global time: " << hit.globalTime() << " accepted anyway as UseTof is false");
587  }
588 
589  return ok;
590 }
591 
592 bool MdtDigitizationTool::createDigits(const EventContext& ctx, Collections_t& collections,
593  MuonSimDataCollection* sdoContainer,
594  CLHEP::HepRandomEngine* rndmEngine) {
595  Identifier currentDigitId{0}, currentElementId{0};
596 
597  double currentDeadTime = 0.;
598  MdtDigitCollection* digitCollection = nullptr;
599  // loop over sorted hits
600  m_hits.sort();
601  HitIt it = m_hits.begin();
602 
603  // +For Cosmics add
604  double timeOffsetEvent = 0.0;
605  double timeOffsetTotal = 0.0;
606 
607  // this offset emulates the timing spead of cosmics: +/- 1 BC
608  if (m_useTof == false && m_useOffSet2 == true) {
609  int inum = CLHEP::RandFlat::shootInt(rndmEngine, 0, 10);
610  if (inum == 8) {
611  timeOffsetEvent = -25.0;
612  } else if (inum == 9) {
613  timeOffsetEvent = 25.0;
614  }
615  ATH_MSG_DEBUG("Emulating timing spead of cosmics: +/- 1 BC. Adding " << timeOffsetEvent << " ns to time");
616  }
617  //-ForCosmics
618 
620  if (!mdtCalibConstants.isValid()) {
621  ATH_MSG_FATAL("Failed to retrieve set of calibration constants "<<mdtCalibConstants.fullKey());
622  return false;
623  }
624  for (; it != m_hits.end(); ++it) {
625  Identifier idDigit = it->id;
626  Identifier elementId = m_idHelperSvc->mdtIdHelper().elementID(idDigit);
628 
629  // Check if we are in a new chamber, if so get the DigitCollection
630  if (elementId != currentElementId) {
631  currentElementId = elementId;
632  digitCollection = getDigitCollection(elementId, collections);
633 
634  //+ForCosmics
635  // this offset emulates the time jitter of cosmic ray muons w.r.t LVL1 accept
636  if (m_useTof == false && m_useOffSet1 == true) {
637  timeOffsetTotal = timeOffsetEvent + CLHEP::RandFlat::shoot(rndmEngine, -12.5, 12.5);
638  ATH_MSG_DEBUG("Emulating time jitter of cosmic ray muons w.r.t LVL1 accept. Adding " << timeOffsetTotal << " ns to time");
639  }
640  //-ForCosmics
641  }
642  if (!digitCollection) {
643  ATH_MSG_ERROR("Trying to use nullptr digitCollection");
644  return false;
645  }
646 
647  float driftRadius = it->radius;
648  double driftTime = it->time;
649  double charge = it->adc;
650 
651  ATH_MSG_VERBOSE("New hit : driftTime " << driftTime << " adc " << charge);
652 
653  // check if we are in a new tube
654  if (idDigit != currentDigitId) {
655  currentDigitId = idDigit;
656  // set the deadTime
657  currentDeadTime = driftTime + charge + m_deadTime;
658  ATH_MSG_VERBOSE("New tube, setting dead time: " << currentDeadTime << " driftTime " << driftTime);
659  } else {
660  // check if tube is dead
661  if (driftTime > currentDeadTime) {
662  // tube produces a second hit, set the new deadtime
663  currentDeadTime = driftTime + charge + m_deadTime;
664  ATH_MSG_VERBOSE("Additional hit, setting dead time: " << currentDeadTime << " driftTime " << driftTime);
665  } else {
666  // tube is dead go to next hit
667  ATH_MSG_VERBOSE("Hit within dead time: " << currentDeadTime << " driftTime " << driftTime);
668  continue;
669  }
670  }
671 
672  const TimedHitPtr<MDTSimHit>& phit = *(it->simhit);
673  const MDTSimHit& hit(*phit);
674 
675  // check if the hits lies within the TDC time window
676  // subtrack the minimum Tof (= globalPosition().mag()/c) from the tof of the hit
677  double relativeTime = driftTime - minimumTof(idDigit, m_MuonGeoMgr);
678  bool insideMatch = insideMatchingWindow(relativeTime);
679  bool insideMask = insideMaskWindow(relativeTime);
680  if (insideMask && insideMatch) {
681  ATH_MSG_WARNING(" Digit in matching AND masking window, please check window definition: relative time " << relativeTime);
682  insideMask = false;
683  }
684  if (insideMatch || insideMask) {
685  // get calibration constants from DbTool
686  double t0 = m_offsetTDC;
687  const MuonCalib::MdtFullCalibData* data{mdtCalibConstants->getCalibData(idDigit, msgStream())};
688  if (data && data->tubeCalib) {
689  // extract calibration constants for single tube
690  const MuonCalib::MdtTubeCalibContainer::SingleTubeCalib* singleTubeData = data->tubeCalib->getCalib(idDigit);
691  if (singleTubeData) {
692  ATH_MSG_DEBUG("Extracted the following calibration constant for "<<m_idHelperSvc->toString(idDigit)<<" "<<singleTubeData->t0);
693  t0 = singleTubeData->t0 + m_t0ShiftTuning;
694  } else ATH_MSG_WARNING("No calibration data found, using t0=" << m_offsetTDC<<" "<<m_idHelperSvc->toString(idDigit));
695  } else {
696  ATH_MSG_WARNING("No calibration data found, using t0=" << m_offsetTDC<<" for "<<m_idHelperSvc->toString(idDigit));
697  }
698  bool isHPTDC = m_idHelperSvc->hasHPTDC(idDigit);
699  int tdc = digitizeTime(driftTime + t0 + timeOffsetTotal, isHPTDC, rndmEngine);
700  int adc = digitizeTime(it->adc, isHPTDC, rndmEngine);
701  ATH_MSG_DEBUG(" >> Digit Id = " << m_idHelperSvc->mdtIdHelper().show_to_string(idDigit) << " driftTime " << driftTime
702  << " driftRadius " << driftRadius << " TDC " << tdc << " ADC " << adc << " mask bit "
703  << insideMask);
704 
705  MdtDigit* newDigit = new MdtDigit(idDigit, tdc, adc, insideMask);
706  digitCollection->push_back(newDigit);
707 
708  ATH_MSG_VERBOSE(" createDigits() phit-" << &phit << " hit-" << hit.print() << " localZPos = " << hit.localPosition().z());
709 
710  // Do not store pile-up truth information
711  if (!m_includePileUpTruth && HepMC::ignoreTruthLink(phit->particleLink(), m_vetoPileUpTruthLinks)) { continue; }
712 
713  // Create the Deposit for MuonSimData
714  MuonSimData::Deposit deposit(HepMcParticleLink::getRedirectedLink(phit->particleLink(), phit.eventId(), ctx), // This link should now correctly resolve to the TruthEvent McEventCollection in the main StoreGateSvc.
715  MuonMCData(driftRadius, hit.localPosition().z()));
716 
717  // Record the SDO collection in StoreGate
718  std::vector<MuonSimData::Deposit> deposits;
719  deposits.push_back(deposit);
720  MuonSimData tempSDO(deposits, 0);
721  const Amg::Vector3D& tempLocPos = (*(it->simhit))->localPosition();
722  Amg::Vector3D p = geo->localToGlobalTransf(idDigit)*tempLocPos;
723  tempSDO.setPosition(p);
724  tempSDO.setTime(hitTime(phit));
725  sdoContainer->insert(std::make_pair(idDigit, tempSDO));
726 
727  } else {
728  ATH_MSG_DEBUG(" >> OUTSIDE TIME WINDOWS << "
729  << " Digit Id = " << m_idHelperSvc->toString(idDigit) << " driftTime " << driftTime
730  << " --> hit ignored");
731  }
732  } // for (; it != hits.end(); ++it)
733 
734  return true;
735 }
736 
738  IdContext mdtContext = m_idHelperSvc->mdtIdHelper().module_context();
739  IdentifierHash coll_hash;
740  if (m_idHelperSvc->mdtIdHelper().get_hash(elementId, coll_hash, &mdtContext)) {
741  ATH_MSG_ERROR("Unable to get MDT hash id from MDT Digit collection "
742  << "context begin_index = " << mdtContext.begin_index() << " context end_index = " << mdtContext.end_index()
743  << " the identifier is ");
744  elementId.show();
745  }
746 
747  if (coll_hash >= collections.size()) {
748  collections.resize (coll_hash+1);
749  }
750 
751  auto& coll = collections[coll_hash];
752  if (!coll) {
753  coll = std::make_unique<MdtDigitCollection>(elementId, coll_hash);
754  }
755  return coll.get();
756 }
757 
758 int MdtDigitizationTool::digitizeTime(double time, bool isHPTDC, CLHEP::HepRandomEngine* rndmEngine) const {
759  int tdcCount{0};
760  double tmpCount = isHPTDC ? time / m_ns2TDCHPTDC : time / m_ns2TDCAMT;
761  tdcCount = CLHEP::RandGaussZiggurat::shoot(rndmEngine, tmpCount, m_resTDC);
762  if (tdcCount < 0 || tdcCount > 4096) { ATH_MSG_DEBUG(" Count outside TDC window: " << tdcCount); }
763  return tdcCount;
764 }
765 
767  if (!m_useTof) return 0.;
768 
769  // get distance to vertex for tof correction before applying the time window
770  double distanceToVertex(0.);
771  const MuonGM::MdtReadoutElement* element = detMgr->getMdtReadoutElement(DigitId);
772 
773  if (!element) {
774  ATH_MSG_ERROR("MuonGeoManager does not return valid element for given id!");
775  } else {
776  distanceToVertex = element->tubePos(DigitId).mag();
777  }
778  // what about this? does this also need to be 1/m_signalSpeed ?
779  ATH_MSG_DEBUG("minimumTof calculated " << distanceToVertex * s_inv_c_light);
780  return distanceToVertex * s_inv_c_light;
781 }
782 
784  if (m_useTimeWindow)
785  if (time < m_bunchCountOffset || time > static_cast<double>(m_bunchCountOffset) + m_matchingWindow) {
786  ATH_MSG_VERBOSE("hit outside MatchingWindow " << time);
787  return false;
788  }
789  return true;
790 }
791 
793  if (m_useTimeWindow)
794  if (time < static_cast<double>(m_bunchCountOffset) - m_maskWindow || time > m_bunchCountOffset) {
795  ATH_MSG_VERBOSE("hit outside MaskWindow " << time);
796  return false;
797  }
798  return true;
799 }
800 
801 //+emulate deformations here
803  const Identifier& DigitId) {
804  // make the deformation
805  Amg::Vector3D hitAtGlobalFrame = element->nodeform_localToGlobalTransf(DigitId) * hit.localPosition();
806  Amg::Vector3D hitDeformed = element->globalToLocalTransf(DigitId) * hitAtGlobalFrame;
807  MDTSimHit simhit2(hit);
808  // apply the deformation
809  simhit2.setDriftRadius(hitDeformed.perp());
810  simhit2.setLocalPosition(hitDeformed);
811  return simhit2;
812 }
813 
815  const MuonGM::MdtReadoutElement* element) const {
816  Amg::Vector3D lpos = hit.localPosition();
817  Amg::Transform3D gToWireFrame = element->globalToLocalTransf(id);
818 
819  // local track direction in precision plane
820  Amg::Vector3D ldir(-lpos.y(), lpos.x(), 0.);
821  ldir.normalize();
822 
823  // calculate the position of the hit sagged wire frame
824  // transform to global coords
825  const Amg::Transform3D& transf{element->localToGlobalTransf(id)};
826  Amg::Vector3D gpos = transf*lpos;
827  Amg::Vector3D gdir = transf* ldir;
828 
829  // get wire surface
830  const Trk::StraightLineSurface& surface = element->surface(id);
831 
832  // check whether direction is pointing away from IP
833  double pointingCheck = gpos.dot(gdir) < 0 ? -1. : 1.;
834  if (pointingCheck < 0) { gdir *= pointingCheck; }
835 
836  double trackingSign = 1.;
837  double localSag = 0.0;
838 
839  // recalculate tracking sign
841  surface.globalToLocal(gpos, gdir, lpsag);
842  trackingSign = lpsag[Trk::locR] < 0 ? -1. : 1.;
843 
844 
845  // local gravity vector
846  Amg::Vector3D gravityDir =-1. * Amg::Vector3D::UnitY();
847  Amg::Vector3D lgravDir = gToWireFrame * gravityDir;
848 
849  // Project gravity vector onto X-Y plane, so the z-components (along the wire)
850  // don't contribute to the dot-product.
851  lgravDir.z() = 0.;
852 
853  // calculate whether hit above or below wire (using gravity direction
854  // 1 -> hit below wire (in same hemisphere as gravity vector)
855  //-1 -> hit above wire (in opposite hemisphere as gravity vector)
856  double sign = lpos.dot(lgravDir) < 0 ? -1. : 1.;
857 
858  return {sign, trackingSign, lpos, localSag};
859 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
MdtHitIdHelper::GetMultiLayer
int GetMultiLayer(const int &hid) const
Definition: MdtHitIdHelper.cxx:79
MuonCalib::MdtTubeCalibContainer::SingleTubeCalib::t0
float t0
< relative t0 in chamber (ns)
Definition: MdtTubeCalibContainer.h:21
MdtDigitizationTool::initialize
virtual StatusCode initialize() override final
Initialize.
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:67
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
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
MdtDigitizationTool::m_bunchCountOffset
Gaudi::Property< double > m_bunchCountOffset
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:170
MdtReadoutElement.h
MdtDigitizationTool::m_ns2TDCAMT
Gaudi::Property< double > m_ns2TDCAMT
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:152
MdtDigitizationTool::MdtDigitizationTool
MdtDigitizationTool(const std::string &type, const std::string &name, const IInterface *pIID)
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:64
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
Muon::nsw::STGTPSegments::moduleIDBits::stationPhi
constexpr uint8_t stationPhi
station Phi 1 to 8
Definition: NSWSTGTPDecodeBitmaps.h:161
MdtDigiToolInput
Definition: MdtDigiToolInput.h:26
MuonSimData::Deposit
std::pair< HepMcParticleLink, MuonMCData > Deposit
Definition: MuonSimData.h:66
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MdtDigitizationTool::getRandomEngine
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:236
get_generator_info.result
result
Definition: get_generator_info.py:21
MuonGM::MdtReadoutElement::tubeLength
double tubeLength(const int tubeLayer, const int tube) const
MdtDigitizationTool::insideMaskWindow
bool insideMaskWindow(double time) const
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:792
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
MdtTubeCalibContainer.h
MDTSimHit::localPosition
const Amg::Vector3D & localPosition() const
Definition: MDTSimHit.h:54
IdentifiableContainerMT::addCollection
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
Definition: IdentifiableContainerMT.h:297
MuonGM::MdtReadoutElement::innerTubeRadius
double innerTubeRadius() const
Returns the inner tube radius excluding the aluminium walls.
MDTSimHit::setDriftRadius
void setDriftRadius(double radius)
Definition: MDTSimHit.h:52
MdtDigitizationTool::m_outputSDOKey
SG::WriteHandleKey< MuonSimDataCollection > m_outputSDOKey
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:210
isBSM
bool isBSM(const T &p)
APID: graviton and all Higgs extensions are BSM.
Definition: AtlasPID.h:836
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
MdtDigitizationTool::m_t0ShiftTuning
Gaudi::Property< double > m_t0ShiftTuning
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:155
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
MdtDigit
Definition: MdtDigit.h:19
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
MDTSimHit
Definition: MDTSimHit.h:21
MdtDigitizationTool::m_useAllBOLTwin
Gaudi::Property< bool > m_useAllBOLTwin
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:165
MdtDigitizationTool::processAllSubEvents
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
alternative interface which uses the PileUpMergeSvc to obtain all the required SubEvents.
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:278
MdtDigitizationTool::m_maskWindow
Gaudi::Property< double > m_maskWindow
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:172
MdtDigitizationTool::m_signalSpeed
Gaudi::Property< double > m_signalSpeed
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:150
MuonSimData::setPosition
void setPosition(const Amg::Vector3D &pos)
Definition: MuonSimData.h:106
EventPrimitivesHelpers.h
IdContext::end_index
size_type end_index() const
Definition: IdContext.h:46
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
AtlasHitsVector
Definition: AtlasHitsVector.h:32
skel.it
it
Definition: skel.GENtoEVGEN.py:407
MDTSimHitCollection
AtlasHitsVector< MDTSimHit > MDTSimHitCollection
Definition: MDTSimHitCollection.h:14
MDT_SortedHitVector::sort
void sort()
Definition: MDT_SortedHitVector.h:44
MuonGM::MdtReadoutElement::nodeform_localToGlobalTransf
Amg::Transform3D nodeform_localToGlobalTransf(const Identifier &id) const
MdtDigitizationTool::m_digiTool
ToolHandle< IMDT_DigitizationTool > m_digiTool
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:144
PileUpTimeEventIndex::index
index_type index() const
the index of the component event in PileUpEventInfo
Definition: PileUpTimeEventIndex.cxx:76
MdtHitIdHelper::GetZSector
int GetZSector(const int &hid) const
Definition: MdtHitIdHelper.cxx:73
TimedHitPtr< MDTSimHit >
Trk::locR
@ locR
Definition: ParamDefs.h:44
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
MdtDigitizationTool::minimumTof
double minimumTof(Identifier DigitId, const MuonGM::MuonDetectorManager *detMgr) const
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:766
MdtHitIdHelper::GetHelper
static const MdtHitIdHelper * GetHelper(unsigned int nTubes=78)
Definition: MdtHitIdHelper.cxx:24
MdtDigitizationTool::m_matchingWindow
Gaudi::Property< double > m_matchingWindow
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:171
HepMC::ignoreTruthLink
bool ignoreTruthLink(const T &p, bool vetoPileUp)
Helper function for SDO creation in PileUpTools.
Definition: MagicNumbers.h:344
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
MdtDigitizationTool::m_deadTime
Gaudi::Property< double > m_deadTime
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:173
MuonSimData::setTime
void setTime(const float &time)
Definition: MuonSimData.h:119
MdtDigitizationTool::applyDeformations
static MDTSimHit applyDeformations(const MDTSimHit &, const MuonGM::MdtReadoutElement *, const Identifier &)
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:802
MuonCalib::MdtFullCalibData
class which holds the full set of calibration constants for a given tube
Definition: MdtFullCalibData.h:15
GenParticle.h
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
PileUpToolBase::m_vetoPileUpTruthLinks
Gaudi::Property< int > m_vetoPileUpTruthLinks
Definition: PileUpToolBase.h:58
MdtDigitizationTool::m_useProp
Gaudi::Property< bool > m_useProp
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:161
MdtDigitizationTool::getNextEvent
StatusCode getNextEvent(const EventContext &ctx)
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:184
MdtDigiToolOutput
Definition: MdtDigiToolOutput.h:19
PileUpMergeSvc::TimedList::type
std::list< value_t > type
type of the collection of timed data object
Definition: PileUpMergeSvc.h:73
MuonGM::MdtReadoutElement::globalToLocalTransf
Amg::Transform3D globalToLocalTransf(const int tubeLayer, const int tube) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MdtReadoutElement.cxx:400
MdtDigitizationTool::m_useTof
Gaudi::Property< bool > m_useTof
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:159
Trk::StraightLineSurface::globalToLocal
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const override final
Specified for StraightLineSurface: GlobalToLocal method without dynamic memory allocation This method...
Definition: StraightLineSurface.cxx:164
fractionalCharge
double fractionalCharge(const T &p)
Definition: AtlasPID.h:985
GeometryStatics.h
MdtHitIdHelper::GetPhiSector
int GetPhiSector(const int &hid) const
Definition: MdtHitIdHelper.cxx:68
MdtDigitizationTool::m_checkMDTSimHits
Gaudi::Property< bool > m_checkMDTSimHits
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:158
MdtDigitizationTool::m_offsetTDC
Gaudi::Property< double > m_offsetTDC
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:149
MdtHitIdHelper::GetStationName
std::string GetStationName(const int &hid) const
Definition: MdtHitIdHelper.cxx:57
IdContext::begin_index
size_type begin_index() const
Definition: IdContext.h:45
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
MdtDigitizationTool::m_DoQballCharge
Gaudi::Property< bool > m_DoQballCharge
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:185
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MdtDigitizationTool::insideMatchingWindow
bool insideMatchingWindow(double time) const
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:783
TRT::Hit::driftTime
@ driftTime
Definition: HitInfo.h:43
MdtDigitizationTool::m_MDTHitCollList
std::vector< MDTSimHitCollection * > m_MDTHitCollList
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:146
MuonGM::MuonDetectorManager::getMdtReadoutElement
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:206
MdtDigitizationTool::m_inputObjectName
std::string m_inputObjectName
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:207
LArG4FSStartPointFilter.rand
rand
Definition: LArG4FSStartPointFilter.py:80
MuonGM::MdtReadoutElement
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:51
MdtDigitizationTool::m_resTDC
Gaudi::Property< double > m_resTDC
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:154
lumiFormat.i
int i
Definition: lumiFormat.py:85
MdtDigitizationTool::m_calibDbKey
SG::ReadCondHandleKey< MuonCalib::MdtCalibDataContainer > m_calibDbKey
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:215
MdtDigitizationTool::m_MuonGeoMgr
const MuonGM::MuonDetectorManager * m_MuonGeoMgr
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:142
MdtDigitizationTool::m_resTwin
Gaudi::Property< double > m_resTwin
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:166
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:53
MdtDigitizationTool::m_useOffSet2
Gaudi::Property< bool > m_useOffSet2
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:178
MdtDigitizationTool::m_outputObjectKey
SG::WriteHandleKey< MdtDigitContainer > m_outputObjectKey
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:208
MuonSimDataCollection
Definition: MuonSimDataCollection.h:21
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition: StoreGate/src/VarHandleBase.cxx:382
MdtDigitizationTool::m_mergeSvc
ServiceHandle< PileUpMergeSvc > m_mergeSvc
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:203
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MdtDigitizationTool::m_useTimeWindow
Gaudi::Property< bool > m_useTimeWindow
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:169
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
MdtDigitizationTool::m_useDeformations
Gaudi::Property< bool > m_useDeformations
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:182
MdtDigitizationTool::m_useAttenuation
Gaudi::Property< bool > m_useAttenuation
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:160
MDTSimHit::setLocalPosition
void setLocalPosition(Amg::Vector3D &localPosition)
Definition: MDTSimHit.h:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MdtDigitizationTool::m_thpcMDT
std::unique_ptr< TimedHitCollection< MDTSimHit > > m_thpcMDT
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:188
MdtDigiToolOutput::wasEfficient
double wasEfficient() const
Definition: MdtDigiToolOutput.h:29
MdtHitIdHelper::GetLayer
int GetLayer(const int &hid) const
Definition: MdtHitIdHelper.cxx:84
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
MdtDigitizationTool::m_readKey
SG::ReadCondHandleKey< MdtCondDbData > m_readKey
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:218
MuonGM::MdtReadoutElement::localToGlobalTransf
const Amg::Transform3D & localToGlobalTransf(const Identifier &id) const
MdtDigitizationTool::correctGeometricalWireSag
GeoCorOut correctGeometricalWireSag(const MDTSimHit &hit, const Identifier &id, const MuonGM::MdtReadoutElement *element) const
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:814
Identifier::show
void show() const
Print out in hex form.
Definition: Identifier.cxx:30
MDTSimHit::globalTime
double globalTime() const
Definition: MDTSimHit.h:48
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
PileUpToolBase
Definition: PileUpToolBase.h:18
mdt_hit_info
Definition: MDT_SortedHitVector.h:9
MDTSimHit::MDTid
HitID MDTid() const
Definition: MDTSimHit.h:62
EventPrimitives.h
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
MdtDigitizationTool::m_includePileUpTruth
Gaudi::Property< bool > m_includePileUpTruth
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:191
WriteHiveWithMetaData.streamName
string streamName
Definition: WriteHiveWithMetaData.py:22
PathResolver.h
MdtDigitizationTool::m_onlyUseContainerName
BooleanProperty m_onlyUseContainerName
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:204
MDTSimHit::driftRadius
double driftRadius() const
Definition: MDTSimHit.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition: RNGWrapper.h:56
MdtDigitCollection
Definition: MdtDigitCollection.h:18
PileUpTimeEventIndex::time
time_type time() const
bunch xing time in ns
Definition: PileUpTimeEventIndex.cxx:71
MdtDigitizationTool::digitizeTime
int digitizeTime(double time, bool isHPTDC, CLHEP::HepRandomEngine *rndmEngine) const
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:758
charge
double charge(const T &p)
Definition: AtlasPID.h:986
MdtDigitizationTool::m_hitsContainerKey
SG::ReadHandleKey< MDTSimHitCollection > m_hitsContainerKey
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:206
MdtDigiToolInput.h
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
MuonSimData
Definition: MuonSimData.h:62
python.PhysicalConstants.c_light
float c_light
Definition: PhysicalConstants.py:73
HitIt
HitVector::iterator HitIt
Definition: MDT_SortedHitVector.h:32
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MdtDigitizationTool.h
MuonDetectorManager.h
MDTSimHit::print
std::string print() const
Definition: MDTSimHit.cxx:100
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
MdtDigitizationTool::checkMDTSimHit
bool checkMDTSimHit(const EventContext &ctx, const MDTSimHit &hit) const
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:531
MdtDigitizationTool::m_useOffSet1
Gaudi::Property< bool > m_useOffSet1
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:177
MdtDigitizationTool::doDigitization
StatusCode doDigitization(const EventContext &ctx, Collections_t &collections, MuonSimDataCollection *sdoContainer)
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:312
MdtDigitizationTool::m_useTwin
Gaudi::Property< bool > m_useTwin
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:164
MdtDigitizationTool::prepareEvent
StatusCode prepareEvent(const EventContext &ctx, const unsigned int) override final
When being run from PileUpToolsAlgs, this method is called at the start of the subevts loop.
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:143
MdtDigitizationTool::m_hits
MDT_SortedHitVector m_hits
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:135
MuonGM::MdtReadoutElement::tubeFrame_localROPos
Amg::Vector3D tubeFrame_localROPos(const int tubelayer, const int tube) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MdtReadoutElement.cxx:282
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
MdtDigitizationTool::GeoCorOut
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:109
MDTSimHit::particleLink
const HepMcParticleLink & particleLink() const
Definition: MDTSimHit.h:100
MdtDigitizationTool::m_DiscardEarlyHits
Gaudi::Property< bool > m_DiscardEarlyHits
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:174
MdtDigitizationTool::handleMDTSimHit
bool handleMDTSimHit(const EventContext &ctx, const TimedHitPtr< MDTSimHit > &phit, CLHEP::HepRandomEngine *twinRndmEngine, CLHEP::HepRandomEngine *toolRndmEngine)
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:349
MuonGM::MdtReadoutElement::tubePos
Amg::Vector3D tubePos(const Identifier &id) const
Returns the global position of the given tube.
MdtDigitizationTool::m_ns2TDCHPTDC
Gaudi::Property< double > m_ns2TDCHPTDC
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:153
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
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
TimedHitPtr::eventId
unsigned short eventId() const
the index of the component event in PileUpEventInfo.
Definition: TimedHitPtr.h:47
MdtHitIdHelper.h
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:51
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MdtDigitizationTool::mergeEvent
StatusCode mergeEvent(const EventContext &ctx) override final
When being run from PileUpToolsAlgs, this method is called at the end of the subevts loop.
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:243
LArCellConditions.geo
bool geo
Definition: LArCellConditions.py:46
MdtFullCalibData.h
MdtDigiToolOutput::driftTime
double driftTime() const
Definition: MdtDigiToolOutput.h:27
MdtDigitizationTool::createDigits
bool createDigits(const EventContext &ctx, Collections_t &collections, MuonSimDataCollection *sdoContainer, CLHEP::HepRandomEngine *rndmEngine)
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:592
MdtDigitizationTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:137
MuonGM::MdtReadoutElement::surface
virtual const Trk::Surface & surface() const override final
Return surface associated with this detector element.
Definition: MuonDetDescr/MuonReadoutGeometry/src/MdtReadoutElement.cxx:885
MdtDigiToolOutput::adc
double adc() const
Definition: MdtDigiToolOutput.h:28
MdtHitIdHelper::GetTube
int GetTube(const int &hid) const
Definition: MdtHitIdHelper.cxx:89
AtlasHitsVector::size
size_type size() const
Definition: AtlasHitsVector.h:142
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
MuonCalib::MdtTubeCalibContainer::SingleTubeCalib
Definition: MdtTubeCalibContainer.h:19
merge.status
status
Definition: merge.py:16
MdtDigitizationTool::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:213
MDT_SortedHitVector::insert
void insert(const mdt_hit_info &hit)
Definition: MDT_SortedHitVector.h:48
hitTime
float hitTime(const AFP_SIDSimHit &hit)
Definition: AFP_SIDSimHit.h:39
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:159
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
PileUpTimeEventIndex
a struct encapsulating the identifier of a pile-up event
Definition: PileUpTimeEventIndex.h:12
PileUpTimeEventIndex::type
PileUpType type() const
the pileup type - minbias, cavern, beam halo, signal?
Definition: PileUpTimeEventIndex.cxx:81
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
TimedHitCollection
Definition: TimedHitCollection.h:15
MdtDigitizationTool::m_muonHelper
const MdtHitIdHelper * m_muonHelper
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:138
MdtDigitizationTool::processBunchXing
virtual StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
When being run from PileUpToolsAlgs, this method is called for each active bunch-crossing to process ...
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:152
calibdata.tube
tube
Definition: calibdata.py:30
HepMCHelpers.h
MdtDigitizationTool::getDigitCollection
MdtDigitCollection * getDigitCollection(Identifier elementId, Collections_t &collections)
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.cxx:737
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51
MuonMCData
Definition: MuonSimData.h:42
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
MdtDigitizationTool::Collections_t
std::vector< std::unique_ptr< MdtDigitCollection > > Collections_t
Definition: MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h:119
Identifier
Definition: IdentifierFieldParser.cxx:14