]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAnalysisTaskPIDResponse.cxx
add pyquen quenching strength
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskPIDResponse.cxx
CommitLineData
66ab8ab2 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 $ */
66ab8ab2 17#include <TFile.h>
66ab8ab2 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>
66ab8ab2 27#include <AliPIDResponse.h>
a864479b 28#include <AliESDpid.h>
9bfecba8 29#include <AliProdInfo.h>
a864479b 30
66ab8ab2 31#include "AliAnalysisTaskPIDResponse.h"
32
66ab8ab2 33ClassImp(AliAnalysisTaskPIDResponse)
34
35//______________________________________________________________________________
36AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse():
37AliAnalysisTaskSE(),
38fIsMC(kFALSE),
00a38d07 39fCachePID(kTRUE),
67ad8680 40fOADBPath(),
b438e263 41fSpecialDetResponse(),
66ab8ab2 42fPIDResponse(0x0),
d14b3358 43fRun(-1),
be1689cc 44fOldRun(-1),
539a5a59 45fRecoPass(0),
46fIsTunedOnData(kFALSE),
e6caef65 47fTunedOnDataMask(0),
f84b18dd 48fRecoPassTuned(0),
22158469
JW
49fUseTPCEtaCorrection(kTRUE),
50fUseTPCMultiplicityCorrection(kTRUE),
2e8a05e1 51fUserDataRecoPass(-1)
66ab8ab2 52{
53 //
54 // Dummy constructor
55 //
56}
57
58//______________________________________________________________________________
59AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(const char* name):
60AliAnalysisTaskSE(name),
61fIsMC(kFALSE),
00a38d07 62fCachePID(kTRUE),
67ad8680 63fOADBPath(),
b438e263 64fSpecialDetResponse(),
66ab8ab2 65fPIDResponse(0x0),
d14b3358 66fRun(-1),
be1689cc 67fOldRun(-1),
539a5a59 68fRecoPass(0),
69fIsTunedOnData(kFALSE),
e6caef65 70fTunedOnDataMask(0),
f84b18dd 71fRecoPassTuned(0),
22158469
JW
72fUseTPCEtaCorrection(kTRUE),
73fUseTPCMultiplicityCorrection(kTRUE),
2e8a05e1 74fUserDataRecoPass(-1)
66ab8ab2 75{
76 //
77 // Default constructor
78 //
79 DefineInput(0,TChain::Class());
66ab8ab2 80}
81
82//______________________________________________________________________________
83AliAnalysisTaskPIDResponse::~AliAnalysisTaskPIDResponse()
84{
85 //
86 // Destructor
87 //
66ab8ab2 88}
89
90//______________________________________________________________________________
91void AliAnalysisTaskPIDResponse::UserCreateOutputObjects()
92{
93 //
94 // Create the output QA objects
95 //
00a38d07 96
66ab8ab2 97 AliLog::SetClassDebugLevel("AliAnalysisTaskPIDResponse",10);
00a38d07 98
66ab8ab2 99 //input hander
100 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
101 AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
102 if (!inputHandler) AliFatal("Input handler needed");
6a45d03f 103
66ab8ab2 104 //pid response object
105 inputHandler->CreatePIDResponse(fIsMC);
106 fPIDResponse=inputHandler->GetPIDResponse();
87977cf5 107 if (!fPIDResponse) AliFatal("PIDResponse object was not created");
66ab8ab2 108
6a45d03f 109 fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath());
1c9d11be 110 fPIDResponse->SetCachePID(fCachePID);
67ad8680 111 if (!fOADBPath.IsNull()) fPIDResponse->SetOADBPath(fOADBPath.Data());
539a5a59 112
113 if(fIsTunedOnData) fPIDResponse->SetTunedOnData(kTRUE,fRecoPassTuned);
e6caef65 114 if(fTunedOnDataMask != 0) fPIDResponse->SetTunedOnDataMask(fTunedOnDataMask);
b438e263 115
116 if (!fSpecialDetResponse.IsNull()){
117 TObjArray *arr=fSpecialDetResponse.Tokenize("; ");
118 for (Int_t i=0; i<arr->GetEntriesFast();++i){
119 TString resp(arr->At(i)->GetName());
120 if (resp.BeginsWith("TPC:")){
121 resp.ReplaceAll("TPC:","");
122 fPIDResponse->SetCustomTPCpidResponse(resp.Data());
123 AliInfo(Form("Setting custom TPC response file: '%s'",resp.Data()));
124 }
125 }
1c9d11be 126 delete arr;
87da0205 127 }
66ab8ab2 128}
129
66ab8ab2 130//______________________________________________________________________________
131void AliAnalysisTaskPIDResponse::UserExec(Option_t */*option*/)
132{
66ab8ab2 133 // Setup the PID response functions and fill the QA histograms
134 //
66ab8ab2 135 AliVEvent *event=InputEvent();
136 if (!event) return;
137 fRun=event->GetRunNumber();
6a45d03f 138
66ab8ab2 139 if (fRun!=fOldRun){
6a45d03f 140 SetRecoInfo();
66ab8ab2 141 fOldRun=fRun;
87da0205 142
143 fPIDResponse->SetUseTPCEtaCorrection(fUseTPCEtaCorrection);
144 fPIDResponse->SetUseTPCMultiplicityCorrection(fUseTPCMultiplicityCorrection);
66ab8ab2 145 }
146
6a45d03f 147 fPIDResponse->InitialiseEvent(event,fRecoPass);
a864479b 148 AliESDpid *pidresp = dynamic_cast<AliESDpid*>(fPIDResponse);
149 if(pidresp && AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()){
150 pidresp->SetEventHandler(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
151 }
00a38d07 152 //create and attach transient PID object
1c9d11be 153// if (fCachePID) {
154// fPIDResponse->FillTrackDetectorPID();
155// }
66ab8ab2 156}
157
66ab8ab2 158//______________________________________________________________________________
159void AliAnalysisTaskPIDResponse::SetRecoInfo()
160{
161 //
162 // Set reconstruction information
163 //
164
165 //reset information
166 fRecoPass=0;
66ab8ab2 167
9bfecba8 168 //Get UserInfo from the current tree
66ab8ab2 169 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
170 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
171 if (!inputHandler) return;
9bfecba8 172
173 TList *uiList = inputHandler->GetUserInfo();
174 AliProdInfo prodInfo(uiList);
175 prodInfo.List();
176
66ab8ab2 177 TTree *tree= (TTree*)inputHandler->GetTree();
178 TFile *file= (TFile*)tree->GetCurrentFile();
66ab8ab2 179 if (!file) {
180 AliError("Current file not found, cannot set reconstruction information");
181 return;
9bfecba8 182 } else {
183 TString fileName(file->GetName());
184 fPIDResponse->SetCurrentFile(fileName.Data());
66ab8ab2 185 }
9bfecba8 186
87da0205 187 fPIDResponse->SetCurrentAliRootRev(prodInfo.GetAlirootSvnVersion());
188
f051eaf2 189 if (prodInfo.IsMC() == kTRUE) fIsMC=kTRUE; // protection if user didn't use macro switch
190 if ( (prodInfo.IsMC() == kFALSE) && (fIsMC == kFALSE) ) { // reco pass is needed only for data
2e8a05e1 191
192 if (fUserDataRecoPass > -1) {
193 AliInfo(Form("Data reconstruction pass is user specified. Setting pass #: %d",fUserDataRecoPass));
194 fRecoPass = fUserDataRecoPass;
195 } else {
196 fRecoPass = prodInfo.GetRecoPass();
197 if (fRecoPass < 0) { // as last resort we find pass from file name (UGLY, but not stored in ESDs/AODs before LHC12d )
198 TString fileName(file->GetName());
199 if (fileName.Contains("pass1") ) {
200 fRecoPass=1;
201 } else if (fileName.Contains("pass2") ) {
202 fRecoPass=2;
203 } else if (fileName.Contains("pass3") ) {
204 fRecoPass=3;
205 } else if (fileName.Contains("pass4") ) {
206 fRecoPass=4;
207 } else if (fileName.Contains("pass5") ) {
208 fRecoPass=5;
209 }
9bfecba8 210 }
2e8a05e1 211 }
9bfecba8 212 if (fRecoPass <= 0) {
213 AliError(" ******** Failed to find reconstruction pass number *********");
9bfecba8 214 AliError(" ******** PID information loaded for 'pass 0': parameters unreliable ******");
f051eaf2 215 AliError(" --> If these are MC data: please set kTRUE first argument of AddTaskPIDResponse");
2e8a05e1 216 AliError(" --> If these are real data: ");
217 AliError(" (a) please insert pass number inside the path of your local file OR");
218 AliError(" (b) specify reconstruction pass number when adding PIDResponse task");
219 AliFatal(" no pass number specified for this data file, abort. Asserting AliFatal");
9bfecba8 220 }
66ab8ab2 221 }
67ad8680 222
66ab8ab2 223}