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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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
 
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)
 
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::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 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 170 of file GenPUProtonProducer.cc.

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

170  :
171  abortOnUnknownPDGCode_( cfg.getUntrackedParameter<bool>( "abortOnUnknownPDGCode", true ) ),
172  bunchList_( cfg.getParameter<vector<int> >( "bunchCrossingList" ) ),
173  minPz_( cfg.getParameter<double>( "minPz" ) )
174 {
175  produces<GenParticleCollection>();
176  mixToken_ = consumes<CrossingFrame<HepMCProduct> >( InputTag(cfg.getParameter<std::string>( "mix" ),"generatorSmeared") );
177 }
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 179 of file GenPUProtonProducer.cc.

179 { }

Member Function Documentation

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

Definition at line 181 of file GenPUProtonProducer.cc.

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

181  {
183  es.getData( pdt );
184  auto convert_ptr = std::make_shared<ConvertParticle>( abortOnUnknownPDGCode_ );
185  if( !convert_ptr->initialized() ) convert_ptr->init( *pdt );
186 
187  return convert_ptr;
188 }
void getData(T &iHolder) const
Definition: EventSetup.h:98
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_, egammaForCoreTracking_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 
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 << " 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 
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 }
#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:20
T const * product() const
Definition: Handle.h:81
part
Definition: HCALResponse.h:20
def move(src, dest)
Definition: eostools.py:510
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().