CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RoadSearchHelixMakerAlgorithm.cc
Go to the documentation of this file.
1 //
2 // Package: RecoTracker/RoadSearchHelixMaker
3 // Class: RoadSearchHelixMakerAlgorithm
4 //
5 // Description:
6 //
7 // Original Author: Steve Wagner, stevew@pizero.colorado.edu
8 // Created: Sat Feb 19 22:00:00 UTC 2006
9 //
10 // $Author: gpetrucc $
11 // $Date: 2010/12/14 15:50:20 $
12 // $Revision: 1.11 $
13 //
14 
15 #include <vector>
16 #include <iostream>
17 #include <cmath>
18 
20 
25 
28 
35 
38 
42 
43 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHel.hh"
44 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxFittedHel.hh"
45 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHit.hh"
46 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxTrackCandidatesToTracks.hh"
47 
49 
54 
56 }
57 
59 }
60 
62  const edm::EventSetup& es,
64 {
65 
66  edm::LogInfo("RoadSearch") << "Input of " << input->size() << " track candidate(s).";
67 
68  //
69  // no track candidates - nothing to try fitting
70  //
71  if ( input->empty() ){
72  edm::LogInfo("RoadSearch") << "Created " << output.size() << " tracks.";
73  return;
74  }
75 
76  //
77  // got > 0 track candidate - try fitting
78  //
79 
80  // get tracker geometry
82  es.get<TrackerDigiGeometryRecord>().get(tracker);
83 
84  // magnetic field
86  es.get<IdealMagneticFieldRecord>().get(fieldHandle);
87  const MagneticField *field = fieldHandle.product();
88 
89  unsigned int trackcandidate_ctr=0;
90 
91  // loop over clouds
92  for ( TrackCandidateCollection::const_iterator trackcandidate = input->begin(); trackcandidate != input->end(); ++trackcandidate ) {
93  TrackCandidate currentCandidate = *trackcandidate;
94  ++trackcandidate_ctr;
95  unsigned int trackcandidate_number_rechits = 0;
96  TrackCandidate::range recHitRange = currentCandidate.recHits();
97  for ( TrackCandidate::const_iterator recHit = recHitRange.first; recHit != recHitRange.second; ++recHit ) {
98  ++trackcandidate_number_rechits;
99  }
100 
101  LogDebug("RoadSearch") << "Track candidate number, number of TrackingRecHits = " << trackcandidate_ctr << " "
102  << trackcandidate_number_rechits;
103 
104  //
105  // helix fitting here
106  //
107  edm::LogInfo("RoadSearch") << "Beware - Use Simple Helix Fitted Tracks only for Debugging Purposes!!" ;
108 
109  std::vector<DcxHit*> listohits;
110 
111  for ( TrackCandidate::const_iterator recHit = recHitRange.first; recHit != recHitRange.second; ++recHit ) {
112  DetId recHitId = recHit->geographicalId();
113  const GeomDet *recHitGeomDet = tracker->idToDet(recHitId);
114  GlobalPoint hit_global_pos = recHitGeomDet->surface().toGlobal(recHit->localPosition());
115  // only for TIB and TOB (for now ... )
116  if ( (unsigned int)recHitId.subdetId() == StripSubdetector::TIB ||
117  (unsigned int)recHitId.subdetId() == StripSubdetector::TOB ) {
118  const GeomDetUnit *recHitGeomDetUnit;
119  // take rphi sensor in case of matched rechit to determine topology
120  const GluedGeomDet *recHitGluedGeomDet = dynamic_cast<const GluedGeomDet*>(recHitGeomDet);
121  if ( recHitGluedGeomDet != 0 ) {
122  recHitGeomDetUnit = recHitGluedGeomDet->monoDet();
123  } else {
124  recHitGeomDetUnit = tracker->idToDetUnit(recHitId);
125  }
126  const StripTopology *recHitTopology = dynamic_cast<const StripTopology*>(&(recHitGeomDetUnit->topology()));
127  double iLength = recHitTopology->stripLength();
128  LocalPoint temp_lpos = recHit->localPosition();
129  LocalPoint temp_lpos_f(temp_lpos.x(),temp_lpos.y()+iLength/2.0,temp_lpos.z());
130  LocalPoint temp_lpos_b(temp_lpos.x(),temp_lpos.y()-iLength/2.0,temp_lpos.z());
131  GlobalPoint temp_gpos_f = recHitGeomDet->surface().toGlobal(temp_lpos_f);
132  GlobalPoint temp_gpos_b = recHitGeomDet->surface().toGlobal(temp_lpos_b);
133  GlobalVector fir_uvec((temp_gpos_f.x()-temp_gpos_b.x())/iLength,
134  (temp_gpos_f.y()-temp_gpos_b.y())/iLength,(temp_gpos_f.z()-temp_gpos_b.z())/iLength);
135  DcxHit* try_me = new DcxHit(hit_global_pos.x(), hit_global_pos.y(), hit_global_pos.z(),
136  fir_uvec.x(), fir_uvec.y(), fir_uvec.z());
137  listohits.push_back(try_me);
138  }
139  }
140  DcxTrackCandidatesToTracks make_tracks(listohits,output, field);
141  }//iterate over all track candidates
142 
143  edm::LogInfo("RoadSearch") << "Created " << output.size() << " tracks.";
144 
145 }
ESHandle< MagneticField > fieldHandle
#define LogDebug(id)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
range recHits() const
std::vector< TrackCandidate > TrackCandidateCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
T y() const
Definition: PV3DBase.h:62
std::pair< const_iterator, const_iterator > range
virtual const Topology & topology() const =0
virtual float stripLength() const =0
T z() const
Definition: PV3DBase.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
tuple conf
Definition: dbtoconf.py:185
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void run(const TrackCandidateCollection *input, const edm::EventSetup &es, reco::TrackCollection &output)
Runs the algorithm.
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
RoadSearchHelixMakerAlgorithm(const edm::ParameterSet &conf)
RecHitContainer::const_iterator const_iterator
T x() const
Definition: PV3DBase.h:61