doxy: all TPC root converted
[u/mrichter/AliRoot.git] / TPC / AliTPCSavePID.C
CommitLineData
a7a1dd76 1/// \file AliTPCSavePID.C
3a4edebe 2///
3/// \author Dubna
4/// \date 2003, 22 Jan
a7a1dd76 5
31ab0ad9 6Int_t AliTPCSavePID(Int_t emax=3) {
3a4edebe 7///
8
31ab0ad9 9#include<fstream.h>
10TFile *inkin = TFile::Open("galice.root");
11if (!inkin->IsOpen()) {
12 cerr<<"Can't open galice.root !\n";
13}
14gAlice = (AliRun*)inkin->Get("gAlice");
15cout<<"AliRun object found on file "<<gAlice<<endl;
16cout<<"!!!! field ="<<gAlice->Field()->SolenoidField()<<endl;
c84a5e9e 17AliKalmanTrack::SetFieldMap(gAlice->Field());
31ab0ad9 18inkin->Close();
19 cout<<" Convconst="<<AliKalmanTrack::GetConvConst()<<endl;
20///////////////////////////////////////
21AliTPCtrack *iotrack=0;
22TFile *tf=TFile::Open("AliTPCtracks.root");
23 if (!tf->IsOpen()) {cerr<<"Can't open AliTPCtracks.root !\n"; return 3;}
24
25AliTPCPid pid;
26AliTPCtrackPid pidtmp;
27AliTPCtrackPid *outpid=&pidtmp;
28TFile fpid("AliTPCtracksPid.root","recreate");
29
30 Int_t nentr=0,i=0;
31 for(int je=0;je<emax;je++){
32 char tname[100]; sprintf(tname,"TreeT_TPC_%d",je);
33 TTree *tracktree=(TTree*)tf->Get(tname);
34 if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n"; return 4;}
35
36 TBranch *tbranch=tracktree->GetBranch("tracks");
37 nentr=(Int_t)tracktree->GetEntries();
38 cout<<nentr<<" "<<" tracks in track tree "<<tname<<"."<<endl;
39
40 char tpname[100]; sprintf(tpname,"TreeT%d",je);
41 TTree *ptree = new TTree(tpname,"Tree with PID");
42 ptree->Branch("pids","AliTPCtrackPid",&outpid,32000,1);
43
44 for (i=0; i<nentr; i++) {
45 iotrack=new AliTPCtrack;
46 tbranch->SetAddress(&iotrack);
47 tracktree->GetEvent(i);
48 Double_t par[5],xx;xx=85.1951;
49 iotrack->PropagateTo(xx);
50 iotrack->GetExternalParameters(xx,par);
51 //cout<<" par="<<par[0]<<" "<<par[1]<<" "<<par[2]<<" "<<par[3]<<" "<<par[4]<<endl;
52 Float_t phi=TMath::ASin(par[2]) + iotrack->GetAlpha();
53 if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
54 if (phi>=TMath::Pi()) phi-=2*TMath::Pi();
55 Float_t lam=TMath::ATan(par[3]);
56 Float_t pt_1=TMath::Abs(par[4]);
57 //cout<<"pt_1,lam="<<pt_1<<" "<<lam<<endl;
58 if(pt_1!=0.){
59 Float_t mom=1./(pt_1*TMath::Cos(lam));
60 Float_t dedx=iotrack->GetdEdx();
61 Int_t pcode=pid.GetPcode(dedx/50.,mom);
62 pidtmp.fPcode=pcode;
63 pidtmp.fSignal=dedx;
64 pidtmp.fMom=mom;
65 pidtmp.fPhi=phi;
66 pidtmp.fLam=lam;
67 pidtmp.fWpi=pid.fWpi;
68 pidtmp.fWk=pid.fWk;
69 pidtmp.fWp=pid.fWp;
70 pidtmp.fLabel=TMath::Abs(iotrack->GetLabel());
71 cout<<"tlab,dedx,mom,pcode="<<pidtmp.fLabel<<" "<<dedx<<" "<<mom<<" "<<pcode<<endl;
72 ptree->Fill();
73 }//if(pt...
74 }//for(i...
75 cout<<"Event "<<je+1<<" ok."<<endl;
76 delete tracktree;
77 }//End for(je...)
78tf->Close();
79fpid.Write();
80cout<<"File AliTPCtracksPid.root written"<<endl;
81return 0;
82}