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, double refpvz) 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 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
 
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
 
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)
 

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_
 
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvTag_
 
const std::vector< double > vz_
 

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

Constructor & Destructor Documentation

◆ NPUTablesProducer()

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

Definition at line 16 of file NPUTablesProducer.cc.

17  : npuTag_(consumes<std::vector<PileupSummaryInfo>>(params.getParameter<edm::InputTag>("src"))),
18  pvTag_(consumes<std::vector<reco::Vertex>>(params.getParameter<edm::InputTag>("pvsrc"))),
19  vz_(params.getParameter<std::vector<double>>("zbins")) {
20  produces<nanoaod::FlatTable>();
21  }

◆ ~NPUTablesProducer()

NPUTablesProducer::~NPUTablesProducer ( )
inlineoverride

Definition at line 23 of file NPUTablesProducer.cc.

23 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 94 of file NPUTablesProducer.cc.

94  {
96  desc.add<edm::InputTag>("src", edm::InputTag("slimmedAddPileupInfo"))
97  ->setComment("tag for the PU information (vector<PileupSummaryInfo>)");
98  desc.add<edm::InputTag>("pvsrc", edm::InputTag("offlineSlimmedPrimaryVertices"))->setComment("tag for the PVs");
99  desc.add<std::vector<double>>("zbins", {})
100  ->setComment("Z bins to compute the generator-level number of PU vertices per mm");
101  descriptions.add("puTable", desc);
102  }

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

◆ fillNPUObjectTable()

void NPUTablesProducer::fillNPUObjectTable ( const std::vector< PileupSummaryInfo > &  npuProd,
nanoaod::FlatTable out,
double  refpvz 
) const
inline

Definition at line 40 of file NPUTablesProducer.cc.

40  {
41  // Get BX 0
42  unsigned int bx0 = 0;
43  unsigned int nt = 0;
44  unsigned int npu = 0;
45 
46  auto zbin = std::lower_bound(vz_.begin(), vz_.end() - 1, std::abs(refpvz));
47  float pudensity = 0;
48  float gpudensity = 0;
49 
50  for (unsigned int ibx = 0; ibx < npuProd.size(); ibx++) {
51  if (npuProd[ibx].getBunchCrossing() == 0) {
52  bx0 = ibx;
53  nt = npuProd[ibx].getTrueNumInteractions();
54  npu = npuProd[ibx].getPU_NumInteractions();
55 
56  std::vector<float> zpositions;
57  unsigned int nzpositions = npuProd[ibx].getPU_zpositions().size();
58  for (unsigned int j = 0; j < nzpositions; ++j) {
59  zpositions.push_back(npuProd[ibx].getPU_zpositions()[j]);
60  if (std::abs(zpositions.back() - refpvz) < 0.1)
61  pudensity++; //N_PU/mm
62  auto bin = std::lower_bound(vz_.begin(), vz_.end() - 1, std::abs(zpositions.back()));
63  if (bin != vz_.end() && bin == zbin)
64  gpudensity++;
65  }
66  gpudensity /= (20.0 * (*(zbin) - *(zbin - 1)));
67  }
68  }
69  unsigned int eoot = 0;
70  for (unsigned int ipu = 0; ipu < bx0; ipu++) {
71  eoot += npuProd[ipu].getPU_NumInteractions();
72  }
73  unsigned int loot = 0;
74  for (unsigned int ipu = npuProd.size() - 1; ipu > bx0; ipu--) {
75  loot += npuProd[ipu].getPU_NumInteractions();
76  }
77  out.addColumnValue<float>("nTrueInt",
78  nt,
79  "the true mean number of the poisson distribution for this event from which the number "
80  "of interactions each bunch crossing has been sampled",
82  out.addColumnValue<int>(
83  "nPU",
84  npu,
85  "the number of pileup interactions that have been added to the event in the current bunch crossing",
87  out.addColumnValue<int>("sumEOOT", eoot, "number of early out of time pileup", nanoaod::FlatTable::IntColumn);
88  out.addColumnValue<int>("sumLOOT", loot, "number of late out of time pileup", nanoaod::FlatTable::IntColumn);
89  out.addColumnValue<float>("pudensity", pudensity, "PU vertices / mm", nanoaod::FlatTable::FloatColumn);
90  out.addColumnValue<float>(
91  "gpudensity", gpudensity, "Generator-level PU vertices / mm", nanoaod::FlatTable::FloatColumn);
92  }

References funct::abs(), newFWLiteAna::bin, nanoaod::FlatTable::FloatColumn, nanoaod::FlatTable::IntColumn, dqmiolumiharvest::j, cuda_std::lower_bound(), nt, MillePedeFileConverter_cfg::out, and vz_.

Referenced by produce().

◆ produce()

void NPUTablesProducer::produce ( edm::StreamID  id,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
inlineoverridevirtual

Implements edm::global::EDProducerBase.

Definition at line 25 of file NPUTablesProducer.cc.

25  {
26  auto npuTab = std::make_unique<nanoaod::FlatTable>(1, "Pileup", true);
27 
29  iEvent.getByToken(pvTag_, pvsIn);
30  const double refpvz = (*pvsIn)[0].position().z();
31 
33  if (iEvent.getByToken(npuTag_, npuInfo)) {
34  fillNPUObjectTable(*npuInfo, *npuTab, refpvz);
35  }
36 
37  iEvent.put(std::move(npuTab));
38  }

References fillNPUObjectTable(), iEvent, eostools::move(), npuTag_, and pvTag_.

Member Data Documentation

◆ npuTag_

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

Definition at line 105 of file NPUTablesProducer.cc.

Referenced by produce().

◆ pvTag_

const edm::EDGetTokenT<std::vector<reco::Vertex> > NPUTablesProducer::pvTag_
protected

Definition at line 106 of file NPUTablesProducer.cc.

Referenced by produce().

◆ vz_

const std::vector<double> NPUTablesProducer::vz_
protected

Definition at line 108 of file NPUTablesProducer.cc.

Referenced by fillNPUObjectTable().

nanoaod::FlatTable::FloatColumn
Definition: FlatTable.h:39
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
NPUTablesProducer::pvTag_
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvTag_
Definition: NPUTablesProducer.cc:106
nt
int nt
Definition: AMPTWrapper.h:42
NPUTablesProducer::fillNPUObjectTable
void fillNPUObjectTable(const std::vector< PileupSummaryInfo > &npuProd, nanoaod::FlatTable &out, double refpvz) const
Definition: NPUTablesProducer.cc:40
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::Handle
Definition: AssociativeIterator.h:50
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
iEvent
int iEvent
Definition: GenABIO.cc:224
NPUTablesProducer::vz_
const std::vector< double > vz_
Definition: NPUTablesProducer.cc:108
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
nanoaod::FlatTable::IntColumn
Definition: FlatTable.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
NPUTablesProducer::npuTag_
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > npuTag_
Definition: NPUTablesProducer.cc:105
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:126
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::InputTag
Definition: InputTag.h:15