Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #define RhoFluct_cxx
0002 #include "RhoFluct.h"
0003 #include <TH2.h>
0004 #include <TStyle.h>
0005 #include <TCanvas.h>
0006 
0007 void RhoFluct::Loop(string out_name)
0008 {
0009 //   In a ROOT session, you can do:
0010 //      root> .L RhoFluct.C
0011 //      root> RhoFluct t
0012 //      root> t.GetEntry(12); // Fill t data members with entry number 12
0013 //      root> t.Show();       // Show values of entry 12
0014 //      root> t.Show(16);     // Read and show values of entry 16
0015 //      root> t.Loop();       // Loop on all entries
0016 //
0017 
0018 //     This is the loop skeleton where:
0019 //    jentry is the global entry number in the chain
0020 //    ientry is the entry number in the current Tree
0021 //  Note that the argument to GetEntry must be:
0022 //    jentry for TChain::GetEntry
0023 //    ientry for TTree::GetEntry and TBranch::GetEntry
0024 //
0025 //       To read only selected branches, Insert statements like:
0026 // METHOD1:
0027 //    fChain->SetBranchStatus("*",0);  // disable all branches
0028 //    fChain->SetBranchStatus("branchname",1);  // activate branchname
0029 // METHOD2: replace line
0030 //    fChain->GetEntry(jentry);       //read all branches
0031 //by  b_branchname->GetEntry(ientry); //read only this branch
0032    if (fChain == 0) return;
0033 
0034    TFile* fout = new TFile(voi_stem(out_name,".root").c_str(),"recreate");
0035 
0036    array<TH1D*,10> harr_sub1, harr_rhoA;
0037    for (int i=0; i<10; ++i) {
0038      int i0 = i*10;
0039      int i1 = i*10+10;
0040      harr_sub1[i] = new TH1D(Form("fluct_sub1_%i",i),
0041          Form("impact param [%4.2f-%4.2f];p_{T,jet}^{SUB1+probe}-p_{T}^{probe};N_{events}", IP_DEC[i], IP_DEC[i+1]), 400, -50, 50);
0042      harr_rhoA[i] = new TH1D(Form("fluct_rhoA_%i",i),
0043          Form("impact param [%4.2f-%4.2f];(p_{T,jet}^{calo+probe}-#rho#timesA)-p_{T}^{probe};N_{events}", IP_DEC[i], IP_DEC[i+1]), 400, -50, 50);
0044    }
0045 
0046    Long64_t nentries = fChain->GetEntriesFast();
0047 
0048    Long64_t nbytes = 0, nb = 0;
0049    for (Long64_t jentry=0; jentry<nentries;jentry++) {
0050       Long64_t ientry = LoadTree(jentry);
0051       if (ientry < 0) break;
0052       nb = fChain->GetEntry(jentry);   nbytes += nb;
0053       // if (Cut(ientry) < 0) continue;
0054 
0055       int k = get_ip_decile(impactparam);
0056       if (k<0 || k>9) {
0057         cout << "bad impact parameter; should NEVER happen" << endl;
0058       }
0059 
0060       ///////////////////////////////////////
0061       // Do the sub1 fluctuations
0062       if (sub1_ismatched) {
0063         harr_sub1[k]->Fill(sub1Jet_delPt);
0064       }
0065       if (rhoA_ismatched) {
0066         harr_rhoA[k]->Fill(rhoAJet_delPt);
0067       }
0068 
0069       /* if (true) if (jentry > 1000) break; */
0070    }
0071 
0072    for (int k=0;k<10;++k) {
0073      harr_sub1[k]->Write();
0074      harr_rhoA[k]->Write();
0075    }
0076    fout->Close();
0077 }