File indexing completed on 2025-08-12 02:29:05
0001 #ifndef L1TriggerScouting_Utilities_SelectedBxTableOutputBranches_h
0002 #define L1TriggerScouting_Utilities_SelectedBxTableOutputBranches_h
0003
0004 #include <string>
0005 #include <vector>
0006 #include <bitset>
0007 #include <TTree.h>
0008 #include "FWCore/Framework/interface/OccurrenceForOutput.h"
0009 #include "DataFormats/NanoAOD/interface/OrbitFlatTable.h"
0010 #include "DataFormats/Provenance/interface/BranchDescription.h"
0011 #include "FWCore/Utilities/interface/EDGetToken.h"
0012
0013 class SelectedBxTableOutputBranches {
0014 public:
0015 SelectedBxTableOutputBranches(const edm::BranchDescription *desc, const edm::EDGetToken &token)
0016 : m_token(token), m_name("SelBx_" + desc->moduleLabel()), m_branch(nullptr) {
0017 if (desc->className() != "std::vector<unsigned int>")
0018 throw cms::Exception("Configuration", "SelectedBxTableOutputBranches can only write out vector<unsigned int>");
0019 if (desc->productInstanceName() != "SelBx") {
0020 m_name += "_" + desc->productInstanceName();
0021 }
0022 }
0023
0024 void beginFill(const edm::OccurrenceForOutput &iWhatever, TTree &tree);
0025 void fillBx(uint32_t bx) { m_value = m_bitset[bx]; }
0026 void endFill() {}
0027
0028 private:
0029 edm::EDGetToken m_token;
0030 std::string m_name;
0031 bool m_value;
0032 std::bitset<l1ScoutingRun3::OrbitFlatTable::NBX> m_bitset;
0033 TBranch *m_branch;
0034
0035 edm::Handle<std::vector<unsigned int>> m_handle;
0036 };
0037
0038 #endif