Skip to content

Commit 82653d5

Browse files
authored
Merge pull request #47594 from hqucms/xpog/trigobj-64b
[NANOAOD] Add missing trigger filter bits
2 parents 3da469f + 29e98f2 commit 82653d5

File tree

10 files changed

+117
-24
lines changed

10 files changed

+117
-24
lines changed

DataFormats/NanoAOD/interface/FlatTable.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ namespace nanoaod {
4444
UInt16,
4545
Int32,
4646
UInt32,
47+
Int64,
48+
UInt64,
4749
Bool,
4850
Float,
4951
Double,
@@ -158,6 +160,10 @@ namespace nanoaod {
158160
return ColumnType::Int32;
159161
else if constexpr (std::is_same<T, uint32_t>())
160162
return ColumnType::UInt32;
163+
else if constexpr (std::is_same<T, int64_t>())
164+
return ColumnType::Int64;
165+
else if constexpr (std::is_same<T, uint64_t>())
166+
return ColumnType::UInt64;
161167
else if constexpr (std::is_same<T, bool>())
162168
return ColumnType::Bool;
163169
else if constexpr (std::is_same<T, float>())
@@ -211,6 +217,10 @@ namespace nanoaod {
211217
return table.int32s_;
212218
else if constexpr (std::is_same<StorageT, uint32_t>())
213219
return table.uint32s_;
220+
else if constexpr (std::is_same<StorageT, int64_t>())
221+
return table.int64s_;
222+
else if constexpr (std::is_same<StorageT, uint64_t>())
223+
return table.uint64s_;
214224
else if constexpr (std::is_same<StorageT, float>())
215225
return table.floats_;
216226
else if constexpr (std::is_same<StorageT, double>())
@@ -228,6 +238,8 @@ namespace nanoaod {
228238
std::vector<uint16_t> uint16s_;
229239
std::vector<int32_t> int32s_;
230240
std::vector<uint32_t> uint32s_;
241+
std::vector<int64_t> int64s_;
242+
std::vector<uint64_t> uint64s_;
231243
std::vector<float> floats_;
232244
std::vector<double> doubles_;
233245
};

DataFormats/NanoAOD/src/FlatTable.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ void nanoaod::FlatTable::addExtension(const nanoaod::FlatTable& other) {
2828
case ColumnType::UInt32:
2929
addColumn<uint32_t>(other.columnName(i), other.columnData<uint32_t>(i), other.columnDoc(i));
3030
break;
31+
case ColumnType::Int64:
32+
addColumn<int64_t>(other.columnName(i), other.columnData<int64_t>(i), other.columnDoc(i));
33+
break;
34+
case ColumnType::UInt64:
35+
addColumn<uint64_t>(other.columnName(i), other.columnData<uint64_t>(i), other.columnDoc(i));
36+
break;
3137
case ColumnType::Bool:
3238
addColumn<bool>(other.columnName(i), other.columnData<bool>(i), other.columnDoc(i));
3339
break;
@@ -57,6 +63,10 @@ double nanoaod::FlatTable::getAnyValue(unsigned int row, unsigned int column) co
5763
return *(beginData<int32_t>(column) + row);
5864
case ColumnType::UInt32:
5965
return *(beginData<uint32_t>(column) + row);
66+
case ColumnType::Int64:
67+
return *(beginData<int64_t>(column) + row);
68+
case ColumnType::UInt64:
69+
return *(beginData<uint64_t>(column) + row);
6070
case ColumnType::Bool:
6171
return *(beginData<bool>(column) + row);
6272
case ColumnType::Float:

DataFormats/NanoAOD/src/classes_def.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<version ClassVersion="3" checksum="3066258528"/>
44
</class>
55
<class name="std::vector<nanoaod::FlatTable::Column>" />
6-
<class name="nanoaod::FlatTable" ClassVersion="7">
6+
<class name="nanoaod::FlatTable" ClassVersion="8">
7+
<version ClassVersion="8" checksum="62213496"/>
78
<version ClassVersion="7" checksum="4155557494"/>
89
<version ClassVersion="6" checksum="70963850"/>
910
<version ClassVersion="5" checksum="4251670483"/>

PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ class SimpleFlatTableProducerBase : public edm::stream::EDProducer<> {
228228
vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
229229
else if (type == "uint")
230230
vars_.push_back(std::make_unique<UIntVar>(vname, varPSet));
231+
else if (type == "int64")
232+
vars_.push_back(std::make_unique<Int64Var>(vname, varPSet));
233+
else if (type == "uint64")
234+
vars_.push_back(std::make_unique<UInt64Var>(vname, varPSet));
231235
else if (type == "float")
232236
vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
233237
else if (type == "double")
@@ -264,10 +268,10 @@ class SimpleFlatTableProducerBase : public edm::stream::EDProducer<> {
264268
variable.add<std::string>("doc")->setComment("few words description of the branch content");
265269
variable.addUntracked<bool>("lazyEval", false)
266270
->setComment("if true, can use methods of inheriting classes in `expr`. Can cause problems with threading.");
267-
variable.ifValue(
268-
edm::ParameterDescription<std::string>(
269-
"type", "int", true, edm::Comment("the c++ type of the branch in the flat table")),
270-
edm::allowedValues<std::string>("int", "uint", "float", "double", "uint8", "int16", "uint16", "bool"));
271+
variable.ifValue(edm::ParameterDescription<std::string>(
272+
"type", "int", true, edm::Comment("the c++ type of the branch in the flat table")),
273+
edm::allowedValues<std::string>(
274+
"int", "uint", "int64", "uint64", "float", "double", "uint8", "int16", "uint16", "bool"));
271275
variable.addOptionalNode(
272276
edm::ParameterDescription<int>(
273277
"precision", true, edm::Comment("the precision with which to store the value in the flat table")) xor
@@ -306,6 +310,8 @@ class SimpleFlatTableProducerBase : public edm::stream::EDProducer<> {
306310

307311
typedef FuncVariable<T, StringObjectFunction<T>, int32_t> IntVar;
308312
typedef FuncVariable<T, StringObjectFunction<T>, uint32_t> UIntVar;
313+
typedef FuncVariable<T, StringObjectFunction<T>, int64_t> Int64Var;
314+
typedef FuncVariable<T, StringObjectFunction<T>, uint64_t> UInt64Var;
309315
typedef FuncVariable<T, StringObjectFunction<T>, float> FloatVar;
310316
typedef FuncVariable<T, StringObjectFunction<T>, double> DoubleVar;
311317
typedef FuncVariable<T, StringObjectFunction<T>, uint8_t> UInt8Var;
@@ -336,6 +342,12 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase<T, edm::View<
336342
else if (type == "uint")
337343
extvars_.push_back(
338344
std::make_unique<UIntExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
345+
else if (type == "int64")
346+
extvars_.push_back(
347+
std::make_unique<Int64ExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
348+
else if (type == "uint64")
349+
extvars_.push_back(
350+
std::make_unique<UInt64ExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
339351
else if (type == "float")
340352
extvars_.push_back(
341353
std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
@@ -382,10 +394,10 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase<T, edm::View<
382394
edm::ParameterSetDescription extvariable;
383395
extvariable.add<edm::InputTag>("src")->setComment("valuemap input collection to fill the flat table");
384396
extvariable.add<std::string>("doc")->setComment("few words description of the branch content");
385-
extvariable.ifValue(
386-
edm::ParameterDescription<std::string>(
387-
"type", "int", true, edm::Comment("the c++ type of the branch in the flat table")),
388-
edm::allowedValues<std::string>("int", "uint", "float", "double", "uint8", "int16", "uint16", "bool"));
397+
extvariable.ifValue(edm::ParameterDescription<std::string>(
398+
"type", "int", true, edm::Comment("the c++ type of the branch in the flat table")),
399+
edm::allowedValues<std::string>(
400+
"int", "uint", "int64", "uint64", "float", "double", "uint8", "int16", "uint16", "bool"));
389401
extvariable.addOptionalNode(
390402
edm::ParameterDescription<int>(
391403
"precision", true, edm::Comment("the precision with which to store the value in the flat table")) xor
@@ -447,6 +459,8 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase<T, edm::View<
447459

448460
typedef ValueMapVariable<T, int32_t> IntExtVar;
449461
typedef ValueMapVariable<T, uint32_t> UIntExtVar;
462+
typedef ValueMapVariable<T, int64_t> Int64ExtVar;
463+
typedef ValueMapVariable<T, uint64_t> UInt64ExtVar;
450464
typedef ValueMapVariable<T, float> FloatExtVar;
451465
typedef ValueMapVariable<T, double, float> DoubleExtVar;
452466
typedef ValueMapVariable<T, bool> BoolExtVar;
@@ -471,6 +485,12 @@ class SimpleTypedExternalFlatTableProducer : public SimpleFlatTableProducer<T> {
471485
else if (type == "uint")
472486
this->typedextvars_.push_back(
473487
std::make_unique<UIntTypedExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
488+
else if (type == "int64")
489+
this->typedextvars_.push_back(
490+
std::make_unique<Int64TypedExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
491+
else if (type == "uint64")
492+
this->typedextvars_.push_back(
493+
std::make_unique<UInt64TypedExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
474494
else if (type == "float")
475495
this->typedextvars_.push_back(
476496
std::make_unique<FloatTypedExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
@@ -528,6 +548,8 @@ class SimpleTypedExternalFlatTableProducer : public SimpleFlatTableProducer<T> {
528548
protected:
529549
typedef TypedValueMapVariable<T, V, StringObjectFunction<V>, int32_t> IntTypedExtVar;
530550
typedef TypedValueMapVariable<T, V, StringObjectFunction<V>, uint32_t> UIntTypedExtVar;
551+
typedef TypedValueMapVariable<T, V, StringObjectFunction<V>, int64_t> Int64TypedExtVar;
552+
typedef TypedValueMapVariable<T, V, StringObjectFunction<V>, uint64_t> UInt64TypedExtVar;
531553
typedef TypedValueMapVariable<T, V, StringObjectFunction<V>, float> FloatTypedExtVar;
532554
typedef TypedValueMapVariable<T, V, StringObjectFunction<V>, double> DoubleTypedExtVar;
533555
typedef TypedValueMapVariable<T, V, StringCutObjectSelector<V>, bool> BoolTypedExtVar;
@@ -559,6 +581,10 @@ class SimpleCollectionFlatTableProducer : public SimpleFlatTableProducer<T> {
559581
coltable.colvars.push_back(std::make_unique<IntVectorVar>(colvarname, colvarPSet));
560582
else if (type == "uint")
561583
coltable.colvars.push_back(std::make_unique<UIntVectorVar>(colvarname, colvarPSet));
584+
else if (type == "int64")
585+
coltable.colvars.push_back(std::make_unique<Int64VectorVar>(colvarname, colvarPSet));
586+
else if (type == "uint64")
587+
coltable.colvars.push_back(std::make_unique<UInt64VectorVar>(colvarname, colvarPSet));
562588
else if (type == "float")
563589
coltable.colvars.push_back(std::make_unique<FloatVectorVar>(colvarname, colvarPSet));
564590
else if (type == "double")
@@ -700,6 +726,8 @@ class SimpleCollectionFlatTableProducer : public SimpleFlatTableProducer<T> {
700726

701727
using IntVectorVar = VectorVar<int32_t>;
702728
using UIntVectorVar = VectorVar<uint32_t>;
729+
using Int64VectorVar = VectorVar<int64_t>;
730+
using UInt64VectorVar = VectorVar<uint64_t>;
703731
using FloatVectorVar = VectorVar<float>;
704732
using DoubleVectorVar = VectorVar<double>;
705733
using UInt8VectorVar = VectorVar<uint8_t>;

PhysicsTools/NanoAOD/plugins/NanoAODDQM.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ class NanoAODDQM : public DQMEDAnalyzer {
119119
case FlatTable::ColumnType::UInt32:
120120
vfill<uint32_t>(table, icol, rowsel);
121121
break;
122+
case FlatTable::ColumnType::Int64:
123+
vfill<int64_t>(table, icol, rowsel);
124+
break;
125+
case FlatTable::ColumnType::UInt64:
126+
vfill<uint64_t>(table, icol, rowsel);
127+
break;
122128
case FlatTable::ColumnType::Bool:
123129
vfill<bool>(table, icol, rowsel);
124130
break;

PhysicsTools/NanoAOD/plugins/TableOutputBranches.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ void TableOutputBranches::defineBranchesFromFirstEvent(const nanoaod::FlatTable
2929
case nanoaod::FlatTable::ColumnType::UInt32:
3030
m_uint32Branches.emplace_back(var, tab.columnDoc(i), "i");
3131
break;
32+
case nanoaod::FlatTable::ColumnType::Int64:
33+
m_int64Branches.emplace_back(var, tab.columnDoc(i), "L");
34+
break;
35+
case nanoaod::FlatTable::ColumnType::UInt64:
36+
m_uint64Branches.emplace_back(var, tab.columnDoc(i), "l");
37+
break;
3238
case nanoaod::FlatTable::ColumnType::Bool:
3339
m_uint8Branches.emplace_back(var, tab.columnDoc(i), "O");
3440
break;
@@ -67,6 +73,8 @@ void TableOutputBranches::branch(TTree &tree) {
6773
&m_uint16Branches,
6874
&m_int32Branches,
6975
&m_uint32Branches,
76+
&m_int64Branches,
77+
&m_uint64Branches,
7078
&m_floatBranches,
7179
&m_doubleBranches}) {
7280
for (auto &pair : *branches) {
@@ -121,6 +129,10 @@ void TableOutputBranches::fill(const edm::OccurrenceForOutput &iWhatever, TTree
121129
fillColumn<int32_t>(pair, tab);
122130
for (auto &pair : m_uint32Branches)
123131
fillColumn<uint32_t>(pair, tab);
132+
for (auto &pair : m_int64Branches)
133+
fillColumn<int64_t>(pair, tab);
134+
for (auto &pair : m_uint64Branches)
135+
fillColumn<uint64_t>(pair, tab);
124136
for (auto &pair : m_floatBranches)
125137
fillColumn<float>(pair, tab);
126138
for (auto &pair : m_doubleBranches)

PhysicsTools/NanoAOD/plugins/TableOutputBranches.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class TableOutputBranches {
4747
std::vector<NamedBranchPtr> m_uint16Branches;
4848
std::vector<NamedBranchPtr> m_int32Branches;
4949
std::vector<NamedBranchPtr> m_uint32Branches;
50+
std::vector<NamedBranchPtr> m_int64Branches;
51+
std::vector<NamedBranchPtr> m_uint64Branches;
5052
std::vector<NamedBranchPtr> m_floatBranches;
5153
std::vector<NamedBranchPtr> m_doubleBranches;
5254
bool m_branchesBooked;

PhysicsTools/NanoAOD/plugins/TriggerObjectTableProducer.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ class TriggerObjectTableProducer : public edm::stream::EDProducer<> {
111111
if (qualityBitsConfig[i].existsAs<unsigned int>("bit"))
112112
bit = qualityBitsConfig[i].getParameter<unsigned int>("bit");
113113
assert(!bits[bit] && "a quality bit was inserted twice"); // the bit should not have been set already
114-
assert(bit < 31 && "quality bits are store on 32 bit");
114+
assert(bit < 64 && "quality bits are store on 64 bits");
115115
bits[bit] = true;
116-
qualityBitsFunc << std::to_string(int(pow(2, bit))) << "*("
116+
qualityBitsFunc << std::to_string(1UL << bit) << "*("
117117
<< qualityBitsConfig[i].getParameter<std::string>("selection") << ")";
118118
qualityBitsDoc += std::to_string(bit) + " => " + qualityBitsConfig[i].getParameter<std::string>("doc");
119119
}
@@ -147,12 +147,12 @@ void TriggerObjectTableProducer::produce(edm::Event &iEvent, const edm::EventSet
147147
const auto &trigObjs = iEvent.get(src_);
148148

149149
std::vector<std::pair<const pat::TriggerObjectStandAlone *, const SelectedObject *>> selected;
150-
std::map<int, std::map<const pat::TriggerObjectStandAlone *, int>> selected_bits;
150+
std::map<int, std::map<const pat::TriggerObjectStandAlone *, uint64_t>> selected_bits;
151151
for (const auto &obj : trigObjs) {
152152
for (const auto &sel : sels_) {
153153
if (sel.match(obj)) {
154-
selected_bits[sel.id][&obj] = int(sel.qualityBits(obj));
155-
if (sel.skipObjectsNotPassingQualityBits ? (selected_bits[sel.id][&obj] > 0) : true) {
154+
selected_bits[sel.id][&obj] = sel.qualityBits(obj);
155+
if (sel.skipObjectsNotPassingQualityBits ? (selected_bits[sel.id][&obj] != 0) : true) {
156156
selected.emplace_back(&obj, &sel);
157157
}
158158
}
@@ -269,7 +269,8 @@ void TriggerObjectTableProducer::produce(edm::Event &iEvent, const edm::EventSet
269269
std::vector<float> pt(nobj, 0), eta(nobj, 0), phi(nobj, 0), l1pt(nobj, 0), l1pt_2(nobj, 0), l2pt(nobj, 0);
270270
std::vector<int16_t> l1charge(nobj, 0);
271271
std::vector<uint16_t> id(nobj, 0);
272-
std::vector<int> bits(nobj, 0), l1iso(nobj, 0);
272+
std::vector<uint64_t> bits(nobj, 0);
273+
std::vector<int> l1iso(nobj, 0);
273274
for (unsigned int i = 0; i < nobj; ++i) {
274275
const auto &obj = *selected[i].first;
275276
const auto &sel = *selected[i].second;
@@ -324,7 +325,7 @@ void TriggerObjectTableProducer::produce(edm::Event &iEvent, const edm::EventSet
324325
tab->addColumn<int16_t>("l1charge", l1charge, "charge of associated L1 seed");
325326
tab->addColumn<float>("l1pt_2", l1pt_2, "pt of associated secondary L1 seed", 8);
326327
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_);
328+
tab->addColumn<uint64_t>("filterBits", bits, "extra bits of associated information: " + bitsDoc_);
328329
iEvent.put(std::move(tab));
329330
}
330331

PhysicsTools/NanoAOD/python/nanoDQM_cfi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,12 +987,14 @@
987987
MHT = cms.string('id == 4'),
988988
Muon = cms.string('id == 13'),
989989
Photon = cms.string('id == 22'),
990-
Tau = cms.string('id == 15')
990+
Tau = cms.string('id == 15'),
991+
FatJet = cms.string('id == 6'),
992+
BoostedTau = cms.string('id == 1515'),
991993
),
992994
plots = cms.VPSet(
993995
Count1D('_size', 28, -0.5, 27.5),
994996
Plot1D('eta', 'eta', 20, -5, 5, 'eta'),
995-
Plot1D('filterBits', 'filterBits', 31, 0, 31, 'extra bits of associated information, object- and era-dependent: see branch documentation', bitset=True),
997+
Plot1D('filterBits', 'filterBits', 64, 0, 64, 'extra bits of associated information, object- and era-dependent: see branch documentation', bitset=True),
996998
Plot1D('id', 'id', 20, 0, 30, 'ID of the object: 11 = Electron (PixelMatched e/gamma), 22 = Photon (PixelMatch-vetoed e/gamma), 13 = Muon, 14 = Tau, 1 = Jet, 2 = MET, 3 = HT, 4 = MHT'),
997999
Plot1D('l1charge', 'l1charge', 3, -1.5, 1.5, 'charge of associated L1 seed'),
9981000
Plot1D('l1iso', 'l1iso', 4, -0.5, 3.5, 'iso of associated L1 seed'),

0 commit comments

Comments
 (0)