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
 
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_
 
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 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>
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)
 
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 14 of file ParticleTreeDrawer.cc.

Member Typedef Documentation

◆ vint

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

accepted status codes

Definition at line 27 of file ParticleTreeDrawer.cc.

Constructor & Destructor Documentation

◆ ParticleTreeDrawer()

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

Definition at line 50 of file ParticleTreeDrawer.cc.

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

Member Function Documentation

◆ accept()

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

accept candidate

Definition at line 59 of file ParticleTreeDrawer.cc.

59  {
60  if (status_.empty())
61  return true;
62  return find(status_.begin(), status_.end(), c.status()) != status_.end();
63 }

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 83 of file ParticleTreeDrawer.cc.

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

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

◆ getParticleName()

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

Definition at line 73 of file ParticleTreeDrawer.cc.

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

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 65 of file ParticleTreeDrawer.cc.

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

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 120 of file ParticleTreeDrawer.cc.

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

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 101 of file ParticleTreeDrawer.cc.

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

References HltBtagPostValidation_cff::c, cands_, gather_cfg::cout, spr::find(), newFWLiteAna::found, training_settings::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 36 of file ParticleTreeDrawer.cc.

Referenced by analyze(), and printInfo().

◆ pdt_

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

Definition at line 23 of file ParticleTreeDrawer.cc.

Referenced by analyze(), and getParticleName().

◆ printIndex_

bool ParticleTreeDrawer::printIndex_
private

Definition at line 25 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

◆ printP4_

bool ParticleTreeDrawer::printP4_
private

print parameters

Definition at line 25 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

◆ printPtEtaPhi_

bool ParticleTreeDrawer::printPtEtaPhi_
private

Definition at line 25 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

◆ printStatus_

bool ParticleTreeDrawer::printStatus_
private

Definition at line 25 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

◆ printVertex_

bool ParticleTreeDrawer::printVertex_
private

Definition at line 25 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

◆ srcToken_

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

Definition at line 21 of file ParticleTreeDrawer.cc.

Referenced by analyze().

◆ status_

vint ParticleTreeDrawer::status_
private

Definition at line 28 of file ParticleTreeDrawer.cc.

Referenced by accept().

ParticleTreeDrawer::status_
vint status_
Definition: ParticleTreeDrawer.cc:28
mps_fire.i
i
Definition: mps_fire.py:355
ParticleTreeDrawer::printP4_
bool printP4_
print parameters
Definition: ParticleTreeDrawer.cc:25
ParticleTreeDrawer::srcToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
Definition: ParticleTreeDrawer.cc:21
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:73
cms::cuda::assert
assert(be >=bs)
ParticleTreeDrawer::pdt_
edm::ESHandle< ParticleDataTable > pdt_
Definition: ParticleTreeDrawer.cc:23
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
training_settings.idx
idx
Definition: training_settings.py:16
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
ParticleData
HepPDT::ParticleData ParticleData
Definition: ParticleDataTable.h:9
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
ParticleTreeDrawer::printInfo
void printInfo(const reco::Candidate &) const
print 4 momenta
Definition: ParticleTreeDrawer.cc:101
ParticleTreeDrawer::printPtEtaPhi_
bool printPtEtaPhi_
Definition: ParticleTreeDrawer.cc:25
edm::View
Definition: CaloClusterFwd.h:14
ParticleTreeDrawer::printVertex_
bool printVertex_
Definition: ParticleTreeDrawer.cc:25
ParticleTreeDrawer::hasValidDaughters
bool hasValidDaughters(const reco::Candidate &) const
has valid daughters in the chain
Definition: ParticleTreeDrawer.cc:65
ParticleTreeDrawer::cands_
std::vector< const reco::Candidate * > cands_
pointer to collection
Definition: ParticleTreeDrawer.cc:36
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
ParticleTreeDrawer::printDecay
void printDecay(const reco::Candidate &, const std::string &pre) const
Definition: ParticleTreeDrawer.cc:120
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:113
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
ParticleTreeDrawer::printIndex_
bool printIndex_
Definition: ParticleTreeDrawer.cc:25
ParticleTreeDrawer::vint
std::vector< int > vint
accepted status codes
Definition: ParticleTreeDrawer.cc:27
ParticleTreeDrawer::accept
bool accept(const reco::Candidate &) const
accept candidate
Definition: ParticleTreeDrawer.cc:59
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:126
edm::InputTag
Definition: InputTag.h:15
ParticleTreeDrawer::printStatus_
bool printStatus_
Definition: ParticleTreeDrawer.cc:25