53 metname =
"SegmentsTrackAssociator";
61 iEvent.
getByLabel(theDTSegmentLabel, dtSegments);
63 iEvent.
getByLabel(theCSCSegmentLabel, cscSegments);
77 if(!(*recHit)->isValid())
continue;
83 DetId idRivHit = (*recHit)->geographicalId();
90 LocalPoint posTrackRecHit = (*recHit)->localPosition();
98 range = dtSegments->get(chamberId);
101 for (segment = range.first; segment!=range.second; segment++){
103 DetId id = segment->geographicalId();
104 const GeomDet* det = theTrackingGeometry->idToDet(
id);
105 vector<const TrackingRecHit*> segments2D = (&(*segment))->recHits();
107 vector <const TrackingRecHit*> dtRecHits;
109 for(vector<const TrackingRecHit*>::const_iterator segm2D = segments2D.begin();
110 segm2D != segments2D.end();
113 vector <const TrackingRecHit*> rHits1D = (*segm2D)->recHits();
114 for (
int hit=0;
hit<int(rHits1D.size());
hit++){
115 dtRecHits.push_back(rHits1D[
hit]);
121 for (
unsigned int hit = 0;
hit < dtRecHits.size();
hit++) {
123 DetId idRivHitSeg = (*dtRecHits[
hit]).geographicalId();
124 LocalPoint posDTSegment= segment->localPosition();
125 LocalPoint posSegDTRecHit = (*dtRecHits[
hit]).localPosition();
127 double rDT=
sqrt(
pow((posSegDTRecHit.
x()-posTrackRecHit.
x()),2) +
pow((posSegDTRecHit.
y()-posTrackRecHit.
y()),2) +
pow((posSegDTRecHit.
z()-posTrackRecHit.
z()),2));
129 if (idRivHit == idRivHitSeg && rDT<0.0001){
131 if (selectedDtSegments.empty()){
133 LogTrace(
metname) <<
"First selected segment (from DT). Position : "<<posDTSegment<<
" Chamber : "<<segment->chamberId();
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));
142 if(check==
int(selectedDtSegments.size())){
144 LogTrace(
metname) <<
"New DT selected segment. Position : "<<posDTSegment<<
" Chamber : "<<segment->chamberId();
159 LocalPoint posTrackRecHit = (*recHit)->localPosition();
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);
174 range = cscSegments->get(chamberId);
176 for(segment2 = range.first; segment2!=range.second; segment2++){
178 DetId id2 = segment2->geographicalId();
179 const GeomDet* det2 = theTrackingGeometry->idToDet(id2);
182 vector<const TrackingRecHit*> cscRecHits = (&(*segment2))->recHits();
185 for (
unsigned int hit = 0;
hit < cscRecHits.size();
hit++) {
187 DetId idRivHitSeg = (*cscRecHits[
hit]).geographicalId();
188 LocalPoint posSegCSCRecHit = (*cscRecHits[
hit]).localPosition();
189 LocalPoint posCSCSegment= segment2->localPosition();
191 double rCSC=
sqrt(
pow((posSegCSCRecHit.
x()-posTrackRecHit.
x()),2) +
pow((posSegCSCRecHit.
y()-posTrackRecHit.
y()),2) +
pow((posSegCSCRecHit.
z()-posTrackRecHit.
z()),2));
193 if (idRivHit==idRivHitSeg && rCSC < 0.0001){
195 if (selectedCscSegments.empty()){
197 LogTrace(
metname) <<
"First selected segment (from CSC). Position: "<<posCSCSegment;
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));
205 if(check==
int(selectedCscSegments.size())){
207 LogTrace(
metname) <<
"New CSC segment selected. Position : "<<posCSCSegment;
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();
233 return selectedSegments;
T getUntrackedParameter(std::string const &, T const &) const
std::pair< const_iterator, const_iterator > range
iterator range
const std::string metname
uint32_t rawId() const
get the raw id
C::const_iterator const_iterator
constant access iterator type
MuonTransientTrackingRecHit::MuonRecHitContainer associate(const edm::Event &, const edm::EventSetup &, const reco::Track &)
Get the analysis.
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
static void check(Principal const &p, std::string const &id)
Detector det() const
get the detector field from this detid
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
std::vector< MuonRecHitPointer > MuonRecHitContainer
Power< A, B >::type pow(const A &a, const B &b)
SegmentsTrackAssociator(const edm::ParameterSet &)
Constructor.
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.