CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ParticleTreeDrawer Class Reference
Inheritance diagram for ParticleTreeDrawer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 ParticleTreeDrawer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 Types

typedef std::vector< int > vint
 accepted status codes More...
 

Private Member Functions

bool accept (const reco::Candidate &) const
 accept candidate More...
 
void analyze (const edm::Event &, const edm::EventSetup &) override
 
std::string getParticleName (int id) const
 
bool hasValidDaughters (const reco::Candidate &) const
 has valid daughters in the chain More...
 
void printDecay (const reco::Candidate &, const std::string &pre) const
 
void printInfo (const reco::Candidate &) const
 print 4 momenta More...
 

Private Attributes

std::vector< const reco::Candidate * > cands_
 pointer to collection More...
 
edm::ESHandle< ParticleDataTablepdt_
 
edm::ESGetToken< ParticleDataTable, edm::DefaultRecordpdtToken_
 
bool printIndex_
 
bool printP4_
 print parameters More...
 
bool printPtEtaPhi_
 
bool printStatus_
 
bool printVertex_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
 
vint status_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 15 of file ParticleTreeDrawer.cc.

Member Typedef Documentation

◆ vint

typedef std::vector<int> ParticleTreeDrawer::vint
private

accepted status codes

Definition at line 29 of file ParticleTreeDrawer.cc.

Constructor & Destructor Documentation

◆ ParticleTreeDrawer()

ParticleTreeDrawer::ParticleTreeDrawer ( const edm::ParameterSet cfg)

Definition at line 52 of file ParticleTreeDrawer.cc.

53  : srcToken_(consumes<edm::View<reco::Candidate> >(cfg.getParameter<InputTag>("src"))),
54  pdtToken_(esConsumes<ParticleDataTable, edm::DefaultRecord>()),
55  printP4_(cfg.getUntrackedParameter<bool>("printP4", false)),
56  printPtEtaPhi_(cfg.getUntrackedParameter<bool>("printPtEtaPhi", false)),
57  printVertex_(cfg.getUntrackedParameter<bool>("printVertex", false)),
58  printStatus_(cfg.getUntrackedParameter<bool>("printStatus", false)),
59  printIndex_(cfg.getUntrackedParameter<bool>("printIndex", false)),
60  status_(cfg.getUntrackedParameter<vint>("status", vint())) {}

Member Function Documentation

◆ accept()

bool ParticleTreeDrawer::accept ( const reco::Candidate c) const
private

accept candidate

Definition at line 62 of file ParticleTreeDrawer.cc.

62  {
63  if (status_.empty())
64  return true;
65  return find(status_.begin(), status_.end(), c.status()) != status_.end();
66 }

References HltBtagPostValidation_cff::c, spr::find(), and status_.

Referenced by analyze(), esMonitoring.FDJsonServer::handle_accept(), hasValidDaughters(), and printDecay().

◆ analyze()

void ParticleTreeDrawer::analyze ( const edm::Event event,
const edm::EventSetup es 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 86 of file ParticleTreeDrawer.cc.

86  {
87  pdt_ = es.getHandle(pdtToken_);
89  event.getByToken(srcToken_, particles);
90  cands_.clear();
91  for (View<Candidate>::const_iterator p = particles->begin(); p != particles->end(); ++p) {
92  cands_.push_back(&*p);
93  }
94  for (View<Candidate>::const_iterator p = particles->begin(); p != particles->end(); ++p) {
95  if (accept(*p)) {
96  if (p->mother() == nullptr) {
97  cout << "-- decay tree: --" << endl;
98  printDecay(*p, "");
99  }
100  }
101  }
102 }

References accept(), cands_, gather_cfg::cout, edm::EventSetup::getHandle(), AlCaHLTBitMon_ParallelJobs::p, ecalTrigSettings_cff::particles, pdt_, pdtToken_, printDecay(), and srcToken_.

◆ getParticleName()

std::string ParticleTreeDrawer::getParticleName ( int  id) const
private

Definition at line 76 of file ParticleTreeDrawer.cc.

76  {
77  const ParticleData *pd = pdt_->particle(id);
78  if (!pd) {
79  std::ostringstream ss;
80  ss << "P" << id;
81  return ss.str();
82  } else
83  return pd->name();
84 }

References triggerObjects_cff::id, pdt_, and contentValuesCheck::ss.

Referenced by printDecay().

◆ hasValidDaughters()

bool ParticleTreeDrawer::hasValidDaughters ( const reco::Candidate c) const
private

has valid daughters in the chain

Definition at line 68 of file ParticleTreeDrawer.cc.

68  {
69  size_t ndau = c.numberOfDaughters();
70  for (size_t i = 0; i < ndau; ++i)
71  if (accept(*c.daughter(i)))
72  return true;
73  return false;
74 }

References accept(), HltBtagPostValidation_cff::c, and mps_fire::i.

Referenced by printDecay().

◆ printDecay()

void ParticleTreeDrawer::printDecay ( const reco::Candidate ,
const std::string &  pre 
) const
private

Definition at line 123 of file ParticleTreeDrawer.cc.

123  {
124  cout << getParticleName(c.pdgId());
125  printInfo(c);
126  cout << endl;
127 
128  size_t ndau = c.numberOfDaughters(), validDau = 0;
129  for (size_t i = 0; i < ndau; ++i)
130  if (accept(*c.daughter(i)))
131  ++validDau;
132  if (validDau == 0)
133  return;
134 
135  bool lastLevel = true;
136  for (size_t i = 0; i < ndau; ++i) {
137  if (hasValidDaughters(*c.daughter(i))) {
138  lastLevel = false;
139  break;
140  }
141  }
142 
143  if (lastLevel) {
144  cout << pre << "+-> ";
145  size_t vd = 0;
146  for (size_t i = 0; i < ndau; ++i) {
147  const Candidate *d = c.daughter(i);
148  if (accept(*d)) {
149  cout << getParticleName(d->pdgId());
150  printInfo(*d);
151  if (vd != validDau - 1)
152  cout << " ";
153  vd++;
154  }
155  }
156  cout << endl;
157  return;
158  }
159 
160  for (size_t i = 0; i < ndau; ++i) {
161  const Candidate *d = c.daughter(i);
162  assert(d != nullptr);
163  if (accept(*d)) {
164  cout << pre << "+-> ";
165  string prepre(pre);
166  if (i == ndau - 1)
167  prepre += " ";
168  else
169  prepre += "| ";
170  printDecay(*d, prepre);
171  }
172  }
173 }

References accept(), cms::cuda::assert(), HltBtagPostValidation_cff::c, gather_cfg::cout, ztail::d, getParticleName(), hasValidDaughters(), mps_fire::i, and printInfo().

Referenced by analyze().

◆ printInfo()

void ParticleTreeDrawer::printInfo ( const reco::Candidate c) const
private

print 4 momenta

Definition at line 104 of file ParticleTreeDrawer.cc.

104  {
105  if (printP4_)
106  cout << " (" << c.px() << ", " << c.py() << ", " << c.pz() << "; " << c.energy() << ")";
107  if (printPtEtaPhi_)
108  cout << " [" << c.pt() << ": " << c.eta() << ", " << c.phi() << "]";
109  if (printVertex_)
110  cout << " {" << c.vx() << ", " << c.vy() << ", " << c.vz() << "}";
111  if (printStatus_)
112  cout << "{status: " << c.status() << "}";
113  if (printIndex_) {
114  int idx = -1;
115  vector<const Candidate *>::const_iterator found = find(cands_.begin(), cands_.end(), &c);
116  if (found != cands_.end()) {
117  idx = found - cands_.begin();
118  cout << " <idx: " << idx << ">";
119  }
120  }
121 }

References HltBtagPostValidation_cff::c, cands_, gather_cfg::cout, spr::find(), newFWLiteAna::found, heavyIonCSV_trainingSettings::idx, printIndex_, printP4_, printPtEtaPhi_, printStatus_, and printVertex_.

Referenced by printDecay().

Member Data Documentation

◆ cands_

std::vector<const reco::Candidate *> ParticleTreeDrawer::cands_
private

pointer to collection

Definition at line 38 of file ParticleTreeDrawer.cc.

Referenced by analyze(), and printInfo().

◆ pdt_

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

Definition at line 24 of file ParticleTreeDrawer.cc.

Referenced by analyze(), and getParticleName().

◆ pdtToken_

edm::ESGetToken<ParticleDataTable, edm::DefaultRecord> ParticleTreeDrawer::pdtToken_
private

Definition at line 25 of file ParticleTreeDrawer.cc.

Referenced by analyze().

◆ printIndex_

bool ParticleTreeDrawer::printIndex_
private

Definition at line 27 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

◆ printP4_

bool ParticleTreeDrawer::printP4_
private

print parameters

Definition at line 27 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

◆ printPtEtaPhi_

bool ParticleTreeDrawer::printPtEtaPhi_
private

Definition at line 27 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

◆ printStatus_

bool ParticleTreeDrawer::printStatus_
private

Definition at line 27 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

◆ printVertex_

bool ParticleTreeDrawer::printVertex_
private

Definition at line 27 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

◆ srcToken_

edm::EDGetTokenT<edm::View<reco::Candidate> > ParticleTreeDrawer::srcToken_
private

Definition at line 22 of file ParticleTreeDrawer.cc.

Referenced by analyze().

◆ status_

vint ParticleTreeDrawer::status_
private

Definition at line 30 of file ParticleTreeDrawer.cc.

Referenced by accept().

ParticleTreeDrawer::status_
vint status_
Definition: ParticleTreeDrawer.cc:30
mps_fire.i
i
Definition: mps_fire.py:428
ParticleTreeDrawer::printP4_
bool printP4_
print parameters
Definition: ParticleTreeDrawer.cc:27
ParticleTreeDrawer::srcToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
Definition: ParticleTreeDrawer.cc:22
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ParticleTreeDrawer::getParticleName
std::string getParticleName(int id) const
Definition: ParticleTreeDrawer.cc:76
ParticleTreeDrawer::pdtToken_
edm::ESGetToken< ParticleDataTable, edm::DefaultRecord > pdtToken_
Definition: ParticleTreeDrawer.cc:25
cms::cuda::assert
assert(be >=bs)
ParticleTreeDrawer::pdt_
edm::ESHandle< ParticleDataTable > pdt_
Definition: ParticleTreeDrawer.cc:24
vd
std::vector< DeviationSensor2D * > vd
Definition: DeviationsFromFileSensor2D.h:21
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
ParticleData
HepPDT::ParticleData ParticleData
Definition: ParticleDataTable.h:9
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
ParticleTreeDrawer::printInfo
void printInfo(const reco::Candidate &) const
print 4 momenta
Definition: ParticleTreeDrawer.cc:104
ParticleTreeDrawer::printPtEtaPhi_
bool printPtEtaPhi_
Definition: ParticleTreeDrawer.cc:27
edm::View
Definition: CaloClusterFwd.h:14
ParticleTreeDrawer::printVertex_
bool printVertex_
Definition: ParticleTreeDrawer.cc:27
ParticleTreeDrawer::hasValidDaughters
bool hasValidDaughters(const reco::Candidate &) const
has valid daughters in the chain
Definition: ParticleTreeDrawer.cc:68
ParticleTreeDrawer::cands_
std::vector< const reco::Candidate * > cands_
pointer to collection
Definition: ParticleTreeDrawer.cc:38
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
ParticleTreeDrawer::printDecay
void printDecay(const reco::Candidate &, const std::string &pre) const
Definition: ParticleTreeDrawer.cc:123
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
ParticleTreeDrawer::printIndex_
bool printIndex_
Definition: ParticleTreeDrawer.cc:27
ParticleTreeDrawer::vint
std::vector< int > vint
accepted status codes
Definition: ParticleTreeDrawer.cc:29
ParticleTreeDrawer::accept
bool accept(const reco::Candidate &) const
accept candidate
Definition: ParticleTreeDrawer.cc:62
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
ztail.d
d
Definition: ztail.py:151
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
edm::InputTag
Definition: InputTag.h:15
ParticleTreeDrawer::printStatus_
bool printStatus_
Definition: ParticleTreeDrawer.cc:27