CMS 3D CMS Logo

VertexHistory.cc
Go to the documentation of this file.
1 
5 
8  edm::ConsumesCollector&& collector
9 ) : HistoryBase()
10 {
11  // Name of the track collection
12  vertexProducer_ = config.getUntrackedParameter<edm::InputTag> ( "vertexProducer" );
13 
14  // Name of the traking pariticle collection
15  trackingTruth_ = config.getUntrackedParameter<edm::InputTag> ( "trackingTruth" );
16 
17  // Vertex association record
18  vertexAssociator_ = config.getUntrackedParameter<edm::InputTag> ( "vertexAssociator" );
19 
20  // Association by max. value
21  bestMatchByMaxValue_ = config.getUntrackedParameter<bool> ( "bestMatchByMaxValue" );
22 
23  // Enable RecoToSim association
24  enableRecoToSim_ = config.getUntrackedParameter<bool> ( "enableRecoToSim" );
25 
26  // Enable SimToReco association
27  enableSimToReco_ = config.getUntrackedParameter<bool> ( "enableSimToReco" );
28 
29  if(enableRecoToSim_ or enableSimToReco_) {
30  collector.consumes<edm::View<reco::Vertex>>(vertexProducer_);
31  collector.consumes<TrackingVertexCollection>(trackingTruth_);
33  }
34 
35  quality_ = 0.;
36 }
37 
38 
40  const edm::Event & event, const edm::EventSetup & setup
41 )
42 {
44  {
45  // Vertex collection
47  event.getByLabel(vertexProducer_, vertexCollection);
48 
49  // Tracking particle information
51  event.getByLabel(trackingTruth_, TVCollection);
52 
53  // Get the track associator
55  event.getByLabel(vertexAssociator_, vertexAssociator);
56 
57  if ( enableRecoToSim_ )
58  {
59  // Calculate the map between recovertex -> simvertex
60  recoToSim_ = vertexAssociator->associateRecoToSim(vertexCollection, TVCollection);
61  }
62 
63  if ( enableSimToReco_ )
64  {
65  // Calculate the map between recovertex <- simvertex
66  simToReco_ = vertexAssociator->associateSimToReco(vertexCollection, TVCollection);
67  }
68 
69  }
70 }
71 
72 
74 {
75 
76  if ( !enableRecoToSim_ ) return false;
77 
78  std::pair<TrackingVertexRef, double> result = match(tv, recoToSim_, bestMatchByMaxValue_);
79 
80  TrackingVertexRef tvr( result.first );
81  quality_ = result.second;
82 
83  if ( !tvr.isNull() )
84  {
86 
87  recovertex_ = tv;
88 
89  return true;
90  }
91 
92  return false;
93 }
94 
T getUntrackedParameter(std::string const &, T const &) const
reco::VertexRecoToSimCollection recoToSim_
Definition: VertexHistory.h:92
void newEvent(const edm::Event &, const edm::EventSetup &)
Pre-process event information (for accessing reconstruction information)
bool bestMatchByMaxValue_
Definition: VertexHistory.h:78
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
VertexHistory(const edm::ParameterSet &, edm::ConsumesCollector &&)
Constructor by pset.
Definition: VertexHistory.cc:6
Definition: config.py:1
reco::VertexSimToRecoCollection simToReco_
Definition: VertexHistory.h:94
bool evaluate(TrackingVertexRef tvr)
Evaluate track history using a TrackingParticleRef.
Definition: VertexHistory.h:42
edm::InputTag trackingTruth_
Definition: VertexHistory.h:86
edm::InputTag vertexAssociator_
Definition: VertexHistory.h:88
reco::VertexBaseRef recovertex_
Definition: VertexHistory.h:90
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
bool enableRecoToSim_
Definition: VertexHistory.h:80
bool isNull() const
Checks for null.
Definition: Ref.h:249
std::vector< TrackingVertex > TrackingVertexCollection
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
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
bool enableSimToReco_
Definition: VertexHistory.h:80
reco::VertexRecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Vertex > > &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const
compare reco to sim the handle of reco::Vertex and TrackingVertex collections
reco::VertexSimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Vertex > > &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const
compare reco to sim the handle of reco::Vertex and TrackingVertex collections
edm::InputTag vertexProducer_
Definition: VertexHistory.h:84
Definition: event.py:1