CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
TracksToTrajectories Class Reference
Inheritance diagram for TracksToTrajectories:
edm::stream::EDProducer< edm::GlobalCache< Count > > edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 Convert a reco::TrackCollection into std::vector<Trajectory> More...
 
 TracksToTrajectories (const edm::ParameterSet &, const Count *)
 Constructor. More...
 
 ~TracksToTrajectories () override
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< Count > >
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void globalEndJob (Count const *iCount)
 
static std::unique_ptr< CountinitializeGlobalCache (edm::ParameterSet const &)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::EDGetTokenT< reco::TrackCollectiontheTracksToken
 
std::unique_ptr< TrackTransformerBasetheTrackTransformer
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< Count > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 42 of file TracksToTrajectories.cc.

Constructor & Destructor Documentation

TracksToTrajectories::TracksToTrajectories ( const edm::ParameterSet parameterSet,
const Count  
)

Constructor.

Definition at line 72 of file TracksToTrajectories.cc.

References Exception, and edm::ParameterSet::getParameter().

72  {
73 
74  theTracksToken = consumes<reco::TrackCollection>(parameterSet.getParameter<InputTag>("Tracks"));
75 
76  ParameterSet trackTransformerParam = parameterSet.getParameter<ParameterSet>("TrackTransformer");
77 
78  string type = parameterSet.getParameter<string>("Type");
79 
80  if(type == "Default") theTrackTransformer = std::make_unique<TrackTransformer>(trackTransformerParam);
81  else if(type == "GlobalCosmicMuonsForAlignment") theTrackTransformer = std::make_unique<TrackTransformerForGlobalCosmicMuons>(trackTransformerParam);
82  else if(type == "CosmicMuonsForAlignment") theTrackTransformer = std::make_unique<TrackTransformerForCosmicMuons>(trackTransformerParam);
83  else{
84  throw cms::Exception("TracksToTrajectories")
85  <<"The selected algorithm does not exist"
86  << "\n"
87  << "Possible choices are:"
88  << "\n"
89  << "Type = [Default, GlobalCosmicMuonsForAlignment, CosmicMuonsForAlignment]";
90  }
91 
92  produces<vector<Trajectory> >("Refitted");
93  produces<TrajTrackAssociationCollection>("Refitted");
94 }
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > theTracksToken
std::unique_ptr< TrackTransformerBase > theTrackTransformer
TracksToTrajectories::~TracksToTrajectories ( )
override

Destructor.

Definition at line 98 of file TracksToTrajectories.cc.

98 {}

Member Function Documentation

void TracksToTrajectories::globalEndJob ( Count const *  iCount)
static

Definition at line 100 of file TracksToTrajectories.cc.

References constexpr, LogTrace, metname, tracksToTrajectories::Count::theNFailures, and tracksToTrajectories::Count::theNTracks.

100  {
101  constexpr char metname[] = "Reco|TrackingTools|TracksToTrajectories";
102 
103  auto theNFailures = iCount->theNFailures.load();
104  auto theNTracks = iCount->theNTracks.load();
105 
106  if(theNFailures!=0)
107  LogWarning(metname) << "During the refit there were "
108  << theNFailures << " out of " << theNTracks << " tracks, i.e. failure rate is: " << double(theNFailures)/theNTracks;
109  else{
110  LogTrace(metname) << "Refit of the tracks done without any failure";
111  }
112 }
const std::string metname
#define constexpr
#define LogTrace(id)
static std::unique_ptr<Count> TracksToTrajectories::initializeGlobalCache ( edm::ParameterSet const &  )
inlinestatic

Definition at line 51 of file TracksToTrajectories.cc.

51  {
52  return std::make_unique<Count>();
53  }
void TracksToTrajectories::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Convert a reco::TrackCollection into std::vector<Trajectory>

Convert Tracks into Trajectories.

Definition at line 116 of file TracksToTrajectories.cc.

References constexpr, DEFINE_FWK_MODULE, LogTrace, metname, eostools::move(), and l1t::tracks.

116  {
117 #ifdef EDM_ML_DEBUG
118  constexpr char metname[] = "Reco|TrackingTools|TracksToTrajectories";
119 #endif
120 
121  theTrackTransformer->setServices(setup);
122 
123  // Collection of Trajectory
124  auto trajectoryCollection = std::make_unique<vector<Trajectory>>();
125 
126  // Get the reference
127  RefProd<vector<Trajectory> > trajectoryCollectionRefProd
128  = event.getRefBeforePut<vector<Trajectory> >("Refitted");
129 
130  // Get the RecTrack collection from the event
132  event.getByToken(theTracksToken, tracks);
133 
134  // Association map between Trajectory and Track
135  auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(trajectoryCollectionRefProd, tracks);
136 
137  Ref<vector<Trajectory> >::key_type trajectoryIndex = 0;
138  reco::TrackRef::key_type trackIndex = 0;
139 
140  // Loop over the Rec tracks
141  for (auto const & newTrack : *tracks ) {
142 
143  ++(globalCache()->theNTracks);
144 
145  auto const & trajectoriesSM = theTrackTransformer->transform(newTrack);
146 
147  if(!trajectoriesSM.empty()){
148  // Load the trajectory in the Trajectory Container
149  trajectoryCollection->push_back(trajectoriesSM.front());
150 
151  // Make the association between the Trajectory and the original Track
152  trajTrackMap->insert(Ref<vector<Trajectory> >(trajectoryCollectionRefProd,trajectoryIndex++),
153  reco::TrackRef(tracks,trackIndex++));
154  }
155  else{
156  LogTrace(metname) << "Error in the Track refitting. This should not happen";
157  ++(globalCache()->theNFailures);
158  }
159  }
160  LogTrace(metname)<<"Load the Trajectory Collection";
161  event.put(move(trajectoryCollection),"Refitted");
162  event.put(move(trajTrackMap),"Refitted");
163 }
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:169
const std::string metname
edm::EDGetTokenT< reco::TrackCollection > theTracksToken
#define constexpr
std::unique_ptr< TrackTransformerBase > theTrackTransformer
#define LogTrace(id)
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

edm::EDGetTokenT<reco::TrackCollection> TracksToTrajectories::theTracksToken
private

Definition at line 63 of file TracksToTrajectories.cc.

std::unique_ptr<TrackTransformerBase> TracksToTrajectories::theTrackTransformer
private

Definition at line 64 of file TracksToTrajectories.cc.