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