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::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 submitPVResolutionJobs::desc.

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  }

Member Function Documentation

◆ fill()

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

◆ updateEventStringNames()

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 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

◆ m_evStringBranches

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

Definition at line 34 of file EventStringOutputBranches.h.

Referenced by updateEventStringNames().

◆ m_fills

unsigned long EventStringOutputBranches::m_fills
private

Definition at line 36 of file EventStringOutputBranches.h.

Referenced by fill(), and updateEventStringNames().

◆ m_lastLumi

long EventStringOutputBranches::m_lastLumi
private

Definition at line 35 of file EventStringOutputBranches.h.

Referenced by fill().

◆ m_token

edm::EDGetToken EventStringOutputBranches::m_token
private

Definition at line 26 of file EventStringOutputBranches.h.

Referenced by fill().

◆ m_update_only_at_new_lumi

bool EventStringOutputBranches::m_update_only_at_new_lumi
private

Definition at line 37 of file EventStringOutputBranches.h.

Referenced by fill().