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
 
 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
 
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::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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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 Attributes

bool abortOnUnknownPDGCode_
 
std::vector< int > bunchList_
 
double minPz_
 
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixToken_
 
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecordpdtToken_
 
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 = 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

Definition at line 134 of file GenPUProtonProducer.cc.

Constructor & Destructor Documentation

◆ GenPUProtonProducer()

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

Definition at line 170 of file GenPUProtonProducer.cc.

171  : abortOnUnknownPDGCode_(cfg.getUntrackedParameter<bool>("abortOnUnknownPDGCode", true)),
172  bunchList_(cfg.getParameter<vector<int> >("bunchCrossingList")),
173  minPz_(cfg.getParameter<double>("minPz")) {
174  produces<GenParticleCollection>();
175  mixToken_ =
176  consumes<CrossingFrame<HepMCProduct> >(InputTag(cfg.getParameter<std::string>("mix"), "generatorSmeared"));
177  pdtToken_ = esConsumes<HepPDT::ParticleDataTable, edm::DefaultRecord, edm::Transition::BeginRun>();
178 }

References looper::cfg, HLT_FULL_cff::InputTag, mixToken_, pdtToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~GenPUProtonProducer()

GenPUProtonProducer::~GenPUProtonProducer ( )
override

Definition at line 180 of file GenPUProtonProducer.cc.

180 {}

Member Function Documentation

◆ globalBeginRun()

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

Definition at line 182 of file GenPUProtonProducer.cc.

182  {
184  auto convert_ptr = std::make_shared<ConvertParticle>(abortOnUnknownPDGCode_);
185  if (!convert_ptr->initialized())
186  convert_ptr->init(*pdt);
187 
188  return convert_ptr;
189 }

References abortOnUnknownPDGCode_, edm::EventSetup::getHandle(), and pdtToken_.

◆ globalEndRun()

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

Definition at line 141 of file GenPUProtonProducer.cc.

141 {};

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 191 of file GenPUProtonProducer.cc.

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

References MixCollection< T >::MixItr::bunch(), bunchList_, HLT_FULL_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 146 of file GenPUProtonProducer.cc.

Referenced by globalBeginRun().

◆ bunchList_

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

Definition at line 147 of file GenPUProtonProducer.cc.

Referenced by produce().

◆ minPz_

double GenPUProtonProducer::minPz_
private

Definition at line 148 of file GenPUProtonProducer.cc.

Referenced by produce().

◆ mixToken_

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

Definition at line 141 of file GenPUProtonProducer.cc.

Referenced by GenPUProtonProducer(), and produce().

◆ pdtToken_

edm::ESGetToken<HepPDT::ParticleDataTable, edm::DefaultRecord> GenPUProtonProducer::pdtToken_
private

Definition at line 145 of file GenPUProtonProducer.cc.

Referenced by GenPUProtonProducer(), and globalBeginRun().

◆ select_

SelectProton GenPUProtonProducer::select_
private

Definition at line 149 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:149
reco::GenParticle
Definition: GenParticle.h:21
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
GenPUProtonProducer::abortOnUnknownPDGCode_
bool abortOnUnknownPDGCode_
Definition: GenPUProtonProducer.cc:146
GenPUProtonProducer::mixToken_
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixToken_
Definition: GenPUProtonProducer.cc:141
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:61
MixCollection::MixItr::bunch
int bunch() const
Definition: MixCollection.h:90
part
part
Definition: HCALResponse.h:20
MixCollection
Definition: MixCollection.h:10
GenPUProtonProducer::pdtToken_
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > pdtToken_
Definition: GenPUProtonProducer.cc:145
edm::ESHandle< HepPDT::ParticleDataTable >
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15161
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
cand
Definition: decayParser.h:32
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
looper.cfg
cfg
Definition: looper.py:296
GenPUProtonProducer::bunchList_
std::vector< int > bunchList_
Definition: GenPUProtonProducer.cc:147
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
eostools.move
def move(src, dest)
Definition: eostools.py:511
event
Definition: event.py:1
GenPUProtonProducer::minPz_
double minPz_
Definition: GenPUProtonProducer.cc:148