CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TrackHistoryAnalyzer Class Reference
Inheritance diagram for TrackHistoryAnalyzer:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 TrackHistoryAnalyzer (const edm::ParameterSet &)
 
 ~TrackHistoryAnalyzer () 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 beginJob () 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

TrackClassifier classifier_
 
edm::ESHandle< ParticleDataTablepdt_
 
const edm::ESGetToken< ParticleDataTable, PDTRecordpdtToken_
 
std::size_t totalTracks_
 
const edm::EDGetTokenT< edm::View< reco::Track > > trkToken_
 

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 TrackHistoryAnalyzer.cc.

Constructor & Destructor Documentation

◆ TrackHistoryAnalyzer()

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

Definition at line 66 of file TrackHistoryAnalyzer.cc.

67  : pdtToken_(esConsumes<edm::Transition::BeginRun>()),
68  trkToken_(consumes<edm::View<reco::Track>>(config.getUntrackedParameter<edm::InputTag>("trackProducer"))),
const edm::ESGetToken< ParticleDataTable, PDTRecord > pdtToken_
Definition: config.py:1
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const edm::EDGetTokenT< edm::View< reco::Track > > trkToken_

◆ ~TrackHistoryAnalyzer()

TrackHistoryAnalyzer::~TrackHistoryAnalyzer ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 71 of file TrackHistoryAnalyzer.cc.

References classifier_, TrackClassifier::evaluate(), TrackCategories::Fake, AJJGenJetFilter_cfi::genParticles, HistoryBase::genParticleTrail(), HistoryBase::genVertexTrail(), TrackClassifier::history(), TrackCategories::is(), TrackClassifier::newEvent(), particleString(), HiggsValidation_cfi::pdg_id, EgammaValidation_cff::pdgId, singleTopDQM_cfi::setup, HistoryBase::simParticleTrail(), HistoryBase::simVertexTrail(), JetHT_cfg::trackCollection, trkToken_, and vertexString().

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

◆ beginJob()

void TrackHistoryAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 145 of file TrackHistoryAnalyzer.cc.

References totalTracks_.

145 { totalTracks_ = 0; }

◆ beginRun()

void TrackHistoryAnalyzer::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
overrideprivate

Definition at line 140 of file TrackHistoryAnalyzer.cc.

References pdt_, pdtToken_, and singleTopDQM_cfi::setup.

140  {
141  // Get the particles table.
142  pdt_ = setup.getHandle(pdtToken_);
143 }
const edm::ESGetToken< ParticleDataTable, PDTRecord > pdtToken_
edm::ESHandle< ParticleDataTable > pdt_

◆ endRun()

void TrackHistoryAnalyzer::endRun ( const edm::Run ,
const edm::EventSetup  
)
inlineoverrideprivate

Definition at line 44 of file TrackHistoryAnalyzer.cc.

44 {};

◆ particleString()

std::string TrackHistoryAnalyzer::particleString ( int  pdgId) const
private

Definition at line 147 of file TrackHistoryAnalyzer.cc.

References LHEGenericFilter_cfi::ParticleID, PbPb_ZMuSkimMuonDPG_cff::particleType, EgammaValidation_cff::pdgId, and pdt_.

Referenced by analyze().

147  {
148  ParticleData const *pid;
149 
150  std::ostringstream vDescription;
151 
153 
154  if (particleType.isValid()) {
155  pid = pdt_->particle(particleType);
156  if (pid)
157  vDescription << pid->name();
158  else
159  vDescription << pdgId;
160  } else
161  vDescription << pdgId;
162 
163  return vDescription.str();
164 }
HepPDT::ParticleData ParticleData
edm::ESHandle< ParticleDataTable > pdt_

◆ vertexString() [1/2]

std::string TrackHistoryAnalyzer::vertexString ( const TrackingParticleRefVector in,
const TrackingParticleRefVector out 
) const
private

Definition at line 166 of file TrackHistoryAnalyzer.cc.

References recoMuon::in, dqmiolumiharvest::j, MillePedeFileConverter_cfg::out, LHEGenericFilter_cfi::ParticleID, PbPb_ZMuSkimMuonDPG_cff::particleType, EgammaValidation_cff::pdgId, and pdt_.

Referenced by analyze().

167  {
168  ParticleData const *pid;
169 
170  std::ostringstream vDescription;
171 
172  for (std::size_t j = 0; j < in.size(); j++) {
173  if (!j)
174  vDescription << "(";
175 
177 
178  if (particleType.isValid()) {
179  pid = pdt_->particle(particleType);
180  if (pid)
181  vDescription << pid->name();
182  else
183  vDescription << in[j]->pdgId();
184  } else
185  vDescription << in[j]->pdgId();
186 
187  if (j == in.size() - 1)
188  vDescription << ")";
189  else
190  vDescription << ",";
191  }
192 
193  vDescription << "->";
194 
195  for (std::size_t j = 0; j < out.size(); j++) {
196  if (!j)
197  vDescription << "(";
198 
200 
201  if (particleType.isValid()) {
202  pid = pdt_->particle(particleType);
203  if (pid)
204  vDescription << pid->name();
205  else
206  vDescription << out[j]->pdgId();
207  } else
208  vDescription << out[j]->pdgId();
209 
210  if (j == out.size() - 1)
211  vDescription << ")";
212  else
213  vDescription << ",";
214  }
215 
216  return vDescription.str();
217 }
HepPDT::ParticleData ParticleData
edm::ESHandle< ParticleDataTable > pdt_

◆ vertexString() [2/2]

std::string TrackHistoryAnalyzer::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 219 of file TrackHistoryAnalyzer.cc.

References recoMuon::in, dqmiolumiharvest::j, MillePedeFileConverter_cfg::out, LHEGenericFilter_cfi::ParticleID, PbPb_ZMuSkimMuonDPG_cff::particleType, and pdt_.

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

Member Data Documentation

◆ classifier_

TrackClassifier TrackHistoryAnalyzer::classifier_
private

Definition at line 56 of file TrackHistoryAnalyzer.cc.

Referenced by analyze().

◆ pdt_

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

Definition at line 52 of file TrackHistoryAnalyzer.cc.

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

◆ pdtToken_

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

Definition at line 44 of file TrackHistoryAnalyzer.cc.

Referenced by beginRun().

◆ totalTracks_

std::size_t TrackHistoryAnalyzer::totalTracks_
private

Definition at line 50 of file TrackHistoryAnalyzer.cc.

Referenced by beginJob().

◆ trkToken_

const edm::EDGetTokenT<edm::View<reco::Track> > TrackHistoryAnalyzer::trkToken_
private

Definition at line 48 of file TrackHistoryAnalyzer.cc.

Referenced by analyze().