CMS 3D CMS Logo

TriggerOutputBranches.cc
Go to the documentation of this file.
4 
5 #include <iostream>
6 
7 void
9 {
10  std::vector<std::string> newNames(triggers.getTriggerNames());
11  if(newNames.empty()) {
12  for(unsigned int j=0;j<triggers.size();j++) {
13  newNames.push_back(names.triggerName(j));
14  }
15  }
16 
17  for(auto & existing : m_triggerBranches)
18  {
19  existing.idx=-1;// reset all triggers as not found
20  for(unsigned int j=0;j<newNames.size();j++) {
21  std::string name=newNames[j]; // no const & as it will be modified below!
22  std::size_t vfound = name.rfind("_v");
23  if (vfound!=std::string::npos){
24  name.replace(vfound,name.size()-vfound,"");
25  }
26  if(name==existing.name) existing.idx=j;
27  }
28  }
29  // Find new ones
30  for(unsigned int j=0;j<newNames.size();j++) {
31  std::string name=newNames[j]; // no const & as it will be modified below!
32  std::size_t vfound = name.rfind("_v");
33  if (vfound!=std::string::npos){
34  name.replace(vfound,name.size()-vfound,"");
35  }
36  bool found=false;
37  if(name.compare(0,3,"HLT")==0 || name.compare(0,4,"Flag")==0 || name.compare(0,2,"L1")==0 ){
38  for(auto & existing : m_triggerBranches) {if(name==existing.name) found=true;}
39  if(!found){
40  NamedBranchPtr nb(name,"Trigger/flag bit"); //FIXME: If the title can be updated we can use it to list the versions _v* that were seen in this file
41  uint8_t backFillValue=-1;
42  nb.branch= tree.Branch(nb.name.c_str(), &backFillValue, (name + "/O").c_str());
43  nb.branch->SetTitle(nb.title.c_str());
44  nb.idx=j;
45  m_triggerBranches.push_back(nb);
46  for(size_t i=0;i<m_fills;i++) nb.branch->Fill(); // Back fill
47  }
48  }
49  }
50 }
51 
54  edm::ParameterSet const* pset=nullptr;
55  if (nullptr!=(pset=psetRegistry->getMapped(triggerResults.parameterSetID()))) {
56 
57  if (pset->existsAs<std::vector<std::string> >("@trigger_paths", true)) {
59 
60  // This should never happen
61  if (triggerNames.size() != triggerResults.size()) {
62  throw cms::Exception("LogicError")
63  << "edm::EventBase::triggerNames_ Encountered vector\n"
64  "of trigger names and a TriggerResults object with\n"
65  "different sizes. This should be impossible.\n"
66  "Please send information to reproduce this problem to\n"
67  "the edm developers.\n";
68  }
69  return triggerNames;
70  }
71  }
72  return edm::TriggerNames();
73 }
74 
76 {
78  iEvent.getByToken(m_token, handle);
79  const edm::TriggerResults & triggers = *handle;
80  const edm::TriggerNames &names = triggerNames(triggers);
81 
82  if(m_lastRun!=iEvent.id().run()) {
83  m_lastRun=iEvent.id().run();
84  updateTriggerNames(tree,names,triggers);
85  }
86  for (auto & pair : m_triggerBranches) fillColumn<uint8_t>(pair, triggers);
87  m_fills++;
88 }
89 
90 
91 
RunNumber_t run() const
Definition: EventID.h:39
EventID const & id() const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
static const HistoName names[]
Strings::size_type size() const
Definition: TriggerNames.cc:39
const std::vector< std::string > & getTriggerNames() const
Obsolete.
bool getByToken(EDGetToken token, TypeID const &typeID, BasicHandle &result) const
int iEvent
Definition: GenABIO.cc:230
unsigned int size() const
Get number of paths stored.
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:19
static std::string const triggerResults
Definition: EdmProvDump.cc:41
edm::TriggerNames triggerNames(const edm::TriggerResults triggerResults)
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
Definition: tree.py:1
void fill(const edm::EventForOutput &iEvent, TTree &tree)
const ParameterSetID & parameterSetID() const
Get stored parameter set id.
void updateTriggerNames(TTree &tree, const edm::TriggerNames &names, const edm::TriggerResults &ta)
std::vector< NamedBranchPtr > m_triggerBranches
static Registry * instance()
Definition: Registry.cc:13