]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliAnalysisTaskPIDResponse.cxx
From Francesco Noferini: important change in the STEER and ANALYSIS dir that allows...
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskPIDResponse.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: AliAnalysisTaskPIDResponse.cxx 43811 2010-09-23 14:13:31Z wiechula $ */
17 #include <TFile.h>
18 #include <TChain.h>
19
20 #include <AliAnalysisManager.h>
21 #include <AliInputEventHandler.h>
22 #include <AliVEventHandler.h>
23 #include <AliVEvent.h>
24 #include <AliVParticle.h>
25 #include <AliVTrack.h>
26 #include <AliLog.h>
27 #include <AliPIDResponse.h>
28
29 #include "AliAnalysisTaskPIDResponse.h"
30
31 ClassImp(AliAnalysisTaskPIDResponse)
32
33 //______________________________________________________________________________
34 AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse():
35 AliAnalysisTaskSE(),
36 fIsMC(kFALSE),
37 fOADBPath(),
38 fPIDResponse(0x0),
39 fRun(0),
40 fOldRun(0),
41 fRecoPass(0),
42 fIsTunedOnData(kFALSE),
43 fRecoPassTuned(0)  
44 {
45   //
46   // Dummy constructor
47   //
48 }
49
50 //______________________________________________________________________________
51 AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(const char* name):
52 AliAnalysisTaskSE(name),
53 fIsMC(kFALSE),
54 fOADBPath(),
55 fPIDResponse(0x0),
56 fRun(0),
57 fOldRun(0),
58 fRecoPass(0),
59 fIsTunedOnData(kFALSE),
60 fRecoPassTuned(0)
61 {
62   //
63   // Default constructor
64   //
65   DefineInput(0,TChain::Class());
66 }
67
68 //______________________________________________________________________________
69 AliAnalysisTaskPIDResponse::~AliAnalysisTaskPIDResponse()
70 {
71   //
72   // Destructor
73   //
74 }
75
76 //______________________________________________________________________________
77 void AliAnalysisTaskPIDResponse::UserCreateOutputObjects()
78 {
79   //
80   // Create the output QA objects
81   //
82   
83   AliLog::SetClassDebugLevel("AliAnalysisTaskPIDResponse",10);
84   
85   //input hander
86   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
87   AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
88   if (!inputHandler) AliFatal("Input handler needed");
89   
90   //pid response object
91   inputHandler->CreatePIDResponse(fIsMC);
92   fPIDResponse=inputHandler->GetPIDResponse();
93   if (!fPIDResponse) AliFatal("PIDResponse object was not created");
94
95   fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath());
96   if (!fOADBPath.IsNull()) fPIDResponse->SetOADBPath(fOADBPath.Data());
97
98   if(fIsTunedOnData) fPIDResponse->SetTunedOnData(kTRUE,fRecoPassTuned);
99 }
100
101 //______________________________________________________________________________
102 void AliAnalysisTaskPIDResponse::UserExec(Option_t */*option*/)
103 {
104   // Setup the PID response functions and fill the QA histograms
105   //
106   AliVEvent *event=InputEvent();
107   if (!event) return;
108   fRun=event->GetRunNumber();
109   
110   if (fRun!=fOldRun){
111     SetRecoInfo();
112     fOldRun=fRun;
113   }
114
115   fPIDResponse->InitialiseEvent(event,fRecoPass);
116 }
117
118 //______________________________________________________________________________
119 void AliAnalysisTaskPIDResponse::SetRecoInfo()
120 {
121   //
122   // Set reconstruction information
123   //
124   
125   //reset information
126   fRecoPass=0;
127   
128   //Get the current file to check the reconstruction pass (UGLY, but not stored in ESD... )
129   AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
130   AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
131   if (!inputHandler) return;
132   
133   TTree *tree= (TTree*)inputHandler->GetTree();
134   TFile *file= (TFile*)tree->GetCurrentFile();
135   
136   if (!file) {
137     AliError("Current file not found, cannot set reconstruction information");
138     return;
139   }
140   
141   //find pass from file name (UGLY, but not stored in ESD... )
142   TString fileName(file->GetName());
143   if (fileName.Contains("pass1") ) {
144     fRecoPass=1;
145   } else if (fileName.Contains("pass2") ) {
146     fRecoPass=2;
147   } else if (fileName.Contains("pass3") ) {
148     fRecoPass=3;
149   } else if (fileName.Contains("pass4") ) {
150     fRecoPass=4;
151   } else if (fileName.Contains("pass5") ) {
152     fRecoPass=5;
153   }
154
155   fPIDResponse->SetCurrentFile(fileName.Data());
156 }