File indexing completed on 2025-08-06 08:12:25
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef MCSelfGenReader_h
0009 #define MCSelfGenReader_h
0010
0011 #include <TROOT.h>
0012 #include <TChain.h>
0013 #include <TFile.h>
0014
0015
0016 #include "vector"
0017 #include "vector"
0018 #include "vector"
0019
0020 class MCSelfGenReader {
0021 public :
0022 TTree *fChain;
0023 Int_t fCurrent;
0024
0025
0026
0027
0028 Int_t NClus;
0029 vector<int> *system;
0030 vector<int> *layer;
0031 vector<int> *adc;
0032 vector<double> *X;
0033 vector<double> *Y;
0034 vector<double> *Z;
0035 vector<int> *size;
0036 vector<int> *phi_size;
0037 vector<int> *Z_size;
0038 Double_t TruthPV_x;
0039 Double_t TruthPV_y;
0040 Double_t TruthPV_z;
0041 Int_t NPrimaryG4P;
0042 vector<float> *PrimaryG4P_Pt;
0043 vector<float> *PrimaryG4P_Eta;
0044 vector<float> *PrimaryG4P_Phi;
0045 vector<float> *PrimaryG4P_E;
0046 vector<int> *PrimaryG4P_PID;
0047
0048
0049 TBranch *b_NClus;
0050 TBranch *b_system;
0051 TBranch *b_layer;
0052 TBranch *b_adc;
0053 TBranch *b_X;
0054 TBranch *b_Y;
0055 TBranch *b_Z;
0056 TBranch *b_size;
0057 TBranch *b_phi_size;
0058 TBranch *b_Z_size;
0059 TBranch *b_TruthPV_x;
0060 TBranch *b_TruthPV_y;
0061 TBranch *b_TruthPV_z;
0062 TBranch *b_NPrimaryG4P;
0063 TBranch *b_PrimaryG4P_Pt;
0064 TBranch *b_PrimaryG4P_Eta;
0065 TBranch *b_PrimaryG4P_Phi;
0066 TBranch *b_PrimaryG4P_E;
0067 TBranch *b_PrimaryG4P_PID;
0068
0069 MCSelfGenReader(TTree *tree=0);
0070 virtual ~MCSelfGenReader();
0071 virtual Int_t Cut(Long64_t entry);
0072 virtual Int_t GetEntry(Long64_t entry);
0073 virtual Long64_t LoadTree(Long64_t entry);
0074 virtual void Init(TTree *tree);
0075 virtual void Loop();
0076 virtual Bool_t Notify();
0077 virtual void Show(Long64_t entry = -1);
0078 };
0079
0080 #endif
0081
0082 #ifdef MCSelfGenReader_cxx
0083 MCSelfGenReader::MCSelfGenReader(TTree *tree) : fChain(0)
0084 {
0085
0086
0087 if (tree == 0) {
0088 TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("merged_file.root");
0089 if (!f || !f->IsOpen()) {
0090 f = new TFile("merged_file.root");
0091 }
0092 f->GetObject("tree",tree);
0093
0094 }
0095 Init(tree);
0096 }
0097
0098 MCSelfGenReader::~MCSelfGenReader()
0099 {
0100 if (!fChain) return;
0101 delete fChain->GetCurrentFile();
0102 }
0103
0104 Int_t MCSelfGenReader::GetEntry(Long64_t entry)
0105 {
0106
0107 if (!fChain) return 0;
0108 return fChain->GetEntry(entry);
0109 }
0110 Long64_t MCSelfGenReader::LoadTree(Long64_t entry)
0111 {
0112
0113 if (!fChain) return -5;
0114 Long64_t centry = fChain->LoadTree(entry);
0115 if (centry < 0) return centry;
0116 if (fChain->GetTreeNumber() != fCurrent) {
0117 fCurrent = fChain->GetTreeNumber();
0118 Notify();
0119 }
0120 return centry;
0121 }
0122
0123 void MCSelfGenReader::Init(TTree *tree)
0124 {
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 system = 0;
0135 layer = 0;
0136 adc = 0;
0137 X = 0;
0138 Y = 0;
0139 Z = 0;
0140 size = 0;
0141 phi_size = 0;
0142 Z_size = 0;
0143 PrimaryG4P_Pt = 0;
0144 PrimaryG4P_Eta = 0;
0145 PrimaryG4P_Phi = 0;
0146 PrimaryG4P_E = 0;
0147 PrimaryG4P_PID = 0;
0148
0149 if (!tree) return;
0150 fChain = tree;
0151 fCurrent = -1;
0152 fChain->SetMakeClass(1);
0153
0154 fChain->SetBranchAddress("NClus", &NClus, &b_NClus);
0155 fChain->SetBranchAddress("system", &system, &b_system);
0156 fChain->SetBranchAddress("layer", &layer, &b_layer);
0157 fChain->SetBranchAddress("adc", &adc, &b_adc);
0158 fChain->SetBranchAddress("X", &X, &b_X);
0159 fChain->SetBranchAddress("Y", &Y, &b_Y);
0160 fChain->SetBranchAddress("Z", &Z, &b_Z);
0161 fChain->SetBranchAddress("size", &size, &b_size);
0162 fChain->SetBranchAddress("phi_size", &phi_size, &b_phi_size);
0163 fChain->SetBranchAddress("Z_size", &Z_size, &b_Z_size);
0164 fChain->SetBranchAddress("TruthPV_x", &TruthPV_x, &b_TruthPV_x);
0165 fChain->SetBranchAddress("TruthPV_y", &TruthPV_y, &b_TruthPV_y);
0166 fChain->SetBranchAddress("TruthPV_z", &TruthPV_z, &b_TruthPV_z);
0167 fChain->SetBranchAddress("NPrimaryG4P", &NPrimaryG4P, &b_NPrimaryG4P);
0168 fChain->SetBranchAddress("PrimaryG4P_Pt", &PrimaryG4P_Pt, &b_PrimaryG4P_Pt);
0169 fChain->SetBranchAddress("PrimaryG4P_Eta", &PrimaryG4P_Eta, &b_PrimaryG4P_Eta);
0170 fChain->SetBranchAddress("PrimaryG4P_Phi", &PrimaryG4P_Phi, &b_PrimaryG4P_Phi);
0171 fChain->SetBranchAddress("PrimaryG4P_E", &PrimaryG4P_E, &b_PrimaryG4P_E);
0172 fChain->SetBranchAddress("PrimaryG4P_PID", &PrimaryG4P_PID, &b_PrimaryG4P_PID);
0173 Notify();
0174 }
0175
0176 Bool_t MCSelfGenReader::Notify()
0177 {
0178
0179
0180
0181
0182
0183
0184 return kTRUE;
0185 }
0186
0187 void MCSelfGenReader::Show(Long64_t entry)
0188 {
0189
0190
0191 if (!fChain) return;
0192 fChain->Show(entry);
0193 }
0194 Int_t MCSelfGenReader::Cut(Long64_t entry)
0195 {
0196
0197
0198
0199 return 1;
0200 }
0201 #endif