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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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

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

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

67  {
68  theTracksToken = consumes<reco::TrackCollection>(parameterSet.getParameter<InputTag>("Tracks"));
69 
70  ParameterSet trackTransformerParam = parameterSet.getParameter<ParameterSet>("TrackTransformer");
71 
72  string type = parameterSet.getParameter<string>("Type");
73 
74  if (type == "Default")
75  theTrackTransformer = std::make_unique<TrackTransformer>(trackTransformerParam);
76  else if (type == "GlobalCosmicMuonsForAlignment")
77  theTrackTransformer = std::make_unique<TrackTransformerForGlobalCosmicMuons>(trackTransformerParam);
78  else if (type == "CosmicMuonsForAlignment")
79  theTrackTransformer = std::make_unique<TrackTransformerForCosmicMuons>(trackTransformerParam);
80  else {
81  throw cms::Exception("TracksToTrajectories")
82  << "The selected algorithm does not exist"
83  << "\n"
84  << "Possible choices are:"
85  << "\n"
86  << "Type = [Default, GlobalCosmicMuonsForAlignment, CosmicMuonsForAlignment]";
87  }
88 
89  produces<vector<Trajectory>>("Refitted");
90  produces<TrajTrackAssociationCollection>("Refitted");
91 }
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 94 of file TracksToTrajectories.cc.

94 {}

Member Function Documentation

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

Definition at line 96 of file TracksToTrajectories.cc.

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

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

Definition at line 50 of file TracksToTrajectories.cc.

50 { return std::make_unique<Count>(); }
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 111 of file TracksToTrajectories.cc.

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

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

Member Data Documentation

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

Definition at line 59 of file TracksToTrajectories.cc.

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

Definition at line 60 of file TracksToTrajectories.cc.