CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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::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
 
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
 
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::DefaultRecord
pdtToken_
 
double ptCut_
 
const edm::EDPutTokenT
< edm::GenHIEvent
putToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
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< B > consumes (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 () noexcept
 
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...
 
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 ( 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 getUntrackedParameter(std::string const &, T const &) const
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 getParameter(std::string const &) const
Definition: ParameterSet.h:303
GenHIEventProducer::~GenHIEventProducer ( )
overridedefault

Member Function Documentation

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, SplitLinear::begin, RecoTauCleanerPlugins::charge, doParticleInfo_, edm::Event::emplace(), dataset::end, relval_parameters_module::energy, PVValHelper::eta, Exception, edm::Event::get(), edm::EventSetup::getData(), MixCollection< T >::getObject(), hepmcSrc_, reco_application_tbsim_DetSim-Digi_cfg::mix, np, npart, pdtToken_, phi, DiDispStaMuonMonitor_cfi::pt, ptCut_, putToken_, and MixCollection< T >::size().

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 }
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_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int np
Definition: AMPTWrapper.h:43
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
HepPDT::ParticleData ParticleData
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:433
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:118
string end
Definition: dataset.py:937

Member Data Documentation

const bool GenHIEventProducer::doParticleInfo_
private

Definition at line 61 of file GenHIEventProducer.cc.

Referenced by GenHIEventProducer(), and produce().

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

Definition at line 56 of file GenHIEventProducer.cc.

Referenced by produce().

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

Definition at line 57 of file GenHIEventProducer.cc.

Referenced by produce().

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

Definition at line 58 of file GenHIEventProducer.cc.

Referenced by produce().