CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
TracksToTrajectories Class Reference

#include <TracksToTrajectories.h>

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

Public Member Functions

void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 Convert a reco::TrackCollection into std::vector<Trajectory> More...
 
 TracksToTrajectories (const edm::ParameterSet &)
 Constructor. More...
 
virtual ~TracksToTrajectories ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

int theNFailures
 
int theNTracks
 
edm::InputTag theTracksLabel
 
TrackTransformerBasetheTrackTransformer
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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:
2008/11/11 08:34:29
Revision:
1.3
Author
R. Bellan - INFN Torino ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.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 edm::hlt::Exception, edm::ParameterSet::getParameter(), theTracksLabel, and theTrackTransformer.

25 
26  theTracksLabel = parameterSet.getParameter<InputTag>("Tracks");
27 
28  ParameterSet trackTransformerParam = parameterSet.getParameter<ParameterSet>("TrackTransformer");
29 
30  string type = parameterSet.getParameter<string>("Type");
31 
32  if(type == "Default") theTrackTransformer = new TrackTransformer(trackTransformerParam);
33  else if(type == "GlobalCosmicMuonsForAlignment") theTrackTransformer = new TrackTransformerForGlobalCosmicMuons(trackTransformerParam);
34  else if(type == "CosmicMuonsForAlignment") theTrackTransformer = new TrackTransformerForCosmicMuons(trackTransformerParam);
35  else{
36  throw cms::Exception("TracksToTrajectories")
37  <<"The selected algorithm does not exist"
38  << "\n"
39  << "Possible choices are:"
40  << "\n"
41  << "Type = [Default, GlobalCosmicMuonsForAlignment, CosmicMuonsForAlignment]";
42  }
43 
44  produces<vector<Trajectory> >("Refitted");
45  produces<TrajTrackAssociationCollection>("Refitted");
46 }
type
Definition: HCALResponse.h:22
T getParameter(std::string const &) const
TrackTransformerBase * theTrackTransformer
TracksToTrajectories::~TracksToTrajectories ( )
virtual

Destructor.

Definition at line 50 of file TracksToTrajectories.cc.

References theTrackTransformer.

50  {
52 }
TrackTransformerBase * 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.

54  {
55  const string metname = "Reco|TrackingTools|TracksToTrajectories";
56 
57  if(theNFailures!=0)
58  LogWarning(metname) << "During the refit there were "
59  << theNFailures << " out of " << theNTracks << " tracks, i.e. failure rate is: " << double(theNFailures)/theNTracks;
60  else{
61  LogTrace(metname) << "Refit of the tracks done without any failure";
62  }
63 }
const std::string metname
#define LogTrace(id)
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().

67  {
68 
69  const string metname = "Reco|TrackingTools|TracksToTrajectories";
70 
72 
73  // Collection of Trajectory
74  auto_ptr<vector<Trajectory> > trajectoryCollection(new vector<Trajectory>);
75 
76  // Get the reference
77  RefProd<vector<Trajectory> > trajectoryCollectionRefProd
78  = event.getRefBeforePut<vector<Trajectory> >("Refitted");
79 
80  // Association map between Trajectory and Track
81  auto_ptr<TrajTrackAssociationCollection> trajTrackMap(new TrajTrackAssociationCollection);
82 
83  // Get the RecTrack collection from the event
85  event.getByLabel(theTracksLabel,tracks);
86 
87  Ref<vector<Trajectory> >::key_type trajectoryIndex = 0;
88  reco::TrackRef::key_type trackIndex = 0;
89 
90  // Loop over the Rec tracks
91  for (reco::TrackCollection::const_iterator newTrack = tracks->begin();
92  newTrack != tracks->end(); ++newTrack) {
93 
94  ++theNTracks;
95 
96  vector<Trajectory> trajectoriesSM = theTrackTransformer->transform(*newTrack);
97 
98  if(!trajectoriesSM.empty()){
99  // Load the trajectory in the Trajectory Container
100  trajectoryCollection->push_back(trajectoriesSM.front());
101 
102  // Make the association between the Trajectory and the original Track
103  trajTrackMap->insert(Ref<vector<Trajectory> >(trajectoryCollectionRefProd,trajectoryIndex++),
104  reco::TrackRef(tracks,trackIndex++));
105  }
106  else{
107  LogTrace(metname) << "Error in the Track refitting. This should not happen";
108  ++theNFailures;
109  }
110  }
111  LogTrace(metname)<<"Load the Trajectory Collection";
112  event.put(trajectoryCollection,"Refitted");
113  event.put(trajTrackMap,"Refitted");
114 }
const std::string metname
virtual void setServices(const edm::EventSetup &)=0
set the services needed by the TrackTransformers
TrackTransformerBase * theTrackTransformer
#define LogTrace(id)
tuple tracks
Definition: testEve_cfg.py:39
virtual std::vector< Trajectory > transform(const reco::Track &) const =0
Convert a reco::Track into Trajectory.
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:169

Member Data Documentation

int TracksToTrajectories::theNFailures
private

Definition at line 43 of file TracksToTrajectories.h.

Referenced by endJob(), and produce().

int TracksToTrajectories::theNTracks
private

Definition at line 42 of file TracksToTrajectories.h.

Referenced by endJob(), and produce().

edm::InputTag TracksToTrajectories::theTracksLabel
private

Definition at line 39 of file TracksToTrajectories.h.

Referenced by produce(), and TracksToTrajectories().

TrackTransformerBase* TracksToTrajectories::theTrackTransformer
private

Definition at line 40 of file TracksToTrajectories.h.

Referenced by produce(), TracksToTrajectories(), and ~TracksToTrajectories().