f15722c56ed2d859ead101b42ca399e872ac989a
[u/mrichter/AliRoot.git] / TPC / AliTPCScanPID.C
1 /// \file AliTPCScanPID.C
2 /// \brief Test macro for AliTPCtracksPid.root file
3 ///
4 /// \author JINR Dubna Aug 2002
5
6 void
7 AliTPCScanPID(Int_t evNumber2=3) {
8   //................. Prepare histogramms ................
9      TH2F *qplot =  new TH2F("Qtrm","Qtrm vs Pmom",100,0,1300,100,0,13);
10      TH2F *qplotP=  new TH2F("Qtrm1","Qtrm vs Pmom",100,0,1300,100,0,13); 
11      TH2F *qplotKa= new TH2F("Qtrm2","Qtrm vs Pmom",100,0,1300,100,0,13);
12      TH2F *qplotPi= new TH2F("Qtrm3","Qtrm vs Pmom",100,0,1300,100,0,13);
13      TH2F *qplotE=  new TH2F("Qtrm4","Qtrm vs Pmom",100,0,1300,100,0,13);
14      qplotP.SetMarkerStyle(8); qplotP.SetMarkerColor(kBlack); qplotP.SetMarkerSize(.3);
15      qplotKa.SetMarkerStyle(8); qplotKa.SetMarkerColor(kRed); qplotKa.SetMarkerSize(.3);
16      qplotPi.SetMarkerStyle(8); qplotPi.SetMarkerColor(kBlue); qplotPi.SetMarkerSize(.3);
17      qplotE.SetMarkerStyle(8); qplotE.SetMarkerColor(kGreen); qplotE.SetMarkerSize(.3);
18   //......................................................
19
20 TFile *fpid = new TFile("AliTPCtracksPid.root","read");
21 //
22 //   Loop over events 
23 //
24 for (int nev=0; nev< evNumber2; nev++) {
25   char tpidname[30];
26   sprintf(tpidname,"TreeT%d",nev);
27   TTree *tracktree=(TTree*)fpid->Get(tpidname);
28   TBranch *tbranch=tracktree->GetBranch("pids");
29         
30    Int_t nentr=tbranch->GetEntries(); 
31    cout<<"Found PID for "<<nentr<<"  TPC tracks on "<<tpidname<<endl;
32
33    AliTPCtrackPid *iopid=0;
34 for(Int_t ii=0;ii<nentr;ii++)
35   {
36       AliTPCtrackPid *iopid=new AliTPCtrackPid;
37       tbranch->SetAddress(&iopid);
38       tracktree->GetEvent(ii);
39
40       Float_t xsignal=iopid->fSignal/50.;
41
42         if(iopid->fPcode ==2212)qplotP.Fill(1000*iopid->fMom,xsignal);
43         if(iopid->fPcode == 321)qplotKa.Fill(1000*iopid->fMom,xsignal  );
44         if(iopid->fPcode == 211)qplotPi.Fill(1000*iopid->fMom,xsignal  );
45         if(iopid->fPcode ==  11)qplotE.Fill(1000*iopid->fMom,xsignal   );
46
47       //cout<<"PID pcode,fsignal,fmom= "
48       //  <<iopid->fPcode<<","<<iopid->fSignal<<","<<iopid->fMom<<endl;
49       delete iopid;
50   }// Enf for ii (tracks)
51  }// End for nev (events)
52  fpid->Close();
53   //...................... Draw histogramms .................
54    TCanvas *c1 = new TCanvas("PID_test","Scan PID ",200,10,900,700);
55    c1->Divide(1,1);
56   //.........................................................
57    c1->cd(1); gPad->SetFillColor(33);
58    qplot->Draw();
59    qplotP.Draw("same");qplotKa.Draw("same");qplotPi.Draw("same");qplotE.Draw("same");
60    AliTPCPid *pid =new AliTPCPid(100);
61     pid.fCutKa->SetLineColor(kRed);
62     pid.fCutKa->Draw("same");
63         
64   c1->Print("PIDplot.ps");
65   cout<<"End of file AliTPCtracksPid.root "<<endl; 
66
67   return;
68 }
69
70