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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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::GenHIEventProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 73 of file GenHIEventProducer.cc.

73  {
74  produces<edm::GenHIEvent>();
75  hepmcSrc_ = consumes<CrossingFrame<edm::HepMCProduct> >(iConfig.getParameter<edm::InputTag>("src"));
76  doParticleInfo_ = iConfig.getUntrackedParameter<bool>("doParticleInfo", false);
77  if (doParticleInfo_) {
78  ptCut_ = iConfig.getParameter<double>("ptCut");
79  }
80 }

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

◆ ~GenHIEventProducer()

GenHIEventProducer::~GenHIEventProducer ( )
override

Definition at line 82 of file GenHIEventProducer.cc.

82  {
83  // do anything here that needs to be done at desctruction time
84  // (e.g. close files, deallocate resources etc.)
85 }

Member Function Documentation

◆ produce()

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

Implements edm::EDProducer.

Definition at line 92 of file GenHIEventProducer.cc.

92  {
93  using namespace edm;
94 
95  if (!(pdt.isValid()))
96  iSetup.getData(pdt);
97 
98  double b = -1;
99  int npart = -1;
100  int ncoll = 0;
101  int nhard = 0;
102  double phi = 0;
103  double ecc = -1;
104 
105  int nCharged = 0;
106  int nChargedMR = 0;
107  int nChargedPtCut = 0; // NchargedPtCut bym
108  int nChargedPtCutMR = 0; // NchargedPtCutMR bym
109 
110  double meanPt = 0;
111  double meanPtMR = 0;
112  double EtMR = 0; // Normalized of total energy bym
113  double TotEnergy = 0; // Total energy bym
114 
116  iEvent.getByToken(hepmcSrc_, hepmc);
118 
119  if (mix.size() < 1) {
120  throw cms::Exception("MatchVtx") << "Mixing has " << mix.size() << " sub-events, should have been at least 1"
121  << endl;
122  }
123 
124  const HepMCProduct& hievt = mix.getObject(mix.size() - 1);
125  const HepMC::GenEvent* evt = hievt.GetEvent();
126  if (doParticleInfo_) {
127  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
128  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
129  for (HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it) {
130  if ((*it)->status() != 1)
131  continue;
132  int pdg_id = (*it)->pdg_id();
133  const ParticleData* part = pdt->particle(pdg_id);
134  int charge = static_cast<int>(part->charge());
135 
136  if (charge == 0)
137  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)
157  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::unique_ptr<edm::GenHIEvent> pGenHI(new edm::GenHIEvent(
189  b, npart, ncoll, nhard, phi, ecc, nCharged, nChargedMR, meanPt, meanPtMR, EtMR, nChargedPtCut, nChargedPtCutMR));
190 
191  iEvent.put(std::move(pGenHI));
192 }

References b, begin, ALCARECOTkAlJpsiMuMu_cff::charge, end, HCALHighEnergyHPDFilter_cfi::energy, PVValHelper::eta, Exception, edm::EventSetup::getData(), edm::HepMCProduct::GetEvent(), iEvent, GeneratorMix_cff::mix, eostools::move(), HLT_2018_cff::nCharged, np, npart, HiggsValidation_cfi::pdg_id, edm::Handle< T >::product(), and DiDispStaMuonMonitor_cfi::pt.

Member Data Documentation

◆ doParticleInfo_

bool GenHIEventProducer::doParticleInfo_
private

Definition at line 59 of file GenHIEventProducer.cc.

◆ hepmcSrc_

edm::EDGetTokenT<CrossingFrame<edm::HepMCProduct> > GenHIEventProducer::hepmcSrc_
private

Definition at line 55 of file GenHIEventProducer.cc.

◆ pdt

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

Definition at line 56 of file GenHIEventProducer.cc.

◆ ptCut_

double GenHIEventProducer::ptCut_
private
HiggsValidation_cfi.pdg_id
pdg_id
Definition: HiggsValidation_cfi.py:6
edm::Handle::product
T const * product() const
Definition: Handle.h:70
GenHIEventProducer::ptCut_
double ptCut_
Definition: GenHIEventProducer.cc:58
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_2018_cff.nCharged
nCharged
Definition: HLT_2018_cff.py:31800
np
int np
Definition: AMPTWrapper.h:43
GenHIEventProducer::pdt
edm::ESHandle< ParticleDataTable > pdt
Definition: GenHIEventProducer.cc:56
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
npart
double npart
Definition: HydjetWrapper.h:46
end
#define end
Definition: vmac.h:39
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
ParticleData
HepPDT::ParticleData ParticleData
Definition: ParticleDataTable.h:9
edm::GenHIEvent
Definition: GenHIEvent.h:8
part
part
Definition: HCALResponse.h:20
GenHIEventProducer::doParticleInfo_
bool doParticleInfo_
Definition: GenHIEventProducer.cc:59
MixCollection
Definition: MixCollection.h:11
PVValHelper::eta
Definition: PVValidationHelpers.h:69
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
b
double b
Definition: hdecay.h:118
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:113
DDAxes::phi
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
hi
Definition: HiEvtPlaneList.h:38
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
edm::HepMCProduct
Definition: HepMCProduct.h:18
GeneratorMix_cff.mix
mix
Definition: GeneratorMix_cff.py:6
edm::InputTag
Definition: InputTag.h:15
begin
#define begin
Definition: vmac.h:32
GenHIEventProducer::hepmcSrc_
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
Definition: GenHIEventProducer.cc:55