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::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 TrackHistoryAnalyzer (const edm::ParameterSet &)
 
 ~TrackHistoryAnalyzer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 35 of file TrackHistoryAnalyzer.cc.

Constructor & Destructor Documentation

◆ TrackHistoryAnalyzer()

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

Definition at line 65 of file TrackHistoryAnalyzer.cc.

66  trackProducer_ = config.getUntrackedParameter<edm::InputTag>("trackProducer");
67  consumes<edm::View<reco::Track>>(trackProducer_);
68 }

References trackProducer_.

◆ ~TrackHistoryAnalyzer()

TrackHistoryAnalyzer::~TrackHistoryAnalyzer ( )
override

Definition at line 70 of file TrackHistoryAnalyzer.cc.

70 {}

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 72 of file TrackHistoryAnalyzer.cc.

72  {
73  // Track collection
75  event.getByLabel(trackProducer_, trackCollection);
76 
77  // Set the classifier for a new event
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 }

References classifier_, gather_cfg::cout, TrackClassifier::evaluate(), TrackCategories::Fake, genParticles2HepMC_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(), duplicaterechits_cfi::trackCollection, trackProducer_, and vertexString().

◆ beginJob()

void TrackHistoryAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 148 of file TrackHistoryAnalyzer.cc.

148 { totalTracks_ = 0; }

References totalTracks_.

◆ beginRun()

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

Definition at line 143 of file TrackHistoryAnalyzer.cc.

143  {
144  // Get the particles table.
145  setup.getData(pdt_);
146 }

References pdt_, and singleTopDQM_cfi::setup.

◆ particleString()

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

Definition at line 150 of file TrackHistoryAnalyzer.cc.

150  {
151  ParticleData const *pid;
152 
153  std::ostringstream vDescription;
154 
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 }

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

Referenced by analyze().

◆ vertexString() [1/2]

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

Definition at line 169 of file TrackHistoryAnalyzer.cc.

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 
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 
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 }

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

Referenced by analyze().

◆ 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 222 of file TrackHistoryAnalyzer.cc.

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 }

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

Member Data Documentation

◆ classifier_

TrackClassifier TrackHistoryAnalyzer::classifier_
private

Definition at line 55 of file TrackHistoryAnalyzer.cc.

Referenced by analyze().

◆ pdt_

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

Definition at line 51 of file TrackHistoryAnalyzer.cc.

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

◆ totalTracks_

std::size_t TrackHistoryAnalyzer::totalTracks_
private

Definition at line 49 of file TrackHistoryAnalyzer.cc.

Referenced by beginJob().

◆ trackProducer_

edm::InputTag TrackHistoryAnalyzer::trackProducer_
private

Definition at line 47 of file TrackHistoryAnalyzer.cc.

Referenced by analyze(), and TrackHistoryAnalyzer().

HiggsValidation_cfi.pdg_id
pdg_id
Definition: HiggsValidation_cfi.py:6
HistoryBase::SimParticleTrail
std::vector< TrackingParticleRef > SimParticleTrail
SimParticle trail type.
Definition: HistoryBase.h:30
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
TrackClassifier::history
const TrackHistory & history() const
Returns a reference to the track history used in the classification.
Definition: TrackClassifier.h:50
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HistoryBase::GenParticleTrail
std::vector< const HepMC::GenParticle * > GenParticleTrail
HepMC::GenParticle trail type.
Definition: HistoryBase.h:15
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:46
edm::Handle
Definition: AssociativeIterator.h:50
TrackHistoryAnalyzer::classifier_
TrackClassifier classifier_
Definition: TrackHistoryAnalyzer.cc:55
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
ParticleData
HepPDT::ParticleData ParticleData
Definition: ParticleDataTable.h:9
config
Definition: config.py:1
TrackCategories::Fake
Definition: TrackCategories.h:12
TrackHistoryAnalyzer::totalTracks_
std::size_t totalTracks_
Definition: TrackHistoryAnalyzer.cc:49
TrackHistoryAnalyzer::particleString
std::string particleString(int) const
Definition: TrackHistoryAnalyzer.cc:150
HistoryBase::simVertexTrail
const SimVertexTrail & simVertexTrail() const
Return all the simulated vertices in the history.
Definition: HistoryBase.h:52
TrackClassifier::evaluate
const TrackClassifier & evaluate(reco::TrackBaseRef const &)
Classify the RecoTrack in categories.
Definition: TrackClassifier.cc:75
HistoryBase::GenVertexTrail
std::vector< const HepMC::GenVertex * > GenVertexTrail
GenVertex trail type.
Definition: HistoryBase.h:24
HistoryBase::genParticleTrail
const GenParticleTrail & genParticleTrail() const
Return all generated particle (HepMC::GenParticle) in the history.
Definition: HistoryBase.h:61
HistoryBase::genVertexTrail
const GenVertexTrail & genVertexTrail() const
Return all generated vertex in the history.
Definition: HistoryBase.h:58
TrackHistoryAnalyzer::vertexString
std::string vertexString(const TrackingParticleRefVector &, const TrackingParticleRefVector &) const
Definition: TrackHistoryAnalyzer.cc:169
duplicaterechits_cfi.trackCollection
trackCollection
Definition: duplicaterechits_cfi.py:4
recoMuon::in
Definition: RecoMuonEnumerators.h:6
TrackClassifier::newEvent
void newEvent(edm::Event const &, edm::EventSetup const &)
Pre-process event information (for accessing reconstraction information)
Definition: TrackClassifier.cc:44
TrackCategories::is
bool is(Category category) const
Returns track flag for a given category.
Definition: TrackCategories.h:76
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
TrackHistoryAnalyzer::pdt_
edm::ESHandle< ParticleDataTable > pdt_
Definition: TrackHistoryAnalyzer.cc:51
HistoryBase::simParticleTrail
const SimParticleTrail & simParticleTrail() const
Return all the simulated particle in the history.
Definition: HistoryBase.h:55
TrackHistory
This class traces the simulated and generated history of a given track.
Definition: TrackHistory.h:17
edm::RefToBase< reco::Track >
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
PbPb_ZMuSkimMuonDPG_cff.particleType
particleType
Definition: PbPb_ZMuSkimMuonDPG_cff.py:27
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
event
Definition: event.py:1
LHEGenericFilter_cfi.ParticleID
ParticleID
Definition: LHEGenericFilter_cfi.py:6
edm::InputTag
Definition: InputTag.h:15
TrackHistoryAnalyzer::trackProducer_
edm::InputTag trackProducer_
Definition: TrackHistoryAnalyzer.cc:47
HistoryBase::SimVertexTrail
std::vector< TrackingVertexRef > SimVertexTrail
SimVertex trail type.
Definition: HistoryBase.h:33