#include <TracksToTrajectories.h>
Public Member Functions | |
void | endJob () |
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 | |
int | theNFailures |
int | theNTracks |
edm::InputTag | theTracksLabel |
TrackTransformerBase * | theTrackTransformer |
This class, which is a EDProducer, takes a reco::TrackCollection from the Event and refits the rechits strored in the reco::Tracks. 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 23 of file TracksToTrajectories.cc.
References Exception, edm::ParameterSet::getParameter(), theTracksLabel, and theTrackTransformer.
:theTrackTransformer(0), theNTracks(0),theNFailures(0){ theTracksLabel = parameterSet.getParameter<InputTag>("Tracks"); ParameterSet trackTransformerParam = parameterSet.getParameter<ParameterSet>("TrackTransformer"); string type = parameterSet.getParameter<string>("Type"); if(type == "Default") theTrackTransformer = new TrackTransformer(trackTransformerParam); else if(type == "GlobalCosmicMuonsForAlignment") theTrackTransformer = new TrackTransformerForGlobalCosmicMuons(trackTransformerParam); else if(type == "CosmicMuonsForAlignment") theTrackTransformer = new TrackTransformerForCosmicMuons(trackTransformerParam); else{ throw cms::Exception("TracksToTrajectories") <<"The selected algorithm does not exist" << "\n" << "Possible choices are:" << "\n" << "Type = [Default, GlobalCosmicMuonsForAlignment, CosmicMuonsForAlignment]"; } produces<vector<Trajectory> >("Refitted"); produces<TrajTrackAssociationCollection>("Refitted"); }
TracksToTrajectories::~TracksToTrajectories | ( | ) | [virtual] |
Destructor.
Definition at line 50 of file TracksToTrajectories.cc.
References theTrackTransformer.
{ if(theTrackTransformer) delete theTrackTransformer; }
void TracksToTrajectories::endJob | ( | void | ) | [virtual] |
Reimplemented from edm::EDProducer.
Definition at line 54 of file TracksToTrajectories.cc.
References LogTrace, metname, theNFailures, and theNTracks.
{ const string metname = "Reco|TrackingTools|TracksToTrajectories"; if(theNFailures!=0) LogWarning(metname) << "During the refit there were " << theNFailures << " out of " << theNTracks << " tracks, i.e. failure rate is: " << double(theNFailures)/theNTracks; else{ LogTrace(metname) << "Refit of the tracks done without any failure"; } }
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 67 of file TracksToTrajectories.cc.
References LogTrace, metname, TrackTransformerBase::setServices(), theNFailures, theNTracks, theTracksLabel, theTrackTransformer, testEve_cfg::tracks, and TrackTransformerBase::transform().
{ const string metname = "Reco|TrackingTools|TracksToTrajectories"; theTrackTransformer->setServices(setup); // Collection of Trajectory auto_ptr<vector<Trajectory> > trajectoryCollection(new vector<Trajectory>); // Get the reference RefProd<vector<Trajectory> > trajectoryCollectionRefProd = event.getRefBeforePut<vector<Trajectory> >("Refitted"); // Association map between Trajectory and Track auto_ptr<TrajTrackAssociationCollection> trajTrackMap(new TrajTrackAssociationCollection); // Get the RecTrack collection from the event Handle<reco::TrackCollection> tracks; event.getByLabel(theTracksLabel,tracks); Ref<vector<Trajectory> >::key_type trajectoryIndex = 0; reco::TrackRef::key_type trackIndex = 0; // Loop over the Rec tracks for (reco::TrackCollection::const_iterator newTrack = tracks->begin(); newTrack != tracks->end(); ++newTrack) { ++theNTracks; vector<Trajectory> trajectoriesSM = theTrackTransformer->transform(*newTrack); if(!trajectoriesSM.empty()){ // Load the trajectory in the Trajectory Container trajectoryCollection->push_back(trajectoriesSM.front()); // Make the association between the Trajectory and the original Track trajTrackMap->insert(Ref<vector<Trajectory> >(trajectoryCollectionRefProd,trajectoryIndex++), reco::TrackRef(tracks,trackIndex++)); } else{ LogTrace(metname) << "Error in the Track refitting. This should not happen"; ++theNFailures; } } LogTrace(metname)<<"Load the Trajectory Collection"; event.put(trajectoryCollection,"Refitted"); event.put(trajTrackMap,"Refitted"); }
int TracksToTrajectories::theNFailures [private] |
Definition at line 43 of file TracksToTrajectories.h.
int TracksToTrajectories::theNTracks [private] |
Definition at line 42 of file TracksToTrajectories.h.
Definition at line 39 of file TracksToTrajectories.h.
Referenced by produce(), and TracksToTrajectories().
Definition at line 40 of file TracksToTrajectories.h.
Referenced by produce(), TracksToTrajectories(), and ~TracksToTrajectories().