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.

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  }

References submitPVResolutionJobs::desc.

Member Function Documentation

◆ fill()

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

Definition at line 30 of file EventStringOutputBranches.cc.

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 }

References patZpeak::handle, iEvent, m_fills, m_lastLumi, m_token, m_update_only_at_new_lumi, AlCaHLTBitMon_QueryRunRegistry::string, and updateEventStringNames().

◆ updateEventStringNames()

void EventStringOutputBranches::updateEventStringNames ( TTree &  tree,
const std::string &  evstring 
)

Definition at line 7 of file EventStringOutputBranches.cc.

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 }

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().

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().

EventStringOutputBranches::m_evStringBranches
std::vector< NamedBranchPtr > m_evStringBranches
Definition: EventStringOutputBranches.h:34
mps_fire.i
i
Definition: mps_fire.py:428
EventStringOutputBranches::updateEventStringNames
void updateEventStringNames(TTree &, const std::string &)
Definition: EventStringOutputBranches.cc:7
patZpeak.handle
handle
Definition: patZpeak.py:23
tree
Definition: tree.py:1
dqmPostProcessing_online.existing
existing
Definition: dqmPostProcessing_online.py:126
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
EventStringOutputBranches::m_lastLumi
long m_lastLumi
Definition: EventStringOutputBranches.h:35
iEvent
int iEvent
Definition: GenABIO.cc:224
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EventStringOutputBranches::m_update_only_at_new_lumi
bool m_update_only_at_new_lumi
Definition: EventStringOutputBranches.h:37
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
EventStringOutputBranches::m_fills
unsigned long m_fills
Definition: EventStringOutputBranches.h:36
EventStringOutputBranches::m_token
edm::EDGetToken m_token
Definition: EventStringOutputBranches.h:26
cms::Exception
Definition: Exception.h:70
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316