CMS 3D CMS Logo

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:
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
TriggerOutputBranches::verifyBranchUniqueName
bool verifyBranchUniqueName(TTree &, std::string) const
Definition: TriggerOutputBranches.cc:99
TriggerOutputBranches::NamedBranchPtr::branch
TBranch * branch
Definition: TriggerOutputBranches.h:38
TriggerOutputBranches::NamedBranchPtr::name
std::string name
Definition: TriggerOutputBranches.h:36
TriggerOutputBranches::processName
std::string processName()
Definition: TriggerOutputBranches.h:24
TriggerOutputBranches::NamedBranchPtr::buffer
uint8_t buffer
Definition: TriggerOutputBranches.h:39
TriggerResults.h
TriggerOutputBranches::m_singleton
bool m_singleton
Definition: TriggerOutputBranches.h:33
TriggerOutputBranches::m_triggerBranches
std::vector< NamedBranchPtr > m_triggerBranches
Definition: TriggerOutputBranches.h:43
TriggerOutputBranches::NamedBranchPtr::NamedBranchPtr
NamedBranchPtr(const std::string &aname, const std::string &atitle, TBranch *branchptr=nullptr)
Definition: TriggerOutputBranches.h:40
tree
Definition: tree.py:1
TriggerOutputBranches::triggerNames
edm::TriggerNames triggerNames(const edm::TriggerResults triggerResults)
Definition: TriggerOutputBranches.cc:63
TriggerOutputBranches::NamedBranchPtr::title
std::string title
Definition: TriggerOutputBranches.h:36
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
TriggerOutputBranches
Definition: TriggerOutputBranches.h:13
EventForOutput.h
TriggerOutputBranches::fillColumn
void fillColumn(NamedBranchPtr &nb, const edm::TriggerResults &triggers)
Definition: TriggerOutputBranches.h:50
TriggerOutputBranches::m_lastRun
long m_lastRun
Definition: TriggerOutputBranches.h:44
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
TriggerOutputBranches::updateTriggerNames
void updateTriggerNames(TTree &tree, const edm::TriggerNames &names, const edm::TriggerResults &ta)
Definition: TriggerOutputBranches.cc:8
TriggerOutputBranches::m_token
edm::EDGetToken m_token
Definition: TriggerOutputBranches.h:31
EDGetToken.h
TriggerOutputBranches::m_fills
unsigned long m_fills
Definition: TriggerOutputBranches.h:45
TriggerOutputBranches::m_counter
UInt_t m_counter
Definition: TriggerOutputBranches.h:34
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TriggerOutputBranches::NamedBranchPtr
Definition: TriggerOutputBranches.h:35
BranchDescription.h
TriggerOutputBranches::TriggerOutputBranches
TriggerOutputBranches(const edm::BranchDescription *desc, const edm::EDGetToken &token)
Definition: TriggerOutputBranches.h:15
TriggerNames.h
iEvent
int iEvent
Definition: GenABIO.cc:224
TriggerOutputBranches::fill
void fill(const edm::EventForOutput &iEvent, TTree &tree)
Definition: TriggerOutputBranches.cc:84
edm::EDGetToken
Definition: EDGetToken.h:35
edm::EventForOutput
Definition: EventForOutput.h:50
TriggerOutputBranches::NamedBranchPtr::idx
int idx
Definition: TriggerOutputBranches.h:37
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::TriggerNames
Definition: TriggerNames.h:55
edm::HLTGlobalStatus::accept
bool accept() const
Has at least one path accepted the event?
Definition: HLTGlobalStatus.h:49
edm::BranchDescription
Definition: BranchDescription.h:32
TriggerOutputBranches::m_baseName
std::string m_baseName
Definition: TriggerOutputBranches.h:32
cms::Exception
Definition: Exception.h:70
TriggerOutputBranches::m_processName
std::string m_processName
Definition: TriggerOutputBranches.h:46
edm::TriggerResults
Definition: TriggerResults.h:35
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:318