48 protonsCut_(iConfig.getParameter<
std::
string>(
"cut")),
49 table_name_(iConfig.getParameter<
std::
string>(
"name")),
50 tolerance_(iConfig.getParameter<double>(
"tolerance")) {
51 produces<nanoaod::FlatTable>();
56 std::vector<float> pxs, pys, pzs, vzs;
57 std::vector<bool> isPUs;
62 pxs.emplace_back(pruned_cand.px());
63 pys.emplace_back(pruned_cand.py());
64 pzs.emplace_back(pruned_cand.pz());
65 vzs.emplace_back(pruned_cand.vz());
66 isPUs.emplace_back(
false);
72 for (
const auto& pu_cand : *hPUCands) {
75 bool associated{
false};
76 for (
size_t i = 0;
i < pzs.size(); ++
i) {
77 if (fabs(1. - pxs.at(
i) / pu_cand.px()) <
tolerance_ && fabs(1. - pys.at(
i) / pu_cand.py()) <
tolerance_ &&
85 pxs.emplace_back(pu_cand.px());
86 pys.emplace_back(pu_cand.py());
87 pzs.emplace_back(pu_cand.pz());
88 vzs.emplace_back(pu_cand.vz());
89 isPUs.emplace_back(
true);
92 auto protons_table = std::make_unique<nanoaod::FlatTable>(isPUs.size(),
table_name_,
false);
93 protons_table->addColumn<
float>(
"px", pxs,
"proton horizontal momentum", 8);
94 protons_table->addColumn<
float>(
"py", pys,
"proton vertical momentum", 8);
95 protons_table->addColumn<
float>(
"pz", pzs,
"proton longitudinal momentum", 8);
96 protons_table->addColumn<
float>(
"vz", vzs,
"proton vertex longitudinal coordinate", 8);
97 protons_table->addColumn<
bool>(
"isPU", isPUs,
"pileup proton?");
104 ->setComment(
"input source for pruned gen-level particle candidates");
106 ->setComment(
"input source for pileup protons collection");
108 ->setComment(
"alternative input source for pileup protons collection (for premix-mix backward compatibility)");
109 desc.add<
std::string>(
"cut",
"")->setComment(
"proton kinematic selection");
110 desc.add<
std::string>(
"name",
"GenProton")->setComment(
"flat table name");
111 desc.add<
std::string>(
"doc",
"generator level information on (signal+PU) protons")
112 ->setComment(
"flat table description");
113 desc.add<
double>(
"tolerance", 1.e-3)->setComment(
"relative difference between the signal and pileup protons momenta");
114 descriptions.
add(
"genProtonTable",
desc);
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
GenProtonTableProducer(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
const edm::EDGetTokenT< reco::GenParticleCollection > puAltCandsToken_
static void fillDescriptions(edm::ConfigurationDescriptions &)
const StringCutObjectSelector< reco::Candidate > protonsCut_
void produce(edm::Event &, const edm::EventSetup &) override
const edm::EDGetTokenT< reco::GenParticleCollection > puCandsToken_
bool use_alt_coll_
Are we using premix/mix collection name for PU protons?
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~GenProtonTableProducer() override=default
const std::string table_name_
const edm::EDGetTokenT< reco::GenParticleCollection > prunedCandsToken_