CMS 3D CMS Logo

TrackHistory.cc
Go to the documentation of this file.
1 
4 
5 
8  edm::ConsumesCollector&& collector
9 ) : HistoryBase()
10 {
11  // Name of the track collection
12  trackProducer_ = config.getUntrackedParameter<edm::InputTag> ( "trackProducer" );
13  collector.consumes<edm::View<reco::Track> >(trackProducer_);
14 
15  // Name of the traking pariticle collection
16  trackingTruth_ = config.getUntrackedParameter<edm::InputTag> ( "trackingTruth" );
17  collector.consumes<TrackingParticleCollection>(trackingTruth_);
18 
19  // Track association record
20  trackAssociator_ = config.getUntrackedParameter<edm::InputTag> ( "trackAssociator" );
21 
22  // Association by max. value
23  bestMatchByMaxValue_ = config.getUntrackedParameter<bool> ( "bestMatchByMaxValue" );
24 
25  // Enable RecoToSim association
26  enableRecoToSim_ = config.getUntrackedParameter<bool> ( "enableRecoToSim" );
27 
28  // Enable SimToReco association
29  enableSimToReco_ = config.getUntrackedParameter<bool> ( "enableSimToReco" );
30 
31  if(enableRecoToSim_ or enableSimToReco_) {
33  }
34 
35  quality_ = 0.;
36 }
37 
38 
40  const edm::Event & event, const edm::EventSetup & setup
41 )
42 {
44  {
45  // Track collection
47  event.getByLabel(trackProducer_, trackCollection);
48 
49  // Tracking particle information
51  event.getByLabel(trackingTruth_, TPCollection);
52 
53  // Get the track associator
55  event.getByLabel(trackAssociator_, associator);
56 
57  // Calculate the map between recotracks -> tp
58  if ( enableRecoToSim_ ) recoToSim_ = associator->associateRecoToSim(trackCollection, TPCollection);
59 
60  // Calculate the map between recotracks <- tp
61  if ( enableSimToReco_ ) simToReco_ = associator->associateSimToReco(trackCollection, TPCollection );
62  }
63 }
64 
65 
67 {
68  if ( !enableRecoToSim_ ) return false;
69 
70  std::pair<TrackingParticleRef, double> result = match(tr, recoToSim_, bestMatchByMaxValue_);
71 
72  TrackingParticleRef tpr( result.first );
73  quality_ = result.second;
74  trackingParticle_ = tpr;
75 
76  if ( !tpr.isNull() )
77  {
79 
80  recotrack_ = tr;
81 
82  return true;
83  }
84 
85  return false;
86 }
87 
88 
T getUntrackedParameter(std::string const &, T const &) const
void newEvent(const edm::Event &, const edm::EventSetup &)
Pre-process event information (for accessing reconstruction information)
Definition: TrackHistory.cc:39
std::vector< TrackingParticle > TrackingParticleCollection
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
Definition: config.py:1
bool enableSimToReco_
Definition: TrackHistory.h:88
reco::SimToRecoCollection simToReco_
Definition: TrackHistory.h:104
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::InputTag trackProducer_
Definition: TrackHistory.h:92
reco::RecoToSimCollection recoToSim_
Definition: TrackHistory.h:102
TrackingParticleRef trackingParticle_
Definition: TrackHistory.h:100
bool isNull() const
Checks for null.
Definition: Ref.h:250
bool enableRecoToSim_
Definition: TrackHistory.h:88
edm::InputTag trackAssociator_
Definition: TrackHistory.h:96
TrackHistory(const edm::ParameterSet &, edm::ConsumesCollector &&)
Constructor by pset.
Definition: TrackHistory.cc:6
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
double quality_
Definition: TrackHistory.h:90
Base class to all the history types.
Definition: HistoryBase.h:12
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: HistoryBase.h:122
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: TrackHistory.h:41
bool bestMatchByMaxValue_
Definition: TrackHistory.h:86
edm::InputTag trackingTruth_
Definition: TrackHistory.h:94
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track > > &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
Definition: event.py:1
reco::TrackBaseRef recotrack_
Definition: TrackHistory.h:98