39 std::stringstream idstr, qualitystr;
40 idstr <<
"ID of the object: ";
41 for (
const auto &
name : selNames) {
45 if (
sels_.size() < selNames.size())
47 if (!
sel.qualityBitsDoc.empty()) {
48 qualitystr <<
sel.qualityBitsDoc <<
" for " <<
name <<
"; ";
54 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()) {
149 std::vector<std::pair<const pat::TriggerObjectStandAlone *, const SelectedObject *>> selected;
150 std::map<int, std::map<const pat::TriggerObjectStandAlone *, int>> selected_bits;
155 if (
sel.skipObjectsNotPassingQualityBits ? (selected_bits[
sel.id][&
obj] > 0) :
true) {
156 selected.emplace_back(&
obj, &
sel);
163 for (
unsigned int i = 0;
i < selected.size(); ++
i) {
164 const auto &
obj = *selected[
i].first;
165 const auto &
sel = *selected[
i].second;
167 for (
unsigned int j = 0;
j <
i; ++
j) {
168 const auto &obj2 = *selected[
j].first;
169 const auto &sel2 = *selected[
j].second;
171 selected_bits[
sel.id][&obj2] |= selected_bits[
sel.id][&
obj];
172 selected.erase(selected.begin() +
i);
184 std::vector<pair<pat::TriggerObjectStandAlone, int>> l1Objects;
192 l1Objects.emplace_back(l1obj, it->hwIso());
198 switch (it->getType()) {
201 l1obj.setCollection(
"L1ETM");
206 l1obj.setCollection(
"L1ETMHF");
211 l1obj.setCollection(
"L1ETT");
216 l1obj.setCollection(
"L1ETEm");
221 l1obj.setCollection(
"L1HTT");
226 l1obj.setCollection(
"L1HTTHF");
231 l1obj.setCollection(
"L1HTM");
236 l1obj.setCollection(
"L1HTMHF");
243 l1Objects.emplace_back(l1obj, it->hwIso());
250 l1Objects.emplace_back(l1obj, it->hwIso());
257 l1obj.setCharge(it->charge());
258 l1Objects.emplace_back(l1obj, it->hwIso());
265 l1Objects.emplace_back(l1obj, it->hwIso());
268 unsigned int nobj = selected.size();
269 std::vector<float>
pt(nobj, 0),
eta(nobj, 0),
phi(nobj, 0), l1pt(nobj, 0), l1pt_2(nobj, 0), l2pt(nobj, 0);
270 std::vector<int16_t> l1charge(nobj, 0);
271 std::vector<uint16_t>
id(nobj, 0);
272 std::vector<int>
bits(nobj, 0), l1iso(nobj, 0);
273 for (
unsigned int i = 0;
i < nobj; ++
i) {
274 const auto &
obj = *selected[
i].first;
275 const auto &
sel = *selected[
i].second;
282 float best =
sel.l1DR2;
283 for (
const auto &l1obj : l1Objects) {
284 const auto &
seed = l1obj.first;
286 if (dr2 < best &&
sel.l1cut(
seed)) {
289 l1iso[
i] = l1obj.second;
290 l1charge[
i] =
seed.charge();
294 if (
sel.l1DR2_2 > 0) {
295 float best =
sel.l1DR2_2;
296 for (
const auto &l1obj : l1Objects) {
297 const auto &
seed = l1obj.first;
299 if (dr2 < best &&
sel.l1cut_2(
seed)) {
301 l1pt_2[
i] =
seed.pt();
306 float best =
sel.l2DR2;
309 if (dr2 < best &&
sel.l2cut(
seed)) {
317 auto tab = std::make_unique<nanoaod::FlatTable>(nobj,
name_,
false,
false);
318 tab->addColumn<uint16_t>(
"id",
id,
idDoc_);
319 tab->addColumn<
float>(
"pt",
pt,
"pt", 12);
320 tab->addColumn<
float>(
"eta",
eta,
"eta", 12);
321 tab->addColumn<
float>(
"phi",
phi,
"phi", 12);
322 tab->addColumn<
float>(
"l1pt", l1pt,
"pt of associated L1 seed", 8);
323 tab->addColumn<
int>(
"l1iso", l1iso,
"iso of associated L1 seed");
324 tab->addColumn<int16_t>(
"l1charge", l1charge,
"charge of associated L1 seed");
325 tab->addColumn<
float>(
"l1pt_2", l1pt_2,
"pt of associated secondary L1 seed", 8);
326 tab->addColumn<
float>(
"l2pt", l2pt,
"pt of associated 'L2' seed (i.e. HLT before tracking/PF)", 10);
327 tab->addColumn<
int>(
"filterBits",
bits,
"extra bits of associated information: " +
bitsDoc_);
333 desc.add<
std::string>(
"name")->setComment(
"name of the flat table output");
334 desc.add<
edm::InputTag>(
"src")->setComment(
"pat::TriggerObjectStandAlone input collection");
335 desc.add<
edm::InputTag>(
"l1EG")->setComment(
"l1t::EGammaBxCollection input collection");
336 desc.add<
edm::InputTag>(
"l1Sum")->setComment(
"l1t::EtSumBxCollection input collection");
337 desc.add<
edm::InputTag>(
"l1Jet")->setComment(
"l1t::JetBxCollection input collection");
338 desc.add<
edm::InputTag>(
"l1Muon")->setComment(
"l1t::MuonBxCollection input collection");
339 desc.add<
edm::InputTag>(
"l1Tau")->setComment(
"l1t::TauBxCollection input collection");
342 selection.setComment(
"a parameterset to define a trigger collection in flat table");
344 "optional additional info to be added to the table doc for that object");
345 selection.add<
int>(
"id")->setComment(
"identifier of the trigger collection in the flat table");
346 selection.add<
std::string>(
"sel")->setComment(
"function to selection on pat::TriggerObjectStandAlone");
347 selection.add<
bool>(
"skipObjectsNotPassingQualityBits")->setComment(
"flag to skip object on quality bit");
350 bit.add<
std::string>(
"selection")->setComment(
"function on pat::TriggerObjectStandAlone to define quality bit");
351 bit.add<
std::string>(
"doc")->setComment(
"definition of the quality bit");
352 bit.addOptional<
uint>(
"bit")->setComment(
"value of the bit, if not the order in the VPset");
353 bit.setComment(
"parameter set to define quality bit of matching object");
358 "l1deltaR",
"deltaR criteria to match pat::TriggerObjectStandAlone to L1 primitive"));
361 "l1deltaR_2",
"deltaR criteria to match pat::TriggerObjectStandAlone to L1 primitive"));
364 "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
bool skipObjectsNotPassingQualityBits
BXVector< Tau > TauBxCollection
~TriggerObjectTableProducer() override
static std::string to_string(const XMLCh *ch)
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
std::vector< std::string > getParameterNames() const
Power< A, B >::type pow(const A &a, const B &b)
StringCutObjectSelector< pat::TriggerObjectStandAlone > l2cut
Analysis-level trigger object class (stand-alone)