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