CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SegmentsTrackAssociator Class Reference

#include <SegmentsTrackAssociator.h>

Public Member Functions

MuonTransientTrackingRecHit::MuonRecHitContainer associate (const edm::Event &, const edm::EventSetup &, const reco::Track &)
 Get the analysis. More...
 
 SegmentsTrackAssociator (const edm::ParameterSet &, edm::ConsumesCollector &iC)
 Constructor. More...
 
virtual ~SegmentsTrackAssociator ()
 Destructor. More...
 

Private Attributes

edm::EDGetTokenT< CSCSegmentCollectioncscSegmentsToken
 
edm::EDGetTokenT< DTRecSegment4DCollectiondtSegmentsToken
 
std::string metname
 
int numRecHit
 
int numRecHitCSC
 
int numRecHitDT
 
edm::InputTag theCSCSegmentLabel
 
edm::InputTag theDTSegmentLabel
 
edm::InputTag theSegmentContainerName
 

Detailed Description

tool which take as input a muon track and return a vector with the segments used to fit it

Author
C. Botta, G. Mila - INFN Torino

Definition at line 39 of file SegmentsTrackAssociator.h.

Constructor & Destructor Documentation

◆ SegmentsTrackAssociator()

SegmentsTrackAssociator::SegmentsTrackAssociator ( const edm::ParameterSet iConfig,
edm::ConsumesCollector iC 
)

Constructor.

Definition at line 37 of file SegmentsTrackAssociator.cc.

37  {
38  theDTSegmentLabel = iConfig.getUntrackedParameter<InputTag>("segmentsDt");
39  theCSCSegmentLabel = iConfig.getUntrackedParameter<InputTag>("segmentsCSC");
40  theSegmentContainerName = iConfig.getUntrackedParameter<InputTag>("SelectedSegments");
41 
42  numRecHit = 0;
43  numRecHitDT = 0;
44  numRecHitCSC = 0;
45  metname = "SegmentsTrackAssociator";
46 
49 }

References edm::ConsumesCollector::consumes(), edm::ParameterSet::getUntrackedParameter(), and metname.

◆ ~SegmentsTrackAssociator()

SegmentsTrackAssociator::~SegmentsTrackAssociator ( )
virtual

Destructor.

Definition at line 51 of file SegmentsTrackAssociator.cc.

51 {}

Member Function Documentation

◆ associate()

MuonTransientTrackingRecHit::MuonRecHitContainer SegmentsTrackAssociator::associate ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const reco::Track Track 
)

Get the analysis.

Definition at line 53 of file SegmentsTrackAssociator.cc.

55  {
56  // The segment collections
58  iEvent.getByToken(dtSegmentsToken, dtSegments);
60  iEvent.getByToken(cscSegmentsToken, cscSegments);
61  ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
62  iSetup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
63 
69 
70  //loop over recHit
71  for (auto const& recHit : Track.recHits()) {
72  if (!recHit->isValid())
73  continue;
74 
75  numRecHit++;
76 
77  //get the detector Id
78  DetId idRivHit = recHit->geographicalId();
79 
80  // DT recHits
81  if (idRivHit.det() == DetId::Muon && idRivHit.subdetId() == MuonSubdetId::DT) {
82  // get the RecHit Local Position
83  LocalPoint posTrackRecHit = recHit->localPosition();
84 
86  numRecHitDT++;
87 
88  // get the chamber Id
89  DTChamberId chamberId(idRivHit.rawId());
90  // get the segments of the chamber
91  range = dtSegments->get(chamberId);
92 
93  // loop over segments
94  for (segment = range.first; segment != range.second; segment++) {
95  DetId id = segment->geographicalId();
96  const GeomDet* det = theTrackingGeometry->idToDet(id);
97  vector<const TrackingRecHit*> segments2D = (&(*segment))->recHits();
98  // container for 4D segment recHits
99  vector<const TrackingRecHit*> dtRecHits;
100 
101  for (vector<const TrackingRecHit*>::const_iterator segm2D = segments2D.begin(); segm2D != segments2D.end();
102  segm2D++) {
103  vector<const TrackingRecHit*> rHits1D = (*segm2D)->recHits();
104  for (int hit = 0; hit < int(rHits1D.size()); hit++) {
105  dtRecHits.push_back(rHits1D[hit]);
106  }
107  }
108 
109  // loop over the recHit checking if there's the recHit of the track
110  for (unsigned int hit = 0; hit < dtRecHits.size(); hit++) {
111  DetId idRivHitSeg = (*dtRecHits[hit]).geographicalId();
112  LocalPoint posDTSegment = segment->localPosition();
113  LocalPoint posSegDTRecHit = (*dtRecHits[hit]).localPosition();
114 
115  double rDT = sqrt(pow((posSegDTRecHit.x() - posTrackRecHit.x()), 2) +
116  pow((posSegDTRecHit.y() - posTrackRecHit.y()), 2) +
117  pow((posSegDTRecHit.z() - posTrackRecHit.z()), 2));
118 
119  if (idRivHit == idRivHitSeg && rDT < 0.0001) {
120  if (selectedDtSegments.empty()) {
121  selectedDtSegments.push_back(MuonTransientTrackingRecHit::specificBuild(det, &*segment));
122  LogTrace(metname) << "First selected segment (from DT). Position : " << posDTSegment
123  << " Chamber : " << segment->chamberId();
124  } else {
125  int check = 0;
126  for (int segm = 0; segm < int(selectedDtSegments.size()); ++segm) {
127  double dist = sqrt(pow((((*(selectedDtSegments[segm])).localPosition()).x() - posDTSegment.x()), 2) +
128  pow((((*(selectedDtSegments[segm])).localPosition()).y() - posDTSegment.y()), 2) +
129  pow((((*(selectedDtSegments[segm])).localPosition()).z() - posDTSegment.z()), 2));
130  if (dist > 30)
131  check++;
132  }
133 
134  if (check == int(selectedDtSegments.size())) {
135  selectedDtSegments.push_back(MuonTransientTrackingRecHit::specificBuild(det, &*segment));
136  LogTrace(metname) << "New DT selected segment. Position : " << posDTSegment
137  << " Chamber : " << segment->chamberId();
138  }
139  }
140  } // check to tag the segment as "selected"
141 
142  } // loop over segment recHits
143 
144  } // loop over DT segments
145  }
146 
147  // CSC recHits
148  if (idRivHit.det() == DetId::Muon && idRivHit.subdetId() == MuonSubdetId::CSC) {
149  // get the RecHit Local Position
150  LocalPoint posTrackRecHit = recHit->localPosition();
151 
153  numRecHitCSC++;
154 
155  // get the chamber Id
156  CSCDetId tempchamberId(idRivHit.rawId());
157 
158  int ring = tempchamberId.ring();
159  int station = tempchamberId.station();
160  int endcap = tempchamberId.endcap();
161  int chamber = tempchamberId.chamber();
162  CSCDetId chamberId(endcap, station, ring, chamber, 0);
163 
164  // get the segments of the chamber
165  range = cscSegments->get(chamberId);
166  // loop over segments
167  for (segment2 = range.first; segment2 != range.second; segment2++) {
168  DetId id2 = segment2->geographicalId();
169  const GeomDet* det2 = theTrackingGeometry->idToDet(id2);
170 
171  // container for CSC segment recHits
172  vector<const TrackingRecHit*> cscRecHits = (&(*segment2))->recHits();
173 
174  // loop over the recHit checking if there's the recHit of the track
175  for (unsigned int hit = 0; hit < cscRecHits.size(); hit++) {
176  DetId idRivHitSeg = (*cscRecHits[hit]).geographicalId();
177  LocalPoint posSegCSCRecHit = (*cscRecHits[hit]).localPosition();
178  LocalPoint posCSCSegment = segment2->localPosition();
179 
180  double rCSC = sqrt(pow((posSegCSCRecHit.x() - posTrackRecHit.x()), 2) +
181  pow((posSegCSCRecHit.y() - posTrackRecHit.y()), 2) +
182  pow((posSegCSCRecHit.z() - posTrackRecHit.z()), 2));
183 
184  if (idRivHit == idRivHitSeg && rCSC < 0.0001) {
185  if (selectedCscSegments.empty()) {
186  selectedCscSegments.push_back(MuonTransientTrackingRecHit::specificBuild(det2, &*segment2));
187  LogTrace(metname) << "First selected segment (from CSC). Position: " << posCSCSegment;
188  } else {
189  int check = 0;
190  for (int n = 0; n < int(selectedCscSegments.size()); n++) {
191  double dist = sqrt(pow(((*(selectedCscSegments[n])).localPosition().x() - posCSCSegment.x()), 2) +
192  pow(((*(selectedCscSegments[n])).localPosition().y() - posCSCSegment.y()), 2) +
193  pow(((*(selectedCscSegments[n])).localPosition().z() - posCSCSegment.z()), 2));
194  if (dist > 30)
195  check++;
196  }
197  if (check == int(selectedCscSegments.size())) {
198  selectedCscSegments.push_back(MuonTransientTrackingRecHit::specificBuild(det2, &*segment2));
199  LogTrace(metname) << "New CSC segment selected. Position : " << posCSCSegment;
200  }
201  }
202 
203  } // check to tag the segment as "selected"
204 
205  } // loop over segment recHits
206 
207  } // loop over DT segments
208  }
209 
210  } // loop over track recHits
211 
212  LogTrace(metname) << "N recHit:" << numRecHit;
213  numRecHit = 0;
214  LogTrace(metname) << "N recHit DT:" << numRecHitDT;
215  numRecHitDT = 0;
216  LogTrace(metname) << "N recHit CSC:" << numRecHitCSC;
217  numRecHitCSC = 0;
218 
219  copy(selectedDtSegments.begin(), selectedDtSegments.end(), back_inserter(selectedSegments));
220  LogTrace(metname) << "N selected Dt segments:" << selectedDtSegments.size();
221  copy(selectedCscSegments.begin(), selectedCscSegments.end(), back_inserter(selectedSegments));
222  LogTrace(metname) << "N selected Csc segments:" << selectedCscSegments.size();
223  LogTrace(metname) << "N selected segments:" << selectedSegments.size();
224 
225  return selectedSegments;
226 }

References relativeConstraints::chamber, edm::check(), filterCSVwithJSON::copy, MuonSubdetId::CSC, dtChamberEfficiency_cfi::cscSegments, DetId::det(), MuonSubdetId::DT, makeMuonMisalignmentScenario::endcap, edm::EventSetup::get(), edm::get(), globals_cff::id2, GlobalTrackingGeometry::idToDet(), iEvent, createfilelist::int, LogTrace, metname, DetId::Muon, dqmiodumpmetadata::n, funct::pow(), FastTimerService_cff::range, DetId::rawId(), rpcPointValidation_cfi::recHit, FastTrackerRecHitMaskProducer_cfi::recHits, reco::Track::recHits(), relativeConstraints::ring, MuonTransientTrackingRecHit::specificBuild(), mathSSE::sqrt(), relativeConstraints::station, DetId::subdetId(), x, PV3DBase< T, PVType, FrameType >::x(), y, PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

Member Data Documentation

◆ cscSegmentsToken

edm::EDGetTokenT<CSCSegmentCollection> SegmentsTrackAssociator::cscSegmentsToken
private

Definition at line 64 of file SegmentsTrackAssociator.h.

◆ dtSegmentsToken

edm::EDGetTokenT<DTRecSegment4DCollection> SegmentsTrackAssociator::dtSegmentsToken
private

Definition at line 63 of file SegmentsTrackAssociator.h.

◆ metname

std::string SegmentsTrackAssociator::metname
private

Definition at line 66 of file SegmentsTrackAssociator.h.

◆ numRecHit

int SegmentsTrackAssociator::numRecHit
private

Definition at line 54 of file SegmentsTrackAssociator.h.

◆ numRecHitCSC

int SegmentsTrackAssociator::numRecHitCSC
private

Definition at line 56 of file SegmentsTrackAssociator.h.

◆ numRecHitDT

int SegmentsTrackAssociator::numRecHitDT
private

Definition at line 55 of file SegmentsTrackAssociator.h.

◆ theCSCSegmentLabel

edm::InputTag SegmentsTrackAssociator::theCSCSegmentLabel
private

Definition at line 60 of file SegmentsTrackAssociator.h.

◆ theDTSegmentLabel

edm::InputTag SegmentsTrackAssociator::theDTSegmentLabel
private

Definition at line 59 of file SegmentsTrackAssociator.h.

◆ theSegmentContainerName

edm::InputTag SegmentsTrackAssociator::theSegmentContainerName
private

Definition at line 61 of file SegmentsTrackAssociator.h.

SegmentsTrackAssociator::numRecHitDT
int numRecHitDT
Definition: SegmentsTrackAssociator.h:55
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
DDAxes::y
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
MuonTransientTrackingRecHit::specificBuild
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
Definition: MuonTransientTrackingRecHit.h:75
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
GeomDet
Definition: GeomDet.h:27
SegmentsTrackAssociator::numRecHit
int numRecHit
Definition: SegmentsTrackAssociator.h:54
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
relativeConstraints.station
station
Definition: relativeConstraints.py:67
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
GlobalTrackingGeometryRecord
Definition: GlobalTrackingGeometryRecord.h:17
MuonTransientTrackingRecHit::MuonRecHitContainer
std::vector< MuonRecHitPointer > MuonRecHitContainer
Definition: MuonTransientTrackingRecHit.h:26
dtChamberEfficiency_cfi.cscSegments
cscSegments
Definition: dtChamberEfficiency_cfi.py:15
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SegmentsTrackAssociator::dtSegmentsToken
edm::EDGetTokenT< DTRecSegment4DCollection > dtSegmentsToken
Definition: SegmentsTrackAssociator.h:63
DDAxes::x
CSCSegmentCollection
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
edm::Handle< DTRecSegment4DCollection >
SegmentsTrackAssociator::theDTSegmentLabel
edm::InputTag theDTSegmentLabel
Definition: SegmentsTrackAssociator.h:59
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DetId
Definition: DetId.h:17
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
edm::ESHandle< GlobalTrackingGeometry >
SegmentsTrackAssociator::numRecHitCSC
int numRecHitCSC
Definition: SegmentsTrackAssociator.h:56
SegmentsTrackAssociator::metname
std::string metname
Definition: SegmentsTrackAssociator.h:66
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
reco::Track::recHits
auto recHits() const
Access to reconstructed hits on the track.
Definition: Track.h:85
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
Point3DBase< float, LocalTag >
DTRecSegment4DCollection
SegmentsTrackAssociator::theCSCSegmentLabel
edm::InputTag theCSCSegmentLabel
Definition: SegmentsTrackAssociator.h:60
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
CSCDetId
Definition: CSCDetId.h:26
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
get
#define get
edm::RangeMap::range
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
GlobalTrackingGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GlobalTrackingGeometry.cc:44
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
SegmentsTrackAssociator::cscSegmentsToken
edm::EDGetTokenT< CSCSegmentCollection > cscSegmentsToken
Definition: SegmentsTrackAssociator.h:64
DetId::Muon
Definition: DetId.h:26
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
globals_cff.id2
id2
Definition: globals_cff.py:33
SegmentsTrackAssociator::theSegmentContainerName
edm::InputTag theSegmentContainerName
Definition: SegmentsTrackAssociator.h:61
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88