]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHSelector.C
Removing extra semicolon
[u/mrichter/AliRoot.git] / RICH / AliRICHSelector.C
CommitLineData
65018e5f 1#include <TF1.h>
2#include <TH2F.h>
3#include <TCanvas.h> //Terminate()
4#include <TChain.h>
5#include <TBenchmark.h>
6#include <fstream> //caf()
7#include <TProof.h> //caf()
8#include <AliSelector.h> //base class
9#include <AliESD.h>
10
11
12class AliRICHSelector : public AliSelector {
13 public :
14 AliRICHSelector():AliSelector(),fChain(0),fEsd(0),fCkovP(0),fMipXY(0),fDifXY(0),fSigP(0) {for(Int_t i=0;i<5;i++) fProb[i]=0;}
15 virtual ~AliRICHSelector() {delete fEsd;}
16
17
18 virtual Int_t Version () const {return 2;}
19 virtual void Begin (TTree *) {}
20 virtual void SlaveBegin (TTree *tree);
21 virtual void Init (TTree *tree);
22 virtual Bool_t Notify () {return kTRUE;}
23 virtual Bool_t Process (Long64_t entry);
24 virtual void SetOption (const char *option) { fOption = option; }
25 virtual void SetObject (TObject *obj) { fObject = obj; }
26 virtual void SetInputList (TList *input) {fInput = input;}
27 virtual TList *GetOutputList () const { return fOutput; }
28 virtual void SlaveTerminate ();
29 virtual void Terminate ();
30
31 private:
32 TTree *fChain ; //!pointer to the analyzed TTree or TChain
33 AliESD *fEsd ; //!
34
35 TH2F *fCkovP,*fMipXY,*fDifXY,*fSigP; //!
36 TH1F *fProb[5]; //!
37
38 ClassDef(AliRICHSelector,0);
39};
40
41
42//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43void AliRICHSelector::SlaveBegin(TTree *tree)
44{
45// The SlaveBegin() function is called after the Begin() function. When running with PROOF SlaveBegin() is called on each slave server.
46// The tree argument is deprecated (on PROOF 0 is passed).
47
48 Init(tree);
49
50 TString option = GetOption();
51
52 // create histograms on each slave server
53 fCkovP = new TH2F("CkovP" , "#theta_{c}, [rad];P, [GeV]", 150, 0, 7 ,100, -3, 1);
54 fSigP = new TH2F("SigP" ,"#sigma_{#theta_c}" , 150, 0, 7 ,100, 0, 1e20);
55 fMipXY = new TH2F("MipXY" ,"mip position" , 260, 0,130 ,252,0,126);
56 fDifXY = new TH2F("DifXY" ,"diff" , 260, -10, 10 ,252,-10,10);
57
58 fProb[0] = new TH1F("PidE" ,"PID: e yellow #mu magenta" ,100,0,1); fProb[0]->SetLineColor(kYellow);
59 fProb[1] = new TH1F("PidMu","pid of #mu" ,100,0,1); fProb[1]->SetLineColor(kMagenta);
60 fProb[2] = new TH1F("PidPi","PID: #pi red K green p blue",100,0,1); fProb[2]->SetLineColor(kRed);
61 fProb[3] = new TH1F("PidK" ,"pid of K" ,100,0,1); fProb[3]->SetLineColor(kGreen);
62 fProb[4] = new TH1F("PidP" ,"pid of p" ,100,0,1); fProb[4]->SetLineColor(kBlue);
63}
64//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
65void AliRICHSelector::Init(TTree *pTr)
66{
67 // The Init() function is called when the selector needs to initialize
68 // a new tree or chain. Typically here the branch addresses of the tree
69 // will be set. It is normaly not necessary to make changes to the
70 // generated code, but the routine can be extended by the user if needed.
71 // Init() will be called many times when running with PROOF.
72
73 // Set branch addresses
74 if ( !pTr ) return ;
75 fChain = pTr ;
76 fChain->SetBranchAddress("ESD", &fEsd) ;
77 fChain->SetBranchStatus("*", 0);
78 fChain->SetBranchStatus("fTracks.*", 1);
79}
80//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
81Bool_t AliRICHSelector::Process(Long64_t entry)
82{
83
84 fChain->GetTree()->GetEntry(entry);
85
86 for(Int_t iTrk=0;iTrk<fEsd->GetNumberOfTracks();iTrk++){
87 AliESDtrack *pTrk=fEsd->GetTrack(iTrk);
88
89// if(pTrk->GetRICHsignal()<0) continue;
90
91 fCkovP->Fill(pTrk->GetP(),pTrk->GetRICHsignal()) ;
92 fSigP ->Fill(pTrk->GetP(),TMath::Sqrt(pTrk->GetRICHchi2()));
93
94// Float_t xm,ym; Int_t q,np; pTrk->GetRICHmip(xm,ym,q,np); fMipXY->Fill(xm,ym); //mip info
95// Float_t xd,yd,th,ph; pTrk->GetRICHtrk(xd,yd,th,ph); fDifXY->Fill(xd,yd); //track info
96
97 Double_t pid[5]; pTrk->GetRICHpid(pid); for(Int_t i =0;i<5;i++) fProb[i]->Fill(pid[i]);
98 }//tracks loop
99
100 return kTRUE;
101}//Process()
102//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
103void AliRICHSelector::SlaveTerminate()
104{
105 // The SlaveTerminate() function is called after all entries or objects
106 // have been processed. When running with PROOF SlaveTerminate() is called
107 // on each slave server.
108
109 // Add the histograms to the output on each slave server
110
111 fOutput->Add(fCkovP);
112 fOutput->Add(fSigP);
113 fOutput->Add(fMipXY);
114 fOutput->Add(fDifXY);
115
116 for(Int_t i=0;i<5;i++) fOutput->Add(fProb[i]);
117}//SlaveTerminate()
118//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
119void AliRICHSelector::Terminate()
120{
121 // The Terminate() function is the last function to be called during
122 // a query. It always runs on the client, it can be used to present
123 // the results graphically or save the results to file.
124
125 fCkovP = dynamic_cast<TH2F*>(fOutput->FindObject("CkovP")) ;
126 fSigP = dynamic_cast<TH2F*>(fOutput->FindObject("SigP")) ;
127 fMipXY = dynamic_cast<TH2F*>(fOutput->FindObject("MipXY")) ;
128 fDifXY = dynamic_cast<TH2F*>(fOutput->FindObject("DifXY")) ;
129
130 fProb[0] = dynamic_cast<TH1F*>(fOutput->FindObject("PidE")) ;
131 fProb[1] = dynamic_cast<TH1F*>(fOutput->FindObject("PidMu")) ;
132 fProb[2] = dynamic_cast<TH1F*>(fOutput->FindObject("PidPi")) ;
133 fProb[3] = dynamic_cast<TH1F*>(fOutput->FindObject("PidK")) ;
134 fProb[4] = dynamic_cast<TH1F*>(fOutput->FindObject("PidP")) ;
135
136 Float_t n=1.292; //mean freon ref idx
137 TF1 *pPi=new TF1("RiPiTheo","acos(sqrt(x*x+[0]*[0])/(x*[1]))",1.2,7); pPi->SetLineWidth(1); pPi->SetParameter(1,n);
138 AliPID ppp; pPi->SetLineColor(kRed); pPi->SetParameter(0,AliPID::ParticleMass(AliPID::kPion)); //mass
139 TF1 *pK=(TF1*)pPi->Clone(); pK ->SetLineColor(kGreen); pK ->SetParameter(0,AliPID::ParticleMass(AliPID::kKaon));
140 TF1 *pP=(TF1*)pPi->Clone(); pP ->SetLineColor(kBlue); pP ->SetParameter(0,AliPID::ParticleMass(AliPID::kProton));
141
142 TCanvas *pC=new TCanvas("c1","ESD QA");pC->SetFillColor(10); pC->SetHighLightColor(10); pC->Divide(3,2);
143 pC->cd(1); fCkovP->Draw(); pPi->Draw("same"); pK->Draw("same"); pP->Draw("same"); pC->cd(2); fMipXY->Draw(); pC->cd(3); fProb[0]->Draw(); fProb[1]->Draw("same");
144 pC->cd(4); fSigP ->Draw(); pC->cd(5); fDifXY->Draw(); pC->cd(6); fProb[2]->Draw(); fProb[3]->Draw("same"); fProb[4]->Draw("same");
145
146}
147//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
148
149
150
151void loc()
152{
153 TChain* pChain =new TChain("esdTree");
154 pChain->Add("AliESDs.root");
155
156 pChain->Process("AliRICHSelector.C+");
157}
158//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
159void caf()
160{
161 gBenchmark->Start("PRooF exec");
162 TChain* pChain =new TChain("esdTree");
163
164 ifstream list; list.open("list.txt");
165
166 TString file;
167 while(list.good()) {
168 list>>file;
169 if (!file.Contains("root")) continue; //it's wrong file name
170 pChain->Add(file.Data());
171 }
172 list.close();
173
174 pChain->GetListOfFiles()->Print();
175
176 TVirtualProof *pProof=TProof::Open("kir@lxb6046.cern.ch");
177 pProof->UploadPackage("ESD.par");
178 pProof->EnablePackage("ESD");
179
180 pChain->SetProof(pProof);
181 pChain->Process("AliRICHSelector.C+");
182
183 gBenchmark->Show("PRooF exec");
184}
185//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
186