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
27 
29 
31 
33 #include "TVector3.h"
34 
36  public:
37  explicit BasicHepMCValidation(const edm::ParameterSet&);
38  ~BasicHepMCValidation() override;
39 
40  void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override;
41  void dqmBeginRun(const edm::Run& r, const edm::EventSetup& c) override;
42  void analyze(edm::Event const&, edm::EventSetup const&) override;
43 
44  private:
47 
50 
51 
53  public:
54  ParticleMonitor(std::string name_,int pdgid_, DQMStore::IBooker &i,bool nlog_=false):name(name_),pdgid(pdgid_),count(0),nlog(nlog_){
55  DQMHelper dqm(&i);
56  // Number of analyzed events
57  if(!nlog){
58  numberPerEvent= dqm.book1dHisto(name+"Number", "Number of "+name+"'s per event",
59  20, 0, 20,"No. of "+name,"Number of Events");
60  }
61  else{
62  numberPerEvent= dqm.book1dHisto(name+"Number", "Number of "+name+"'s per event",
63  20, 0, 20,"log_{10}(No. of "+name+")","Number of Events");
64  }
65  p_init = dqm.book1dHisto(name+"Momentum", "log_{10}(P) of the "+name+"s",
66  60, -2, 4,"log_{10}(P) (log_{10}(GeV))","Number of "+name );
67 
68  eta_init = dqm.book1dHisto(name+"Eta", "#eta of the "+name+"s",
69  100, -5., 5.,"#eta","Number of "+name);
70 
71  lifetime_init = dqm.book1dHisto(name+"LifeTime", "#phi of the "+name+"s",
72  100, -15, -5,"Log_{10}(life-time^{final}) (log_{10}(s))","Number of "+name);
73 
74  p_final = dqm.book1dHisto(name+"MomentumFinal", "log_{10}(P^{final}) of "+name+"s at end of decay chain",
75  60, -2, 4,"log_{10}(P^{final}) (log_{10}(GeV))","Number of "+name);
76 
77  lifetime_final=dqm.book1dHisto(name+"LifeTimeFinal", "Log_{10}(life-time^{final}) of "+name+"s at end of decay chain",
78  100,-15,-5,"Log_{10}(life-time^{final}) (log_{10}(s))","Number of "+name);
79  }
80 
82 
83  bool Fill(const HepMC::GenParticle* p, double weight){
84  if(p->pdg_id()==pdgid){
85  if(isFirst(p)){
86  p_init->Fill(log10(p->momentum().rho()),weight);
87  eta_init->Fill(p->momentum().eta(),weight);
88  const HepMC::GenParticle* pf=GetFinal(p); // inlcude mixing
89  p_final->Fill(log10(pf->momentum().rho()),weight);
90  // compute lifetime...
91  if(p->production_vertex() && p->end_vertex()){
92  TVector3 PV(p->production_vertex()->point3d().x(),p->production_vertex()->point3d().y(),p->production_vertex()->point3d().z());
93  TVector3 SV(p->end_vertex()->point3d().x(),p->end_vertex()->point3d().y(),p->end_vertex()->point3d().z());
94  TVector3 DL=SV-PV;
95  double c(2.99792458E8),Ltau(DL.Mag()/100)/*cm->m*/,beta(p->momentum().rho()/p->momentum().m());
96  double lt=Ltau/(c*beta);
97  if(lt>1E-16)lifetime_init->Fill(log10(lt),weight);
98  if(pf->end_vertex()){
99  TVector3 SVf(pf->end_vertex()->point3d().x(),pf->end_vertex()->point3d().y(),pf->end_vertex()->point3d().z());
100  DL=SVf-PV;
101  Ltau=DL.Mag()/100;
102  lt=Ltau/(c*beta);
103  if(lt>1E-16)lifetime_final->Fill(log10(lt),weight);
104  }
105  }
106  count++;
107  }
108  return true;
109  }
110  return false;
111  }
112 
113  void FillCount(double weight){
114  if(nlog) numberPerEvent->Fill(log10(count),weight);
115  else numberPerEvent->Fill(count,weight);
116  count=0;
117  }
118 
119  int PDGID(){return pdgid;}
120 
121  private:
123  if(p->production_vertex()){
124  for(HepMC::GenVertex::particles_in_const_iterator m=p->production_vertex()->particles_in_const_begin(); m!=p->production_vertex()->particles_in_const_end();m++){
125  if(abs((*m)->pdg_id())==abs(p->pdg_id())) return false;
126  }
127  }
128  return true;
129  }
130 
131  const HepMC::GenParticle* GetFinal(const HepMC::GenParticle* p){ // includes mixing (assuming mixing is not occurring more than 5 times back and forth)
132  const HepMC::GenParticle* aPart = p;
133  for (unsigned int iMix = 0; iMix < 10; iMix++) {
134  bool foundSimilar = false;
135  if(aPart->end_vertex()){
136  if(aPart->end_vertex()->particles_out_size()!=0){
137  for(HepMC::GenVertex::particles_out_const_iterator d=aPart->end_vertex()->particles_out_const_begin(); d!=aPart->end_vertex()->particles_out_const_end();d++){
138  if(abs((*d)->pdg_id())==abs(aPart->pdg_id())){
139  aPart = *d;
140  foundSimilar = true;
141  break;
142  }
143  }
144  }
145  if (!foundSimilar) break;
146  }
147  }
148  return aPart;
149  }
150 
152  int pdgid;
153  unsigned int count;
154  bool nlog;
156  };
157 
158 
160  std::vector<ParticleMonitor> particles;
161 
170  //
181  //
184  //
197 
199 
205 
207 
208 };
209 
210 #endif
MonitorElement * genPtclStatus
MonitorElement * DeltaEcms
MonitorElement * genVrtxNumber
MonitorElement * unknownPDTNumber
MonitorElement * pdf_bbbar
MonitorElement * outVrtxPtclNumber
MonitorElement * pdf_ccbar
bool isFirst(const HepMC::GenParticle *p)
MonitorElement * Bjorken_x
MonitorElement * otherPtclNumber
other ME&#39;s
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
BasicHepMCValidation(const edm::ParameterSet &)
MonitorElement * parton2Id
MonitorElement * otherPtclMomentum
MonitorElement * stablePtclCharge
Definition: weight.py:1
MonitorElement * partonNumber
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
MonitorElement * book1dHisto(std::string name, std::string title, int n, double xmin, double xmax, std::string xaxis, std::string yaxis)
Definition: DQMHelper.cc:12
void Fill(long long x)
MonitorElement * vrtxRadius
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MonitorElement * log10DeltaEcms
MonitorElement * stablePtclPhi
MonitorElement * stablePtclEta
const HepMC::GenParticle * GetFinal(const HepMC::GenParticle *p)
void analyze(edm::Event const &, edm::EventSetup const &) override
MonitorElement * stablePtclp
MonitorElement * status1ShortLived
MonitorElement * stablePtclpT
MonitorElement * stableChaNumber
ParticleMonitor(std::string name_, int pdgid_, DQMStore::IBooker &i, bool nlog_=false)
MonitorElement * stablePtclNumber
bool Fill(const HepMC::GenParticle *p, double weight)
MonitorElement * genPtclNumber
edm::InputTag hepmcCollection_
MonitorElement * outVrtxStablePtclNumber
std::vector< ParticleMonitor > particles
MonitorElement * pdf_ssbar
Definition: Run.h:45
MonitorElement * parton1Id