CMS 3D CMS Logo

Public Member Functions | Private Attributes

TracksToTrajectories Class Reference

#include <TracksToTrajectories.h>

Inheritance diagram for TracksToTrajectories:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

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
TrackTransformerBasetheTrackTransformer

Detailed Description

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

Date:
2010/02/11 00:15:17
Revision:
1.4
Author:
R. Bellan - INFN Torino <riccardo.bellan@cern.ch>

Definition at line 20 of file TracksToTrajectories.h.


Constructor & Destructor Documentation

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.


Member Function Documentation

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");
}

Member Data Documentation

Definition at line 43 of file TracksToTrajectories.h.

Referenced by endJob(), and produce().

Definition at line 42 of file TracksToTrajectories.h.

Referenced by endJob(), and produce().

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().