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 
33  UInt_t m_counter;
34  struct NamedBranchPtr {
36  int idx;
37  TBranch *branch;
38  uint8_t buffer;
39  NamedBranchPtr(const std::string &aname, const std::string &atitle, TBranch *branchptr = nullptr)
40  : name(aname), title(atitle), branch(branchptr), buffer(0) {}
41  };
42  std::vector<NamedBranchPtr> m_triggerBranches;
43  long m_lastRun;
44  unsigned long m_fills;
46  bool verifyBranchUniqueName(TTree &, std::string) const;
47 
48  template <typename T>
49  void fillColumn(NamedBranchPtr &nb, const edm::TriggerResults &triggers) {
50  nb.buffer = (nb.idx >= 0) ? triggers.accept(nb.idx) : 0;
51  nb.branch->SetAddress(&(nb.buffer)); // Can be improved: this is not reallt needed at each event
52  //but we should be sure that resize of vectors of TriggerOutputBranches do not mess up things
53  }
54 };
55 
56 #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