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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GenHIEventProducer (const edm::ParameterSet &)
 
 ~GenHIEventProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

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
 
- 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)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

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

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

Definition at line 48 of file GenHIEventProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 74 of file GenHIEventProducer.cc.

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

75 {
76  produces<edm::GenHIEvent>();
77  hepmcSrc_ = iConfig.getParameter<std::vector<std::string> >("generators");
78  doParticleInfo_ = iConfig.getUntrackedParameter<bool>("doParticleInfo",false);
79  if(doParticleInfo_){
80  ptCut_ = iConfig.getUntrackedParameter<double> ("ptCut",1.);
81  }
82 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > hepmcSrc_
GenHIEventProducer::~GenHIEventProducer ( )

Definition at line 85 of file GenHIEventProducer.cc.

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

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 100 of file GenHIEventProducer.cc.

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

101 {
102  using namespace edm;
103 
104  if(!(pdt.isValid())) iSetup.getData(pdt);
105 
106  double b = -1;
107  int npart = -1;
108  int ncoll = 0;
109  int nhard = 0;
110  double phi = 0;
111  double ecc = -1;
112 
113  int nCharged = 0;
114  int nChargedMR = 0;
115  int nChargedPtCut = 0; // NchargedPtCut bym
116  int nChargedPtCutMR = 0; // NchargedPtCutMR bym
117 
118  double meanPt = 0;
119  double meanPtMR = 0;
120  double EtMR = 0; // Normalized of total energy bym
121  double TotEnergy = 0; // Total energy bym
122 
123  for(size_t ihep = 0; ihep < hepmcSrc_.size(); ++ihep){
125  iEvent.getByLabel(hepmcSrc_[ihep],hepmc);
126 
127  const HepMC::GenEvent* evt = hepmc->GetEvent();
128  if(doParticleInfo_){
129  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
130  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
131  for(HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it){
132  if((*it)->status() != 1) continue;
133  int pdg_id = (*it)->pdg_id();
134  const ParticleData * part = pdt->particle(pdg_id );
135  int charge = static_cast<int>(part->charge());
136 
137  if(charge == 0) continue;
138  float pt = (*it)->momentum().perp();
139  float eta = (*it)->momentum().eta();
140  float energy = (*it)->momentum().e(); // energy bym
141  //float energy = (*it)->momentum().energy(); // energy bym
142  nCharged++;
143  meanPt += pt;
144  // Get the total energy bym
145  if(fabs(eta)<1.0){
146  TotEnergy += energy;
147  }
148  if(pt>ptCut_){
149  nChargedPtCut++;
150  if(fabs(eta)<0.5){
151  nChargedPtCutMR++;
152  }
153  }
154  // end bym
155 
156  if(fabs(eta) > 0.5) continue;
157  nChargedMR++;
158  meanPtMR += pt;
159  }
160  }
161  const HepMC::HeavyIon* hi = evt->heavy_ion();
162 
163  if(hi){
164  ncoll = ncoll + hi->Ncoll();
165  nhard = nhard + hi->Ncoll_hard();
166  int np = hi->Npart_proj() + hi->Npart_targ();
167  if(np >= 0){
168  npart = np;
169  b = hi->impact_parameter();
170  phi = hi->event_plane_angle();
171  ecc = hi->eccentricity();
172  }
173  }
174  }
175  // Get the normalized total energy bym
176  if(TotEnergy != 0){
177  EtMR = TotEnergy/2;
178  }
179 
180  if(nChargedMR != 0){
181  meanPtMR /= nChargedMR;
182  }
183  if(nCharged != 0){
184  meanPt /= nCharged;
185  }
186 
187  std::auto_ptr<edm::GenHIEvent> pGenHI(new edm::GenHIEvent(b,
188  npart,
189  ncoll,
190  nhard,
191  phi,
192  ecc,
193  nCharged,
194  nChargedMR,
195  meanPt,
196  meanPtMR,
197  EtMR,
198  nChargedPtCut,
199  nChargedPtCutMR
200  ));
201 
202  iEvent.put(pGenHI);
203 
204 }
edm::ESHandle< ParticleDataTable > pdt
double npart
Definition: HydjetWrapper.h:44
T eta() const
void getData(T &iHolder) const
Definition: EventSetup.h:78
int np
Definition: AMPTWrapper.h:33
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
std::vector< std::string > hepmcSrc_
#define end
Definition: vmac.h:37
HepPDT::ParticleData ParticleData
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
unsigned int nCharged(const GenJet &jet)
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:120
#define begin
Definition: vmac.h:30
bool isValid() const
Definition: ESHandle.h:47
Definition: DDAxes.h:10

Member Data Documentation

bool GenHIEventProducer::doParticleInfo_
private

Definition at line 59 of file GenHIEventProducer.cc.

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

Definition at line 55 of file GenHIEventProducer.cc.

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

Definition at line 56 of file GenHIEventProducer.cc.

double GenHIEventProducer::ptCut_
private

Definition at line 58 of file GenHIEventProducer.cc.