1 ///////////////////////////////////////////////////////////////////////
2 // CalculateTPCTOFPIDCorrFact.C (called by JCGAnalysis.C) //
4 // the return value is an array containing the correction factors //
6 // written by John Groh //
7 ///////////////////////////////////////////////////////////////////////
10 Float_t * CalculateTPCTOFPIDCorrFact(TH2F ** hTPCTOFnsig)
12 cout << "\n--- Just entered CalculateTPCTOFPIDCorrFact() ---\n";
15 Float_t * TPCTOFPIDCorrFact = new Float_t[nPart];
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
20 TH1F * hTPCTOFnsigProj[nPart]; // projection histograms
22 for (Int_t ipart=0; ipart<nPart; ipart++)
24 // project the nsigma distribution in the desired pt bin
25 hTPCTOFnsigProj[ipart] = (TH1F*)hTPCTOFnsig[ipart]->ProjectionY("",fixedBin[ipart],fixedBin[ipart])->Clone();
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]);
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++)
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");
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;
49 cout << "\n--- Leaving CalculateTPCTOFPIDCorrFact() ---\n";
51 // return the correction factors
52 return TPCTOFPIDCorrFact;