]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ANALYSIS/AliAnalysisTaskPIDResponse.cxx
o updates for the TRD tender (Markus Fasel):
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskPIDResponse.cxx
... / ...
CommitLineData
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#include <AliESDpid.h>
29#include <AliProdInfo.h>
30
31#include "AliAnalysisTaskPIDResponse.h"
32
33ClassImp(AliAnalysisTaskPIDResponse)
34
35//______________________________________________________________________________
36AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse():
37AliAnalysisTaskSE(),
38fIsMC(kFALSE),
39fCachePID(kTRUE),
40fOADBPath(),
41fSpecialDetResponse(),
42fPIDResponse(0x0),
43fRun(0),
44fOldRun(0),
45fRecoPass(0),
46fIsTunedOnData(kFALSE),
47fRecoPassTuned(0),
48fUseTPCEtaCorrection(kFALSE)//TODO: In future, default kTRUE
49{
50 //
51 // Dummy constructor
52 //
53}
54
55//______________________________________________________________________________
56AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(const char* name):
57AliAnalysisTaskSE(name),
58fIsMC(kFALSE),
59fCachePID(kTRUE),
60fOADBPath(),
61fSpecialDetResponse(),
62fPIDResponse(0x0),
63fRun(0),
64fOldRun(0),
65fRecoPass(0),
66fIsTunedOnData(kFALSE),
67fRecoPassTuned(0),
68fUseTPCEtaCorrection(kFALSE)//TODO: In future, default kTRUE
69{
70 //
71 // Default constructor
72 //
73 DefineInput(0,TChain::Class());
74}
75
76//______________________________________________________________________________
77AliAnalysisTaskPIDResponse::~AliAnalysisTaskPIDResponse()
78{
79 //
80 // Destructor
81 //
82}
83
84//______________________________________________________________________________
85void AliAnalysisTaskPIDResponse::UserCreateOutputObjects()
86{
87 //
88 // Create the output QA objects
89 //
90
91 AliLog::SetClassDebugLevel("AliAnalysisTaskPIDResponse",10);
92
93 //input hander
94 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
95 AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
96 if (!inputHandler) AliFatal("Input handler needed");
97
98 //pid response object
99 inputHandler->CreatePIDResponse(fIsMC);
100 fPIDResponse=inputHandler->GetPIDResponse();
101 if (!fPIDResponse) AliFatal("PIDResponse object was not created");
102
103 fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath());
104 fPIDResponse->SetCachePID(fCachePID);
105 if (!fOADBPath.IsNull()) fPIDResponse->SetOADBPath(fOADBPath.Data());
106
107 if(fIsTunedOnData) fPIDResponse->SetTunedOnData(kTRUE,fRecoPassTuned);
108
109 if (!fSpecialDetResponse.IsNull()){
110 TObjArray *arr=fSpecialDetResponse.Tokenize("; ");
111 for (Int_t i=0; i<arr->GetEntriesFast();++i){
112 TString resp(arr->At(i)->GetName());
113 if (resp.BeginsWith("TPC:")){
114 resp.ReplaceAll("TPC:","");
115 fPIDResponse->SetCustomTPCpidResponse(resp.Data());
116 AliInfo(Form("Setting custom TPC response file: '%s'",resp.Data()));
117 }
118 }
119 delete arr;
120 }
121}
122
123//______________________________________________________________________________
124void AliAnalysisTaskPIDResponse::UserExec(Option_t */*option*/)
125{
126 // Setup the PID response functions and fill the QA histograms
127 //
128 AliVEvent *event=InputEvent();
129 if (!event) return;
130 fRun=event->GetRunNumber();
131
132 if (fRun!=fOldRun){
133 SetRecoInfo();
134 fOldRun=fRun;
135 }
136
137 fPIDResponse->SetUseTPCEtaCorrection(fUseTPCEtaCorrection);
138 fPIDResponse->InitialiseEvent(event,fRecoPass);
139 AliESDpid *pidresp = dynamic_cast<AliESDpid*>(fPIDResponse);
140 if(pidresp && AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()){
141 pidresp->SetEventHandler(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
142 }
143 //create and attach transient PID object
144// if (fCachePID) {
145// fPIDResponse->FillTrackDetectorPID();
146// }
147}
148
149//______________________________________________________________________________
150void AliAnalysisTaskPIDResponse::SetRecoInfo()
151{
152 //
153 // Set reconstruction information
154 //
155
156 //reset information
157 fRecoPass=0;
158
159 //Get UserInfo from the current tree
160 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
161 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
162 if (!inputHandler) return;
163
164 TList *uiList = inputHandler->GetUserInfo();
165 AliProdInfo prodInfo(uiList);
166 prodInfo.List();
167
168 TTree *tree= (TTree*)inputHandler->GetTree();
169 TFile *file= (TFile*)tree->GetCurrentFile();
170 if (!file) {
171 AliError("Current file not found, cannot set reconstruction information");
172 return;
173 } else {
174 TString fileName(file->GetName());
175 fPIDResponse->SetCurrentFile(fileName.Data());
176 }
177
178 if (!(prodInfo.IsMC())) { // reco pass is needed only for data
179 fRecoPass = prodInfo.GetRecoPass();
180 if (fRecoPass < 0) { // as last resort we find pass from file name (UGLY, but not stored in ESDs/AODs before LHC12d )
181 TString fileName(file->GetName());
182 if (fileName.Contains("pass1") ) {
183 fRecoPass=1;
184 } else if (fileName.Contains("pass2") ) {
185 fRecoPass=2;
186 } else if (fileName.Contains("pass3") ) {
187 fRecoPass=3;
188 } else if (fileName.Contains("pass4") ) {
189 fRecoPass=4;
190 } else if (fileName.Contains("pass5") ) {
191 fRecoPass=5;
192 }
193 }
194 if (fRecoPass <= 0) {
195 AliError(" ******** Failed to find reconstruction pass number *********");
196 AliError(" ******** Insert pass number inside the path of your local file ******");
197 AliError(" ******** PID information loaded for 'pass 0': parameters unreliable ******");
198 }
199 }
200
201}