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