]>
Commit | Line | Data |
---|---|---|
59697224 | 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$ */ | |
17 | ||
1598ba75 | 18 | //-------------------------------------------------------------------- |
19 | // Options for the TPC Reconstruction in rec.C | |
20 | // | |
21 | // 4 options can be set to change the input for TPC reconstruction | |
22 | // which overwrites the usage of fUseHLTClusters of the AliTPCRecoParam | |
23 | // | |
24 | // 1) useRAW - use RAW, if not present -> do nothing | |
25 | // 2) useRAWorHLT - use RAW, if not present -> use HLT clusters | |
26 | // 3) useHLT - use HLT clusters, if not present -> do nothing | |
27 | // 4) useHLTorRAW - use HLT clusters, if not present -> use RAW | |
28 | // | |
29 | // -> The current default is useHLTorRAW | |
30 | //-------------------------------------------------------------------- | |
31 | ||
59697224 | 32 | /////////////////////////////////////////////////////////////////////////////// |
33 | // // | |
34 | // class for TPC reconstruction // | |
35 | // // | |
36 | /////////////////////////////////////////////////////////////////////////////// | |
37 | ||
a7b1d798 | 38 | #include <TObject.h> |
39 | #include <TString.h> | |
40 | #include <TObjString.h> | |
41 | #include <TObjArray.h> | |
42 | #include <TFile.h> | |
59697224 | 43 | |
a7b1d798 | 44 | #include <AliLog.h> |
45 | #include <AliPID.h> | |
46 | #include <AliESDpid.h> | |
47 | #include <AliTPCPIDResponse.h> | |
59697224 | 48 | #include "AliTPCReconstructor.h" |
49 | #include "AliRunLoader.h" | |
50 | #include "AliRun.h" | |
38e6e547 | 51 | #include "AliRawReader.h" |
829455ad | 52 | #include "AliTPCclusterer.h" |
53 | #include "AliTPCtracker.h" | |
4fb6310b | 54 | #include "AliTPCParam.h" |
90c7886e | 55 | #include "AliTPCParamSR.h" |
3d37b790 | 56 | #include "AliTPCcalibDB.h" |
7bab76cf | 57 | #include "AliTracker.h" |
58 | #include "AliMagF.h" | |
f1887eb6 | 59 | #include "TTreeStream.h" |
59697224 | 60 | |
61 | ClassImp(AliTPCReconstructor) | |
62 | ||
194b0609 | 63 | |
f1887eb6 | 64 | Int_t AliTPCReconstructor::fgStreamLevel = 0; // stream (debug) level |
e2a1f213 | 65 | AliTPCAltroEmulator * AliTPCReconstructor::fAltroEmulator=0; // ALTRO emulator |
f1887eb6 | 66 | TTreeSRedirector * AliTPCReconstructor::fgDebugStreamer=0; // NOTE - AliTPCReconstructor is not an owner of the streamer |
194b0609 | 67 | |
f1887eb6 | 68 | |
3464c690 | 69 | AliTPCReconstructor::AliTPCReconstructor(): |
70 | AliReconstructor(), | |
3deecc7e | 71 | fClusterer(NULL), |
72 | fArrSplines(NULL) | |
3464c690 | 73 | { |
194b0609 | 74 | // |
75 | // default constructor | |
76 | // | |
7a9e557b | 77 | // |
78 | // | |
7bab76cf | 79 | AliTPCcalibDB * calib = AliTPCcalibDB::Instance(); |
745b6db9 | 80 | const AliMagF * field = (AliMagF*)TGeoGlobalMagField::Instance()->GetField(); |
0a997b33 | 81 | calib->SetExBField(field); |
3464c690 | 82 | AliTPCParam* param = GetTPCParam(); |
83 | if (!param) { | |
84 | AliWarning("Loading default TPC parameters !"); | |
85 | param = new AliTPCParamSR; | |
86 | } | |
829455ad | 87 | fClusterer = new AliTPCclusterer(param); |
194b0609 | 88 | } |
89 | ||
0ffd2ae1 | 90 | AliTPCReconstructor::AliTPCReconstructor(const AliTPCReconstructor& /*rec*/): |
91 | AliReconstructor(), | |
3deecc7e | 92 | fClusterer(NULL), |
93 | fArrSplines(NULL) | |
0ffd2ae1 | 94 | { |
95 | // | |
96 | // Dummy copu constructor | |
97 | // | |
98 | } | |
99 | ||
100 | AliTPCReconstructor& AliTPCReconstructor::operator=(const AliTPCReconstructor&){ | |
101 | // | |
102 | // dummy operator | |
103 | // | |
104 | return *this; | |
105 | } | |
106 | ||
3464c690 | 107 | //_____________________________________________________________________________ |
108 | AliTPCReconstructor::~AliTPCReconstructor() | |
109 | { | |
3464c690 | 110 | if (fClusterer) delete fClusterer; |
3deecc7e | 111 | delete fArrSplines; |
b1e5634c | 112 | delete AliTPCcalibDB::Instance(); |
3464c690 | 113 | } |
194b0609 | 114 | |
3464c690 | 115 | //_____________________________________________________________________________ |
116 | void AliTPCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const { | |
117 | // single event local reconstruction | |
118 | // of TPC data | |
119 | fClusterer->SetInput(digitsTree); | |
120 | fClusterer->SetOutput(clustersTree); | |
121 | fClusterer->Digits2Clusters(); | |
122 | } | |
123 | ||
59697224 | 124 | //_____________________________________________________________________________ |
3464c690 | 125 | void AliTPCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const { |
126 | // single event local reconstruction | |
127 | // of TPC data starting from raw data | |
3464c690 | 128 | |
129 | fClusterer->SetOutput(clustersTree); | |
130 | fClusterer->Digits2Clusters(rawReader); | |
131 | } | |
132 | ||
133 | //_____________________________________________________________________________ | |
d76c31f4 | 134 | AliTracker* AliTPCReconstructor::CreateTracker() const |
59697224 | 135 | { |
136 | // create a TPC tracker | |
137 | ||
3464c690 | 138 | AliTPCParam* param = GetTPCParam(); |
90c7886e | 139 | if (!param) { |
140 | AliWarning("Loading default TPC parameters !"); | |
141 | param = new AliTPCParamSR; | |
142 | } | |
4fb6310b | 143 | param->ReadGeoMatrices(); |
1598ba75 | 144 | |
829455ad | 145 | AliTPCtracker* tracker = new AliTPCtracker(param); |
1598ba75 | 146 | |
147 | ParseOptions(tracker); | |
148 | ||
149 | return tracker; | |
59697224 | 150 | } |
151 | ||
152 | //_____________________________________________________________________________ | |
d76c31f4 | 153 | void AliTPCReconstructor::FillESD(TTree */*digitsTree*/, TTree */*clustersTree*/, |
937a076a | 154 | AliESDEvent* /*esd*/) const |
59697224 | 155 | { |
156 | // make PID | |
10d100d4 | 157 | /* Now done in AliESDpid |
83afd539 | 158 | Double_t parTPC[] = {50., 0.07, 5.}; // MIP nnormalized to channel 50 -MI |
59697224 | 159 | AliTPCpidESD tpcPID(parTPC); |
160 | tpcPID.MakePID(esd); | |
10d100d4 | 161 | */ |
59697224 | 162 | } |
163 | ||
164 | ||
165 | //_____________________________________________________________________________ | |
3464c690 | 166 | AliTPCParam* AliTPCReconstructor::GetTPCParam() const |
59697224 | 167 | { |
168 | // get the TPC parameters | |
169 | ||
3464c690 | 170 | AliTPCParam* param = AliTPCcalibDB::Instance()->GetParameters(); |
3d37b790 | 171 | |
6d75e4b6 | 172 | return param; |
59697224 | 173 | } |
1598ba75 | 174 | |
a7b1d798 | 175 | //_____________________________________________________________________________ |
176 | void AliTPCReconstructor::SetSplinesFromOADB(const char* tmplt, AliESDpid *esdPID) | |
177 | { | |
178 | // | |
179 | // load splines from the OADB using 'template' | |
180 | // | |
181 | ||
3deecc7e | 182 | // only load splines if not already set |
183 | if (!fArrSplines) { | |
184 | fArrSplines=new TObjArray(Int_t(AliPID::kSPECIES)); | |
185 | fArrSplines->SetOwner(); | |
186 | TString stemplate(tmplt); | |
187 | ||
188 | TString fileNamePIDresponse("$ALICE_ROOT/OADB/COMMON/PID/data/TPCPIDResponse.root"); | |
189 | TFile f(fileNamePIDresponse.Data()); | |
190 | ||
191 | TObjArray *arrPidResponseMaster=0x0; | |
192 | ||
193 | if (f.IsOpen() && !f.IsZombie()){ | |
194 | arrPidResponseMaster=dynamic_cast<TObjArray*>(f.Get("TPCPIDResponse")); | |
195 | } | |
196 | f.Close(); | |
197 | ||
198 | if (!arrPidResponseMaster){ | |
199 | AliError("PID response array not found, cannot assign proper splines"); | |
200 | return; | |
201 | } | |
202 | ||
203 | for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec) | |
204 | { | |
205 | Int_t ispec2=ispec; | |
206 | if (ispec==Int_t(AliPID::kMuon)) ispec2=Int_t(AliPID::kPion); | |
207 | ||
208 | TString particle=AliPID::ParticleName(ispec2); | |
209 | particle.ToUpper(); | |
210 | ||
211 | TString splineName; | |
212 | splineName.Form(stemplate.Data(),particle.Data()); | |
213 | TObject *spline=arrPidResponseMaster->FindObject(splineName.Data()); | |
214 | if (!spline) { | |
215 | AliError(Form("No spline found for '%s'", splineName.Data())); | |
216 | continue; | |
217 | }; | |
218 | AliInfo(Form("Adding Response function %d:%s",ispec,splineName.Data())); | |
219 | fArrSplines->AddAt(spline->Clone(), ispec); | |
220 | } | |
221 | arrPidResponseMaster->Delete(); | |
222 | delete arrPidResponseMaster; | |
223 | if (fArrSplines->GetEntries()!=Int_t(AliPID::kSPECIES)) { | |
224 | AliError("Splines not found for all species, cannot use proper PID"); | |
225 | delete fArrSplines; | |
226 | fArrSplines=NULL; | |
227 | return; | |
228 | } | |
a7b1d798 | 229 | } |
230 | ||
a7b1d798 | 231 | for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec) |
232 | { | |
3deecc7e | 233 | esdPID->GetTPCResponse().SetResponseFunction( (AliPID::EParticleType)ispec, fArrSplines->UncheckedAt(ispec) ); |
a7b1d798 | 234 | } |
235 | ||
3deecc7e | 236 | esdPID->GetTPCResponse().SetUseDatabase(kTRUE); |
a7b1d798 | 237 | } |
238 | ||
239 | //_____________________________________________________________________________ | |
240 | void AliTPCReconstructor::GetPidSettings(AliESDpid *esdPID) | |
241 | { | |
242 | // | |
243 | // Get TPC pid splines. They should be written to the OCDB during the CPass | |
244 | // the splines themselves are owned by the OCDB object | |
245 | // | |
246 | ||
247 | // parse options | |
248 | TString allopt(GetOption()); | |
249 | TObjArray *optArray=allopt.Tokenize(";"); | |
250 | ||
4e087e75 | 251 | // defines whether the pid was set via a specific option in the rec.C |
252 | Bool_t pidSetInOptions = kFALSE; | |
253 | ||
a7b1d798 | 254 | for (Int_t iopt=0; iopt<optArray->GetEntriesFast(); ++iopt){ |
255 | if (!optArray->At(iopt)) continue; | |
256 | TString option(static_cast<TObjString*>(optArray->At(iopt))->GetString().Strip(TString::kBoth,' ')); | |
257 | ||
258 | if (!option.BeginsWith("PID.")) continue; | |
259 | ||
260 | // remove 'PID.' identifyer | |
261 | option.Remove(0,4); | |
262 | ||
263 | // parse PID type | |
264 | if (option.BeginsWith("Static=")){ | |
265 | option.Remove(0,option.First('=')+1); | |
266 | if (option.Contains("LHC13b2_fix_PID")) { | |
267 | esdPID->GetTPCResponse().SetBetheBlochParameters(0.0320981, 19.9768, 2.52666e-16, 2.72123, 6.08092); | |
268 | esdPID->GetTPCResponse().SetMip(53.4968); | |
4e087e75 | 269 | pidSetInOptions=kTRUE; |
a7b1d798 | 270 | } |
271 | ||
272 | } else if (option.BeginsWith("OADB=")) { | |
273 | option.Remove(0,option.First('=')+1); | |
274 | AliInfo(Form("Setting splines From OADB using template: '%s'",option.Data())); | |
275 | SetSplinesFromOADB(option, esdPID); | |
4e087e75 | 276 | pidSetInOptions=kTRUE; |
a7b1d798 | 277 | } else if (option.BeginsWith("OCDB=")){ |
278 | option.Remove(0,option.First('=')+1); | |
279 | // not yet implemented | |
280 | } | |
281 | ||
282 | } | |
283 | ||
284 | delete optArray; | |
285 | ||
4e087e75 | 286 | // |
287 | // Initialisation of BB parameters from the OCDB. | |
288 | // They are stored in the AliTPCParam | |
289 | // | |
290 | if (!pidSetInOptions) { | |
291 | AliTPCParam* param = AliTPCcalibDB::Instance()->GetParameters(); | |
292 | if (param) { | |
293 | TVectorD *paramBB=param->GetBetheBlochParameters(); | |
294 | if (paramBB){ | |
295 | esdPID->GetTPCResponse().SetBetheBlochParameters((*paramBB)(0),(*paramBB)(1),(*paramBB)(2),(*paramBB)(3),(*paramBB)(4)); | |
296 | AliInfo(Form("Setting BB parameters from OCDB (AliTPCParam): %.2g, %.2g, %.2g, %.2g, %.2g", | |
297 | (*paramBB)(0),(*paramBB)(1),(*paramBB)(2),(*paramBB)(3),(*paramBB)(4))); | |
298 | } else { | |
299 | AliError("Couldn't get BB parameters from OCDB, the old default values will be used instead"); | |
300 | } | |
301 | } else { | |
302 | AliError("Couldn't get TPC parameters"); | |
303 | } | |
304 | } | |
305 | ||
a7b1d798 | 306 | /* |
307 | AliTPCcalibDB * calib = AliTPCcalibDB::Instance(); | |
308 | ||
309 | //Get pid splines array | |
310 | TObjArray *arrSplines=calib->GetPidResponse(); | |
311 | if (!arrSplines) return; | |
312 | AliTPCPIDResponse &tpcPID=esdPID->GetTPCResponse(); | |
313 | tpcPID.SetUseDatabase(kTRUE); | |
314 | ||
315 | // check if parametrisations are already set. | |
316 | // since this is uniq for one run, we don't have to reload them | |
317 | if (tpcPID.GetResponseFunction(AliPID::kPion)) return; | |
318 | ||
319 | // get the default object | |
320 | TObject *defaultPID=arrSplines->At(AliPID::kUnknown); | |
321 | ||
322 | // loop over all particle species and set the response functions | |
323 | for (Int_t ispec=0; ispec<AliPID::kUnknown; ++ispec){ | |
324 | TObject *pidSpline=arrSplines->At(ispec); | |
325 | if (!pidSpline) pidSpline=defaultPID; | |
326 | tpcPID.SetResponseFunction((AliPID::EParticleType)ispec,pidSpline); | |
327 | } | |
328 | */ | |
329 | } | |
1598ba75 | 330 | |
331 | //_____________________________________________________________________________ | |
829455ad | 332 | void AliTPCReconstructor::ParseOptions( AliTPCtracker* tracker ) const |
1598ba75 | 333 | { |
334 | // parse options from rec.C and set in clusterer and tracker | |
335 | ||
336 | TString option = GetOption(); | |
337 | ||
338 | Int_t useHLTClusters = 3; | |
339 | ||
340 | if (option.Contains("use")) { | |
341 | ||
342 | AliInfo(Form("Overide TPC RecoParam with option %s",option.Data())); | |
343 | ||
c08dc6e5 | 344 | if (option.Contains("useRAW")) { |
1598ba75 | 345 | useHLTClusters = 1; |
c08dc6e5 | 346 | if (option.Contains("useRAWorHLT")) |
347 | useHLTClusters = 2; | |
348 | } | |
349 | else if (option.Contains("useHLT")) { | |
1598ba75 | 350 | useHLTClusters = 3; |
c08dc6e5 | 351 | if (option.Contains("useHLTorRAW")) |
352 | useHLTClusters = 4; | |
353 | } | |
1598ba75 | 354 | } |
355 | else { | |
356 | const AliTPCRecoParam* param = GetRecoParam(); | |
357 | useHLTClusters = param->GetUseHLTClusters(); | |
358 | } | |
359 | ||
360 | AliInfo(Form("Usage of HLT clusters in TPC reconstruction : %d", useHLTClusters)); | |
361 | ||
362 | fClusterer->SetUseHLTClusters(useHLTClusters); | |
363 | tracker->SetUseHLTClusters(useHLTClusters); | |
364 | ||
365 | return; | |
366 | } |