]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAnalysisTaskPIDResponse.cxx
New histos in the task for checks on the MC kinematics
[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),
66ab8ab2 43fRun(0),
44fOldRun(0),
539a5a59 45fRecoPass(0),
46fIsTunedOnData(kFALSE),
f84b18dd 47fRecoPassTuned(0),
48fUseTPCEtaCorrection(kFALSE)//TODO: In future, default kTRUE
66ab8ab2 49{
50 //
51 // Dummy constructor
52 //
53}
54
55//______________________________________________________________________________
56AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(const char* name):
57AliAnalysisTaskSE(name),
58fIsMC(kFALSE),
00a38d07 59fCachePID(kTRUE),
67ad8680 60fOADBPath(),
b438e263 61fSpecialDetResponse(),
66ab8ab2 62fPIDResponse(0x0),
66ab8ab2 63fRun(0),
64fOldRun(0),
539a5a59 65fRecoPass(0),
66fIsTunedOnData(kFALSE),
f84b18dd 67fRecoPassTuned(0),
68fUseTPCEtaCorrection(kFALSE)//TODO: In future, default kTRUE
66ab8ab2 69{
70 //
71 // Default constructor
72 //
73 DefineInput(0,TChain::Class());
66ab8ab2 74}
75
76//______________________________________________________________________________
77AliAnalysisTaskPIDResponse::~AliAnalysisTaskPIDResponse()
78{
79 //
80 // Destructor
81 //
66ab8ab2 82}
83
84//______________________________________________________________________________
85void AliAnalysisTaskPIDResponse::UserCreateOutputObjects()
86{
87 //
88 // Create the output QA objects
89 //
00a38d07 90
66ab8ab2 91 AliLog::SetClassDebugLevel("AliAnalysisTaskPIDResponse",10);
00a38d07 92
66ab8ab2 93 //input hander
94 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
95 AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
96 if (!inputHandler) AliFatal("Input handler needed");
6a45d03f 97
66ab8ab2 98 //pid response object
99 inputHandler->CreatePIDResponse(fIsMC);
100 fPIDResponse=inputHandler->GetPIDResponse();
87977cf5 101 if (!fPIDResponse) AliFatal("PIDResponse object was not created");
66ab8ab2 102
6a45d03f 103 fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath());
1c9d11be 104 fPIDResponse->SetCachePID(fCachePID);
67ad8680 105 if (!fOADBPath.IsNull()) fPIDResponse->SetOADBPath(fOADBPath.Data());
539a5a59 106
107 if(fIsTunedOnData) fPIDResponse->SetTunedOnData(kTRUE,fRecoPassTuned);
b438e263 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 }
1c9d11be 119 delete arr;
b438e263 120 }
66ab8ab2 121}
122
66ab8ab2 123//______________________________________________________________________________
124void AliAnalysisTaskPIDResponse::UserExec(Option_t */*option*/)
125{
66ab8ab2 126 // Setup the PID response functions and fill the QA histograms
127 //
66ab8ab2 128 AliVEvent *event=InputEvent();
129 if (!event) return;
130 fRun=event->GetRunNumber();
6a45d03f 131
66ab8ab2 132 if (fRun!=fOldRun){
6a45d03f 133 SetRecoInfo();
66ab8ab2 134 fOldRun=fRun;
135 }
136
f84b18dd 137 fPIDResponse->SetUseTPCEtaCorrection(fUseTPCEtaCorrection);
6a45d03f 138 fPIDResponse->InitialiseEvent(event,fRecoPass);
a864479b 139 AliESDpid *pidresp = dynamic_cast<AliESDpid*>(fPIDResponse);
140 if(pidresp && AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()){
141 pidresp->SetEventHandler(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
142 }
00a38d07 143 //create and attach transient PID object
1c9d11be 144// if (fCachePID) {
145// fPIDResponse->FillTrackDetectorPID();
146// }
66ab8ab2 147}
148
66ab8ab2 149//______________________________________________________________________________
150void AliAnalysisTaskPIDResponse::SetRecoInfo()
151{
152 //
153 // Set reconstruction information
154 //
155
156 //reset information
157 fRecoPass=0;
66ab8ab2 158
9bfecba8 159 //Get UserInfo from the current tree
66ab8ab2 160 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
161 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
162 if (!inputHandler) return;
9bfecba8 163
164 TList *uiList = inputHandler->GetUserInfo();
165 AliProdInfo prodInfo(uiList);
166 prodInfo.List();
167
66ab8ab2 168 TTree *tree= (TTree*)inputHandler->GetTree();
169 TFile *file= (TFile*)tree->GetCurrentFile();
66ab8ab2 170 if (!file) {
171 AliError("Current file not found, cannot set reconstruction information");
172 return;
9bfecba8 173 } else {
174 TString fileName(file->GetName());
175 fPIDResponse->SetCurrentFile(fileName.Data());
66ab8ab2 176 }
9bfecba8 177
067f4c36 178 if ( (prodInfo.IsMC() == kFALSE) || (fIsMC == kFALSE) ) { // reco pass is needed only for data
9bfecba8 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 }
66ab8ab2 199 }
67ad8680 200
66ab8ab2 201}