9 #include "TLorentzVector.h" 21 produces<nanoaod::FlatTable>(
"LHE");
23 produces<nanoaod::FlatTable>(
"LHEPart");
29 auto lheTab = std::make_unique<nanoaod::FlatTable>(1,
"LHE",
true);
32 for (
const auto& lheTag :
lheTag_) {
34 if (lheInfo.isValid()) {
38 if (lheInfo.isValid()) {
44 auto lhePartTab = std::make_unique<nanoaod::FlatTable>(1,
"LHEPart",
true);
53 double lheHT = 0, lheHTIncoming = 0;
54 unsigned int lheNj = 0, lheNb = 0, lheNc = 0, lheNuds = 0, lheNglu = 0;
57 const auto& hepeup = lheProd.
hepeup();
58 const auto& pup = hepeup.
PUP;
59 int lep = -1, lepBar = -1, nu = -1, nuBar = -1;
60 std::vector<float> vals_pt;
61 std::vector<float> vals_eta;
62 std::vector<float> vals_phi;
63 std::vector<float> vals_mass;
64 std::vector<int> vals_pid;
65 for (
unsigned int i = 0,
n = pup.size();
i <
n; ++
i) {
69 TLorentzVector
p4(pup[
i][0], pup[i][1], pup[i][2], pup[i][3]);
70 vals_pt.push_back(p4.Pt());
71 vals_eta.push_back(p4.Eta());
72 vals_phi.push_back(p4.Phi());
73 vals_mass.push_back(p4.M());
74 vals_pid.push_back(hepeup.IDUP[i]);
76 if ((status == 1) && ((idabs == 21) || (idabs > 0 && idabs < 7))) {
88 double pt = std::hypot(pup[
i][0], pup[i][1]);
91 hepeup.MOTHUP[i].first - 1,
93 int mothIdxTwo =
std::max(hepeup.MOTHUP[i].second - 1, 0);
94 int mothStatus = hepeup.ISTUP[mothIdx];
95 int mothStatusTwo = hepeup.ISTUP[mothIdxTwo];
96 bool hasIncomingAsMother = mothStatus < 0 || mothStatusTwo < 0;
97 if (hasIncomingAsMother)
99 }
else if (idabs == 12 || idabs == 14 || idabs == 16) {
100 (hepeup.IDUP[
i] > 0 ? nu : nuBar) =
i;
101 }
else if (idabs == 11 || idabs == 13 || idabs == 15) {
102 (hepeup.IDUP[
i] > 0 ? lep : lepBar) =
i;
105 std::pair<int, int>
v(0, 0);
106 if (lep != -1 && lepBar != -1)
107 v = std::make_pair(lep, lepBar);
108 else if (lep != -1 && nuBar != -1)
109 v = std::make_pair(lep, nuBar);
110 else if (nu != -1 && lepBar != -1)
111 v = std::make_pair(nu, lepBar);
112 else if (nu != -1 && nuBar != -1)
113 v = std::make_pair(nu, nuBar);
114 if (v.first != -1 && v.second != -1) {
115 lheVpt = std::hypot(pup[v.first][0] + pup[v.second][0], pup[v.first][1] + pup[v.second][1]);
129 "HT, scalar sum of parton pTs at LHE step, restricted to partons",
135 auto outPart = std::make_unique<nanoaod::FlatTable>(vals_pt.size(),
"LHEPart",
false);
137 outPart->addColumn<
float>(
139 outPart->addColumn<
float>(
141 outPart->addColumn<
float>(
150 desc.
add<std::vector<edm::InputTag>>(
"lheInfo", std::vector<edm::InputTag>{{
"externalLHEProducer"}, {
"source"}})
151 ->setComment(
"tag(s) for the LHE information (LHEEventProduct)");
152 desc.
add<
int>(
"precision", -1)->setComment(
"precision on the 4-momenta of the LHE particles");
153 desc.
add<
bool>(
"storeLHEParticles",
false)
154 ->setComment(
"Whether we want to store the 4-momenta of the status 1 particles at LHE level");
155 descriptions.
add(
"lheInfoTable", desc);
159 const std::vector<edm::EDGetTokenT<LHEEventProduct>>
lheTag_;
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const lhef::HEPEUP & hepeup() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
LHETablesProducer(edm::ParameterSet const ¶ms)
void produce(edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
const unsigned int precision_
std::unique_ptr< nanoaod::FlatTable > fillLHEObjectTable(const LHEEventProduct &lheProd, nanoaod::FlatTable &out) const
const bool storeLHEParticles_
#define DEFINE_FWK_MODULE(type)
~LHETablesProducer() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< FiveVector > PUP
Abs< T >::type abs(const T &t)
const std::vector< edm::EDGetTokenT< LHEEventProduct > > lheTag_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void addColumnValue(const std::string &name, const C &value, const std::string &docString, ColumnType type=defaultColumnType< T >(), int mantissaBits=-1)
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
void add(std::string const &label, ParameterSetDescription const &psetDescription)