test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GenHIEventProducer (const edm::ParameterSet &)
 
 ~GenHIEventProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual 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
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)
 
- 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 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 ( )

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

Implements edm::EDProducer.

Definition at line 101 of file GenHIEventProducer.cc.

References b, begin, RecoTauCleanerPlugins::charge, end, relval_parameters_module::energy, eta, Exception, edm::Event::getByToken(), edm::EventSetup::getData(), reco_application_tbsim_DetSim-Digi_cfg::mix, eostools::move(), reco::tau::helpers::nCharged(), np, npart, phi(), 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);
126  MixCollection<HepMCProduct> mix(hepmc.product());
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 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
edm::ESHandle< ParticleDataTable > pdt
double npart
Definition: HydjetWrapper.h:49
void getData(T &iHolder) const
Definition: EventSetup.h:79
int np
Definition: AMPTWrapper.h:33
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
def move
Definition: eostools.py:510
#define end
Definition: vmac.h:37
HepPDT::ParticleData ParticleData
unsigned int nCharged(const GenJet &jet)
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:120
#define begin
Definition: vmac.h:30
bool isValid() const
Definition: ESHandle.h:47

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

Definition at line 59 of file GenHIEventProducer.cc.