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 
HiggsValidation_cfi.pdg_id
pdg_id
Definition: HiggsValidation_cfi.py:6
CaloTowersParam_cfi.mc
mc
Definition: CaloTowersParam_cfi.py:8
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
HiBasicGenTest
Definition: HiBasicGenTest.h:21
HiBasicGenTest::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: HiBasicGenTest.cc:42
edm::Handle
Definition: AssociativeIterator.h:50
end
#define end
Definition: vmac.h:39
HiBasicGenTest::~HiBasicGenTest
~HiBasicGenTest() override
Definition: HiBasicGenTest.cc:21
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
ParticleData
HepPDT::ParticleData ParticleData
Definition: ParticleDataTable.h:9
GenParticle.h
MakerMacros.h
part
part
Definition: HCALResponse.h:20
HiBasicGenTest::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: HiBasicGenTest.cc:23
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HiBasicGenTest.h
PVValHelper::eta
Definition: PVValidationHelpers.h:69
b
double b
Definition: hdecay.h:118
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::ParameterSet
Definition: ParameterSet.h:36
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:113
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
hi
Definition: HiEvtPlaneList.h:38
HiBasicGenTest::dqmBeginRun
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
Definition: HiBasicGenTest.cc:40
HepMC
Definition: GenParticle.h:15
HiBasicGenTest::HiBasicGenTest
HiBasicGenTest(const edm::ParameterSet &)
Definition: HiBasicGenTest.cc:17
dqm::implementation::IBooker
Definition: DQMStore.h:43
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
pi
const Double_t pi
Definition: trackSplitPlot.h:36
Candidate.h
HepMCProduct.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
begin
#define begin
Definition: vmac.h:32
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98