CMS 3D CMS Logo

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 () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

bool doParticleInfo_
 
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
 
edm::ESHandle< ParticleDataTablepdt
 
double ptCut_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 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_ = consumes<CrossingFrame<edm::HepMCProduct> >(iConfig.getParameter<edm::InputTag>("src"));
79  doParticleInfo_ = iConfig.getUntrackedParameter<bool>("doParticleInfo",false);
80  if(doParticleInfo_){
81  ptCut_ = iConfig.getParameter<double> ("ptCut");
82  }
83 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
GenHIEventProducer::~GenHIEventProducer ( )
override

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 
)
overrideprivate

Definition at line 101 of file GenHIEventProducer.cc.

References b, begin, ALCARECOTkAlJpsiMuMu_cff::charge, DEFINE_FWK_MODULE, end, randomXiThetaGunProducer_cfi::energy, PVValHelper::eta, Exception, edm::Event::getByToken(), edm::EventSetup::getData(), edm::HepMCProduct::GetEvent(), ecalTB2006H4_GenSimDigiReco_cfg::mix, eostools::move(), hpstanc_transforms::nCharged, np, npart, HiggsValidation_cfi::pdg_id, edm::Handle< T >::product(), EnergyCorrector::pt, 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 
125  iEvent.getByToken(hepmcSrc_,hepmc);
127 
128  if(mix.size() < 1){
129  throw cms::Exception("MatchVtx")
130  <<"Mixing has "<<mix.size()<<" sub-events, should have been at least 1"
131  <<endl;
132  }
133 
134  const HepMCProduct& hievt = mix.getObject(mix.size()-1);
135  const HepMC::GenEvent* evt = hievt.GetEvent();
136  if(doParticleInfo_){
137  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
138  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
139  for(HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it){
140  if((*it)->status() != 1) continue;
141  int pdg_id = (*it)->pdg_id();
142  const ParticleData * part = pdt->particle(pdg_id );
143  int charge = static_cast<int>(part->charge());
144 
145  if(charge == 0) continue;
146  float pt = (*it)->momentum().perp();
147  float eta = (*it)->momentum().eta();
148  float energy = (*it)->momentum().e(); // energy bym
149  //float energy = (*it)->momentum().energy(); // energy bym
150  nCharged++;
151  meanPt += pt;
152  // Get the total energy bym
153  if(fabs(eta)<1.0){
154  TotEnergy += energy;
155  }
156  if(pt>ptCut_){
157  nChargedPtCut++;
158  if(fabs(eta)<0.5){
159  nChargedPtCutMR++;
160  }
161  }
162  // end bym
163 
164  if(fabs(eta) > 0.5) continue;
165  nChargedMR++;
166  meanPtMR += pt;
167  }
168  }
169  const HepMC::HeavyIon* hi = evt->heavy_ion();
170 
171  if(hi){
172  ncoll = ncoll + hi->Ncoll();
173  nhard = nhard + hi->Ncoll_hard();
174  int np = hi->Npart_proj() + hi->Npart_targ();
175  if(np >= 0){
176  npart = np;
177  b = hi->impact_parameter();
178  phi = hi->event_plane_angle();
179  ecc = hi->eccentricity();
180  }
181  }
182 
183  // Get the normalized total energy bym
184  if(TotEnergy != 0){
185  EtMR = TotEnergy/2;
186  }
187 
188  if(nChargedMR != 0){
189  meanPtMR /= nChargedMR;
190  }
191  if(nCharged != 0){
192  meanPt /= nCharged;
193  }
194 
195  std::unique_ptr<edm::GenHIEvent> pGenHI(new edm::GenHIEvent(b,
196  npart,
197  ncoll,
198  nhard,
199  phi,
200  ecc,
201  nCharged,
202  nChargedMR,
203  meanPt,
204  meanPtMR,
205  EtMR,
206  nChargedPtCut,
207  nChargedPtCutMR
208  ));
209 
210  iEvent.put(std::move(pGenHI));
211 
212 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
edm::ESHandle< ParticleDataTable > pdt
double npart
Definition: HydjetWrapper.h:49
bool getData(T &iHolder) const
Definition: EventSetup.h:111
int np
Definition: AMPTWrapper.h:33
#define end
Definition: vmac.h:39
HepPDT::ParticleData ParticleData
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
T const * product() const
Definition: Handle.h:74
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:120
#define begin
Definition: vmac.h:32
HLT enums.
bool isValid() const
Definition: ESHandle.h:44
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

bool GenHIEventProducer::doParticleInfo_
private

Definition at line 60 of file GenHIEventProducer.cc.

edm::EDGetTokenT<CrossingFrame<edm::HepMCProduct> > 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