CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GenPUProtonProducer Class Reference
Inheritance diagram for GenPUProtonProducer:
edm::global::EDProducer< edm::RunCache< ConvertParticle > > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GenPUProtonProducer (const edm::ParameterSet &)
 
std::shared_ptr< ConvertParticle > globalBeginRun (const edm::Run &, const edm::EventSetup &) const override
 
void globalEndRun (edm::Run const &, edm::EventSetup const &) const override
 
void produce (edm::StreamID, edm::Event &e, const edm::EventSetup &) const override
 
 ~GenPUProtonProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer< edm::RunCache< ConvertParticle > >
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (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 Attributes

bool abortOnUnknownPDGCode_
 
std::vector< int > bunchList_
 
double minPz_
 
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixToken_
 
SelectProton select_
 

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

Definition at line 131 of file GenPUProtonProducer.cc.

Constructor & Destructor Documentation

◆ GenPUProtonProducer()

GenPUProtonProducer::GenPUProtonProducer ( const edm::ParameterSet cfg)

Definition at line 168 of file GenPUProtonProducer.cc.

169  : abortOnUnknownPDGCode_(cfg.getUntrackedParameter<bool>("abortOnUnknownPDGCode", true)),
170  bunchList_(cfg.getParameter<vector<int> >("bunchCrossingList")),
171  minPz_(cfg.getParameter<double>("minPz")) {
172  produces<GenParticleCollection>();
173  mixToken_ =
174  consumes<CrossingFrame<HepMCProduct> >(InputTag(cfg.getParameter<std::string>("mix"), "generatorSmeared"));
175 }

References looper::cfg, HLT_2018_cff::InputTag, mixToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~GenPUProtonProducer()

GenPUProtonProducer::~GenPUProtonProducer ( )
override

Definition at line 177 of file GenPUProtonProducer.cc.

177 {}

Member Function Documentation

◆ globalBeginRun()

std::shared_ptr< ConvertParticle > GenPUProtonProducer::globalBeginRun ( const edm::Run ,
const edm::EventSetup es 
) const
override

Definition at line 179 of file GenPUProtonProducer.cc.

179  {
181  es.getData(pdt);
182  auto convert_ptr = std::make_shared<ConvertParticle>(abortOnUnknownPDGCode_);
183  if (!convert_ptr->initialized())
184  convert_ptr->init(*pdt);
185 
186  return convert_ptr;
187 }

References abortOnUnknownPDGCode_, and edm::EventSetup::getData().

◆ globalEndRun()

void GenPUProtonProducer::globalEndRun ( edm::Run const &  ,
edm::EventSetup const &   
) const
inlineoverride

Definition at line 138 of file GenPUProtonProducer.cc.

138 {};

◆ produce()

void GenPUProtonProducer::produce ( edm::StreamID  ,
edm::Event e,
const edm::EventSetup es 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 189 of file GenPUProtonProducer.cc.

189  {
190  size_t totalSize = 0;
191  size_t npiles = 1;
192 
194  evt.getByToken(mixToken_, cf);
195  std::unique_ptr<MixCollection<HepMCProduct> > cfhepmcprod(new MixCollection<HepMCProduct>(cf.product()));
196  npiles = cfhepmcprod->size();
197 
198  LogDebug("GenPUProtonProducer") << " Number of pile-up events : " << npiles << endl;
199 
200  for (size_t icf = 0; icf < npiles; ++icf) {
201  LogDebug("GenPUProtonProducer") << "CF " << icf
202  << " size : " << cfhepmcprod->getObject(icf).GetEvent()->particles_size() << endl;
203  totalSize += cfhepmcprod->getObject(icf).GetEvent()->particles_size();
204  }
205  LogDebug("GenPUProtonProducer") << "Total size : " << totalSize << endl;
206 
207  // Initialise containers
208  auto candsPtr = std::make_unique<GenParticleCollection>();
209  GenParticleCollection& cands = *candsPtr;
210 
211  // Loop over pile-up events
212  ConvertParticle const& convertParticle_ = *runCache(evt.getRun().index());
213 
215  unsigned int total_number_of_protons = 0;
216  size_t idx_mix = 0;
217  // Fill collection
218  for (mixHepMC_itr = cfhepmcprod->begin(); mixHepMC_itr != cfhepmcprod->end(); ++mixHepMC_itr, ++idx_mix) {
219  int bunch = mixHepMC_itr.bunch();
220 
221  if (find(bunchList_.begin(), bunchList_.end(), bunch) != bunchList_.end()) {
222  auto event = (*mixHepMC_itr).GetEvent();
223 
224  size_t num_particles = event->particles_size();
225 
226  // Fill output collection
227  unsigned int number_of_protons = 0;
228  for (auto p = event->particles_begin(); p != event->particles_end(); ++p) {
229  HepMC::GenParticle const* part = *p;
230  if (select_(part, minPz_)) {
232  convertParticle_(cand, part);
233  ++number_of_protons;
234  cands.push_back(cand);
235  }
236  }
237  LogDebug("GenPUProtonProducer") << "Idx : " << idx_mix << " Bunch : " << bunch
238  << " Number of particles : " << num_particles
239  << " Number of protons : " << number_of_protons << endl;
240 
241  total_number_of_protons += number_of_protons;
242  }
243  }
244  LogDebug("GenPUProtonProducer") << "Total number of protons : " << total_number_of_protons << endl;
245  LogDebug("GenPUProtonProducer") << "Output collection size : " << cands.size() << endl;
246 
247  evt.put(std::move(candsPtr));
248 }

References MixCollection< T >::MixItr::bunch(), bunchList_, HLT_2018_cff::cands, spr::find(), GenParticle::GenParticle, edm::Event::getByToken(), edm::Event::getRun(), edm::Run::index(), LogDebug, minPz_, mixToken_, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, edm::Handle< T >::product(), edm::Event::put(), and select_.

Member Data Documentation

◆ abortOnUnknownPDGCode_

bool GenPUProtonProducer::abortOnUnknownPDGCode_
private

Definition at line 143 of file GenPUProtonProducer.cc.

Referenced by globalBeginRun().

◆ bunchList_

std::vector<int> GenPUProtonProducer::bunchList_
private

Definition at line 144 of file GenPUProtonProducer.cc.

Referenced by produce().

◆ minPz_

double GenPUProtonProducer::minPz_
private

Definition at line 145 of file GenPUProtonProducer.cc.

Referenced by produce().

◆ mixToken_

edm::EDGetTokenT<CrossingFrame<edm::HepMCProduct> > GenPUProtonProducer::mixToken_
private

Definition at line 138 of file GenPUProtonProducer.cc.

Referenced by GenPUProtonProducer(), and produce().

◆ select_

SelectProton GenPUProtonProducer::select_
private

Definition at line 146 of file GenPUProtonProducer.cc.

Referenced by produce().

edm::Handle::product
T const * product() const
Definition: Handle.h:70
GenPUProtonProducer::select_
SelectProton select_
Definition: GenPUProtonProducer.cc:146
reco::GenParticle
Definition: GenParticle.h:21
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
GenPUProtonProducer::abortOnUnknownPDGCode_
bool abortOnUnknownPDGCode_
Definition: GenPUProtonProducer.cc:143
GenPUProtonProducer::mixToken_
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixToken_
Definition: GenPUProtonProducer.cc:138
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
MixCollection::MixItr
Definition: MixCollection.h:62
MixCollection::MixItr::bunch
int bunch() const
Definition: MixCollection.h:91
part
part
Definition: HCALResponse.h:20
MixCollection
Definition: MixCollection.h:11
edm::ESHandle< HepPDT::ParticleDataTable >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
cand
Definition: decayParser.h:34
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:113
looper.cfg
cfg
Definition: looper.py:297
GenPUProtonProducer::bunchList_
std::vector< int > bunchList_
Definition: GenPUProtonProducer.cc:144
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLT_2018_cff.cands
cands
Definition: HLT_2018_cff.py:13762
event
Definition: event.py:1
GenPUProtonProducer::minPz_
double minPz_
Definition: GenPUProtonProducer.cc:145