CMS 3D CMS Logo

MuonMillepedeTrackRefitter.cc
Go to the documentation of this file.
1 
10 
11 // Collaborating Class Header
13 
18 
24 
27 
30 
36 
39 
43 
46 
47 
48 #include <vector>
49 #include "TH2D.h"
50 
51 
54 {
55 
56  SACollectionTag = pset.getParameter<edm::InputTag>( "SATrackCollectionTag" );
57 
58  //Products
59  produces<std::vector<Trajectory> >();
60  produces<TrajTrackAssociationCollection>();
61 
62 }
63 
64 // Destructor
66 {
67 }
68 
69 
71 {
72 
73  //Get collections from the event
74 
76  event.getByLabel( SACollectionTag, tracksSA );
77 
79  eventSetup.get<IdealMagneticFieldRecord>().get( theMGField );
80 
81  edm::ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
82  eventSetup.get<GlobalTrackingGeometryRecord>().get( theTrackingGeometry );
83 
84  edm::RefProd<std::vector<Trajectory> > trajectoryCollectionRefProd
85  = event.getRefBeforePut<std::vector<Trajectory> >();
86 
87  //Allocate collection of tracks
88  auto trajectoryCollection = std::make_unique<std::vector<Trajectory>>();
89  // Association map between Trajectory and Track
90  auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
91 
92 
93  //Create the propagator
94 
95  std::map<edm::Ref<std::vector<Trajectory> >::key_type, edm::Ref<reco::TrackCollection>::key_type> trajToTrack_map;
96 
97  edm::Ref<std::vector<Trajectory> >::key_type trajectoryIndex = 0;
98 
99  reco::TrackRef::key_type trackIndex = 0;
100 
101  for (reco::TrackCollection::const_iterator trackSA = tracksSA->begin(); trackSA != tracksSA->end(); ++trackSA ) {
102 
103  reco::TransientTrack tTrackSA( *trackSA, &*theMGField, theTrackingGeometry );
104 
105  //Create an empty trajectory
106  Trajectory myTraj;
107 
109 
110 
111  for(trackingRecHit_iterator theHit = tTrackSA.recHitsBegin(); theHit != tTrackSA.recHitsEnd(); ++theHit) {
112 
113  TrackingRecHit *myClone = (*theHit)->clone();
114  const GeomDet* myDet = theTrackingGeometry->idToDet( (*theHit)->geographicalId() );
116  myTraj.push(myMeas);
117 
118  }
119 
120  trajectoryCollection->push_back(myTraj);
121  trajToTrack_map[trajectoryIndex] = trackIndex;
122  ++trajectoryIndex;
123  ++trackIndex;
124  }
125 
126  edm::OrphanHandle<std::vector<Trajectory> > trajsRef = event.put(std::move(trajectoryCollection));
127 
128  for( trajectoryIndex = 0; trajectoryIndex < tracksSA->size(); ++trajectoryIndex)
129  {
130  edm::Ref<reco::TrackCollection>::key_type trackCounter = trajToTrack_map[trajectoryIndex];
131  trajTrackMap->insert(edm::Ref<std::vector<Trajectory> >(trajsRef, trajectoryIndex), edm::Ref<reco::TrackCollection>(tracksSA, trackCounter));
132  }
133 
134  event.put(std::move(trajTrackMap));
135 
136 }
137 
138 
139 
141 
142 
143 
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void produce(edm::Event &event, const edm::EventSetup &eventSetup)
TrajectoryStateOnSurface innermostMeasurementState() const
virtual const GeomDet * idToDet(DetId) const
virtual ~MuonMillepedeTrackRefitter()
Destructor.
virtual TrackingRecHit * clone() const =0
trackingRecHit_iterator recHitsEnd() const
last iterator to RecHits
const T & get() const
Definition: EventSetup.h:56
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
void push(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:50
trackingRecHit_iterator recHitsBegin() const
first iterator to RecHits
def move(src, dest)
Definition: eostools.py:510
MuonMillepedeTrackRefitter(const edm::ParameterSet &pset)
Constructor.
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:168
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
Definition: event.py:1