Updated version of the PID code (from B. Batyunya)
[u/mrichter/AliRoot.git] / ITS / scan_pidV2.C
1 ///////////////////////////////////////////////////////////
2 // Test macro for AliITStracksV1Pid.root file            //
3 // JINR Dubna Jan 2002                                   //
4 ///////////////////////////////////////////////////////////
5 void
6 scan_pidV2(Int_t evNumber1=0,Int_t evNumber2=0) {
7   //................. Prepare histogramms ................
8      TH2F *qplot =  new TH2F("Qtrm","Qtrm vs Pmom",100,0,1300,100,0,13);
9      TH2F *qplotP=  new TH2F("Qtrm","Qtrm vs Pmom",100,0,1300,100,0,13); 
10      TH2F *qplotKa= new TH2F("Qtrm","Qtrm vs Pmom",100,0,1300,100,0,13);
11      TH2F *qplotPi= new TH2F("Qtrm","Qtrm vs Pmom",100,0,1300,100,0,13);
12      TH2F *qplotE=  new TH2F("Qtrm","Qtrm vs Pmom",100,0,1300,100,0,13);
13      qplotP.SetMarkerStyle(8); qplotP.SetMarkerColor(kBlack); qplotP.SetMarkerSize(.3);
14      qplotKa.SetMarkerStyle(8); qplotKa.SetMarkerColor(kRed); qplotKa.SetMarkerSize(.3);
15      qplotPi.SetMarkerStyle(8); qplotPi.SetMarkerColor(kBlue); qplotPi.SetMarkerSize(.3);
16      qplotE.SetMarkerStyle(8); qplotE.SetMarkerColor(kGreen); qplotE.SetMarkerSize(.3);
17   //......................................................
18   TH1F *signal_mip = new TH1F("signal_mip","Signal (mips) for track",100,0.,15.);
19
20 TFile *fpid = new TFile("AliITStracksV2Pid.root","read");
21 fpid->ls();
22 //
23 //   Loop over events 
24 //
25 for (int nev=0; nev<= evNumber2; nev++) {
26   char tpidname[30];
27   sprintf(tpidname,"TreeT%d",nev);
28   TTree *tracktree=(TTree*)fpid->Get(tpidname);
29   TBranch *tbranch=tracktree->GetBranch("pids");
30         
31    Int_t nentr=tracktree->GetEntries();
32    cout<<"Found PID for "<<nentr<<" ITS V1 tracks on "<<tpidname<<endl;
33
34    AliITStrackV2Pid *iopid=0;
35 for(Int_t ii=0;ii<nentr;ii++)
36   {
37       AliITStrackV2Pid *iopid=new AliITStrackV2Pid;
38       tbranch->SetAddress(&iopid);
39       tracktree->GetEvent(ii);
40
41       signal_mip->Fill(iopid->fSignal);
42
43         if(iopid->fPcode ==2212)qplotP.Fill(1000*iopid->fMom,iopid->fSignal);
44         if(iopid->fPcode == 321)qplotKa.Fill(1000*iopid->fMom,iopid->fSignal  );
45         if(iopid->fPcode == 211)qplotPi.Fill(1000*iopid->fMom,iopid->fSignal  );
46         if(iopid->fPcode ==  11)qplotE.Fill(1000*iopid->fMom,iopid->fSignal   );
47
48       cout<<"PID pcode,fsignal,fmom= "
49           <<iopid->fPcode<<","<<iopid->fSignal<<","<<iopid->fMom<<endl;
50       delete iopid;
51   }// Enf for ii (tracks)
52  }// End for nev (events)
53  fpid->Close();
54   //...................... Draw histogramms .................
55    TCanvas *c1 = new TCanvas("PID_test","Scan PID ",200,10,900,700);
56    c1->Divide(2,1);
57   //.........................................................
58    c1->cd(1); gPad->SetFillColor(33);
59    signal_mip->Draw();
60
61    c1->cd(2); //gPad->SetFillColor(33);
62    qplot->Draw();
63    qplotP.Draw("same"); qplotKa.Draw("same"); qplotPi.Draw("same"); qplotE.Draw("same");
64    AliITSPid *pid =new AliITSPid(100);
65     c1->Range(0,0,1300,10);
66     gStyle->SetLineColor(kRed);
67     gStyle->SetLineWidth(2);
68         TLine *lj[3],*lk[3]; 
69         for(Int_t j=0;j<3;j++){
70                 Float_t x1,x2,y1,y2,xx1,xx2,yy1,yy2;
71                 x1=pid->cut[j+1][0]; x2=pid->cut[j+2][0];
72                 y1=y2=pid->cut[j+2][2];
73             lj[j]=new TLine(1000*x1,y1,1000*x2,y2); lj[j]->Draw();
74             if(j==0){yy1=10.;}else{yy1=lj[j-1]->GetY1();}
75             yy2=lj[j]->GetY1();
76             xx1=xx2=x1;
77             lk[j]=new TLine(1000*xx1,yy1,1000*xx2,yy2); lk[j]->Draw();
78         }
79         //Draw pions-kaons cuts.
80         TLine *mj[7],*mk[7]; 
81         for(Int_t j=0;j<7;j++){
82                 Float_t x1,x2,y1,y2,xx1,xx2,yy1,yy2;
83                 x1=pid->cut[j+2][0]; x2=pid->cut[j+3][0];
84                 y1=y2=pid->cut[j+3][5];
85             mj[j]=new TLine(1000*x1,y1,1000*x2,y2); mj[j]->Draw();
86             if(j==0){yy1=10.;}else{yy1=mj[j-1]->GetY1();}
87             yy2=mj[j]->GetY1();
88             xx1=xx2=x1;
89             mk[j]=new TLine(1000*xx1,yy1,1000*xx2,yy2); mk[j]->Draw();
90         }
91   cout<<"End of file AliITStracksV1Pid.root "<<endl; 
92   return;
93 }
94