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