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::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_
 
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 133 of file GenPUProtonProducer.cc.

Constructor & Destructor Documentation

◆ GenPUProtonProducer()

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

Definition at line 169 of file GenPUProtonProducer.cc.

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

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

◆ ~GenPUProtonProducer()

GenPUProtonProducer::~GenPUProtonProducer ( )
override

Definition at line 179 of file GenPUProtonProducer.cc.

179 {}

Member Function Documentation

◆ globalBeginRun()

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

Definition at line 181 of file GenPUProtonProducer.cc.

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

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

◆ globalEndRun()

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

Definition at line 140 of file GenPUProtonProducer.cc.

140 {};

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 190 of file GenPUProtonProducer.cc.

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

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 145 of file GenPUProtonProducer.cc.

Referenced by globalBeginRun().

◆ bunchList_

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

Definition at line 146 of file GenPUProtonProducer.cc.

Referenced by produce().

◆ minPz_

double GenPUProtonProducer::minPz_
private

Definition at line 147 of file GenPUProtonProducer.cc.

Referenced by produce().

◆ mixToken_

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

Definition at line 140 of file GenPUProtonProducer.cc.

Referenced by GenPUProtonProducer(), and produce().

◆ pdtToken_

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

Definition at line 144 of file GenPUProtonProducer.cc.

Referenced by GenPUProtonProducer(), and globalBeginRun().

◆ select_

SelectProton GenPUProtonProducer::select_
private

Definition at line 148 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:148
reco::GenParticle
Definition: GenParticle.h:21
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
GenPUProtonProducer::abortOnUnknownPDGCode_
bool abortOnUnknownPDGCode_
Definition: GenPUProtonProducer.cc:145
GenPUProtonProducer::mixToken_
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixToken_
Definition: GenPUProtonProducer.cc:140
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
GenPUProtonProducer::pdtToken_
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > pdtToken_
Definition: GenPUProtonProducer.cc:144
edm::ESHandle< HepPDT::ParticleDataTable >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15208
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
cand
Definition: decayParser.h:32
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
looper.cfg
cfg
Definition: looper.py:297
GenPUProtonProducer::bunchList_
std::vector< int > bunchList_
Definition: GenPUProtonProducer.cc:146
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:147