AliTPCCalibCE.cxx.diff New algorithm using in addition the laser tracks...
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDAnalysisTask.cxx
CommitLineData
9a8aafa5 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
dcb23f7e 16//==============================================================================
66cdae53 17// AliHMPIDAnalysysTask - Class representing a basic analysis tool of HMPID data
740b6bde 18// A set of histograms is created.
dcb23f7e 19//==============================================================================
740b6bde 20//
dcb23f7e 21// By means of AliHMPIDAnalysisTask.C macro it is possible to use this class
740b6bde 22// to perform the analysis on local data, on data on alien using local machine
23// and on CAF.
dcb23f7e 24
9a8aafa5 25#ifndef AliHMPIDAnalysisTASK_CXX
26#define AliHMPIDAnalysisTASK_CXX
27
740b6bde 28
29#include "TH1.h"
30#include "TH2.h"
31#include "TFile.h"
32#include "TCanvas.h"
33#include "TGraphErrors.h"
9a8aafa5 34#include "AliAnalysisManager.h"
38b8c336 35#include "AliESDInputHandler.h"
740b6bde 36#include "AliMCEventHandler.h"
37#include "AliMCEvent.h"
9a8aafa5 38#include "AliESDtrack.h"
740b6bde 39#include "AliPID.h"
40#include "AliLog.h"
38b8c336 41#include "AliHMPIDAnalysisTask.h"
9a8aafa5 42
43ClassImp(AliHMPIDAnalysisTask)
44
45//__________________________________________________________________________
46AliHMPIDAnalysisTask::AliHMPIDAnalysisTask() :
66cdae53 47 fESD(0x0),fMC(0x0),fUseMC(kTRUE),
48 fHmpHistList(0x0),
9a8aafa5 49 fNevts(0),
50 fTrigNevts(0),
38b8c336 51 fTrigger(0),
dcb23f7e 52 fHmpPesdPhmp(0x0),fHmpCkovPesd(0x0),fHmpCkovPhmp(0x0),
38b8c336 53 fHmpMipTrkDist(0x0),fHmpMipTrkDistX(0x0),fHmpMipTrkDistY(0x0),fHmpMipCharge3cm(0x0),fHmpMipCharge1cm(0x0),fHmpNumPhots(0x0),
740b6bde 54 fHmpTrkFlags(0x0),
55 fN1(6),
56 fN2(8),
57 fPionEff(0x0),
58 fKaonEff(0x0),
59 fProtEff(0x0),
60 fPionTot(0x0),
61 fKaonTot(0x0),
62 fProtTot(0x0),
63 fPionNot(0x0),
64 fKaonNot(0x0),
65 fProtNot(0x0),
66 fPionCon(0x0),
67 fKaonCon(0x0),
68 fProtCon(0x0),
69 fThetavsPiFromK(0x0),
70 fThetapivsPesd(0x0),
71 fThetaKvsPesd(0x0),
72 fThetaPvsPesd(0x0)
9a8aafa5 73{
74 //
75 //Default ctor
76 //
77}
740b6bde 78
9a8aafa5 79//___________________________________________________________________________
80AliHMPIDAnalysisTask::AliHMPIDAnalysisTask(const Char_t* name) :
81 AliAnalysisTaskSE(name),
66cdae53 82 fESD(0x0), fMC(0x0), fUseMC(kTRUE),
83 fHmpHistList(0x0), fNevts(0),
9a8aafa5 84 fTrigNevts(0),
38b8c336 85 fTrigger(0),
740b6bde 86 fHmpPesdPhmp(0x0), fHmpCkovPesd(0x0), fHmpCkovPhmp(0x0),
87 fHmpMipTrkDist(0x0), fHmpMipTrkDistX(0x0), fHmpMipTrkDistY(0x0),
88 fHmpMipCharge3cm(0x0), fHmpMipCharge1cm(0x0),
89 fHmpNumPhots(0x0), fHmpTrkFlags(0x0),
90 fN1(6),
91 fN2(8),
92 fPionEff(0x0),
93 fKaonEff(0x0),
94 fProtEff(0x0),
95 fPionTot(0x0),
96 fKaonTot(0x0),
97 fProtTot(0x0),
98 fPionNot(0x0),
99 fKaonNot(0x0),
100 fProtNot(0x0),
101 fPionCon(0x0),
102 fKaonCon(0x0),
103 fProtCon(0x0),
104 fThetavsPiFromK(0x0),
105 fThetapivsPesd(0x0),
106 fThetaKvsPesd(0x0),
107 fThetaPvsPesd(0x0)
9a8aafa5 108{
109 //
110 // Constructor. Initialization of Inputs and Outputs
111 //
740b6bde 112
66cdae53 113 DefineOutput(1,TList::Class());
740b6bde 114}
115
9a8aafa5 116//___________________________________________________________________________
740b6bde 117AliHMPIDAnalysisTask& AliHMPIDAnalysisTask::operator=(const AliHMPIDAnalysisTask& c)
dcb23f7e 118{
119 //
120 // Assignment operator
121 //
122 if (this!=&c) {
740b6bde 123 AliAnalysisTaskSE::operator=(c);
124 fESD = c.fESD;
66cdae53 125 fMC = c.fMC;
126 fUseMC = c.fUseMC;
740b6bde 127 fHmpHistList = c.fHmpHistList;
dcb23f7e 128 fNevts = c.fNevts;
129 fTrigNevts = c.fTrigNevts;
130 fTrigger = c.fTrigger;
740b6bde 131 fHmpPesdPhmp = c.fHmpPesdPhmp;
132 fHmpCkovPesd = c.fHmpCkovPesd;
133 fHmpCkovPhmp = c.fHmpCkovPhmp;
dcb23f7e 134 fHmpMipTrkDist = c.fHmpMipTrkDist;
135 fHmpMipTrkDistX = c.fHmpMipTrkDistX;
136 fHmpMipTrkDistY = c.fHmpMipTrkDistY;
137 fHmpMipCharge3cm = c.fHmpMipCharge3cm;
138 fHmpMipCharge1cm = c.fHmpMipCharge1cm;
139 fHmpNumPhots = c.fHmpNumPhots;
140 fHmpTrkFlags = c.fHmpTrkFlags;
740b6bde 141 fN1 = c.fN1;
142 fN2 = c.fN2;
143 fPionEff = c.fPionEff;
144 fKaonEff = c.fKaonEff;
145 fProtEff = c.fProtEff;
146 fPionTot = c.fPionTot;
147 fKaonTot = c.fKaonTot;
148 fProtTot = c.fProtTot;
149 fPionNot = c.fPionNot;
150 fKaonNot = c.fKaonNot;
151 fProtNot = c.fProtNot;
152 fPionCon = c.fPionCon;
153 fKaonCon = c.fKaonCon;
154 fProtCon = c.fProtCon;
155 fThetavsPiFromK = c.fThetavsPiFromK;
156 fThetapivsPesd = c.fThetapivsPesd;
157 fThetaKvsPesd = c.fThetaKvsPesd;
158 fThetaPvsPesd = c.fThetaPvsPesd;
dcb23f7e 159 }
160 return *this;
740b6bde 161}
dcb23f7e 162
163//___________________________________________________________________________
164AliHMPIDAnalysisTask::AliHMPIDAnalysisTask(const AliHMPIDAnalysisTask& c) :
165 AliAnalysisTaskSE(c),
66cdae53 166 fESD(c.fESD),fMC(c.fMC),fUseMC(c.fUseMC),
167 fHmpHistList(c.fHmpHistList), fNevts(c.fNevts),
dcb23f7e 168 fTrigNevts(c.fTrigNevts),
169 fTrigger(c.fTrigger),
170 fHmpPesdPhmp(c.fHmpPesdPhmp),fHmpCkovPesd(c.fHmpCkovPesd),fHmpCkovPhmp(c.fHmpCkovPhmp),
740b6bde 171 fHmpMipTrkDist(c.fHmpMipTrkDist),fHmpMipTrkDistX(c.fHmpMipTrkDistX),fHmpMipTrkDistY(c.fHmpMipTrkDistY),
172 fHmpMipCharge3cm(c.fHmpMipCharge3cm), fHmpMipCharge1cm(c.fHmpMipCharge1cm),
173 fHmpNumPhots(c.fHmpNumPhots), fHmpTrkFlags(c.fHmpTrkFlags),
174 fN1(c.fN1),
175 fN2(c.fN2),
176 fPionEff(c.fPionEff),
177 fKaonEff(c.fKaonEff),
178 fProtEff(c.fProtEff),
179 fPionTot(c.fPionTot),
180 fKaonTot(c.fKaonTot),
181 fProtTot(c.fProtTot),
182 fPionNot(c.fPionNot),
183 fKaonNot(c.fKaonNot),
184 fProtNot(c.fProtNot),
185 fPionCon(c.fPionCon),
186 fKaonCon(c.fKaonCon),
187 fProtCon(c.fProtCon),
188 fThetavsPiFromK(c.fThetavsPiFromK),
189 fThetapivsPesd(c.fThetapivsPesd),
190 fThetaKvsPesd(c.fThetaKvsPesd),
191 fThetaPvsPesd(c.fThetaPvsPesd)
dcb23f7e 192{
193 //
194 // Copy Constructor
195 //
196}
197
198//___________________________________________________________________________
9a8aafa5 199AliHMPIDAnalysisTask::~AliHMPIDAnalysisTask() {
200 //
201 //destructor
202 //
740b6bde 203 Info("~AliHMPIDAnalysisTask","Calling Destructor");
66cdae53 204 if (fHmpHistList && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fHmpHistList;
9a8aafa5 205}
740b6bde 206
38b8c336 207//___________________________________________________________________________
66cdae53 208void AliHMPIDAnalysisTask::UserConnectInputData(Option_t *)
38b8c336 209{
210 // Connect ESD here
740b6bde 211
38b8c336 212 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
213 if (!esdH) {
66cdae53 214 AliDebug(2,Form("ERROR: Could not get ESDInputHandler"));
215 } else
216 fESD = esdH->GetEvent();
217
218 if (fUseMC){
219 // Connect MC
220 AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
221 if (!mcH) {
740b6bde 222 AliDebug(2,Form("ERROR: Could not get MCEventHandler"));
66cdae53 223 fUseMC = kFALSE;
740b6bde 224 } else
225 fMC = mcH->MCEvent();
66cdae53 226 }
740b6bde 227}
228
66cdae53 229//___________________________________________________________________________
230void AliHMPIDAnalysisTask::UserExec(Option_t *)
9a8aafa5 231{
740b6bde 232 Double_t priors[5]={1.,1.,1.,1.,1.}; //{0.01,0.01,0.83,0.10,0.5};
233 Double_t probs[5];
234 AliPID *pPid = new AliPID();
235 pPid->SetPriors(priors);
236 Double_t n = 1.293;
237 Double_t dGeVMass[] = {0.000511,0.105658,0.13957018,0.493677,0.938272};
740b6bde 238 AliESDtrack *track=0;
239 TParticle *pPart=0;
66cdae53 240 AliStack* pStack = 0;
241 Int_t label;
242 if (fUseMC){
243 pStack = fMC->Stack();
244 }
245
9a8aafa5 246 //
247 // Main loop function, executed on Event basis
248 //
9a8aafa5 249 for (Int_t iTrack = 0; iTrack<fESD->GetNumberOfTracks(); iTrack++) {
250
740b6bde 251 track = fESD->GetTrack(iTrack);
9a8aafa5 252 if(!track) continue;
740b6bde 253 Double_t dPtr = track->P();
9a8aafa5 254 Double_t rin[3], rout[3];
255 track->GetInnerXYZ(rin);
256 track->GetOuterXYZ(rout);
740b6bde 257 Double_t ktol = 0.001;
258
259 if(Equal(track->GetHMPIDsignal(),-20.,ktol)) fHmpTrkFlags->Fill(0);
260 else if(Equal(track->GetHMPIDsignal(),-9.,ktol)) fHmpTrkFlags->Fill(1);
66cdae53 261 else if(Equal(track->GetHMPIDsignal(),-5.,ktol)) fHmpTrkFlags->Fill(2);
262 else if(Equal(track->GetHMPIDsignal(),-11.,ktol)) fHmpTrkFlags->Fill(3);
740b6bde 263 else if(Equal(track->GetHMPIDsignal(),-22.,ktol)) fHmpTrkFlags->Fill(4);
264 else fHmpTrkFlags->Fill(4);
265
dcb23f7e 266 if(Equal(track->GetHMPIDsignal(),-20.,ktol)) continue;
38b8c336 267 if(track->GetHMPIDcluIdx() < 0) continue;
740b6bde 268
269 //Int_t ch = track->GetHMPIDcluIdx()/1000000;
270 Int_t q, nph;
271 Float_t x, y;
9a8aafa5 272 Float_t xpc, ypc, th, ph;
38b8c336 273 track->GetHMPIDmip(x,y,q,nph);
274 track->GetHMPIDtrk(xpc,ypc,th,ph);
740b6bde 275
dcb23f7e 276 if(Equal(x,0.,ktol) && Equal(y,0.,ktol) && Equal(xpc,0.,ktol) && Equal(ypc,0.,ktol)) continue;
740b6bde 277
9a8aafa5 278 Double_t dist = TMath::Sqrt( (xpc-x)*(xpc-x) + (ypc - y)*(ypc - y));
38b8c336 279 fHmpMipTrkDist->Fill(dist);
740b6bde 280 fHmpMipTrkDistX->Fill(xpc - x);
38b8c336 281 fHmpMipTrkDistY->Fill(ypc - y);
740b6bde 282 Double_t pHmp[3] = {0}, pHmp3 = 0;
283 if (track->GetOuterHmpPxPyPz(pHmp)) pHmp3 = TMath::Sqrt(pHmp[0]*pHmp[0]+pHmp[1]*pHmp[1]+pHmp[2]*pHmp[2]);
284 if (dist <= 3.0) fHmpMipCharge3cm->Fill(q);
285
286 Float_t thetaTheorPion = 999., thetaTheorKaon = 999., thetaTheorProt = 999.,
287 thetaHmpTheorPion = 999., thetaHmpTheorKaon = 999., thetaHmpTheorProt = 999.;
288 if(dPtr != 0){
289 thetaTheorPion = TMath::ACos(TMath::Sqrt(dPtr*dPtr + dGeVMass[2]*dGeVMass[2])/(n*dPtr));
290 thetaTheorKaon = TMath::ACos(TMath::Sqrt(dPtr*dPtr + dGeVMass[3]*dGeVMass[3])/(n*dPtr));
291 thetaTheorProt = TMath::ACos(TMath::Sqrt(dPtr*dPtr + dGeVMass[4]*dGeVMass[4])/(n*dPtr));
292 }
293 if(pHmp3 != 0){
294 thetaHmpTheorPion = TMath::ACos(TMath::Sqrt(pHmp3*pHmp3 + dGeVMass[2]*dGeVMass[2])/(n*pHmp3));
295 thetaHmpTheorKaon = TMath::ACos(TMath::Sqrt(pHmp3*pHmp3 + dGeVMass[3]*dGeVMass[3])/(n*pHmp3));
296 thetaHmpTheorProt = TMath::ACos(TMath::Sqrt(pHmp3*pHmp3 + dGeVMass[4]*dGeVMass[4])/(n*pHmp3));
297 }
298
299 track->GetHMPIDpid(probs);
300 pPid->SetProbabilities(probs);
66cdae53 301 if (fUseMC){
302 if ((label = track->GetLabel()) < 0) continue;
303 pPart = pStack->Particle(label);
304 }
740b6bde 305
66cdae53 306 if(track->GetHMPIDsignal() > 0 ){
740b6bde 307 fHmpPesdPhmp->Fill(track->P(),pHmp3);
308 if (dist<=1.0) fHmpMipCharge1cm->Fill(q);
38b8c336 309 fHmpNumPhots->Fill(nph);
310 fHmpCkovPesd->Fill(track->P(),track->GetHMPIDsignal());
740b6bde 311 fHmpCkovPhmp->Fill(pHmp3,track->GetHMPIDsignal());
312
66cdae53 313 if (fUseMC){
314 if (!pStack->IsPhysicalPrimary(label)) continue;
315 Int_t pdgCode = TMath::Abs(pPart->GetPdgCode());
316 if (pdgCode==211){
317 fThetapivsPesd->Fill(track->P(),track->GetHMPIDsignal());
318 Int_t mot=pPart->GetFirstMother();
319 if (mot > -1){
320 TParticle *pMot=pStack->Particle(mot);
321 TString str=pMot->GetName();
322 if (str.Contains("K")) fThetavsPiFromK->Fill(pHmp3,track->GetHMPIDsignal());
323 }
740b6bde 324 }
66cdae53 325 if (pdgCode==321) fThetaKvsPesd->Fill(track->P(),track->GetHMPIDsignal());
326 if (pdgCode==2212) fThetaPvsPesd->Fill(track->P(),track->GetHMPIDsignal());
327
328 if (track->Pt()<1. || track->Pt()>5.) continue;
329 Int_t ptBin=(Int_t) (2*(track->Pt()-1));
330 if (pdgCode!=2212) fProtCon->Fill(ptBin);
331 if (pdgCode==2212){
332 fProtTot->Fill(ptBin);
333 fProtEff->Fill(ptBin,pPid->GetProbability(AliPID::kProton));
334 fPionNot->Fill(ptBin,pPid->GetProbability(AliPID::kPion));
740b6bde 335 fKaonNot->Fill(ptBin,pPid->GetProbability(AliPID::kKaon));
336 }
66cdae53 337 if (pdgCode!=211) fPionCon->Fill(ptBin);
338 if (pdgCode!=321) fKaonCon->Fill(ptBin);
339 if (pdgCode==211){
340 if (ptBin < 6){
341 Float_t weight=pPid->GetProbability(AliPID::kElectron)+
342 pPid->GetProbability(AliPID::kMuon)+
343 pPid->GetProbability(AliPID::kPion);
344 fPionTot->Fill(ptBin);
345 fPionEff->Fill(ptBin,weight);
346 fKaonNot->Fill(ptBin,pPid->GetProbability(AliPID::kKaon));
347 }
348 fProtNot->Fill(ptBin,pPid->GetProbability(AliPID::kProton));
349 }
350 if (pdgCode==321){
351 if (ptBin < 6){
352 fKaonTot->Fill(ptBin);
353 fKaonEff->Fill(ptBin,pPid->GetProbability(AliPID::kKaon));
354 fPionNot->Fill(ptBin,(pPid->GetProbability(AliPID::kPion)));
355 }
356 fProtNot->Fill(ptBin,(pPid->GetProbability(AliPID::kProton)));
740b6bde 357 }
740b6bde 358 }
38b8c336 359 }//there is signal
740b6bde 360 }//track loop
361
362 delete pPid;
363
9a8aafa5 364 /* PostData(0) is taken care of by AliAnalysisTaskSE */
66cdae53 365 PostData(1,fHmpHistList);
9a8aafa5 366}
367
9a8aafa5 368//___________________________________________________________________________
369void AliHMPIDAnalysisTask::Terminate(Option_t*)
370{
371 // The Terminate() function is the last function to be called during
372 // a query. It always runs on the client, it can be used to present
373 // the results graphically or save the results to file.
374
375 Info("Terminate","");
66cdae53 376
377 if (!fUseMC) return;
378
379 fHmpHistList = dynamic_cast<TList*> (GetOutputData(1));
380
381 if (!fHmpHistList) {
382 AliError("Histogram List is not available");
383 return;
384 }
740b6bde 385
386 fPionEff = dynamic_cast<TH1F*> (fHmpHistList->FindObject("PionEff"));
387 fPionTot = dynamic_cast<TH1I*> (fHmpHistList->FindObject("PionTot"));
388 fPionNot = dynamic_cast<TH1F*> (fHmpHistList->FindObject("PionNot"));
389 fPionCon = dynamic_cast<TH1I*> (fHmpHistList->FindObject("PionCon"));
390 fKaonEff = dynamic_cast<TH1F*> (fHmpHistList->FindObject("KaonEff"));
391 fKaonTot = dynamic_cast<TH1I*> (fHmpHistList->FindObject("KaonTot"));
392 fKaonNot = dynamic_cast<TH1F*> (fHmpHistList->FindObject("KaonNot"));
393 fKaonCon = dynamic_cast<TH1I*> (fHmpHistList->FindObject("KaonCon"));
394 fProtEff = dynamic_cast<TH1F*> (fHmpHistList->FindObject("ProtEff"));
395 fProtTot = dynamic_cast<TH1I*> (fHmpHistList->FindObject("ProtTot"));
396 fProtNot = dynamic_cast<TH1F*> (fHmpHistList->FindObject("ProtNot"));
397 fProtCon = dynamic_cast<TH1I*> (fHmpHistList->FindObject("ProtCon"));
398
399 Float_t *pionEff=fPionEff->GetArray();
400 Int_t *pionTot=fPionTot->GetArray();
401 Float_t *pionNot=fPionNot->GetArray();
402 Int_t *pionCon=fPionCon->GetArray();
403 Float_t *kaonEff=fKaonEff->GetArray();
404 Int_t *kaonTot=fKaonTot->GetArray();
405 Float_t *kaonNot=fKaonNot->GetArray();
406 Int_t *kaonCon=fKaonCon->GetArray();
407 Float_t *protEff=fProtEff->GetArray();
408 Int_t *protTot=fProtTot->GetArray();
409 Float_t *protNot=fProtNot->GetArray();
410 Int_t *protCon=fProtCon->GetArray();
411
412 TGraphErrors *effPi = new TGraphErrors(fN1);
413 TGraphErrors *effKa = new TGraphErrors(fN1);
414 TGraphErrors *effPr = new TGraphErrors(fN2);
415 TGraphErrors *conPi = new TGraphErrors(fN1);
416 TGraphErrors *conKa = new TGraphErrors(fN1);
417 TGraphErrors *conPr = new TGraphErrors(fN2);
418
419 Float_t pt[8]={1.25,1.75,2.25,2.75,3.25,3.75,4.25,4.75};
420 Float_t eff=0, effErr=0, con=0, conErr=0;
421 for (Int_t i=0; i< fN2; i++){
422 eff = protEff[i+1]/TMath::Max(protTot[i+1],1);
423 effErr = TMath::Sqrt(eff*(1.-eff)/TMath::Max(protTot[i+1],1));
424 con = protNot[i+1]/TMath::Max(protCon[i+1],1);
425 conErr = TMath::Sqrt(con*(1.-con)/protCon[i+1]);
426 effPr->SetPoint(i,pt[i],eff);
427 effPr->SetPointError(i,0,effErr);
428 conPr->SetPoint(i,pt[i],con);
429 conPr->SetPointError(i,0,conErr);
430
431 if (i>=fN1) continue;
432 eff = pionEff[i+1]/pionTot[i+1];
433 effErr = TMath::Sqrt(eff*(1.-eff)/pionTot[i+1]);
434 con=pionNot[i+1]/pionCon[i+1];
435 conErr = TMath::Sqrt(con*(1.-con)/pionCon[i+1]);
436 effPi->SetPoint(i,pt[i],(Float_t)pionEff[i+1]/(Float_t)pionTot[i+1]);
437 effPi->SetPointError(i,0,effErr);
438 conPi->SetPoint(i,pt[i],(Float_t)pionNot[i+1]/(Float_t)pionCon[i+1]);
439 conPi->SetPointError(i,0,conErr);
440
441 eff = kaonEff[i+1]/TMath::Max(kaonTot[i+1],1);
442 effErr = TMath::Sqrt(eff*(1.-eff)/kaonTot[i+1]);
443 con = kaonNot[i+1]/TMath::Max(kaonCon[i+1],1);
444 conErr = TMath::Sqrt(con*(1.-con)/kaonCon[i+1]);
445 effKa->SetPoint(i,pt[i],(Float_t)kaonEff[i+1]/TMath::Max(kaonTot[i+1],1));
446 effKa->SetPointError(i,0,effErr);
447 conKa->SetPoint(i,pt[i],(Float_t)kaonNot[i+1]/TMath::Max(kaonCon[i+1],1));
448 conKa->SetPointError(i,0,conErr);
449 }
450
451 TCanvas *pCan=new TCanvas("Hmp","Efficiency and contamination",500,900);
452 pCan->Divide(1,3);
453
454 pCan->cd(1);
455 effPi->SetTitle("Pions");
456 effPi->GetXaxis()->SetTitle("p_{T} (GeV/c)");
457 effPi->GetYaxis()->SetRangeUser(0.,1.);
458 effPi->SetMarkerStyle(20);
459 effPi->Draw("ALP");
460 conPi->SetMarkerStyle(21);
461 conPi->Draw("sameLP");
462
463 pCan->cd(2);
464 effKa->SetTitle("Kaons");
465 effKa->GetXaxis()->SetTitle("p_{T} (GeV/c)");
466 effKa->GetYaxis()->SetRangeUser(0.,1.);
467 effKa->SetMarkerStyle(20);
468 effKa->Draw("ALP");
469 conKa->SetMarkerStyle(21);
470 conKa->Draw("sameLP");
471
472 pCan->cd(3);
473 effPr->SetTitle("Protons");
474 effPr->GetXaxis()->SetTitle("p_{T} (GeV/c)");
475 effPr->GetYaxis()->SetRangeUser(0.,1.);
476 effPr->SetMarkerStyle(20);
477 effPr->Draw("ALP");
478 conPr->SetMarkerStyle(21);
479 conPr->Draw("sameLP");
480
481 TFile *outFile = new TFile("HmpidGraphs.root","recreate");
482 pCan->Write();
483 outFile->Close();
484
9a8aafa5 485 AliAnalysisTaskSE::Terminate();
486
487}
488
9a8aafa5 489//___________________________________________________________________________
66cdae53 490void AliHMPIDAnalysisTask::UserCreateOutputObjects() {
9a8aafa5 491 //
492 //HERE ONE CAN CREATE OUTPUT OBJECTS
493 //TO BE SET BEFORE THE EXECUTION OF THE TASK
494 //
9a8aafa5 495
496 //slot #1
66cdae53 497 OpenFile(1);
38b8c336 498 fHmpHistList = new TList();
740b6bde 499
38b8c336 500 fHmpPesdPhmp = new TH2F("fHmpPesdPhmp","HMPID: ESD p - running p;HMP p (GeV/c);ESD p (Gev/c)",100,0,10,100,0,10);
501 fHmpHistList->Add(fHmpPesdPhmp);
740b6bde 502
38b8c336 503 fHmpCkovPesd = new TH2F("fHmpCkovPesd","HMPID: ThetaCherenkov vs P;p_esd (GeV/c);#Theta_C;Entries",100,0,10,110,0,1.1);
504 fHmpHistList->Add(fHmpCkovPesd);
740b6bde 505
38b8c336 506 fHmpCkovPhmp = new TH2F("fHmpCkovPhmp","HMPID: ThetaCherenkov vs P;p_hmp (GeV/c);#Theta_C;Entries",100,0,10,110,0,1.1);
740b6bde 507 fHmpHistList->Add(fHmpCkovPhmp);
508
38b8c336 509 fHmpMipTrkDist = new TH1F("fHmpMipTrkDist","HMPID MIP-Track distance;distance (cm);Entries",800,-20,20);
510 fHmpHistList->Add(fHmpMipTrkDist);
740b6bde 511
38b8c336 512 fHmpMipTrkDistX = new TH1F("fHmpMipTrkDistX","HMPID MIP-Track distance in local X;distance (cm);Entries",800,-20,20);
513 fHmpHistList->Add(fHmpMipTrkDistX);
740b6bde 514
38b8c336 515 fHmpMipTrkDistY = new TH1F("fHmpMipTrkDistY","HMPID MIP-Track distance in local Y;distance (cm);Entries",800,-20,20);
516 fHmpHistList->Add(fHmpMipTrkDistY);
740b6bde 517
38b8c336 518 fHmpMipCharge3cm = new TH1F("fHmpMipCharge3cm","HMPID MIP Charge;MIP Charge (ADC);Entries",5001,-0.5,5000.5);
519 fHmpHistList->Add(fHmpMipCharge3cm);
740b6bde 520
38b8c336 521 fHmpMipCharge1cm = new TH1F("fHmpMipCharge1cm","HMPID MIP Charge;MIP Charge (ADC);Entries",5001,-0.5,5000.5);
522 fHmpHistList->Add(fHmpMipCharge1cm);
740b6bde 523
38b8c336 524 fHmpNumPhots = new TH1F("fHmpNumPhots","HMPID Number of photon clusters on ring;#photon clus.;Entries",51,-0.5,50.5);
525 fHmpHistList->Add(fHmpNumPhots);
740b6bde 526
38b8c336 527 fHmpTrkFlags = new TH1F("fHmpTrkFlags","HMPID track flags",6,0,6);
528 TString summary[6] = {"NotPerformed","MipDistCut", "MipQdcCut", "NoPhotAccept", "kNoRad", "other"};
529 for(Int_t ibin = 0; ibin < 6; ibin++) fHmpTrkFlags->GetXaxis()->SetBinLabel(ibin+1,Form("%i %s",ibin+1,summary[ibin].Data()));
530 fHmpHistList->Add(fHmpTrkFlags);
740b6bde 531
532 fPionEff = new TH1F("PionEff","Identified pions",fN1,0,fN1);
533 fKaonEff = new TH1F("KaonEff","Identified kaons",fN1,0,fN1);
534 fProtEff = new TH1F("ProtEff","Identified protons",fN2,0,fN2);
535 fPionTot = new TH1I("PionTot","Total MC pions",fN1,0,fN1);
536 fKaonTot = new TH1I("KaonTot","Total MC kaons",fN1,0,fN1);
537 fProtTot = new TH1I("ProtTot","Total MC protons",fN2,0,fN2);
538 fPionNot = new TH1F("PionNot","Misidentified pions",fN1,0,fN1);
539 fKaonNot = new TH1F("KaonNot","Misidentified kaons",fN1,0,fN1);
540 fProtNot = new TH1F("ProtNot","Misidentified protons",fN2,0,fN2);
541 fPionCon = new TH1I("PionCon","Total not MC pions",fN1,0,fN1);
542 fKaonCon = new TH1I("KaonCon","Total not MC kaons",fN1,0,fN1);
543 fProtCon = new TH1I("ProtCon","Total not MC protons",fN2,0,fN2);
544
545 fHmpHistList->Add(fPionEff); fHmpHistList->Add(fKaonEff); fHmpHistList->Add(fProtEff);
546 fHmpHistList->Add(fPionTot); fHmpHistList->Add(fKaonTot); fHmpHistList->Add(fProtTot);
547 fHmpHistList->Add(fPionNot); fHmpHistList->Add(fKaonNot); fHmpHistList->Add(fProtNot);
548 fHmpHistList->Add(fPionCon); fHmpHistList->Add(fKaonCon); fHmpHistList->Add(fProtCon);
549
550 fThetavsPiFromK= new TH2F("ThetavsPiFromK","Theta vs p of pions from K;p_esd (GeV/c);#Theta_C",100,0,10,110,0,1.1);
551 fHmpHistList->Add(fThetavsPiFromK);
552
553 fThetapivsPesd = new TH2F("ThetapivsPesd","Theta of pions vs p of esd;p_esd (GeV/c);#Theta_C",100,0,10,110,0,1.1);
554 fHmpHistList->Add(fThetapivsPesd);
555
556 fThetaKvsPesd = new TH2F("ThetaKvsPesd","Theta of kaons vs p of esd;p_esd (GeV/c);#Theta_C",100,0,10,110,0,1.1);
557 fHmpHistList->Add(fThetaKvsPesd);
558
559 fThetaPvsPesd = new TH2F("ThetaPvsPesd","Theta of protons vs p of esd;p_esd (GeV/c);#Theta_C",100,0,10,110,0,1.1);
560 fHmpHistList->Add(fThetaPvsPesd);
561
9a8aafa5 562}
dcb23f7e 563//____________________________________________________________________________________________________________________________________
564Bool_t AliHMPIDAnalysisTask::Equal(Double_t x, Double_t y, Double_t tolerance)
565{
740b6bde 566 return abs(x - y) <= tolerance ;
567}
dcb23f7e 568
9a8aafa5 569#endif