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  dbe = 0;
20  dbe = edm::Service<DQMStore>().operator->();
21  generatorToken_ = consumes<edm::HepMCProduct> (
22  iPSet.getParameter<edm::InputTag>("generatorLabel"));
23 }
24 
26 
28 {
29  if(dbe){
31  dbe->setCurrentFolder("Generator/Particles");
32 
34  for(int ibin=0; ibin<3; ibin++) {
35  dnchdeta[ibin] = dbe->book1D(Form("dnchdeta%d",ibin), ";#eta;dN^{ch}/d#eta", 100, -6.0, 6.0);
36  dnchdpt[ibin] = dbe->book1D(Form("dnchdpt%d",ibin), ";p_{T};dN^{ch}/dp_{T}", 200, 0.0, 100.0);
37  b[ibin] = dbe->book1D(Form("b%d",ibin),";b[fm];events",100, 0.0, 20.0);
38  dnchdphi[ibin] = dbe->book1D(Form("dnchdphi%d",ibin),";#phi;dN^{ch}/d#phi",100, -3.2, 3.2);
39 
40  dbe->tag(dnchdeta[ibin]->getFullname(),1+ibin*4);
41  dbe->tag(dnchdpt[ibin]->getFullname(),2+ibin*4);
42  dbe->tag(b[ibin]->getFullname(),3+ibin*4);
43  dbe->tag(dnchdphi[ibin]->getFullname(),4+ibin*4);
44  }
45 
46  rp = dbe->book1D("phi0",";#phi_{RP};events",100,-3.2,3.2);
47  dbe->tag(rp->getFullname(),13);
48 
49 
50  }
51  return;
52 }
53 
55  // normalization of histograms can be done here (or in post-processor)
56  return;
57 }
58 
59 void HiBasicGenTest::beginRun(const edm::Run& iRun,const edm::EventSetup& iSetup)
60 {
61  iSetup.getData(pdt);
62  return;
63 }
64 
65 void HiBasicGenTest::endRun(const edm::Run& iRun,const edm::EventSetup& iSetup){return;}
66 
68 {
69 
71  iEvent.getByToken(generatorToken_, mc);
72  const HepMC::GenEvent *evt = mc->GetEvent();
73  const HepMC::HeavyIon *hi = evt->heavy_ion();
74 
75  double ip = 0;
76  double phi0 = 0;
77  if ( hi ) {
78  ip = hi->impact_parameter();
79  phi0 = hi->event_plane_angle();
80  }
81 
82  // fill reaction plane distribution
83  rp->Fill(phi0);
84 
85  // if the event is in one of the centrality bins of interest fill hists
86  int cbin=-1;
87  if(ip < 5.045) cbin=0;
88  else if (ip < 7.145 && ip > 5.045) cbin=1;
89  else if (ip < 15.202 && ip > 14.283) cbin=2;
90  if(cbin<0) return;
91 
92  // fill impact parameter distributions
93  b[cbin]->Fill(ip);
94 
95  // loop over particles
96  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
97  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
98  for(HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it){
99 
100  // only fill hists for status=1 particles
101  if((*it)->status() != 1) continue;
102 
103  // only fill hists for charged particles
104  int pdg_id = (*it)->pdg_id();
105  const ParticleData * part = pdt->particle(pdg_id);
106  int charge = static_cast<int>(part->charge());
107  if(charge==0) continue;
108 
109  float eta = (*it)->momentum().eta();
110  float phi = (*it)->momentum().phi();
111  float pt = (*it)->momentum().perp();
112 
113  dnchdeta[cbin]->Fill(eta);
114  dnchdpt[cbin]->Fill(pt);
115 
116  double pi = TMath::Pi();
117  double p = phi-phi0;
118  if(p > pi) p = p - 2*pi;
119  if(p < -1*pi) p = p + 2*pi;
120  dnchdphi[cbin]->Fill(p);
121 
122  }
123 
124  return;
125 
126 }
127 
130 
131 
const double Pi
virtual void analyze(const edm::Event &, const edm::EventSetup &)
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
virtual void beginJob()
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
DEFINE_FWK_MODULE(HiMixingModule)
T eta() const
virtual void endJob()
void getData(T &iHolder) const
Definition: EventSetup.h:78
const Double_t pi
virtual void endRun(const edm::Run &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
virtual ~HiBasicGenTest()
HiBasicGenTest(const edm::ParameterSet &)
#define end
Definition: vmac.h:37
HepPDT::ParticleData ParticleData
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:120
#define begin
Definition: vmac.h:30
Definition: Run.h:41
Definition: DDAxes.h:10