CMS 3D CMS Logo

EventStringOutputBranches.cc
Go to the documentation of this file.
4 
5 #include <iostream>
6 
7 void
9 {
10  bool found = false;
11  for (auto & existing : m_evStringBranches) {
12  existing.buffer = false;
13  if (evstring==existing.name) {existing.buffer = true; found=true;}
14  }
15  if (!found && (!evstring.empty())){
16  NamedBranchPtr nb(evstring,"EventString bit");
17  bool backFillValue = false;
18  nb.branch = tree.Branch(nb.name.c_str(), &backFillValue, (nb.name + "/O").c_str());
19  nb.branch->SetTitle(nb.title.c_str());
20  for(size_t i=0;i<m_fills;i++) nb.branch->Fill(); // Back fill
21  nb.buffer = true;
22  m_evStringBranches.push_back(nb);
23  for (auto & existing : m_evStringBranches) existing.branch->SetAddress(&(existing.buffer)); // m_evStringBranches might have been resized
24  }
25 }
26 
28 {
31  iEvent.getByToken(m_token, handle);
32  const std::string & evstring = *handle;
33  m_lastLumi=iEvent.id().luminosityBlock();
34  updateEventStringNames(tree,evstring);
35  }
36  m_fills++;
37 }
EventID const & id() const
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
void fill(const edm::EventForOutput &iEvent, TTree &tree)
std::vector< NamedBranchPtr > m_evStringBranches
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
int iEvent
Definition: GenABIO.cc:224
void updateEventStringNames(TTree &, const std::string &)
Definition: tree.py:1