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::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GenHIEventProducer (const edm::ParameterSet &)
 
 ~GenHIEventProducer () override=default
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

const bool doParticleInfo_
 
const edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
 
const edm::ESGetToken< ParticleDataTable, edm::DefaultRecordpdtToken_
 
double ptCut_
 
const edm::EDPutTokenT< edm::GenHIEventputToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

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

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

Definition at line 49 of file GenHIEventProducer.cc.

Constructor & Destructor Documentation

◆ GenHIEventProducer()

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

Definition at line 67 of file GenHIEventProducer.cc.

References doParticleInfo_, edm::ParameterSet::getParameter(), and ptCut_.

69  pdtToken_(esConsumes<ParticleDataTable, edm::DefaultRecord>()),
70  putToken_(produces<edm::GenHIEvent>()),
71  doParticleInfo_(iConfig.getUntrackedParameter<bool>("doParticleInfo", false)) {
72  if (doParticleInfo_) {
73  ptCut_ = iConfig.getParameter<double>("ptCut");
74  }
75 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< ParticleDataTable, edm::DefaultRecord > pdtToken_
const edm::EDPutTokenT< edm::GenHIEvent > putToken_
const edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getUntrackedParameter(std::string const &, T const &) const

◆ ~GenHIEventProducer()

GenHIEventProducer::~GenHIEventProducer ( )
overridedefault

Member Function Documentation

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 82 of file GenHIEventProducer.cc.

References b, ALCARECOTkAlJpsiMuMu_cff::charge, doParticleInfo_, mps_fire::end, HCALHighEnergyHPDFilter_cfi::energy, PVValHelper::eta, Exception, edm::EventSetup::getData(), hepmcSrc_, iEvent, GeneratorMix_cff::mix, HLT_2023v11_cff::nCharged, np, npart, HiggsValidation_cfi::pdg_id, pdtToken_, phi, DiDispStaMuonMonitor_cfi::pt, ptCut_, and putToken_.

82  {
83  using namespace edm;
84 
85  const auto& pdt = iSetup.getData(pdtToken_);
86 
87  double b = -1;
88  int npart = -1;
89  int ncoll = 0;
90  int nhard = 0;
91  double phi = 0;
92  double ecc = -1;
93 
94  int nCharged = 0;
95  int nChargedMR = 0;
96  int nChargedPtCut = 0; // NchargedPtCut bym
97  int nChargedPtCutMR = 0; // NchargedPtCutMR bym
98 
99  double meanPt = 0;
100  double meanPtMR = 0;
101  double EtMR = 0; // Normalized of total energy bym
102  double TotEnergy = 0; // Total energy bym
103 
104  const auto& hepmc = iEvent.get(hepmcSrc_);
106 
107  if (mix.size() < 1) {
108  throw cms::Exception("MatchVtx") << "Mixing has " << mix.size() << " sub-events, should have been at least 1"
109  << endl;
110  }
111 
112  const HepMCProduct& hievt = mix.getObject(mix.size() - 1);
113  const HepMC::GenEvent* evt = hievt.GetEvent();
114  if (doParticleInfo_) {
115  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
116  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
117  for (HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it) {
118  if ((*it)->status() != 1)
119  continue;
120  int pdg_id = (*it)->pdg_id();
121  const ParticleData* part = pdt.particle(pdg_id);
122  int charge = static_cast<int>(part->charge());
123 
124  if (charge == 0)
125  continue;
126  float pt = (*it)->momentum().perp();
127  float eta = (*it)->momentum().eta();
128  float energy = (*it)->momentum().e(); // energy bym
129  //float energy = (*it)->momentum().energy(); // energy bym
130  nCharged++;
131  meanPt += pt;
132  // Get the total energy bym
133  if (fabs(eta) < 1.0) {
134  TotEnergy += energy;
135  }
136  if (pt > ptCut_) {
137  nChargedPtCut++;
138  if (fabs(eta) < 0.5) {
139  nChargedPtCutMR++;
140  }
141  }
142  // end bym
143 
144  if (fabs(eta) > 0.5)
145  continue;
146  nChargedMR++;
147  meanPtMR += pt;
148  }
149  }
150  const HepMC::HeavyIon* hi = evt->heavy_ion();
151 
152  if (hi) {
153  ncoll = ncoll + hi->Ncoll();
154  nhard = nhard + hi->Ncoll_hard();
155  int np = hi->Npart_proj() + hi->Npart_targ();
156  if (np >= 0) {
157  npart = np;
158  b = hi->impact_parameter();
159  phi = hi->event_plane_angle();
160  ecc = hi->eccentricity();
161  }
162  }
163 
164  // Get the normalized total energy bym
165  if (TotEnergy != 0) {
166  EtMR = TotEnergy / 2;
167  }
168 
169  if (nChargedMR != 0) {
170  meanPtMR /= nChargedMR;
171  }
172  if (nCharged != 0) {
173  meanPt /= nCharged;
174  }
175 
176  iEvent.emplace(putToken_,
177  b,
178  npart,
179  ncoll,
180  nhard,
181  phi,
182  ecc,
183  nCharged,
184  nChargedMR,
185  meanPt,
186  meanPtMR,
187  EtMR,
188  nChargedPtCut,
189  nChargedPtCutMR);
190 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
double npart
Definition: HydjetWrapper.h:46
const edm::ESGetToken< ParticleDataTable, edm::DefaultRecord > pdtToken_
const edm::EDPutTokenT< edm::GenHIEvent > putToken_
const edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
int iEvent
Definition: GenABIO.cc:224
int np
Definition: AMPTWrapper.h:43
Definition: EPCuts.h:4
HepPDT::ParticleData ParticleData
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:118
HLT enums.

Member Data Documentation

◆ doParticleInfo_

const bool GenHIEventProducer::doParticleInfo_
private

Definition at line 61 of file GenHIEventProducer.cc.

Referenced by GenHIEventProducer(), and produce().

◆ hepmcSrc_

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

Definition at line 56 of file GenHIEventProducer.cc.

Referenced by produce().

◆ pdtToken_

const edm::ESGetToken<ParticleDataTable, edm::DefaultRecord> GenHIEventProducer::pdtToken_
private

Definition at line 57 of file GenHIEventProducer.cc.

Referenced by produce().

◆ ptCut_

double GenHIEventProducer::ptCut_
private

◆ putToken_

const edm::EDPutTokenT<edm::GenHIEvent> GenHIEventProducer::putToken_
private

Definition at line 58 of file GenHIEventProducer.cc.

Referenced by produce().