CMS 3D CMS Logo

BasicHepMCValidation.h
Go to the documentation of this file.
1 #ifndef BASICHEPMCVALIDATION_H
2 #define BASICHEPMCVALIDATION_H
3 
4 /*class BasicHepMCValidation
5  *
6  * Class to fill Event Generator dqm monitor elements; works on HepMCProduct
7  *
8  *
9  */
10 
11 // framework & common header files
15 
20 
21 //DQM services
26 
28 
30 
32 #include "TVector3.h"
33 
35 public:
36  explicit BasicHepMCValidation(const edm::ParameterSet &);
37  ~BasicHepMCValidation() override;
38 
39  void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override;
40  void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override;
41  void analyze(edm::Event const &, edm::EventSetup const &) override;
42 
43 private:
46 
49 
51  public:
52  ParticleMonitor(std::string name_, int pdgid_, DQMStore::IBooker &i, bool nlog_ = false)
53  : name(name_), pdgid(pdgid_), count(0), nlog(nlog_) {
54  DQMHelper dqm(&i);
55  // Number of analyzed events
56  if (!nlog) {
57  numberPerEvent = dqm.book1dHisto(
58  name + "Number", "Number of " + name + "'s per event", 20, 0, 20, "No. of " + name, "Number of Events");
59  } else {
60  numberPerEvent = dqm.book1dHisto(name + "Number",
61  "Number of " + name + "'s per event",
62  20,
63  0,
64  20,
65  "log_{10}(No. of " + name + ")",
66  "Number of Events");
67  }
68  p_init = dqm.book1dHisto(name + "Momentum",
69  "log_{10}(P) of the " + name + "s",
70  60,
71  -2,
72  4,
73  "log_{10}(P) (log_{10}(GeV))",
74  "Number of " + name);
75 
76  eta_init = dqm.book1dHisto(name + "Eta", "#eta of the " + name + "s", 100, -5., 5., "#eta", "Number of " + name);
77 
78  lifetime_init = dqm.book1dHisto(name + "LifeTime",
79  "#phi of the " + name + "s",
80  100,
81  -15,
82  -5,
83  "Log_{10}(life-time^{final}) (log_{10}(s))",
84  "Number of " + name);
85 
86  p_final = dqm.book1dHisto(name + "MomentumFinal",
87  "log_{10}(P^{final}) of " + name + "s at end of decay chain",
88  60,
89  -2,
90  4,
91  "log_{10}(P^{final}) (log_{10}(GeV))",
92  "Number of " + name);
93 
94  lifetime_final = dqm.book1dHisto(name + "LifeTimeFinal",
95  "Log_{10}(life-time^{final}) of " + name + "s at end of decay chain",
96  100,
97  -15,
98  -5,
99  "Log_{10}(life-time^{final}) (log_{10}(s))",
100  "Number of " + name);
101  }
102 
104 
105  bool Fill(const HepMC::GenParticle *p, double weight) {
106  if (p->pdg_id() == pdgid) {
107  if (isFirst(p)) {
108  p_init->Fill(log10(p->momentum().rho()), weight);
109  eta_init->Fill(p->momentum().eta(), weight);
110  const HepMC::GenParticle *pf = GetFinal(p); // inlcude mixing
111  p_final->Fill(log10(pf->momentum().rho()), weight);
112  // compute lifetime...
113  if (p->production_vertex() && p->end_vertex()) {
114  TVector3 PV(p->production_vertex()->point3d().x(),
115  p->production_vertex()->point3d().y(),
116  p->production_vertex()->point3d().z());
117  TVector3 SV(p->end_vertex()->point3d().x(), p->end_vertex()->point3d().y(), p->end_vertex()->point3d().z());
118  TVector3 DL = SV - PV;
119  double c(2.99792458E8), Ltau(DL.Mag() / 100) /*cm->m*/, beta(p->momentum().rho() / p->momentum().m());
120  double lt = Ltau / (c * beta);
121  if (lt > 1E-16)
122  lifetime_init->Fill(log10(lt), weight);
123  if (pf->end_vertex()) {
124  TVector3 SVf(
125  pf->end_vertex()->point3d().x(), pf->end_vertex()->point3d().y(), pf->end_vertex()->point3d().z());
126  DL = SVf - PV;
127  Ltau = DL.Mag() / 100;
128  lt = Ltau / (c * beta);
129  if (lt > 1E-16)
130  lifetime_final->Fill(log10(lt), weight);
131  }
132  }
133  count++;
134  }
135  return true;
136  }
137  return false;
138  }
139 
140  void FillCount(double weight) {
141  if (nlog)
142  numberPerEvent->Fill(log10(count), weight);
143  else
145  count = 0;
146  }
147 
148  int PDGID() { return pdgid; }
149 
150  private:
151  bool isFirst(const HepMC::GenParticle *p) {
152  if (p->production_vertex()) {
153  for (HepMC::GenVertex::particles_in_const_iterator m = p->production_vertex()->particles_in_const_begin();
154  m != p->production_vertex()->particles_in_const_end();
155  m++) {
156  if (abs((*m)->pdg_id()) == abs(p->pdg_id()))
157  return false;
158  }
159  }
160  return true;
161  }
162 
163  // includes mixing (assuming mixing is not occurring more than 5 times back and forth)
165  const HepMC::GenParticle *aPart = p;
166  for (unsigned int iMix = 0; iMix < 10; iMix++) {
167  bool foundSimilar = false;
168  if (aPart->end_vertex()) {
169  if (aPart->end_vertex()->particles_out_size() != 0) {
170  for (HepMC::GenVertex::particles_out_const_iterator d = aPart->end_vertex()->particles_out_const_begin();
171  d != aPart->end_vertex()->particles_out_const_end();
172  d++) {
173  if (abs((*d)->pdg_id()) == abs(aPart->pdg_id())) {
174  aPart = *d;
175  foundSimilar = true;
176  break;
177  }
178  }
179  }
180  if (!foundSimilar)
181  break;
182  }
183  }
184  return aPart;
185  }
186 
188  int pdgid;
189  unsigned int count;
190  bool nlog;
192  };
193 
195  std::vector<ParticleMonitor> particles;
196 
205  //
216  //
219  //
232 
234 
240 
242 };
243 
244 #endif
BasicHepMCValidation::particles
std::vector< ParticleMonitor > particles
Definition: BasicHepMCValidation.h:195
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
BasicHepMCValidation::ParticleMonitor::nlog
bool nlog
Definition: BasicHepMCValidation.h:190
ESHandle.h
BasicHepMCValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
Definition: BasicHepMCValidation.cc:35
edm::Run
Definition: Run.h:45
HLT_FULL_cff.beta
beta
Definition: HLT_FULL_cff.py:8651
edm::EDGetTokenT< edm::HepMCProduct >
mps_merge.weight
weight
Definition: mps_merge.py:88
BasicHepMCValidation::hepmcCollection_
edm::InputTag hepmcCollection_
Definition: BasicHepMCValidation.h:45
BasicHepMCValidation::ParticleMonitor::PDGID
int PDGID()
Definition: BasicHepMCValidation.h:148
BasicHepMCValidation::ParticleMonitor::lifetime_init
MonitorElement * lifetime_init
Definition: BasicHepMCValidation.h:191
BasicHepMCValidation::DeltaPy
MonitorElement * DeltaPy
Definition: BasicHepMCValidation.h:238
BasicHepMCValidation::otherPtclNumber
MonitorElement * otherPtclNumber
other ME's
Definition: BasicHepMCValidation.h:198
BasicHepMCValidation::vrtxZ
MonitorElement * vrtxZ
Definition: BasicHepMCValidation.h:217
BasicHepMCValidation::DeltaPx
MonitorElement * DeltaPx
Definition: BasicHepMCValidation.h:237
BasicHepMCValidation::ParticleMonitor::eta_init
MonitorElement * eta_init
Definition: BasicHepMCValidation.h:191
DQMStore.h
BasicHepMCValidation::pdf_g
MonitorElement * pdf_g
Definition: BasicHepMCValidation.h:228
BasicHepMCValidation::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: BasicHepMCValidation.cc:276
BasicHepMCValidation::ParticleMonitor
Definition: BasicHepMCValidation.h:50
BasicHepMCValidation
Definition: BasicHepMCValidation.h:34
BasicHepMCValidation::stablePtclPhi
MonitorElement * stablePtclPhi
Definition: BasicHepMCValidation.h:208
BasicHepMCValidation::~BasicHepMCValidation
~BasicHepMCValidation() override
Definition: BasicHepMCValidation.cc:19
BasicHepMCValidation::genPtclStatus
MonitorElement * genPtclStatus
Definition: BasicHepMCValidation.h:204
BasicHepMCValidation::ParticleMonitor::count
unsigned int count
Definition: BasicHepMCValidation.h:189
nanoDQM_cfi.PV
PV
Definition: nanoDQM_cfi.py:576
BasicHepMCValidation::fPDGTable
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
Definition: BasicHepMCValidation.h:48
BasicHepMCValidation::ParticleMonitor::p_final
MonitorElement * p_final
Definition: BasicHepMCValidation.h:191
BasicHepMCValidation::pdf_ccbar
MonitorElement * pdf_ccbar
Definition: BasicHepMCValidation.h:226
BasicHepMCValidation::ParticleMonitor::numberPerEvent
MonitorElement * numberPerEvent
Definition: BasicHepMCValidation.h:191
DQMHelper.h
BasicHepMCValidation::status1ShortLived
MonitorElement * status1ShortLived
Definition: BasicHepMCValidation.h:233
BasicHepMCValidation::scalePDF
MonitorElement * scalePDF
Definition: BasicHepMCValidation.h:229
BasicHepMCValidation::Bjorken_x
MonitorElement * Bjorken_x
Definition: BasicHepMCValidation.h:220
Service.h
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:79
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
BasicHepMCValidation::ParticleMonitor::p_init
MonitorElement * p_init
Definition: BasicHepMCValidation.h:191
Run.h
edm::ESHandle< HepPDT::ParticleDataTable >
BasicHepMCValidation::stablePtclNumber
MonitorElement * stablePtclNumber
Definition: BasicHepMCValidation.h:206
BasicHepMCValidation::hepmcCollectionToken_
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
Definition: BasicHepMCValidation.h:241
BasicHepMCValidation::nEvt
MonitorElement * nEvt
Definition: BasicHepMCValidation.h:194
BasicHepMCValidation::partonpT
MonitorElement * partonpT
Definition: BasicHepMCValidation.h:214
BasicHepMCValidation::otherPtclMomentum
MonitorElement * otherPtclMomentum
Definition: BasicHepMCValidation.h:199
DQMEDAnalyzer.h
DQMEDAnalyzer
Definition: DQMEDAnalyzer.py:1
WeightManager.h
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
BasicHepMCValidation::BasicHepMCValidation
BasicHepMCValidation(const edm::ParameterSet &)
Definition: BasicHepMCValidation.cc:14
Event.h
ParticleDataTable.h
BasicHepMCValidation::DeltaEcms
MonitorElement * DeltaEcms
Definition: BasicHepMCValidation.h:236
WeightManager
Definition: WeightManager.h:20
BasicHepMCValidation::partonNumber
MonitorElement * partonNumber
Definition: BasicHepMCValidation.h:213
BasicHepMCValidation::DeltaPz
MonitorElement * DeltaPz
Definition: BasicHepMCValidation.h:239
nanoDQM_cfi.SV
SV
Definition: nanoDQM_cfi.py:698
BasicHepMCValidation::genVrtxNumber
MonitorElement * genVrtxNumber
Definition: BasicHepMCValidation.h:201
BasicHepMCValidation::stablePtclEta
MonitorElement * stablePtclEta
Definition: BasicHepMCValidation.h:209
BasicHepMCValidation::outVrtxStablePtclNumber
MonitorElement * outVrtxStablePtclNumber
Definition: BasicHepMCValidation.h:215
BasicHepMCValidation::pdf_u
MonitorElement * pdf_u
Definition: BasicHepMCValidation.h:221
edm::EventSetup
Definition: EventSetup.h:58
BasicHepMCValidation::ParticleMonitor::FillCount
void FillCount(double weight)
Definition: BasicHepMCValidation.h:140
BasicHepMCValidation::ParticleMonitor::lifetime_final
MonitorElement * lifetime_final
Definition: BasicHepMCValidation.h:191
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
BasicHepMCValidation::dqmBeginRun
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
Definition: BasicHepMCValidation.cc:21
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DQMHelper
Definition: DQMHelper.h:15
BasicHepMCValidation::vrtxRadius
MonitorElement * vrtxRadius
Definition: BasicHepMCValidation.h:218
BasicHepMCValidation::ParticleMonitor::isFirst
bool isFirst(const HepMC::GenParticle *p)
Definition: BasicHepMCValidation.h:151
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
BasicHepMCValidation::unknownPDTNumber
MonitorElement * unknownPDTNumber
Definition: BasicHepMCValidation.h:202
BasicHepMCValidation::pdf_ubar
MonitorElement * pdf_ubar
Definition: BasicHepMCValidation.h:222
BasicHepMCValidation::stablePtclCharge
MonitorElement * stablePtclCharge
Definition: BasicHepMCValidation.h:210
BasicHepMCValidation::pdf_bbbar
MonitorElement * pdf_bbbar
Definition: BasicHepMCValidation.h:227
BasicHepMCValidation::ParticleMonitor::name
std::string name
Definition: BasicHepMCValidation.h:187
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
BasicHepMCValidation::ParticleMonitor::GetFinal
const HepMC::GenParticle * GetFinal(const HepMC::GenParticle *p)
Definition: BasicHepMCValidation.h:164
BasicHepMCValidation::pdf_d
MonitorElement * pdf_d
Definition: BasicHepMCValidation.h:223
BasicHepMCValidation::outVrtxPtclNumber
MonitorElement * outVrtxPtclNumber
Definition: BasicHepMCValidation.h:203
EventSetup.h
BasicHepMCValidation::stableChaNumber
MonitorElement * stableChaNumber
Definition: BasicHepMCValidation.h:207
BasicHepMCValidation::ParticleMonitor::~ParticleMonitor
~ParticleMonitor()
Definition: BasicHepMCValidation.h:103
dqm::implementation::IBooker
Definition: DQMStore.h:43
BasicHepMCValidation::ParticleMonitor::pdgid
int pdgid
Definition: BasicHepMCValidation.h:188
ztail.d
d
Definition: ztail.py:151
BasicHepMCValidation::wmanager_
WeightManager wmanager_
Definition: BasicHepMCValidation.h:44
BasicHepMCValidation::genPtclNumber
MonitorElement * genPtclNumber
Definition: BasicHepMCValidation.h:200
dqm
Definition: DQMStore.h:18
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
BasicHepMCValidation::ParticleMonitor::Fill
bool Fill(const HepMC::GenParticle *p, double weight)
Definition: BasicHepMCValidation.h:105
HepMCProduct.h
BasicHepMCValidation::parton1Id
MonitorElement * parton1Id
Definition: BasicHepMCValidation.h:230
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
edm::Event
Definition: Event.h:73
BasicHepMCValidation::stablePtclpT
MonitorElement * stablePtclpT
Definition: BasicHepMCValidation.h:212
edm::InputTag
Definition: InputTag.h:15
BasicHepMCValidation::log10DeltaEcms
MonitorElement * log10DeltaEcms
Definition: BasicHepMCValidation.h:235
weight
Definition: weight.py:1
BasicHepMCValidation::ParticleMonitor::ParticleMonitor
ParticleMonitor(std::string name_, int pdgid_, DQMStore::IBooker &i, bool nlog_=false)
Definition: BasicHepMCValidation.h:52
BasicHepMCValidation::pdf_dbar
MonitorElement * pdf_dbar
Definition: BasicHepMCValidation.h:224
BasicHepMCValidation::parton2Id
MonitorElement * parton2Id
Definition: BasicHepMCValidation.h:231
BasicHepMCValidation::stablePtclp
MonitorElement * stablePtclp
Definition: BasicHepMCValidation.h:211
BasicHepMCValidation::pdf_ssbar
MonitorElement * pdf_ssbar
Definition: BasicHepMCValidation.h:225