1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliAnalysisTaskPIDResponse.cxx 43811 2010-09-23 14:13:31Z wiechula $ */
20 #include <AliAnalysisManager.h>
21 #include <AliInputEventHandler.h>
22 #include <AliVEventHandler.h>
23 #include <AliVEvent.h>
24 #include <AliVParticle.h>
25 #include <AliVTrack.h>
27 #include <AliPIDResponse.h>
28 #include <AliESDpid.h>
29 #include <AliProdInfo.h>
31 #include "AliAnalysisTaskPIDResponse.h"
33 ClassImp(AliAnalysisTaskPIDResponse)
35 //______________________________________________________________________________
36 AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse():
41 fSpecialDetResponse(),
46 fIsTunedOnData(kFALSE),
48 fUseTPCEtaCorrection(kFALSE)//TODO: In future, default kTRUE
55 //______________________________________________________________________________
56 AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(const char* name):
57 AliAnalysisTaskSE(name),
61 fSpecialDetResponse(),
66 fIsTunedOnData(kFALSE),
68 fUseTPCEtaCorrection(kFALSE)//TODO: In future, default kTRUE
71 // Default constructor
73 DefineInput(0,TChain::Class());
76 //______________________________________________________________________________
77 AliAnalysisTaskPIDResponse::~AliAnalysisTaskPIDResponse()
84 //______________________________________________________________________________
85 void AliAnalysisTaskPIDResponse::UserCreateOutputObjects()
88 // Create the output QA objects
91 AliLog::SetClassDebugLevel("AliAnalysisTaskPIDResponse",10);
94 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
95 AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
96 if (!inputHandler) AliFatal("Input handler needed");
99 inputHandler->CreatePIDResponse(fIsMC);
100 fPIDResponse=inputHandler->GetPIDResponse();
101 if (!fPIDResponse) AliFatal("PIDResponse object was not created");
103 fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath());
104 fPIDResponse->SetCachePID(fCachePID);
105 if (!fOADBPath.IsNull()) fPIDResponse->SetOADBPath(fOADBPath.Data());
107 if(fIsTunedOnData) fPIDResponse->SetTunedOnData(kTRUE,fRecoPassTuned);
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()));
123 //______________________________________________________________________________
124 void AliAnalysisTaskPIDResponse::UserExec(Option_t */*option*/)
126 // Setup the PID response functions and fill the QA histograms
128 AliVEvent *event=InputEvent();
130 fRun=event->GetRunNumber();
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());
143 //create and attach transient PID object
145 // fPIDResponse->FillTrackDetectorPID();
149 //______________________________________________________________________________
150 void AliAnalysisTaskPIDResponse::SetRecoInfo()
153 // Set reconstruction information
159 //Get UserInfo from the current tree
160 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
161 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
162 if (!inputHandler) return;
164 TList *uiList = inputHandler->GetUserInfo();
165 AliProdInfo prodInfo(uiList);
168 TTree *tree= (TTree*)inputHandler->GetTree();
169 TFile *file= (TFile*)tree->GetCurrentFile();
171 AliError("Current file not found, cannot set reconstruction information");
174 TString fileName(file->GetName());
175 fPIDResponse->SetCurrentFile(fileName.Data());
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") ) {
184 } else if (fileName.Contains("pass2") ) {
186 } else if (fileName.Contains("pass3") ) {
188 } else if (fileName.Contains("pass4") ) {
190 } else if (fileName.Contains("pass5") ) {
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 ******");