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
TrackHistoryAnalyzer Class Reference
Inheritance diagram for TrackHistoryAnalyzer:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 TrackHistoryAnalyzer (const edm::ParameterSet &)
 
 ~TrackHistoryAnalyzer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 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
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
 
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_
 
std::size_t totalTracks_
 
edm::InputTag trackProducer_
 

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< B > consumes (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 () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
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 ( const edm::ParameterSet config)
explicit

Definition at line 65 of file TrackHistoryAnalyzer.cc.

References edm::ParameterSet::getUntrackedParameter(), and trackProducer_.

65  : classifier_(config, consumesCollector()) {
66  trackProducer_ = config.getUntrackedParameter<edm::InputTag>("trackProducer");
67  consumes<edm::View<reco::Track>>(trackProducer_);
68 }
T getUntrackedParameter(std::string const &, T const &) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TrackHistoryAnalyzer::~TrackHistoryAnalyzer ( )
override

Definition at line 70 of file TrackHistoryAnalyzer.cc.

70 {}

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 72 of file TrackHistoryAnalyzer.cc.

References classifier_, gather_cfg::cout, TrackClassifier::evaluate(), TrackCategories::Fake, genParticleCandidates2GenParticles_cfi::genParticles, HistoryBase::genParticleTrail(), HistoryBase::genVertexTrail(), TrackClassifier::history(), TrackCategories::is(), TrackClassifier::newEvent(), particleString(), HistoryBase::simParticleTrail(), HistoryBase::simVertexTrail(), HLT_FULL_cff::trackCollection, trackProducer_, and vertexString().

72  {
73  // Track collection
75  event.getByLabel(trackProducer_, trackCollection);
76 
77  // Set the classifier for a new event
78  classifier_.newEvent(event, setup);
79 
80  // Get a constant reference to the track history associated to the classifier
81  TrackHistory const &tracer = classifier_.history();
82 
83  // Loop over the track collection.
84  for (std::size_t index = 0; index < trackCollection->size(); index++) {
85  std::cout << std::endl << "History for track #" << index << " : " << std::endl;
86 
87  // Classify the track and detect for fakes
89  // Get the list of TrackingParticles associated to
90  TrackHistory::SimParticleTrail simParticles(tracer.simParticleTrail());
91 
92  // Loop over all simParticles
93  for (std::size_t hindex = 0; hindex < simParticles.size(); hindex++) {
94  std::cout << " simParticles [" << hindex << "] : " << particleString(simParticles[hindex]->pdgId())
95  << std::endl;
96  }
97 
98  // Get the list of TrackingVertexes associated to
99  TrackHistory::SimVertexTrail simVertexes(tracer.simVertexTrail());
100 
101  // Loop over all simVertexes
102  if (!simVertexes.empty()) {
103  for (std::size_t hindex = 0; hindex < simVertexes.size(); hindex++) {
104  std::cout << " simVertex [" << hindex << "] : "
105  << vertexString(simVertexes[hindex]->sourceTracks(), simVertexes[hindex]->daughterTracks())
106  << std::endl;
107  }
108  } else
109  std::cout << " simVertex no found" << std::endl;
110 
111  // Get the list of GenParticles associated to
113 
114  // Loop over all genParticles
115  for (std::size_t hindex = 0; hindex < genParticles.size(); hindex++) {
116  std::cout << " genParticles [" << hindex << "] : " << particleString(genParticles[hindex]->pdg_id())
117  << std::endl;
118  }
119 
120  // Get the list of TrackingVertexes associated to
121  TrackHistory::GenVertexTrail genVertexes(tracer.genVertexTrail());
122 
123  // Loop over all simVertexes
124  if (!genVertexes.empty()) {
125  for (std::size_t hindex = 0; hindex < genVertexes.size(); hindex++) {
126  std::cout << " genVertex [" << hindex << "] : "
127  << vertexString(genVertexes[hindex]->particles_in_const_begin(),
128  genVertexes[hindex]->particles_in_const_end(),
129  genVertexes[hindex]->particles_out_const_begin(),
130  genVertexes[hindex]->particles_out_const_end())
131  << std::endl;
132  }
133  } else
134  std::cout << " genVertex no found" << std::endl;
135  } else
136  std::cout << " fake track" << std::endl;
137 
138  std::cout << " track categories : " << classifier_;
139  std::cout << std::endl;
140  }
141 }
std::string vertexString(const TrackingParticleRefVector &, const TrackingParticleRefVector &) const
SimVertexTrail const & simVertexTrail() const
Return all the simulated vertices in the history.
Definition: HistoryBase.h:52
std::string particleString(int) const
TrackHistory const & history() const
Returns a reference to the track history used in the classification.
std::vector< const HepMC::GenParticle * > GenParticleTrail
HepMC::GenParticle trail type.
Definition: HistoryBase.h:15
TrackClassifier const & evaluate(reco::TrackBaseRef const &)
Classify the RecoTrack in categories.
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)
bool is(Category category) const
Returns track flag for a given category.
tuple trackCollection
SimParticleTrail const & simParticleTrail() const
Return all the simulated particle in the history.
Definition: HistoryBase.h:55
tuple cout
Definition: gather_cfg.py:144
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 TrackHistoryAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 148 of file TrackHistoryAnalyzer.cc.

References totalTracks_.

148 { totalTracks_ = 0; }
void TrackHistoryAnalyzer::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
privatevirtual

Definition at line 143 of file TrackHistoryAnalyzer.cc.

References edm::EventSetup::getData(), and pdt_.

143  {
144  // Get the particles table.
145  setup.getData(pdt_);
146 }
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::ESHandle< ParticleDataTable > pdt_
std::string TrackHistoryAnalyzer::particleString ( int  pdgId) const
private

Definition at line 150 of file TrackHistoryAnalyzer.cc.

References HLT_FULL_cff::particleType, and pdt_.

Referenced by analyze().

150  {
151  ParticleData const *pid;
152 
153  std::ostringstream vDescription;
154 
155  HepPDT::ParticleID particleType(pdgId);
156 
157  if (particleType.isValid()) {
158  pid = pdt_->particle(particleType);
159  if (pid)
160  vDescription << pid->name();
161  else
162  vDescription << pdgId;
163  } else
164  vDescription << pdgId;
165 
166  return vDescription.str();
167 }
HepPDT::ParticleData ParticleData
edm::ESHandle< ParticleDataTable > pdt_
std::string TrackHistoryAnalyzer::vertexString ( const TrackingParticleRefVector in,
const TrackingParticleRefVector out 
) const
private

Definition at line 169 of file TrackHistoryAnalyzer.cc.

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

Referenced by analyze().

170  {
171  ParticleData const *pid;
172 
173  std::ostringstream vDescription;
174 
175  for (std::size_t j = 0; j < in.size(); j++) {
176  if (!j)
177  vDescription << "(";
178 
179  HepPDT::ParticleID particleType(in[j]->pdgId());
180 
181  if (particleType.isValid()) {
182  pid = pdt_->particle(particleType);
183  if (pid)
184  vDescription << pid->name();
185  else
186  vDescription << in[j]->pdgId();
187  } else
188  vDescription << in[j]->pdgId();
189 
190  if (j == in.size() - 1)
191  vDescription << ")";
192  else
193  vDescription << ",";
194  }
195 
196  vDescription << "->";
197 
198  for (std::size_t j = 0; j < out.size(); j++) {
199  if (!j)
200  vDescription << "(";
201 
202  HepPDT::ParticleID particleType(out[j]->pdgId());
203 
204  if (particleType.isValid()) {
205  pid = pdt_->particle(particleType);
206  if (pid)
207  vDescription << pid->name();
208  else
209  vDescription << out[j]->pdgId();
210  } else
211  vDescription << out[j]->pdgId();
212 
213  if (j == out.size() - 1)
214  vDescription << ")";
215  else
216  vDescription << ",";
217  }
218 
219  return vDescription.str();
220 }
HepPDT::ParticleData ParticleData
edm::ESHandle< ParticleDataTable > pdt_
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
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 222 of file TrackHistoryAnalyzer.cc.

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

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

Member Data Documentation

TrackClassifier TrackHistoryAnalyzer::classifier_
private

Definition at line 55 of file TrackHistoryAnalyzer.cc.

Referenced by analyze().

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

Definition at line 51 of file TrackHistoryAnalyzer.cc.

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

std::size_t TrackHistoryAnalyzer::totalTracks_
private

Definition at line 49 of file TrackHistoryAnalyzer.cc.

Referenced by beginJob().

edm::InputTag TrackHistoryAnalyzer::trackProducer_
private

Definition at line 47 of file TrackHistoryAnalyzer.cc.

Referenced by analyze(), and TrackHistoryAnalyzer().