CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
EventStringOutputBranches Class Reference

#include <EventStringOutputBranches.h>

Classes

struct  NamedBranchPtr
 

Public Member Functions

 EventStringOutputBranches (const edm::BranchDescription *desc, const edm::EDGetToken &token, bool update_only_at_new_lumi=false)
 
void fill (const edm::EventForOutput &iEvent, TTree &tree)
 
void updateEventStringNames (TTree &, const std::string &)
 

Private Attributes

std::vector< NamedBranchPtrm_evStringBranches
 
unsigned long m_fills
 
long m_lastLumi
 
edm::EDGetToken m_token
 
bool m_update_only_at_new_lumi
 

Detailed Description

Definition at line 11 of file EventStringOutputBranches.h.

Constructor & Destructor Documentation

EventStringOutputBranches::EventStringOutputBranches ( const edm::BranchDescription desc,
const edm::EDGetToken token,
bool  update_only_at_new_lumi = false 
)
inline

Definition at line 13 of file EventStringOutputBranches.h.

References edm::BranchDescription::className(), fill(), iEvent, AlCaHLTBitMon_QueryRunRegistry::string, and updateEventStringNames().

16  : m_token(token), m_lastLumi(-1), m_fills(0), m_update_only_at_new_lumi(update_only_at_new_lumi) {
17  if (desc->className() != "std::basic_string<char,std::char_traits<char> >")
18  throw cms::Exception("Configuration",
19  "NanoAODOutputModule/EventStringOutputBranches can only write out std::string objects");
20  }
std::string const & className() const

Member Function Documentation

void EventStringOutputBranches::fill ( const edm::EventForOutput iEvent,
TTree &  tree 
)

Definition at line 30 of file EventStringOutputBranches.cc.

References edm::OccurrenceForOutput::getByToken(), patZpeak::handle, edm::EventForOutput::id(), edm::EventID::luminosityBlock(), m_fills, m_lastLumi, m_token, m_update_only_at_new_lumi, AlCaHLTBitMon_QueryRunRegistry::string, and updateEventStringNames().

Referenced by EventStringOutputBranches().

30  {
31  if ((!m_update_only_at_new_lumi) || m_lastLumi != iEvent.id().luminosityBlock()) {
33  iEvent.getByToken(m_token, handle);
34  const std::string &evstring = *handle;
35  m_lastLumi = iEvent.id().luminosityBlock();
36  updateEventStringNames(tree, evstring);
37  }
38  m_fills++;
39 }
EventID const & id() const
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
void updateEventStringNames(TTree &, const std::string &)
Definition: tree.py:1
void EventStringOutputBranches::updateEventStringNames ( TTree &  tree,
const std::string &  evstring 
)

Definition at line 7 of file EventStringOutputBranches.cc.

References EventStringOutputBranches::NamedBranchPtr::branch, EventStringOutputBranches::NamedBranchPtr::buffer, dqmPostProcessing_online::existing, newFWLiteAna::found, mps_fire::i, m_evStringBranches, m_fills, EventStringOutputBranches::NamedBranchPtr::name, and EventStringOutputBranches::NamedBranchPtr::title.

Referenced by EventStringOutputBranches(), and fill().

7  {
8  bool found = false;
9  for (auto &existing : m_evStringBranches) {
10  existing.buffer = false;
11  if (evstring == existing.name) {
12  existing.buffer = true;
13  found = true;
14  }
15  }
16  if (!found && (!evstring.empty())) {
17  NamedBranchPtr nb(evstring, "EventString bit");
18  bool backFillValue = false;
19  nb.branch = tree.Branch(nb.name.c_str(), &backFillValue, (nb.name + "/O").c_str());
20  nb.branch->SetTitle(nb.title.c_str());
21  for (size_t i = 0; i < m_fills; i++)
22  nb.branch->Fill(); // Back fill
23  nb.buffer = true;
24  m_evStringBranches.push_back(nb);
25  for (auto &existing : m_evStringBranches)
26  existing.branch->SetAddress(&(existing.buffer)); // m_evStringBranches might have been resized
27  }
28 }
std::vector< NamedBranchPtr > m_evStringBranches
Definition: tree.py:1

Member Data Documentation

std::vector<NamedBranchPtr> EventStringOutputBranches::m_evStringBranches
private

Definition at line 34 of file EventStringOutputBranches.h.

Referenced by updateEventStringNames().

unsigned long EventStringOutputBranches::m_fills
private

Definition at line 36 of file EventStringOutputBranches.h.

Referenced by fill(), and updateEventStringNames().

long EventStringOutputBranches::m_lastLumi
private

Definition at line 35 of file EventStringOutputBranches.h.

Referenced by fill().

edm::EDGetToken EventStringOutputBranches::m_token
private

Definition at line 26 of file EventStringOutputBranches.h.

Referenced by fill().

bool EventStringOutputBranches::m_update_only_at_new_lumi
private

Definition at line 37 of file EventStringOutputBranches.h.

Referenced by fill().