File indexing completed on 2024-04-06 12:23:22
0001
0002
0003 #if !defined(EventContainer_H)
0004 #define EventContainer_H
0005
0006 #include <map>
0007 #include <string>
0008 #include <typeinfo>
0009
0010 #include "TH1.h"
0011 #include "TFile.h"
0012
0013 #include "FWCore/Utilities/interface/InputTag.h"
0014 #include "DataFormats/Common/interface/Handle.h"
0015 #include "PhysicsTools/FWLite/interface/CommandLineParser.h"
0016 #include "DataFormats/FWLite/interface/EventBase.h"
0017 #include "PhysicsTools/FWLite/interface/TH1Store.h"
0018
0019 namespace fwlite {
0020
0021 class EventContainer : public EventBase {
0022 public:
0023
0024
0025
0026
0027 typedef std::map<std::string, std::string> SSMap;
0028 typedef void (*FuncPtr)(std::string&);
0029
0030
0031
0032
0033
0034 friend std::ostream& operator<<(std::ostream& o_stream, const EventContainer& rhs);
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 EventContainer(optutl::CommandLineParser& parser, FuncPtr funcPtr = nullptr);
0047 ~EventContainer() override;
0048
0049
0050
0051
0052
0053
0054 int eventsSeen() const { return m_eventsSeen; }
0055
0056
0057
0058
0059
0060
0061
0062 void add(TH1* histPtr, const std::string& directory = "");
0063
0064
0065 TH1* hist(const std::string& name);
0066 TH1* hist(const char* name) { return hist((const std::string)name); }
0067 TH1* hist(const TString& name) { return hist((const char*)name); }
0068
0069
0070 optutl::CommandLineParser& parser();
0071
0072
0073
0074
0075 bool getByLabel(const std::type_info& iInfo,
0076 const char* iModuleLabel,
0077 const char* iProductInstanceLabel,
0078 const char* iProcessLabel,
0079 void* oData) const override;
0080
0081 const std::string getBranchNameFor(const std::type_info& iInfo,
0082 const char* iModuleLabel,
0083 const char* iProductInstanceLabel,
0084 const char* iProcessLabel) const override;
0085
0086 const EventContainer& operator++() override;
0087
0088 const EventContainer& toBegin() override;
0089
0090 bool atEnd() const override;
0091
0092 edm::TriggerNames const& triggerNames(edm::TriggerResults const& triggerResults) const override {
0093 return m_eventBasePtr->triggerNames(triggerResults);
0094 }
0095
0096 edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const& triggerResults) const override {
0097 return m_eventBasePtr->triggerResultsByName(triggerResults);
0098 }
0099
0100 Long64_t fileIndex() const override { return m_eventBasePtr->fileIndex(); }
0101 Long64_t secondaryFileIndex() const override { return m_eventBasePtr->secondaryFileIndex(); }
0102
0103 edm::EventAuxiliary const& eventAuxiliary() const override { return m_eventBasePtr->eventAuxiliary(); }
0104
0105 template <class T>
0106 bool getByLabel(const edm::InputTag& tag, edm::Handle<T>& handle) const {
0107 return m_eventBasePtr->getByLabel(tag, handle);
0108 }
0109
0110
0111
0112
0113 private:
0114
0115
0116
0117
0118
0119 EventContainer(const EventContainer& rhs) {}
0120
0121
0122
0123
0124
0125 fwlite::EventBase* m_eventBasePtr;
0126 TH1Store m_histStore;
0127 std::string m_outputName;
0128 int m_eventsSeen;
0129 int m_maxWanted;
0130 int m_outputEvery;
0131 optutl::CommandLineParser* m_parserPtr;
0132
0133
0134
0135
0136
0137 static bool sm_autoloaderCalled;
0138 };
0139 }
0140
0141 #endif