]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/EsdQa.C
MAJOR UPGRADE: 1. all objects are counted from 0 2. new AliRICHRecon 3. calib off...
[u/mrichter/AliRoot.git] / RICH / EsdQa.C
1 // The following methods are defined in this file:
2 //    Begin():        called everytime a loop on the tree starts, a convenient place to create your histograms.
3 //    SlaveBegin():   called after Begin(), when on PROOF called only on the slave servers.
4 //    Process():      called for each event, in this function you decide what to read and fill your histograms.
5 //    SlaveTerminate: called at the end of the loop on the tree, when on PROOF called only on the slave servers.
6 //    Terminate():    called at the end of the loop on the tree, a convenient place to draw/fit your histograms.
7
8 #include "EsdQa.h"    //class header
9 #include <TCanvas.h>  //Terminate()
10 #include <TChain.h>
11 #include <TF1.h>
12 #include <TBenchmark.h>
13 #include <TH2F.h>
14 #include <fstream>    //caf()      
15 #include <TProof.h>   //caf()
16 #include <TDSet.h>    //caf()
17 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
18 void EsdQa::Begin(TTree *)
19 {
20    // The Begin() function is called at the start of the query.
21    // When running with PROOF Begin() is only called on the client.
22    // The tree argument is deprecated (on PROOF 0 is passed).
23
24    TString option = GetOption();
25
26 }
27 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
28 void EsdQa::SlaveBegin(TTree *tree)
29 {
30    // The SlaveBegin() function is called after the Begin() function.
31    // When running with PROOF SlaveBegin() is called on each slave server.
32    // The tree argument is deprecated (on PROOF 0 is passed).
33
34    Init(tree);
35
36    TString option = GetOption();
37
38    // create histograms on each slave server
39    fCkovP    = new TH2F("CkovP" , "#theta_{c}, [rad];P, [GeV]", 150,   0,  7  ,100, 0, 1); 
40    fSigP     = new TH2F("SigP"  ,"#sigma_{#theta_c}"          , 150,   0,  7  ,100, 0, 1e20);
41    fMipXY    = new TH2F("MipXY" ,"mip position"               , 260,   0,130  ,252,0,126); 
42    fDifXY    = new TH2F("DifXY" ,"diff"                       , 260, -10, 10  ,252,-10,10); 
43
44    fProb[0] = new TH1F("PidE" ,"PID: e yellow #mu magenta"  ,100,0,1); fProb[0]->SetLineColor(kYellow);
45    fProb[1] = new TH1F("PidMu","pid of #mu"                 ,100,0,1); fProb[1]->SetLineColor(kMagenta);
46    fProb[2] = new TH1F("PidPi","PID: #pi red K green p blue",100,0,1); fProb[2]->SetLineColor(kRed);
47    fProb[3] = new TH1F("PidK" ,"pid of K"                   ,100,0,1); fProb[3]->SetLineColor(kGreen);
48    fProb[4] = new TH1F("PidP" ,"pid of p"                   ,100,0,1); fProb[4]->SetLineColor(kBlue);
49 }
50 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
51 void EsdQa::Init(TTree *tree)
52 {
53    // The Init() function is called when the selector needs to initialize
54    // a new tree or chain. Typically here the branch addresses of the tree
55    // will be set. It is normaly not necessary to make changes to the
56    // generated code, but the routine can be extended by the user if needed.
57    // Init() will be called many times when running with PROOF.
58
59    // Set branch addresses
60    if ( !tree ) 
61      return ;
62    fChain = tree ;
63    fChain->SetBranchAddress("ESD", &fEsd) ;
64 }
65 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
66 Bool_t EsdQa::Notify()
67 {
68    // The Notify() function is called when a new file is opened. This
69    // can be either for a new TTree in a TChain or when when a new TTree
70    // is started when using PROOF. Typically here the branch pointers
71    // will be retrieved. It is normaly not necessary to make changes
72    // to the generated code, but the routine can be extended by the
73    // user if needed.
74
75    // Get branch pointers
76
77    return kTRUE;
78 }
79 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
80 Bool_t EsdQa::Process(Long64_t entry)
81 {
82    // The Process() function is called for each entry in the tree (or possibly
83    // keyed object in the case of PROOF) to be processed. The entry argument
84    // specifies which entry in the currently loaded tree is to be processed.
85    // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
86    // to read either all or the required parts of the data. When processing
87    // keyed objects with PROOF, the object is already loaded and is available
88    // via the fObject pointer.
89    //
90    // This function should contain the "body" of the analysis. It can contain
91    // simple or elaborate selection criteria, run algorithms on the data
92    // of the event and typically fill histograms.
93
94    // WARNING when a selector is used with a TChain, you must use
95    //  the pointer to the current TTree to call GetEntry(entry).
96    //  The entry is always the local entry number in the current tree.
97    //  Assuming that fChain is the pointer to the TChain being processed,
98    //  use fChain->GetTree()->GetEntry(entry).
99
100   fChain->GetTree()->GetEntry(entry);
101
102   for(Int_t iTrk=0;iTrk<fEsd->GetNumberOfTracks();iTrk++){
103      AliESDtrack *pTrk=fEsd->GetTrack(iTrk);
104      
105      if(pTrk->GetRICHsignal()<0) continue;
106      
107      fCkovP->Fill(pTrk->GetP(),pTrk->GetRICHsignal()) ; 
108      fSigP ->Fill(pTrk->GetP(),TMath::Sqrt(pTrk->GetRICHchi2()));
109      
110      Float_t xm,ym;  pTrk->GetRICHmipXY(xm,ym);  fMipXY->Fill(xm,ym);
111      Float_t xd,yd;  pTrk->GetRICHdxdy(xd,yd);   fDifXY->Fill(xd,yd);
112      
113      Double_t pid[5];  pTrk->GetRICHpid(pid); for(Int_t i =0;i<5;i++) fProb[i]->Fill(pid[i]);
114   }//tracks loop 
115      
116   return kTRUE;
117 }//Process()
118 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
119 void EsdQa::SlaveTerminate()
120 {
121   // The SlaveTerminate() function is called after all entries or objects
122   // have been processed. When running with PROOF SlaveTerminate() is called
123   // on each slave server.
124   
125   // Add the histograms to the output on each slave server
126   
127   fOutput->Add(fCkovP);
128   fOutput->Add(fSigP); 
129   fOutput->Add(fMipXY);
130   fOutput->Add(fDifXY);
131   
132   for(Int_t i=0;i<5;i++) fOutput->Add(fProb[i]);
133 }//SlaveTerminate()
134 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
135 void EsdQa::Terminate()
136 {
137    // The Terminate() function is the last function to be called during
138    // a query. It always runs on the client, it can be used to present
139    // the results graphically or save the results to file.
140   
141   fCkovP   = dynamic_cast<TH2F*>(fOutput->FindObject("CkovP")) ;
142   fSigP    = dynamic_cast<TH2F*>(fOutput->FindObject("SigP")) ; 
143   fMipXY   = dynamic_cast<TH2F*>(fOutput->FindObject("MipXY")) ;
144   fDifXY   = dynamic_cast<TH2F*>(fOutput->FindObject("DifXY")) ;
145   
146   fProb[0] = dynamic_cast<TH1F*>(fOutput->FindObject("PidE")) ;
147   fProb[1] = dynamic_cast<TH1F*>(fOutput->FindObject("PidMu")) ;
148   fProb[2] = dynamic_cast<TH1F*>(fOutput->FindObject("PidPi")) ;
149   fProb[3] = dynamic_cast<TH1F*>(fOutput->FindObject("PidK")) ;
150   fProb[4] = dynamic_cast<TH1F*>(fOutput->FindObject("PidP")) ;
151
152   Float_t n=1.292; //mean freon ref idx 
153   TF1 *pPi=new TF1("RiPiTheo","acos(sqrt(x*x+[0]*[0])/(x*[1]))",1.2,7); pPi->SetLineWidth(1); pPi->SetParameter(1,n); 
154   AliPID ppp;                 pPi->SetLineColor(kRed);   pPi->SetParameter(0,AliPID::ParticleMass(AliPID::kPion));    //mass
155   TF1 *pK=(TF1*)pPi->Clone(); pK ->SetLineColor(kGreen); pK ->SetParameter(0,AliPID::ParticleMass(AliPID::kKaon)); 
156   TF1 *pP=(TF1*)pPi->Clone(); pP ->SetLineColor(kBlue);  pP ->SetParameter(0,AliPID::ParticleMass(AliPID::kProton)); 
157
158   TCanvas *pC=new TCanvas("c1","ESD QA");pC->SetFillColor(10); pC->SetHighLightColor(10); pC->Divide(3,2);
159   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"); 
160   pC->cd(4); fSigP ->Draw();                                                          pC->cd(5); fDifXY->Draw();   pC->cd(6); fProb[2]->Draw(); fProb[3]->Draw("same"); fProb[4]->Draw("same"); 
161   
162 }
163 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
164
165 void loc()
166 {
167   TChain* pChain =new TChain("esdTree");
168   pChain->Add("AliESDs.root");
169
170   pChain->Process("EsdQa.C+");  
171 }
172
173 void caf()
174 {
175   gBenchmark->Start("PRooF exec");
176   TChain* pChain =new TChain("esdTree");
177   
178   ifstream list; list.open("list.txt");
179
180   TString file;
181   while(list.good()) {
182     list>>file;
183     if (!file.Contains("root")) continue; //it's wrong file name
184     pChain->Add(file.Data());
185   }
186   list.close();
187   
188   pChain->GetListOfFiles()->Print();
189   
190   TVirtualProof *pProof=TProof::Open("kir@lxb6046.cern.ch");    
191   pProof->UploadPackage("ESD.par");
192   pProof->EnablePackage("ESD");
193   
194   pChain->MakeTDSet()->Process("EsdQa.C+");
195   
196   gBenchmark->Show("PRooF exec");
197 }
198