Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:13:54

0001 //////////////////////////////////////////////////////////
0002 // This class has been automatically generated on
0003 // Tue Dec 26 05:12:53 2023 by ROOT version 6.26/06
0004 // from TTree tree_geo_scan/tree_geo_scan
0005 // found on file: geo_scan_1719900.root
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 // Header file for the classes stored in the TTree if any.
0016 #include "vector"
0017 
0018 class GeoScan {
0019 public :
0020    TChain          *fChain;   //!pointer to the analyzed TTree or TChain
0021    Int_t           fCurrent; //!current Tree number in a TChain
0022 
0023    // Declaration of leaf types
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    // List of branches
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    // if parameter tree is not specified (or zero), connect the file
0069    // used to generate this class and read the Tree.
0070    if (chain_in == 0) {
0071       // TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("INTTRecoClusters_test_400_0.root");
0072       // if (!f || !f->IsOpen()) {
0073       //    f = new TFile("INTTRecoClusters_test_400_0.root");
0074       // }
0075       // f->GetObject("EventTree",chain_in);
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(); // note : read the 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          // note : Just in case you don't want to read all the files, it takes time
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 // Read contents of entry.
0137    if (!fChain) return 0;
0138    return fChain->GetEntry(entry);
0139 }
0140 Long64_t GeoScan::LoadTree(Long64_t entry)
0141 {
0142 // Set the environment to read one entry
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    // The Init() function is called when the selector needs to initialize
0156    // a new tree or chain. Typically here the branch addresses and branch
0157    // pointers of the tree will be set.
0158    // It is normally not necessary to make changes to the generated
0159    // code, but the routine can be extended by the user if needed.
0160    // Init() will be called many times when running on PROOF
0161    // (once per file to be processed).
0162 
0163    // Set object pointer
0164    offset_x_vec = 0;
0165    offset_y_vec = 0;
0166    // Set branch addresses and branch pointers
0167    if (!chain_in) return;
0168    fChain = chain_in;
0169    fCurrent = -1;
0170    fChain->SetMakeClass(1);
0171 
0172    // note : fill the root files
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    // The Notify() function is called when a new file is opened. This
0188    // can be either for a new TTree in a TChain or when when a new TTree
0189    // is started when using PROOF. It is normally not necessary to make changes
0190    // to the generated code, but the routine can be extended by the
0191    // user if needed. The return value is currently not used.
0192 
0193    return kTRUE;
0194 }
0195 
0196 void GeoScan::Show(Long64_t entry)
0197 {
0198 // Print contents of entry.
0199 // If entry is not specified, print current entry
0200    if (!fChain) return;
0201    fChain->Show(entry);
0202 }
0203 Int_t GeoScan::Cut(Long64_t entry)
0204 {
0205 // This function may be called from Loop.
0206 // returns  1 if entry is accepted.
0207 // returns -1 otherwise.
0208    return 1;
0209 }
0210 #endif // #ifdef GeoScan_cxx