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 40 of file SegmentsTrackAssociator.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 40 of file SegmentsTrackAssociator.cc.

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

41 {
42  theDTSegmentLabel = iConfig.getUntrackedParameter<InputTag>("segmentsDt");
43  theCSCSegmentLabel = iConfig.getUntrackedParameter<InputTag>("segmentsCSC");
44  theSegmentContainerName = iConfig.getUntrackedParameter<InputTag>("SelectedSegments");
45 
46  numRecHit=0;
47  numRecHitDT=0;
48  numRecHitCSC=0;
49  metname = "SegmentsTrackAssociator";
50 
53 
54 
55 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< DTRecSegment4DCollection > dtSegmentsToken
edm::EDGetTokenT< CSCSegmentCollection > cscSegmentsToken
SegmentsTrackAssociator::~SegmentsTrackAssociator ( )
virtual

Destructor.

Definition at line 58 of file SegmentsTrackAssociator.cc.

58 {}

Member Function Documentation

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

Get the analysis.

Definition at line 61 of file SegmentsTrackAssociator.cc.

References relativeConstraints::chamber, edm::check(), popcon2dropbox::copy(), MuonSubdetId::CSC, cscSegments_cfi::cscSegments, DetId::det(), MuonSubdetId::DT, makeMuonMisalignmentScenario::endcap, edm::EventSetup::get(), edm::Event::getByToken(), globals_cff::id2, GlobalTrackingGeometry::idToDet(), createfilelist::int, LogTrace, metname, DetId::Muon, gen::n, funct::pow(), DetId::rawId(), rpcPointValidation_cfi::recHit, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), 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().

61  {
62 
63  // The segment collections
65  iEvent.getByToken(dtSegmentsToken, dtSegments);
67  iEvent.getByToken(cscSegmentsToken, cscSegments);
68  ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
69  iSetup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
70 
71 
77 
78  //loop over recHit
79  for(trackingRecHit_iterator recHit = Track.recHitsBegin(); recHit != Track.recHitsEnd(); ++recHit){
80 
81  if(!(*recHit)->isValid()) continue;
82 
83 
84  numRecHit++;
85 
86  //get the detector Id
87  DetId idRivHit = (*recHit)->geographicalId();
88 
89 
90  // DT recHits
91  if (idRivHit.det() == DetId::Muon && idRivHit.subdetId() == MuonSubdetId::DT ) {
92 
93  // get the RecHit Local Position
94  LocalPoint posTrackRecHit = (*recHit)->localPosition();
95 
97  numRecHitDT++;
98 
99  // get the chamber Id
100  DTChamberId chamberId(idRivHit.rawId());
101  // get the segments of the chamber
102  range = dtSegments->get(chamberId);
103 
104  // loop over segments
105  for (segment = range.first; segment!=range.second; segment++){
106 
107  DetId id = segment->geographicalId();
108  const GeomDet* det = theTrackingGeometry->idToDet(id);
109  vector<const TrackingRecHit*> segments2D = (&(*segment))->recHits();
110  // container for 4D segment recHits
111  vector <const TrackingRecHit*> dtRecHits;
112 
113  for(vector<const TrackingRecHit*>::const_iterator segm2D = segments2D.begin();
114  segm2D != segments2D.end();
115  segm2D++) {
116 
117  vector <const TrackingRecHit*> rHits1D = (*segm2D)->recHits();
118  for (int hit=0; hit<int(rHits1D.size()); hit++){
119  dtRecHits.push_back(rHits1D[hit]);
120  }
121 
122  }
123 
124  // loop over the recHit checking if there's the recHit of the track
125  for (unsigned int hit = 0; hit < dtRecHits.size(); hit++) {
126 
127  DetId idRivHitSeg = (*dtRecHits[hit]).geographicalId();
128  LocalPoint posDTSegment= segment->localPosition();
129  LocalPoint posSegDTRecHit = (*dtRecHits[hit]).localPosition();
130 
131  double rDT=sqrt(pow((posSegDTRecHit.x()-posTrackRecHit.x()),2) +pow((posSegDTRecHit.y()-posTrackRecHit.y()),2) + pow((posSegDTRecHit.z()-posTrackRecHit.z()),2));
132 
133  if (idRivHit == idRivHitSeg && rDT<0.0001){
134 
135  if (selectedDtSegments.empty()){
136  selectedDtSegments.push_back(MuonTransientTrackingRecHit::specificBuild(det,&*segment));
137  LogTrace(metname) <<"First selected segment (from DT). Position : "<<posDTSegment<<" Chamber : "<<segment->chamberId();
138  }
139  else{
140  int check=0;
141  for(int segm=0; segm < int(selectedDtSegments.size()); ++segm) {
142  double dist=sqrt(pow((((*(selectedDtSegments[segm])).localPosition()).x()-posDTSegment.x()),2) +pow((((*(selectedDtSegments[segm])).localPosition()).y()-posDTSegment.y()),2) + pow((((*(selectedDtSegments[segm])).localPosition()).z()-posDTSegment.z()),2));
143  if(dist>30) check++;
144  }
145 
146  if(check==int(selectedDtSegments.size())){
147  selectedDtSegments.push_back(MuonTransientTrackingRecHit::specificBuild(det,&*segment));
148  LogTrace(metname) <<"New DT selected segment. Position : "<<posDTSegment<<" Chamber : "<<segment->chamberId();
149  }
150  }
151  } // check to tag the segment as "selected"
152 
153  } // loop over segment recHits
154 
155  } // loop over DT segments
156  }
157 
158 
159  // CSC recHits
160  if (idRivHit.det() == DetId::Muon && idRivHit.subdetId() == MuonSubdetId::CSC ) {
161 
162  // get the RecHit Local Position
163  LocalPoint posTrackRecHit = (*recHit)->localPosition();
164 
166  numRecHitCSC++;
167 
168  // get the chamber Id
169  CSCDetId tempchamberId(idRivHit.rawId());
170 
171  int ring = tempchamberId.ring();
172  int station = tempchamberId.station();
173  int endcap = tempchamberId.endcap();
174  int chamber = tempchamberId.chamber();
175  CSCDetId chamberId(endcap, station, ring, chamber, 0);
176 
177  // get the segments of the chamber
178  range = cscSegments->get(chamberId);
179  // loop over segments
180  for(segment2 = range.first; segment2!=range.second; segment2++){
181 
182  DetId id2 = segment2->geographicalId();
183  const GeomDet* det2 = theTrackingGeometry->idToDet(id2);
184 
185  // container for CSC segment recHits
186  vector<const TrackingRecHit*> cscRecHits = (&(*segment2))->recHits();
187 
188  // loop over the recHit checking if there's the recHit of the track
189  for (unsigned int hit = 0; hit < cscRecHits.size(); hit++) {
190 
191  DetId idRivHitSeg = (*cscRecHits[hit]).geographicalId();
192  LocalPoint posSegCSCRecHit = (*cscRecHits[hit]).localPosition();
193  LocalPoint posCSCSegment= segment2->localPosition();
194 
195  double rCSC=sqrt(pow((posSegCSCRecHit.x()-posTrackRecHit.x()),2) +pow((posSegCSCRecHit.y()-posTrackRecHit.y()),2) + pow((posSegCSCRecHit.z()-posTrackRecHit.z()),2));
196 
197  if (idRivHit==idRivHitSeg && rCSC < 0.0001){
198 
199  if (selectedCscSegments.empty()){
200  selectedCscSegments.push_back(MuonTransientTrackingRecHit::specificBuild(det2,&*segment2));
201  LogTrace(metname) <<"First selected segment (from CSC). Position: "<<posCSCSegment;
202  }
203  else{
204  int check=0;
205  for(int n=0; n< int(selectedCscSegments.size()); n++){
206  double dist = sqrt(pow(((*(selectedCscSegments[n])).localPosition().x()-posCSCSegment.x()),2) +pow(((*(selectedCscSegments[n])).localPosition().y()-posCSCSegment.y()),2) + pow(((*(selectedCscSegments[n])).localPosition().z()-posCSCSegment.z()),2));
207  if(dist>30) check++;
208  }
209  if(check==int(selectedCscSegments.size())){
210  selectedCscSegments.push_back(MuonTransientTrackingRecHit::specificBuild(det2,&*segment2));
211  LogTrace(metname) <<"New CSC segment selected. Position : "<<posCSCSegment;
212  }
213  }
214 
215  } // check to tag the segment as "selected"
216 
217  } // loop over segment recHits
218 
219  } // loop over DT segments
220  }
221 
222  } // loop over track recHits
223 
224  LogTrace(metname) <<"N recHit:"<<numRecHit;
225  numRecHit=0;
226  LogTrace(metname) <<"N recHit DT:"<<numRecHitDT;
227  numRecHitDT=0;
228  LogTrace(metname) <<"N recHit CSC:"<<numRecHitCSC;
229  numRecHitCSC=0;
230 
231  copy(selectedDtSegments.begin(), selectedDtSegments.end(), back_inserter(selectedSegments));
232  LogTrace(metname) <<"N selected Dt segments:"<<selectedDtSegments.size();
233  copy(selectedCscSegments.begin(), selectedCscSegments.end(), back_inserter(selectedSegments));
234  LogTrace(metname) <<"N selected Csc segments:"<<selectedCscSegments.size();
235  LogTrace(metname) <<"N selected segments:"<<selectedSegments.size();
236 
237  return selectedSegments;
238 
239 }
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
edm::EDGetTokenT< DTRecSegment4DCollection > dtSegmentsToken
def copy(args, dbName)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
T y() const
Definition: PV3DBase.h:63
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
static const int CSC
Definition: MuonSubdetId.h:13
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:38
#define LogTrace(id)
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:59
const GeomDet * idToDet(DetId) const override
static const int DT
Definition: MuonSubdetId.h:12
Detector det() const
get the detector field from this detid
Definition: DetId.h:36
def check(config)
Definition: trackerTree.py:14
T x() const
Definition: PV3DBase.h:62
edm::EDGetTokenT< CSCSegmentCollection > cscSegmentsToken
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
std::vector< MuonRecHitPointer > MuonRecHitContainer
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109

Member Data Documentation

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

Definition at line 68 of file SegmentsTrackAssociator.h.

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

Definition at line 67 of file SegmentsTrackAssociator.h.

std::string SegmentsTrackAssociator::metname
private

Definition at line 71 of file SegmentsTrackAssociator.h.

int SegmentsTrackAssociator::numRecHit
private

Definition at line 58 of file SegmentsTrackAssociator.h.

int SegmentsTrackAssociator::numRecHitCSC
private

Definition at line 60 of file SegmentsTrackAssociator.h.

int SegmentsTrackAssociator::numRecHitDT
private

Definition at line 59 of file SegmentsTrackAssociator.h.

edm::InputTag SegmentsTrackAssociator::theCSCSegmentLabel
private

Definition at line 64 of file SegmentsTrackAssociator.h.

edm::InputTag SegmentsTrackAssociator::theDTSegmentLabel
private

Definition at line 63 of file SegmentsTrackAssociator.h.

edm::InputTag SegmentsTrackAssociator::theSegmentContainerName
private

Definition at line 65 of file SegmentsTrackAssociator.h.