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

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

Member Function Documentation

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

Definition at line 27 of file EventStringOutputBranches.cc.

References edm::OccurrenceForOutput::getByToken(), cmsBatch::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().

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
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
void updateEventStringNames(TTree &, const std::string &)
Definition: tree.py:1
void EventStringOutputBranches::updateEventStringNames ( TTree &  tree,
const std::string &  evstring 
)

Definition at line 8 of file EventStringOutputBranches.cc.

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

Referenced by EventStringOutputBranches(), and fill().

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 }
std::vector< NamedBranchPtr > m_evStringBranches
Definition: tree.py:1

Member Data Documentation

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

Definition at line 32 of file EventStringOutputBranches.h.

Referenced by updateEventStringNames().

unsigned long EventStringOutputBranches::m_fills
private

Definition at line 34 of file EventStringOutputBranches.h.

Referenced by fill(), and updateEventStringNames().

long EventStringOutputBranches::m_lastLumi
private

Definition at line 33 of file EventStringOutputBranches.h.

Referenced by fill().

edm::EDGetToken EventStringOutputBranches::m_token
private

Definition at line 24 of file EventStringOutputBranches.h.

Referenced by fill().

bool EventStringOutputBranches::m_update_only_at_new_lumi
private

Definition at line 35 of file EventStringOutputBranches.h.

Referenced by fill().