ATLAS Offline Software
VP1TrackSummary.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class VP1TrackSummary //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: November 2009 //
12 // //
14 
16 #include "VP1Utils/VP1DetInfo.h"
18 
19 #include "TrkTrack/Track.h"
21 #include "TrkSurfaces/Surface.h"
26 #include "TrkSegment/Segment.h"
27 
28 #include <iostream>
29 //____________________________________________________________________
31  unsigned& nPixelHits,
32  unsigned& nSCTHits,
33  unsigned& nTRTHits,
34  unsigned& nhits_muon_phi,
35  unsigned& nhits_rpc,
36  unsigned& nhits_mdt,
37  unsigned& nhits_tgc,
38  unsigned& nhits_csc,
39  unsigned& nhits_mm,
40  unsigned& nhits_stgc
41  )
42 {
43  nPixelHits = nSCTHits = nTRTHits = nhits_muon_phi = nhits_rpc = nhits_mdt = nhits_tgc = nhits_csc = nhits_mm = nhits_stgc = 0;
44  if (!trk)
45  return false;
46 
47  const AtlasDetectorID * idhelper = VP1DetInfo::atlasIDHelper();
48  if (!idhelper)
49  return false;
50 
51  std::set<const Trk::TrkDetElementBase*> detelems;// Need several to handle #$$%ing cROTs. EJWM
54  for (; tsos_iter != tsos_end; ++tsos_iter) {
55  const Trk::MeasurementBase* meas = *tsos_iter ? (*tsos_iter)->measurementOnTrack() : nullptr;
56  VP1TrackSummary::addCounts(detelems, meas, idhelper, nPixelHits , nSCTHits , nTRTHits , nhits_muon_phi , nhits_rpc , nhits_mdt , nhits_tgc , nhits_csc, nhits_mm, nhits_stgc);
57  }
58  return true;
59 }
60 
61 //____________________________________________________________________
63  unsigned& nPixelHits,
64  unsigned& nSCTHits,
65  unsigned& nTRTHits,
66  unsigned& nhits_muon_phi,
67  unsigned& nhits_rpc,
68  unsigned& nhits_mdt,
69  unsigned& nhits_tgc,
70  unsigned& nhits_csc,
71  unsigned& nhits_mm,
72  unsigned& nhits_stgc
73  )
74 {
75  nPixelHits = nSCTHits = nTRTHits = nhits_muon_phi = nhits_rpc = nhits_mdt = nhits_tgc = nhits_csc = nhits_mm = nhits_stgc = 0;
76  if (!seg)
77  return false;
78 
79  const AtlasDetectorID * idhelper = VP1DetInfo::atlasIDHelper();
80  if (!idhelper)
81  return false;
82 
83  std::set<const Trk::TrkDetElementBase*> detelems;// Need several to handle #$$%ing cROTs. EJWM
84  std::vector< const Trk::MeasurementBase * >::const_iterator tsos_iter = seg->containedMeasurements().begin(), tsos_end = seg->containedMeasurements().end();
85  for (; tsos_iter != tsos_end; ++tsos_iter) {
86  const Trk::MeasurementBase* meas = *tsos_iter;
87  addCounts(detelems, meas, idhelper, nPixelHits , nSCTHits , nTRTHits , nhits_muon_phi , nhits_rpc , nhits_mdt , nhits_tgc , nhits_csc, nhits_mm, nhits_stgc);
88  }
89  return true;
90 }
91 
92 void VP1TrackSummary::addCounts( std::set<const Trk::TrkDetElementBase*>& detelems, const Trk::MeasurementBase* meas,
93  const AtlasDetectorID * idhelper,
94  unsigned& nPixelHits,
95  unsigned& nSCTHits,
96  unsigned& nTRTHits,
97  unsigned& nhits_muon_phi,
98  unsigned& nhits_rpc,
99  unsigned& nhits_mdt,
100  unsigned& nhits_tgc,
101  unsigned& nhits_csc,
102  unsigned& nhits_mm,
103  unsigned& nhits_stgc
104  )
105 {
106  const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(meas);
107 
108  if (crot){
109  unsigned int i = 0;
110  for (;i<crot->numberOfContainedROTs();++i){
111  detelems.insert(crot->rioOnTrack(i).detectorElement());
112  }
113  }else if (meas) {
114  const Trk::Surface * surf = &(meas->associatedSurface());
115  detelems.insert( surf ? surf->associatedDetectorElement() : nullptr);
116  }
117 
118  std::set<const Trk::TrkDetElementBase*>::const_iterator it = detelems.begin(), itEnd=detelems.end();
119  for (;it!=itEnd;++it){
120  const Trk::TrkDetElementBase* detelem=*it;
121  if (!detelem) continue;
122  Identifier id = detelem->identify();
123  if (!id.is_valid())
124  continue;
125  if (idhelper->is_pixel(id)) ++nPixelHits;
126  else if (idhelper->is_sct(id)) ++nSCTHits;
127  else if (idhelper->is_trt(id)) ++nTRTHits;
128  else if (idhelper->is_mdt(id)) ++nhits_mdt;
129  else if (idhelper->is_rpc(id)) ++nhits_rpc;
130  else if (idhelper->is_tgc(id)) ++nhits_tgc;
131  else if (idhelper->is_csc(id)) ++nhits_csc;
132  else if (idhelper->is_mm(id)) ++nhits_mm;
133  else if (idhelper->is_stgc(id)) ++nhits_stgc;
134  }// FIXME! Implement Muon phi hits
135  nhits_muon_phi=0;
136  detelems.clear();
137 }
AtlasDetectorID::is_pixel
bool is_pixel(Identifier id) const
Definition: AtlasDetectorID.h:760
TrkDetElementBase.h
AtlasDetectorID::is_rpc
bool is_rpc(Identifier id) const
Definition: AtlasDetectorID.h:875
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
Trk::Surface::associatedDetectorElement
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
MeasurementBase.h
AtlasDetectorID::is_csc
bool is_csc(Identifier id) const
Definition: AtlasDetectorID.h:891
CompetingRIOsOnTrack.h
Surface.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
TauGNNUtils::Variables::Track::nPixelHits
bool nPixelHits(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:542
AtlasDetectorID::is_sct
bool is_sct(Identifier id) const
Definition: AtlasDetectorID.h:770
Trk::Track::trackStateOnSurfaces
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
skel.it
it
Definition: skel.GENtoEVGEN.py:423
AtlasDetectorID::is_mm
bool is_mm(Identifier id) const
Definition: AtlasDetectorID.h:913
Trk::TrkDetElementBase
Definition: TrkDetElementBase.h:52
VP1DetInfo::atlasIDHelper
static const AtlasDetectorID * atlasIDHelper()
Definition: VP1DetInfo.cxx:157
AtlasDetectorID::is_trt
bool is_trt(Identifier id) const
Definition: AtlasDetectorID.h:782
Trk::TrkDetElementBase::identify
virtual Identifier identify() const =0
Identifier.
VP1TrackSummary::addCounts
static void addCounts(std::set< const Trk::TrkDetElementBase * > &detelems, const Trk::MeasurementBase *meas, const AtlasDetectorID *idhelper, unsigned &nPixelHits, unsigned &nSCTHits, unsigned &nTRTHits, unsigned &nhits_muon_phi, unsigned &nhits_rpc, unsigned &nhits_mdt, unsigned &nhits_tgc, unsigned &nhits_csc, unsigned &nhits_mm, unsigned &nhits_stgc)
Definition: VP1TrackSummary.cxx:92
Track.h
VP1DetInfo.h
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Trk::CompetingRIOsOnTrack::rioOnTrack
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
Trk::CompetingRIOsOnTrack::numberOfContainedROTs
virtual unsigned int numberOfContainedROTs() const =0
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
AtlasDetectorID::is_tgc
bool is_tgc(Identifier id) const
Definition: AtlasDetectorID.h:902
Segment.h
Trk::Segment::containedMeasurements
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
Definition: TrkEvent/TrkSegment/TrkSegment/Segment.h:166
Trk::Segment
Definition: TrkEvent/TrkSegment/TrkSegment/Segment.h:56
Trk::CompetingRIOsOnTrack
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
Definition: CompetingRIOsOnTrack.h:64
VP1TrackSummary.h
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::MeasurementBase::associatedSurface
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
RIO_OnTrack.h
TauGNNUtils::Variables::Track::nSCTHits
bool nSCTHits(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:549
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
AtlasDetectorID::is_stgc
bool is_stgc(Identifier id) const
Definition: AtlasDetectorID.h:924
Trk::RIO_OnTrack::detectorElement
virtual const TrkDetElementBase * detectorElement() const =0
returns the detector element, assoicated with the PRD of this class
VP1TrackSummary::countHits
static bool countHits(const Trk::Track *, unsigned &nPixelHits, unsigned &nSCTHits, unsigned &nTRTHits, unsigned &nhits_muon_phi, unsigned &nhits_rpc, unsigned &nhits_mdt, unsigned &nhits_tgc, unsigned &nhits_csc, unsigned &nhits_mm, unsigned &nhits_stgc)
Definition: VP1TrackSummary.cxx:30
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:57
TrackStateOnSurface.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
AtlasDetectorID::is_mdt
bool is_mdt(Identifier id) const
Definition: AtlasDetectorID.h:859