File indexing completed on 2025-12-17 09:13:54
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef GeoScan_h
0009 #define GeoScan_h
0010
0011 #include <TROOT.h>
0012 #include <TChain.h>
0013 #include <TFile.h>
0014
0015
0016 #include "vector"
0017
0018 class GeoScan {
0019 public :
0020 TChain *fChain;
0021 Int_t fCurrent;
0022
0023
0024 vector<double> *offset_x_vec;
0025 vector<double> *offset_y_vec;
0026 Double_t DCA_inner_fitYpos;
0027 Double_t DCA_inner_fitE;
0028 Double_t angle_diff_fitYpos;
0029 Double_t angle_diff_fitE;
0030 Int_t random_seed;
0031
0032
0033 TBranch *b_offset_x_vec;
0034 TBranch *b_offset_y_vec;
0035 TBranch *b_DCA_inner_fitYpos;
0036 TBranch *b_DCA_inner_fitE;
0037 TBranch *b_angle_diff_fitYpos;
0038 TBranch *b_angle_diff_fitE;
0039 TBranch *b_random_seed;
0040
0041 GeoScan(TChain *chain_in = 0, string folder_direction = "", string MC_list_name = "", int Nfile = -1);
0042 virtual ~GeoScan();
0043 virtual Int_t Cut(Long64_t entry);
0044 virtual Int_t GetEntry(Long64_t entry);
0045 virtual Long64_t LoadTree(Long64_t entry);
0046 virtual void Init(TChain *chain_in);
0047 virtual void Loop();
0048 virtual Bool_t Notify();
0049 virtual void Show(Long64_t entry = -1);
0050
0051 private:
0052 string folder_direction;
0053 string MC_list_name;
0054 vector<string> file_list;
0055 int Nfile;
0056 void read_list();
0057 };
0058
0059 #endif
0060
0061 #ifdef GeoScan_cxx
0062 GeoScan::GeoScan(TChain *chain_in, string folder_direction, string MC_list_name, int Nfile) :
0063 fChain(0),
0064 folder_direction(folder_direction),
0065 MC_list_name(MC_list_name),
0066 Nfile(Nfile)
0067 {
0068
0069
0070 if (chain_in == 0) {
0071
0072
0073
0074
0075
0076 std::cout<<"There is no TChain input ?, run exit"<<std::endl;
0077 std::exit(1);
0078 }
0079 if (folder_direction.size() == 0) {std::cout<<"There is no folder_direction input ?, run exit"<<std::endl; std::exit(1);}
0080 if (MC_list_name.size() == 0) {std::cout<<"There is no MC_list_name input ?, run exit"<<std::endl; std::exit(1);}
0081
0082 read_list();
0083
0084 std::cout<<"correct input format"<<std::endl;
0085 std::cout<<"Read the list by class"<<std::endl;
0086 std::cout<<"file_list size : "<<file_list.size()<<std::endl;
0087
0088 Init(chain_in);
0089 }
0090
0091 void GeoScan::read_list()
0092 {
0093 string list_buffer;
0094 ifstream data_list;
0095 data_list.open((folder_direction + "/" + MC_list_name).c_str());
0096
0097 file_list.clear();
0098
0099 if (Nfile == -1){
0100 while (1)
0101 {
0102 data_list >> list_buffer;
0103 if (!data_list.good())
0104 {
0105 break;
0106 }
0107 file_list.push_back(list_buffer);
0108 }
0109 }
0110 else
0111 {
0112 while (1)
0113 {
0114 data_list >> list_buffer;
0115 if (!data_list.good())
0116 {
0117 break;
0118 }
0119 file_list.push_back(list_buffer);
0120
0121
0122 if (file_list.size() == Nfile) {break;}
0123 }
0124 }
0125 cout<<"size : "<<file_list.size()<<endl;
0126 }
0127
0128 GeoScan::~GeoScan()
0129 {
0130 if (!fChain) return;
0131 delete fChain->GetCurrentFile();
0132 }
0133
0134 Int_t GeoScan::GetEntry(Long64_t entry)
0135 {
0136
0137 if (!fChain) return 0;
0138 return fChain->GetEntry(entry);
0139 }
0140 Long64_t GeoScan::LoadTree(Long64_t entry)
0141 {
0142
0143 if (!fChain) return -5;
0144 Long64_t centry = fChain->LoadTree(entry);
0145 if (centry < 0) return centry;
0146 if (fChain->GetTreeNumber() != fCurrent) {
0147 fCurrent = fChain->GetTreeNumber();
0148 Notify();
0149 }
0150 return centry;
0151 }
0152
0153 void GeoScan::Init(TChain *chain_in)
0154 {
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164 offset_x_vec = 0;
0165 offset_y_vec = 0;
0166
0167 if (!chain_in) return;
0168 fChain = chain_in;
0169 fCurrent = -1;
0170 fChain->SetMakeClass(1);
0171
0172
0173 for (auto each_file : file_list){ fChain -> Add((folder_direction + "/" + each_file).c_str()); }
0174
0175 fChain->SetBranchAddress("offset_x_vec", &offset_x_vec, &b_offset_x_vec);
0176 fChain->SetBranchAddress("offset_y_vec", &offset_y_vec, &b_offset_y_vec);
0177 fChain->SetBranchAddress("DCA_inner_fitYpos", &DCA_inner_fitYpos, &b_DCA_inner_fitYpos);
0178 fChain->SetBranchAddress("DCA_inner_fitE", &DCA_inner_fitE, &b_DCA_inner_fitE);
0179 fChain->SetBranchAddress("angle_diff_fitYpos", &angle_diff_fitYpos, &b_angle_diff_fitYpos);
0180 fChain->SetBranchAddress("angle_diff_fitE", &angle_diff_fitE, &b_angle_diff_fitE);
0181 fChain->SetBranchAddress("random_seed", &random_seed, &b_random_seed);
0182 Notify();
0183 }
0184
0185 Bool_t GeoScan::Notify()
0186 {
0187
0188
0189
0190
0191
0192
0193 return kTRUE;
0194 }
0195
0196 void GeoScan::Show(Long64_t entry)
0197 {
0198
0199
0200 if (!fChain) return;
0201 fChain->Show(entry);
0202 }
0203 Int_t GeoScan::Cut(Long64_t entry)
0204 {
0205
0206
0207
0208 return 1;
0209 }
0210 #endif