#include <TrackingTools/TrackRefitter/plugins/TracksToTrajectories.h>
Public Member Functions | |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
Convert a reco::TrackCollection into std::vector<Trajectory>. | |
TracksToTrajectories (const edm::ParameterSet &) | |
Constructor. | |
virtual | ~TracksToTrajectories () |
Destructor. | |
Private Attributes | |
edm::InputTag | theTracksLabel |
TrackTransformer * | theTrackTransformer |
The final result is a std::vector of Trajectories (objs of the type "Trajectory"), which is loaded into the Event in a transient way
Definition at line 20 of file TracksToTrajectories.h.
TracksToTrajectories::TracksToTrajectories | ( | const edm::ParameterSet & | parameterSet | ) |
Constructor.
Definition at line 21 of file TracksToTrajectories.cc.
References edm::ParameterSet::getParameter(), theTracksLabel, and theTrackTransformer.
00021 { 00022 00023 theTracksLabel = parameterSet.getParameter<InputTag>("Tracks"); 00024 00025 theTrackTransformer = new TrackTransformer(parameterSet.getParameter<ParameterSet>("TrackTransformer")); 00026 00027 produces<vector<Trajectory> >(); 00028 produces<TrajTrackAssociationCollection>(); 00029 }
TracksToTrajectories::~TracksToTrajectories | ( | ) | [virtual] |
Destructor.
Definition at line 32 of file TracksToTrajectories.cc.
References theTrackTransformer.
00032 { 00033 if(theTrackTransformer) delete theTrackTransformer; 00034 }
void TracksToTrajectories::produce | ( | edm::Event & | event, | |
const edm::EventSetup & | setup | |||
) | [virtual] |
Convert a reco::TrackCollection into std::vector<Trajectory>.
Convert Tracks into Trajectories.
Implements edm::EDProducer.
Definition at line 37 of file TracksToTrajectories.cc.
References LogDebug, TrackTransformer::setServices(), theTracksLabel, theTrackTransformer, tracks, and TrackTransformer::transform().
00037 { 00038 00039 const string metname = "Reco|TrackingTools|TracksToTrajectories"; 00040 00041 theTrackTransformer->setServices(setup); 00042 00043 // Collection of Trajectory 00044 auto_ptr<vector<Trajectory> > trajectoryCollection(new vector<Trajectory>); 00045 00046 // Get the reference 00047 RefProd<vector<Trajectory> > trajectoryCollectionRefProd 00048 = event.getRefBeforePut<vector<Trajectory> >(); 00049 00050 // Association map between Trajectory and Track 00051 auto_ptr<TrajTrackAssociationCollection> trajTrackMap(new TrajTrackAssociationCollection); 00052 00053 // Get the RecTrack collection from the event 00054 Handle<reco::TrackCollection> tracks; 00055 event.getByLabel(theTracksLabel,tracks); 00056 00057 Ref<vector<Trajectory> >::key_type trajectoryIndex = 0; 00058 reco::TrackRef::key_type trackIndex = 0; 00059 00060 // Loop over the Rec tracks 00061 for (reco::TrackCollection::const_iterator newTrack = tracks->begin(); 00062 newTrack != tracks->end(); ++newTrack) { 00063 00064 vector<Trajectory> trajectoriesSM = theTrackTransformer->transform(*newTrack); 00065 00066 if(!trajectoriesSM.empty()){ 00067 // Load the trajectory in the Trajectory Container 00068 trajectoryCollection->push_back(trajectoriesSM.front()); 00069 00070 // Make the association between the Trajectory and the original Track 00071 trajTrackMap->insert(Ref<vector<Trajectory> >(trajectoryCollectionRefProd,trajectoryIndex++), 00072 reco::TrackRef(tracks,trackIndex++)); 00073 } 00074 else 00075 LogError(metname) << "Error in the Track refitting. This must not happen!"; 00076 } 00077 LogDebug(metname)<<"Load the Trajectory Collection"; 00078 event.put(trajectoryCollection); 00079 event.put(trajTrackMap); 00080 }
Definition at line 38 of file TracksToTrajectories.h.
Referenced by produce(), and TracksToTrajectories().
Definition at line 39 of file TracksToTrajectories.h.
Referenced by produce(), TracksToTrajectories(), and ~TracksToTrajectories().