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::EDConsumerBase 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 ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

int theNFailures
 
int theNTracks
 
edm::InputTag theTracksLabel
 
TrackTransformerBasetheTrackTransformer
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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

Author
R. Bellan - INFN Torino ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Definition at line 18 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, theTrackTransformer, and HLT_25ns14e33_v1_cff::TrackTransformer.

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:21
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:168

Member Data Documentation

int TracksToTrajectories::theNFailures
private

Definition at line 41 of file TracksToTrajectories.h.

Referenced by endJob(), and produce().

int TracksToTrajectories::theNTracks
private

Definition at line 40 of file TracksToTrajectories.h.

Referenced by endJob(), and produce().

edm::InputTag TracksToTrajectories::theTracksLabel
private

Definition at line 37 of file TracksToTrajectories.h.

Referenced by produce(), and TracksToTrajectories().

TrackTransformerBase* TracksToTrajectories::theTrackTransformer
private

Definition at line 38 of file TracksToTrajectories.h.

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