]>
Commit | Line | Data |
---|---|---|
596a855f | 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 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // class for running the reconstruction // | |
21 | // // | |
22 | // Clusters and tracks are created for all detectors and all events by // | |
23 | // typing: // | |
24 | // // | |
25 | // AliReconstruction rec; // | |
26 | // rec.Run(); // | |
27 | // // | |
28 | // The Run method returns kTRUE in case of successful execution. // | |
c71de921 | 29 | // // |
30 | // If the input to the reconstruction are not simulated digits but raw data, // | |
31 | // this can be specified by an argument of the Run method or by the method // | |
32 | // // | |
33 | // rec.SetInput("..."); // | |
34 | // // | |
35 | // The input formats and the corresponding argument are: // | |
36 | // - DDL raw data files: directory name, ends with "/" // | |
37 | // - raw data root file: root file name, extension ".root" // | |
38 | // - raw data DATE file: DATE file name, any other non-empty string // | |
39 | // - MC root files : empty string, default // | |
40 | // // | |
b26c3770 | 41 | // By default all events are reconstructed. The reconstruction can be // |
42 | // limited to a range of events by giving the index of the first and the // | |
43 | // last event as an argument to the Run method or by calling // | |
44 | // // | |
45 | // rec.SetEventRange(..., ...); // | |
46 | // // | |
47 | // The index -1 (default) can be used for the last event to indicate no // | |
48 | // upper limit of the event range. // | |
49 | // // | |
973388c2 | 50 | // In case of raw-data reconstruction the user can modify the default // |
51 | // number of events per digits/clusters/tracks file. In case the option // | |
52 | // is not used the number is set 1. In case the user provides 0, than // | |
53 | // the number of events is equal to the number of events inside the // | |
54 | // raw-data file (i.e. one digits/clusters/tracks file): // | |
55 | // // | |
56 | // rec.SetNumberOfEventsPerFile(...); // | |
57 | // // | |
58 | // // | |
596a855f | 59 | // The name of the galice file can be changed from the default // |
e583c30d | 60 | // "galice.root" by passing it as argument to the AliReconstruction // |
61 | // constructor or by // | |
596a855f | 62 | // // |
63 | // rec.SetGAliceFile("..."); // | |
64 | // // | |
59697224 | 65 | // The local reconstruction can be switched on or off for individual // |
66 | // detectors by // | |
596a855f | 67 | // // |
59697224 | 68 | // rec.SetRunLocalReconstruction("..."); // |
596a855f | 69 | // // |
70 | // The argument is a (case sensitive) string with the names of the // | |
71 | // detectors separated by a space. The special string "ALL" selects all // | |
72 | // available detectors. This is the default. // | |
73 | // // | |
c71de921 | 74 | // The reconstruction of the primary vertex position can be switched off by // |
75 | // // | |
76 | // rec.SetRunVertexFinder(kFALSE); // | |
77 | // // | |
b8cd5251 | 78 | // The tracking and the creation of ESD tracks can be switched on for // |
79 | // selected detectors by // | |
596a855f | 80 | // // |
b8cd5251 | 81 | // rec.SetRunTracking("..."); // |
596a855f | 82 | // // |
c84a5e9e | 83 | // Uniform/nonuniform field tracking switches (default: uniform field) // |
84 | // // | |
1d99986f | 85 | // rec.SetUniformFieldTracking(); ( rec.SetUniformFieldTracking(kFALSE); ) // |
c84a5e9e | 86 | // // |
596a855f | 87 | // The filling of additional ESD information can be steered by // |
88 | // // | |
89 | // rec.SetFillESD("..."); // | |
90 | // // | |
b8cd5251 | 91 | // Again, for both methods the string specifies the list of detectors. // |
92 | // The default is "ALL". // | |
93 | // // | |
94 | // The call of the shortcut method // | |
95 | // // | |
96 | // rec.SetRunReconstruction("..."); // | |
97 | // // | |
98 | // is equivalent to calling SetRunLocalReconstruction, SetRunTracking and // | |
99 | // SetFillESD with the same detector selecting string as argument. // | |
596a855f | 100 | // // |
c71de921 | 101 | // The reconstruction requires digits or raw data as input. For the creation // |
102 | // of digits and raw data have a look at the class AliSimulation. // | |
596a855f | 103 | // // |
24f7a148 | 104 | // For debug purposes the method SetCheckPointLevel can be used. If the // |
105 | // argument is greater than 0, files with ESD events will be written after // | |
106 | // selected steps of the reconstruction for each event: // | |
107 | // level 1: after tracking and after filling of ESD (final) // | |
108 | // level 2: in addition after each tracking step // | |
109 | // level 3: in addition after the filling of ESD for each detector // | |
110 | // If a final check point file exists for an event, this event will be // | |
111 | // skipped in the reconstruction. The tracking and the filling of ESD for // | |
112 | // a detector will be skipped as well, if the corresponding check point // | |
113 | // file exists. The ESD event will then be loaded from the file instead. // | |
114 | // // | |
596a855f | 115 | /////////////////////////////////////////////////////////////////////////////// |
116 | ||
024a7e64 | 117 | #include <TArrayF.h> |
118 | #include <TFile.h> | |
119 | #include <TSystem.h> | |
120 | #include <TROOT.h> | |
121 | #include <TPluginManager.h> | |
3103d196 | 122 | #include <TGeoManager.h> |
2bdb9d38 | 123 | #include <TLorentzVector.h> |
596a855f | 124 | |
125 | #include "AliReconstruction.h" | |
87932dab | 126 | #include "AliCodeTimer.h" |
b8cd5251 | 127 | #include "AliReconstructor.h" |
815c2b38 | 128 | #include "AliLog.h" |
596a855f | 129 | #include "AliRunLoader.h" |
130 | #include "AliRun.h" | |
b649205a | 131 | #include "AliRawReaderFile.h" |
132 | #include "AliRawReaderDate.h" | |
133 | #include "AliRawReaderRoot.h" | |
001397cd | 134 | #include "AliRawEventHeaderBase.h" |
af885e0f | 135 | #include "AliESDEvent.h" |
faffd83e | 136 | #include "AliESDMuonTrack.h" |
1d99986f | 137 | #include "AliESDfriend.h" |
2257f27e | 138 | #include "AliESDVertex.h" |
faffd83e | 139 | #include "AliESDcascade.h" |
140 | #include "AliESDkink.h" | |
141 | #include "AliESDtrack.h" | |
142 | #include "AliESDCaloCluster.h" | |
32e449be | 143 | #include "AliMultiplicity.h" |
c84a5e9e | 144 | #include "AliTracker.h" |
2257f27e | 145 | #include "AliVertexer.h" |
c5e3e5d1 | 146 | #include "AliVertexerTracks.h" |
5e4ff34d | 147 | #include "AliV0vertexer.h" |
148 | #include "AliCascadeVertexer.h" | |
596a855f | 149 | #include "AliHeader.h" |
150 | #include "AliGenEventHeader.h" | |
b26c3770 | 151 | #include "AliPID.h" |
596a855f | 152 | #include "AliESDpid.h" |
ff8bb5ae | 153 | #include "AliESDtrack.h" |
f3a97c86 | 154 | |
08e1a23e | 155 | #include "AliESDTagCreator.h" |
a1069ee1 | 156 | #include "AliAODTagCreator.h" |
f3a97c86 | 157 | |
25be1e5c | 158 | #include "AliGeomManager.h" |
98937d93 | 159 | #include "AliTrackPointArray.h" |
b0314964 | 160 | #include "AliCDBManager.h" |
6bae477a | 161 | #include "AliCDBEntry.h" |
162 | #include "AliAlignObj.h" | |
f3a97c86 | 163 | |
b647652d | 164 | #include "AliCentralTrigger.h" |
165 | #include "AliCTPRawStream.h" | |
166 | ||
f29f1726 | 167 | #include "AliAODEvent.h" |
168 | #include "AliAODHeader.h" | |
169 | #include "AliAODTrack.h" | |
170 | #include "AliAODVertex.h" | |
171 | #include "AliAODCluster.h" | |
172 | ||
a5fa6165 | 173 | #include "AliQualAssDataMaker.h" |
f29f1726 | 174 | |
596a855f | 175 | ClassImp(AliReconstruction) |
176 | ||
177 | ||
c757bafd | 178 | //_____________________________________________________________________________ |
b384f8a4 | 179 | const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"}; |
c757bafd | 180 | |
596a855f | 181 | //_____________________________________________________________________________ |
024cf675 | 182 | AliReconstruction::AliReconstruction(const char* gAliceFilename, const char* cdbUri, |
e583c30d | 183 | const char* name, const char* title) : |
184 | TNamed(name, title), | |
185 | ||
c84a5e9e | 186 | fUniformField(kTRUE), |
2257f27e | 187 | fRunVertexFinder(kTRUE), |
1f46a9ae | 188 | fRunHLTTracking(kFALSE), |
e66fbafb | 189 | fRunMuonTracking(kFALSE), |
1d99986f | 190 | fStopOnError(kFALSE), |
191 | fWriteAlignmentData(kFALSE), | |
d64bd07d | 192 | fCleanESD(kTRUE), |
1d99986f | 193 | fWriteESDfriend(kFALSE), |
a7807689 | 194 | fWriteAOD(kFALSE), |
b647652d | 195 | fFillTriggerESD(kTRUE), |
1d99986f | 196 | |
197 | fRunLocalReconstruction("ALL"), | |
b8cd5251 | 198 | fRunTracking("ALL"), |
e583c30d | 199 | fFillESD("ALL"), |
200 | fGAliceFileName(gAliceFilename), | |
b649205a | 201 | fInput(""), |
35042093 | 202 | fEquipIdMap(""), |
b26c3770 | 203 | fFirstEvent(0), |
204 | fLastEvent(-1), | |
973388c2 | 205 | fNumberOfEventsPerFile(1), |
24f7a148 | 206 | fCheckPointLevel(0), |
b8cd5251 | 207 | fOptions(), |
6bae477a | 208 | fLoadAlignFromCDB(kTRUE), |
209 | fLoadAlignData("ALL"), | |
46698ae4 | 210 | fESDPar(""), |
e583c30d | 211 | |
212 | fRunLoader(NULL), | |
b649205a | 213 | fRawReader(NULL), |
b8cd5251 | 214 | |
98937d93 | 215 | fVertexer(NULL), |
9178838a | 216 | fDiamondProfile(NULL), |
98937d93 | 217 | |
6bae477a | 218 | fAlignObjArray(NULL), |
ec92bee0 | 219 | fCDBUri(cdbUri), |
00aa02d5 | 220 | fRemoteCDBUri(""), |
ec92bee0 | 221 | fSpecCDBUri() |
596a855f | 222 | { |
223 | // create reconstruction object with default parameters | |
b8cd5251 | 224 | |
225 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
226 | fReconstructor[iDet] = NULL; | |
227 | fLoader[iDet] = NULL; | |
228 | fTracker[iDet] = NULL; | |
d101408a | 229 | fQualAssDataMaker[iDet] = NULL; |
b8cd5251 | 230 | } |
e47c4c2e | 231 | AliPID pid; |
596a855f | 232 | } |
233 | ||
234 | //_____________________________________________________________________________ | |
235 | AliReconstruction::AliReconstruction(const AliReconstruction& rec) : | |
e583c30d | 236 | TNamed(rec), |
237 | ||
c84a5e9e | 238 | fUniformField(rec.fUniformField), |
2257f27e | 239 | fRunVertexFinder(rec.fRunVertexFinder), |
1f46a9ae | 240 | fRunHLTTracking(rec.fRunHLTTracking), |
e66fbafb | 241 | fRunMuonTracking(rec.fRunMuonTracking), |
1d99986f | 242 | fStopOnError(rec.fStopOnError), |
243 | fWriteAlignmentData(rec.fWriteAlignmentData), | |
d64bd07d | 244 | fCleanESD(rec.fCleanESD), |
1d99986f | 245 | fWriteESDfriend(rec.fWriteESDfriend), |
a7807689 | 246 | fWriteAOD(rec.fWriteAOD), |
b647652d | 247 | fFillTriggerESD(rec.fFillTriggerESD), |
1d99986f | 248 | |
249 | fRunLocalReconstruction(rec.fRunLocalReconstruction), | |
e583c30d | 250 | fRunTracking(rec.fRunTracking), |
251 | fFillESD(rec.fFillESD), | |
252 | fGAliceFileName(rec.fGAliceFileName), | |
b649205a | 253 | fInput(rec.fInput), |
35042093 | 254 | fEquipIdMap(rec.fEquipIdMap), |
b26c3770 | 255 | fFirstEvent(rec.fFirstEvent), |
256 | fLastEvent(rec.fLastEvent), | |
973388c2 | 257 | fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile), |
24f7a148 | 258 | fCheckPointLevel(0), |
b8cd5251 | 259 | fOptions(), |
6bae477a | 260 | fLoadAlignFromCDB(rec.fLoadAlignFromCDB), |
261 | fLoadAlignData(rec.fLoadAlignData), | |
46698ae4 | 262 | fESDPar(rec.fESDPar), |
e583c30d | 263 | |
264 | fRunLoader(NULL), | |
b649205a | 265 | fRawReader(NULL), |
b8cd5251 | 266 | |
98937d93 | 267 | fVertexer(NULL), |
9178838a | 268 | fDiamondProfile(NULL), |
98937d93 | 269 | |
6bae477a | 270 | fAlignObjArray(rec.fAlignObjArray), |
ec92bee0 | 271 | fCDBUri(rec.fCDBUri), |
00aa02d5 | 272 | fRemoteCDBUri(rec.fRemoteCDBUri), |
ec92bee0 | 273 | fSpecCDBUri() |
596a855f | 274 | { |
275 | // copy constructor | |
276 | ||
ec92bee0 | 277 | for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) { |
efd2085e | 278 | if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone()); |
279 | } | |
b8cd5251 | 280 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
281 | fReconstructor[iDet] = NULL; | |
282 | fLoader[iDet] = NULL; | |
283 | fTracker[iDet] = NULL; | |
d101408a | 284 | fQualAssDataMaker[iDet] = NULL; |
b8cd5251 | 285 | } |
ec92bee0 | 286 | for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) { |
287 | if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone()); | |
288 | } | |
596a855f | 289 | } |
290 | ||
291 | //_____________________________________________________________________________ | |
292 | AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec) | |
293 | { | |
294 | // assignment operator | |
295 | ||
296 | this->~AliReconstruction(); | |
297 | new(this) AliReconstruction(rec); | |
298 | return *this; | |
299 | } | |
300 | ||
301 | //_____________________________________________________________________________ | |
302 | AliReconstruction::~AliReconstruction() | |
303 | { | |
304 | // clean up | |
305 | ||
e583c30d | 306 | CleanUp(); |
efd2085e | 307 | fOptions.Delete(); |
ec92bee0 | 308 | fSpecCDBUri.Delete(); |
87932dab | 309 | |
310 | AliCodeTimer::Instance()->Print(); | |
596a855f | 311 | } |
312 | ||
024cf675 | 313 | //_____________________________________________________________________________ |
314 | void AliReconstruction::InitCDBStorage() | |
315 | { | |
316 | // activate a default CDB storage | |
317 | // First check if we have any CDB storage set, because it is used | |
318 | // to retrieve the calibration and alignment constants | |
319 | ||
320 | AliCDBManager* man = AliCDBManager::Instance(); | |
ec92bee0 | 321 | if (man->IsDefaultStorageSet()) |
024cf675 | 322 | { |
323 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
ec92bee0 | 324 | AliWarning("Default CDB storage has been already set !"); |
325 | AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data())); | |
024cf675 | 326 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
ec92bee0 | 327 | fCDBUri = ""; |
328 | } | |
329 | else { | |
b8ec52f6 | 330 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
331 | AliDebug(2, Form("Default CDB storage is set to: %s",fCDBUri.Data())); | |
332 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
ec92bee0 | 333 | man->SetDefaultStorage(fCDBUri); |
334 | } | |
335 | ||
00aa02d5 | 336 | // Remote storage (the Grid storage) is used if it is activated |
337 | // and if the object is not found in the default storage | |
338 | if (man->IsRemoteStorageSet()) | |
339 | { | |
340 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
341 | AliWarning("Remote CDB storage has been already set !"); | |
342 | AliWarning(Form("Ignoring the remote storage declared in AliReconstruction: %s",fRemoteCDBUri.Data())); | |
343 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
344 | fRemoteCDBUri = ""; | |
345 | } | |
346 | else { | |
347 | AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
348 | AliDebug(2, Form("Remote CDB storage is set to: %s",fRemoteCDBUri.Data())); | |
349 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
350 | man->SetRemoteStorage(fRemoteCDBUri); | |
351 | } | |
352 | ||
ec92bee0 | 353 | // Now activate the detector specific CDB storage locations |
c3a7b59a | 354 | for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) { |
355 | TObject* obj = fSpecCDBUri[i]; | |
356 | if (!obj) continue; | |
b8ec52f6 | 357 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
358 | AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle())); | |
359 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
c3a7b59a | 360 | man->SetSpecificStorage(obj->GetName(), obj->GetTitle()); |
ec92bee0 | 361 | } |
727d0766 | 362 | man->Print(); |
024cf675 | 363 | } |
364 | ||
365 | //_____________________________________________________________________________ | |
366 | void AliReconstruction::SetDefaultStorage(const char* uri) { | |
ec92bee0 | 367 | // Store the desired default CDB storage location |
368 | // Activate it later within the Run() method | |
024cf675 | 369 | |
ec92bee0 | 370 | fCDBUri = uri; |
024cf675 | 371 | |
372 | } | |
373 | ||
374 | //_____________________________________________________________________________ | |
00aa02d5 | 375 | void AliReconstruction::SetRemoteStorage(const char* uri) { |
376 | // Store the desired remote CDB storage location | |
377 | // Activate it later within the Run() method | |
378 | // Remote storage (the Grid storage) is used if it is activated | |
379 | // and if the object is not found in the default storage | |
380 | ||
381 | fRemoteCDBUri = uri; | |
382 | ||
383 | } | |
384 | ||
385 | //_____________________________________________________________________________ | |
c3a7b59a | 386 | void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) { |
ec92bee0 | 387 | // Store a detector-specific CDB storage location |
388 | // Activate it later within the Run() method | |
024cf675 | 389 | |
c3a7b59a | 390 | AliCDBPath aPath(calibType); |
391 | if(!aPath.IsValid()){ | |
392 | // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path | |
393 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
394 | if(!strcmp(calibType, fgkDetectorName[iDet])) { | |
395 | aPath.SetPath(Form("%s/*", calibType)); | |
396 | AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data())); | |
397 | break; | |
398 | } | |
399 | } | |
400 | if(!aPath.IsValid()){ | |
401 | AliError(Form("Not a valid path or detector: %s", calibType)); | |
402 | return; | |
403 | } | |
404 | } | |
405 | ||
53dd3c3d | 406 | // // check that calibType refers to a "valid" detector name |
407 | // Bool_t isDetector = kFALSE; | |
408 | // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
409 | // TString detName = fgkDetectorName[iDet]; | |
410 | // if(aPath.GetLevel0() == detName) { | |
411 | // isDetector = kTRUE; | |
412 | // break; | |
413 | // } | |
414 | // } | |
415 | // | |
416 | // if(!isDetector) { | |
417 | // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data())); | |
418 | // return; | |
419 | // } | |
c3a7b59a | 420 | |
421 | TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data()); | |
ec92bee0 | 422 | if (obj) fSpecCDBUri.Remove(obj); |
c3a7b59a | 423 | fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri)); |
024cf675 | 424 | |
425 | } | |
426 | ||
46698ae4 | 427 | |
428 | ||
429 | ||
6bae477a | 430 | //_____________________________________________________________________________ |
431 | Bool_t AliReconstruction::SetRunNumber() | |
432 | { | |
433 | // The method is called in Run() in order | |
434 | // to set a correct run number. | |
435 | // In case of raw data reconstruction the | |
436 | // run number is taken from the raw data header | |
437 | ||
438 | if(AliCDBManager::Instance()->GetRun() < 0) { | |
439 | if (!fRunLoader) { | |
440 | AliError("No run loader is found !"); | |
441 | return kFALSE; | |
442 | } | |
443 | // read run number from gAlice | |
ec92bee0 | 444 | if(fRunLoader->GetAliRun()) |
445 | AliCDBManager::Instance()->SetRun(fRunLoader->GetAliRun()->GetRunNumber()); | |
446 | else { | |
447 | if(fRawReader) { | |
448 | if(fRawReader->NextEvent()) { | |
449 | AliCDBManager::Instance()->SetRun(fRawReader->GetRunNumber()); | |
450 | fRawReader->RewindEvents(); | |
451 | } | |
452 | else { | |
453 | AliError("No raw-data events found !"); | |
454 | return kFALSE; | |
455 | } | |
456 | } | |
457 | else { | |
458 | AliError("Neither gAlice nor RawReader objects are found !"); | |
459 | return kFALSE; | |
460 | } | |
461 | } | |
462 | AliInfo(Form("CDB Run number: %d",AliCDBManager::Instance()->GetRun())); | |
6bae477a | 463 | } |
464 | return kTRUE; | |
465 | } | |
466 | ||
6bae477a | 467 | //_____________________________________________________________________________ |
468 | Bool_t AliReconstruction::MisalignGeometry(const TString& detectors) | |
469 | { | |
470 | // Read the alignment objects from CDB. | |
471 | // Each detector is supposed to have the | |
472 | // alignment objects in DET/Align/Data CDB path. | |
473 | // All the detector objects are then collected, | |
474 | // sorted by geometry level (starting from ALIC) and | |
475 | // then applied to the TGeo geometry. | |
476 | // Finally an overlaps check is performed. | |
477 | ||
478 | // Load alignment data from CDB and fill fAlignObjArray | |
479 | if(fLoadAlignFromCDB){ | |
6bae477a | 480 | |
25be1e5c | 481 | TString detStr = detectors; |
482 | TString loadAlObjsListOfDets = ""; | |
483 | ||
484 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
485 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
486 | loadAlObjsListOfDets += fgkDetectorName[iDet]; | |
487 | loadAlObjsListOfDets += " "; | |
488 | } // end loop over detectors | |
53dd3c3d | 489 | loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules |
98e303d9 | 490 | AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data()); |
25be1e5c | 491 | }else{ |
492 | // Check if the array with alignment objects was | |
493 | // provided by the user. If yes, apply the objects | |
494 | // to the present TGeo geometry | |
495 | if (fAlignObjArray) { | |
496 | if (gGeoManager && gGeoManager->IsClosed()) { | |
98e303d9 | 497 | if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) { |
25be1e5c | 498 | AliError("The misalignment of one or more volumes failed!" |
499 | "Compare the list of simulated detectors and the list of detector alignment data!"); | |
500 | return kFALSE; | |
501 | } | |
502 | } | |
503 | else { | |
504 | AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!"); | |
6bae477a | 505 | return kFALSE; |
506 | } | |
507 | } | |
6bae477a | 508 | } |
25be1e5c | 509 | |
8e245d15 | 510 | delete fAlignObjArray; fAlignObjArray=0; |
a03b0371 | 511 | |
6bae477a | 512 | return kTRUE; |
513 | } | |
596a855f | 514 | |
515 | //_____________________________________________________________________________ | |
516 | void AliReconstruction::SetGAliceFile(const char* fileName) | |
517 | { | |
518 | // set the name of the galice file | |
519 | ||
520 | fGAliceFileName = fileName; | |
521 | } | |
522 | ||
efd2085e | 523 | //_____________________________________________________________________________ |
524 | void AliReconstruction::SetOption(const char* detector, const char* option) | |
525 | { | |
526 | // set options for the reconstruction of a detector | |
527 | ||
528 | TObject* obj = fOptions.FindObject(detector); | |
529 | if (obj) fOptions.Remove(obj); | |
530 | fOptions.Add(new TNamed(detector, option)); | |
531 | } | |
532 | ||
596a855f | 533 | |
534 | //_____________________________________________________________________________ | |
4a33489c | 535 | Bool_t AliReconstruction::Run(const char* input) |
596a855f | 536 | { |
537 | // run the reconstruction | |
538 | ||
87932dab | 539 | AliCodeTimerAuto("") |
540 | ||
b649205a | 541 | // set the input |
542 | if (!input) input = fInput.Data(); | |
543 | TString fileName(input); | |
544 | if (fileName.EndsWith("/")) { | |
545 | fRawReader = new AliRawReaderFile(fileName); | |
546 | } else if (fileName.EndsWith(".root")) { | |
547 | fRawReader = new AliRawReaderRoot(fileName); | |
548 | } else if (!fileName.IsNull()) { | |
549 | fRawReader = new AliRawReaderDate(fileName); | |
550 | fRawReader->SelectEvents(7); | |
551 | } | |
35042093 | 552 | if (!fEquipIdMap.IsNull() && fRawReader) |
553 | fRawReader->LoadEquipmentIdsMap(fEquipIdMap); | |
554 | ||
b649205a | 555 | |
f08fc9f5 | 556 | // get the run loader |
557 | if (!InitRunLoader()) return kFALSE; | |
596a855f | 558 | |
ec92bee0 | 559 | // Initialize the CDB storage |
560 | InitCDBStorage(); | |
561 | ||
6bae477a | 562 | // Set run number in CDBManager (if it is not already set by the user) |
563 | if (!SetRunNumber()) if (fStopOnError) return kFALSE; | |
564 | ||
565 | // Import ideal TGeo geometry and apply misalignment | |
566 | if (!gGeoManager) { | |
567 | TString geom(gSystem->DirName(fGAliceFileName)); | |
568 | geom += "/geometry.root"; | |
98e303d9 | 569 | AliGeomManager::LoadGeometry(geom.Data()); |
6bae477a | 570 | if (!gGeoManager) if (fStopOnError) return kFALSE; |
571 | } | |
8e245d15 | 572 | |
573 | AliCDBManager* man = AliCDBManager::Instance(); | |
6bae477a | 574 | if (!MisalignGeometry(fLoadAlignData)) if (fStopOnError) return kFALSE; |
575 | ||
596a855f | 576 | // local reconstruction |
59697224 | 577 | if (!fRunLocalReconstruction.IsNull()) { |
578 | if (!RunLocalReconstruction(fRunLocalReconstruction)) { | |
e583c30d | 579 | if (fStopOnError) {CleanUp(); return kFALSE;} |
596a855f | 580 | } |
581 | } | |
b26c3770 | 582 | // if (!fRunVertexFinder && fRunTracking.IsNull() && |
583 | // fFillESD.IsNull()) return kTRUE; | |
2257f27e | 584 | |
585 | // get vertexer | |
586 | if (fRunVertexFinder && !CreateVertexer()) { | |
587 | if (fStopOnError) { | |
588 | CleanUp(); | |
589 | return kFALSE; | |
590 | } | |
591 | } | |
596a855f | 592 | |
f08fc9f5 | 593 | // get trackers |
b8cd5251 | 594 | if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) { |
24f7a148 | 595 | if (fStopOnError) { |
596 | CleanUp(); | |
597 | return kFALSE; | |
598 | } | |
596a855f | 599 | } |
24f7a148 | 600 | |
b26c3770 | 601 | // get the possibly already existing ESD file and tree |
af885e0f | 602 | AliESDEvent* esd = new AliESDEvent(); AliESDEvent* hltesd = new AliESDEvent(); |
b26c3770 | 603 | TFile* fileOld = NULL; |
1f46a9ae | 604 | TTree* treeOld = NULL; TTree *hlttreeOld = NULL; |
b26c3770 | 605 | if (!gSystem->AccessPathName("AliESDs.root")){ |
606 | gSystem->CopyFile("AliESDs.root", "AliESDs.old.root", kTRUE); | |
607 | fileOld = TFile::Open("AliESDs.old.root"); | |
608 | if (fileOld && fileOld->IsOpen()) { | |
609 | treeOld = (TTree*) fileOld->Get("esdTree"); | |
46698ae4 | 610 | if (treeOld)esd->ReadFromTree(treeOld); |
1f46a9ae | 611 | hlttreeOld = (TTree*) fileOld->Get("HLTesdTree"); |
46698ae4 | 612 | if (hlttreeOld) hltesd->ReadFromTree(hlttreeOld); |
b26c3770 | 613 | } |
614 | } | |
615 | ||
36711aa4 | 616 | // create the ESD output file and tree |
596a855f | 617 | TFile* file = TFile::Open("AliESDs.root", "RECREATE"); |
46698ae4 | 618 | file->SetCompressionLevel(2); |
596a855f | 619 | if (!file->IsOpen()) { |
815c2b38 | 620 | AliError("opening AliESDs.root failed"); |
b26c3770 | 621 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
596a855f | 622 | } |
46698ae4 | 623 | |
36711aa4 | 624 | TTree* tree = new TTree("esdTree", "Tree with ESD objects"); |
af885e0f | 625 | esd = new AliESDEvent(); |
46698ae4 | 626 | esd->CreateStdContent(); |
627 | esd->WriteToTree(tree); | |
628 | ||
1f46a9ae | 629 | TTree* hlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects"); |
af885e0f | 630 | hltesd = new AliESDEvent(); |
46698ae4 | 631 | hltesd->CreateStdContent(); |
632 | hltesd->WriteToTree(hlttree); | |
633 | ||
634 | /* CKB Why? | |
1f46a9ae | 635 | delete esd; delete hltesd; |
636 | esd = NULL; hltesd = NULL; | |
46698ae4 | 637 | */ |
500d54ab | 638 | // create the branch with ESD additions |
5728d3d5 | 639 | |
640 | ||
641 | ||
46698ae4 | 642 | AliESDfriend *esdf = 0; |
1d99986f | 643 | if (fWriteESDfriend) { |
46698ae4 | 644 | esdf = new AliESDfriend(); |
645 | TBranch *br=tree->Branch("ESDfriend.","AliESDfriend", &esdf); | |
646 | br->SetFile("AliESDfriends.root"); | |
647 | esd->AddObject(esdf); | |
1d99986f | 648 | } |
5728d3d5 | 649 | |
46698ae4 | 650 | |
17c86e90 | 651 | // Get the diamond profile from OCDB |
652 | AliCDBEntry* entry = AliCDBManager::Instance() | |
653 | ->Get("GRP/Calib/MeanVertex"); | |
654 | ||
655 | if(entry) { | |
656 | fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
657 | } else { | |
658 | AliError("No diamond profile found in OCDB!"); | |
659 | } | |
660 | ||
20e5681c | 661 | AliVertexerTracks tVertexer(AliTracker::GetBz()); |
9178838a | 662 | if(fDiamondProfile) tVertexer.SetVtxStart(fDiamondProfile); |
c5e3e5d1 | 663 | |
596a855f | 664 | // loop over events |
a5fa6165 | 665 | |
b649205a | 666 | if (fRawReader) fRawReader->RewindEvents(); |
a5fa6165 | 667 | TString detStr(fFillESD) ; |
668 | ||
669 | // initialises quality assurance for ESDs | |
670 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
671 | if (!IsSelected(fgkDetectorName[iDet], detStr)) | |
672 | continue; | |
673 | AliQualAssDataMaker * qadm = GetQualAssDataMaker(iDet); | |
674 | if (!qadm) | |
675 | continue; | |
676 | qadm->Init(AliQualAss::kESDS) ; | |
677 | } | |
f08fc9f5 | 678 | |
596a855f | 679 | for (Int_t iEvent = 0; iEvent < fRunLoader->GetNumberOfEvents(); iEvent++) { |
b26c3770 | 680 | if (fRawReader) fRawReader->NextEvent(); |
4a33489c | 681 | if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) { |
b26c3770 | 682 | // copy old ESD to the new one |
683 | if (treeOld) { | |
46698ae4 | 684 | esd->ReadFromTree(treeOld); |
b26c3770 | 685 | treeOld->GetEntry(iEvent); |
686 | } | |
687 | tree->Fill(); | |
1f46a9ae | 688 | if (hlttreeOld) { |
46698ae4 | 689 | esd->ReadFromTree(hlttreeOld); |
1f46a9ae | 690 | hlttreeOld->GetEntry(iEvent); |
691 | } | |
692 | hlttree->Fill(); | |
b26c3770 | 693 | continue; |
694 | } | |
46698ae4 | 695 | |
815c2b38 | 696 | AliInfo(Form("processing event %d", iEvent)); |
596a855f | 697 | fRunLoader->GetEvent(iEvent); |
24f7a148 | 698 | |
bb0901a4 | 699 | char aFileName[256]; |
700 | sprintf(aFileName, "ESD_%d.%d_final.root", | |
f08fc9f5 | 701 | fRunLoader->GetHeader()->GetRun(), |
702 | fRunLoader->GetHeader()->GetEventNrInRun()); | |
bb0901a4 | 703 | if (!gSystem->AccessPathName(aFileName)) continue; |
24f7a148 | 704 | |
b26c3770 | 705 | // local reconstruction |
706 | if (!fRunLocalReconstruction.IsNull()) { | |
707 | if (!RunLocalEventReconstruction(fRunLocalReconstruction)) { | |
708 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
709 | } | |
710 | } | |
711 | ||
46698ae4 | 712 | |
f08fc9f5 | 713 | esd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); |
1f46a9ae | 714 | hltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); |
31fd97b2 | 715 | esd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun()); |
716 | hltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun()); | |
46698ae4 | 717 | |
d6ee376f | 718 | // Set magnetic field from the tracker |
719 | esd->SetMagneticField(AliTracker::GetBz()); | |
720 | hltesd->SetMagneticField(AliTracker::GetBz()); | |
596a855f | 721 | |
46698ae4 | 722 | |
723 | ||
2e3550da | 724 | // Fill raw-data error log into the ESD |
725 | if (fRawReader) FillRawDataErrorLog(iEvent,esd); | |
726 | ||
2257f27e | 727 | // vertex finder |
728 | if (fRunVertexFinder) { | |
729 | if (!ReadESD(esd, "vertex")) { | |
730 | if (!RunVertexFinder(esd)) { | |
b26c3770 | 731 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
2257f27e | 732 | } |
733 | if (fCheckPointLevel > 0) WriteESD(esd, "vertex"); | |
734 | } | |
735 | } | |
736 | ||
1f46a9ae | 737 | // HLT tracking |
738 | if (!fRunTracking.IsNull()) { | |
739 | if (fRunHLTTracking) { | |
740 | hltesd->SetVertex(esd->GetVertex()); | |
741 | if (!RunHLTTracking(hltesd)) { | |
742 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
743 | } | |
744 | } | |
745 | } | |
746 | ||
e66fbafb | 747 | // Muon tracking |
b8cd5251 | 748 | if (!fRunTracking.IsNull()) { |
e66fbafb | 749 | if (fRunMuonTracking) { |
761350a6 | 750 | if (!RunMuonTracking(esd)) { |
b26c3770 | 751 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
24f7a148 | 752 | } |
596a855f | 753 | } |
754 | } | |
755 | ||
e66fbafb | 756 | // barrel tracking |
757 | if (!fRunTracking.IsNull()) { | |
21c573b7 | 758 | if (!ReadESD(esd, "tracking")) { |
759 | if (!RunTracking(esd)) { | |
760 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
e66fbafb | 761 | } |
21c573b7 | 762 | if (fCheckPointLevel > 0) WriteESD(esd, "tracking"); |
e66fbafb | 763 | } |
764 | } | |
21c573b7 | 765 | |
596a855f | 766 | // fill ESD |
767 | if (!fFillESD.IsNull()) { | |
768 | if (!FillESD(esd, fFillESD)) { | |
b26c3770 | 769 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
596a855f | 770 | } |
771 | } | |
a5fa6165 | 772 | |
773 | if (!fFillESD.IsNull()) | |
774 | RunQualAss(fFillESD.Data(), esd); | |
775 | ||
001397cd | 776 | // fill Event header information from the RawEventHeader |
777 | if (fRawReader){FillRawEventHeaderESD(esd);} | |
596a855f | 778 | |
779 | // combined PID | |
780 | AliESDpid::MakePID(esd); | |
24f7a148 | 781 | if (fCheckPointLevel > 1) WriteESD(esd, "PID"); |
596a855f | 782 | |
b647652d | 783 | if (fFillTriggerESD) { |
784 | if (!ReadESD(esd, "trigger")) { | |
785 | if (!FillTriggerESD(esd)) { | |
786 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
787 | } | |
788 | if (fCheckPointLevel > 1) WriteESD(esd, "trigger"); | |
789 | } | |
790 | } | |
791 | ||
a03cd2e0 | 792 | //Try to improve the reconstructed primary vertex position using the tracks |
c060d7fe | 793 | AliESDVertex *pvtx=0; |
794 | Bool_t dovertex=kTRUE; | |
795 | TObject* obj = fOptions.FindObject("ITS"); | |
796 | if (obj) { | |
797 | TString optITS = obj->GetTitle(); | |
798 | if (optITS.Contains("cosmics") || optITS.Contains("COSMICS")) | |
799 | dovertex=kFALSE; | |
800 | } | |
801 | if(dovertex) pvtx=tVertexer.FindPrimaryVertex(esd); | |
17c86e90 | 802 | if(fDiamondProfile) esd->SetDiamond(fDiamondProfile); |
803 | ||
a03cd2e0 | 804 | if (pvtx) |
805 | if (pvtx->GetStatus()) { | |
806 | // Store the improved primary vertex | |
807 | esd->SetPrimaryVertex(pvtx); | |
808 | // Propagate the tracks to the DCA to the improved primary vertex | |
809 | Double_t somethingbig = 777.; | |
810 | Double_t bz = esd->GetMagneticField(); | |
811 | Int_t nt=esd->GetNumberOfTracks(); | |
812 | while (nt--) { | |
813 | AliESDtrack *t = esd->GetTrack(nt); | |
814 | t->RelateToVertex(pvtx, bz, somethingbig); | |
815 | } | |
816 | } | |
c5e3e5d1 | 817 | |
5e4ff34d | 818 | { |
819 | // V0 finding | |
820 | AliV0vertexer vtxer; | |
821 | vtxer.Tracks2V0vertices(esd); | |
822 | ||
823 | // Cascade finding | |
824 | AliCascadeVertexer cvtxer; | |
825 | cvtxer.V0sTracks2CascadeVertices(esd); | |
826 | } | |
827 | ||
596a855f | 828 | // write ESD |
d64bd07d | 829 | if (fCleanESD) CleanESD(esd); |
1d99986f | 830 | if (fWriteESDfriend) { |
46698ae4 | 831 | new (esdf) AliESDfriend(); // Reset... |
832 | esd->GetESDfriend(esdf); | |
1d99986f | 833 | } |
500d54ab | 834 | tree->Fill(); |
835 | ||
836 | // write HLT ESD | |
837 | hlttree->Fill(); | |
1d99986f | 838 | |
f3a97c86 | 839 | if (fCheckPointLevel > 0) WriteESD(esd, "final"); |
46698ae4 | 840 | esd->Reset(); |
841 | hltesd->Reset(); | |
5728d3d5 | 842 | if (fWriteESDfriend) { |
843 | new (esdf) AliESDfriend(); // Reset... | |
844 | } | |
46698ae4 | 845 | // esdf->Reset(); |
846 | // delete esdf; esdf = 0; | |
a5fa6165 | 847 | // ESD QA |
848 | ||
849 | } | |
850 | ||
851 | detStr = fFillESD ; | |
852 | // write quality assurance ESDs data (one entry for all events) | |
853 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
854 | if (!IsSelected(fgkDetectorName[iDet], detStr)) | |
855 | continue; | |
856 | AliQualAssDataMaker * qadm = GetQualAssDataMaker(iDet); | |
857 | if (!qadm) | |
858 | continue; | |
859 | qadm->Finish(AliQualAss::kESDS) ; | |
860 | } | |
5728d3d5 | 861 | |
46698ae4 | 862 | tree->GetUserInfo()->Add(esd); |
863 | hlttree->GetUserInfo()->Add(hltesd); | |
864 | ||
865 | ||
866 | ||
867 | if(fESDPar.Contains("ESD.par")){ | |
868 | AliInfo("Attaching ESD.par to Tree"); | |
869 | TNamed *fn = CopyFileToTNamed(fESDPar.Data(),"ESD.par"); | |
870 | tree->GetUserInfo()->Add(fn); | |
596a855f | 871 | } |
872 | ||
46698ae4 | 873 | |
36711aa4 | 874 | file->cd(); |
a9c0e6db | 875 | if (fWriteESDfriend) |
876 | tree->SetBranchStatus("ESDfriend*",0); | |
36711aa4 | 877 | tree->Write(); |
1f46a9ae | 878 | hlttree->Write(); |
f3a97c86 | 879 | |
a7807689 | 880 | if (fWriteAOD) { |
f29f1726 | 881 | TFile *aodFile = TFile::Open("AliAOD.root", "RECREATE"); |
882 | ESDFile2AODFile(file, aodFile); | |
883 | aodFile->Close(); | |
a7807689 | 884 | } |
885 | ||
46698ae4 | 886 | gROOT->cd(); |
151e0c96 | 887 | CleanUp(file, fileOld); |
888 | ||
f3a97c86 | 889 | // Create tags for the events in the ESD tree (the ESD tree is always present) |
890 | // In case of empty events the tags will contain dummy values | |
08e1a23e | 891 | AliESDTagCreator *esdtagCreator = new AliESDTagCreator(); |
892 | esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent); | |
a1069ee1 | 893 | if (fWriteAOD) { |
894 | AliAODTagCreator *aodtagCreator = new AliAODTagCreator(); | |
895 | aodtagCreator->CreateAODTags(fFirstEvent,fLastEvent); | |
896 | } | |
596a855f | 897 | |
898 | return kTRUE; | |
899 | } | |
900 | ||
901 | ||
902 | //_____________________________________________________________________________ | |
59697224 | 903 | Bool_t AliReconstruction::RunLocalReconstruction(const TString& detectors) |
596a855f | 904 | { |
59697224 | 905 | // run the local reconstruction |
596a855f | 906 | |
87932dab | 907 | AliCodeTimerAuto("") |
030b532d | 908 | |
8e245d15 | 909 | AliCDBManager* man = AliCDBManager::Instance(); |
910 | Bool_t origCache = man->GetCacheFlag(); | |
911 | ||
596a855f | 912 | TString detStr = detectors; |
b8cd5251 | 913 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
914 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
915 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
916 | if (!reconstructor) continue; | |
b26c3770 | 917 | if (reconstructor->HasLocalReconstruction()) continue; |
b8cd5251 | 918 | |
87932dab | 919 | AliCodeTimerStart(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
b8cd5251 | 920 | AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
87932dab | 921 | |
922 | AliCodeTimerStart(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); | |
8e245d15 | 923 | AliInfo(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); |
924 | ||
925 | man->SetCacheFlag(kTRUE); | |
926 | TString calibPath = Form("%s/Calib/*", fgkDetectorName[iDet]); | |
927 | man->GetAll(calibPath); // entries are cached! | |
928 | ||
87932dab | 929 | AliCodeTimerStop(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); |
930 | ||
b8cd5251 | 931 | if (fRawReader) { |
932 | fRawReader->RewindEvents(); | |
933 | reconstructor->Reconstruct(fRunLoader, fRawReader); | |
934 | } else { | |
935 | reconstructor->Reconstruct(fRunLoader); | |
596a855f | 936 | } |
87932dab | 937 | |
938 | AliCodeTimerStop(Form("running reconstruction for %s", fgkDetectorName[iDet])); | |
8e245d15 | 939 | |
940 | // unload calibration data | |
98e303d9 | 941 | man->UnloadFromCache(calibPath); |
942 | //man->ClearCache(); | |
596a855f | 943 | } |
944 | ||
8e245d15 | 945 | man->SetCacheFlag(origCache); |
946 | ||
596a855f | 947 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { |
815c2b38 | 948 | AliError(Form("the following detectors were not found: %s", |
949 | detStr.Data())); | |
596a855f | 950 | if (fStopOnError) return kFALSE; |
951 | } | |
952 | ||
953 | return kTRUE; | |
954 | } | |
955 | ||
b26c3770 | 956 | //_____________________________________________________________________________ |
957 | Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors) | |
958 | { | |
959 | // run the local reconstruction | |
960 | ||
87932dab | 961 | AliCodeTimerAuto("") |
b26c3770 | 962 | |
963 | TString detStr = detectors; | |
964 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
965 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
966 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
967 | if (!reconstructor) continue; | |
968 | AliLoader* loader = fLoader[iDet]; | |
969 | ||
970 | // conversion of digits | |
971 | if (fRawReader && reconstructor->HasDigitConversion()) { | |
972 | AliInfo(Form("converting raw data digits into root objects for %s", | |
973 | fgkDetectorName[iDet])); | |
87932dab | 974 | AliCodeTimerAuto(Form("converting raw data digits into root objects for %s", |
975 | fgkDetectorName[iDet])); | |
b26c3770 | 976 | loader->LoadDigits("update"); |
977 | loader->CleanDigits(); | |
978 | loader->MakeDigitsContainer(); | |
979 | TTree* digitsTree = loader->TreeD(); | |
980 | reconstructor->ConvertDigits(fRawReader, digitsTree); | |
981 | loader->WriteDigits("OVERWRITE"); | |
982 | loader->UnloadDigits(); | |
b26c3770 | 983 | } |
984 | ||
985 | // local reconstruction | |
986 | if (!reconstructor->HasLocalReconstruction()) continue; | |
987 | AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); | |
87932dab | 988 | AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
b26c3770 | 989 | loader->LoadRecPoints("update"); |
990 | loader->CleanRecPoints(); | |
991 | loader->MakeRecPointsContainer(); | |
992 | TTree* clustersTree = loader->TreeR(); | |
993 | if (fRawReader && !reconstructor->HasDigitConversion()) { | |
994 | reconstructor->Reconstruct(fRawReader, clustersTree); | |
995 | } else { | |
996 | loader->LoadDigits("read"); | |
997 | TTree* digitsTree = loader->TreeD(); | |
998 | if (!digitsTree) { | |
999 | AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet])); | |
1000 | if (fStopOnError) return kFALSE; | |
1001 | } else { | |
1002 | reconstructor->Reconstruct(digitsTree, clustersTree); | |
1003 | } | |
1004 | loader->UnloadDigits(); | |
1005 | } | |
1006 | loader->WriteRecPoints("OVERWRITE"); | |
1007 | loader->UnloadRecPoints(); | |
b26c3770 | 1008 | } |
1009 | ||
1010 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
1011 | AliError(Form("the following detectors were not found: %s", | |
1012 | detStr.Data())); | |
1013 | if (fStopOnError) return kFALSE; | |
1014 | } | |
5f8272e1 | 1015 | |
b26c3770 | 1016 | return kTRUE; |
1017 | } | |
1018 | ||
596a855f | 1019 | //_____________________________________________________________________________ |
af885e0f | 1020 | Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd) |
596a855f | 1021 | { |
1022 | // run the barrel tracking | |
1023 | ||
87932dab | 1024 | AliCodeTimerAuto("") |
030b532d | 1025 | |
2257f27e | 1026 | AliESDVertex* vertex = NULL; |
1027 | Double_t vtxPos[3] = {0, 0, 0}; | |
1028 | Double_t vtxErr[3] = {0.07, 0.07, 0.1}; | |
1029 | TArrayF mcVertex(3); | |
a6b0b91b | 1030 | if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) { |
1031 | fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex); | |
1032 | for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i]; | |
1033 | } | |
2257f27e | 1034 | |
b8cd5251 | 1035 | if (fVertexer) { |
17c86e90 | 1036 | if(fDiamondProfile) fVertexer->SetVtxStart(fDiamondProfile); |
815c2b38 | 1037 | AliInfo("running the ITS vertex finder"); |
b26c3770 | 1038 | if (fLoader[0]) fLoader[0]->LoadRecPoints(); |
b8cd5251 | 1039 | vertex = fVertexer->FindVertexForCurrentEvent(fRunLoader->GetEventNumber()); |
b26c3770 | 1040 | if (fLoader[0]) fLoader[0]->UnloadRecPoints(); |
2257f27e | 1041 | if(!vertex){ |
815c2b38 | 1042 | AliWarning("Vertex not found"); |
c710f220 | 1043 | vertex = new AliESDVertex(); |
d1a50cb5 | 1044 | vertex->SetName("default"); |
2257f27e | 1045 | } |
1046 | else { | |
d1a50cb5 | 1047 | vertex->SetName("reconstructed"); |
2257f27e | 1048 | } |
1049 | ||
1050 | } else { | |
815c2b38 | 1051 | AliInfo("getting the primary vertex from MC"); |
2257f27e | 1052 | vertex = new AliESDVertex(vtxPos, vtxErr); |
1053 | } | |
1054 | ||
1055 | if (vertex) { | |
1056 | vertex->GetXYZ(vtxPos); | |
1057 | vertex->GetSigmaXYZ(vtxErr); | |
1058 | } else { | |
815c2b38 | 1059 | AliWarning("no vertex reconstructed"); |
2257f27e | 1060 | vertex = new AliESDVertex(vtxPos, vtxErr); |
1061 | } | |
1062 | esd->SetVertex(vertex); | |
32e449be | 1063 | // if SPD multiplicity has been determined, it is stored in the ESD |
25be1e5c | 1064 | AliMultiplicity *mult = fVertexer->GetMultiplicity(); |
32e449be | 1065 | if(mult)esd->SetMultiplicity(mult); |
1066 | ||
b8cd5251 | 1067 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1068 | if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr); | |
1069 | } | |
2257f27e | 1070 | delete vertex; |
1071 | ||
2257f27e | 1072 | return kTRUE; |
1073 | } | |
1074 | ||
1f46a9ae | 1075 | //_____________________________________________________________________________ |
af885e0f | 1076 | Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd) |
1f46a9ae | 1077 | { |
1078 | // run the HLT barrel tracking | |
1079 | ||
87932dab | 1080 | AliCodeTimerAuto("") |
1f46a9ae | 1081 | |
1082 | if (!fRunLoader) { | |
1083 | AliError("Missing runLoader!"); | |
1084 | return kFALSE; | |
1085 | } | |
1086 | ||
1087 | AliInfo("running HLT tracking"); | |
1088 | ||
1089 | // Get a pointer to the HLT reconstructor | |
1090 | AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1); | |
1091 | if (!reconstructor) return kFALSE; | |
1092 | ||
1093 | // TPC + ITS | |
1094 | for (Int_t iDet = 1; iDet >= 0; iDet--) { | |
1095 | TString detName = fgkDetectorName[iDet]; | |
1096 | AliDebug(1, Form("%s HLT tracking", detName.Data())); | |
1097 | reconstructor->SetOption(detName.Data()); | |
1098 | AliTracker *tracker = reconstructor->CreateTracker(fRunLoader); | |
1099 | if (!tracker) { | |
1100 | AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data())); | |
1101 | if (fStopOnError) return kFALSE; | |
9dcc06e1 | 1102 | continue; |
1f46a9ae | 1103 | } |
1104 | Double_t vtxPos[3]; | |
1105 | Double_t vtxErr[3]={0.005,0.005,0.010}; | |
1106 | const AliESDVertex *vertex = esd->GetVertex(); | |
1107 | vertex->GetXYZ(vtxPos); | |
1108 | tracker->SetVertex(vtxPos,vtxErr); | |
1109 | if(iDet != 1) { | |
1110 | fLoader[iDet]->LoadRecPoints("read"); | |
1111 | TTree* tree = fLoader[iDet]->TreeR(); | |
1112 | if (!tree) { | |
1113 | AliError(Form("Can't get the %s cluster tree", detName.Data())); | |
1114 | return kFALSE; | |
1115 | } | |
1116 | tracker->LoadClusters(tree); | |
1117 | } | |
1118 | if (tracker->Clusters2Tracks(esd) != 0) { | |
1119 | AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
1120 | return kFALSE; | |
1121 | } | |
1122 | if(iDet != 1) { | |
1123 | tracker->UnloadClusters(); | |
1124 | } | |
1125 | delete tracker; | |
1126 | } | |
1127 | ||
1f46a9ae | 1128 | return kTRUE; |
1129 | } | |
1130 | ||
e66fbafb | 1131 | //_____________________________________________________________________________ |
af885e0f | 1132 | Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd) |
e66fbafb | 1133 | { |
1134 | // run the muon spectrometer tracking | |
1135 | ||
87932dab | 1136 | AliCodeTimerAuto("") |
e66fbafb | 1137 | |
1138 | if (!fRunLoader) { | |
1139 | AliError("Missing runLoader!"); | |
1140 | return kFALSE; | |
1141 | } | |
1142 | Int_t iDet = 7; // for MUON | |
1143 | ||
1144 | AliInfo("is running..."); | |
1145 | ||
1146 | // Get a pointer to the MUON reconstructor | |
1147 | AliReconstructor *reconstructor = GetReconstructor(iDet); | |
1148 | if (!reconstructor) return kFALSE; | |
1149 | ||
1150 | ||
1151 | TString detName = fgkDetectorName[iDet]; | |
1152 | AliDebug(1, Form("%s tracking", detName.Data())); | |
1153 | AliTracker *tracker = reconstructor->CreateTracker(fRunLoader); | |
1154 | if (!tracker) { | |
1155 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); | |
1156 | return kFALSE; | |
1157 | } | |
1158 | ||
1159 | // create Tracks | |
1160 | fLoader[iDet]->LoadTracks("update"); | |
1161 | fLoader[iDet]->CleanTracks(); | |
1162 | fLoader[iDet]->MakeTracksContainer(); | |
1163 | ||
1164 | // read RecPoints | |
761350a6 | 1165 | fLoader[iDet]->LoadRecPoints("read"); |
1166 | tracker->LoadClusters(fLoader[iDet]->TreeR()); | |
1167 | ||
1168 | Int_t rv = tracker->Clusters2Tracks(esd); | |
1169 | ||
1170 | fLoader[iDet]->UnloadRecPoints(); | |
1171 | ||
1172 | if ( rv ) | |
1173 | { | |
e66fbafb | 1174 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); |
1175 | return kFALSE; | |
1176 | } | |
761350a6 | 1177 | |
1178 | tracker->UnloadClusters(); | |
1179 | ||
e66fbafb | 1180 | fLoader[iDet]->UnloadRecPoints(); |
1181 | ||
1182 | fLoader[iDet]->WriteTracks("OVERWRITE"); | |
1183 | fLoader[iDet]->UnloadTracks(); | |
1184 | ||
1185 | delete tracker; | |
1186 | ||
e66fbafb | 1187 | return kTRUE; |
1188 | } | |
1189 | ||
1190 | ||
2257f27e | 1191 | //_____________________________________________________________________________ |
af885e0f | 1192 | Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd) |
2257f27e | 1193 | { |
1194 | // run the barrel tracking | |
1195 | ||
87932dab | 1196 | AliCodeTimerAuto("") |
24f7a148 | 1197 | |
815c2b38 | 1198 | AliInfo("running tracking"); |
596a855f | 1199 | |
91b876d1 | 1200 | //Fill the ESD with the T0 info (will be used by the TOF) |
1f4331b3 | 1201 | if (fReconstructor[11]) |
1202 | GetReconstructor(11)->FillESD(fRunLoader, esd); | |
91b876d1 | 1203 | |
b8cd5251 | 1204 | // pass 1: TPC + ITS inwards |
1205 | for (Int_t iDet = 1; iDet >= 0; iDet--) { | |
1206 | if (!fTracker[iDet]) continue; | |
1207 | AliDebug(1, Form("%s tracking", fgkDetectorName[iDet])); | |
24f7a148 | 1208 | |
b8cd5251 | 1209 | // load clusters |
1210 | fLoader[iDet]->LoadRecPoints("read"); | |
1211 | TTree* tree = fLoader[iDet]->TreeR(); | |
1212 | if (!tree) { | |
1213 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); | |
24f7a148 | 1214 | return kFALSE; |
1215 | } | |
b8cd5251 | 1216 | fTracker[iDet]->LoadClusters(tree); |
1217 | ||
1218 | // run tracking | |
1219 | if (fTracker[iDet]->Clusters2Tracks(esd) != 0) { | |
1220 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
24f7a148 | 1221 | return kFALSE; |
1222 | } | |
b8cd5251 | 1223 | if (fCheckPointLevel > 1) { |
1224 | WriteESD(esd, Form("%s.tracking", fgkDetectorName[iDet])); | |
1225 | } | |
878e1fe1 | 1226 | // preliminary PID in TPC needed by the ITS tracker |
1227 | if (iDet == 1) { | |
1228 | GetReconstructor(1)->FillESD(fRunLoader, esd); | |
b26c3770 | 1229 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); |
878e1fe1 | 1230 | AliESDpid::MakePID(esd); |
1231 | } | |
b8cd5251 | 1232 | } |
596a855f | 1233 | |
b8cd5251 | 1234 | // pass 2: ALL backwards |
1235 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1236 | if (!fTracker[iDet]) continue; | |
1237 | AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet])); | |
1238 | ||
1239 | // load clusters | |
1240 | if (iDet > 1) { // all except ITS, TPC | |
1241 | TTree* tree = NULL; | |
7b61cd9c | 1242 | fLoader[iDet]->LoadRecPoints("read"); |
1243 | tree = fLoader[iDet]->TreeR(); | |
b8cd5251 | 1244 | if (!tree) { |
1245 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); | |
24f7a148 | 1246 | return kFALSE; |
1247 | } | |
b8cd5251 | 1248 | fTracker[iDet]->LoadClusters(tree); |
1249 | } | |
24f7a148 | 1250 | |
b8cd5251 | 1251 | // run tracking |
1252 | if (fTracker[iDet]->PropagateBack(esd) != 0) { | |
1253 | AliError(Form("%s backward propagation failed", fgkDetectorName[iDet])); | |
49dfd67a | 1254 | // return kFALSE; |
b8cd5251 | 1255 | } |
1256 | if (fCheckPointLevel > 1) { | |
1257 | WriteESD(esd, Form("%s.back", fgkDetectorName[iDet])); | |
1258 | } | |
24f7a148 | 1259 | |
b8cd5251 | 1260 | // unload clusters |
1261 | if (iDet > 2) { // all except ITS, TPC, TRD | |
1262 | fTracker[iDet]->UnloadClusters(); | |
7b61cd9c | 1263 | fLoader[iDet]->UnloadRecPoints(); |
b8cd5251 | 1264 | } |
8f37df88 | 1265 | // updated PID in TPC needed by the ITS tracker -MI |
1266 | if (iDet == 1) { | |
1267 | GetReconstructor(1)->FillESD(fRunLoader, esd); | |
1268 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); | |
1269 | AliESDpid::MakePID(esd); | |
1270 | } | |
b8cd5251 | 1271 | } |
596a855f | 1272 | |
98937d93 | 1273 | // write space-points to the ESD in case alignment data output |
1274 | // is switched on | |
1275 | if (fWriteAlignmentData) | |
1276 | WriteAlignmentData(esd); | |
1277 | ||
b8cd5251 | 1278 | // pass 3: TRD + TPC + ITS refit inwards |
1279 | for (Int_t iDet = 2; iDet >= 0; iDet--) { | |
1280 | if (!fTracker[iDet]) continue; | |
1281 | AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet])); | |
596a855f | 1282 | |
b8cd5251 | 1283 | // run tracking |
1284 | if (fTracker[iDet]->RefitInward(esd) != 0) { | |
1285 | AliError(Form("%s inward refit failed", fgkDetectorName[iDet])); | |
49dfd67a | 1286 | // return kFALSE; |
b8cd5251 | 1287 | } |
1288 | if (fCheckPointLevel > 1) { | |
1289 | WriteESD(esd, Form("%s.refit", fgkDetectorName[iDet])); | |
1290 | } | |
596a855f | 1291 | |
b8cd5251 | 1292 | // unload clusters |
1293 | fTracker[iDet]->UnloadClusters(); | |
1294 | fLoader[iDet]->UnloadRecPoints(); | |
1295 | } | |
ff8bb5ae | 1296 | // |
1297 | // Propagate track to the vertex - if not done by ITS | |
1298 | // | |
1299 | Int_t ntracks = esd->GetNumberOfTracks(); | |
1300 | for (Int_t itrack=0; itrack<ntracks; itrack++){ | |
1301 | const Double_t kRadius = 3; // beam pipe radius | |
1302 | const Double_t kMaxStep = 5; // max step | |
1303 | const Double_t kMaxD = 123456; // max distance to prim vertex | |
1304 | Double_t fieldZ = AliTracker::GetBz(); // | |
1305 | AliESDtrack * track = esd->GetTrack(itrack); | |
1306 | if (!track) continue; | |
1307 | if (track->IsOn(AliESDtrack::kITSrefit)) continue; | |
a7265806 | 1308 | AliTracker::PropagateTrackTo(track,kRadius,track->GetMass(),kMaxStep,kTRUE); |
ff8bb5ae | 1309 | track->RelateToVertex(esd->GetVertex(),fieldZ, kMaxD); |
1310 | } | |
1311 | ||
596a855f | 1312 | return kTRUE; |
1313 | } | |
1314 | ||
d64bd07d | 1315 | //_____________________________________________________________________________ |
1316 | Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){ | |
1317 | // | |
1318 | // Remove the data which are not needed for the physics analysis. | |
1319 | // | |
1320 | ||
1321 | AliInfo("Cleaning the ESD..."); | |
1322 | ||
1323 | const AliESDVertex *vertex=esd->GetVertex(); | |
1324 | Double_t vz=vertex->GetZv(); | |
1325 | ||
1326 | Int_t nTracks=esd->GetNumberOfTracks(); | |
1327 | for (Int_t i=0; i<nTracks; i++) { | |
1328 | AliESDtrack *track=esd->GetTrack(i); | |
1329 | ||
1330 | Float_t xy,z; track->GetImpactParameters(xy,z); | |
1331 | if (TMath::Abs(xy) < 50.) continue; | |
1332 | if (vertex->GetStatus()) | |
1333 | if (TMath::Abs(vz-z) < 5.) continue; | |
1334 | ||
1335 | esd->RemoveTrack(i); | |
1336 | } | |
1337 | ||
1338 | return kTRUE; | |
1339 | } | |
1340 | ||
596a855f | 1341 | //_____________________________________________________________________________ |
af885e0f | 1342 | Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors) |
596a855f | 1343 | { |
1344 | // fill the event summary data | |
1345 | ||
87932dab | 1346 | AliCodeTimerAuto("") |
030b532d | 1347 | |
596a855f | 1348 | TString detStr = detectors; |
b8cd5251 | 1349 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1350 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
1351 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
1352 | if (!reconstructor) continue; | |
1353 | ||
1354 | if (!ReadESD(esd, fgkDetectorName[iDet])) { | |
1355 | AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet])); | |
b26c3770 | 1356 | TTree* clustersTree = NULL; |
1357 | if (reconstructor->HasLocalReconstruction() && fLoader[iDet]) { | |
1358 | fLoader[iDet]->LoadRecPoints("read"); | |
1359 | clustersTree = fLoader[iDet]->TreeR(); | |
1360 | if (!clustersTree) { | |
1361 | AliError(Form("Can't get the %s clusters tree", | |
1362 | fgkDetectorName[iDet])); | |
1363 | if (fStopOnError) return kFALSE; | |
1364 | } | |
1365 | } | |
1366 | if (fRawReader && !reconstructor->HasDigitConversion()) { | |
1367 | reconstructor->FillESD(fRawReader, clustersTree, esd); | |
1368 | } else { | |
1369 | TTree* digitsTree = NULL; | |
1370 | if (fLoader[iDet]) { | |
1371 | fLoader[iDet]->LoadDigits("read"); | |
1372 | digitsTree = fLoader[iDet]->TreeD(); | |
1373 | if (!digitsTree) { | |
1374 | AliError(Form("Can't get the %s digits tree", | |
1375 | fgkDetectorName[iDet])); | |
1376 | if (fStopOnError) return kFALSE; | |
1377 | } | |
1378 | } | |
1379 | reconstructor->FillESD(digitsTree, clustersTree, esd); | |
1380 | if (fLoader[iDet]) fLoader[iDet]->UnloadDigits(); | |
1381 | } | |
1382 | if (reconstructor->HasLocalReconstruction() && fLoader[iDet]) { | |
1383 | fLoader[iDet]->UnloadRecPoints(); | |
1384 | } | |
1385 | ||
b8cd5251 | 1386 | if (fRawReader) { |
1387 | reconstructor->FillESD(fRunLoader, fRawReader, esd); | |
1388 | } else { | |
1389 | reconstructor->FillESD(fRunLoader, esd); | |
24f7a148 | 1390 | } |
b8cd5251 | 1391 | if (fCheckPointLevel > 2) WriteESD(esd, fgkDetectorName[iDet]); |
596a855f | 1392 | } |
1393 | } | |
1394 | ||
1395 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
815c2b38 | 1396 | AliError(Form("the following detectors were not found: %s", |
1397 | detStr.Data())); | |
596a855f | 1398 | if (fStopOnError) return kFALSE; |
1399 | } | |
1400 | ||
1401 | return kTRUE; | |
1402 | } | |
1403 | ||
b647652d | 1404 | //_____________________________________________________________________________ |
af885e0f | 1405 | Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd) |
b647652d | 1406 | { |
1407 | // Reads the trigger decision which is | |
1408 | // stored in Trigger.root file and fills | |
1409 | // the corresponding esd entries | |
1410 | ||
87932dab | 1411 | AliCodeTimerAuto("") |
1412 | ||
b647652d | 1413 | AliInfo("Filling trigger information into the ESD"); |
1414 | ||
1415 | if (fRawReader) { | |
1416 | AliCTPRawStream input(fRawReader); | |
1417 | if (!input.Next()) { | |
1418 | AliError("No valid CTP (trigger) DDL raw data is found ! The trigger information is not stored in the ESD !"); | |
1419 | return kFALSE; | |
1420 | } | |
1421 | esd->SetTriggerMask(input.GetClassMask()); | |
1422 | esd->SetTriggerCluster(input.GetClusterMask()); | |
1423 | } | |
1424 | else { | |
1425 | AliRunLoader *runloader = AliRunLoader::GetRunLoader(); | |
1426 | if (runloader) { | |
1427 | if (!runloader->LoadTrigger()) { | |
1428 | AliCentralTrigger *aCTP = runloader->GetTrigger(); | |
1429 | esd->SetTriggerMask(aCTP->GetClassMask()); | |
1430 | esd->SetTriggerCluster(aCTP->GetClusterMask()); | |
1431 | } | |
1432 | else { | |
1433 | AliWarning("No trigger can be loaded! The trigger information is not stored in the ESD !"); | |
1434 | return kFALSE; | |
1435 | } | |
1436 | } | |
1437 | else { | |
1438 | AliError("No run loader is available! The trigger information is not stored in the ESD !"); | |
1439 | return kFALSE; | |
1440 | } | |
1441 | } | |
1442 | ||
1443 | return kTRUE; | |
1444 | } | |
596a855f | 1445 | |
001397cd | 1446 | |
1447 | ||
1448 | ||
1449 | ||
1450 | //_____________________________________________________________________________ | |
af885e0f | 1451 | Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd) |
001397cd | 1452 | { |
1453 | // | |
1454 | // Filling information from RawReader Header | |
1455 | // | |
1456 | ||
1457 | AliInfo("Filling information from RawReader Header"); | |
31fd97b2 | 1458 | esd->SetBunchCrossNumber(0); |
1459 | esd->SetOrbitNumber(0); | |
9bcc1e45 | 1460 | esd->SetPeriodNumber(0); |
001397cd | 1461 | esd->SetTimeStamp(0); |
1462 | esd->SetEventType(0); | |
1463 | const AliRawEventHeaderBase * eventHeader = fRawReader->GetEventHeader(); | |
1464 | if (eventHeader){ | |
9bcc1e45 | 1465 | |
1466 | const UInt_t *id = eventHeader->GetP("Id"); | |
1467 | esd->SetBunchCrossNumber((id)[1]&0x00000fff); | |
1468 | esd->SetOrbitNumber((((id)[0]<<20)&0xf00000)|(((id)[1]>>12)&0xfffff)); | |
1469 | esd->SetPeriodNumber(((id)[0]>>4)&0x0fffffff); | |
1470 | ||
001397cd | 1471 | esd->SetTimeStamp((eventHeader->Get("Timestamp"))); |
31fd97b2 | 1472 | esd->SetEventType((eventHeader->Get("Type"))); |
001397cd | 1473 | } |
1474 | ||
1475 | return kTRUE; | |
1476 | } | |
1477 | ||
1478 | ||
596a855f | 1479 | //_____________________________________________________________________________ |
1480 | Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const | |
1481 | { | |
1482 | // check whether detName is contained in detectors | |
1483 | // if yes, it is removed from detectors | |
1484 | ||
1485 | // check if all detectors are selected | |
1486 | if ((detectors.CompareTo("ALL") == 0) || | |
1487 | detectors.BeginsWith("ALL ") || | |
1488 | detectors.EndsWith(" ALL") || | |
1489 | detectors.Contains(" ALL ")) { | |
1490 | detectors = "ALL"; | |
1491 | return kTRUE; | |
1492 | } | |
1493 | ||
1494 | // search for the given detector | |
1495 | Bool_t result = kFALSE; | |
1496 | if ((detectors.CompareTo(detName) == 0) || | |
1497 | detectors.BeginsWith(detName+" ") || | |
1498 | detectors.EndsWith(" "+detName) || | |
1499 | detectors.Contains(" "+detName+" ")) { | |
1500 | detectors.ReplaceAll(detName, ""); | |
1501 | result = kTRUE; | |
1502 | } | |
1503 | ||
1504 | // clean up the detectors string | |
1505 | while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " "); | |
1506 | while (detectors.BeginsWith(" ")) detectors.Remove(0, 1); | |
1507 | while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1); | |
1508 | ||
1509 | return result; | |
1510 | } | |
e583c30d | 1511 | |
f08fc9f5 | 1512 | //_____________________________________________________________________________ |
1513 | Bool_t AliReconstruction::InitRunLoader() | |
1514 | { | |
1515 | // get or create the run loader | |
1516 | ||
1517 | if (gAlice) delete gAlice; | |
1518 | gAlice = NULL; | |
1519 | ||
b26c3770 | 1520 | if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists |
1521 | // load all base libraries to get the loader classes | |
1522 | TString libs = gSystem->GetLibraries(); | |
1523 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1524 | TString detName = fgkDetectorName[iDet]; | |
1525 | if (detName == "HLT") continue; | |
1526 | if (libs.Contains("lib" + detName + "base.so")) continue; | |
1527 | gSystem->Load("lib" + detName + "base.so"); | |
1528 | } | |
f08fc9f5 | 1529 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); |
1530 | if (!fRunLoader) { | |
1531 | AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); | |
1532 | CleanUp(); | |
1533 | return kFALSE; | |
1534 | } | |
b26c3770 | 1535 | fRunLoader->CdGAFile(); |
1536 | if (gFile->GetKey(AliRunLoader::GetGAliceName())) { | |
1537 | if (fRunLoader->LoadgAlice() == 0) { | |
1538 | gAlice = fRunLoader->GetAliRun(); | |
c84a5e9e | 1539 | AliTracker::SetFieldMap(gAlice->Field(),fUniformField); |
b26c3770 | 1540 | } |
f08fc9f5 | 1541 | } |
1542 | if (!gAlice && !fRawReader) { | |
1543 | AliError(Form("no gAlice object found in file %s", | |
1544 | fGAliceFileName.Data())); | |
1545 | CleanUp(); | |
1546 | return kFALSE; | |
1547 | } | |
1548 | ||
6cae184e | 1549 | //PH This is a temporary fix to give access to the kinematics |
1550 | //PH that is needed for the labels of ITS clusters | |
1551 | fRunLoader->LoadKinematics(); | |
1552 | ||
f08fc9f5 | 1553 | } else { // galice.root does not exist |
1554 | if (!fRawReader) { | |
1555 | AliError(Form("the file %s does not exist", fGAliceFileName.Data())); | |
1556 | CleanUp(); | |
1557 | return kFALSE; | |
1558 | } | |
1559 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(), | |
1560 | AliConfig::GetDefaultEventFolderName(), | |
1561 | "recreate"); | |
1562 | if (!fRunLoader) { | |
1563 | AliError(Form("could not create run loader in file %s", | |
1564 | fGAliceFileName.Data())); | |
1565 | CleanUp(); | |
1566 | return kFALSE; | |
1567 | } | |
1568 | fRunLoader->MakeTree("E"); | |
1569 | Int_t iEvent = 0; | |
1570 | while (fRawReader->NextEvent()) { | |
1571 | fRunLoader->SetEventNumber(iEvent); | |
1572 | fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(), | |
1573 | iEvent, iEvent); | |
1574 | fRunLoader->MakeTree("H"); | |
1575 | fRunLoader->TreeE()->Fill(); | |
1576 | iEvent++; | |
1577 | } | |
1578 | fRawReader->RewindEvents(); | |
973388c2 | 1579 | if (fNumberOfEventsPerFile > 0) |
1580 | fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile); | |
1581 | else | |
1582 | fRunLoader->SetNumberOfEventsPerFile(iEvent); | |
f08fc9f5 | 1583 | fRunLoader->WriteHeader("OVERWRITE"); |
1584 | fRunLoader->CdGAFile(); | |
1585 | fRunLoader->Write(0, TObject::kOverwrite); | |
1586 | // AliTracker::SetFieldMap(???); | |
1587 | } | |
1588 | ||
1589 | return kTRUE; | |
1590 | } | |
1591 | ||
c757bafd | 1592 | //_____________________________________________________________________________ |
b8cd5251 | 1593 | AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet) |
c757bafd | 1594 | { |
f08fc9f5 | 1595 | // get the reconstructor object and the loader for a detector |
c757bafd | 1596 | |
b8cd5251 | 1597 | if (fReconstructor[iDet]) return fReconstructor[iDet]; |
1598 | ||
1599 | // load the reconstructor object | |
1600 | TPluginManager* pluginManager = gROOT->GetPluginManager(); | |
1601 | TString detName = fgkDetectorName[iDet]; | |
1602 | TString recName = "Ali" + detName + "Reconstructor"; | |
f08fc9f5 | 1603 | if (gAlice && !gAlice->GetDetector(detName) && (detName != "HLT")) return NULL; |
b8cd5251 | 1604 | |
1605 | if (detName == "HLT") { | |
1606 | if (!gROOT->GetClass("AliLevel3")) { | |
4aa41877 | 1607 | gSystem->Load("libAliHLTSrc.so"); |
1608 | gSystem->Load("libAliHLTMisc.so"); | |
1609 | gSystem->Load("libAliHLTHough.so"); | |
1610 | gSystem->Load("libAliHLTComp.so"); | |
b8cd5251 | 1611 | } |
1612 | } | |
1613 | ||
1614 | AliReconstructor* reconstructor = NULL; | |
1615 | // first check if a plugin is defined for the reconstructor | |
1616 | TPluginHandler* pluginHandler = | |
1617 | pluginManager->FindHandler("AliReconstructor", detName); | |
f08fc9f5 | 1618 | // if not, add a plugin for it |
1619 | if (!pluginHandler) { | |
b8cd5251 | 1620 | AliDebug(1, Form("defining plugin for %s", recName.Data())); |
b26c3770 | 1621 | TString libs = gSystem->GetLibraries(); |
1622 | if (libs.Contains("lib" + detName + "base.so") || | |
1623 | (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
b8cd5251 | 1624 | pluginManager->AddHandler("AliReconstructor", detName, |
1625 | recName, detName + "rec", recName + "()"); | |
1626 | } else { | |
1627 | pluginManager->AddHandler("AliReconstructor", detName, | |
1628 | recName, detName, recName + "()"); | |
c757bafd | 1629 | } |
b8cd5251 | 1630 | pluginHandler = pluginManager->FindHandler("AliReconstructor", detName); |
1631 | } | |
1632 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
1633 | reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0); | |
c757bafd | 1634 | } |
b8cd5251 | 1635 | if (reconstructor) { |
1636 | TObject* obj = fOptions.FindObject(detName.Data()); | |
1637 | if (obj) reconstructor->SetOption(obj->GetTitle()); | |
b26c3770 | 1638 | reconstructor->Init(fRunLoader); |
b8cd5251 | 1639 | fReconstructor[iDet] = reconstructor; |
1640 | } | |
1641 | ||
f08fc9f5 | 1642 | // get or create the loader |
1643 | if (detName != "HLT") { | |
1644 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); | |
1645 | if (!fLoader[iDet]) { | |
1646 | AliConfig::Instance() | |
1647 | ->CreateDetectorFolders(fRunLoader->GetEventFolder(), | |
1648 | detName, detName); | |
1649 | // first check if a plugin is defined for the loader | |
bb0901a4 | 1650 | pluginHandler = |
f08fc9f5 | 1651 | pluginManager->FindHandler("AliLoader", detName); |
1652 | // if not, add a plugin for it | |
1653 | if (!pluginHandler) { | |
1654 | TString loaderName = "Ali" + detName + "Loader"; | |
1655 | AliDebug(1, Form("defining plugin for %s", loaderName.Data())); | |
1656 | pluginManager->AddHandler("AliLoader", detName, | |
1657 | loaderName, detName + "base", | |
1658 | loaderName + "(const char*, TFolder*)"); | |
1659 | pluginHandler = pluginManager->FindHandler("AliLoader", detName); | |
1660 | } | |
1661 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
1662 | fLoader[iDet] = | |
1663 | (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(), | |
1664 | fRunLoader->GetEventFolder()); | |
1665 | } | |
1666 | if (!fLoader[iDet]) { // use default loader | |
1667 | fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder()); | |
1668 | } | |
1669 | if (!fLoader[iDet]) { | |
1670 | AliWarning(Form("couldn't get loader for %s", detName.Data())); | |
6667b602 | 1671 | if (fStopOnError) return NULL; |
f08fc9f5 | 1672 | } else { |
1673 | fRunLoader->AddLoader(fLoader[iDet]); | |
1674 | fRunLoader->CdGAFile(); | |
1675 | if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE"); | |
1676 | fRunLoader->Write(0, TObject::kOverwrite); | |
1677 | } | |
1678 | } | |
1679 | } | |
1680 | ||
b8cd5251 | 1681 | return reconstructor; |
c757bafd | 1682 | } |
1683 | ||
2257f27e | 1684 | //_____________________________________________________________________________ |
1685 | Bool_t AliReconstruction::CreateVertexer() | |
1686 | { | |
1687 | // create the vertexer | |
1688 | ||
b8cd5251 | 1689 | fVertexer = NULL; |
1690 | AliReconstructor* itsReconstructor = GetReconstructor(0); | |
59697224 | 1691 | if (itsReconstructor) { |
b8cd5251 | 1692 | fVertexer = itsReconstructor->CreateVertexer(fRunLoader); |
2257f27e | 1693 | } |
b8cd5251 | 1694 | if (!fVertexer) { |
815c2b38 | 1695 | AliWarning("couldn't create a vertexer for ITS"); |
2257f27e | 1696 | if (fStopOnError) return kFALSE; |
1697 | } | |
1698 | ||
1699 | return kTRUE; | |
1700 | } | |
1701 | ||
24f7a148 | 1702 | //_____________________________________________________________________________ |
b8cd5251 | 1703 | Bool_t AliReconstruction::CreateTrackers(const TString& detectors) |
24f7a148 | 1704 | { |
f08fc9f5 | 1705 | // create the trackers |
24f7a148 | 1706 | |
b8cd5251 | 1707 | TString detStr = detectors; |
1708 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1709 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
1710 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
1711 | if (!reconstructor) continue; | |
1712 | TString detName = fgkDetectorName[iDet]; | |
1f46a9ae | 1713 | if (detName == "HLT") { |
1714 | fRunHLTTracking = kTRUE; | |
1715 | continue; | |
1716 | } | |
e66fbafb | 1717 | if (detName == "MUON") { |
1718 | fRunMuonTracking = kTRUE; | |
1719 | continue; | |
1720 | } | |
1721 | ||
f08fc9f5 | 1722 | |
1723 | fTracker[iDet] = reconstructor->CreateTracker(fRunLoader); | |
1724 | if (!fTracker[iDet] && (iDet < 7)) { | |
1725 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); | |
8250d5f5 | 1726 | if (fStopOnError) return kFALSE; |
1727 | } | |
1728 | } | |
1729 | ||
24f7a148 | 1730 | return kTRUE; |
1731 | } | |
1732 | ||
e583c30d | 1733 | //_____________________________________________________________________________ |
b26c3770 | 1734 | void AliReconstruction::CleanUp(TFile* file, TFile* fileOld) |
e583c30d | 1735 | { |
1736 | // delete trackers and the run loader and close and delete the file | |
1737 | ||
b8cd5251 | 1738 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1739 | delete fReconstructor[iDet]; | |
1740 | fReconstructor[iDet] = NULL; | |
1741 | fLoader[iDet] = NULL; | |
1742 | delete fTracker[iDet]; | |
1743 | fTracker[iDet] = NULL; | |
d101408a | 1744 | delete fQualAssDataMaker[iDet]; |
1745 | fQualAssDataMaker[iDet] = NULL; | |
b8cd5251 | 1746 | } |
1747 | delete fVertexer; | |
1748 | fVertexer = NULL; | |
9178838a | 1749 | delete fDiamondProfile; |
1750 | fDiamondProfile = NULL; | |
e583c30d | 1751 | |
1752 | delete fRunLoader; | |
1753 | fRunLoader = NULL; | |
b649205a | 1754 | delete fRawReader; |
1755 | fRawReader = NULL; | |
e583c30d | 1756 | |
1757 | if (file) { | |
1758 | file->Close(); | |
1759 | delete file; | |
1760 | } | |
b26c3770 | 1761 | |
1762 | if (fileOld) { | |
1763 | fileOld->Close(); | |
1764 | delete fileOld; | |
1765 | gSystem->Unlink("AliESDs.old.root"); | |
1766 | } | |
e583c30d | 1767 | } |
24f7a148 | 1768 | |
24f7a148 | 1769 | //_____________________________________________________________________________ |
af885e0f | 1770 | |
1771 | Bool_t AliReconstruction::ReadESD(AliESDEvent*& esd, const char* recStep) const | |
24f7a148 | 1772 | { |
1773 | // read the ESD event from a file | |
1774 | ||
1775 | if (!esd) return kFALSE; | |
1776 | char fileName[256]; | |
1777 | sprintf(fileName, "ESD_%d.%d_%s.root", | |
31fd97b2 | 1778 | esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep); |
24f7a148 | 1779 | if (gSystem->AccessPathName(fileName)) return kFALSE; |
1780 | ||
f3a97c86 | 1781 | AliInfo(Form("reading ESD from file %s", fileName)); |
815c2b38 | 1782 | AliDebug(1, Form("reading ESD from file %s", fileName)); |
24f7a148 | 1783 | TFile* file = TFile::Open(fileName); |
1784 | if (!file || !file->IsOpen()) { | |
815c2b38 | 1785 | AliError(Form("opening %s failed", fileName)); |
24f7a148 | 1786 | delete file; |
1787 | return kFALSE; | |
1788 | } | |
1789 | ||
1790 | gROOT->cd(); | |
1791 | delete esd; | |
af885e0f | 1792 | esd = (AliESDEvent*) file->Get("ESD"); |
24f7a148 | 1793 | file->Close(); |
1794 | delete file; | |
1795 | return kTRUE; | |
af885e0f | 1796 | |
24f7a148 | 1797 | } |
1798 | ||
af885e0f | 1799 | |
1800 | ||
24f7a148 | 1801 | //_____________________________________________________________________________ |
af885e0f | 1802 | void AliReconstruction::WriteESD(AliESDEvent* esd, const char* recStep) const |
24f7a148 | 1803 | { |
1804 | // write the ESD event to a file | |
1805 | ||
1806 | if (!esd) return; | |
1807 | char fileName[256]; | |
1808 | sprintf(fileName, "ESD_%d.%d_%s.root", | |
31fd97b2 | 1809 | esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep); |
24f7a148 | 1810 | |
815c2b38 | 1811 | AliDebug(1, Form("writing ESD to file %s", fileName)); |
24f7a148 | 1812 | TFile* file = TFile::Open(fileName, "recreate"); |
1813 | if (!file || !file->IsOpen()) { | |
815c2b38 | 1814 | AliError(Form("opening %s failed", fileName)); |
24f7a148 | 1815 | } else { |
1816 | esd->Write("ESD"); | |
1817 | file->Close(); | |
1818 | } | |
1819 | delete file; | |
1820 | } | |
f3a97c86 | 1821 | |
1822 | ||
1823 | ||
1824 | ||
f3a97c86 | 1825 | |
a7807689 | 1826 | //_____________________________________________________________________________ |
f29f1726 | 1827 | void AliReconstruction::ESDFile2AODFile(TFile* esdFile, TFile* aodFile) |
a7807689 | 1828 | { |
f29f1726 | 1829 | // write all files from the given esd file to an aod file |
85ba66b8 | 1830 | |
f29f1726 | 1831 | // create an AliAOD object |
1832 | AliAODEvent *aod = new AliAODEvent(); | |
1833 | aod->CreateStdContent(); | |
1834 | ||
1835 | // go to the file | |
1836 | aodFile->cd(); | |
1837 | ||
1838 | // create the tree | |
b97637d4 | 1839 | TTree *aodTree = new TTree("aodTree", "AliAOD tree"); |
f29f1726 | 1840 | aodTree->Branch(aod->GetList()); |
1841 | ||
1842 | // connect to ESD | |
1843 | TTree *t = (TTree*) esdFile->Get("esdTree"); | |
af885e0f | 1844 | AliESDEvent *esd = new AliESDEvent(); |
53ec9628 | 1845 | esd->ReadFromTree(t); |
f29f1726 | 1846 | |
53ec9628 | 1847 | Int_t nEvents = t->GetEntries(); |
f29f1726 | 1848 | |
1849 | // set arrays and pointers | |
1850 | Float_t posF[3]; | |
1851 | Double_t pos[3]; | |
1852 | Double_t p[3]; | |
1853 | Double_t covVtx[6]; | |
1854 | Double_t covTr[21]; | |
1855 | Double_t pid[10]; | |
1856 | ||
1857 | // loop over events and fill them | |
1858 | for (Int_t iEvent = 0; iEvent < nEvents; ++iEvent) { | |
53ec9628 | 1859 | t->GetEntry(iEvent); |
f29f1726 | 1860 | |
1861 | // Multiplicity information needed by the header (to be revised!) | |
1862 | Int_t nTracks = esd->GetNumberOfTracks(); | |
1863 | Int_t nPosTracks = 0; | |
1864 | for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) | |
b97637d4 | 1865 | if (esd->GetTrack(iTrack)->Charge()> 0) nPosTracks++; |
f29f1726 | 1866 | |
85ba66b8 | 1867 | // Access the header |
1868 | AliAODHeader *header = aod->GetHeader(); | |
1869 | ||
1870 | // fill the header | |
ade23daf | 1871 | header->SetRunNumber (esd->GetRunNumber() ); |
1872 | header->SetBunchCrossNumber(esd->GetBunchCrossNumber()); | |
1873 | header->SetOrbitNumber (esd->GetOrbitNumber() ); | |
1874 | header->SetPeriodNumber (esd->GetPeriodNumber() ); | |
1875 | header->SetTriggerMask (esd->GetTriggerMask() ); | |
1876 | header->SetTriggerCluster (esd->GetTriggerCluster() ); | |
1877 | header->SetEventType (esd->GetEventType() ); | |
1878 | header->SetMagneticField (esd->GetMagneticField() ); | |
1879 | header->SetZDCN1Energy (esd->GetZDCN1Energy() ); | |
1880 | header->SetZDCP1Energy (esd->GetZDCP1Energy() ); | |
1881 | header->SetZDCN2Energy (esd->GetZDCN2Energy() ); | |
1882 | header->SetZDCP2Energy (esd->GetZDCP2Energy() ); | |
1883 | header->SetZDCEMEnergy (esd->GetZDCEMEnergy() ); | |
a1d4139d | 1884 | header->SetRefMultiplicity (nTracks); |
1885 | header->SetRefMultiplicityPos(nPosTracks); | |
1886 | header->SetRefMultiplicityNeg(nTracks - nPosTracks); | |
1887 | header->SetMuonMagFieldScale(-999.); // FIXME | |
1888 | header->SetCentrality(-999.); // FIXME | |
f29f1726 | 1889 | |
1890 | Int_t nV0s = esd->GetNumberOfV0s(); | |
1891 | Int_t nCascades = esd->GetNumberOfCascades(); | |
1892 | Int_t nKinks = esd->GetNumberOfKinks(); | |
1893 | Int_t nVertices = nV0s + nCascades + nKinks; | |
1894 | ||
1895 | aod->ResetStd(nTracks, nVertices); | |
1896 | AliAODTrack *aodTrack; | |
1897 | ||
f29f1726 | 1898 | // Array to take into account the tracks already added to the AOD |
1899 | Bool_t * usedTrack = NULL; | |
1900 | if (nTracks>0) { | |
1901 | usedTrack = new Bool_t[nTracks]; | |
1902 | for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) usedTrack[iTrack]=kFALSE; | |
1903 | } | |
1904 | // Array to take into account the V0s already added to the AOD | |
1905 | Bool_t * usedV0 = NULL; | |
1906 | if (nV0s>0) { | |
1907 | usedV0 = new Bool_t[nV0s]; | |
1908 | for (Int_t iV0=0; iV0<nV0s; ++iV0) usedV0[iV0]=kFALSE; | |
1909 | } | |
1910 | // Array to take into account the kinks already added to the AOD | |
1911 | Bool_t * usedKink = NULL; | |
1912 | if (nKinks>0) { | |
1913 | usedKink = new Bool_t[nKinks]; | |
1914 | for (Int_t iKink=0; iKink<nKinks; ++iKink) usedKink[iKink]=kFALSE; | |
1915 | } | |
1916 | ||
1917 | // Access to the AOD container of vertices | |
1918 | TClonesArray &vertices = *(aod->GetVertices()); | |
1919 | Int_t jVertices=0; | |
1920 | ||
1921 | // Access to the AOD container of tracks | |
1922 | TClonesArray &tracks = *(aod->GetTracks()); | |
1923 | Int_t jTracks=0; | |
1924 | ||
1925 | // Add primary vertex. The primary tracks will be defined | |
1926 | // after the loops on the composite objects (V0, cascades, kinks) | |
1927 | const AliESDVertex *vtx = esd->GetPrimaryVertex(); | |
1928 | ||
1929 | vtx->GetXYZ(pos); // position | |
1930 | vtx->GetCovMatrix(covVtx); //covariance matrix | |
1931 | ||
1932 | AliAODVertex * primary = new(vertices[jVertices++]) | |
02153d58 | 1933 | AliAODVertex(pos, covVtx, vtx->GetChi2toNDF(), NULL, -1, AliAODVertex::kPrimary); |
f29f1726 | 1934 | |
1935 | // Create vertices starting from the most complex objects | |
1936 | ||
1937 | // Cascades | |
1938 | for (Int_t nCascade = 0; nCascade < nCascades; ++nCascade) { | |
1939 | AliESDcascade *cascade = esd->GetCascade(nCascade); | |
1940 | ||
1941 | cascade->GetXYZ(pos[0], pos[1], pos[2]); | |
1942 | cascade->GetPosCovXi(covVtx); | |
1943 | ||
1944 | // Add the cascade vertex | |
1945 | AliAODVertex * vcascade = new(vertices[jVertices++]) AliAODVertex(pos, | |
1946 | covVtx, | |
1947 | cascade->GetChi2Xi(), // = chi2/NDF since NDF = 2*2-3 | |
1948 | primary, | |
02153d58 | 1949 | nCascade, |
f29f1726 | 1950 | AliAODVertex::kCascade); |
1951 | ||
1952 | primary->AddDaughter(vcascade); | |
1953 | ||
1954 | // Add the V0 from the cascade. The ESD class have to be optimized... | |
85ba66b8 | 1955 | // Now we have to search for the corresponding V0 in the list of V0s |
f29f1726 | 1956 | // using the indeces of the positive and negative tracks |
1957 | ||
1958 | Int_t posFromV0 = cascade->GetPindex(); | |
1959 | Int_t negFromV0 = cascade->GetNindex(); | |
1960 | ||
1961 | ||
1962 | AliESDv0 * v0 = 0x0; | |
1963 | Int_t indV0 = -1; | |
1964 | ||
1965 | for (Int_t iV0=0; iV0<nV0s; ++iV0) { | |
1966 | ||
1967 | v0 = esd->GetV0(iV0); | |
1968 | Int_t posV0 = v0->GetPindex(); | |
1969 | Int_t negV0 = v0->GetNindex(); | |
1970 | ||
1971 | if (posV0==posFromV0 && negV0==negFromV0) { | |
1972 | indV0 = iV0; | |
1973 | break; | |
1974 | } | |
1975 | } | |
1976 | ||
1977 | AliAODVertex * vV0FromCascade = 0x0; | |
1978 | ||
1979 | if (indV0>-1 && !usedV0[indV0] ) { | |
1980 | ||
1981 | // the V0 exists in the array of V0s and is not used | |
1982 | ||
1983 | usedV0[indV0] = kTRUE; | |
1984 | ||
1985 | v0->GetXYZ(pos[0], pos[1], pos[2]); | |
1986 | v0->GetPosCov(covVtx); | |
1987 | ||
1988 | vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos, | |
1989 | covVtx, | |
1990 | v0->GetChi2V0(), // = chi2/NDF since NDF = 2*2-3 | |
1991 | vcascade, | |
02153d58 | 1992 | indV0, |
f29f1726 | 1993 | AliAODVertex::kV0); |
1994 | } else { | |
1995 | ||
1996 | // the V0 doesn't exist in the array of V0s or was used | |
1997 | cerr << "Error: event " << iEvent << " cascade " << nCascade | |
1998 | << " The V0 " << indV0 | |
1999 | << " doesn't exist in the array of V0s or was used!" << endl; | |
2000 | ||
2001 | cascade->GetXYZ(pos[0], pos[1], pos[2]); | |
2002 | cascade->GetPosCov(covVtx); | |
2003 | ||
2004 | vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos, | |
2005 | covVtx, | |
2006 | v0->GetChi2V0(), // = chi2/NDF since NDF = 2*2-3 | |
2007 | vcascade, | |
02153d58 | 2008 | indV0, |
f29f1726 | 2009 | AliAODVertex::kV0); |
2010 | vcascade->AddDaughter(vV0FromCascade); | |
2011 | } | |
2012 | ||
2013 | // Add the positive tracks from the V0 | |
2014 | ||
2015 | if (! usedTrack[posFromV0]) { | |
2016 | ||
2017 | usedTrack[posFromV0] = kTRUE; | |
2018 | ||
2019 | AliESDtrack *esdTrack = esd->GetTrack(posFromV0); | |
2020 | esdTrack->GetPxPyPz(p); | |
2021 | esdTrack->GetXYZ(pos); | |
2022 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
2023 | esdTrack->GetESDpid(pid); | |
2024 | ||
2025 | vV0FromCascade->AddDaughter(aodTrack = | |
2026 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
2027 | esdTrack->GetLabel(), | |
2028 | p, | |
2029 | kTRUE, | |
2030 | pos, | |
2031 | kFALSE, | |
2032 | covTr, | |
b97637d4 | 2033 | (Short_t)esdTrack->Charge(), |
f29f1726 | 2034 | esdTrack->GetITSClusterMap(), |
2035 | pid, | |
2036 | vV0FromCascade, | |
2037 | kTRUE, // check if this is right | |
2038 | kFALSE, // check if this is right | |
2039 | AliAODTrack::kSecondary) | |
2040 | ); | |
2041 | aodTrack->ConvertAliPIDtoAODPID(); | |
2042 | } | |
2043 | else { | |
2044 | cerr << "Error: event " << iEvent << " cascade " << nCascade | |
2045 | << " track " << posFromV0 << " has already been used!" << endl; | |
2046 | } | |
2047 | ||
2048 | // Add the negative tracks from the V0 | |
2049 | ||
2050 | if (!usedTrack[negFromV0]) { | |
2051 | ||
2052 | usedTrack[negFromV0] = kTRUE; | |
2053 | ||
2054 | AliESDtrack *esdTrack = esd->GetTrack(negFromV0); | |
2055 | esdTrack->GetPxPyPz(p); | |
2056 | esdTrack->GetXYZ(pos); | |
2057 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
2058 | esdTrack->GetESDpid(pid); | |
2059 | ||
2060 | vV0FromCascade->AddDaughter(aodTrack = | |
2061 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
2062 | esdTrack->GetLabel(), | |
2063 | p, | |
2064 | kTRUE, | |
2065 | pos, | |
2066 | kFALSE, | |
2067 | covTr, | |
b97637d4 | 2068 | (Short_t)esdTrack->Charge(), |
f29f1726 | 2069 | esdTrack->GetITSClusterMap(), |
2070 | pid, | |
2071 | vV0FromCascade, | |
2072 | kTRUE, // check if this is right | |
2073 | kFALSE, // check if this is right | |
2074 | AliAODTrack::kSecondary) | |
2075 | ); | |
2076 | aodTrack->ConvertAliPIDtoAODPID(); | |
2077 | } | |
2078 | else { | |
2079 | cerr << "Error: event " << iEvent << " cascade " << nCascade | |
2080 | << " track " << negFromV0 << " has already been used!" << endl; | |
2081 | } | |
2082 | ||
2083 | // Add the bachelor track from the cascade | |
2084 | ||
2085 | Int_t bachelor = cascade->GetBindex(); | |
2086 | ||
2087 | if(!usedTrack[bachelor]) { | |
2088 | ||
2089 | usedTrack[bachelor] = kTRUE; | |
2090 | ||
2091 | AliESDtrack *esdTrack = esd->GetTrack(bachelor); | |
2092 | esdTrack->GetPxPyPz(p); | |
2093 | esdTrack->GetXYZ(pos); | |
2094 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
2095 | esdTrack->GetESDpid(pid); | |
2096 | ||
2097 | vcascade->AddDaughter(aodTrack = | |
2098 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
2099 | esdTrack->GetLabel(), | |
2100 | p, | |
2101 | kTRUE, | |
2102 | pos, | |
2103 | kFALSE, | |
2104 | covTr, | |
b97637d4 | 2105 | (Short_t)esdTrack->Charge(), |
f29f1726 | 2106 | esdTrack->GetITSClusterMap(), |
2107 | pid, | |
2108 | vcascade, | |
2109 | kTRUE, // check if this is right | |
2110 | kFALSE, // check if this is right | |
2111 | AliAODTrack::kSecondary) | |
2112 | ); | |
2113 | aodTrack->ConvertAliPIDtoAODPID(); | |
2114 | } | |
2115 | else { | |
2116 | cerr << "Error: event " << iEvent << " cascade " << nCascade | |
2117 | << " track " << bachelor << " has already been used!" << endl; | |
2118 | } | |
2119 | ||
2120 | // Add the primary track of the cascade (if any) | |
2121 | ||
2122 | } // end of the loop on cascades | |
2123 | ||
2124 | // V0s | |
2125 | ||
2126 | for (Int_t nV0 = 0; nV0 < nV0s; ++nV0) { | |
2127 | ||
2128 | if (usedV0[nV0]) continue; // skip if aready added to the AOD | |
2129 | ||
2130 | AliESDv0 *v0 = esd->GetV0(nV0); | |
2131 | ||
2132 | v0->GetXYZ(pos[0], pos[1], pos[2]); | |
2133 | v0->GetPosCov(covVtx); | |
2134 | ||
2135 | AliAODVertex * vV0 = | |
2136 | new(vertices[jVertices++]) AliAODVertex(pos, | |
2137 | covVtx, | |
2138 | v0->GetChi2V0(), // = chi2/NDF since NDF = 2*2-3 | |
2139 | primary, | |
02153d58 | 2140 | nV0, |
f29f1726 | 2141 | AliAODVertex::kV0); |
2142 | primary->AddDaughter(vV0); | |
2143 | ||
2144 | Int_t posFromV0 = v0->GetPindex(); | |
2145 | Int_t negFromV0 = v0->GetNindex(); | |
2146 | ||
2147 | // Add the positive tracks from the V0 | |
2148 | ||
2149 | if (!usedTrack[posFromV0]) { | |
2150 | ||
2151 | usedTrack[posFromV0] = kTRUE; | |
2152 | ||
2153 | AliESDtrack *esdTrack = esd->GetTrack(posFromV0); | |
2154 | esdTrack->GetPxPyPz(p); | |
2155 | esdTrack->GetXYZ(pos); | |
2156 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
2157 | esdTrack->GetESDpid(pid); | |
2158 | ||
2159 | vV0->AddDaughter(aodTrack = | |
2160 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
2161 | esdTrack->GetLabel(), | |
2162 | p, | |
2163 | kTRUE, | |
2164 | pos, | |
2165 | kFALSE, | |
2166 | covTr, | |
b97637d4 | 2167 | (Short_t)esdTrack->Charge(), |
f29f1726 | 2168 | esdTrack->GetITSClusterMap(), |
2169 | pid, | |
2170 | vV0, | |
2171 | kTRUE, // check if this is right | |
2172 | kFALSE, // check if this is right | |
2173 | AliAODTrack::kSecondary) | |
2174 | ); | |
2175 | aodTrack->ConvertAliPIDtoAODPID(); | |
2176 | } | |
2177 | else { | |
2178 | cerr << "Error: event " << iEvent << " V0 " << nV0 | |
2179 | << " track " << posFromV0 << " has already been used!" << endl; | |
2180 | } | |
a7807689 | 2181 | |
f29f1726 | 2182 | // Add the negative tracks from the V0 |
2183 | ||
2184 | if (!usedTrack[negFromV0]) { | |
2185 | ||
2186 | usedTrack[negFromV0] = kTRUE; | |
2187 | ||
2188 | AliESDtrack *esdTrack = esd->GetTrack(negFromV0); | |
2189 | esdTrack->GetPxPyPz(p); | |
2190 | esdTrack->GetXYZ(pos); | |
2191 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
2192 | esdTrack->GetESDpid(pid); | |
2193 | ||
2194 | vV0->AddDaughter(aodTrack = | |
2195 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
2196 | esdTrack->GetLabel(), | |
2197 | p, | |
2198 | kTRUE, | |
2199 | pos, | |
2200 | kFALSE, | |
2201 | covTr, | |
b97637d4 | 2202 | (Short_t)esdTrack->Charge(), |
f29f1726 | 2203 | esdTrack->GetITSClusterMap(), |
2204 | pid, | |
2205 | vV0, | |
2206 | kTRUE, // check if this is right | |
2207 | kFALSE, // check if this is right | |
2208 | AliAODTrack::kSecondary) | |
2209 | ); | |
2210 | aodTrack->ConvertAliPIDtoAODPID(); | |
2211 | } | |
2212 | else { | |
2213 | cerr << "Error: event " << iEvent << " V0 " << nV0 | |
2214 | << " track " << negFromV0 << " has already been used!" << endl; | |
2215 | } | |
2216 | ||
2217 | } // end of the loop on V0s | |
2218 | ||
2219 | // Kinks: it is a big mess the access to the information in the kinks | |
2220 | // The loop is on the tracks in order to find the mother and daugther of each kink | |
2221 | ||
2222 | ||
2223 | for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) { | |
2224 | ||
2225 | ||
2226 | AliESDtrack * esdTrack = esd->GetTrack(iTrack); | |
2227 | ||
2228 | Int_t ikink = esdTrack->GetKinkIndex(0); | |
2229 | ||
2230 | if (ikink) { | |
2231 | // Negative kink index: mother, positive: daughter | |
2232 | ||
2233 | // Search for the second track of the kink | |
2234 | ||
2235 | for (Int_t jTrack = iTrack+1; jTrack<nTracks; ++jTrack) { | |
2236 | ||
2237 | AliESDtrack * esdTrack1 = esd->GetTrack(jTrack); | |
2238 | ||
2239 | Int_t jkink = esdTrack1->GetKinkIndex(0); | |
2240 | ||
2241 | if ( TMath::Abs(ikink)==TMath::Abs(jkink) ) { | |
2242 | ||
2243 | // The two tracks are from the same kink | |
2244 | ||
2245 | if (usedKink[TMath::Abs(ikink)-1]) continue; // skip used kinks | |
2246 | ||
2247 | Int_t imother = -1; | |
2248 | Int_t idaughter = -1; | |
2249 | ||
2250 | if (ikink<0 && jkink>0) { | |
2251 | ||
2252 | imother = iTrack; | |
2253 | idaughter = jTrack; | |
2254 | } | |
2255 | else if (ikink>0 && jkink<0) { | |
2256 | ||
2257 | imother = jTrack; | |
2258 | idaughter = iTrack; | |
2259 | } | |
2260 | else { | |
2261 | cerr << "Error: Wrong combination of kink indexes: " | |
2262 | << ikink << " " << jkink << endl; | |
2263 | continue; | |
2264 | } | |
2265 | ||
2266 | // Add the mother track | |
2267 | ||
2268 | AliAODTrack * mother = NULL; | |
2269 | ||
2270 | if (!usedTrack[imother]) { | |
2271 | ||
2272 | usedTrack[imother] = kTRUE; | |
2273 | ||
2274 | AliESDtrack *esdTrack = esd->GetTrack(imother); | |
2275 | esdTrack->GetPxPyPz(p); | |
2276 | esdTrack->GetXYZ(pos); | |
2277 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
2278 | esdTrack->GetESDpid(pid); | |
2279 | ||
2280 | mother = | |
2281 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
2282 | esdTrack->GetLabel(), | |
2283 | p, | |
2284 | kTRUE, | |
2285 | pos, | |
2286 | kFALSE, | |
2287 | covTr, | |
b97637d4 | 2288 | (Short_t)esdTrack->Charge(), |
f29f1726 | 2289 | esdTrack->GetITSClusterMap(), |
2290 | pid, | |
2291 | primary, | |
2292 | kTRUE, // check if this is right | |
2293 | kTRUE, // check if this is right | |
2294 | AliAODTrack::kPrimary); | |
2295 | primary->AddDaughter(mother); | |
2296 | mother->ConvertAliPIDtoAODPID(); | |
2297 | } | |
2298 | else { | |
2299 | cerr << "Error: event " << iEvent << " kink " << TMath::Abs(ikink)-1 | |
2300 | << " track " << imother << " has already been used!" << endl; | |
2301 | } | |
2302 | ||
2303 | // Add the kink vertex | |
2304 | AliESDkink * kink = esd->GetKink(TMath::Abs(ikink)-1); | |
2305 | ||
2306 | AliAODVertex * vkink = | |
2307 | new(vertices[jVertices++]) AliAODVertex(kink->GetPosition(), | |
2308 | NULL, | |
2309 | 0., | |
2310 | mother, | |
02153d58 | 2311 | esdTrack->GetID(), // This is the track ID of the mother's track! |
f29f1726 | 2312 | AliAODVertex::kKink); |
2313 | // Add the daughter track | |
2314 | ||
2315 | AliAODTrack * daughter = NULL; | |
2316 | ||
2317 | if (!usedTrack[idaughter]) { | |
2318 | ||
2319 | usedTrack[idaughter] = kTRUE; | |
2320 | ||
2321 | AliESDtrack *esdTrack = esd->GetTrack(idaughter); | |
2322 | esdTrack->GetPxPyPz(p); | |
2323 | esdTrack->GetXYZ(pos); | |
2324 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
2325 | esdTrack->GetESDpid(pid); | |
2326 | ||
2327 | daughter = | |
2328 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
2329 | esdTrack->GetLabel(), | |
2330 | p, | |
2331 | kTRUE, | |
2332 | pos, | |
2333 | kFALSE, | |
2334 | covTr, | |
b97637d4 | 2335 | (Short_t)esdTrack->Charge(), |
f29f1726 | 2336 | esdTrack->GetITSClusterMap(), |
2337 | pid, | |
2338 | vkink, | |
2339 | kTRUE, // check if this is right | |
2340 | kTRUE, // check if this is right | |
2341 | AliAODTrack::kPrimary); | |
2342 | vkink->AddDaughter(daughter); | |
2343 | daughter->ConvertAliPIDtoAODPID(); | |
2344 | } | |
2345 | else { | |
2346 | cerr << "Error: event " << iEvent << " kink " << TMath::Abs(ikink)-1 | |
2347 | << " track " << idaughter << " has already been used!" << endl; | |
2348 | } | |
2349 | ||
2350 | ||
2351 | } | |
2352 | } | |
2353 | ||
2354 | } | |
2355 | ||
2356 | } | |
2357 | ||
2358 | ||
2359 | // Tracks (primary and orphan) | |
2360 | ||
2361 | for (Int_t nTrack = 0; nTrack < nTracks; ++nTrack) { | |
2362 | ||
2363 | ||
2364 | if (usedTrack[nTrack]) continue; | |
2365 | ||
2366 | AliESDtrack *esdTrack = esd->GetTrack(nTrack); | |
2367 | esdTrack->GetPxPyPz(p); | |
2368 | esdTrack->GetXYZ(pos); | |
2369 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
2370 | esdTrack->GetESDpid(pid); | |
2371 | ||
2372 | Float_t impactXY, impactZ; | |
2373 | ||
2374 | esdTrack->GetImpactParameters(impactXY,impactZ); | |
2375 | ||
2376 | if (impactXY<3) { | |
2377 | // track inside the beam pipe | |
2378 | ||
2379 | primary->AddDaughter(aodTrack = | |
2380 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
2381 | esdTrack->GetLabel(), | |
2382 | p, | |
2383 | kTRUE, | |
2384 | pos, | |
2385 | kFALSE, | |
2386 | covTr, | |
b97637d4 | 2387 | (Short_t)esdTrack->Charge(), |
f29f1726 | 2388 | esdTrack->GetITSClusterMap(), |
2389 | pid, | |
2390 | primary, | |
2391 | kTRUE, // check if this is right | |
2392 | kTRUE, // check if this is right | |
2393 | AliAODTrack::kPrimary) | |
2394 | ); | |
2395 | aodTrack->ConvertAliPIDtoAODPID(); | |
2396 | } | |
2397 | else { | |
2398 | // outside the beam pipe: orphan track | |
2399 | aodTrack = | |
2400 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
2401 | esdTrack->GetLabel(), | |
2402 | p, | |
2403 | kTRUE, | |
2404 | pos, | |
2405 | kFALSE, | |
2406 | covTr, | |
b97637d4 | 2407 | (Short_t)esdTrack->Charge(), |
f29f1726 | 2408 | esdTrack->GetITSClusterMap(), |
2409 | pid, | |
2410 | NULL, | |
2411 | kFALSE, // check if this is right | |
2412 | kFALSE, // check if this is right | |
2413 | AliAODTrack::kOrphan); | |
2414 | aodTrack->ConvertAliPIDtoAODPID(); | |
2415 | } | |
2416 | } // end of loop on tracks | |
2417 | ||
2418 | // muon tracks | |
2419 | Int_t nMuTracks = esd->GetNumberOfMuonTracks(); | |
2420 | for (Int_t nMuTrack = 0; nMuTrack < nMuTracks; ++nMuTrack) { | |
2421 | ||
2422 | AliESDMuonTrack *esdMuTrack = esd->GetMuonTrack(nMuTrack); | |
2423 | p[0] = esdMuTrack->Px(); | |
2424 | p[1] = esdMuTrack->Py(); | |
2425 | p[2] = esdMuTrack->Pz(); | |
2426 | pos[0] = primary->GetX(); | |
2427 | pos[1] = primary->GetY(); | |
2428 | pos[2] = primary->GetZ(); | |
2429 | ||
2430 | // has to be changed once the muon pid is provided by the ESD | |
2431 | for (Int_t i = 0; i < 10; pid[i++] = 0.); pid[AliAODTrack::kMuon]=1.; | |
2432 | ||
85ba66b8 | 2433 | primary->AddDaughter(aodTrack = |
f29f1726 | 2434 | new(tracks[jTracks++]) AliAODTrack(0, // no ID provided |
2435 | 0, // no label provided | |
2436 | p, | |
2437 | kTRUE, | |
2438 | pos, | |
2439 | kFALSE, | |
2440 | NULL, // no covariance matrix provided | |
b97637d4 | 2441 | esdMuTrack->Charge(), |
e704c7d4 | 2442 | 0, // ITSClusterMap is set below |
f29f1726 | 2443 | pid, |
2444 | primary, | |
85ba66b8 | 2445 | kFALSE, // muon tracks are not used to fit the primary vtx |
2446 | kFALSE, // not used for vertex fit | |
f29f1726 | 2447 | AliAODTrack::kPrimary) |
2448 | ); | |
85ba66b8 | 2449 | |
2450 | aodTrack->SetHitsPatternInTrigCh(esdMuTrack->GetHitsPatternInTrigCh()); | |
2451 | Int_t track2Trigger = esdMuTrack->GetMatchTrigger(); | |
2452 | aodTrack->SetMatchTrigger(track2Trigger); | |
2453 | if (track2Trigger) | |
2454 | aodTrack->SetChi2MatchTrigger(esdMuTrack->GetChi2MatchTrigger()); | |
2455 | else | |
2456 | aodTrack->SetChi2MatchTrigger(0.); | |
f29f1726 | 2457 | } |
2458 | ||
2459 | // Access to the AOD container of clusters | |
2460 | TClonesArray &clusters = *(aod->GetClusters()); | |
2461 | Int_t jClusters=0; | |
2462 | ||
2463 | // Calo Clusters | |
2464 | Int_t nClusters = esd->GetNumberOfCaloClusters(); | |
2465 | ||
2466 | for (Int_t iClust=0; iClust<nClusters; ++iClust) { | |
2467 | ||
2468 | AliESDCaloCluster * cluster = esd->GetCaloCluster(iClust); | |
2469 | ||
2470 | Int_t id = cluster->GetID(); | |
2471 | Int_t label = -1; | |
53ec9628 | 2472 | Float_t energy = cluster->E(); |
2473 | cluster->GetPosition(posF); | |
f29f1726 | 2474 | AliAODVertex *prodVertex = primary; |
2475 | AliAODTrack *primTrack = NULL; | |
2476 | Char_t ttype=AliAODCluster::kUndef; | |
85ba66b8 | 2477 | |
f29f1726 | 2478 | if (cluster->IsPHOS()) ttype=AliAODCluster::kPHOSNeutral; |
2479 | else if (cluster->IsEMCAL()) { | |
85ba66b8 | 2480 | |
f29f1726 | 2481 | if (cluster->GetClusterType() == AliESDCaloCluster::kPseudoCluster) |
2482 | ttype = AliAODCluster::kEMCALPseudoCluster; | |
2483 | else | |
2484 | ttype = AliAODCluster::kEMCALClusterv1; | |
85ba66b8 | 2485 | |
f29f1726 | 2486 | } |
85ba66b8 | 2487 | |
f29f1726 | 2488 | new(clusters[jClusters++]) AliAODCluster(id, |
2489 | label, | |
2490 | energy, | |
2491 | pos, | |
2492 | NULL, // no covariance matrix provided | |
2493 | NULL, // no pid for clusters provided | |
2494 | prodVertex, | |
2495 | primTrack, | |
2496 | ttype); | |
85ba66b8 | 2497 | |
f29f1726 | 2498 | } // end of loop on calo clusters |
85ba66b8 | 2499 | |
2500 | // tracklets | |
2501 | const AliMultiplicity *mult = esd->GetMultiplicity(); | |
2502 | if (mult) { | |
2503 | if (mult->GetNumberOfTracklets()>0) { | |
2504 | aod->GetTracklets()->CreateContainer(mult->GetNumberOfTracklets()); | |
2505 | ||
2506 | for (Int_t n=0; n<mult->GetNumberOfTracklets(); n++) { | |
2507 | aod->GetTracklets()->SetTracklet(n, mult->GetTheta(n), mult->GetPhi(n), mult->GetDeltaPhi(n), mult->GetLabel(n)); | |
2508 | } | |
2509 | } | |
2510 | } else { | |
2511 | Printf("ERROR: AliMultiplicity could not be retrieved from ESD"); | |
2512 | } | |
2513 | ||
f29f1726 | 2514 | delete [] usedTrack; |
2515 | delete [] usedV0; | |
2516 | delete [] usedKink; | |
85ba66b8 | 2517 | |
f29f1726 | 2518 | // fill the tree for this event |
2519 | aodTree->Fill(); | |
2520 | } // end of event loop | |
85ba66b8 | 2521 | |
f29f1726 | 2522 | aodTree->GetUserInfo()->Add(aod); |
85ba66b8 | 2523 | |
f29f1726 | 2524 | // close ESD file |
2525 | esdFile->Close(); | |
85ba66b8 | 2526 | |
f29f1726 | 2527 | // write the tree to the specified file |
2528 | aodFile = aodTree->GetCurrentFile(); | |
2529 | aodFile->cd(); | |
2530 | aodTree->Write(); | |
85ba66b8 | 2531 | |
a7807689 | 2532 | return; |
2533 | } | |
2534 | ||
af885e0f | 2535 | void AliReconstruction::WriteAlignmentData(AliESDEvent* esd) |
98937d93 | 2536 | { |
2537 | // Write space-points which are then used in the alignment procedures | |
2538 | // For the moment only ITS, TRD and TPC | |
2539 | ||
2540 | // Load TOF clusters | |
d528ee75 | 2541 | if (fTracker[3]){ |
2542 | fLoader[3]->LoadRecPoints("read"); | |
2543 | TTree* tree = fLoader[3]->TreeR(); | |
2544 | if (!tree) { | |
2545 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[3])); | |
2546 | return; | |
2547 | } | |
2548 | fTracker[3]->LoadClusters(tree); | |
98937d93 | 2549 | } |
98937d93 | 2550 | Int_t ntracks = esd->GetNumberOfTracks(); |
2551 | for (Int_t itrack = 0; itrack < ntracks; itrack++) | |
2552 | { | |
2553 | AliESDtrack *track = esd->GetTrack(itrack); | |
2554 | Int_t nsp = 0; | |
ef7253ac | 2555 | Int_t idx[200]; |
98937d93 | 2556 | for (Int_t iDet = 3; iDet >= 0; iDet--) |
2557 | nsp += track->GetNcls(iDet); | |
2558 | if (nsp) { | |
2559 | AliTrackPointArray *sp = new AliTrackPointArray(nsp); | |
2560 | track->SetTrackPointArray(sp); | |
2561 | Int_t isptrack = 0; | |
2562 | for (Int_t iDet = 3; iDet >= 0; iDet--) { | |
2563 | AliTracker *tracker = fTracker[iDet]; | |
2564 | if (!tracker) continue; | |
2565 | Int_t nspdet = track->GetNcls(iDet); | |
98937d93 | 2566 | if (nspdet <= 0) continue; |
2567 | track->GetClusters(iDet,idx); | |
2568 | AliTrackPoint p; | |
2569 | Int_t isp = 0; | |
2570 | Int_t isp2 = 0; | |
2571 | while (isp < nspdet) { | |
2572 | Bool_t isvalid = tracker->GetTrackPoint(idx[isp2],p); isp2++; | |
160db090 | 2573 | const Int_t kNTPCmax = 159; |
2574 | if (iDet==1 && isp2>kNTPCmax) break; // to be fixed | |
98937d93 | 2575 | if (!isvalid) continue; |
2576 | sp->AddPoint(isptrack,&p); isptrack++; isp++; | |
2577 | } | |
98937d93 | 2578 | } |
2579 | } | |
2580 | } | |
d528ee75 | 2581 | if (fTracker[3]){ |
2582 | fTracker[3]->UnloadClusters(); | |
2583 | fLoader[3]->UnloadRecPoints(); | |
2584 | } | |
98937d93 | 2585 | } |
2e3550da | 2586 | |
2587 | //_____________________________________________________________________________ | |
af885e0f | 2588 | void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd) |
2e3550da | 2589 | { |
2590 | // The method reads the raw-data error log | |
2591 | // accumulated within the rawReader. | |
2592 | // It extracts the raw-data errors related to | |
2593 | // the current event and stores them into | |
2594 | // a TClonesArray inside the esd object. | |
2595 | ||
2596 | if (!fRawReader) return; | |
2597 | ||
2598 | for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) { | |
2599 | ||
2600 | AliRawDataErrorLog *log = fRawReader->GetErrorLog(i); | |
2601 | if (!log) continue; | |
2602 | if (iEvent != log->GetEventNumber()) continue; | |
2603 | ||
2604 | esd->AddRawDataErrorLog(log); | |
2605 | } | |
2606 | ||
2607 | } | |
46698ae4 | 2608 | |
2609 | TNamed* AliReconstruction::CopyFileToTNamed(TString fPath,TString fName){ | |
b545009a | 2610 | // Dump a file content into a char in TNamed |
46698ae4 | 2611 | ifstream in; |
2612 | in.open(fPath.Data(),ios::in | ios::binary|ios::ate); | |
2613 | Int_t kBytes = (Int_t)in.tellg(); | |
2614 | printf("Size: %d \n",kBytes); | |
2615 | TNamed *fn = 0; | |
2616 | if(in.good()){ | |
2617 | char* memblock = new char [kBytes]; | |
2618 | in.seekg (0, ios::beg); | |
2619 | in.read (memblock, kBytes); | |
2620 | in.close(); | |
2621 | TString fData(memblock,kBytes); | |
2622 | fn = new TNamed(fName,fData); | |
2623 | printf("fData Size: %d \n",fData.Sizeof()); | |
2624 | printf("fName Size: %d \n",fName.Sizeof()); | |
2625 | printf("fn Size: %d \n",fn->Sizeof()); | |
2626 | delete[] memblock; | |
2627 | } | |
2628 | else{ | |
2629 | AliInfo(Form("Could not Open %s\n",fPath.Data())); | |
2630 | } | |
2631 | ||
2632 | return fn; | |
2633 | } | |
2634 | ||
2635 | void AliReconstruction::TNamedToFile(TTree* fTree, TString fName){ | |
46698ae4 | 2636 | // This is not really needed in AliReconstruction at the moment |
2637 | // but can serve as a template | |
2638 | ||
2639 | TList *fList = fTree->GetUserInfo(); | |
2640 | TNamed *fn = (TNamed*)fList->FindObject(fName.Data()); | |
2641 | printf("fn Size: %d \n",fn->Sizeof()); | |
2642 | ||
2643 | TString fTmp(fn->GetName()); // to be 100% sure in principle fName also works | |
2644 | const char* cdata = fn->GetTitle(); | |
2645 | printf("fTmp Size %d\n",fTmp.Sizeof()); | |
2646 | ||
2647 | int size = fn->Sizeof()-fTmp.Sizeof()-sizeof(UChar_t)-sizeof(Int_t); // see dfinition of TString::SizeOf()... | |
2648 | printf("calculated size %d\n",size); | |
2649 | ofstream out(fName.Data(),ios::out | ios::binary); | |
2650 | out.write(cdata,size); | |
2651 | out.close(); | |
2652 | ||
2653 | } | |
2654 | ||
a5fa6165 | 2655 | //_____________________________________________________________________________ |
2656 | AliQualAssDataMaker * AliReconstruction::GetQualAssDataMaker(Int_t iDet) | |
2657 | { | |
2658 | // get the quality assurance data maker object and the loader for a detector | |
2659 | ||
2660 | if (fQualAssDataMaker[iDet]) | |
2661 | return fQualAssDataMaker[iDet]; | |
2662 | ||
2663 | // load the QA data maker object | |
2664 | TPluginManager* pluginManager = gROOT->GetPluginManager(); | |
2665 | TString detName = fgkDetectorName[iDet]; | |
2666 | TString qadmName = "Ali" + detName + "QualAssDataMaker"; | |
2667 | if (gAlice && !gAlice->GetDetector(detName) && (detName != "HLT")) | |
2668 | return NULL; | |
2669 | ||
2670 | AliQualAssDataMaker * qadm = NULL; | |
2671 | // first check if a plugin is defined for the quality assurance data maker | |
2672 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQualAssDataMaker", detName); | |
2673 | // if not, add a plugin for it | |
2674 | if (!pluginHandler) { | |
2675 | AliDebug(1, Form("defining plugin for %s", qadmName.Data())); | |
2676 | TString libs = gSystem->GetLibraries(); | |
2677 | if (libs.Contains("lib" + detName + "base.so") || | |
2678 | (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
2679 | pluginManager->AddHandler("AliQualAssDataMaker", detName, | |
2680 | qadmName, detName + "qadm", qadmName + "()"); | |
2681 | } else { | |
2682 | pluginManager->AddHandler("AliQualAssDataMaker", detName, | |
2683 | qadmName, detName, qadmName + "()"); | |
2684 | } | |
2685 | pluginHandler = pluginManager->FindHandler("AliQualAssDataMaker", detName); | |
2686 | } | |
2687 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
2688 | qadm = (AliQualAssDataMaker *) pluginHandler->ExecPlugin(0); | |
2689 | } | |
2690 | if (qadm) { | |
2691 | // TObject* obj = fOptions.FindObject(detName.Data()); | |
2692 | // if (obj) reconstructor->SetOption(obj->GetTitle()); | |
2693 | fQualAssDataMaker[iDet] = qadm; | |
2694 | } | |
2695 | ||
2696 | // get or create the loader | |
2697 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); | |
2698 | if (!fLoader[iDet]) { | |
2699 | AliConfig::Instance() | |
2700 | ->CreateDetectorFolders(fRunLoader->GetEventFolder(), | |
2701 | detName, detName); | |
2702 | // first check if a plugin is defined for the loader | |
2703 | pluginHandler = | |
2704 | pluginManager->FindHandler("AliLoader", detName); | |
2705 | // if not, add a plugin for it | |
2706 | if (!pluginHandler) { | |
2707 | TString loaderName = "Ali" + detName + "Loader"; | |
2708 | AliDebug(1, Form("defining plugin for %s", loaderName.Data())); | |
2709 | pluginManager->AddHandler("AliLoader", detName, | |
2710 | loaderName, detName + "base", | |
2711 | loaderName + "(const char*, TFolder*)"); | |
2712 | pluginHandler = pluginManager->FindHandler("AliLoader", detName); | |
2713 | } | |
2714 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
2715 | fLoader[iDet] = | |
2716 | (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(), | |
2717 | fRunLoader->GetEventFolder()); | |
2718 | } | |
2719 | if (!fLoader[iDet]) { // use default loader | |
2720 | fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder()); | |
2721 | } | |
2722 | if (!fLoader[iDet]) { | |
2723 | AliWarning(Form("couldn't get loader for %s", detName.Data())); | |
2724 | if (fStopOnError) return NULL; | |
2725 | } else { | |
2726 | fRunLoader->AddLoader(fLoader[iDet]); | |
2727 | fRunLoader->CdGAFile(); | |
2728 | if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE"); | |
2729 | fRunLoader->Write(0, TObject::kOverwrite); | |
2730 | } | |
2731 | } | |
2732 | ||
2733 | return qadm; | |
2734 | } | |
2735 | ||
2736 | //_____________________________________________________________________________ | |
2737 | Bool_t AliReconstruction::RunQualAss(const char* detectors, AliESDEvent *& esd) | |
2738 | { | |
2739 | // run the Quality Assurance data producer | |
2740 | ||
2741 | AliCodeTimerAuto("") | |
2742 | TString detStr = detectors; | |
2743 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
2744 | if (!IsSelected(fgkDetectorName[iDet], detStr)) | |
2745 | continue; | |
2746 | AliQualAssDataMaker * qadm = GetQualAssDataMaker(iDet); | |
2747 | if (!qadm) | |
2748 | continue; | |
2749 | AliCodeTimerStart(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); | |
2750 | AliInfo(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); | |
2751 | ||
2752 | qadm->SetData(esd) ; | |
2753 | qadm->Exec(AliQualAss::kESDS) ; | |
2754 | ||
2755 | AliCodeTimerStop(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); | |
2756 | } | |
2757 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
2758 | AliError(Form("the following detectors were not found: %s", | |
2759 | detStr.Data())); | |
2760 | if (fStopOnError) | |
2761 | return kFALSE; | |
2762 | } | |
2763 | ||
2764 | return kTRUE; | |
2765 | } |