CMS 3D CMS Logo

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  generatorToken_ = consumes<edm::HepMCProduct>(iPSet.getParameter<edm::InputTag>("generatorLabel"));
19  pdtToken_ = esConsumes<edm::Transition::BeginRun>();
20 }
21 
23 
26  ibooker.setCurrentFolder("Generator/Particles");
27 
29  for (int ibin = 0; ibin < 3; ibin++) {
30  dnchdeta[ibin] = ibooker.book1D(Form("dnchdeta%d", ibin), ";#eta;dN^{ch}/d#eta", 100, -6.0, 6.0);
31 
32  dnchdpt[ibin] = ibooker.book1D(Form("dnchdpt%d", ibin), ";p_{T};dN^{ch}/dp_{T}", 200, 0.0, 100.0);
33 
34  b[ibin] = ibooker.book1D(Form("b%d", ibin), ";b[fm];events", 100, 0.0, 20.0);
35  dnchdphi[ibin] = ibooker.book1D(Form("dnchdphi%d", ibin), ";#phi;dN^{ch}/d#phi", 100, -3.2, 3.2);
36  }
37 
38  rp = ibooker.book1D("phi0", ";#phi_{RP};events", 100, -3.2, 3.2);
39 }
40 
41 void HiBasicGenTest::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
42  pdt = iSetup.getHandle(pdtToken_);
43 }
44 
47  iEvent.getByToken(generatorToken_, mc);
48  const HepMC::GenEvent* evt = mc->GetEvent();
49  const HepMC::HeavyIon* hi = evt->heavy_ion();
50 
51  int cbin = 0;
52  double phi0 = 0.;
53 
54  if (hi) {
55  double ip = hi->impact_parameter();
56  phi0 = hi->event_plane_angle();
57 
58  // fill reaction plane distribution
59  rp->Fill(phi0);
60 
61  // if the event is in one of the centrality bins of interest fill hists
62  int cbin = -1;
63  if (ip < 5.045)
64  cbin = 0;
65  else if (ip < 7.145 && ip > 5.045)
66  cbin = 1;
67  else if (ip < 15.202 && ip > 14.283)
68  cbin = 2;
69  if (cbin < 0)
70  return;
71 
72  // fill impact parameter distributions
73  b[cbin]->Fill(ip);
74  }
75 
76  // loop over particles
77  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
78  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
79  for (HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it) {
80  // only fill hists for status=1 particles
81  if ((*it)->status() != 1)
82  continue;
83 
84  // only fill hists for charged particles
85  int pdg_id = (*it)->pdg_id();
86  const ParticleData* part = pdt->particle(pdg_id);
87  int charge = static_cast<int>(part->charge());
88  if (charge == 0)
89  continue;
90 
91  float eta = (*it)->momentum().eta();
92  float phi = (*it)->momentum().phi();
93  float pt = (*it)->momentum().perp();
94 
95  dnchdeta[cbin]->Fill(eta);
96  dnchdpt[cbin]->Fill(pt);
97 
98  double pi = TMath::Pi();
99  double p = phi - phi0;
100  if (p > pi)
101  p = p - 2 * pi;
102  if (p < -1 * pi)
103  p = p + 2 * pi;
104  dnchdphi[cbin]->Fill(p);
105  }
106 
107  return;
108 }
109 
const double Pi
void analyze(const edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const Double_t pi
int iEvent
Definition: GenABIO.cc:224
Definition: EPCuts.h:4
HiBasicGenTest(const edm::ParameterSet &)
HepPDT::ParticleData ParticleData
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:118
HLT enums.
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
~HiBasicGenTest() override
Definition: Run.h:45