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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

Detailed Description

Definition at line 14 of file ParticleTreeDrawer.cc.

Member Typedef Documentation

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

accepted status codes

Definition at line 26 of file ParticleTreeDrawer.cc.

Constructor & Destructor Documentation

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

Definition at line 49 of file ParticleTreeDrawer.cc.

49  :
51  printP4_( cfg.getUntrackedParameter<bool>( "printP4", false ) ),
52  printPtEtaPhi_( cfg.getUntrackedParameter<bool>( "printPtEtaPhi", false ) ),
53  printVertex_( cfg.getUntrackedParameter<bool>( "printVertex", false ) ),
54  printStatus_( cfg.getUntrackedParameter<bool>( "printStatus", false ) ),
55  printIndex_( cfg.getUntrackedParameter<bool>( "printIndex", false ) ),
56  status_( cfg.getUntrackedParameter<vint>( "status", vint() ) ) {
57 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
std::vector< int > vint
accepted status codes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool printP4_
print parameters

Member Function Documentation

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

accept candidate

Definition at line 59 of file ParticleTreeDrawer.cc.

References spr::find(), reco::Candidate::status(), and status_.

Referenced by analyze(), Vispa.Gui.BoxContentDialog.BoxContentDialog::apply(), Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog::apply(), esMonitoring.FDJsonServer::handle_accept(), hasValidDaughters(), and printDecay().

59  {
60  if ( status_.empty() ) return true;
61  return find( status_.begin(), status_.end(), c.status() ) != status_.end();
62 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
virtual int status() const =0
status word
void ParticleTreeDrawer::analyze ( const edm::Event event,
const edm::EventSetup es 
)
overrideprivate

Definition at line 83 of file ParticleTreeDrawer.cc.

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

83  {
84  es.getData( pdt_ );
86  event.getByToken( srcToken_, particles );
87  cands_.clear();
88  for( View<Candidate>::const_iterator p = particles->begin();
89  p != particles->end(); ++ p ) {
90  cands_.push_back( & * p );
91  }
92  for( View<Candidate>::const_iterator p = particles->begin();
93  p != particles->end(); ++ p ) {
94  if ( accept( * p ) ) {
95  if ( p->mother() == nullptr ) {
96  cout << "-- decay tree: --" << endl;
97  printDecay( * p, "" );
98  }
99  }
100  }
101 }
std::vector< const reco::Candidate * > cands_
pointer to collection
edm::ESHandle< ParticleDataTable > pdt_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
void printDecay(const reco::Candidate &, const std::string &pre) const
#define nullptr
void getData(T &iHolder) const
Definition: EventSetup.h:82
bool accept(const reco::Candidate &) const
accept candidate
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
std::string ParticleTreeDrawer::getParticleName ( int  id) const
private

Definition at line 72 of file ParticleTreeDrawer.cc.

References triggerObjects_cff::id, and pdt_.

Referenced by printDecay().

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 }
edm::ESHandle< ParticleDataTable > pdt_
HepPDT::ParticleData ParticleData
bool ParticleTreeDrawer::hasValidDaughters ( const reco::Candidate c) const
private

has valid daughters in the chain

Definition at line 64 of file ParticleTreeDrawer.cc.

References accept(), reco::Candidate::daughter(), mps_fire::i, and reco::Candidate::numberOfDaughters().

Referenced by printDecay().

64  {
65  size_t ndau = c.numberOfDaughters();
66  for( size_t i = 0; i < ndau; ++ i )
67  if ( accept( * c.daughter( i ) ) )
68  return true;
69  return false;
70 }
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
bool accept(const reco::Candidate &) const
accept candidate
virtual size_type numberOfDaughters() const =0
number of daughters
void ParticleTreeDrawer::printDecay ( const reco::Candidate ,
const std::string &  pre 
) const
private

Definition at line 118 of file ParticleTreeDrawer.cc.

References accept(), gather_cfg::cout, edmIntegrityCheck::d, reco::Candidate::daughter(), DEFINE_FWK_MODULE, getParticleName(), hasValidDaughters(), mps_fire::i, reco::Candidate::numberOfDaughters(), reco::Candidate::pdgId(), and printInfo().

Referenced by analyze().

118  {
119  cout << getParticleName( c.pdgId() );
120  printInfo( c );
121  cout << endl;
122 
123  size_t ndau = c.numberOfDaughters(), validDau = 0;
124  for( size_t i = 0; i < ndau; ++ i )
125  if ( accept( * c.daughter( i ) ) )
126  ++ validDau;
127  if ( validDau == 0 ) return;
128 
129  bool lastLevel = true;
130  for( size_t i = 0; i < ndau; ++ i ) {
131  if ( hasValidDaughters( * c.daughter( i ) ) ) {
132  lastLevel = false;
133  break;
134  }
135  }
136 
137  if ( lastLevel ) {
138  cout << pre << "+-> ";
139  size_t vd = 0;
140  for( size_t i = 0; i < ndau; ++ i ) {
141  const Candidate * d = c.daughter( i );
142  if ( accept( * d ) ) {
143  cout << getParticleName( d->pdgId() );
144  printInfo( * d );
145  if ( vd != validDau - 1 )
146  cout << " ";
147  vd ++;
148  }
149  }
150  cout << endl;
151  return;
152  }
153 
154  for( size_t i = 0; i < ndau; ++i ) {
155  const Candidate * d = c.daughter( i );
156  assert( d != nullptr );
157  if ( accept( * d ) ) {
158  cout << pre << "+-> ";
159  string prepre( pre );
160  if ( i == ndau - 1 ) prepre += " ";
161  else prepre += "| ";
162  printDecay( * d, prepre );
163  }
164  }
165 }
void printInfo(const reco::Candidate &) const
print 4 momenta
std::string getParticleName(int id) const
void printDecay(const reco::Candidate &, const std::string &pre) const
std::vector< DeviationSensor2D * > vd
bool accept(const reco::Candidate &) const
accept candidate
virtual int pdgId() const =0
PDG identifier.
bool hasValidDaughters(const reco::Candidate &) const
has valid daughters in the chain
void ParticleTreeDrawer::printInfo ( const reco::Candidate c) const
private

print 4 momenta

Definition at line 103 of file ParticleTreeDrawer.cc.

References EnergyCorrector::c, cands_, gather_cfg::cout, reco::Candidate::energy(), reco::Candidate::eta(), spr::find(), runEdmFileComparison::found, training_settings::idx, reco::Candidate::phi(), printIndex_, printP4_, printPtEtaPhi_, printStatus_, printVertex_, reco::Candidate::pt(), reco::Candidate::px(), reco::Candidate::py(), reco::Candidate::pz(), reco::Candidate::status(), reco::Candidate::vx(), reco::Candidate::vy(), and reco::Candidate::vz().

Referenced by printDecay().

103  {
104  if ( printP4_ ) cout << " (" << c.px() << ", " << c.py() << ", " << c.pz() << "; " << c.energy() << ")";
105  if ( printPtEtaPhi_ ) cout << " [" << c.pt() << ": " << c.eta() << ", " << c.phi() << "]";
106  if ( printVertex_ ) cout << " {" << c.vx() << ", " << c.vy() << ", " << c.vz() << "}";
107  if ( printStatus_ ) cout << "{status: " << c.status() << "}";
108  if ( printIndex_ ) {
109  int idx = -1;
110  vector<const Candidate *>::const_iterator found = find( cands_.begin(), cands_.end(), & c );
111  if ( found != cands_.end() ) {
112  idx = found - cands_.begin();
113  cout << " <idx: " << idx << ">";
114  }
115  }
116 }
virtual double pz() const =0
z coordinate of momentum vector
virtual double vx() const =0
x coordinate of vertex position
std::vector< const reco::Candidate * > cands_
pointer to collection
virtual double vy() const =0
y coordinate of vertex position
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
virtual int status() const =0
status word
virtual double energy() const =0
energy
virtual double py() const =0
y coordinate of momentum vector
bool printP4_
print parameters
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
virtual double vz() const =0
z coordinate of vertex position
virtual double px() const =0
x coordinate of momentum vector
virtual double phi() const =0
momentum azimuthal angle

Member Data Documentation

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

pointer to collection

Definition at line 35 of file ParticleTreeDrawer.cc.

Referenced by analyze(), and printInfo().

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

Definition at line 22 of file ParticleTreeDrawer.cc.

Referenced by analyze(), and getParticleName().

bool ParticleTreeDrawer::printIndex_
private

Definition at line 24 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

bool ParticleTreeDrawer::printP4_
private

print parameters

Definition at line 24 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

bool ParticleTreeDrawer::printPtEtaPhi_
private

Definition at line 24 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

bool ParticleTreeDrawer::printStatus_
private

Definition at line 24 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

bool ParticleTreeDrawer::printVertex_
private

Definition at line 24 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

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

Definition at line 20 of file ParticleTreeDrawer.cc.

Referenced by analyze().

vint ParticleTreeDrawer::status_
private

Definition at line 27 of file ParticleTreeDrawer.cc.

Referenced by accept().