Back to home page

sPhenix code displayed by LXR

 
 

    


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

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