/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Simulation/BOOST/TofSim/TofSim-00-02-33/dat/readTree.cxx

Go to the documentation of this file.
00001 void readTree(){
00002   int rBin,phiBin,zBin;
00003   const int nR = 43;
00004   const int nPhi = 6;
00005   const int nZ = 6;
00006   float eff,x[400],y[400]; 
00007 
00008   TFile *f = new TFile("effTree.root", "read");
00009   TTree *t = (TTree*)f->Get("effTree");
00010 
00011   t->SetBranchAddress("rBin", &rBin);
00012   t->SetBranchAddress("phiBin", &phiBin);
00013   t->SetBranchAddress("zBin", &zBin);
00014   t->SetBranchAddress("eff", &eff);
00015   t->SetBranchAddress("x", x);
00016   t->SetBranchAddress("y", y);
00017   
00018   int r,phi,z;
00019   float efficiency[43][6][6];
00020   float propTime[43][6][6][400];
00021   float prob[43][6][6][400];
00022 
00023   for (Int_t i = 0; i < nR*nPhi*nZ; i++){
00024     t->GetEntry(i);
00025     r = rBin;
00026     phi = phiBin;
00027     z = zBin;
00028     efficiency[r][phi][z] = eff;
00029     for (Int_t j = 0; j < 400; j++){
00030       propTime[r][phi][z][j] = x[j];
00031       prob[r][phi][z][j] = y[j];
00032       //cout << "\n" << propTime[r][phi][z][j] << "   " << prob[r][phi][z][j] << endl;
00033     }
00034   }
00035   //TH1F *h1 = new TH1F("h1","propTime",400,0,20);
00036   int r0 = 41;
00037   int phi0 = 2;
00038   int z0 = 0;
00039   Float_t x0[400], y0[400];
00040 
00041   char file[200];
00042   int rPos = 400+r0*10;
00043   float x1[400],y1[400];
00044   float t1;
00045   sprintf(file,"/ihepbatch/besd12/liuy/EndcapTof/OpInETof2/results/%d/timeSta_%d_%d_%d.root",rPos,rPos,phi0,z0);
00046   cout << file << endl;
00047   TH1F* h1 = new TH1F("h1","time distr.(ns)",400,0,20);
00048   TFile* f1 = TFile::Open(file);
00049   TNtuple* n1 = (TNtuple*)f1 -> Get("timeTuple");
00050   n1->SetBranchAddress("inTimePre",&t1);
00051   int nEntries = (Int_t)n1->GetEntries();
00052   cout << "nEntries:" << nEntries << "\n" << endl;
00053 
00054   for(int m=0;m<nEntries;m++)
00055   {
00056     n1->GetEntry(m);
00057     h1->Fill(t1);
00058   }
00059   double norm = h1->Integral();
00060   eff = norm/2000000.; // 200 events per run ; 10k photons per event
00061   if(norm!=0)
00062     h1->Scale(1./norm);
00063   else
00064   {
00065     cout << "The eff is null!" << endl;
00066     continue;
00067   }
00068   TAxis* xaxis = h1->GetXaxis();
00069   for(int m=0;m<400;m++)
00070   {
00071     x1[m] = xaxis->GetBinCenter(m);
00072     y1[m] = h1->GetBinContent(m);
00073   }
00074   f1->Close();
00075   
00076   for(Int_t i=0;i<400;i++)
00077   {
00078     x0[i] = propTime[r0][phi0][z0][i] - x1[i];
00079     y0[i] = prob[r0][phi0][z0][i] - y1[i];
00080   }
00081 
00082   TGraph *g = new TGraph( 400, x0, y0);
00083   g->Draw("APL");
00084 
00085   f->Close();
00086 }

Generated on Tue Nov 29 23:14:31 2016 for BOSS_7.0.2 by  doxygen 1.4.7