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