CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
VertexHistoryAnalyzer Class Reference
Inheritance diagram for VertexHistoryAnalyzer:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 VertexHistoryAnalyzer (const edm::ParameterSet &)
 
 ~VertexHistoryAnalyzer () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
std::string particleString (int) const
 
std::string vertexString (const TrackingParticleRefVector &, const TrackingParticleRefVector &) const
 
std::string vertexString (HepMC::GenVertex::particles_in_const_iterator, HepMC::GenVertex::particles_in_const_iterator, HepMC::GenVertex::particles_out_const_iterator, HepMC::GenVertex::particles_out_const_iterator) const
 

Private Attributes

VertexClassifier classifier_
 
edm::ESHandle< ParticleDataTablepdt_
 
const edm::ESGetToken
< ParticleDataTable, PDTRecord
pdtToken_
 
const edm::EDGetTokenT
< edm::View< reco::Vertex > > 
vtxToken_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 35 of file VertexHistoryAnalyzer.cc.

Constructor & Destructor Documentation

VertexHistoryAnalyzer::VertexHistoryAnalyzer ( const edm::ParameterSet config)
explicit

Definition at line 63 of file VertexHistoryAnalyzer.cc.

64  : pdtToken_(esConsumes<edm::Transition::BeginRun>()),
66  classifier_(config, consumesCollector()) {}
T getUntrackedParameter(std::string const &, T const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const edm::ESGetToken< ParticleDataTable, PDTRecord > pdtToken_
const edm::EDGetTokenT< edm::View< reco::Vertex > > vtxToken_
VertexHistoryAnalyzer::~VertexHistoryAnalyzer ( )
overridedefault

Member Function Documentation

void VertexHistoryAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 68 of file VertexHistoryAnalyzer.cc.

References classifier_, VertexClassifier::evaluate(), VertexCategories::Fake, genParticleCandidates2GenParticles_cfi::genParticles, HistoryBase::genParticleTrail(), HistoryBase::genVertexTrail(), VertexClassifier::history(), VertexCategories::is(), VertexClassifier::newEvent(), particleString(), HistoryBase::simParticleTrail(), HistoryBase::simVertexTrail(), GoodVertex_cfg::vertexCollection, vertexString(), and vtxToken_.

68  {
69  // Set the classifier for a new event
70  classifier_.newEvent(event, setup);
71 
72  // Vertex collection
74  event.getByToken(vtxToken_, vertexCollection);
75 
76  // Get a constant reference to the track history associated to the classifier
77  VertexHistory const &tracer = classifier_.history();
78 
79  // Loop over the track collection.
80  for (std::size_t index = 0; index < vertexCollection->size(); index++) {
81  edm::LogPrint("VertexHistoryAnalyzer") << std::endl << "History for vertex #" << index << " : ";
82 
83  // Classify the track and detect for fakes
84  if (!classifier_.evaluate(reco::VertexBaseRef(vertexCollection, index)).is(VertexClassifier::Fake)) {
85  // Get the list of TrackingParticles associated to
87 
88  // Loop over all simParticles
89  for (std::size_t hindex = 0; hindex < simParticles.size(); hindex++) {
90  edm::LogPrint("VertexHistoryAnalyzer")
91  << " simParticles [" << hindex << "] : " << particleString(simParticles[hindex]->pdgId());
92  }
93 
94  // Get the list of TrackingVertexes associated to
95  VertexHistory::SimVertexTrail simVertexes(tracer.simVertexTrail());
96 
97  // Loop over all simVertexes
98  if (!simVertexes.empty()) {
99  for (std::size_t hindex = 0; hindex < simVertexes.size(); hindex++) {
100  edm::LogPrint("VertexHistoryAnalyzer")
101  << " simVertex [" << hindex
102  << "] : " << vertexString(simVertexes[hindex]->sourceTracks(), simVertexes[hindex]->daughterTracks());
103  }
104  } else
105  edm::LogPrint("VertexHistoryAnalyzer") << " simVertex no found";
106 
107  // Get the list of GenParticles associated to
109 
110  // Loop over all genParticles
111  for (std::size_t hindex = 0; hindex < genParticles.size(); hindex++) {
112  edm::LogPrint("VertexHistoryAnalyzer")
113  << " genParticles [" << hindex << "] : " << particleString(genParticles[hindex]->pdg_id());
114  }
115 
116  // Get the list of TrackingVertexes associated to
117  VertexHistory::GenVertexTrail genVertexes(tracer.genVertexTrail());
118 
119  // Loop over all simVertexes
120  if (!genVertexes.empty()) {
121  for (std::size_t hindex = 0; hindex < genVertexes.size(); hindex++) {
122  edm::LogPrint("VertexHistoryAnalyzer") << " genVertex [" << hindex << "] : "
123  << vertexString(genVertexes[hindex]->particles_in_const_begin(),
124  genVertexes[hindex]->particles_in_const_end(),
125  genVertexes[hindex]->particles_out_const_begin(),
126  genVertexes[hindex]->particles_out_const_end());
127  }
128  } else
129  edm::LogPrint("VertexHistoryAnalyzer") << " genVertex no found";
130  } else
131  edm::LogPrint("VertexHistoryAnalyzer") << " fake vertex";
132 
133  edm::LogPrint("VertexHistoryAnalyzer") << " vertex categories : " << classifier_;
134  }
135 }
This class traces the simulated and generated history of a given track.
Definition: VertexHistory.h:18
VertexHistory const & history() const
Returns a reference to the vertex history used in the classification.
std::string vertexString(const TrackingParticleRefVector &, const TrackingParticleRefVector &) const
SimVertexTrail const & simVertexTrail() const
Return all the simulated vertices in the history.
Definition: HistoryBase.h:52
tuple vertexCollection
std::vector< const HepMC::GenParticle * > GenParticleTrail
HepMC::GenParticle trail type.
Definition: HistoryBase.h:15
std::string particleString(int) const
bool is(Category category) const
Returns track flag for a given category.
std::vector< const HepMC::GenVertex * > GenVertexTrail
GenVertex trail type.
Definition: HistoryBase.h:24
Log< level::Warning, true > LogPrint
SimParticleTrail const & simParticleTrail() const
Return all the simulated particle in the history.
Definition: HistoryBase.h:55
VertexClassifier const & evaluate(reco::VertexBaseRef const &)
Classify the RecoVertex in categories.
const edm::EDGetTokenT< edm::View< reco::Vertex > > vtxToken_
virtual void newEvent(edm::Event const &, edm::EventSetup const &)
Pre-process event information (for accessing reconstraction information)
GenVertexTrail const & genVertexTrail() const
Return all generated vertex in the history.
Definition: HistoryBase.h:58
std::vector< TrackingVertexRef > SimVertexTrail
SimVertex trail type.
Definition: HistoryBase.h:33
GenParticleTrail const & genParticleTrail() const
Return all generated particle (HepMC::GenParticle) in the history.
Definition: HistoryBase.h:61
std::vector< TrackingParticleRef > SimParticleTrail
SimParticle trail type.
Definition: HistoryBase.h:30
void VertexHistoryAnalyzer::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
overrideprivate

Definition at line 137 of file VertexHistoryAnalyzer.cc.

References edm::EventSetup::getHandle(), pdt_, and pdtToken_.

137  {
138  // Get the particles table.
139  pdt_ = setup.getHandle(pdtToken_);
140 }
edm::ESHandle< ParticleDataTable > pdt_
const edm::ESGetToken< ParticleDataTable, PDTRecord > pdtToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
void VertexHistoryAnalyzer::endRun ( const edm::Run ,
const edm::EventSetup  
)
inlineoverrideprivate

Definition at line 42 of file VertexHistoryAnalyzer.cc.

42 {};
std::string VertexHistoryAnalyzer::particleString ( int  pdgId) const
private

Definition at line 142 of file VertexHistoryAnalyzer.cc.

References HLT_FULL_cff::particleType, and pdt_.

Referenced by analyze().

142  {
143  ParticleData const *pid;
144 
145  std::ostringstream vDescription;
146 
147  HepPDT::ParticleID particleType(pdgId);
148 
149  if (particleType.isValid()) {
150  pid = pdt_->particle(particleType);
151  if (pid)
152  vDescription << pid->name();
153  else
154  vDescription << pdgId;
155  } else
156  vDescription << pdgId;
157 
158  return vDescription.str();
159 }
edm::ESHandle< ParticleDataTable > pdt_
HepPDT::ParticleData ParticleData
std::string VertexHistoryAnalyzer::vertexString ( const TrackingParticleRefVector in,
const TrackingParticleRefVector out 
) const
private

Definition at line 161 of file VertexHistoryAnalyzer.cc.

References dqmiolumiharvest::j, HLT_FULL_cff::particleType, pdt_, and edm::RefVector< C, T, F >::size().

Referenced by analyze().

162  {
163  ParticleData const *pid;
164 
165  std::ostringstream vDescription;
166 
167  for (std::size_t j = 0; j < in.size(); j++) {
168  if (!j)
169  vDescription << "(";
170 
171  HepPDT::ParticleID particleType(in[j]->pdgId());
172 
173  if (particleType.isValid()) {
174  pid = pdt_->particle(particleType);
175  if (pid)
176  vDescription << pid->name();
177  else
178  vDescription << in[j]->pdgId();
179  } else
180  vDescription << in[j]->pdgId();
181 
182  if (j == in.size() - 1)
183  vDescription << ")";
184  else
185  vDescription << ",";
186  }
187 
188  vDescription << "->";
189 
190  for (std::size_t j = 0; j < out.size(); j++) {
191  if (!j)
192  vDescription << "(";
193 
194  HepPDT::ParticleID particleType(out[j]->pdgId());
195 
196  if (particleType.isValid()) {
197  pid = pdt_->particle(particleType);
198  if (pid)
199  vDescription << pid->name();
200  else
201  vDescription << out[j]->pdgId();
202  } else
203  vDescription << out[j]->pdgId();
204 
205  if (j == out.size() - 1)
206  vDescription << ")";
207  else
208  vDescription << ",";
209  }
210 
211  return vDescription.str();
212 }
edm::ESHandle< ParticleDataTable > pdt_
HepPDT::ParticleData ParticleData
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
std::string VertexHistoryAnalyzer::vertexString ( HepMC::GenVertex::particles_in_const_iterator  in_begin,
HepMC::GenVertex::particles_in_const_iterator  in_end,
HepMC::GenVertex::particles_out_const_iterator  out_begin,
HepMC::GenVertex::particles_out_const_iterator  out_end 
) const
private

Definition at line 214 of file VertexHistoryAnalyzer.cc.

References recoMuon::in, dqmiolumiharvest::j, submitPVResolutionJobs::out, HLT_FULL_cff::particleType, and pdt_.

217  {
218  ParticleData const *pid;
219 
220  std::ostringstream vDescription;
221 
222  std::size_t j = 0;
223 
224  HepMC::GenVertex::particles_in_const_iterator in, itmp;
225 
226  for (in = in_begin; in != in_end; in++, j++) {
227  if (!j)
228  vDescription << "(";
229 
230  HepPDT::ParticleID particleType((*in)->pdg_id());
231 
232  if (particleType.isValid()) {
233  pid = pdt_->particle(particleType);
234  if (pid)
235  vDescription << pid->name();
236  else
237  vDescription << (*in)->pdg_id();
238  } else
239  vDescription << (*in)->pdg_id();
240 
241  itmp = in;
242 
243  if (++itmp == in_end)
244  vDescription << ")";
245  else
246  vDescription << ",";
247  }
248 
249  vDescription << "->";
250  j = 0;
251 
252  HepMC::GenVertex::particles_out_const_iterator out, otmp;
253 
254  for (out = out_begin; out != out_end; out++, j++) {
255  if (!j)
256  vDescription << "(";
257 
258  HepPDT::ParticleID particleType((*out)->pdg_id());
259 
260  if (particleType.isValid()) {
261  pid = pdt_->particle(particleType);
262  if (pid)
263  vDescription << pid->name();
264  else
265  vDescription << (*out)->pdg_id();
266  } else
267  vDescription << (*out)->pdg_id();
268 
269  otmp = out;
270 
271  if (++otmp == out_end)
272  vDescription << ")";
273  else
274  vDescription << ",";
275  }
276 
277  return vDescription.str();
278 }
edm::ESHandle< ParticleDataTable > pdt_
HepPDT::ParticleData ParticleData

Member Data Documentation

VertexClassifier VertexHistoryAnalyzer::classifier_
private

Definition at line 49 of file VertexHistoryAnalyzer.cc.

Referenced by analyze().

edm::ESHandle<ParticleDataTable> VertexHistoryAnalyzer::pdt_
private

Definition at line 51 of file VertexHistoryAnalyzer.cc.

Referenced by beginRun(), particleString(), and vertexString().

const edm::ESGetToken<ParticleDataTable, PDTRecord> VertexHistoryAnalyzer::pdtToken_
private

Definition at line 46 of file VertexHistoryAnalyzer.cc.

Referenced by beginRun().

const edm::EDGetTokenT<edm::View<reco::Vertex> > VertexHistoryAnalyzer::vtxToken_
private

Definition at line 47 of file VertexHistoryAnalyzer.cc.

Referenced by analyze().