File indexing completed on 2023-03-17 10:44:23
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
0033 class ShallowTree : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0034 private:
0035 void analyze(const edm::Event&, const edm::EventSetup&) override;
0036
0037 template <class T>
0038 void eat(edm::BranchDescription const* desc) {
0039 consumes<T>(edm::InputTag(desc->moduleLabel(), desc->productInstanceName()));
0040 }
0041
0042 class BranchConnector {
0043 public:
0044 virtual ~BranchConnector(){};
0045 virtual void connect(const edm::Event&) = 0;
0046 };
0047
0048 template <class T>
0049 class TypedBranchConnector : public BranchConnector {
0050 private:
0051 std::string ml;
0052 std::string pin;
0053 T object_;
0054 T* object_ptr_;
0055
0056 public:
0057 TypedBranchConnector(edm::BranchDescription const*, std::string, TTree*);
0058 void connect(const edm::Event&) override;
0059 };
0060
0061 edm::Service<TFileService> fs_;
0062 TTree* tree_;
0063 std::vector<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