Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:40

0001 #ifndef PhysicsTools_NanoAOD_EventStringOutputBranches_h
0002 #define PhysicsTools_NanoAOD_EventStringOutputBranches_h
0003 
0004 #include <string>
0005 #include <vector>
0006 #include <TTree.h>
0007 #include "FWCore/Framework/interface/EventForOutput.h"
0008 #include "DataFormats/Provenance/interface/BranchDescription.h"
0009 #include "FWCore/Utilities/interface/EDGetToken.h"
0010 
0011 class EventStringOutputBranches {
0012 public:
0013   EventStringOutputBranches(const edm::BranchDescription *desc,
0014                             const edm::EDGetToken &token,
0015                             bool update_only_at_new_lumi = false)
0016       : m_token(token), m_lastLumi(-1), m_fills(0), m_update_only_at_new_lumi(update_only_at_new_lumi) {
0017     if (desc->className() != "std::basic_string<char,std::char_traits<char> >")
0018       throw cms::Exception("Configuration",
0019                            "NanoAODOutputModule/EventStringOutputBranches can only write out std::string objects");
0020   }
0021 
0022   void updateEventStringNames(TTree &, const std::string &);
0023   void fill(const edm::EventForOutput &iEvent, TTree &tree);
0024 
0025 private:
0026   edm::EDGetToken m_token;
0027   struct NamedBranchPtr {
0028     std::string name, title;
0029     TBranch *branch;
0030     bool buffer;
0031     NamedBranchPtr(const std::string &aname, const std::string &atitle, TBranch *branchptr = nullptr)
0032         : name(aname), title(atitle), branch(branchptr), buffer(false) {}
0033   };
0034   std::vector<NamedBranchPtr> m_evStringBranches;
0035   long m_lastLumi;
0036   unsigned long m_fills;
0037   bool m_update_only_at_new_lumi;
0038 };
0039 
0040 #endif