File indexing completed on 2023-03-17 10:39:41
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef theTree_h
0009 #define theTree_h
0010
0011 #include <TROOT.h>
0012 #include <TChain.h>
0013 #include <TFile.h>
0014
0015 class theTree {
0016 public :
0017 TTree *fChain;
0018 Int_t fCurrent;
0019
0020
0021 Float_t x;
0022 Float_t y;
0023 Float_t z;
0024 Float_t phi;
0025 Float_t theta;
0026 Float_t length;
0027 Float_t width;
0028 Float_t thick;
0029
0030
0031 TBranch *b_x;
0032 TBranch *b_y;
0033 TBranch *b_z;
0034 TBranch *b_phi;
0035 TBranch *b_theta;
0036 TBranch *b_length;
0037 TBranch *b_width;
0038 TBranch *b_thick;
0039
0040 theTree(TTree *tree=0);
0041 virtual ~theTree();
0042 virtual Int_t Cut(Long64_t entry);
0043 virtual Int_t GetEntry(Long64_t entry);
0044 virtual Long64_t LoadTree(Long64_t entry);
0045 virtual void Init(TTree *tree);
0046 virtual void Loop();
0047 virtual Bool_t Notify();
0048 virtual void Show(Long64_t entry = -1);
0049 };
0050
0051 #endif
0052
0053 #ifdef theTree_cxx
0054 theTree::theTree(TTree *tree)
0055 {
0056
0057
0058 if (tree == 0) {
0059 TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("aligned.root");
0060 if (!f) {
0061 f = new TFile("aligned.root");
0062 }
0063 tree = (TTree*)gDirectory->Get("theTree");
0064
0065 }
0066 Init(tree);
0067 }
0068
0069 theTree::~theTree()
0070 {
0071 if (!fChain) return;
0072 delete fChain->GetCurrentFile();
0073 }
0074
0075 Int_t theTree::GetEntry(Long64_t entry)
0076 {
0077
0078 if (!fChain) return 0;
0079 return fChain->GetEntry(entry);
0080 }
0081 Long64_t theTree::LoadTree(Long64_t entry)
0082 {
0083
0084 if (!fChain) return -5;
0085 Long64_t centry = fChain->LoadTree(entry);
0086 if (centry < 0) return centry;
0087 if (fChain->IsA() != TChain::Class()) return centry;
0088 TChain *chain = (TChain*)fChain;
0089 if (chain->GetTreeNumber() != fCurrent) {
0090 fCurrent = chain->GetTreeNumber();
0091 Notify();
0092 }
0093 return centry;
0094 }
0095
0096 void theTree::Init(TTree *tree)
0097 {
0098
0099
0100
0101
0102
0103
0104
0105 if (tree == 0) return;
0106 fChain = tree;
0107 fCurrent = -1;
0108 fChain->SetMakeClass(1);
0109
0110 fChain->SetBranchAddress("x",&x);
0111 fChain->SetBranchAddress("y",&y);
0112 fChain->SetBranchAddress("z",&z);
0113 fChain->SetBranchAddress("phi",&phi);
0114 fChain->SetBranchAddress("theta",&theta);
0115 fChain->SetBranchAddress("length",&length);
0116 fChain->SetBranchAddress("width",&width);
0117 fChain->SetBranchAddress("thick",&thick);
0118 Notify();
0119 }
0120
0121 Bool_t theTree::Notify()
0122 {
0123
0124
0125
0126
0127
0128
0129
0130
0131 b_x = fChain->GetBranch("x");
0132 b_y = fChain->GetBranch("y");
0133 b_z = fChain->GetBranch("z");
0134 b_phi = fChain->GetBranch("phi");
0135 b_theta = fChain->GetBranch("theta");
0136 b_length = fChain->GetBranch("length");
0137 b_width = fChain->GetBranch("width");
0138 b_thick = fChain->GetBranch("thick");
0139
0140 return kTRUE;
0141 }
0142
0143 void theTree::Show(Long64_t entry)
0144 {
0145
0146
0147 if (!fChain) return;
0148 fChain->Show(entry);
0149 }
0150 Int_t theTree::Cut(Long64_t entry)
0151 {
0152
0153
0154
0155 return 1;
0156 }
0157 #endif