CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HiBasicGenTest.cc
Go to the documentation of this file.
1 #include "HepMC/GenEvent.h"
2 #include "HepMC/GenParticle.h"
7 
8 #include "HepMC/GenEvent.h"
9 #include "HepMC/HeavyIon.h"
10 
11 #include <TString.h>
12 #include <TMath.h>
13 
14 using namespace edm;
15 using namespace HepMC;
16 
18 {
19  generatorToken_ = consumes<edm::HepMCProduct> (
20  iPSet.getParameter<edm::InputTag>("generatorLabel"));
21 }
22 
24 
26  edm::Run const &, edm::EventSetup const & ){
27 
29  ibooker.setCurrentFolder("Generator/Particles");
30 
32  for (int ibin = 0; ibin < 3; ibin++) {
33  dnchdeta[ibin] = ibooker.book1D(Form("dnchdeta%d", ibin), ";#eta;dN^{ch}/d#eta",
34  100, -6.0, 6.0);
35 
36  dnchdpt[ibin] = ibooker.book1D(Form("dnchdpt%d", ibin), ";p_{T};dN^{ch}/dp_{T}",
37  200, 0.0, 100.0);
38 
39  b[ibin] = ibooker.book1D(Form("b%d",ibin),";b[fm];events", 100, 0.0, 20.0);
40  dnchdphi[ibin] = ibooker.book1D(Form("dnchdphi%d", ibin), ";#phi;dN^{ch}/d#phi",
41  100, -3.2, 3.2);
42 
43  ibooker.tag(dnchdeta[ibin], 1+ibin*4);
44  ibooker.tag(dnchdpt[ibin], 2+ibin*4);
45  ibooker.tag(b[ibin], 3+ibin*4);
46  ibooker.tag(dnchdphi[ibin], 4+ibin*4);
47  }
48 
49  rp = ibooker.book1D("phi0", ";#phi_{RP};events", 100, -3.2, 3.2);
50  ibooker.tag(rp, 13);
51 }
52 
53 void HiBasicGenTest::dqmBeginRun(const edm::Run& iRun,const edm::EventSetup& iSetup)
54 {
55  iSetup.getData(pdt);
56 }
57 
58 
60 {
61 
63  iEvent.getByToken(generatorToken_, mc);
64  const HepMC::GenEvent *evt = mc->GetEvent();
65  const HepMC::HeavyIon *hi = evt->heavy_ion();
66 
67  int cbin = 0;
68  double phi0 =0.;
69 
70  if(hi){
71 
72  double ip = hi->impact_parameter();
73  phi0 = hi->event_plane_angle();
74 
75  // fill reaction plane distribution
76  rp->Fill(phi0);
77 
78  // if the event is in one of the centrality bins of interest fill hists
79  int cbin=-1;
80  if(ip < 5.045) cbin=0;
81  else if (ip < 7.145 && ip > 5.045) cbin=1;
82  else if (ip < 15.202 && ip > 14.283) cbin=2;
83  if(cbin<0) return;
84 
85  // fill impact parameter distributions
86  b[cbin]->Fill(ip);
87  }
88 
89  // loop over particles
90  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
91  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
92  for(HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it){
93 
94  // only fill hists for status=1 particles
95  if((*it)->status() != 1) continue;
96 
97  // only fill hists for charged particles
98  int pdg_id = (*it)->pdg_id();
99  const ParticleData * part = pdt->particle(pdg_id);
100  int charge = static_cast<int>(part->charge());
101  if(charge==0) continue;
102 
103  float eta = (*it)->momentum().eta();
104  float phi = (*it)->momentum().phi();
105  float pt = (*it)->momentum().perp();
106 
107  dnchdeta[cbin]->Fill(eta);
108  dnchdpt[cbin]->Fill(pt);
109 
110  double pi = TMath::Pi();
111  double p = phi-phi0;
112  if(p > pi) p = p - 2*pi;
113  if(p < -1*pi) p = p + 2*pi;
114  dnchdphi[cbin]->Fill(p);
115 
116  }
117 
118  return;
119 
120 }
121 
124 
125 
const double Pi
T getParameter(std::string const &) const
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void getData(T &iHolder) const
Definition: EventSetup.h:79
const Double_t pi
int iEvent
Definition: GenABIO.cc:230
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void tag(MonitorElement *, unsigned int)
Definition: DQMStore.cc:289
virtual ~HiBasicGenTest()
HiBasicGenTest(const edm::ParameterSet &)
#define end
Definition: vmac.h:37
HepPDT::ParticleData ParticleData
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:120
Geom::Phi< T > phi() const
#define begin
Definition: vmac.h:30
Definition: Run.h:42