]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/oldmacros/AliITSScanPIDV1.C
Fix for wrong track lenght calculation (at the moment somewhat clumsy,
[u/mrichter/AliRoot.git] / ITS / oldmacros / AliITSScanPIDV1.C
1 ///////////////////////////////////////////////////////////
2 // Test macro for AliITStracksV1Pid.root file            //
3 // JINR Dubna Jan 2002                                   //
4 ///////////////////////////////////////////////////////////
5 void
6 AliITSScanPIDV1(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 //*****************************************************************************************************************************************
21
22   const char *filename="itstracks.root";
23   
24   ///////////////// Dynamically link some shared libs ////////////////////////////////
25   
26   if (gClassTable->GetID("AliRun") < 0) {
27     gROOT->LoadMacro("loadlibs.C");
28     loadlibs();
29   } else {
30     delete gAlice;
31     gAlice=0;
32   }
33
34 // Connect the Root Galice file containing Geometry, Kine and Hits
35    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
36    if (!file) file = new TFile(filename);
37
38 //
39 //   Loop over events 
40 //
41    char tname[30];
42    for (int nev=evNumber1; nev<= evNumber2; nev++) {
43  
44
45   // for (int nev=0; nev<= evNumber2; nev++) {
46
47    sprintf(tname,"TreeT%d",nev);
48    TTree *tracktree=(TTree*)file->Get(tname);
49    TBranch *tbranch=tracktree->GetBranch("ITStracks");
50    cout<<" nev = "<<nev<<"\n";
51         //cout<<" open the file \n"; 
52         
53    Int_t nentr=tracktree->GetEntries();
54
55    TObjArray tarray(nentr);
56   // AliITSIOTrack *iotrack=0;
57    printf("nentr %d\n",nentr);
58         
59    for (Int_t i=0; i<nentr; i++) {
60       AliITSIOTrack *iotrack=new AliITSIOTrack;
61       // tarray.AddAt(new AliITSIOTrack,i);
62       // iotrack=(AliITSiotrack*)tarray.UncheckedAt(i);
63        tbranch->SetAddress(&iotrack);
64        tracktree->GetEvent(i);
65        tarray.AddLast(iotrack);
66    }
67    //file->Close();              
68         
69           AliITSIOTrack *iotrack;
70    for (Int_t i=0; i<nentr; i++) {
71          AliITSIOTrack *iotrack=new AliITSIOTrack;      
72          iotrack=(AliITSIOTrack*)tarray.UncheckedAt(i);
73          if(!iotrack) continue;
74           
75          Float_t Px=iotrack->GetPx();
76          Float_t Py=iotrack->GetPy();
77          Float_t Pz=iotrack->GetPz();
78           
79          Float_t momentum = TMath::Sqrt(Px*Px+Py*Py+Pz*Pz);
80          Float_t dEdx = iotrack->GetdEdx();
81          Int_t pcode = 211;//iotrack->GetPDG();
82
83          signal_mip->Fill(dEdx);
84          
85          if(pcode == 2212) qplotP.Fill(1000*momentum,dEdx);
86          if(pcode ==  321) qplotKa.Fill(1000*momentum,dEdx);
87          if(pcode ==  211) qplotPi.Fill(1000*momentum,dEdx);
88          if(pcode ==   11) qplotE.Fill(1000*momentum,dEdx);
89          
90     delete iotrack;              
91    }  
92
93    }   // event loop 
94    file->Close();   
95
96 //*****************************************************************************************************************************************
97   
98   //...................... Draw histogramms .................
99    TCanvas *c1 = new TCanvas("PID_test","Scan PID ",200,10,900,700);
100    c1->Divide(2,1);
101   //.........................................................
102    c1->cd(1); gPad->SetFillColor(33);
103    signal_mip->Draw();
104
105    c1->cd(2); //gPad->SetFillColor(33);
106    qplot->Draw();
107    qplotP.Draw("same"); qplotKa.Draw("same"); qplotPi.Draw("same"); qplotE.Draw("same");
108    AliITSPid *pid =new AliITSPid(1000);
109     c1->Range(0,0,1300,10);
110     gStyle->SetLineColor(kRed);
111     gStyle->SetLineWidth(2);
112         TLine *lj[3],*lk[3]; 
113         for(Int_t j=0;j<3;j++){
114                 Float_t x1,x2,y1,y2,xx1,xx2,yy1,yy2;
115                 x1=pid->cut[j+1][0]; x2=pid->cut[j+2][0];
116                 y1=y2=pid->cut[j+2][2];
117             lj[j]=new TLine(1000*x1,y1,1000*x2,y2); lj[j]->Draw();
118             if(j==0){yy1=10.;}else{yy1=lj[j-1]->GetY1();}
119             yy2=lj[j]->GetY1();
120             xx1=xx2=x1;
121             lk[j]=new TLine(1000*xx1,yy1,1000*xx2,yy2); lk[j]->Draw();
122         }
123         //Draw pions-kaons cuts.
124         TLine *mj[7],*mk[7]; 
125         for(Int_t j=0;j<7;j++){
126                 Float_t x1,x2,y1,y2,xx1,xx2,yy1,yy2;
127                 x1=pid->cut[j+2][0]; x2=pid->cut[j+3][0];
128                 y1=y2=pid->cut[j+3][5];
129             mj[j]=new TLine(1000*x1,y1,1000*x2,y2); mj[j]->Draw();
130             if(j==0){yy1=10.;}else{yy1=mj[j-1]->GetY1();}
131             yy2=mj[j]->GetY1();
132             xx1=xx2=x1;
133             mk[j]=new TLine(1000*xx1,yy1,1000*xx2,yy2); mk[j]->Draw();
134         }
135   cout<<"End of file AliITStracksV1Pid.root "<<endl; 
136   return;
137 }
138