CMS 3D CMS Logo

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

Public Member Functions

 ParticleDecayDrawer (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
 
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
 
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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

bool accept (const reco::Candidate &, const std::list< const reco::Candidate * > &) const
 accept candidate More...
 
void analyze (const edm::Event &, const edm::EventSetup &) override
 
std::string decay (const reco::Candidate &, std::list< const reco::Candidate * > &) const
 
bool hasValidDaughters (const reco::Candidate &) const
 has valid daughters in the chain More...
 
std::string printP4 (const reco::Candidate &) const
 print 4 momenta More...
 
bool select (const reco::Candidate &) const
 select candidate More...
 

Private Attributes

edm::ESHandle< ParticleDataTablepdt_
 
bool printP4_
 print parameters More...
 
bool printPtEtaPhi_
 
bool printVertex_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
 

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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 12 of file ParticleDecayDrawer.cc.

Constructor & Destructor Documentation

ParticleDecayDrawer::ParticleDecayDrawer ( const edm::ParameterSet cfg)

Definition at line 45 of file ParticleDecayDrawer.cc.

47  printP4_(cfg.getUntrackedParameter<bool>("printP4", false)),
48  printPtEtaPhi_(cfg.getUntrackedParameter<bool>("printPtEtaPhi", false)),
49  printVertex_(cfg.getUntrackedParameter<bool>("printVertex", false)) {}
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool printP4_
print parameters
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_

Member Function Documentation

bool ParticleDecayDrawer::accept ( const reco::Candidate ,
const std::list< const reco::Candidate * > &   
) const
private

accept candidate

Definition at line 51 of file ParticleDecayDrawer.cc.

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

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

51  {
52  if (find(skip.begin(), skip.end(), &c) != skip.end())
53  return false;
54  return select(c);
55 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
bool select(const reco::Candidate &) const
select candidate
void ParticleDecayDrawer::analyze ( const edm::Event event,
const edm::EventSetup es 
)
overrideprivate

Definition at line 67 of file ParticleDecayDrawer.cc.

References gather_cfg::cout, TauDecayModes::dec, decay(), edm::EventSetup::getData(), dqmiolumiharvest::j, visualization-live-secondInstance_cfg::m, reco::Candidate::mother(), dqmiodumpmetadata::n, class-composition::nodes, AlCaHLTBitMon_ParallelJobs::p, ecalTrigSettings_cff::particles, pdt_, select(), optionsL1T::skip, and srcToken_.

67  {
68  es.getData(pdt_);
70  event.getByToken(srcToken_, particles);
71  list<const Candidate *> skip;
72  vector<const Candidate *> nodes, moms;
73  for (View<Candidate>::const_iterator p = particles->begin(); p != particles->end(); ++p) {
74  if (p->numberOfMothers() > 1) {
75  if (select(*p)) {
76  skip.push_back(&*p);
77  nodes.push_back(&*p);
78  for (size_t j = 0; j < p->numberOfMothers(); ++j) {
79  const Candidate *mom = p->mother(j);
80  const Candidate *grandMom;
81  while ((grandMom = mom->mother()) != nullptr)
82  mom = grandMom;
83  if (select(*mom)) {
84  moms.push_back(mom);
85  }
86  }
87  }
88  }
89  }
90  cout << "-- decay: --" << endl;
91  if (!moms.empty()) {
92  if (moms.size() > 1)
93  for (size_t m = 0; m < moms.size(); ++m) {
94  string dec = decay(*moms[m], skip);
95  if (!dec.empty())
96  cout << "{ " << dec << " } ";
97  }
98  else
99  cout << decay(*moms[0], skip);
100  }
101  if (!nodes.empty()) {
102  cout << "-> ";
103  if (nodes.size() > 1) {
104  for (size_t n = 0; n < nodes.size(); ++n) {
105  skip.remove(nodes[n]);
106  string dec = decay(*nodes[n], skip);
107  if (!dec.empty()) {
108  if (dec.find("->", 0) != string::npos)
109  cout << " ( " << dec << " )";
110  else
111  cout << " " << dec;
112  }
113  }
114  } else {
115  skip.remove(nodes[0]);
116  cout << decay(*nodes[0], skip);
117  }
118  }
119  cout << endl;
120 }
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
edm::ESHandle< ParticleDataTable > pdt_
bool getData(T &iHolder) const
Definition: EventSetup.h:113
std::string decay(const reco::Candidate &, std::list< const reco::Candidate * > &) const
bool select(const reco::Candidate &) const
select candidate
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
string ParticleDecayDrawer::decay ( const reco::Candidate ,
std::list< const reco::Candidate * > &   
) const
private

Definition at line 133 of file ParticleDecayDrawer.cc.

References accept(), HltBtagPostValidation_cff::c, ztail::d, reco::Candidate::daughter(), TauDecayModes::dec, DEFINE_FWK_MODULE, spr::find(), mps_fire::i, reco::Candidate::numberOfDaughters(), MillePedeFileConverter_cfg::out, reco::Candidate::pdgId(), pdt_, printP4(), and optionsL1T::skip.

Referenced by analyze().

133  {
134  string out;
135  if (find(skip.begin(), skip.end(), &c) != skip.end())
136  return out;
137  skip.push_back(&c);
138 
139  int id = c.pdgId();
140  const ParticleData *pd = pdt_->particle(id);
141  assert(pd != nullptr);
142  out += (pd->name() + printP4(c));
143 
144  size_t validDau = 0, ndau = c.numberOfDaughters();
145  for (size_t i = 0; i < ndau; ++i)
146  if (accept(*c.daughter(i), skip))
147  ++validDau;
148  if (validDau == 0)
149  return out;
150 
151  out += " ->";
152 
153  for (size_t i = 0; i < ndau; ++i) {
154  const Candidate *d = c.daughter(i);
155  if (accept(*d, skip)) {
156  string dec = decay(*d, skip);
157  if (dec.find("->", 0) != string::npos)
158  out += (" ( " + dec + " )");
159  else
160  out += (" " + dec);
161  }
162  }
163  return out;
164 }
bool accept(const reco::Candidate &, const std::list< const reco::Candidate * > &) const
accept candidate
std::string printP4(const reco::Candidate &) const
print 4 momenta
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::ESHandle< ParticleDataTable > pdt_
std::string decay(const reco::Candidate &, std::list< const reco::Candidate * > &) const
HepPDT::ParticleData ParticleData
d
Definition: ztail.py:151
bool ParticleDecayDrawer::hasValidDaughters ( const reco::Candidate c) const
private

has valid daughters in the chain

Definition at line 59 of file ParticleDecayDrawer.cc.

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

59  {
60  size_t ndau = c.numberOfDaughters();
61  for (size_t i = 0; i < ndau; ++i)
62  if (select(*c.daughter(i)))
63  return true;
64  return false;
65 }
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
bool select(const reco::Candidate &) const
select candidate
virtual size_type numberOfDaughters() const =0
number of daughters
string ParticleDecayDrawer::printP4 ( const reco::Candidate c) const
private

print 4 momenta

Definition at line 122 of file ParticleDecayDrawer.cc.

References gather_cfg::cout, reco::Candidate::energy(), reco::Candidate::eta(), reco::Candidate::phi(), printP4_, printPtEtaPhi_, printVertex_, reco::Candidate::pt(), reco::Candidate::px(), reco::Candidate::py(), reco::Candidate::pz(), reco::Candidate::vx(), reco::Candidate::vy(), and reco::Candidate::vz().

Referenced by decay().

122  {
123  ostringstream cout;
124  if (printP4_)
125  cout << " (" << c.px() << ", " << c.py() << ", " << c.pz() << "; " << c.energy() << ")";
126  if (printPtEtaPhi_)
127  cout << " [" << c.pt() << ": " << c.eta() << ", " << c.phi() << "]";
128  if (printVertex_)
129  cout << " {" << c.vx() << ", " << c.vy() << ", " << c.vz() << "}";
130  return cout.str();
131 }
virtual double pz() const =0
z coordinate of momentum vector
virtual double vx() const =0
x coordinate of vertex position
virtual double vy() const =0
y coordinate of vertex position
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
bool ParticleDecayDrawer::select ( const reco::Candidate c) const
private

select candidate

Definition at line 57 of file ParticleDecayDrawer.cc.

References reco::Candidate::status().

Referenced by accept(), analyze(), and hasValidDaughters().

57 { return c.status() == 3; }
virtual int status() const =0
status word

Member Data Documentation

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

Definition at line 20 of file ParticleDecayDrawer.cc.

Referenced by analyze(), and decay().

bool ParticleDecayDrawer::printP4_
private

print parameters

Definition at line 22 of file ParticleDecayDrawer.cc.

Referenced by printP4().

bool ParticleDecayDrawer::printPtEtaPhi_
private

Definition at line 22 of file ParticleDecayDrawer.cc.

Referenced by printP4().

bool ParticleDecayDrawer::printVertex_
private

Definition at line 22 of file ParticleDecayDrawer.cc.

Referenced by printP4().

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

Definition at line 18 of file ParticleDecayDrawer.cc.

Referenced by analyze().