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
 
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)
 
 ~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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Definition at line 132 of file GenPUProtonProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 169 of file GenPUProtonProducer.cc.

References edm::ParameterSet::getParameter(), HLT_2018_cff::InputTag, mixToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

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 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< int > bunchList_
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > mixToken_
GenPUProtonProducer::~GenPUProtonProducer ( )
override

Definition at line 178 of file GenPUProtonProducer.cc.

178 {}

Member Function Documentation

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

Definition at line 180 of file GenPUProtonProducer.cc.

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

180  {
182  es.getData(pdt);
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 }
bool getData(T &iHolder) const
Definition: EventSetup.h:113
void GenPUProtonProducer::globalEndRun ( edm::Run const &  ,
edm::EventSetup const &   
) const
inlineoverride

Definition at line 139 of file GenPUProtonProducer.cc.

139 {};
void GenPUProtonProducer::produce ( edm::StreamID  ,
edm::Event e,
const edm::EventSetup es 
) const
override

Definition at line 190 of file GenPUProtonProducer.cc.

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

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

Member Data Documentation

bool GenPUProtonProducer::abortOnUnknownPDGCode_
private

Definition at line 144 of file GenPUProtonProducer.cc.

Referenced by globalBeginRun().

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

Definition at line 145 of file GenPUProtonProducer.cc.

Referenced by produce().

double GenPUProtonProducer::minPz_
private

Definition at line 146 of file GenPUProtonProducer.cc.

Referenced by produce().

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

Definition at line 139 of file GenPUProtonProducer.cc.

Referenced by GenPUProtonProducer(), and produce().

SelectProton GenPUProtonProducer::select_
private

Definition at line 147 of file GenPUProtonProducer.cc.

Referenced by produce().