53 metname =
"SegmentsTrackAssociator";
64 iEvent.
getByLabel(theDTSegmentLabel, dtSegments);
66 iEvent.
getByLabel(theCSCSegmentLabel, cscSegments);
80 if(!(*recHit)->isValid())
continue;
86 DetId idRivHit = (*recHit)->geographicalId();
93 LocalPoint posTrackRecHit = (*recHit)->localPosition();
101 range = dtSegments->get(chamberId);
104 for (segment = range.first; segment!=range.second; segment++){
106 DetId id = segment->geographicalId();
107 const GeomDet* det = theTrackingGeometry->idToDet(
id);
108 vector<const TrackingRecHit*> segments2D = (&(*segment))->recHits();
110 vector <const TrackingRecHit*> dtRecHits;
112 for(vector<const TrackingRecHit*>::const_iterator segm2D = segments2D.begin();
113 segm2D != segments2D.end();
116 vector <const TrackingRecHit*> rHits1D = (*segm2D)->recHits();
117 for (
int hit=0;
hit<int(rHits1D.size());
hit++){
118 dtRecHits.push_back(rHits1D[
hit]);
124 for (
unsigned int hit = 0;
hit < dtRecHits.size();
hit++) {
126 DetId idRivHitSeg = (*dtRecHits[
hit]).geographicalId();
127 LocalPoint posDTSegment= segment->localPosition();
128 LocalPoint posSegDTRecHit = (*dtRecHits[
hit]).localPosition();
130 double rDT=
sqrt(
pow((posSegDTRecHit.
x()-posTrackRecHit.
x()),2) +
pow((posSegDTRecHit.
y()-posTrackRecHit.
y()),2) +
pow((posSegDTRecHit.
z()-posTrackRecHit.
z()),2));
132 if (idRivHit == idRivHitSeg && rDT<0.0001){
134 if (selectedDtSegments.empty()){
136 LogTrace(
metname) <<
"First selected segment (from DT). Position : "<<posDTSegment<<
" Chamber : "<<segment->chamberId();
140 for(
int segm=0; segm < int(selectedDtSegments.size()); ++segm) {
141 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));
145 if(check==
int(selectedDtSegments.size())){
147 LogTrace(
metname) <<
"New DT selected segment. Position : "<<posDTSegment<<
" Chamber : "<<segment->chamberId();
162 LocalPoint posTrackRecHit = (*recHit)->localPosition();
170 int ring = tempchamberId.ring();
171 int station = tempchamberId.station();
172 int endcap = tempchamberId.endcap();
173 int chamber = tempchamberId.chamber();
174 CSCDetId chamberId(endcap, station, ring, chamber, 0);
177 range = cscSegments->get(chamberId);
179 for(segment2 = range.first; segment2!=range.second; segment2++){
181 DetId id2 = segment2->geographicalId();
182 const GeomDet* det2 = theTrackingGeometry->idToDet(id2);
185 vector<const TrackingRecHit*> cscRecHits = (&(*segment2))->recHits();
188 for (
unsigned int hit = 0;
hit < cscRecHits.size();
hit++) {
190 DetId idRivHitSeg = (*cscRecHits[
hit]).geographicalId();
191 LocalPoint posSegCSCRecHit = (*cscRecHits[
hit]).localPosition();
192 LocalPoint posCSCSegment= segment2->localPosition();
194 double rCSC=
sqrt(
pow((posSegCSCRecHit.
x()-posTrackRecHit.
x()),2) +
pow((posSegCSCRecHit.
y()-posTrackRecHit.
y()),2) +
pow((posSegCSCRecHit.
z()-posTrackRecHit.
z()),2));
196 if (idRivHit==idRivHitSeg && rCSC < 0.0001){
198 if (selectedCscSegments.empty()){
200 LogTrace(
metname) <<
"First selected segment (from CSC). Position: "<<posCSCSegment;
204 for(
int n=0;
n< int(selectedCscSegments.size());
n++){
205 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));
208 if(check==
int(selectedCscSegments.size())){
210 LogTrace(
metname) <<
"New CSC segment selected. Position : "<<posCSCSegment;
230 copy(selectedDtSegments.begin(), selectedDtSegments.end(), back_inserter(selectedSegments));
231 LogTrace(
metname) <<
"N selected Dt segments:"<<selectedDtSegments.size();
232 copy(selectedCscSegments.begin(), selectedCscSegments.end(), back_inserter(selectedSegments));
233 LogTrace(
metname) <<
"N selected Csc segments:"<<selectedCscSegments.size();
236 return selectedSegments;
T getUntrackedParameter(std::string const &, T const &) const
std::pair< const_iterator, const_iterator > range
iterator range
const std::string metname
virtual ~SegmentsTrackAssociator()
Destructor.
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.