37 std::vector<edm::ParameterSet> selPSets = iConfig.
getParameter<std::vector<edm::ParameterSet>>(
"selections");
38 sels_.reserve(selPSets.size());
39 std::stringstream idstr, qualitystr;
40 idstr <<
"ID of the object: ";
41 for (
auto &
pset : selPSets) {
43 idstr <<
sels_.back().id <<
" = " <<
sels_.back().name;
44 if (
sels_.size() < selPSets.size())
46 if (!
sels_.back().qualityBitsDoc.empty()) {
47 qualitystr <<
sels_.back().qualityBitsDoc <<
" for " <<
sels_.back().name <<
"; ";
53 produces<nanoaod::FlatTable>();
101 std::vector<edm::ParameterSet> qualityBitsConfig =
102 pset.getParameter<std::vector<edm::ParameterSet>>(
"qualityBits");
103 std::stringstream qualityBitsFunc;
104 std::vector<bool>
bits(qualityBitsConfig.size(),
false);
105 for (
size_t i = 0;
i != qualityBitsConfig.size(); ++
i) {
107 qualityBitsFunc <<
" + ";
110 unsigned int bit =
i;
111 if (qualityBitsConfig[
i].existsAs<unsigned int>(
"bit"))
112 bit = qualityBitsConfig[
i].getParameter<unsigned int>(
"bit");
114 assert(
bit < 31 &&
"quality bits are store on 32 bit");
117 << qualityBitsConfig[
i].getParameter<
std::string>(
"selection") <<
")";
120 if (!qualityBitsFunc.str().empty()) {
150 std::vector<std::pair<const pat::TriggerObjectStandAlone *, const SelectedObject *>> selected;
151 std::map<int, std::map<const pat::TriggerObjectStandAlone *, int>> selected_bits;
156 if (
sel.skipObjectsNotPassingQualityBits ? (selected_bits[
sel.id][&
obj] > 0) :
true) {
157 selected.emplace_back(&
obj, &
sel);
164 for (
unsigned int i = 0;
i < selected.size(); ++
i) {
165 const auto &
obj = *selected[
i].first;
166 const auto &
sel = *selected[
i].second;
168 for (
unsigned int j = 0;
j <
i; ++
j) {
169 const auto &obj2 = *selected[
j].first;
170 const auto &sel2 = *selected[
j].second;
172 selected_bits[
sel.id][&obj2] |= selected_bits[
sel.id][&
obj];
173 selected.erase(selected.begin() +
i);
185 std::vector<pair<pat::TriggerObjectStandAlone, int>> l1Objects;
193 l1Objects.emplace_back(l1obj, it->hwIso());
199 switch (it->getType()) {
202 l1obj.setCollection(
"L1ETM");
207 l1obj.setCollection(
"L1ETMHF");
212 l1obj.setCollection(
"L1ETT");
217 l1obj.setCollection(
"L1ETEm");
222 l1obj.setCollection(
"L1HTT");
227 l1obj.setCollection(
"L1HTTHF");
232 l1obj.setCollection(
"L1HTM");
237 l1obj.setCollection(
"L1HTMHF");
244 l1Objects.emplace_back(l1obj, it->hwIso());
251 l1Objects.emplace_back(l1obj, it->hwIso());
258 l1obj.setCharge(it->charge());
259 l1Objects.emplace_back(l1obj, it->hwIso());
266 l1Objects.emplace_back(l1obj, it->hwIso());
269 unsigned int nobj = selected.size();
270 std::vector<float>
pt(nobj, 0),
eta(nobj, 0),
phi(nobj, 0), l1pt(nobj, 0), l1pt_2(nobj, 0), l2pt(nobj, 0);
271 std::vector<int>
id(nobj, 0),
bits(nobj, 0), l1iso(nobj, 0), l1charge(nobj, 0);
272 for (
unsigned int i = 0;
i < nobj; ++
i) {
273 const auto &
obj = *selected[
i].first;
274 const auto &
sel = *selected[
i].second;
281 float best =
sel.l1DR2;
282 for (
const auto &l1obj : l1Objects) {
283 const auto &
seed = l1obj.first;
285 if (dr2 < best &&
sel.l1cut(
seed)) {
288 l1iso[
i] = l1obj.second;
289 l1charge[
i] =
seed.charge();
293 if (
sel.l1DR2_2 > 0) {
294 float best =
sel.l1DR2_2;
295 for (
const auto &l1obj : l1Objects) {
296 const auto &
seed = l1obj.first;
298 if (dr2 < best &&
sel.l1cut_2(
seed)) {
300 l1pt_2[
i] =
seed.pt();
305 float best =
sel.l2DR2;
308 if (dr2 < best &&
sel.l2cut(
seed)) {
316 auto tab = std::make_unique<nanoaod::FlatTable>(nobj,
name_,
false,
false);
317 tab->addColumn<
int>(
"id",
id,
idDoc_);
318 tab->addColumn<
float>(
"pt",
pt,
"pt", 12);
319 tab->addColumn<
float>(
"eta",
eta,
"eta", 12);
320 tab->addColumn<
float>(
"phi",
phi,
"phi", 12);
321 tab->addColumn<
float>(
"l1pt", l1pt,
"pt of associated L1 seed", 8);
322 tab->addColumn<
int>(
"l1iso", l1iso,
"iso of associated L1 seed");
323 tab->addColumn<
int>(
"l1charge", l1charge,
"charge of associated L1 seed");
324 tab->addColumn<
float>(
"l1pt_2", l1pt_2,
"pt of associated secondary L1 seed", 8);
325 tab->addColumn<
float>(
"l2pt", l2pt,
"pt of associated 'L2' seed (i.e. HLT before tracking/PF)", 10);
326 tab->addColumn<
int>(
"filterBits",
bits,
"extra bits of associated information: " +
bitsDoc_);
332 desc.add<
std::string>(
"name")->setComment(
"name of the flat table output");
333 desc.add<
edm::InputTag>(
"src")->setComment(
"pat::TriggerObjectStandAlone input collection");
334 desc.add<
edm::InputTag>(
"l1EG")->setComment(
"l1t::EGammaBxCollection input collection");
335 desc.add<
edm::InputTag>(
"l1Sum")->setComment(
"l1t::EtSumBxCollection input collection");
336 desc.add<
edm::InputTag>(
"l1Jet")->setComment(
"l1t::JetBxCollection input collection");
337 desc.add<
edm::InputTag>(
"l1Muon")->setComment(
"l1t::MuonBxCollection input collection");
338 desc.add<
edm::InputTag>(
"l1Tau")->setComment(
"l1t::TauBxCollection input collection");
341 selection.setComment(
"a parameterset to define a trigger collection in flat table");
343 selection.add<
int>(
"id")->setComment(
"identifier of the trigger collection in the flat table");
344 selection.add<
std::string>(
"sel")->setComment(
"function to selection on pat::TriggerObjectStandAlone");
345 selection.add<
bool>(
"skipObjectsNotPassingQualityBits")->setComment(
"flag to skip object on quality bit");
348 "qualityBits",
"0",
true,
edm::Comment(
"function on pat::TriggerObjectStandAlone to define quality bits"));
350 "qualityBitsDoc",
"",
true,
edm::Comment(
"documentation of the quality bits"));
352 bit.add<
std::string>(
"selection")->setComment(
"function on pat::TriggerObjectStandAlone to define quality bit");
353 bit.add<
std::string>(
"doc")->setComment(
"definition of the quality bit");
354 bit.addOptional<
uint>(
"bit")->setComment(
"value of the bit, if not the order in the VPset");
355 bit.setComment(
"parameter set to define quality bit of matching object");
359 "qualityBits",
bit,
true, std::vector<edm::ParameterSet>());
365 "l1deltaR",
"deltaR criteria to match pat::TriggerObjectStandAlone to L1 primitive"));
368 "l1deltaR_2",
"deltaR criteria to match pat::TriggerObjectStandAlone to L1 primitive"));
371 "l2deltaR",
"deltaR criteria to match pat::TriggerObjectStandAlone to 'L2' primitive"));
BXVector< EGamma > EGammaBxCollection
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
SelectedObject(const edm::ParameterSet &pset)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
enum start value shifted to 81 so as to avoid clashes with PDG codes
std::string to_string(const V &value)
bool skipObjectsNotPassingQualityBits
BXVector< Tau > TauBxCollection
~TriggerObjectTableProducer() override
StringCutObjectSelector< pat::TriggerObjectStandAlone > l1cut
edm::EDGetTokenT< l1t::JetBxCollection > l1Jet_
std::vector< T >::const_iterator const_iterator
BXVector< EtSum > EtSumBxCollection
TriggerObjectTableProducer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< std::vector< pat::TriggerObjectStandAlone > > src_
void setCollection(const std::string &collName)
Methods.
StringObjectFunction< pat::TriggerObjectStandAlone > qualityBits
edm::EDGetTokenT< l1t::MuonBxCollection > l1Muon_
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
bool match(const pat::TriggerObjectStandAlone &obj) const
std::string qualityBitsDoc
BXVector< Muon > MuonBxCollection
BXVector< Jet > JetBxCollection
StringCutObjectSelector< pat::TriggerObjectStandAlone > l1cut_2
edm::EDGetTokenT< l1t::TauBxCollection > l1Tau_
StringCutObjectSelector< pat::TriggerObjectStandAlone > cut
std::vector< SelectedObject > sels_
edm::EDGetTokenT< l1t::EGammaBxCollection > l1EG_
edm::EDGetTokenT< l1t::EtSumBxCollection > l1Sum_
void produce(edm::Event &, edm::EventSetup const &) override
Power< A, B >::type pow(const A &a, const B &b)
StringCutObjectSelector< pat::TriggerObjectStandAlone > l2cut
Analysis-level trigger object class (stand-alone)