CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
GenHIEventProducer Class Reference

#include <yetkin/GenHIEventProducer/src/GenHIEventProducer.cc>

Inheritance diagram for GenHIEventProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 GenHIEventProducer (const edm::ParameterSet &)
 
 ~GenHIEventProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

bool doParticleInfo_
 
std::vector< std::string > hepmcSrc_
 
edm::ESHandle< ParticleDataTablepdt
 
double ptCut_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 49 of file GenHIEventProducer.cc.

Constructor & Destructor Documentation

GenHIEventProducer::GenHIEventProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 75 of file GenHIEventProducer.cc.

References edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

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 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > hepmcSrc_
GenHIEventProducer::~GenHIEventProducer ( )

Definition at line 86 of file GenHIEventProducer.cc.

87 {
88 
89  // do anything here that needs to be done at desctruction time
90  // (e.g. close files, deallocate resources etc.)
91 
92 }

Member Function Documentation

void GenHIEventProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 101 of file GenHIEventProducer.cc.

References b, begin, DeDxDiscriminatorTools::charge(), end, relval_parameters_module::energy, eta(), edm::Event::getByLabel(), edm::EventSetup::getData(), reco::tau::helpers::nCharged(), runTheMatrix::np, npart, phi, and edm::Event::put().

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 }
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
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:355
unsigned int nCharged(const GenJet &jet)
part
Definition: HCALResponse.h:21
double b
Definition: hdecay.h:120
#define begin
Definition: vmac.h:31
bool isValid() const
Definition: ESHandle.h:37
Definition: DDAxes.h:10

Member Data Documentation

bool GenHIEventProducer::doParticleInfo_
private

Definition at line 60 of file GenHIEventProducer.cc.

std::vector<std::string> GenHIEventProducer::hepmcSrc_
private

Definition at line 56 of file GenHIEventProducer.cc.

edm::ESHandle< ParticleDataTable > GenHIEventProducer::pdt
private

Definition at line 57 of file GenHIEventProducer.cc.

double GenHIEventProducer::ptCut_
private

Definition at line 59 of file GenHIEventProducer.cc.