22 produces<nanoaod::FlatTable>();
28 auto npuTab = std::make_unique<nanoaod::FlatTable>(1,
"Pileup",
true);
31 const double refpvz = pvProd.at(0).position().z();
53 for (
unsigned int ibx = 0; ibx < npuProd.size(); ibx++) {
54 if (npuProd[ibx].getBunchCrossing() == 0) {
56 nt = npuProd[ibx].getTrueNumInteractions();
57 npu = npuProd[ibx].getPU_NumInteractions();
59 std::vector<float> zpositions;
60 unsigned int nzpositions = npuProd[ibx].getPU_zpositions().size();
61 for (
unsigned int j = 0;
j < nzpositions; ++
j) {
62 zpositions.push_back(npuProd[ibx].getPU_zpositions()[
j]);
63 if (
std::abs(zpositions.back() - refpvz) < 0.1)
69 gpudensity /= (20.0 * (*(zbin) - *(zbin - 1)));
72 if (!npuProd[ibx].getPU_pT_hats().empty()) {
73 pthatmax = *max_element(npuProd[ibx].getPU_pT_hats().begin(), npuProd[ibx].getPU_pT_hats().
end());
78 unsigned int eoot = 0;
79 for (
unsigned int ipu = 0; ipu < bx0; ipu++) {
80 eoot += npuProd[ipu].getPU_NumInteractions();
82 unsigned int loot = 0;
83 for (
unsigned int ipu = npuProd.size() - 1; ipu > bx0; ipu--) {
84 loot += npuProd[ipu].getPU_NumInteractions();
86 out.addColumnValue<
float>(
"nTrueInt",
88 "the true mean number of the poisson distribution for this event from which the number " 89 "of interactions each bunch crossing has been sampled",
91 out.addColumnValue<
int>(
94 "the number of pileup interactions that have been added to the event in the current bunch crossing");
95 out.addColumnValue<
int>(
"sumEOOT", eoot,
"number of early out of time pileup");
96 out.addColumnValue<
int>(
"sumLOOT", loot,
"number of late out of time pileup");
97 out.addColumnValue<
float>(
"pudensity", pudensity,
"PU vertices / mm");
98 out.addColumnValue<
float>(
"gpudensity", gpudensity,
"Generator-level PU vertices / mm");
100 out.addColumnValue<
float>(
"pthatmax", pthatmax,
"Maximum pt-hat", 10);
107 ->setComment(
"tag for the PU information (vector<PileupSummaryInfo>)");
109 desc.add<std::vector<double>>(
"zbins", {})
110 ->setComment(
"Z bins to compute the generator-level number of PU vertices per mm");
111 desc.add<
bool>(
"savePtHatMax",
false)->setComment(
"Store maximum pt-hat of PU");
112 descriptions.
add(
"puTable",
desc);
119 const std::vector<double>
vz_;
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Abs< T >::type abs(const T &t)
NPUTablesProducer(edm::ParameterSet const ¶ms)
#define DEFINE_FWK_MODULE(type)
void produce(edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > npuTag_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~NPUTablesProducer() override
void fillNPUObjectTable(const std::vector< PileupSummaryInfo > &npuProd, nanoaod::FlatTable &out, double refpvz) const
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvTag_
const std::vector< double > vz_