CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TriggerOutputBranches.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_NanoAOD_TriggerOutputBranches_h
2 #define PhysicsTools_NanoAOD_TriggerOutputBranches_h
3 
4 #include <string>
5 #include <vector>
6 #include <TTree.h>
12 
14 public:
16  : m_token(token), m_lastRun(-1), m_fills(0), m_processName(desc->processName()) {
17  if (desc->className() != "edm::TriggerResults")
18  throw cms::Exception("Configuration",
19  "NanoAODOutputModule/TriggerOutputBranches can only write out edm::TriggerResults objects");
20  }
21 
22  void updateTriggerNames(TTree &tree, const edm::TriggerNames &names, const edm::TriggerResults &ta);
23  void fill(const edm::EventForOutput &iEvent, TTree &tree);
25 
26 private:
29  triggerResults); //FIXME: if we have to keep it local we may use PsetID check per event instead of run boundary
30 
34  UInt_t m_counter;
35  struct NamedBranchPtr {
37  int idx;
38  TBranch *branch;
39  uint8_t buffer;
40  NamedBranchPtr(const std::string &aname, const std::string &atitle, TBranch *branchptr = nullptr)
41  : name(aname), title(atitle), branch(branchptr), buffer(0) {}
42  };
43  std::vector<NamedBranchPtr> m_triggerBranches;
44  long m_lastRun;
45  unsigned long m_fills;
47  bool verifyBranchUniqueName(TTree &, std::string) const;
48 
49  template <typename T>
50  void fillColumn(NamedBranchPtr &nb, const edm::TriggerResults &triggers) {
51  nb.buffer = (nb.idx >= 0) ? triggers.accept(nb.idx) : 0;
52  nb.branch->SetAddress(&(nb.buffer)); // Can be improved: this is not reallt needed at each event
53  //but we should be sure that resize of vectors of TriggerOutputBranches do not mess up things
54  }
55 };
56 
57 #endif
void fillColumn(NamedBranchPtr &nb, const edm::TriggerResults &triggers)
bool accept() const
Has at least one path accepted the event?
const std::string names[nVars_]
int iEvent
Definition: GenABIO.cc:224
TriggerOutputBranches(const edm::BranchDescription *desc, const edm::EDGetToken &token)
std::string const & className() const
bool verifyBranchUniqueName(TTree &, std::string) const
static std::string const triggerResults
Definition: EdmProvDump.cc:44
edm::TriggerNames triggerNames(const edm::TriggerResults triggerResults)
NamedBranchPtr(const std::string &aname, const std::string &atitle, TBranch *branchptr=nullptr)
void fill(const edm::EventForOutput &iEvent, TTree &tree)
void updateTriggerNames(TTree &tree, const edm::TriggerNames &names, const edm::TriggerResults &ta)
std::vector< NamedBranchPtr > m_triggerBranches