CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenHIEventProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: GenHIEventProducer
4 // Class: GenHIEventProducer
5 //
13 //
14 // Original Author: Yetkin Yilmaz
15 // Created: Thu Aug 13 08:39:51 EDT 2009
16 // $Id: GenHIEventProducer.cc,v 1.7 2010/08/18 16:45:26 yilmaz Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 #include <string>
24 #include <iostream>
25 
26 // user include files
30 
33 
36 
39 
40 #include "HepMC/HeavyIon.h"
43 using namespace std;
44 
45 //
46 // class decleration
47 //
48 
50  public:
51  explicit GenHIEventProducer(const edm::ParameterSet&);
53 
54  private:
55  virtual void produce(edm::Event&, const edm::EventSetup&);
56  std::vector<std::string> hepmcSrc_;
58 
59  double ptCut_;
61 };
62 
63 //
64 // constants, enums and typedefs
65 //
66 
67 
68 //
69 // static data member definitions
70 //
71 
72 //
73 // constructors and destructor
74 //
76 {
77  produces<edm::GenHIEvent>();
78  hepmcSrc_ = iConfig.getParameter<std::vector<std::string> >("generators");
79  doParticleInfo_ = iConfig.getUntrackedParameter<bool>("doParticleInfo",false);
80  if(doParticleInfo_){
81  ptCut_ = iConfig.getUntrackedParameter<double> ("ptCut",1.);
82  }
83 }
84 
85 
87 {
88 
89  // do anything here that needs to be done at desctruction time
90  // (e.g. close files, deallocate resources etc.)
91 
92 }
93 
94 
95 //
96 // member functions
97 //
98 
99 // ------------ method called to produce the data ------------
100  void
102 {
103  using namespace edm;
104 
105  if(!(pdt.isValid())) iSetup.getData(pdt);
106 
107  double b = -1;
108  int npart = -1;
109  int ncoll = 0;
110  int nhard = 0;
111  double phi = 0;
112  double ecc = -1;
113 
114  int nCharged = 0;
115  int nChargedMR = 0;
116  int nChargedPtCut = 0; // NchargedPtCut bym
117  int nChargedPtCutMR = 0; // NchargedPtCutMR bym
118 
119  double meanPt = 0;
120  double meanPtMR = 0;
121  double EtMR = 0; // Normalized of total energy bym
122  double TotEnergy = 0; // Total energy bym
123 
124  for(size_t ihep = 0; ihep < hepmcSrc_.size(); ++ihep){
126  iEvent.getByLabel(hepmcSrc_[ihep],hepmc);
127 
128  const HepMC::GenEvent* evt = hepmc->GetEvent();
129  if(doParticleInfo_){
130  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
131  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
132  for(HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it){
133  if((*it)->status() != 1) continue;
134  int pdg_id = (*it)->pdg_id();
135  const ParticleData * part = pdt->particle(pdg_id );
136  int charge = static_cast<int>(part->charge());
137 
138  if(charge == 0) continue;
139  float pt = (*it)->momentum().perp();
140  float eta = (*it)->momentum().eta();
141  float energy = (*it)->momentum().e(); // energy bym
142  //float energy = (*it)->momentum().energy(); // energy bym
143  nCharged++;
144  meanPt += pt;
145  // Get the total energy bym
146  if(fabs(eta)<1.0){
147  TotEnergy += energy;
148  }
149  if(pt>ptCut_){
150  nChargedPtCut++;
151  if(fabs(eta)<0.5){
152  nChargedPtCutMR++;
153  }
154  }
155  // end bym
156 
157  if(fabs(eta) > 0.5) continue;
158  nChargedMR++;
159  meanPtMR += pt;
160  }
161  }
162  const HepMC::HeavyIon* hi = evt->heavy_ion();
163 
164  if(hi){
165  ncoll = ncoll + hi->Ncoll();
166  nhard = nhard + hi->Ncoll_hard();
167  int np = hi->Npart_proj() + hi->Npart_targ();
168  if(np >= 0){
169  npart = np;
170  b = hi->impact_parameter();
171  phi = hi->event_plane_angle();
172  ecc = hi->eccentricity();
173  }
174  }
175  }
176  // Get the normalized total energy bym
177  if(TotEnergy != 0){
178  EtMR = TotEnergy/2;
179  }
180 
181  if(nChargedMR != 0){
182  meanPtMR /= nChargedMR;
183  }
184  if(nCharged != 0){
185  meanPt /= nCharged;
186  }
187 
188  std::auto_ptr<edm::GenHIEvent> pGenHI(new edm::GenHIEvent(b,
189  npart,
190  ncoll,
191  nhard,
192  phi,
193  ecc,
194  nCharged,
195  nChargedMR,
196  meanPt,
197  meanPtMR,
198  EtMR,
199  nChargedPtCut,
200  nChargedPtCutMR
201  ));
202 
203  iEvent.put(pGenHI);
204 
205 }
206 
207 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::ESHandle< ParticleDataTable > pdt
double npart
Definition: HydjetWrapper.h:45
T eta() const
double charge(const std::vector< uint8_t > &Ampls)
void getData(T &iHolder) const
Definition: EventSetup.h:67
int iEvent
Definition: GenABIO.cc:243
int np
Definition: AMPTWrapper.h:33
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
std::vector< std::string > hepmcSrc_
#define end
Definition: vmac.h:38
HepPDT::ParticleData ParticleData
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void produce(edm::Event &, const edm::EventSetup &)
unsigned int nCharged(const GenJet &jet)
part
Definition: HCALResponse.h:21
double b
Definition: hdecay.h:120
#define begin
Definition: vmac.h:31
GenHIEventProducer(const edm::ParameterSet &)
Definition: DDAxes.h:10