]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ESDCheck/AliHMPIDQATask.cxx
Update pair cut usage
[u/mrichter/AliRoot.git] / ESDCheck / AliHMPIDQATask.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //_________________________________________________________________________
19 // An analysis task to check the HMPID data in simulated data
20 //
21 //*-- Annalisa Mastroserio
22 //////////////////////////////////////////////////////////////////////////////
23
24 #include <TCanvas.h>
25 #include <TChain.h>
26 #include <TF1.h>
27 #include <TFile.h> 
28 #include <TH1F.h>
29 #include <TH2F.h>
30 #include <TLegend.h> 
31 #include <TROOT.h>
32 #include <TVector3.h> 
33 #include <TString.h> 
34
35 #include "AliHMPIDQATask.h" 
36 #include "AliESD.h" 
37 #include "AliLog.h"
38 #include "AliPID.h"
39
40 //______________________________________________________________________________
41 AliHMPIDQATask::AliHMPIDQATask(const char *name) : 
42   AliAnalysisTask(name,""),  
43   fChain(0),
44   fESD(0), 
45   fOutputContainer(0),
46   fhHMPIDCkovP(0),
47   fhHMPIDMipXY(0),
48   fhHMPIDDifXY(0),
49   fhHMPIDSigP(0)
50 {
51   // Constructor.
52   // Input slot #0 works with an Ntuple
53   DefineInput(0, TChain::Class());
54   // Output slot #0 writes into a TH1 container
55   DefineOutput(0,  TObjArray::Class()) ; 
56
57   Int_t i ; 
58   for(i = 0 ; i < 5 ; i++) 
59     fhHMPIDProb[i]=0;
60 }
61
62 //______________________________________________________________________________
63 AliHMPIDQATask::~AliHMPIDQATask()
64 {
65   // dtor
66   fOutputContainer->Clear() ; 
67   delete fOutputContainer ; 
68   
69   delete fhHMPIDCkovP ;  
70   delete fhHMPIDMipXY ;  
71   delete fhHMPIDDifXY ;  
72   delete fhHMPIDSigP ;
73   for (Int_t i=0; i<5; i++)
74     delete fhHMPIDProb[i] ;
75 }
76
77 //______________________________________________________________________________
78 void AliHMPIDQATask::ConnectInputData(const Option_t*)
79 {
80   // Initialisation of branch container and histograms 
81     
82   AliInfo(Form("*** Initialization of %s", GetName())) ; 
83   
84   // Get input data
85   fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
86   if (!fChain) {
87     AliError(Form("Input 0 for %s not found\n", GetName()));
88     return ;
89   }
90   
91   // One should first check if the branch address was taken by some other task
92   char ** address = (char **)GetBranchAddress(0, "ESD");
93   if (address) {
94     fESD = (AliESD*)(*address);
95   } else {
96     fESD = new AliESD();
97     SetBranchAddress(0, "ESD", &fESD);
98   }
99 }
100
101 //________________________________________________________________________
102 void AliHMPIDQATask::CreateOutputObjects()
103 {  
104   // create histograms 
105
106   OpenFile(0) ; 
107
108   fhHMPIDCkovP    = new TH2F("CkovP" , "#theta_{c}, [rad];P, [GeV]", 150,   0,  7  ,100, -3, 1); 
109   fhHMPIDSigP     = new TH2F("SigP"  ,"#sigma_{#theta_c}"          , 150,   0,  7  ,100, 0, 1e20);
110   fhHMPIDMipXY    = new TH2F("MipXY" ,"mip position"               , 260,   0,130  ,252,0,126); 
111   fhHMPIDDifXY    = new TH2F("DifXY" ,"diff"                       , 260, -10, 10  ,252,-10,10); 
112   
113   fhHMPIDProb[0] = new TH1F("PidE" ,"PID: e yellow #mu magenta"  ,100,0,1); 
114   fhHMPIDProb[0]->SetLineColor(kYellow);
115   fhHMPIDProb[1] = new TH1F("PidMu","pid of #mu"                 ,100,0,1); 
116   fhHMPIDProb[1]->SetLineColor(kMagenta);
117   fhHMPIDProb[2] = new TH1F("PidPi","PID: #pi red K green p blue",100,0,1); 
118   fhHMPIDProb[2]->SetLineColor(kRed);
119   fhHMPIDProb[3] = new TH1F("PidK" ,"pid of K"                   ,100,0,1); 
120   fhHMPIDProb[3]->SetLineColor(kGreen);
121   fhHMPIDProb[4] = new TH1F("PidP" ,"pid of p"                   ,100,0,1); 
122   fhHMPIDProb[4]->SetLineColor(kBlue);
123  
124
125   
126   // create output container
127   
128   fOutputContainer = new TObjArray(9) ; 
129   fOutputContainer->SetName(GetName()) ; 
130
131   fOutputContainer->AddAt(fhHMPIDCkovP,      0) ; 
132   fOutputContainer->AddAt(fhHMPIDSigP,       1) ; 
133   fOutputContainer->AddAt(fhHMPIDMipXY,      2) ; 
134   fOutputContainer->AddAt(fhHMPIDDifXY,      3) ; 
135   fOutputContainer->AddAt(fhHMPIDProb[0],    4) ; 
136   fOutputContainer->AddAt(fhHMPIDProb[1],    5) ; 
137   fOutputContainer->AddAt(fhHMPIDProb[2],    6) ; 
138   fOutputContainer->AddAt(fhHMPIDProb[3],    7) ; 
139   fOutputContainer->AddAt(fhHMPIDProb[4],    8) ; 
140 }
141
142 //______________________________________________________________________________
143 void AliHMPIDQATask::Exec(Option_t *) 
144 {
145   // Processing of one event
146     
147   Long64_t entry = fChain->GetReadEntry() ;
148   
149   if (!fESD) {
150     AliError("fESD is not connected to the input!") ; 
151     return ; 
152   }
153   
154   if ( !((entry-1)%100) ) 
155     AliInfo(Form("%s ----> Processing event # %lld",  (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ; 
156   
157   // ************************  HMPID *************************************
158   Int_t iTrk ; 
159   for(iTrk = 0 ; iTrk < fESD->GetNumberOfTracks() ; iTrk++){
160     AliESDtrack *pTrk = fESD->GetTrack(iTrk) ;
161
162     fhHMPIDCkovP->Fill( pTrk->GetP(), pTrk->GetHMPIDsignal() ) ; 
163     fhHMPIDSigP ->Fill( pTrk->GetP(), TMath::Sqrt(pTrk->GetHMPIDchi2()) ) ;
164      
165 //     Float_t xm,ym; Int_t q,np;  pTrk->GetHMPIDmip(xm,ym,q,np);  fMipXY->Fill(xm,ym); //mip info
166 //     Float_t xd,yd,th,ph;        pTrk->GetHMPIDtrk(xd,yd,th,ph); fDifXY->Fill(xd,yd); //track info 
167      
168     Double_t pid[5] ;  
169     pTrk->GetHMPIDpid(pid) ; 
170     Int_t i ; 
171     for(i = 0 ; i < 5 ; i++) 
172       fhHMPIDProb[i]->Fill(pid[i]) ;
173   }//tracks loop 
174        
175   PostData(0, fOutputContainer);
176 }
177
178 //______________________________________________________________________________
179 void AliHMPIDQATask::Terminate(Option_t *)
180 {
181   // Processing when the event loop is ended
182   fOutputContainer = (TObjArray*)GetOutputData(0);
183   fhHMPIDCkovP   = (TH2F*)fOutputContainer->At(0);
184   fhHMPIDSigP    = (TH2F*)fOutputContainer->At(1);
185   fhHMPIDMipXY   = (TH2F*)fOutputContainer->At(2);
186   fhHMPIDDifXY   = (TH2F*)fOutputContainer->At(3);
187   fhHMPIDProb[0] = (TH1F*)fOutputContainer->At(4);
188   fhHMPIDProb[1] = (TH1F*)fOutputContainer->At(5);
189   fhHMPIDProb[2] = (TH1F*)fOutputContainer->At(6);
190   fhHMPIDProb[3] = (TH1F*)fOutputContainer->At(7);
191   fhHMPIDProb[4] = (TH1F*)fOutputContainer->At(8);
192
193   Bool_t problem = kFALSE ; 
194   AliInfo(Form(" *** %s Report:", GetName())) ; 
195
196   Float_t n = 1.292 ; //mean freon ref idx 
197   TF1 * hHMPIDpPi = new TF1("RiPiTheo", "acos(sqrt(x*x+[0]*[0])/(x*[1]))", 1.2, 7) ; 
198   hHMPIDpPi->SetLineWidth(1) ; 
199   hHMPIDpPi->SetParameter(1,n) ; 
200
201   AliPID ppp ;                 
202   hHMPIDpPi->SetLineColor(kRed);   
203   hHMPIDpPi->SetParameter(0,AliPID::ParticleMass(AliPID::kPion));    //mass
204
205   TF1 * hHMPIDK = static_cast<TF1*>(hHMPIDpPi->Clone()) ; 
206   hHMPIDK ->SetLineColor(kGreen) ; 
207   hHMPIDK ->SetParameter(0, AliPID::ParticleMass(AliPID::kKaon)) ; 
208
209   TF1 * hHMPIDP=static_cast<TF1*>(hHMPIDpPi->Clone()) ; 
210   hHMPIDP ->SetLineColor(kBlue) ;  
211   hHMPIDP ->SetParameter(0,AliPID::ParticleMass(AliPID::kProton)) ; 
212
213   TCanvas * cHMPID = new TCanvas("cHMPID","HMPID ESD Test") ;
214   cHMPID->SetFillColor(10) ; 
215   cHMPID->SetHighLightColor(10) ; 
216   cHMPID->Divide(3,2) ;
217
218   cHMPID->cd(1); 
219   fhHMPIDCkovP->Draw() ; 
220   hHMPIDpPi->Draw("same") ; 
221   hHMPIDK->Draw("same") ; 
222   hHMPIDP->Draw("same") ;   
223
224   cHMPID->cd(2) ; 
225   fhHMPIDMipXY->Draw() ;   
226
227   cHMPID->cd(3) ; 
228   fhHMPIDProb[0]->Draw() ; 
229   fhHMPIDProb[1]->Draw("same") ;
230   
231   cHMPID->cd(4) ; 
232   fhHMPIDSigP ->Draw() ;                                                          
233
234   cHMPID->cd(5) ; 
235   fhHMPIDDifXY->Draw() ;   
236
237   cHMPID->cd(6) ; 
238   fhHMPIDProb[2]->Draw() ; 
239   fhHMPIDProb[3]->Draw("same") ; 
240   fhHMPIDProb[4]->Draw("same") ; 
241
242   cHMPID->Print("HMPID.eps");
243   
244   char line[1024] ; 
245   sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ; 
246   gROOT->ProcessLine(line);
247   sprintf(line, ".!rm -fR *.eps"); 
248   gROOT->ProcessLine(line);
249   
250   AliInfo(Form("!!! All the eps files are in %s.tar.gz !!!", GetName())) ;
251
252   TString report ; 
253   if(problem)
254     report="Problems found, please check!!!";  
255   else 
256     report="OK";
257
258   AliInfo(Form("*** %s Summary Report: %s \n",GetName(), report.Data())) ; 
259 }