]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/PiKaPr/TestAOD/HighLevelQA/CalculateTPCTOFPIDCorrFact.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / TestAOD / HighLevelQA / CalculateTPCTOFPIDCorrFact.C
1 ///////////////////////////////////////////////////////////////////////
2 // CalculateTPCTOFPIDCorrFact.C  (called by JCGAnalysis.C)           //
3 //                                                                   //
4 // the return value is an array containing the correction factors    //
5 //                                                                   //
6 // written by John Groh                                              //
7 ///////////////////////////////////////////////////////////////////////
8
9
10 Float_t * CalculateTPCTOFPIDCorrFact(TH2F ** hTPCTOFnsig)
11 {
12   cout << "\n--- Just entered CalculateTPCTOFPIDCorrFact() ---\n";
13
14   // return value
15   Float_t * TPCTOFPIDCorrFact = new Float_t[nPart];
16
17   const Int_t fixedBin[nPart] = {25,25,36}; // pt bin to use for the projection
18   const Int_t fitMax[nPart] = {153,130,126}; // ranges for integration
19   
20   TH1F * hTPCTOFnsigProj[nPart]; // projection histograms
21
22   for (Int_t ipart=0; ipart<nPart; ipart++)
23     {
24       // project the nsigma distribution in the desired pt bin
25       hTPCTOFnsigProj[ipart] = (TH1F*)hTPCTOFnsig[ipart]->ProjectionY("",fixedBin[ipart],fixedBin[ipart])->Clone();
26
27       // integrate and calculate the correction factors
28       TPCTOFPIDCorrFact[ipart] = hTPCTOFnsigProj[ipart]->Integral(hTPCTOFnsigProj[ipart]->FindBin(0), hTPCTOFnsigProj[ipart]->FindBin(3));
29       TPCTOFPIDCorrFact[ipart] /= hTPCTOFnsigProj[ipart]->Integral(hTPCTOFnsigProj[ipart]->FindBin(0), fitMax[ipart]);
30     }
31
32   // draw everything to make sure it worked
33   TCanvas * cTPCTOFnsigInterp = new TCanvas("cTPCTOFnsigInterp","cTPCTOFnsigInterp");
34   cTPCTOFnsigInterp->Divide(3,1);
35   for (Int_t ipart=0; ipart<nPart; ipart++)
36     {
37       cTPCTOFnsigInterp->cd(ipart+1);
38       hTPCTOFnsigProj[ipart]->SetTitle(Form("TPC+TOF NSigma Projection - %ss - Bin %i;n#sigma (TPC+TOF);",Particle[ipart].Data(),fixedBin[ipart]));
39       hTPCTOFnsigProj[ipart]->SetLineColor(Color[ipart]);
40       hTPCTOFnsigProj[ipart]->DrawCopy("hist");      
41     }
42   
43   cout << "\n\n\n\n\n--- PID CORRECTION FACTORS:\n"
44        << "Pions: " << TPCTOFPIDCorrFact[0] << endl
45        << "Kaons: " << TPCTOFPIDCorrFact[1] << endl
46        << "Protons: " << TPCTOFPIDCorrFact[2] << endl << endl << endl;
47
48
49   cout << "\n--- Leaving CalculateTPCTOFPIDCorrFact() ---\n";
50
51   // return the correction factors
52   return TPCTOFPIDCorrFact;
53 }
54
55
56
57