Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #define ReadEta_v2_cxx
0002 #include "ReadEta_v2.h"
0003 
0004 #include <iostream>
0005 using namespace std;
0006 
0007 ReadEta_v2::ReadEta_v2(TTree *tree) : fChain(0) 
0008 {
0009 // if parameter tree is not specified (or zero), connect the file
0010 // used to generate this class and read the Tree.
0011    if (tree == 0) {
0012       TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("../../../../sPH_dNdeta/HIJING_ana398_xvtx-0p04cm_yvtx0p24cm_zvtx-20cm_dummyAlignParams/DeltaR_TrackCounting_RecoZ_noMegaTrackRemoval_35k/INTT_final_hist_info.root");
0013       if (!f || !f->IsOpen()) {
0014          f = new TFile("../../../../sPH_dNdeta/HIJING_ana398_xvtx-0p04cm_yvtx0p24cm_zvtx-20cm_dummyAlignParams/DeltaR_TrackCounting_RecoZ_noMegaTrackRemoval_35k/INTT_final_hist_info.root");
0015       }
0016       f->GetObject("tree_eta",tree);
0017 
0018    }
0019 
0020    std::cout<<"running test!, can you see me now v2?"<<std::endl;
0021 
0022    Init(tree);
0023 }
0024 
0025 ReadEta_v2::~ReadEta_v2()
0026 {
0027    if (!fChain) return;
0028    delete fChain->GetCurrentFile();
0029 }
0030 
0031 Int_t ReadEta_v2::GetEntry(Long64_t entry)
0032 {
0033 // Read contents of entry.
0034    if (!fChain) return 0;
0035    return fChain->GetEntry(entry);
0036 }
0037 Long64_t ReadEta_v2::LoadTree(Long64_t entry)
0038 {
0039 // Set the environment to read one entry
0040    if (!fChain) return -5;
0041    Long64_t centry = fChain->LoadTree(entry);
0042    if (centry < 0) return centry;
0043    if (fChain->GetTreeNumber() != fCurrent) {
0044       fCurrent = fChain->GetTreeNumber();
0045       Notify();
0046    }
0047    return centry;
0048 }
0049 
0050 void ReadEta_v2::Init(TTree *tree)
0051 {
0052    // The Init() function is called when the selector needs to initialize
0053    // a new tree or chain. Typically here the branch addresses and branch
0054    // pointers of the tree will be set.
0055    // It is normally not necessary to make changes to the generated
0056    // code, but the routine can be extended by the user if needed.
0057    // Init() will be called many times when running on PROOF
0058    // (once per file to be processed).
0059 
0060    // Set object pointer
0061    RecoTrack_eta_d = 0;
0062    RecoTrack_phi_d = 0;
0063    TrueTrack_eta_d = 0;
0064    TrueTrack_phi_d = 0;
0065    // Set branch addresses and branch pointers
0066    if (!tree) return;
0067    fChain = tree;
0068    fCurrent = -1;
0069    fChain->SetMakeClass(1);
0070 
0071    fChain->SetBranchAddress("eID", &eID, &b_eID);
0072    fChain->SetBranchAddress("Evt_centrality_bin", &Evt_centrality_bin, &b_Evt_centrality_bin);
0073    fChain->SetBranchAddress("Evt_zvtx", &Evt_zvtx, &b_Evt_zvtx);
0074    fChain->SetBranchAddress("NTrueTrack", &NTrueTrack, &b_NTrueTrack);
0075    fChain->SetBranchAddress("NClus", &NClus, &b_NClus);
0076    fChain->SetBranchAddress("RecoTrack_eta_d", &RecoTrack_eta_d, &b_RecoTrack_eta_d);
0077    fChain->SetBranchAddress("RecoTrack_phi_d", &RecoTrack_phi_d, &b_RecoTrack_phi_d);
0078    fChain->SetBranchAddress("TrueTrack_eta_d", &TrueTrack_eta_d, &b_TrueTrack_eta_d);
0079    fChain->SetBranchAddress("TrueTrack_phi_d", &TrueTrack_phi_d, &b_TrueTrack_phi_d);
0080    fChain->SetBranchAddress("N2Clu_track", &N2Clu_track, &b_N2Clu_track);
0081    fChain->SetBranchAddress("N3Clu_track", &N3Clu_track, &b_N3Clu_track);
0082    fChain->SetBranchAddress("N4Clu_track", &N4Clu_track, &b_N4Clu_track);
0083    Notify();
0084 }
0085 
0086 Bool_t ReadEta_v2::Notify()
0087 {
0088    // The Notify() function is called when a new file is opened. This
0089    // can be either for a new TTree in a TChain or when when a new TTree
0090    // is started when using PROOF. It is normally not necessary to make changes
0091    // to the generated code, but the routine can be extended by the
0092    // user if needed. The return value is currently not used.
0093 
0094    return kTRUE;
0095 }
0096 
0097 void ReadEta_v2::Show(Long64_t entry)
0098 {
0099 // Print contents of entry.
0100 // If entry is not specified, print current entry
0101    if (!fChain) return;
0102    fChain->Show(entry);
0103 }
0104 Int_t ReadEta_v2::Cut(Long64_t entry)
0105 {
0106 // This function may be called from Loop.
0107 // returns  1 if entry is accepted.
0108 // returns -1 otherwise.
0109    return 1;
0110 }
0111 
0112 void ReadEta_v2::Loop()
0113 {
0114 //   In a ROOT session, you can do:
0115 //      root> .L ReadEta_v2.C
0116 //      root> ReadEta_v2 t
0117 //      root> t.GetEntry(12); // Fill t data members with entry number 12
0118 //      root> t.Show();       // Show values of entry 12
0119 //      root> t.Show(16);     // Read and show values of entry 16
0120 //      root> t.Loop();       // Loop on all entries
0121 //
0122 
0123 //     This is the loop skeleton where:
0124 //    jentry is the global entry number in the chain
0125 //    ientry is the entry number in the current Tree
0126 //  Note that the argument to GetEntry must be:
0127 //    jentry for TChain::GetEntry
0128 //    ientry for TTree::GetEntry and TBranch::GetEntry
0129 //
0130 //       To read only selected branches, Insert statements like:
0131 // METHOD1:
0132 //    fChain->SetBranchStatus("*",0);  // disable all branches
0133 //    fChain->SetBranchStatus("branchname",1);  // activate branchname
0134 // METHOD2: replace line
0135 //    fChain->GetEntry(jentry);       //read all branches
0136 //by  b_branchname->GetEntry(ientry); //read only this branch
0137    if (fChain == 0) return;
0138 
0139    Long64_t nentries = fChain->GetEntriesFast();
0140 
0141    Long64_t nbytes = 0, nb = 0;
0142    for (Long64_t jentry=0; jentry<nentries;jentry++) {
0143       Long64_t ientry = LoadTree(jentry);
0144       if (ientry < 0) break;
0145       nb = fChain->GetEntry(jentry);   nbytes += nb;
0146       // if (Cut(ientry) < 0) continue;
0147    }
0148 }