Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:12:15

0001 //////////////////////////////////////////////////////////
0002 // This class has been automatically generated on
0003 // Thu Jan 18 21:15:42 2024 by ROOT version 6.26/06
0004 // from TTree tree_geo_scan/tree_geo_scan
0005 // found on file: geo_scan_212_13_3186500.root
0006 //////////////////////////////////////////////////////////
0007 
0008 #ifndef GeoScanV2_h
0009 #define GeoScanV2_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 GeoScanV2 {
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_inner_fitYpos;
0029    Double_t        angle_diff_inner_fitE;
0030    Double_t        DCA_outer_fitYpos;
0031    Double_t        DCA_outer_fitE;
0032    Double_t        angle_diff_outer_fitYpos;
0033    Double_t        angle_diff_outer_fitE;
0034    Int_t           random_seed;
0035    Double_t        vtxX;
0036    Double_t        vtxY;
0037    Double_t        trial_originX;
0038    Double_t        trial_originY;
0039 
0040    // List of branches
0041    TBranch        *b_offset_x_vec;   //!
0042    TBranch        *b_offset_y_vec;   //!
0043    TBranch        *b_DCA_inner_fitYpos;   //!
0044    TBranch        *b_DCA_inner_fitE;   //!
0045    TBranch        *b_angle_diff_inner_fitYpos;   //!
0046    TBranch        *b_angle_diff_inner_fitE;   //!
0047    TBranch        *b_DCA_outer_fitYpos;   //!
0048    TBranch        *b_DCA_outer_fitE;   //!
0049    TBranch        *b_angle_diff_outer_fitYpos;   //!
0050    TBranch        *b_angle_diff_outer_fitE;   //!
0051    TBranch        *b_random_seed;   //!
0052    TBranch        *b_vtxX;   //!
0053    TBranch        *b_vtxY;   //!
0054    TBranch        *b_trial_originX;   //!
0055    TBranch        *b_trial_originY;   //!
0056 
0057    vector<string> file_list;
0058 
0059    GeoScanV2(TChain *chain_in = 0, string folder_direction = "", string MC_list_name = "", int Nfile = -1);
0060    virtual ~GeoScanV2();
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(TChain *chain_in);
0065    virtual void     Loop();
0066    virtual Bool_t   Notify();
0067    virtual void     Show(Long64_t entry = -1);
0068 
0069 private:
0070    string folder_direction;
0071    string MC_list_name;
0072    int Nfile;
0073    void read_list();
0074 };
0075 
0076 #endif
0077 
0078 #ifdef GeoScanV2_cxx
0079 GeoScanV2::GeoScanV2(TChain *chain_in, string folder_direction, string MC_list_name, int Nfile) : 
0080 fChain(0),
0081 folder_direction(folder_direction), 
0082 MC_list_name(MC_list_name),
0083 Nfile(Nfile) 
0084 {
0085    file_list.clear();
0086    
0087    // if parameter tree is not specified (o}r zero), connect the file
0088    // used to generate this class and read the Tree.
0089    if (chain_in == 0) {
0090       // TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("INTTRecoClusters_test_400_0.root");
0091       // if (!f || !f->IsOpen()) {
0092       //    f = new TFile("INTTRecoClusters_test_400_0.root");
0093       // }
0094       // f->GetObject("EventTree",chain_in);
0095       std::cout<<"There is no TChain input ?, run exit"<<std::endl;
0096       std::exit(1);
0097    }
0098    if (folder_direction.size() == 0) {std::cout<<"There is no folder_direction input ?, run exit"<<std::endl; std::exit(1);}
0099    if (MC_list_name.size() == 0) {std::cout<<"There is no MC_list_name input ?, run exit"<<std::endl; std::exit(1);}
0100 
0101    read_list(); // note : read the list
0102 
0103    std::cout<<"correct input format"<<std::endl;
0104    std::cout<<"Read the list by class"<<std::endl;
0105    std::cout<<"file_list size : "<<file_list.size()<<std::endl;
0106 
0107    Init(chain_in);
0108 }
0109 
0110 void GeoScanV2::read_list()
0111 {
0112    string list_buffer;
0113    ifstream data_list;
0114     data_list.open((folder_direction + "/" + MC_list_name).c_str());
0115 
0116    file_list.clear();
0117 
0118    if (Nfile == -1){
0119       while (1)
0120       {
0121          data_list >> list_buffer;
0122          if (!data_list.good())
0123          {
0124             break;
0125          }
0126          file_list.push_back(list_buffer);
0127       }
0128    }
0129    else 
0130    {
0131       while (1)
0132       {
0133          data_list >> list_buffer;
0134          if (!data_list.good())
0135          {
0136             break;
0137          }
0138          file_list.push_back(list_buffer);
0139 
0140          // note : Just in case you don't want to read all the files, it takes time
0141          if (file_list.size() == Nfile) {break;}
0142       }
0143    }    
0144     cout<<"size : "<<file_list.size()<<endl;
0145 }
0146 
0147 GeoScanV2::~GeoScanV2()
0148 {
0149    if (!fChain) return;
0150    delete fChain->GetCurrentFile();
0151 }
0152 
0153 Int_t GeoScanV2::GetEntry(Long64_t entry)
0154 {
0155 // Read contents of entry.
0156    if (!fChain) return 0;
0157    return fChain->GetEntry(entry);
0158 }
0159 Long64_t GeoScanV2::LoadTree(Long64_t entry)
0160 {
0161 // Set the environment to read one entry
0162    if (!fChain) return -5;
0163    Long64_t centry = fChain->LoadTree(entry);
0164    if (centry < 0) return centry;
0165    if (fChain->GetTreeNumber() != fCurrent) {
0166       fCurrent = fChain->GetTreeNumber();
0167       Notify();
0168    }
0169    return centry;
0170 }
0171 
0172 void GeoScanV2::Init(TChain *chain_in)
0173 {
0174    // The Init() function is called when the selector needs to initialize
0175    // a new tree or chain. Typically here the branch addresses and branch
0176    // pointers of the tree will be set.
0177    // It is normally not necessary to make changes to the generated
0178    // code, but the routine can be extended by the user if needed.
0179    // Init() will be called many times when running on PROOF
0180    // (once per file to be processed).
0181 
0182    // Set object pointer
0183    offset_x_vec = 0;
0184    offset_y_vec = 0;
0185    // Set branch addresses and branch pointers
0186    if (!chain_in) return;
0187    fChain = chain_in;
0188    fCurrent = -1;
0189    fChain->SetMakeClass(1);
0190 
0191    // note : fill the root files
0192    for (auto each_file : file_list){ fChain -> Add((folder_direction + "/" + each_file).c_str()); }
0193 
0194    fChain->SetBranchAddress("offset_x_vec", &offset_x_vec, &b_offset_x_vec);
0195    fChain->SetBranchAddress("offset_y_vec", &offset_y_vec, &b_offset_y_vec);
0196    fChain->SetBranchAddress("DCA_inner_fitYpos", &DCA_inner_fitYpos, &b_DCA_inner_fitYpos);
0197    fChain->SetBranchAddress("DCA_inner_fitE", &DCA_inner_fitE, &b_DCA_inner_fitE);
0198    fChain->SetBranchAddress("angle_diff_inner_fitYpos", &angle_diff_inner_fitYpos, &b_angle_diff_inner_fitYpos);
0199    fChain->SetBranchAddress("angle_diff_inner_fitE", &angle_diff_inner_fitE, &b_angle_diff_inner_fitE);
0200    fChain->SetBranchAddress("DCA_outer_fitYpos", &DCA_outer_fitYpos, &b_DCA_outer_fitYpos);
0201    fChain->SetBranchAddress("DCA_outer_fitE", &DCA_outer_fitE, &b_DCA_outer_fitE);
0202    fChain->SetBranchAddress("angle_diff_outer_fitYpos", &angle_diff_outer_fitYpos, &b_angle_diff_outer_fitYpos);
0203    fChain->SetBranchAddress("angle_diff_outer_fitE", &angle_diff_outer_fitE, &b_angle_diff_outer_fitE);
0204    fChain->SetBranchAddress("random_seed", &random_seed, &b_random_seed);
0205    fChain->SetBranchAddress("vtxX", &vtxX, &b_vtxX);
0206    fChain->SetBranchAddress("vtxY", &vtxY, &b_vtxY);
0207    fChain->SetBranchAddress("trial_originX", &trial_originX, &b_trial_originX);
0208    fChain->SetBranchAddress("trial_originY", &trial_originY, &b_trial_originY);
0209    Notify();
0210 }
0211 
0212 Bool_t GeoScanV2::Notify()
0213 {
0214    // The Notify() function is called when a new file is opened. This
0215    // can be either for a new TTree in a TChain or when when a new TTree
0216    // is started when using PROOF. It is normally not necessary to make changes
0217    // to the generated code, but the routine can be extended by the
0218    // user if needed. The return value is currently not used.
0219 
0220    return kTRUE;
0221 }
0222 
0223 void GeoScanV2::Show(Long64_t entry)
0224 {
0225 // Print contents of entry.
0226 // If entry is not specified, print current entry
0227    if (!fChain) return;
0228    fChain->Show(entry);
0229 }
0230 Int_t GeoScanV2::Cut(Long64_t entry)
0231 {
0232 // This function may be called from Loop.
0233 // returns  1 if entry is accepted.
0234 // returns -1 otherwise.
0235    return 1;
0236 }
0237 #endif // #ifdef GeoScanV2_cxx