File indexing completed on 2025-08-09 08:13:29
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef truthtree_h
0009 #define truthtree_h
0010
0011 #include <TROOT.h>
0012 #include <TChain.h>
0013 #include <TFile.h>
0014
0015
0016 #include "vector"
0017 #include "vector"
0018
0019 class truthtree
0020 {
0021 public:
0022 TTree *fChain;
0023 Int_t fCurrent;
0024
0025
0026
0027
0028 int evt_truth;
0029 vector<double> *truthpx;
0030 vector<double> *truthpy;
0031 vector<double> *truthpz;
0032 vector<double> *truthpt;
0033 vector<double> *trutheta;
0034 vector<double> *truththeta;
0035 vector<double> *truthphi;
0036 vector<int> *truthpid;
0037 vector<int> *status;
0038 vector<double> *truthxvtx;
0039 vector<double> *truthyvtx;
0040 vector<double> *truthzvtx;
0041 vector<double> *truthzout;
0042
0043
0044 TBranch *b_truthpx;
0045 TBranch *b_truthpy;
0046 TBranch *b_truthpz;
0047 TBranch *b_truthpt;
0048 TBranch *b_trutheta;
0049 TBranch *b_truththeta;
0050 TBranch *b_truthphi;
0051 TBranch *b_truthpid;
0052 TBranch *b_status;
0053 TBranch *b_evt_truth;
0054 TBranch *b_truthxvtx;
0055 TBranch *b_truthyvtx;
0056 TBranch *b_truthzvtx;
0057 TBranch *b_truthzout;
0058
0059 truthtree(TTree *tree = 0);
0060 virtual ~truthtree();
0061 virtual Int_t Cut(Long64_t entry);
0062 virtual Int_t GetEntry(Long64_t entry);
0063 virtual Long64_t LoadTree(Long64_t entry);
0064 virtual void Init(TTree *tree);
0065 virtual void Loop();
0066 virtual Bool_t Notify();
0067 virtual void Show(Long64_t entry = -1);
0068 };
0069
0070 #endif
0071
0072 #ifdef truthtree_cxx
0073 truthtree::truthtree(TTree *tree) : fChain(0)
0074 {
0075
0076
0077 if (tree == 0)
0078 {
0079 TFile *f = (TFile *)gROOT->GetListOfFiles()->FindObject("tracking_1K_reverse_3sigma_cut.root");
0080 if (!f || !f->IsOpen())
0081 {
0082 f = new TFile("tracking_1K_reverse_3sigma_cut.root");
0083 }
0084 f->GetObject("truth_tree", tree);
0085 }
0086 Init(tree);
0087 }
0088
0089 truthtree::~truthtree()
0090 {
0091 if (!fChain)
0092 return;
0093 delete fChain->GetCurrentFile();
0094 }
0095
0096 Int_t truthtree::GetEntry(Long64_t entry)
0097 {
0098
0099 if (!fChain)
0100 return 0;
0101 return fChain->GetEntry(entry);
0102 }
0103 Long64_t truthtree::LoadTree(Long64_t entry)
0104 {
0105
0106 if (!fChain)
0107 return -5;
0108 Long64_t centry = fChain->LoadTree(entry);
0109 if (centry < 0)
0110 return centry;
0111 if (fChain->GetTreeNumber() != fCurrent)
0112 {
0113 fCurrent = fChain->GetTreeNumber();
0114 Notify();
0115 }
0116 return centry;
0117 }
0118
0119 void truthtree::Init(TTree *tree)
0120 {
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130 truthpx = 0;
0131 truthpy = 0;
0132 truthpz = 0;
0133 truthpt = 0;
0134 trutheta = 0;
0135 truththeta = 0;
0136 truthphi = 0;
0137 truthpid = 0;
0138 status = 0;
0139 truthxvtx = 0;
0140 truthyvtx = 0;
0141 truthzvtx = 0;
0142 truthzout = 0;
0143
0144 if (!tree)
0145 return;
0146 fChain = tree;
0147 fCurrent = -1;
0148 fChain->SetMakeClass(1);
0149
0150 fChain->SetBranchAddress("truthpx", &truthpx, &b_truthpx);
0151 fChain->SetBranchAddress("truthpy", &truthpy, &b_truthpy);
0152 fChain->SetBranchAddress("truthpz", &truthpz, &b_truthpz);
0153 fChain->SetBranchAddress("truthpt", &truthpt, &b_truthpt);
0154 fChain->SetBranchAddress("trutheta", &trutheta, &b_trutheta);
0155 fChain->SetBranchAddress("truththeta", &truththeta, &b_truththeta);
0156 fChain->SetBranchAddress("truthphi", &truthphi, &b_truthphi);
0157 fChain->SetBranchAddress("truthpid", &truthpid, &b_truthpid);
0158 fChain->SetBranchAddress("status", &status, &b_status);
0159 fChain->SetBranchAddress("evt_truth", &evt_truth, &b_evt_truth);
0160 fChain->SetBranchAddress("truthxvtx", &truthxvtx, &b_truthxvtx);
0161 fChain->SetBranchAddress("truthyvtx", &truthyvtx, &b_truthyvtx);
0162 fChain->SetBranchAddress("truthzvtx", &truthzvtx, &b_truthzvtx);
0163 fChain->SetBranchAddress("truthzout", &truthzout, &b_truthzout);
0164 Notify();
0165 }
0166
0167 Bool_t truthtree::Notify()
0168 {
0169
0170
0171
0172
0173
0174
0175 return kTRUE;
0176 }
0177
0178 void truthtree::Show(Long64_t entry)
0179 {
0180
0181
0182 if (!fChain)
0183 return;
0184 fChain->Show(entry);
0185 }
0186 Int_t truthtree::Cut(Long64_t entry)
0187 {
0188
0189
0190
0191 return 1;
0192 }
0193 #endif