ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
MuonCalib::EventHandler Class Reference

#include <EventHandler.h>

Collaboration diagram for MuonCalib::EventHandler:

Classes

struct  AuthorIndices
 

Public Types

using ExtendedTrackPtr = MuonCalibExtendedRawHits::ExtendedTrkPtr
 
using ExtendedSegmentPtr = MuonCalibExtendedRawHits::ExtendedSegPtr
 
using TruthPtr = MuonCalibTruthCollection::TruthPtr
 
using TruthMdtPtr = MuonCalibTruthCollection::TruthMdtPtr
 
using TruthRpcPtr = MuonCalibTruthCollection::TruthRpcPtr
 
using TruthTgcPtr = MuonCalibTruthCollection::TruthTgcPtr
 
using TruthCscPtr = MuonCalibTruthCollection::TruthCscPtr
 
using TrackVec = std::vector< ExtendedTrackPtr >
 
using AuthorTrackVecMap = std::map< int, TrackVec >
 
using SegmentVec = std::vector< ExtendedSegmentPtr >
 
using AuthorSegmentVecMap = std::map< int, SegmentVec >
 
using AuthorSegmentVecIt = AuthorSegmentVecMap::iterator
 
using AuthorSegmentVecCit = AuthorSegmentVecMap::const_iterator
 

Public Member Functions

 EventHandler ()
 default constructor More...
 
 ~EventHandler ()
 default destructor More...
 
void clear ()
 clear all buffers More...
 
void setEvent (std::shared_ptr< const MuonCalibEvent_E > event)
 set a new event (will call clear on the previous) More...
 
const TrackVecextendedTracks (int author) const
 get extended tracks More...
 
const SegmentVecextendedSegments (int author) const
 get extended tracks More...
 
const MuonCalibExtendedRawHitsextendedRawHits () const
 get extended raw hits More...
 
const MuonCalibEvent_Eevent () const
 get event More...
 
const AuthorIndicesmooreIndices () const
 get author indices for Moore More...
 
const AuthorIndicesmuonboyIndices () const
 get author indices for Muonboy More...
 
std::string dumpRawHits () const
 dump routines More...
 
std::string dumpTracks () const
 
std::string dumpTracks (const TrackVec &tracks) const
 
std::string dumpSegments (const SegmentVec &segments) const
 
std::string dumpSegments () const
 
std::string dumpEvent () const
 
void setdbg (const bool dbg_on)
 

Private Member Functions

void createExtendedTracks ()
 create extended tracks for event More...
 
void createExtendedTruthTracks ()
 create extended tracks for event More...
 
void createExtendedSegments ()
 create extended segments for event More...
 
void createExtendedRawHits ()
 create extend raw hits More...
 
void associateSegmentsWithTracks (SegmentVec &segments, TrackVec &tracks)
 create association between tracks and segments More...
 
int associateSegmentWithTrack (const MuonCalibExtendedSegment &segment, const MuonCalibExtendedTrack &track)
 check whether segment and track share the same hits More...
 
int segmentOverlap (const MuonCalibExtendedSegment &segment1, const MuonCalibExtendedSegment &segment2)
 check whether segments share the same hits More...
 
void linkTracks (int referenceIndex)
 link tracks to the reference track using the hits on the track More...
 
void match (const MuonCalibExtendedTrack &reference, TrackVec &tracks)
 find best match of tracks with reference More...
 
template<typename T >
void split_along_barcode (const std::vector< T > &container, std::map< int, std::set< T >> &barcode_map)
 Spltis the truth hit container into a map having the barcode of the particle as key. More...
 
std::shared_ptr< MuonCalibTrack_Etransform_to_trk (const TruthPtr &truth_part, const std::map< int, std::set< TruthMdtPtr >> &mdt_hits, const std::map< int, std::set< TruthCscPtr >> &csc_hits, const std::map< int, std::set< TruthRpcPtr >> &rpc_hits, const std::map< int, std::set< TruthTgcPtr >> &tgc_hits)
 

Private Attributes

std::shared_ptr< const MuonCalibEvent_Em_event
 
AuthorTrackVecMap m_extendedTracks
 
AuthorSegmentVecMap m_extendedSegments
 
MuonCalibExtendedRawHits m_extendedRawHits
 
AuthorIndices m_mooreIndices
 
AuthorIndices m_muonboyIndices
 
bool m_debug
 

Detailed Description

Definition at line 23 of file EventHandler.h.

Member Typedef Documentation

◆ AuthorSegmentVecCit

using MuonCalib::EventHandler::AuthorSegmentVecCit = AuthorSegmentVecMap::const_iterator

Definition at line 47 of file EventHandler.h.

◆ AuthorSegmentVecIt

using MuonCalib::EventHandler::AuthorSegmentVecIt = AuthorSegmentVecMap::iterator

Definition at line 46 of file EventHandler.h.

◆ AuthorSegmentVecMap

Definition at line 45 of file EventHandler.h.

◆ AuthorTrackVecMap

Definition at line 42 of file EventHandler.h.

◆ ExtendedSegmentPtr

Definition at line 33 of file EventHandler.h.

◆ ExtendedTrackPtr

Definition at line 32 of file EventHandler.h.

◆ SegmentVec

Definition at line 44 of file EventHandler.h.

◆ TrackVec

Definition at line 41 of file EventHandler.h.

◆ TruthCscPtr

Definition at line 39 of file EventHandler.h.

◆ TruthMdtPtr

Definition at line 36 of file EventHandler.h.

◆ TruthPtr

Definition at line 35 of file EventHandler.h.

◆ TruthRpcPtr

Definition at line 37 of file EventHandler.h.

◆ TruthTgcPtr

Definition at line 38 of file EventHandler.h.

Constructor & Destructor Documentation

◆ EventHandler()

MuonCalib::EventHandler::EventHandler ( )

default constructor

Definition at line 35 of file EventHandler.cxx.

35 : m_event(nullptr), m_mooreIndices(4, 0), m_muonboyIndices(3, 100), m_debug(false) {}

◆ ~EventHandler()

MuonCalib::EventHandler::~EventHandler ( )

default destructor

Definition at line 37 of file EventHandler.cxx.

37 { clear(); }

Member Function Documentation

◆ associateSegmentsWithTracks()

void MuonCalib::EventHandler::associateSegmentsWithTracks ( SegmentVec segments,
TrackVec tracks 
)
private

create association between tracks and segments

helper struct to evaluate the segment match quality

Definition at line 405 of file EventHandler.cxx.

405  {
407  struct segmentMatchQual {
408  ExtendedSegmentPtr seg;
409  int assoc_quality{0};
410  bool vetoed{false};
411  bool operator<(const segmentMatchQual& other) const {
412  if (assoc_quality != other.assoc_quality) return assoc_quality > other.assoc_quality;
413  return seg->chi2() < other.seg->chi2();
414  };
415  segmentMatchQual(ExtendedSegmentPtr _ptr, int score) : seg{std::move(_ptr)}, assoc_quality{score} {}
416  };
417 
418  for (const ExtendedTrackPtr& trk : tracks) {
419  std::vector<segmentMatchQual> segmentTrackMatch;
420  for (const ExtendedSegmentPtr& seg : segments) {
421  int match = associateSegmentWithTrack(*seg, *trk);
422  if (match > 200) { segmentTrackMatch.emplace_back(seg, match); }
423  }
424  std::vector<segmentMatchQual>::iterator mit = segmentTrackMatch.begin();
425  std::vector<segmentMatchQual>::iterator mit_end = segmentTrackMatch.end();
426  std::sort(mit, mit_end);
427  for (; mit != mit_end; ++mit) {
429  for (; mit2 != mit_end; ++mit2) {
430  if (segmentOverlap(*mit->seg, *mit2->seg) > 1) { mit2->vetoed = true; }
431  }
432 
433  std::cout << "We need to refine the track to segment association " << __FILE__ << " " << __LINE__ << std::endl;
434  // if (!mit->vetoed) {
435  // mit->seg->addTrack(trk);
436  // trk->addSegment(mit->seg);
437  // }
438  }
439  }
440  }

◆ associateSegmentWithTrack()

int MuonCalib::EventHandler::associateSegmentWithTrack ( const MuonCalibExtendedSegment segment,
const MuonCalibExtendedTrack track 
)
private

check whether segment and track share the same hits

Definition at line 487 of file EventHandler.cxx.

487  {
488  double minRadius = 1.; // the sign of all hits with a drift radius smaller that minRadius is not taken into account
489  unsigned int noppositeSign{0}, nsameSign{0}, nnotOnTrack{0};
490  for (const MuonCalibSegment::MdtHitPtr& mdt_hit : segment.mdtHOT()) {
491  const MuonFixedId& id = mdt_hit->identify();
492  if (!id.isValid()) {
493  MsgStream log(Athena::getMessageSvc(), "EventHandler");
494  log << MSG::WARNING << "associateSegmentWithTrack(), invalid MDT id! " << endmsg;
495  continue;
496  }
497  // look up hit on track
498  IdHitMap::const_iterator trkHit = track.idHitMap().find(id);
499  if (trkHit != track.idHitMap().end()) {
500  // found hit
501  double signSeg = mdt_hit->driftRadius() < -minRadius ? -1. : 1.;
502  double signTrk = trkHit->second->driftRadius() < -minRadius ? -1. : 1.;
503  if (signSeg == signTrk)
504  ++nsameSign;
505  else
506  ++noppositeSign;
507  } else {
508  ++nnotOnTrack;
509  }
510  }
511 
512  for (const MuonCalibSegment::CscHitPtr& csc_hit : segment.cscHOT()) {
513  MuonFixedId id = csc_hit->identify();
514  if (!id.isValid()) {
515  MsgStream log(Athena::getMessageSvc(), "EventHandler");
516  log << MSG::WARNING << "associateSegmentWithTrack(), invalid CSC id! " << endmsg;
517  continue;
518  }
519  // look up hit on track
520  IdHitMap::const_iterator trkHit = track.idHitMap().find(id);
521  if (trkHit != track.idHitMap().end()) {
522  // found hit
523  ++nsameSign;
524  } else {
525  ++nnotOnTrack;
526  }
527  }
528  // Okay the weighting factors seem a bit arbitrary
529  return nnotOnTrack + 10 * noppositeSign + 100 * nsameSign;
530  }

◆ clear()

void MuonCalib::EventHandler::clear ( )

clear all buffers

Definition at line 68 of file EventHandler.cxx.

68  {
69  m_extendedTracks.clear();
70  m_extendedSegments.clear();
71  }

◆ createExtendedRawHits()

void MuonCalib::EventHandler::createExtendedRawHits ( )
private

create extend raw hits

Definition at line 167 of file EventHandler.cxx.

167  {
168  if (!m_event || !m_event->rawHitCollection()) return;
169 
172 
173  SegmentVec seg_to_pipe;
174  TrackVec trk_to_pipe;
175  if (segIt != m_extendedSegments.end()) seg_to_pipe = segIt->second;
176  if (trk_itr != m_extendedTracks.end()) trk_to_pipe = trk_itr->second;
177 
178  m_extendedRawHits = MuonCalibExtendedRawHits(*m_event->rawHitCollection(), seg_to_pipe, trk_to_pipe);
179  }

◆ createExtendedSegments()

void MuonCalib::EventHandler::createExtendedSegments ( )
private

create extended segments for event

Definition at line 388 of file EventHandler.cxx.

388  {
389  // check that event is set
390  if (!m_event) return;
391 
392  for (const MuonCalibEvent::PatternPtr& pat_ptr : m_event->pattern()) {
393  for (const MuonCalibPattern::MuonCalibSegPtr& seg_ptr : pat_ptr->muonSegs()) {
394  // get author
395  int author = seg_ptr->author();
397 
398  // create new extended segment
399  MuonCalibExtendedSegment* extendedSegment = new MuonCalibExtendedSegment(*seg_ptr);
400  segVec.emplace_back(extendedSegment);
401  }
402  }
403  }

◆ createExtendedTracks()

void MuonCalib::EventHandler::createExtendedTracks ( )
private

create extended tracks for event

Definition at line 181 of file EventHandler.cxx.

181  {
182  // check that event is set
183  if (!m_event) return;
184 
185  // hack to get the associations right...
186  ExtendedTrackPtr previousMooreTrack;
187 
188  for (const MuonCalibEvent_E::MuonCalibTrkPtr& track_ptr : m_event->tracks()) {
189  // get author Moore/Muonboy tracks author == 0 and corresponding TrackVec
190  int author = track_ptr->author();
191  TrackVec& trackVec = m_extendedTracks[author];
192 
193  // create new extended track and add it to TrackVec
194  ExtendedTrackPtr extendedTrack = std::make_shared<MuonCalibExtendedTrack>(*track_ptr, 0, 0);
195 
196  // store previous moore track so we can add the back extrapolated ones if any
197 #ifdef TO_DO
198  if (author == 0) {
199  previousMooreTrack = extendedTrack;
200  } else if ((author == 1 || author == 2) && previousMooreTrack) {
201  std::cout << "Perform proper track association " << __FILE__ << " " << __LINE__ << std::endl;
202  // previousMooreTrack->addAssociatedTrack(extendedTrack);
203  // extendedTrack->addAssociatedTrack(previousMooreTrack);
204  } else if (author == 10 && track_ptr->nrHits() == 0) {
205  // Associate MuidSA/MooreExtrapolate to IP to author 0 if no hits on track
206  TrackVec& trackVec0 = m_extendedTracks[0];
207  double dotprodmax = -1.;
208  if (trackVec0.size() > 0) {
209  int trackcount10 = trackVec.size();
210  TrackVec::iterator it0 = trackVec0.begin();
211  TrackVec::iterator it0_end = trackVec0.end();
212  int trackcount0 = 0;
213  const MuonCalibExtendedTrack* associatedMooreTrack = 0;
214  for (; it0 != it0_end; ++it0) {
215  trackcount0++;
216  if (trackcount10 > trackcount0) continue;
217  double dotprod = extendedTrack->direction().dot((*it0)->direction());
218  if (extendedTrack->isAssociated(*it0)) continue;
219  if ((*it0)->isAssociated(extendedTrack)) continue;
220  if (dotprod > dotprodmax) {
221  dotprodmax = dotprod;
222  associatedMooreTrack = *it0;
223  if (dotprodmax > 0.8) break;
224  }
225  }
226  if (dotprodmax > 0.8 && associatedMooreTrack) {
227  extendedTrack->addAssociatedTrack(associatedMooreTrack);
228  associatedMooreTrack->addAssociatedTrack(extendedTrack);
229  }
230  }
231  }
232 #endif
233  trackVec.push_back(extendedTrack);
234  }
235  }

◆ createExtendedTruthTracks()

void MuonCalib::EventHandler::createExtendedTruthTracks ( )
private

create extended tracks for event

Definition at line 245 of file EventHandler.cxx.

245  {
246  // check that event is set
247  if (!m_event) return;
248  //
249  // Truth track collection
250  //
251 
252  const MuonCalibTruthCollection* truth = m_event->calibTruthCollection();
253  if (!truth) return;
254 
255  if (truth->TruthContainer().empty()) return;
256 
257  std::map<int, TruthPtr> truthTrkME, truthTrkIP, truthTrkRest;
258 
259  std::map<int, std::set<TruthMdtPtr>> truthTrkMdtHitMap;
260  std::map<int, std::set<TruthCscPtr>> truthTrkCscHitMap;
261  std::map<int, std::set<TruthRpcPtr>> truthTrkRpcHitMap;
262  std::map<int, std::set<TruthTgcPtr>> truthTrkTgcHitMap;
263 
264  MsgStream log(Athena::getMessageSvc(), "EventHandler");
265  for (const TruthPtr& truth_part : truth->TruthContainer()) {
266  int barcode = truth_part->barCode();
267  if (barcode <= 0) continue;
268  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "createExtendedTruthTracks() truth track barcode " << barcode << endmsg;
269 
270  if (truth_part->position().perp() < 4000 && std::abs(truth_part->position().z()) < 6000.) {
271  if (truth_part->position().perp() < 100 && std::abs(truth_part->position().z()) < 500.) {
272  // Close to IP
273  truthTrkIP[barcode] = truth_part;
274  } else {
275  truthTrkRest[barcode] = truth_part;
276  }
277  } else {
278  // Take track at Muon Entry
279  truthTrkME[barcode] = truth_part;
280  }
281  }
282 
283  //
284  // Mdt truth hit information
285  //
286  split_along_barcode(truth->MdtContainer(), truthTrkMdtHitMap);
287 
288  if (truthTrkMdtHitMap.empty()) return;
289 
290  //
291  // Csc truth hit information
292  //
293  split_along_barcode(truth->CscContainer(), truthTrkCscHitMap);
294  //
295  // Rpc truth hit information
296  //
297 
298  split_along_barcode(truth->RpcContainer(), truthTrkRpcHitMap);
299 
300  //
301  // Tgc truth hit information
302  //
303  split_along_barcode(truth->TgcContainer(), truthTrkTgcHitMap);
304 
305  for (const auto& it_IP : truthTrkIP) {
306  std::shared_ptr<MuonCalibTrack_E> truth_trk =
307  transform_to_trk(it_IP.second, truthTrkMdtHitMap, truthTrkCscHitMap, truthTrkRpcHitMap, truthTrkTgcHitMap);
308  int barcode = it_IP.first;
309  int pdgcode = it_IP.second->PDGCode();
310  int author = -13;
311  if (std::abs(pdgcode) != 13) author = -113;
312  TrackVec& trackVec = m_extendedTracks[author];
313  std::shared_ptr<MuonCalibExtendedTrack> extendedTrack = std::make_shared<MuonCalibExtendedTrack>(*truth_trk, pdgcode, barcode);
314  trackVec.push_back(extendedTrack);
315  // dump truth track
316  if (m_debug) extendedTrack->dump();
317  }
318 
319  for (const auto& it_ME : truthTrkME) {
320  std::shared_ptr<MuonCalibTrack_E> truth_trk =
321  transform_to_trk(it_ME.second, truthTrkMdtHitMap, truthTrkCscHitMap, truthTrkRpcHitMap, truthTrkTgcHitMap);
322 
323  int barcode = it_ME.first;
324  int pdgcode = it_ME.second->PDGCode();
325  int author = -1013;
326  if (std::abs(pdgcode) != 13) author = -1113;
327  TrackVec& trackVec = m_extendedTracks[author];
328  std::shared_ptr<MuonCalibExtendedTrack> extendedTrack = std::make_shared<MuonCalibExtendedTrack>(*truth_trk, pdgcode, barcode);
329  trackVec.push_back(extendedTrack);
330  // dump truth track
331  if (m_debug) extendedTrack->dump();
332  }
333  }

◆ dumpEvent()

std::string MuonCalib::EventHandler::dumpEvent ( ) const

Definition at line 147 of file EventHandler.cxx.

147  {
148  std::ostringstream sout;
149  sout << dumpRawHits() << std::endl << dumpTracks() << std::endl << dumpSegments();
150  return sout.str();
151  }

◆ dumpRawHits()

std::string MuonCalib::EventHandler::dumpRawHits ( ) const

dump routines

Definition at line 103 of file EventHandler.cxx.

103  {
104  std::ostringstream sout;
105  sout << m_extendedRawHits.dumpMdtHits();
106  return sout.str();
107  }

◆ dumpSegments() [1/2]

std::string MuonCalib::EventHandler::dumpSegments ( ) const

Definition at line 133 of file EventHandler.cxx.

133  {
134  std::ostringstream sout;
136  sout << " Muonboy Segments " << extendedSegments(m_muonboyIndices.segment).size() << std::endl
138  if (!extendedSegments(m_mooreIndices.segment).empty()) sout << std::endl;
139  }
141  sout << " Moore Segments " << extendedSegments(m_mooreIndices.segment).size() << std::endl
143  }
144  return sout.str();
145  }

◆ dumpSegments() [2/2]

std::string MuonCalib::EventHandler::dumpSegments ( const SegmentVec segments) const

Definition at line 121 of file EventHandler.cxx.

121  {
122  std::ostringstream sout;
123  SegmentVec::const_iterator seg = segments.begin();
124  SegmentVec::const_iterator seg_end = segments.end();
125  SegmentVec::const_iterator seg_last = seg_end - 1;
126  for (; seg != seg_end; ++seg) {
127  sout << (*seg)->dump();
128  if (seg != seg_last) sout << std::endl;
129  }
130  return sout.str();
131  }

◆ dumpTracks() [1/2]

std::string MuonCalib::EventHandler::dumpTracks ( ) const

Definition at line 153 of file EventHandler.cxx.

153  {
154  std::ostringstream sout;
155  for (const auto& it : m_extendedTracks) {
156  // skip standalone tracks at IP
157  if (it.first == 1 || it.first == 2) continue;
158 
159  sout << " Track Author " << it.first << " number of tracks " << it.second.size();
160  // only dump Muon tracks
161  if (it.first < 1000) sout << std::endl << dumpTracks(it.second);
162  sout << std::endl;
163  }
164  return sout.str();
165  }

◆ dumpTracks() [2/2]

std::string MuonCalib::EventHandler::dumpTracks ( const TrackVec tracks) const

Definition at line 109 of file EventHandler.cxx.

109  {
110  std::ostringstream sout;
111  TrackVec::const_iterator trk = tracks.begin();
112  TrackVec::const_iterator trk_end = tracks.end();
113  TrackVec::const_iterator trk_last = trk_end - 1;
114  for (; trk != trk_end; ++trk) {
115  sout << (*trk)->dump();
116  if (trk != trk_last) sout << std::endl;
117  }
118  return sout.str();
119  }

◆ event()

const MuonCalibEvent_E & MuonCalib::EventHandler::event ( ) const

get event

Definition at line 58 of file EventHandler.cxx.

58 { return *m_event; }

◆ extendedRawHits()

const MuonCalibExtendedRawHits & MuonCalib::EventHandler::extendedRawHits ( ) const

get extended raw hits

Definition at line 55 of file EventHandler.cxx.

55 { return m_extendedRawHits; }

◆ extendedSegments()

const EventHandler::SegmentVec & MuonCalib::EventHandler::extendedSegments ( int  author) const

get extended tracks

Definition at line 47 of file EventHandler.cxx.

47  {
48  AuthorSegmentVecMap::const_iterator itr = m_extendedSegments.find(author);
49  if (itr != m_extendedSegments.end()) return itr->second;
50  static const SegmentVec dummy_vec;
51  return dummy_vec;
52  }

◆ extendedTracks()

const EventHandler::TrackVec & MuonCalib::EventHandler::extendedTracks ( int  author) const

get extended tracks

Definition at line 39 of file EventHandler.cxx.

39  {
40  AuthorTrackVecMap::const_iterator itr = m_extendedTracks.find(author);
41  if (itr != m_extendedTracks.end()) return itr->second;
42  static const TrackVec dummy_vec;
43  return dummy_vec;
44  }

◆ linkTracks()

void MuonCalib::EventHandler::linkTracks ( int  referenceIndex)
private

link tracks to the reference track using the hits on the track

Definition at line 532 of file EventHandler.cxx.

532  {
533  // check if author found in list
534  AuthorTrackVecMap::iterator pos = m_extendedTracks.find(referenceIndex);
535  if (pos == m_extendedTracks.end()) return;
536 
537  TrackVec& refTracks = pos->second;
538 
539  // loop over reference tracks and associate other authors
540  TrackVec::iterator rit = refTracks.begin();
541  TrackVec::iterator rit_end = refTracks.end();
542  for (; rit != rit_end; ++rit) {
543  // loop over authors
546  for (; ait != ait_end; ++ait) {
547  // skip same collection
548  if (ait->first == referenceIndex) continue;
549 
550  TrackVec& tracks = ait->second;
551 
552  match(**rit, tracks);
553  }
554  }
555  }

◆ match()

void MuonCalib::EventHandler::match ( const MuonCalibExtendedTrack reference,
EventHandler::TrackVec tracks 
)
private

find best match of tracks with reference

Definition at line 557 of file EventHandler.cxx.

557  {
558  const MuonCalibExtendedTrack* bestMatch = nullptr;
559  MuonCalibExtendedTrackOverlap bestOverlap;
560  // loop over tracks and calcualte overlap with reference
561  TrackVec::iterator it = tracks.begin();
562  TrackVec::iterator it_end = tracks.end();
563  for (; it != it_end; ++it) {
564  // check whether the two tracks are not already associated
565 
566  // if (reference.isAssociated(*it)) continue;
567 
568  MuonCalibExtendedTrackOverlap overlap = reference.calculateHitOverlap(**it);
569  if (overlap.sharedPrecisionHits() > 0) {
570  if (overlap.sharedPrecisionHits() > bestOverlap.sharedPrecisionHits()) {
571  bestMatch = it->get();
572  bestOverlap = overlap;
573  }
574  }
575  }
576 
577  std::cout << " Still need to be done a proper association " << __FILE__ << " " << __LINE__ << std::endl;
578  if (bestMatch) {
579  // reference.addAssociatedTrack(bestMatch);
580  // bestMatch->addAssociatedTrack(&reference);
581  }
582  }

◆ mooreIndices()

const EventHandler::AuthorIndices & MuonCalib::EventHandler::mooreIndices ( ) const

get author indices for Moore

Definition at line 61 of file EventHandler.cxx.

61 { return m_mooreIndices; }

◆ muonboyIndices()

const EventHandler::AuthorIndices & MuonCalib::EventHandler::muonboyIndices ( ) const

get author indices for Muonboy

Definition at line 64 of file EventHandler.cxx.

64 { return m_muonboyIndices; }

◆ segmentOverlap()

int MuonCalib::EventHandler::segmentOverlap ( const MuonCalibExtendedSegment segment1,
const MuonCalibExtendedSegment segment2 
)
private

check whether segments share the same hits

Definition at line 441 of file EventHandler.cxx.

441  {
442  int overlap = 0;
443  if (segment1.mdtHitsOnTrack() > 0 && segment2.mdtHitsOnTrack() > 0) {
444  std::set<MuonFixedId> segmentIds;
445  for (const MuonCalibSegment::MdtHitPtr& mdt_hit : segment1.mdtHOT()) {
446  const MuonFixedId& id = mdt_hit->identify();
447  if (!id.isValid()) {
448  MsgStream log(Athena::getMessageSvc(), "EventHandler");
449  log << MSG::WARNING << "segmentOverlap(), invalid MDT id! " << endmsg;
450  continue;
451  }
452  segmentIds.insert(id);
453  }
454  for (const MuonCalibSegment::MdtHitPtr& mdt_hit : segment2.mdtHOT()) {
455  const MuonFixedId& id = mdt_hit->identify();
456  if (!id.isValid()) {
457  MsgStream log(Athena::getMessageSvc(), "EventHandler");
458  log << MSG::WARNING << "segmentOverlap(), invalid MDT id! " << endmsg;
459  continue;
460  }
461  overlap += (segmentIds.count(id) > 0);
462  }
463  return overlap;
464  } else if (segment1.cscHitsOnTrack() > 0 && segment2.cscHitsOnTrack() > 0) {
465  std::set<MuonFixedId> segmentIds;
466  for (const MuonCalibSegment::CscHitPtr& csc_hit : segment1.cscHOT()) {
467  const MuonFixedId& id = csc_hit->identify();
468  if (!id.isValid()) {
469  MsgStream log(Athena::getMessageSvc(), "EventHandler");
470  log << MSG::WARNING << "segmentOverlap(), invalid CSC id! " << endmsg;
471  continue;
472  }
473  segmentIds.insert(id);
474  }
475  for (const MuonCalibSegment::CscHitPtr& csc_hit : segment1.cscHOT()) {
476  MuonFixedId id = csc_hit->identify();
477  if (!id.isValid()) {
478  MsgStream log(Athena::getMessageSvc(), "EventHandler");
479  log << MSG::WARNING << "segmentOverlap(), invalid CSC id! " << endmsg;
480  continue;
481  }
482  overlap += (segmentIds.count(id) > 0);
483  }
484  }
485  return overlap;
486  }

◆ setdbg()

void MuonCalib::EventHandler::setdbg ( const bool  dbg_on)

Definition at line 66 of file EventHandler.cxx.

66 { m_debug = dbg_on; }

◆ setEvent()

void MuonCalib::EventHandler::setEvent ( std::shared_ptr< const MuonCalibEvent_E event)

set a new event (will call clear on the previous)

Definition at line 73 of file EventHandler.cxx.

73  {
74  // reset previous event and set new event
75  clear();
76  m_event = std::move(event);
77 
78  // create extended tracks
80 
81  // create extended truth tracks
83 
84  // create extended tracks
86 
87  // create extended raw hits
89 
92  for (; mit != mit_end; ++mit) {
93  if (mit->first < 500) linkTracks(mit->first);
94 
95  // associate segments with tracks
96  if (mit->first < 99)
98  else
100  }
101  }

◆ split_along_barcode()

template<typename T >
void MuonCalib::EventHandler::split_along_barcode ( const std::vector< T > &  container,
std::map< int, std::set< T >> &  barcode_map 
)
private

Spltis the truth hit container into a map having the barcode of the particle as key.

Definition at line 237 of file EventHandler.cxx.

237  {
238  for (const auto& hit_ptr : container) {
239  int barcode = hit_ptr->barCode();
240  if (barcode <= 0) continue;
241  barcode_map[barcode].insert(hit_ptr);
242  }
243  }

◆ transform_to_trk()

std::shared_ptr< MuonCalibTrack_E > MuonCalib::EventHandler::transform_to_trk ( const TruthPtr truth_part,
const std::map< int, std::set< TruthMdtPtr >> &  mdt_hits,
const std::map< int, std::set< TruthCscPtr >> &  csc_hits,
const std::map< int, std::set< TruthRpcPtr >> &  rpc_hits,
const std::map< int, std::set< TruthTgcPtr >> &  tgc_hits 
)
private

Definition at line 334 of file EventHandler.cxx.

338  {
339  const int barcode = truth_part->barCode();
340  MuonCalibTrack_E::defineParams build_pars{};
341  build_pars.x0 = truth_part->position().x();
342  build_pars.y0 = truth_part->position().y();
343  build_pars.z0 = truth_part->position().z();
344  build_pars.phi = truth_part->momentum().phi();
345  build_pars.theta = truth_part->momentum().theta();
346  build_pars.author = std::abs(truth_part->PDGCode());
347  build_pars.qOverP = (1. - 2. * (truth_part->PDGCode() < 0)) / (truth_part->momentum().mag());
348  build_pars.cov.setZero();
349  std::shared_ptr<MuonCalibTrack_E> track_ptr = std::make_shared<MuonCalibTrack_E>(build_pars);
350 
351  std::map<int, std::set<TruthMdtPtr>>::const_iterator mdt_itr = mdt_hits.find(barcode);
352  if (mdt_itr != mdt_hits.end()) {
353  for (const TruthMdtPtr& mdt_hit : mdt_itr->second) {
354  MuonCalibHit_E::definePars hit_pars{};
355  hit_pars.driftRadius = mdt_hit->driftRadius();
356  hit_pars.pos = Amg::Vector3D(0., mdt_hit->positionAlongTube(), 0.);
357  track_ptr->addHit(std::make_shared<MuonCalibHit_E>(mdt_hit->identify(), hit_pars));
358  }
359  }
360  std::map<int, std::set<TruthCscPtr>>::const_iterator csc_itr = csc_hits.find(barcode);
361  if (csc_itr != csc_hits.end()) {
362  for (const TruthCscPtr& csc_hit : csc_itr->second) {
363  MuonCalibHit_E::definePars hit_pars{};
364  hit_pars.driftRadius = csc_hit->time();
365  track_ptr->addHit(std::make_shared<MuonCalibHit_E>(csc_hit->identify(), hit_pars));
366  }
367  }
368 
369  std::map<int, std::set<TruthRpcPtr>>::const_iterator rpc_itr = rpc_hits.find(barcode);
370  if (rpc_itr != rpc_hits.end()) {
371  for (const TruthRpcPtr& rpc_hit : rpc_itr->second) {
372  MuonCalibHit_E::definePars hit_pars{};
373  hit_pars.driftRadius = rpc_hit->time();
374  track_ptr->addHit(std::make_shared<MuonCalibHit_E>(rpc_hit->identify(), hit_pars));
375  }
376  }
377  std::map<int, std::set<TruthTgcPtr>>::const_iterator tgc_itr = tgc_hits.find(barcode);
378  if (tgc_itr != tgc_hits.end()) {
379  for (const TruthTgcPtr& tgc_hit : tgc_itr->second) {
380  MuonCalibHit_E::definePars hit_pars{};
381  hit_pars.driftRadius = tgc_hit->time();
382  track_ptr->addHit(std::make_shared<MuonCalibHit_E>(tgc_hit->identify(), hit_pars));
383  }
384  }
385  return track_ptr;
386  }

Member Data Documentation

◆ m_debug

bool MuonCalib::EventHandler::m_debug
private

Definition at line 126 of file EventHandler.h.

◆ m_event

std::shared_ptr<const MuonCalibEvent_E> MuonCalib::EventHandler::m_event
private

Definition at line 118 of file EventHandler.h.

◆ m_extendedRawHits

MuonCalibExtendedRawHits MuonCalib::EventHandler::m_extendedRawHits
private

Definition at line 121 of file EventHandler.h.

◆ m_extendedSegments

AuthorSegmentVecMap MuonCalib::EventHandler::m_extendedSegments
private

Definition at line 120 of file EventHandler.h.

◆ m_extendedTracks

AuthorTrackVecMap MuonCalib::EventHandler::m_extendedTracks
private

Definition at line 119 of file EventHandler.h.

◆ m_mooreIndices

AuthorIndices MuonCalib::EventHandler::m_mooreIndices
private

Definition at line 124 of file EventHandler.h.

◆ m_muonboyIndices

AuthorIndices MuonCalib::EventHandler::m_muonboyIndices
private

Definition at line 125 of file EventHandler.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
operator<
bool operator<(const DataVector< T > &a, const DataVector< T > &b)
Vector ordering relation.
MuonCalib::MuonCalibEvent_E::MuonCalibTrkPtr
std::shared_ptr< const MuonCalibTrack_E > MuonCalibTrkPtr
Definition: MuonCalibEvent_E.h:37
MuonCalib::EventHandler::m_mooreIndices
AuthorIndices m_mooreIndices
Definition: EventHandler.h:124
MuonCalib::EventHandler::match
void match(const MuonCalibExtendedTrack &reference, TrackVec &tracks)
find best match of tracks with reference
Definition: EventHandler.cxx:557
MuonCalib::EventHandler::createExtendedTruthTracks
void createExtendedTruthTracks()
create extended tracks for event
Definition: EventHandler.cxx:245
MuonCalib::EventHandler::SegmentVec
std::vector< ExtendedSegmentPtr > SegmentVec
Definition: EventHandler.h:44
MuonCalib::EventHandler::extendedSegments
const SegmentVec & extendedSegments(int author) const
get extended tracks
Definition: EventHandler.cxx:47
skel.it
it
Definition: skel.GENtoEVGEN.py:396
MuonCalib::EventHandler::event
const MuonCalibEvent_E & event() const
get event
Definition: EventHandler.cxx:58
MuonCalib::EventHandler::m_extendedSegments
AuthorSegmentVecMap m_extendedSegments
Definition: EventHandler.h:120
MuonCalib::EventHandler::createExtendedTracks
void createExtendedTracks()
create extended tracks for event
Definition: EventHandler.cxx:181
reference
Definition: hcg.cxx:437
isValid
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition: AtlasPID.h:620
MuonCalib::EventHandler::TruthTgcPtr
MuonCalibTruthCollection::TruthTgcPtr TruthTgcPtr
Definition: EventHandler.h:38
MuonCalib::EventHandler::createExtendedRawHits
void createExtendedRawHits()
create extend raw hits
Definition: EventHandler.cxx:167
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::EventHandler::ExtendedTrackPtr
MuonCalibExtendedRawHits::ExtendedTrkPtr ExtendedTrackPtr
Definition: EventHandler.h:32
MuonCalib::EventHandler::clear
void clear()
clear all buffers
Definition: EventHandler.cxx:68
MuonCalib::EventHandler::m_extendedTracks
AuthorTrackVecMap m_extendedTracks
Definition: EventHandler.h:119
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
MuonCalib::EventHandler::TruthCscPtr
MuonCalibTruthCollection::TruthCscPtr TruthCscPtr
Definition: EventHandler.h:39
MuonCalib::EventHandler::segmentOverlap
int segmentOverlap(const MuonCalibExtendedSegment &segment1, const MuonCalibExtendedSegment &segment2)
check whether segments share the same hits
Definition: EventHandler.cxx:441
MuonCalib::EventHandler::associateSegmentWithTrack
int associateSegmentWithTrack(const MuonCalibExtendedSegment &segment, const MuonCalibExtendedTrack &track)
check whether segment and track share the same hits
Definition: EventHandler.cxx:487
MuonCalib::EventHandler::transform_to_trk
std::shared_ptr< MuonCalibTrack_E > transform_to_trk(const TruthPtr &truth_part, const std::map< int, std::set< TruthMdtPtr >> &mdt_hits, const std::map< int, std::set< TruthCscPtr >> &csc_hits, const std::map< int, std::set< TruthRpcPtr >> &rpc_hits, const std::map< int, std::set< TruthTgcPtr >> &tgc_hits)
Definition: EventHandler.cxx:334
MuonCalib::EventHandler::linkTracks
void linkTracks(int referenceIndex)
link tracks to the reference track using the hits on the track
Definition: EventHandler.cxx:532
MuonCalib::MuonCalibSegment::CscHitPtr
std::shared_ptr< const CscCalibHitBase > CscHitPtr
typedef for a collection of CscCalibHitBase s
Definition: MuonCalibSegment.h:48
MuonCalib::EventHandler::m_muonboyIndices
AuthorIndices m_muonboyIndices
Definition: EventHandler.h:125
MuonCalib::EventHandler::dumpTracks
std::string dumpTracks() const
Definition: EventHandler.cxx:153
MuonCalib::EventHandler::m_extendedRawHits
MuonCalibExtendedRawHits m_extendedRawHits
Definition: EventHandler.h:121
MuonCalib::MuonCalibPattern::MuonCalibSegPtr
std::shared_ptr< MuonCalibSegment > MuonCalibSegPtr
typedef for a set of (pointers to) MuonCalibSegments
Definition: MuonCalibPattern.h:45
MuonCalib::EventHandler::split_along_barcode
void split_along_barcode(const std::vector< T > &container, std::map< int, std::set< T >> &barcode_map)
Spltis the truth hit container into a map having the barcode of the particle as key.
Definition: EventHandler.cxx:237
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonCalib::EventHandler::m_event
std::shared_ptr< const MuonCalibEvent_E > m_event
Definition: EventHandler.h:118
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
xAOD::score
@ score
Definition: TrackingPrimitives.h:513
MuonCalib::EventHandler::AuthorIndices::track
int track
Definition: EventHandler.h:28
MuonCalib::EventHandler::associateSegmentsWithTracks
void associateSegmentsWithTracks(SegmentVec &segments, TrackVec &tracks)
create association between tracks and segments
Definition: EventHandler.cxx:405
MuonCalib::EventHandler::TrackVec
std::vector< ExtendedTrackPtr > TrackVec
Definition: EventHandler.h:41
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
MuonCalib::EventHandler::TruthPtr
MuonCalibTruthCollection::TruthPtr TruthPtr
Definition: EventHandler.h:35
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
MuonCalib::MuonCalibExtendedRawHits::dumpMdtHits
std::string dumpMdtHits() const
Definition: MuonCalibExtendedRawHits.cxx:92
DEBUG
#define DEBUG
Definition: page_access.h:11
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonCalib::EventHandler::createExtendedSegments
void createExtendedSegments()
create extended segments for event
Definition: EventHandler.cxx:388
MuonCalib::EventHandler::AuthorIndices::segment
int segment
Definition: EventHandler.h:27
MuonCalib::EventHandler::dumpSegments
std::string dumpSegments() const
Definition: EventHandler.cxx:133
MuonCalib::EventHandler::dumpRawHits
std::string dumpRawHits() const
dump routines
Definition: EventHandler.cxx:103
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
MuonCalib::EventHandler::TruthMdtPtr
MuonCalibTruthCollection::TruthMdtPtr TruthMdtPtr
Definition: EventHandler.h:36
MuonCalib::EventHandler::TruthRpcPtr
MuonCalibTruthCollection::TruthRpcPtr TruthRpcPtr
Definition: EventHandler.h:37
MuonCalib::EventHandler::m_debug
bool m_debug
Definition: EventHandler.h:126
MuonCalib::MuonCalibEvent::PatternPtr
std::shared_ptr< MuonCalibPattern > PatternPtr
Definition: MuonCalibEvent.h:50
MuonCalib::MuonCalibSegment::MdtHitPtr
std::shared_ptr< MdtCalibHitBase > MdtHitPtr
typedef for a collection of MdtCalibHitBase s
Definition: MuonCalibSegment.h:44
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
MuonCalib::EventHandler::ExtendedSegmentPtr
MuonCalibExtendedRawHits::ExtendedSegPtr ExtendedSegmentPtr
Definition: EventHandler.h:33