Macros for handling the PID code
authorkowal2 <kowal2@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 3 Mar 2003 13:26:03 +0000 (13:26 +0000)
committerkowal2 <kowal2@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 3 Mar 2003 13:26:03 +0000 (13:26 +0000)
TPC/AliTPCSavePID.C [new file with mode: 0644]
TPC/AliTPCScanPID.C [new file with mode: 0644]

diff --git a/TPC/AliTPCSavePID.C b/TPC/AliTPCSavePID.C
new file mode 100644 (file)
index 0000000..334f8dd
--- /dev/null
@@ -0,0 +1,79 @@
+////////////////////////////////////////////////
+// Dubna, 22 Jan 2003                         //
+////////////////////////////////////////////////
+Int_t AliTPCSavePID(Int_t emax=3) {
+///////////////////////////////////////
+#include<fstream.h>
+TFile *inkin = TFile::Open("galice.root");
+if (!inkin->IsOpen()) {
+  cerr<<"Can't open galice.root !\n";
+}                                                                                        
+gAlice = (AliRun*)inkin->Get("gAlice");
+cout<<"AliRun object found on file "<<gAlice<<endl;
+cout<<"!!!! field ="<<gAlice->Field()->SolenoidField()<<endl;
+AliKalmanTrack::SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
+inkin->Close();                                  
+ cout<<" Convconst="<<AliKalmanTrack::GetConvConst()<<endl;
+/////////////////////////////////////// 
+AliTPCtrack *iotrack=0; 
+TFile *tf=TFile::Open("AliTPCtracks.root");
+   if (!tf->IsOpen()) {cerr<<"Can't open AliTPCtracks.root !\n"; return 3;}
+                                        
+AliTPCPid pid;
+AliTPCtrackPid pidtmp;                                                                
+AliTPCtrackPid *outpid=&pidtmp;
+TFile fpid("AliTPCtracksPid.root","recreate");
+
+ Int_t nentr=0,i=0;
+ for(int je=0;je<emax;je++){
+   char tname[100]; sprintf(tname,"TreeT_TPC_%d",je);
+   TTree *tracktree=(TTree*)tf->Get(tname);
+   if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n"; return 4;}
+
+   TBranch *tbranch=tracktree->GetBranch("tracks");
+   nentr=(Int_t)tracktree->GetEntries();
+   cout<<nentr<<" "<<" tracks in track tree "<<tname<<"."<<endl;
+
+    char tpname[100]; sprintf(tpname,"TreeT%d",je);
+    TTree *ptree = new  TTree(tpname,"Tree with PID"); 
+    ptree->Branch("pids","AliTPCtrackPid",&outpid,32000,1); 
+
+   for (i=0; i<nentr; i++) {
+       iotrack=new AliTPCtrack;
+       tbranch->SetAddress(&iotrack);
+       tracktree->GetEvent(i);
+      Double_t par[5],xx;xx=85.1951;
+      iotrack->PropagateTo(xx); 
+      iotrack->GetExternalParameters(xx,par);
+      //cout<<" par="<<par[0]<<" "<<par[1]<<" "<<par[2]<<" "<<par[3]<<" "<<par[4]<<endl;
+      Float_t phi=TMath::ASin(par[2]) + iotrack->GetAlpha();
+      if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
+      if (phi>=TMath::Pi()) phi-=2*TMath::Pi();
+      Float_t lam=TMath::ATan(par[3]); 
+      Float_t pt_1=TMath::Abs(par[4]);
+      //cout<<"pt_1,lam="<<pt_1<<" "<<lam<<endl;
+    if(pt_1!=0.){
+      Float_t mom=1./(pt_1*TMath::Cos(lam));
+      Float_t dedx=iotrack->GetdEdx();
+      Int_t pcode=pid.GetPcode(dedx/50.,mom);
+       pidtmp.fPcode=pcode;
+       pidtmp.fSignal=dedx;
+       pidtmp.fMom=mom;
+       pidtmp.fPhi=phi;
+       pidtmp.fLam=lam;
+       pidtmp.fWpi=pid.fWpi;
+       pidtmp.fWk=pid.fWk;
+       pidtmp.fWp=pid.fWp;
+       pidtmp.fLabel=TMath::Abs(iotrack->GetLabel());
+       cout<<"tlab,dedx,mom,pcode="<<pidtmp.fLabel<<" "<<dedx<<" "<<mom<<" "<<pcode<<endl;      
+       ptree->Fill();
+     }//if(pt...
+   }//for(i...
+  cout<<"Event "<<je+1<<" ok."<<endl;      
+   delete tracktree; 
+ }//End for(je...)   
+tf->Close();
+fpid.Write();
+cout<<"File AliTPCtracksPid.root written"<<endl;
+return 0;
+}
diff --git a/TPC/AliTPCScanPID.C b/TPC/AliTPCScanPID.C
new file mode 100644 (file)
index 0000000..3c2cd44
--- /dev/null
@@ -0,0 +1,69 @@
+///////////////////////////////////////////////////////////
+// Test macro for AliTPCtracksPid.root file            //
+// JINR Dubna Aug 2002                                   //
+///////////////////////////////////////////////////////////
+void
+AliTPCScanPID(Int_t evNumber2=3) {
+  //................. Prepare histogramms ................
+     TH2F *qplot =  new TH2F("Qtrm","Qtrm vs Pmom",100,0,1300,100,0,13);
+     TH2F *qplotP=  new TH2F("Qtrm1","Qtrm vs Pmom",100,0,1300,100,0,13); 
+     TH2F *qplotKa= new TH2F("Qtrm2","Qtrm vs Pmom",100,0,1300,100,0,13);
+     TH2F *qplotPi= new TH2F("Qtrm3","Qtrm vs Pmom",100,0,1300,100,0,13);
+     TH2F *qplotE=  new TH2F("Qtrm4","Qtrm vs Pmom",100,0,1300,100,0,13);
+     qplotP.SetMarkerStyle(8); qplotP.SetMarkerColor(kBlack); qplotP.SetMarkerSize(.3);
+     qplotKa.SetMarkerStyle(8); qplotKa.SetMarkerColor(kRed); qplotKa.SetMarkerSize(.3);
+     qplotPi.SetMarkerStyle(8); qplotPi.SetMarkerColor(kBlue); qplotPi.SetMarkerSize(.3);
+     qplotE.SetMarkerStyle(8); qplotE.SetMarkerColor(kGreen); qplotE.SetMarkerSize(.3);
+  //......................................................
+
+TFile *fpid = new TFile("AliTPCtracksPid.root","read");
+//
+//   Loop over events 
+//
+for (int nev=0; nev< evNumber2; nev++) {
+  char tpidname[30];
+  sprintf(tpidname,"TreeT%d",nev);
+  TTree *tracktree=(TTree*)fpid->Get(tpidname);
+  TBranch *tbranch=tracktree->GetBranch("pids");
+       
+   Int_t nentr=tbranch->GetEntries(); 
+   cout<<"Found PID for "<<nentr<<"  TPC tracks on "<<tpidname<<endl;
+
+   AliTPCtrackPid *iopid=0;
+for(Int_t ii=0;ii<nentr;ii++)
+  {
+      AliTPCtrackPid *iopid=new AliTPCtrackPid;
+      tbranch->SetAddress(&iopid);
+      tracktree->GetEvent(ii);
+
+      Float_t xsignal=iopid->fSignal/50.;
+
+        if(iopid->fPcode ==2212)qplotP.Fill(1000*iopid->fMom,xsignal);
+       if(iopid->fPcode == 321)qplotKa.Fill(1000*iopid->fMom,xsignal  );
+       if(iopid->fPcode == 211)qplotPi.Fill(1000*iopid->fMom,xsignal  );
+       if(iopid->fPcode ==  11)qplotE.Fill(1000*iopid->fMom,xsignal   );
+
+      //cout<<"PID pcode,fsignal,fmom= "
+      //  <<iopid->fPcode<<","<<iopid->fSignal<<","<<iopid->fMom<<endl;
+      delete iopid;
+  }// Enf for ii (tracks)
+ }// End for nev (events)
+ fpid->Close();
+  //...................... Draw histogramms .................
+   TCanvas *c1 = new TCanvas("PID_test","Scan PID ",200,10,900,700);
+   c1->Divide(1,1);
+  //.........................................................
+   c1->cd(1); gPad->SetFillColor(33);
+   qplot->Draw();
+   qplotP.Draw("same");qplotKa.Draw("same");qplotPi.Draw("same");qplotE.Draw("same");
+   AliTPCPid *pid =new AliTPCPid(100);
+    pid.fCutKa->SetLineColor(kRed);
+    pid.fCutKa->Draw("same");
+       
+  c1->Print("PIDplot.ps");
+  cout<<"End of file AliTPCtracksPid.root "<<endl; 
+
+  return;
+}
+
+