CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
NPUTablesProducer Class Reference
Inheritance diagram for NPUTablesProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void fillNPUObjectTable (const std::vector< PileupSummaryInfo > &npuProd, nanoaod::FlatTable &out) const
 
 NPUTablesProducer (edm::ParameterSet const &params)
 
void produce (edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
 ~NPUTablesProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 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 () 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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- 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 Attributes

const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > npuTag_
 

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
 
- 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 14 of file NPUTablesProducer.cc.

Constructor & Destructor Documentation

NPUTablesProducer::NPUTablesProducer ( edm::ParameterSet const &  params)
inline

Definition at line 16 of file NPUTablesProducer.cc.

16  :
17  npuTag_(consumes<std::vector<PileupSummaryInfo>>(params.getParameter<edm::InputTag>("src")))
18  {
19  produces<nanoaod::FlatTable>();
20  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > npuTag_
NPUTablesProducer::~NPUTablesProducer ( )
inlineoverride

Definition at line 22 of file NPUTablesProducer.cc.

22 {}

Member Function Documentation

static void NPUTablesProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 61 of file NPUTablesProducer.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

61  {
63  desc.add<edm::InputTag>("src", edm::InputTag("slimmedAddPileupInfo"))->setComment("tag for the PU information (vector<PileupSummaryInfo>)");
64  descriptions.add("puTable", desc);
65  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void NPUTablesProducer::fillNPUObjectTable ( const std::vector< PileupSummaryInfo > &  npuProd,
nanoaod::FlatTable out 
) const
inline

Definition at line 35 of file NPUTablesProducer.cc.

References nanoaod::FlatTable::addColumnValue(), nanoaod::FlatTable::FloatColumn, nanoaod::FlatTable::IntColumn, and nt.

Referenced by produce().

35  {
36  // Get BX 0
37  unsigned int bx0 = 0;
38  unsigned int nt = 0;
39  unsigned int npu = 0;
40  for(unsigned int ibx=0; ibx<npuProd.size(); ibx++) {
41  if(npuProd[ibx].getBunchCrossing()==0) {
42  bx0 = ibx;
43  nt = npuProd[ibx].getTrueNumInteractions();
44  npu = npuProd[ibx].getPU_NumInteractions();
45  }
46  }
47  unsigned int eoot = 0;
48  for(unsigned int ipu=0; ipu<bx0; ipu++) {
49  eoot+=npuProd[ipu].getPU_NumInteractions();
50  }
51  unsigned int loot = 0;
52  for(unsigned int ipu=npuProd.size()-1; ipu>bx0; ipu--) {
53  loot+=npuProd[ipu].getPU_NumInteractions();
54  }
55  out.addColumnValue<float>("nTrueInt", nt, "the true mean number of the poisson distribution for this event from which the number of interactions each bunch crossing has been sampled", nanoaod::FlatTable::FloatColumn);
56  out.addColumnValue<int>("nPU", npu, "the number of pileup interactions that have been added to the event in the current bunch crossing", nanoaod::FlatTable::IntColumn);
57  out.addColumnValue<int>("sumEOOT", eoot, "number of early out of time pileup" , nanoaod::FlatTable::IntColumn);
58  out.addColumnValue<int>("sumLOOT", loot, "number of late out of time pileup" , nanoaod::FlatTable::IntColumn);
59  }
void addColumnValue(const std::string &name, const C &value, const std::string &docString, ColumnType type=defaultColumnType< T >(), int mantissaBits=-1)
Definition: FlatTable.h:101
int nt
Definition: AMPTWrapper.h:32
void NPUTablesProducer::produce ( edm::StreamID  id,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
inlineoverride

Definition at line 24 of file NPUTablesProducer.cc.

References fillNPUObjectTable(), edm::Event::getByToken(), eostools::move(), npuTag_, and edm::Event::put().

24  {
25  auto npuTab = std::make_unique<nanoaod::FlatTable>(1, "Pileup", true);
26 
28  if (iEvent.getByToken(npuTag_, npuInfo)) {
29  fillNPUObjectTable(*npuInfo, *npuTab);
30  }
31 
32  iEvent.put(std::move(npuTab));
33  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > npuTag_
void fillNPUObjectTable(const std::vector< PileupSummaryInfo > &npuProd, nanoaod::FlatTable &out) const
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

const edm::EDGetTokenT<std::vector<PileupSummaryInfo> > NPUTablesProducer::npuTag_
protected

Definition at line 68 of file NPUTablesProducer.cc.

Referenced by produce().