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 (const std::string &iProcessName, std::vector< const char * > &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 76 of file GenHIEventProducer.cc.

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

77 {
78  produces<edm::GenHIEvent>();
79 
80  hepmcSrc_ = consumes<CrossingFrame<edm::HepMCProduct> >(iConfig.getParameter<edm::InputTag>("src"));
81 
82  doParticleInfo_ = iConfig.getUntrackedParameter<bool>("doParticleInfo",false);
83  if(doParticleInfo_){
84  ptCut_ = iConfig.getParameter<double> ("ptCut");
85  }
86 }
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 89 of file GenHIEventProducer.cc.

90 {
91 
92  // do anything here that needs to be done at desctruction time
93  // (e.g. close files, deallocate resources etc.)
94 
95 }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 104 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, reco::tau::helpers::nCharged(), np, npart, phi(), EnergyCorrector::pt, and edm::Event::put().

105 {
106  using namespace edm;
107 
108  if(!(pdt.isValid())) iSetup.getData(pdt);
109 
110  double b = -1;
111  int npart = -1;
112  int ncoll = 0;
113  int nhard = 0;
114  double phi = 0;
115  double ecc = -1;
116 
117  int nCharged = 0;
118  int nChargedMR = 0;
119  int nChargedPtCut = 0; // NchargedPtCut bym
120  int nChargedPtCutMR = 0; // NchargedPtCutMR bym
121 
122  double meanPt = 0;
123  double meanPtMR = 0;
124  double EtMR = 0; // Normalized of total energy bym
125  double TotEnergy = 0; // Total energy bym
126 
128 
129  iEvent.getByToken(hepmcSrc_,hepmc);
130  MixCollection<HepMCProduct> mix(hepmc.product());
131 
132  if(mix.size() < 1){
133  throw cms::Exception("MatchVtx")
134  <<"Mixing has "<<mix.size()<<" sub-events, should have been at least 1"
135  <<endl;
136  }
137 
138  // use the last event, bkg for embedding, signal in non-embedded
139  const HepMCProduct& hievt = mix.getObject(mix.size()-1);
140  const HepMC::GenEvent* evt = hievt.GetEvent();
141  if(doParticleInfo_){
142  HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
143  HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
144  for(HepMC::GenEvent::particle_const_iterator it = begin; it != end; ++it){
145  if((*it)->status() != 1) continue;
146  int pdg_id = (*it)->pdg_id();
147  const ParticleData * part = pdt->particle(pdg_id );
148  int charge = static_cast<int>(part->charge());
149 
150  if(charge == 0) continue;
151  float pt = (*it)->momentum().perp();
152  float eta = (*it)->momentum().eta();
153  float energy = (*it)->momentum().e(); // energy bym
154  //float energy = (*it)->momentum().energy(); // energy bym
155  nCharged++;
156  meanPt += pt;
157  // Get the total energy bym
158  if(fabs(eta)<1.0){
159  TotEnergy += energy;
160  }
161  if(pt>ptCut_){
162  nChargedPtCut++;
163  if(fabs(eta)<0.5){
164  nChargedPtCutMR++;
165  }
166  }
167  // end bym
168 
169  if(fabs(eta) > 0.5) continue;
170  nChargedMR++;
171  meanPtMR += pt;
172  }
173  }
174  const HepMC::HeavyIon* hi = evt->heavy_ion();
175 
176  if(hi){
177  ncoll = ncoll + hi->Ncoll();
178  nhard = nhard + hi->Ncoll_hard();
179  int np = hi->Npart_proj() + hi->Npart_targ();
180  if(np >= 0){
181  npart = np;
182  b = hi->impact_parameter();
183  phi = hi->event_plane_angle();
184  ecc = hi->eccentricity();
185  }
186  }
187 
188  // Get the normalized total energy bym
189  if(TotEnergy != 0){
190  EtMR = TotEnergy/2;
191  }
192 
193  if(nChargedMR != 0){
194  meanPtMR /= nChargedMR;
195  }
196  if(nCharged != 0){
197  meanPt /= nCharged;
198  }
199 
200  std::auto_ptr<edm::GenHIEvent> pGenHI(new edm::GenHIEvent(b,
201  npart,
202  ncoll,
203  nhard,
204  phi,
205  ecc,
206  nCharged,
207  nChargedMR,
208  meanPt,
209  meanPtMR,
210  EtMR,
211  nChargedPtCut,
212  nChargedPtCutMR
213  ));
214 
215  iEvent.put(pGenHI);
216 
217 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > hepmcSrc_
edm::ESHandle< ParticleDataTable > pdt
double npart
Definition: HydjetWrapper.h:44
void getData(T &iHolder) const
Definition: EventSetup.h:78
int np
Definition: AMPTWrapper.h:33
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
#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 61 of file GenHIEventProducer.cc.

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

Definition at line 57 of file GenHIEventProducer.cc.

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

Definition at line 58 of file GenHIEventProducer.cc.

double GenHIEventProducer::ptCut_
private

Definition at line 60 of file GenHIEventProducer.cc.