CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 &)
 Constructor. More...
 
virtual ~SegmentsTrackAssociator ()
 Destructor. More...
 

Private Attributes

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

Date:
2010/02/11 00:14:33
Revision:
1.2
Author
C. Botta, G. Mila - INFN Torino

Definition at line 37 of file SegmentsTrackAssociator.h.

Constructor & Destructor Documentation

SegmentsTrackAssociator::SegmentsTrackAssociator ( const edm::ParameterSet iConfig)

Constructor.

Definition at line 44 of file SegmentsTrackAssociator.cc.

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

45 {
46  theDTSegmentLabel = iConfig.getUntrackedParameter<InputTag>("segmentsDt");
47  theCSCSegmentLabel = iConfig.getUntrackedParameter<InputTag>("segmentsCSC");
48  theSegmentContainerName = iConfig.getUntrackedParameter<InputTag>("SelectedSegments");
49 
50  numRecHit=0;
51  numRecHitDT=0;
52  numRecHitCSC=0;
53  metname = "SegmentsTrackAssociator";
54 }
T getUntrackedParameter(std::string const &, T const &) const
virtual SegmentsTrackAssociator::~SegmentsTrackAssociator ( )
inlinevirtual

Destructor.

Definition at line 45 of file SegmentsTrackAssociator.h.

45 {}

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 57 of file SegmentsTrackAssociator.cc.

References edm::check(), filterCSVwithJSON::copy, MuonSubdetId::CSC, cscSegments_cfi::cscSegments, DetId::det(), MuonSubdetId::DT, Reference_intrackfit_cff::endcap, edm::EventSetup::get(), edm::Event::getByLabel(), LogTrace, metname, DetId::Muon, n, funct::pow(), DetId::rawId(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), relativeConstraints::ring, MuonTransientTrackingRecHit::specificBuild(), mathSSE::sqrt(), relativeConstraints::station, DetId::subdetId(), PV3DBase< T, PVType, FrameType >::x(), vdt::x, detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), detailsBasic3DVector::z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by SegmentTrackAnalyzer::analyze().

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

Member Data Documentation

std::string SegmentsTrackAssociator::metname
private

Definition at line 64 of file SegmentsTrackAssociator.h.

int SegmentsTrackAssociator::numRecHit
private

Definition at line 55 of file SegmentsTrackAssociator.h.

int SegmentsTrackAssociator::numRecHitCSC
private

Definition at line 57 of file SegmentsTrackAssociator.h.

int SegmentsTrackAssociator::numRecHitDT
private

Definition at line 56 of file SegmentsTrackAssociator.h.

edm::InputTag SegmentsTrackAssociator::theCSCSegmentLabel
private

Definition at line 61 of file SegmentsTrackAssociator.h.

edm::InputTag SegmentsTrackAssociator::theDTSegmentLabel
private

Definition at line 60 of file SegmentsTrackAssociator.h.

edm::InputTag SegmentsTrackAssociator::theSegmentContainerName
private

Definition at line 62 of file SegmentsTrackAssociator.h.