File indexing completed on 2025-01-31 02:18:54
0001 #ifndef Shallow_Tree_h
0002 #define Shallow_Tree_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0023 #include "FWCore/Framework/interface/Event.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/ServiceRegistry/interface/Service.h"
0026 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0027 #include "FWCore/Utilities/interface/InputTag.h"
0028
0029 #include <string>
0030 #include <vector>
0031 #include <TTree.h>
0032 #include <memory>
0033
0034 class ShallowTree : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0035 private:
0036 void analyze(const edm::Event&, const edm::EventSetup&) override;
0037
0038 template <class T>
0039 void eat(edm::ProductDescription const& desc) {
0040 consumes<T>(edm::InputTag(desc.moduleLabel(), desc.productInstanceName()));
0041 }
0042
0043 class BranchConnector {
0044 public:
0045 virtual ~BranchConnector() {}
0046 virtual void connect(const edm::Event&) = 0;
0047 };
0048
0049 template <class T>
0050 class TypedBranchConnector : public BranchConnector {
0051 private:
0052 std::string ml_;
0053 std::string pin_;
0054 T object_;
0055 T* object_ptr_;
0056
0057 public:
0058 TypedBranchConnector(edm::ProductDescription const*, std::string, TTree*);
0059 void connect(const edm::Event&) override;
0060 };
0061
0062 TTree* tree_;
0063 std::vector<std::unique_ptr<BranchConnector>> connectors_;
0064
0065 public:
0066 explicit ShallowTree(const edm::ParameterSet& iConfig);
0067
0068 enum LEAFTYPE {
0069 BOOL = 1,
0070 BOOL_V,
0071 SHORT,
0072 SHORT_V,
0073 U_SHORT,
0074 U_SHORT_V,
0075 INT,
0076 INT_V,
0077 U_INT,
0078 U_INT_V,
0079 FLOAT,
0080 FLOAT_V,
0081 DOUBLE,
0082 DOUBLE_V,
0083 LONG,
0084 LONG_V,
0085 U_LONG,
0086 U_LONG_V,
0087 CHAR,
0088 CHAR_V,
0089 U_CHAR,
0090 U_CHAR_V
0091 };
0092 };
0093
0094 #endif