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 &&)=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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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_
 
edm::ESGetToken< ParticleDataTable, edm::DefaultRecordpdtToken_
 
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 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 13 of file ParticleDecayDrawer.cc.

Constructor & Destructor Documentation

◆ ParticleDecayDrawer()

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

Definition at line 47 of file ParticleDecayDrawer.cc.

48  : srcToken_(consumes<edm::View<reco::Candidate> >(cfg.getParameter<InputTag>("src"))),
49  pdtToken_(esConsumes<ParticleDataTable, edm::DefaultRecord>()),
50  printP4_(cfg.getUntrackedParameter<bool>("printP4", false)),
51  printPtEtaPhi_(cfg.getUntrackedParameter<bool>("printPtEtaPhi", false)),
52  printVertex_(cfg.getUntrackedParameter<bool>("printVertex", false)) {}

Member Function Documentation

◆ accept()

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

accept candidate

Definition at line 54 of file ParticleDecayDrawer.cc.

54  {
55  if (find(skip.begin(), skip.end(), &c) != skip.end())
56  return false;
57  return select(c);
58 }

References c, spr::find(), select(), and optionsL1T::skip.

Referenced by decay(), and esMonitoring.FDJsonServer::handle_accept().

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 70 of file ParticleDecayDrawer.cc.

70  {
71  pdt_ = es.getHandle(pdtToken_);
73  event.getByToken(srcToken_, particles);
74  list<const Candidate *> skip;
75  vector<const Candidate *> nodes, moms;
76  for (View<Candidate>::const_iterator p = particles->begin(); p != particles->end(); ++p) {
77  if (p->numberOfMothers() > 1) {
78  if (select(*p)) {
79  skip.push_back(&*p);
80  nodes.push_back(&*p);
81  for (size_t j = 0; j < p->numberOfMothers(); ++j) {
82  const Candidate *mom = p->mother(j);
83  const Candidate *grandMom;
84  while ((grandMom = mom->mother()) != nullptr)
85  mom = grandMom;
86  if (select(*mom)) {
87  moms.push_back(mom);
88  }
89  }
90  }
91  }
92  }
93  cout << "-- decay: --" << endl;
94  if (!moms.empty()) {
95  if (moms.size() > 1)
96  for (size_t m = 0; m < moms.size(); ++m) {
97  string dec = decay(*moms[m], skip);
98  if (!dec.empty())
99  cout << "{ " << dec << " } ";
100  }
101  else
102  cout << decay(*moms[0], skip);
103  }
104  if (!nodes.empty()) {
105  cout << "-> ";
106  if (nodes.size() > 1) {
107  for (size_t n = 0; n < nodes.size(); ++n) {
108  skip.remove(nodes[n]);
109  string dec = decay(*nodes[n], skip);
110  if (!dec.empty()) {
111  if (dec.find("->", 0) != string::npos)
112  cout << " ( " << dec << " )";
113  else
114  cout << " " << dec;
115  }
116  }
117  } else {
118  skip.remove(nodes[0]);
119  cout << decay(*nodes[0], skip);
120  }
121  }
122  cout << endl;
123 }

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

◆ decay()

string ParticleDecayDrawer::decay ( const reco::Candidate ,
std::list< const reco::Candidate * > &   
) const
private

Definition at line 136 of file ParticleDecayDrawer.cc.

136  {
137  string out;
138  if (find(skip.begin(), skip.end(), &c) != skip.end())
139  return out;
140  skip.push_back(&c);
141 
142  int id = c.pdgId();
143  const ParticleData *pd = pdt_->particle(id);
144  assert(pd != nullptr);
145  out += (pd->name() + printP4(c));
146 
147  size_t validDau = 0, ndau = c.numberOfDaughters();
148  for (size_t i = 0; i < ndau; ++i)
149  if (accept(*c.daughter(i), skip))
150  ++validDau;
151  if (validDau == 0)
152  return out;
153 
154  out += " ->";
155 
156  for (size_t i = 0; i < ndau; ++i) {
157  const Candidate *d = c.daughter(i);
158  if (accept(*d, skip)) {
159  string dec = decay(*d, skip);
160  if (dec.find("->", 0) != string::npos)
161  out += (" ( " + dec + " )");
162  else
163  out += (" " + dec);
164  }
165  }
166  return out;
167 }

References accept(), cms::cuda::assert(), c, ztail::d, TauDecayModes::dec, spr::find(), mps_fire::i, MillePedeFileConverter_cfg::out, pdt_, printP4(), and optionsL1T::skip.

Referenced by analyze().

◆ hasValidDaughters()

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

has valid daughters in the chain

Definition at line 62 of file ParticleDecayDrawer.cc.

62  {
63  size_t ndau = c.numberOfDaughters();
64  for (size_t i = 0; i < ndau; ++i)
65  if (select(*c.daughter(i)))
66  return true;
67  return false;
68 }

References c, mps_fire::i, and select().

◆ printP4()

string ParticleDecayDrawer::printP4 ( const reco::Candidate c) const
private

print 4 momenta

Definition at line 125 of file ParticleDecayDrawer.cc.

125  {
126  ostringstream cout;
127  if (printP4_)
128  cout << " (" << c.px() << ", " << c.py() << ", " << c.pz() << "; " << c.energy() << ")";
129  if (printPtEtaPhi_)
130  cout << " [" << c.pt() << ": " << c.eta() << ", " << c.phi() << "]";
131  if (printVertex_)
132  cout << " {" << c.vx() << ", " << c.vy() << ", " << c.vz() << "}";
133  return cout.str();
134 }

References c, gather_cfg::cout, printP4_, printPtEtaPhi_, and printVertex_.

Referenced by decay().

◆ select()

bool ParticleDecayDrawer::select ( const reco::Candidate c) const
private

select candidate

Definition at line 60 of file ParticleDecayDrawer.cc.

60 { return c.status() == 3; }

References c.

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

Member Data Documentation

◆ pdt_

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

Definition at line 21 of file ParticleDecayDrawer.cc.

Referenced by analyze(), and decay().

◆ pdtToken_

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

Definition at line 22 of file ParticleDecayDrawer.cc.

Referenced by analyze().

◆ printP4_

bool ParticleDecayDrawer::printP4_
private

print parameters

Definition at line 24 of file ParticleDecayDrawer.cc.

Referenced by printP4().

◆ printPtEtaPhi_

bool ParticleDecayDrawer::printPtEtaPhi_
private

Definition at line 24 of file ParticleDecayDrawer.cc.

Referenced by printP4().

◆ printVertex_

bool ParticleDecayDrawer::printVertex_
private

Definition at line 24 of file ParticleDecayDrawer.cc.

Referenced by printP4().

◆ srcToken_

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

Definition at line 19 of file ParticleDecayDrawer.cc.

Referenced by analyze().

ParticleDecayDrawer::printP4_
bool printP4_
print parameters
Definition: ParticleDecayDrawer.cc:24
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
ParticleDecayDrawer::printVertex_
bool printVertex_
Definition: ParticleDecayDrawer.cc:24
ParticleDecayDrawer::select
bool select(const reco::Candidate &) const
select candidate
Definition: ParticleDecayDrawer.cc:60
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ParticleDecayDrawer::pdt_
edm::ESHandle< ParticleDataTable > pdt_
Definition: ParticleDecayDrawer.cc:21
cms::cuda::assert
assert(be >=bs)
ParticleDecayDrawer::srcToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
Definition: ParticleDecayDrawer.cc:19
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
reco::Candidate::mother
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
edm::Handle
Definition: AssociativeIterator.h:50
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
ParticleDecayDrawer::accept
bool accept(const reco::Candidate &, const std::list< const reco::Candidate * > &) const
accept candidate
Definition: ParticleDecayDrawer.cc:54
ParticleData
HepPDT::ParticleData ParticleData
Definition: ParticleDataTable.h:9
optionsL1T.skip
skip
Definition: optionsL1T.py:30
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
ParticleDecayDrawer::pdtToken_
edm::ESGetToken< ParticleDataTable, edm::DefaultRecord > pdtToken_
Definition: ParticleDecayDrawer.cc:22
class-composition.nodes
nodes
Definition: class-composition.py:84
edm::View
Definition: CaloClusterFwd.h:14
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ParticleDecayDrawer::printPtEtaPhi_
bool printPtEtaPhi_
Definition: ParticleDecayDrawer.cc:24
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
looper.cfg
cfg
Definition: looper.py:296
reco::Candidate
Definition: Candidate.h:27
ParticleDecayDrawer::printP4
std::string printP4(const reco::Candidate &) const
print 4 momenta
Definition: ParticleDecayDrawer.cc:125
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ztail.d
d
Definition: ztail.py:151
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:159
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
ParticleDecayDrawer::decay
std::string decay(const reco::Candidate &, std::list< const reco::Candidate * > &) const
Definition: ParticleDecayDrawer.cc:136
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
edm::InputTag
Definition: InputTag.h:15