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
 
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::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
 
edm::ESGetToken< ParticleDataTable, edm::DefaultRecordpdtToken_
 
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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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 49 of file GenHIEventProducer.cc.

Constructor & Destructor Documentation

◆ GenHIEventProducer()

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

Definition at line 75 of file GenHIEventProducer.cc.

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

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

◆ ~GenHIEventProducer()

GenHIEventProducer::~GenHIEventProducer ( )
override

Definition at line 85 of file GenHIEventProducer.cc.

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

Member Function Documentation

◆ produce()

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

Implements edm::EDProducer.

Definition at line 95 of file GenHIEventProducer.cc.

95  {
96  using namespace edm;
97 
98  if (!(pdt.isValid())) {
99  pdt = iSetup.getHandle(pdtToken_);
100  }
101 
102  double b = -1;
103  int npart = -1;
104  int ncoll = 0;
105  int nhard = 0;
106  double phi = 0;
107  double ecc = -1;
108 
109  int nCharged = 0;
110  int nChargedMR = 0;
111  int nChargedPtCut = 0; // NchargedPtCut bym
112  int nChargedPtCutMR = 0; // NchargedPtCutMR bym
113 
114  double meanPt = 0;
115  double meanPtMR = 0;
116  double EtMR = 0; // Normalized of total energy bym
117  double TotEnergy = 0; // Total energy bym
118 
120  iEvent.getByToken(hepmcSrc_, hepmc);
122 
123  if (mix.size() < 1) {
124  throw cms::Exception("MatchVtx") << "Mixing has " << mix.size() << " sub-events, should have been at least 1"
125  << endl;
126  }
127 
128  const HepMCProduct& hievt = mix.getObject(mix.size() - 1);
129  const HepMC::GenEvent* evt = hievt.GetEvent();
130  if (doParticleInfo_) {
131  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
132  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
133  for (HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it) {
134  if ((*it)->status() != 1)
135  continue;
136  int pdg_id = (*it)->pdg_id();
137  const ParticleData* part = pdt->particle(pdg_id);
138  int charge = static_cast<int>(part->charge());
139 
140  if (charge == 0)
141  continue;
142  float pt = (*it)->momentum().perp();
143  float eta = (*it)->momentum().eta();
144  float energy = (*it)->momentum().e(); // energy bym
145  //float energy = (*it)->momentum().energy(); // energy bym
146  nCharged++;
147  meanPt += pt;
148  // Get the total energy bym
149  if (fabs(eta) < 1.0) {
150  TotEnergy += energy;
151  }
152  if (pt > ptCut_) {
153  nChargedPtCut++;
154  if (fabs(eta) < 0.5) {
155  nChargedPtCutMR++;
156  }
157  }
158  // end bym
159 
160  if (fabs(eta) > 0.5)
161  continue;
162  nChargedMR++;
163  meanPtMR += pt;
164  }
165  }
166  const HepMC::HeavyIon* hi = evt->heavy_ion();
167 
168  if (hi) {
169  ncoll = ncoll + hi->Ncoll();
170  nhard = nhard + hi->Ncoll_hard();
171  int np = hi->Npart_proj() + hi->Npart_targ();
172  if (np >= 0) {
173  npart = np;
174  b = hi->impact_parameter();
175  phi = hi->event_plane_angle();
176  ecc = hi->eccentricity();
177  }
178  }
179 
180  // Get the normalized total energy bym
181  if (TotEnergy != 0) {
182  EtMR = TotEnergy / 2;
183  }
184 
185  if (nChargedMR != 0) {
186  meanPtMR /= nChargedMR;
187  }
188  if (nCharged != 0) {
189  meanPt /= nCharged;
190  }
191 
192  std::unique_ptr<edm::GenHIEvent> pGenHI(new edm::GenHIEvent(
193  b, npart, ncoll, nhard, phi, ecc, nCharged, nChargedMR, meanPt, meanPtMR, EtMR, nChargedPtCut, nChargedPtCutMR));
194 
195  iEvent.put(std::move(pGenHI));
196 }

References b, ALCARECOTkAlJpsiMuMu_cff::charge, mps_fire::end, HCALHighEnergyHPDFilter_cfi::energy, PVValHelper::eta, Exception, edm::HepMCProduct::GetEvent(), edm::EventSetup::getHandle(), iEvent, GeneratorMix_cff::mix, eostools::move(), HLT_FULL_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 61 of file GenHIEventProducer.cc.

◆ hepmcSrc_

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

Definition at line 56 of file GenHIEventProducer.cc.

◆ pdt

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

Definition at line 57 of file GenHIEventProducer.cc.

◆ pdtToken_

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

Definition at line 58 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
HLT_FULL_cff.nCharged
nCharged
Definition: HLT_FULL_cff.py:33318
GenHIEventProducer::ptCut_
double ptCut_
Definition: GenHIEventProducer.cc:60
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm
HLT enums.
Definition: AlignableModifier.h:19
np
int np
Definition: AMPTWrapper.h:43
GenHIEventProducer::pdt
edm::ESHandle< ParticleDataTable > pdt
Definition: GenHIEventProducer.cc:57
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
npart
double npart
Definition: HydjetWrapper.h:46
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:61
MixCollection
Definition: MixCollection.h:11
PVValHelper::eta
Definition: PVValidationHelpers.h:69
mps_fire.end
end
Definition: mps_fire.py:242
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::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
DDAxes::phi
hi
Definition: EPCuts.h:4
eostools.move
def move(src, dest)
Definition: eostools.py:511
GenHIEventProducer::pdtToken_
edm::ESGetToken< ParticleDataTable, edm::DefaultRecord > pdtToken_
Definition: GenHIEventProducer.cc:58
Exception
Definition: hltDiff.cc:246
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::HepMCProduct
Definition: HepMCProduct.h:18
GeneratorMix_cff.mix
mix
Definition: GeneratorMix_cff.py:6
edm::InputTag
Definition: InputTag.h:15
GenHIEventProducer::hepmcSrc_
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
Definition: GenHIEventProducer.cc:56