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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
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< Bconsumes (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 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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
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

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.

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

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 }
std::vector< int > bunchList_
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixToken_
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > pdtToken_

◆ ~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.

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

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 }
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > pdtToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130

◆ 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.

References MixCollection< T >::MixItr::bunch(), bunchList_, HLT_2024v14_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_.

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 }
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
std::vector< int > bunchList_
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixToken_
T const * product() const
Definition: Handle.h:70
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
part
Definition: HCALResponse.h:20
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
#define LogDebug(id)

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