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 > >

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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void globalEndJob (Count const *iCount)
 
static std::unique_ptr< CountinitializeGlobalCache (edm::ParameterSet const &)
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< Count > >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

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 43 of file TracksToTrajectories.cc.

Constructor & Destructor Documentation

◆ TracksToTrajectories()

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

Constructor.

Definition at line 68 of file TracksToTrajectories.cc.

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

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

◆ ~TracksToTrajectories()

TracksToTrajectories::~TracksToTrajectories ( )
override

Destructor.

Definition at line 96 of file TracksToTrajectories.cc.

96 {}

Member Function Documentation

◆ globalEndJob()

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

Definition at line 98 of file TracksToTrajectories.cc.

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

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

◆ initializeGlobalCache()

static std::unique_ptr<Count> TracksToTrajectories::initializeGlobalCache ( edm::ParameterSet const &  )
inlinestatic

Definition at line 51 of file TracksToTrajectories.cc.

51 { return std::make_unique<Count>(); }

◆ produce()

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 113 of file TracksToTrajectories.cc.

References LogTrace, metname, eostools::move(), singleTopDQM_cfi::setup, and tracks.

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

Member Data Documentation

◆ theTracksToken

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

Definition at line 60 of file TracksToTrajectories.cc.

◆ theTrackTransformer

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

Definition at line 61 of file TracksToTrajectories.cc.