]>
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 | // // | |
596a855f | 50 | // The name of the galice file can be changed from the default // |
e583c30d | 51 | // "galice.root" by passing it as argument to the AliReconstruction // |
52 | // constructor or by // | |
596a855f | 53 | // // |
54 | // rec.SetGAliceFile("..."); // | |
55 | // // | |
59697224 | 56 | // The local reconstruction can be switched on or off for individual // |
57 | // detectors by // | |
596a855f | 58 | // // |
59697224 | 59 | // rec.SetRunLocalReconstruction("..."); // |
596a855f | 60 | // // |
61 | // The argument is a (case sensitive) string with the names of the // | |
62 | // detectors separated by a space. The special string "ALL" selects all // | |
63 | // available detectors. This is the default. // | |
64 | // // | |
c71de921 | 65 | // The reconstruction of the primary vertex position can be switched off by // |
66 | // // | |
67 | // rec.SetRunVertexFinder(kFALSE); // | |
68 | // // | |
b8cd5251 | 69 | // The tracking and the creation of ESD tracks can be switched on for // |
70 | // selected detectors by // | |
596a855f | 71 | // // |
b8cd5251 | 72 | // rec.SetRunTracking("..."); // |
596a855f | 73 | // // |
c84a5e9e | 74 | // Uniform/nonuniform field tracking switches (default: uniform field) // |
75 | // // | |
1d99986f | 76 | // rec.SetUniformFieldTracking(); ( rec.SetUniformFieldTracking(kFALSE); ) // |
c84a5e9e | 77 | // // |
596a855f | 78 | // The filling of additional ESD information can be steered by // |
79 | // // | |
80 | // rec.SetFillESD("..."); // | |
81 | // // | |
b8cd5251 | 82 | // Again, for both methods the string specifies the list of detectors. // |
83 | // The default is "ALL". // | |
84 | // // | |
85 | // The call of the shortcut method // | |
86 | // // | |
87 | // rec.SetRunReconstruction("..."); // | |
88 | // // | |
89 | // is equivalent to calling SetRunLocalReconstruction, SetRunTracking and // | |
90 | // SetFillESD with the same detector selecting string as argument. // | |
596a855f | 91 | // // |
c71de921 | 92 | // The reconstruction requires digits or raw data as input. For the creation // |
93 | // of digits and raw data have a look at the class AliSimulation. // | |
596a855f | 94 | // // |
24f7a148 | 95 | // For debug purposes the method SetCheckPointLevel can be used. If the // |
96 | // argument is greater than 0, files with ESD events will be written after // | |
97 | // selected steps of the reconstruction for each event: // | |
98 | // level 1: after tracking and after filling of ESD (final) // | |
99 | // level 2: in addition after each tracking step // | |
100 | // level 3: in addition after the filling of ESD for each detector // | |
101 | // If a final check point file exists for an event, this event will be // | |
102 | // skipped in the reconstruction. The tracking and the filling of ESD for // | |
103 | // a detector will be skipped as well, if the corresponding check point // | |
104 | // file exists. The ESD event will then be loaded from the file instead. // | |
105 | // // | |
596a855f | 106 | /////////////////////////////////////////////////////////////////////////////// |
107 | ||
024a7e64 | 108 | #include <TArrayF.h> |
109 | #include <TFile.h> | |
110 | #include <TSystem.h> | |
111 | #include <TROOT.h> | |
112 | #include <TPluginManager.h> | |
fd46e2d2 | 113 | #include <TStopwatch.h> |
3103d196 | 114 | #include <TGeoManager.h> |
2bdb9d38 | 115 | #include <TLorentzVector.h> |
596a855f | 116 | |
117 | #include "AliReconstruction.h" | |
b8cd5251 | 118 | #include "AliReconstructor.h" |
815c2b38 | 119 | #include "AliLog.h" |
596a855f | 120 | #include "AliRunLoader.h" |
121 | #include "AliRun.h" | |
b649205a | 122 | #include "AliRawReaderFile.h" |
123 | #include "AliRawReaderDate.h" | |
124 | #include "AliRawReaderRoot.h" | |
596a855f | 125 | #include "AliESD.h" |
1d99986f | 126 | #include "AliESDfriend.h" |
2257f27e | 127 | #include "AliESDVertex.h" |
c84a5e9e | 128 | #include "AliTracker.h" |
2257f27e | 129 | #include "AliVertexer.h" |
c5e3e5d1 | 130 | #include "AliVertexerTracks.h" |
596a855f | 131 | #include "AliHeader.h" |
132 | #include "AliGenEventHeader.h" | |
b26c3770 | 133 | #include "AliPID.h" |
596a855f | 134 | #include "AliESDpid.h" |
ff8bb5ae | 135 | #include "AliESDtrack.h" |
f3a97c86 | 136 | |
137 | #include "AliRunTag.h" | |
f3a97c86 | 138 | #include "AliDetectorTag.h" |
139 | #include "AliEventTag.h" | |
140 | ||
98937d93 | 141 | #include "AliTrackPointArray.h" |
b0314964 | 142 | #include "AliCDBManager.h" |
6bae477a | 143 | #include "AliCDBEntry.h" |
144 | #include "AliAlignObj.h" | |
f3a97c86 | 145 | |
b647652d | 146 | #include "AliCentralTrigger.h" |
147 | #include "AliCTPRawStream.h" | |
148 | ||
596a855f | 149 | ClassImp(AliReconstruction) |
150 | ||
151 | ||
c757bafd | 152 | //_____________________________________________________________________________ |
482070f2 | 153 | const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "RICH", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "START", "VZERO", "CRT", "HLT"}; |
c757bafd | 154 | |
596a855f | 155 | //_____________________________________________________________________________ |
024cf675 | 156 | AliReconstruction::AliReconstruction(const char* gAliceFilename, const char* cdbUri, |
e583c30d | 157 | const char* name, const char* title) : |
158 | TNamed(name, title), | |
159 | ||
c84a5e9e | 160 | fUniformField(kTRUE), |
2257f27e | 161 | fRunVertexFinder(kTRUE), |
1f46a9ae | 162 | fRunHLTTracking(kFALSE), |
1d99986f | 163 | fStopOnError(kFALSE), |
164 | fWriteAlignmentData(kFALSE), | |
165 | fWriteESDfriend(kFALSE), | |
b647652d | 166 | fFillTriggerESD(kTRUE), |
1d99986f | 167 | |
168 | fRunLocalReconstruction("ALL"), | |
b8cd5251 | 169 | fRunTracking("ALL"), |
e583c30d | 170 | fFillESD("ALL"), |
171 | fGAliceFileName(gAliceFilename), | |
b649205a | 172 | fInput(""), |
35042093 | 173 | fEquipIdMap(""), |
b26c3770 | 174 | fFirstEvent(0), |
175 | fLastEvent(-1), | |
24f7a148 | 176 | fCheckPointLevel(0), |
b8cd5251 | 177 | fOptions(), |
6bae477a | 178 | fLoadAlignFromCDB(kTRUE), |
179 | fLoadAlignData("ALL"), | |
e583c30d | 180 | |
181 | fRunLoader(NULL), | |
b649205a | 182 | fRawReader(NULL), |
b8cd5251 | 183 | |
98937d93 | 184 | fVertexer(NULL), |
185 | ||
6bae477a | 186 | fAlignObjArray(NULL), |
ec92bee0 | 187 | fCDBUri(cdbUri), |
188 | fSpecCDBUri() | |
596a855f | 189 | { |
190 | // create reconstruction object with default parameters | |
b8cd5251 | 191 | |
192 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
193 | fReconstructor[iDet] = NULL; | |
194 | fLoader[iDet] = NULL; | |
195 | fTracker[iDet] = NULL; | |
196 | } | |
e47c4c2e | 197 | AliPID pid; |
596a855f | 198 | } |
199 | ||
200 | //_____________________________________________________________________________ | |
201 | AliReconstruction::AliReconstruction(const AliReconstruction& rec) : | |
e583c30d | 202 | TNamed(rec), |
203 | ||
c84a5e9e | 204 | fUniformField(rec.fUniformField), |
2257f27e | 205 | fRunVertexFinder(rec.fRunVertexFinder), |
1f46a9ae | 206 | fRunHLTTracking(rec.fRunHLTTracking), |
1d99986f | 207 | fStopOnError(rec.fStopOnError), |
208 | fWriteAlignmentData(rec.fWriteAlignmentData), | |
209 | fWriteESDfriend(rec.fWriteESDfriend), | |
b647652d | 210 | fFillTriggerESD(rec.fFillTriggerESD), |
1d99986f | 211 | |
212 | fRunLocalReconstruction(rec.fRunLocalReconstruction), | |
e583c30d | 213 | fRunTracking(rec.fRunTracking), |
214 | fFillESD(rec.fFillESD), | |
215 | fGAliceFileName(rec.fGAliceFileName), | |
b649205a | 216 | fInput(rec.fInput), |
35042093 | 217 | fEquipIdMap(rec.fEquipIdMap), |
b26c3770 | 218 | fFirstEvent(rec.fFirstEvent), |
219 | fLastEvent(rec.fLastEvent), | |
24f7a148 | 220 | fCheckPointLevel(0), |
b8cd5251 | 221 | fOptions(), |
6bae477a | 222 | fLoadAlignFromCDB(rec.fLoadAlignFromCDB), |
223 | fLoadAlignData(rec.fLoadAlignData), | |
e583c30d | 224 | |
225 | fRunLoader(NULL), | |
b649205a | 226 | fRawReader(NULL), |
b8cd5251 | 227 | |
98937d93 | 228 | fVertexer(NULL), |
229 | ||
6bae477a | 230 | fAlignObjArray(rec.fAlignObjArray), |
ec92bee0 | 231 | fCDBUri(rec.fCDBUri), |
232 | fSpecCDBUri() | |
596a855f | 233 | { |
234 | // copy constructor | |
235 | ||
ec92bee0 | 236 | for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) { |
efd2085e | 237 | if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone()); |
238 | } | |
b8cd5251 | 239 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
240 | fReconstructor[iDet] = NULL; | |
241 | fLoader[iDet] = NULL; | |
242 | fTracker[iDet] = NULL; | |
243 | } | |
ec92bee0 | 244 | for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) { |
245 | if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone()); | |
246 | } | |
596a855f | 247 | } |
248 | ||
249 | //_____________________________________________________________________________ | |
250 | AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec) | |
251 | { | |
252 | // assignment operator | |
253 | ||
254 | this->~AliReconstruction(); | |
255 | new(this) AliReconstruction(rec); | |
256 | return *this; | |
257 | } | |
258 | ||
259 | //_____________________________________________________________________________ | |
260 | AliReconstruction::~AliReconstruction() | |
261 | { | |
262 | // clean up | |
263 | ||
e583c30d | 264 | CleanUp(); |
efd2085e | 265 | fOptions.Delete(); |
ec92bee0 | 266 | fSpecCDBUri.Delete(); |
596a855f | 267 | } |
268 | ||
024cf675 | 269 | //_____________________________________________________________________________ |
270 | void AliReconstruction::InitCDBStorage() | |
271 | { | |
272 | // activate a default CDB storage | |
273 | // First check if we have any CDB storage set, because it is used | |
274 | // to retrieve the calibration and alignment constants | |
275 | ||
276 | AliCDBManager* man = AliCDBManager::Instance(); | |
ec92bee0 | 277 | if (man->IsDefaultStorageSet()) |
024cf675 | 278 | { |
279 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
ec92bee0 | 280 | AliWarning("Default CDB storage has been already set !"); |
281 | AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data())); | |
024cf675 | 282 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
ec92bee0 | 283 | fCDBUri = ""; |
284 | } | |
285 | else { | |
286 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
287 | AliWarning(Form("Default CDB storage is set to: %s",fCDBUri.Data())); | |
288 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
289 | man->SetDefaultStorage(fCDBUri); | |
290 | } | |
291 | ||
292 | // Now activate the detector specific CDB storage locations | |
293 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
294 | TString detName = fgkDetectorName[iDet]; | |
295 | TObject* obj = fSpecCDBUri.FindObject(detName.Data()); | |
bb3da222 | 296 | if (obj) { |
297 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
298 | AliWarning(Form("Specific CDB storage for %s is set to: %s",detName.Data(),obj->GetTitle())); | |
299 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
300 | man->SetSpecificStorage(detName.Data(),obj->GetTitle()); | |
301 | } | |
ec92bee0 | 302 | } |
024cf675 | 303 | |
304 | } | |
305 | ||
306 | //_____________________________________________________________________________ | |
307 | void AliReconstruction::SetDefaultStorage(const char* uri) { | |
ec92bee0 | 308 | // Store the desired default CDB storage location |
309 | // Activate it later within the Run() method | |
024cf675 | 310 | |
ec92bee0 | 311 | fCDBUri = uri; |
024cf675 | 312 | |
313 | } | |
314 | ||
315 | //_____________________________________________________________________________ | |
316 | void AliReconstruction::SetSpecificStorage(const char* detName, const char* uri) { | |
ec92bee0 | 317 | // Store a detector-specific CDB storage location |
318 | // Activate it later within the Run() method | |
024cf675 | 319 | |
ec92bee0 | 320 | TObject* obj = fSpecCDBUri.FindObject(detName); |
321 | if (obj) fSpecCDBUri.Remove(obj); | |
322 | fSpecCDBUri.Add(new TNamed(detName, uri)); | |
024cf675 | 323 | |
324 | } | |
325 | ||
6bae477a | 326 | //_____________________________________________________________________________ |
327 | Bool_t AliReconstruction::SetRunNumber() | |
328 | { | |
329 | // The method is called in Run() in order | |
330 | // to set a correct run number. | |
331 | // In case of raw data reconstruction the | |
332 | // run number is taken from the raw data header | |
333 | ||
334 | if(AliCDBManager::Instance()->GetRun() < 0) { | |
335 | if (!fRunLoader) { | |
336 | AliError("No run loader is found !"); | |
337 | return kFALSE; | |
338 | } | |
339 | // read run number from gAlice | |
ec92bee0 | 340 | if(fRunLoader->GetAliRun()) |
341 | AliCDBManager::Instance()->SetRun(fRunLoader->GetAliRun()->GetRunNumber()); | |
342 | else { | |
343 | if(fRawReader) { | |
344 | if(fRawReader->NextEvent()) { | |
345 | AliCDBManager::Instance()->SetRun(fRawReader->GetRunNumber()); | |
346 | fRawReader->RewindEvents(); | |
347 | } | |
348 | else { | |
349 | AliError("No raw-data events found !"); | |
350 | return kFALSE; | |
351 | } | |
352 | } | |
353 | else { | |
354 | AliError("Neither gAlice nor RawReader objects are found !"); | |
355 | return kFALSE; | |
356 | } | |
357 | } | |
358 | AliInfo(Form("CDB Run number: %d",AliCDBManager::Instance()->GetRun())); | |
6bae477a | 359 | } |
360 | return kTRUE; | |
361 | } | |
362 | ||
363 | //_____________________________________________________________________________ | |
364 | Bool_t AliReconstruction::ApplyAlignObjsToGeom(TObjArray* alObjArray) | |
365 | { | |
366 | // Read collection of alignment objects (AliAlignObj derived) saved | |
367 | // in the TClonesArray ClArrayName and apply them to the geometry | |
368 | // manager singleton. | |
369 | // | |
370 | alObjArray->Sort(); | |
371 | Int_t nvols = alObjArray->GetEntriesFast(); | |
372 | ||
dc0984f8 | 373 | Bool_t flag = kTRUE; |
374 | ||
6bae477a | 375 | for(Int_t j=0; j<nvols; j++) |
376 | { | |
377 | AliAlignObj* alobj = (AliAlignObj*) alObjArray->UncheckedAt(j); | |
dc0984f8 | 378 | if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE; |
6bae477a | 379 | } |
380 | ||
381 | if (AliDebugLevelClass() >= 1) { | |
e0625db4 | 382 | gGeoManager->GetTopNode()->CheckOverlaps(20); |
6bae477a | 383 | TObjArray* ovexlist = gGeoManager->GetListOfOverlaps(); |
384 | if(ovexlist->GetEntriesFast()){ | |
385 | AliError("The application of alignment objects to the geometry caused huge overlaps/extrusions!"); | |
386 | } | |
387 | } | |
388 | ||
dc0984f8 | 389 | return flag; |
6bae477a | 390 | |
391 | } | |
392 | ||
393 | //_____________________________________________________________________________ | |
394 | Bool_t AliReconstruction::SetAlignObjArraySingleDet(const char* detName) | |
395 | { | |
396 | // Fills array of single detector's alignable objects from CDB | |
397 | ||
398 | AliDebug(2, Form("Loading alignment data for detector: %s",detName)); | |
399 | ||
400 | AliCDBEntry *entry; | |
401 | ||
402 | AliCDBPath path(detName,"Align","Data"); | |
403 | ||
404 | entry=AliCDBManager::Instance()->Get(path.GetPath()); | |
405 | if(!entry){ | |
406 | AliDebug(2,Form("Couldn't load alignment data for detector %s",detName)); | |
407 | return kFALSE; | |
408 | } | |
409 | entry->SetOwner(1); | |
410 | TClonesArray *alignArray = (TClonesArray*) entry->GetObject(); | |
411 | alignArray->SetOwner(0); | |
412 | AliDebug(2,Form("Found %d alignment objects for %s", | |
413 | alignArray->GetEntries(),detName)); | |
414 | ||
415 | AliAlignObj *alignObj=0; | |
416 | TIter iter(alignArray); | |
417 | ||
418 | // loop over align objects in detector | |
419 | while( ( alignObj=(AliAlignObj *) iter.Next() ) ){ | |
420 | fAlignObjArray->Add(alignObj); | |
421 | } | |
422 | // delete entry --- Don't delete, it is cached! | |
423 | ||
424 | AliDebug(2, Form("fAlignObjArray entries: %d",fAlignObjArray->GetEntries() )); | |
425 | return kTRUE; | |
426 | ||
427 | } | |
428 | ||
429 | //_____________________________________________________________________________ | |
430 | Bool_t AliReconstruction::MisalignGeometry(const TString& detectors) | |
431 | { | |
432 | // Read the alignment objects from CDB. | |
433 | // Each detector is supposed to have the | |
434 | // alignment objects in DET/Align/Data CDB path. | |
435 | // All the detector objects are then collected, | |
436 | // sorted by geometry level (starting from ALIC) and | |
437 | // then applied to the TGeo geometry. | |
438 | // Finally an overlaps check is performed. | |
439 | ||
440 | // Load alignment data from CDB and fill fAlignObjArray | |
441 | if(fLoadAlignFromCDB){ | |
442 | if(!fAlignObjArray) fAlignObjArray = new TObjArray(); | |
443 | ||
444 | //fAlignObjArray->RemoveAll(); | |
445 | fAlignObjArray->Clear(); | |
446 | fAlignObjArray->SetOwner(0); | |
447 | ||
448 | TString detStr = detectors; | |
449 | TString dataNotLoaded=""; | |
450 | TString dataLoaded=""; | |
451 | ||
452 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
453 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
454 | if(!SetAlignObjArraySingleDet(fgkDetectorName[iDet])){ | |
455 | dataNotLoaded += fgkDetectorName[iDet]; | |
456 | dataNotLoaded += " "; | |
457 | } else { | |
458 | dataLoaded += fgkDetectorName[iDet]; | |
459 | dataLoaded += " "; | |
460 | } | |
461 | } // end loop over detectors | |
462 | ||
463 | if ((detStr.CompareTo("ALL") == 0)) detStr = ""; | |
464 | dataNotLoaded += detStr; | |
465 | AliInfo(Form("Alignment data loaded for: %s", | |
466 | dataLoaded.Data())); | |
467 | AliInfo(Form("Didn't/couldn't load alignment data for: %s", | |
468 | dataNotLoaded.Data())); | |
469 | } // fLoadAlignFromCDB flag | |
470 | ||
471 | // Check if the array with alignment objects was | |
472 | // provided by the user. If yes, apply the objects | |
473 | // to the present TGeo geometry | |
474 | if (fAlignObjArray) { | |
475 | if (gGeoManager && gGeoManager->IsClosed()) { | |
476 | if (ApplyAlignObjsToGeom(fAlignObjArray) == kFALSE) { | |
dc0984f8 | 477 | AliError("The misalignment of one or more volumes failed!" |
478 | "Compare the list of simulated detectors and the list of detector alignment data!"); | |
6bae477a | 479 | return kFALSE; |
480 | } | |
481 | } | |
482 | else { | |
483 | AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!"); | |
484 | return kFALSE; | |
485 | } | |
486 | } | |
487 | ||
488 | return kTRUE; | |
489 | } | |
596a855f | 490 | |
491 | //_____________________________________________________________________________ | |
492 | void AliReconstruction::SetGAliceFile(const char* fileName) | |
493 | { | |
494 | // set the name of the galice file | |
495 | ||
496 | fGAliceFileName = fileName; | |
497 | } | |
498 | ||
efd2085e | 499 | //_____________________________________________________________________________ |
500 | void AliReconstruction::SetOption(const char* detector, const char* option) | |
501 | { | |
502 | // set options for the reconstruction of a detector | |
503 | ||
504 | TObject* obj = fOptions.FindObject(detector); | |
505 | if (obj) fOptions.Remove(obj); | |
506 | fOptions.Add(new TNamed(detector, option)); | |
507 | } | |
508 | ||
596a855f | 509 | |
510 | //_____________________________________________________________________________ | |
b26c3770 | 511 | Bool_t AliReconstruction::Run(const char* input, |
512 | Int_t firstEvent, Int_t lastEvent) | |
596a855f | 513 | { |
514 | // run the reconstruction | |
515 | ||
b649205a | 516 | // set the input |
517 | if (!input) input = fInput.Data(); | |
518 | TString fileName(input); | |
519 | if (fileName.EndsWith("/")) { | |
520 | fRawReader = new AliRawReaderFile(fileName); | |
521 | } else if (fileName.EndsWith(".root")) { | |
522 | fRawReader = new AliRawReaderRoot(fileName); | |
523 | } else if (!fileName.IsNull()) { | |
524 | fRawReader = new AliRawReaderDate(fileName); | |
525 | fRawReader->SelectEvents(7); | |
526 | } | |
35042093 | 527 | if (!fEquipIdMap.IsNull() && fRawReader) |
528 | fRawReader->LoadEquipmentIdsMap(fEquipIdMap); | |
529 | ||
b649205a | 530 | |
f08fc9f5 | 531 | // get the run loader |
532 | if (!InitRunLoader()) return kFALSE; | |
596a855f | 533 | |
ec92bee0 | 534 | // Initialize the CDB storage |
535 | InitCDBStorage(); | |
536 | ||
6bae477a | 537 | // Set run number in CDBManager (if it is not already set by the user) |
538 | if (!SetRunNumber()) if (fStopOnError) return kFALSE; | |
539 | ||
540 | // Import ideal TGeo geometry and apply misalignment | |
541 | if (!gGeoManager) { | |
542 | TString geom(gSystem->DirName(fGAliceFileName)); | |
543 | geom += "/geometry.root"; | |
544 | TGeoManager::Import(geom.Data()); | |
545 | if (!gGeoManager) if (fStopOnError) return kFALSE; | |
546 | } | |
547 | if (!MisalignGeometry(fLoadAlignData)) if (fStopOnError) return kFALSE; | |
548 | ||
549 | // Temporary fix by A.Gheata | |
550 | // Could be removed with the next Root version (>5.11) | |
551 | if (gGeoManager) { | |
552 | TIter next(gGeoManager->GetListOfVolumes()); | |
553 | TGeoVolume *vol; | |
554 | while ((vol = (TGeoVolume *)next())) { | |
555 | if (vol->GetVoxels()) { | |
556 | if (vol->GetVoxels()->NeedRebuild()) { | |
557 | vol->GetVoxels()->Voxelize(); | |
558 | vol->FindOverlaps(); | |
559 | } | |
560 | } | |
561 | } | |
562 | } | |
563 | ||
596a855f | 564 | // local reconstruction |
59697224 | 565 | if (!fRunLocalReconstruction.IsNull()) { |
566 | if (!RunLocalReconstruction(fRunLocalReconstruction)) { | |
e583c30d | 567 | if (fStopOnError) {CleanUp(); return kFALSE;} |
596a855f | 568 | } |
569 | } | |
b26c3770 | 570 | // if (!fRunVertexFinder && fRunTracking.IsNull() && |
571 | // fFillESD.IsNull()) return kTRUE; | |
2257f27e | 572 | |
573 | // get vertexer | |
574 | if (fRunVertexFinder && !CreateVertexer()) { | |
575 | if (fStopOnError) { | |
576 | CleanUp(); | |
577 | return kFALSE; | |
578 | } | |
579 | } | |
596a855f | 580 | |
f08fc9f5 | 581 | // get trackers |
b8cd5251 | 582 | if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) { |
24f7a148 | 583 | if (fStopOnError) { |
584 | CleanUp(); | |
585 | return kFALSE; | |
586 | } | |
596a855f | 587 | } |
24f7a148 | 588 | |
9db3a215 | 589 | |
590 | TStopwatch stopwatch; | |
591 | stopwatch.Start(); | |
592 | ||
b26c3770 | 593 | // get the possibly already existing ESD file and tree |
1f46a9ae | 594 | AliESD* esd = new AliESD; AliESD* hltesd = new AliESD; |
b26c3770 | 595 | TFile* fileOld = NULL; |
1f46a9ae | 596 | TTree* treeOld = NULL; TTree *hlttreeOld = NULL; |
b26c3770 | 597 | if (!gSystem->AccessPathName("AliESDs.root")){ |
598 | gSystem->CopyFile("AliESDs.root", "AliESDs.old.root", kTRUE); | |
599 | fileOld = TFile::Open("AliESDs.old.root"); | |
600 | if (fileOld && fileOld->IsOpen()) { | |
601 | treeOld = (TTree*) fileOld->Get("esdTree"); | |
602 | if (treeOld) treeOld->SetBranchAddress("ESD", &esd); | |
1f46a9ae | 603 | hlttreeOld = (TTree*) fileOld->Get("HLTesdTree"); |
604 | if (hlttreeOld) hlttreeOld->SetBranchAddress("ESD", &hltesd); | |
b26c3770 | 605 | } |
606 | } | |
607 | ||
36711aa4 | 608 | // create the ESD output file and tree |
596a855f | 609 | TFile* file = TFile::Open("AliESDs.root", "RECREATE"); |
610 | if (!file->IsOpen()) { | |
815c2b38 | 611 | AliError("opening AliESDs.root failed"); |
b26c3770 | 612 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
596a855f | 613 | } |
36711aa4 | 614 | TTree* tree = new TTree("esdTree", "Tree with ESD objects"); |
615 | tree->Branch("ESD", "AliESD", &esd); | |
1f46a9ae | 616 | TTree* hlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects"); |
617 | hlttree->Branch("ESD", "AliESD", &hltesd); | |
618 | delete esd; delete hltesd; | |
619 | esd = NULL; hltesd = NULL; | |
1d99986f | 620 | |
621 | // create the file and tree with ESD additions | |
622 | TFile *filef=0; TTree *treef=0; AliESDfriend *esdf=0; | |
623 | if (fWriteESDfriend) { | |
624 | filef = TFile::Open("AliESDfriends.root", "RECREATE"); | |
625 | if (!filef->IsOpen()) { | |
626 | AliError("opening AliESDfriends.root failed"); | |
627 | } | |
628 | treef = new TTree("esdFriendTree", "Tree with ESD friends"); | |
629 | treef->Branch("ESDfriend", "AliESDfriend", &esdf); | |
630 | } | |
631 | ||
36711aa4 | 632 | gROOT->cd(); |
596a855f | 633 | |
c5e3e5d1 | 634 | AliVertexerTracks tVertexer; |
635 | ||
596a855f | 636 | // loop over events |
b649205a | 637 | if (fRawReader) fRawReader->RewindEvents(); |
f08fc9f5 | 638 | |
596a855f | 639 | for (Int_t iEvent = 0; iEvent < fRunLoader->GetNumberOfEvents(); iEvent++) { |
b26c3770 | 640 | if (fRawReader) fRawReader->NextEvent(); |
641 | if ((iEvent < firstEvent) || ((lastEvent >= 0) && (iEvent > lastEvent))) { | |
642 | // copy old ESD to the new one | |
643 | if (treeOld) { | |
644 | treeOld->SetBranchAddress("ESD", &esd); | |
645 | treeOld->GetEntry(iEvent); | |
646 | } | |
647 | tree->Fill(); | |
1f46a9ae | 648 | if (hlttreeOld) { |
649 | hlttreeOld->SetBranchAddress("ESD", &hltesd); | |
650 | hlttreeOld->GetEntry(iEvent); | |
651 | } | |
652 | hlttree->Fill(); | |
b26c3770 | 653 | continue; |
654 | } | |
655 | ||
815c2b38 | 656 | AliInfo(Form("processing event %d", iEvent)); |
596a855f | 657 | fRunLoader->GetEvent(iEvent); |
24f7a148 | 658 | |
659 | char fileName[256]; | |
660 | sprintf(fileName, "ESD_%d.%d_final.root", | |
f08fc9f5 | 661 | fRunLoader->GetHeader()->GetRun(), |
662 | fRunLoader->GetHeader()->GetEventNrInRun()); | |
24f7a148 | 663 | if (!gSystem->AccessPathName(fileName)) continue; |
664 | ||
b26c3770 | 665 | // local reconstruction |
666 | if (!fRunLocalReconstruction.IsNull()) { | |
667 | if (!RunLocalEventReconstruction(fRunLocalReconstruction)) { | |
668 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
669 | } | |
670 | } | |
671 | ||
1f46a9ae | 672 | esd = new AliESD; hltesd = new AliESD; |
f08fc9f5 | 673 | esd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); |
1f46a9ae | 674 | hltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); |
f08fc9f5 | 675 | esd->SetEventNumber(fRunLoader->GetHeader()->GetEventNrInRun()); |
1f46a9ae | 676 | hltesd->SetEventNumber(fRunLoader->GetHeader()->GetEventNrInRun()); |
d6ee376f | 677 | |
678 | // Set magnetic field from the tracker | |
679 | esd->SetMagneticField(AliTracker::GetBz()); | |
680 | hltesd->SetMagneticField(AliTracker::GetBz()); | |
596a855f | 681 | |
2257f27e | 682 | // vertex finder |
683 | if (fRunVertexFinder) { | |
684 | if (!ReadESD(esd, "vertex")) { | |
685 | if (!RunVertexFinder(esd)) { | |
b26c3770 | 686 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
2257f27e | 687 | } |
688 | if (fCheckPointLevel > 0) WriteESD(esd, "vertex"); | |
689 | } | |
690 | } | |
691 | ||
1f46a9ae | 692 | // HLT tracking |
693 | if (!fRunTracking.IsNull()) { | |
694 | if (fRunHLTTracking) { | |
695 | hltesd->SetVertex(esd->GetVertex()); | |
696 | if (!RunHLTTracking(hltesd)) { | |
697 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
698 | } | |
699 | } | |
700 | } | |
701 | ||
596a855f | 702 | // barrel tracking |
b8cd5251 | 703 | if (!fRunTracking.IsNull()) { |
24f7a148 | 704 | if (!ReadESD(esd, "tracking")) { |
705 | if (!RunTracking(esd)) { | |
b26c3770 | 706 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
24f7a148 | 707 | } |
708 | if (fCheckPointLevel > 0) WriteESD(esd, "tracking"); | |
596a855f | 709 | } |
710 | } | |
711 | ||
712 | // fill ESD | |
713 | if (!fFillESD.IsNull()) { | |
714 | if (!FillESD(esd, fFillESD)) { | |
b26c3770 | 715 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
596a855f | 716 | } |
717 | } | |
718 | ||
719 | // combined PID | |
720 | AliESDpid::MakePID(esd); | |
24f7a148 | 721 | if (fCheckPointLevel > 1) WriteESD(esd, "PID"); |
596a855f | 722 | |
b647652d | 723 | if (fFillTriggerESD) { |
724 | if (!ReadESD(esd, "trigger")) { | |
725 | if (!FillTriggerESD(esd)) { | |
726 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
727 | } | |
728 | if (fCheckPointLevel > 1) WriteESD(esd, "trigger"); | |
729 | } | |
730 | } | |
731 | ||
a28195f7 | 732 | esd->SetPrimaryVertex(tVertexer.FindPrimaryVertex(esd)); |
c5e3e5d1 | 733 | |
596a855f | 734 | // write ESD |
36711aa4 | 735 | tree->Fill(); |
1f46a9ae | 736 | // write HLT ESD |
737 | hlttree->Fill(); | |
24f7a148 | 738 | |
1d99986f | 739 | // write ESD friend |
740 | if (fWriteESDfriend) { | |
d75007f6 | 741 | esdf=new AliESDfriend(); |
742 | esd->GetESDfriend(esdf); | |
1d99986f | 743 | treef->Fill(); |
744 | } | |
745 | ||
f3a97c86 | 746 | if (fCheckPointLevel > 0) WriteESD(esd, "final"); |
747 | ||
1f46a9ae | 748 | delete esd; delete hltesd; |
749 | esd = NULL; hltesd = NULL; | |
596a855f | 750 | } |
751 | ||
9db3a215 | 752 | AliInfo(Form("Execution time for filling ESD : R:%.2fs C:%.2fs", |
753 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
754 | ||
36711aa4 | 755 | file->cd(); |
756 | tree->Write(); | |
1f46a9ae | 757 | hlttree->Write(); |
f3a97c86 | 758 | |
1d99986f | 759 | if (fWriteESDfriend) { |
760 | filef->cd(); | |
761 | treef->Write(); delete treef; filef->Close(); delete filef; | |
762 | } | |
763 | ||
f3a97c86 | 764 | // Create tags for the events in the ESD tree (the ESD tree is always present) |
765 | // In case of empty events the tags will contain dummy values | |
766 | CreateTag(file); | |
b26c3770 | 767 | CleanUp(file, fileOld); |
596a855f | 768 | |
769 | return kTRUE; | |
770 | } | |
771 | ||
772 | ||
773 | //_____________________________________________________________________________ | |
59697224 | 774 | Bool_t AliReconstruction::RunLocalReconstruction(const TString& detectors) |
596a855f | 775 | { |
59697224 | 776 | // run the local reconstruction |
596a855f | 777 | |
030b532d | 778 | TStopwatch stopwatch; |
779 | stopwatch.Start(); | |
780 | ||
596a855f | 781 | TString detStr = detectors; |
b8cd5251 | 782 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
783 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
784 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
785 | if (!reconstructor) continue; | |
b26c3770 | 786 | if (reconstructor->HasLocalReconstruction()) continue; |
b8cd5251 | 787 | |
788 | AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); | |
789 | TStopwatch stopwatchDet; | |
790 | stopwatchDet.Start(); | |
791 | if (fRawReader) { | |
792 | fRawReader->RewindEvents(); | |
793 | reconstructor->Reconstruct(fRunLoader, fRawReader); | |
794 | } else { | |
795 | reconstructor->Reconstruct(fRunLoader); | |
596a855f | 796 | } |
5f8272e1 | 797 | AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs", |
798 | fgkDetectorName[iDet], | |
799 | stopwatchDet.RealTime(),stopwatchDet.CpuTime())); | |
596a855f | 800 | } |
801 | ||
802 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
815c2b38 | 803 | AliError(Form("the following detectors were not found: %s", |
804 | detStr.Data())); | |
596a855f | 805 | if (fStopOnError) return kFALSE; |
806 | } | |
807 | ||
5f8272e1 | 808 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", |
809 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
030b532d | 810 | |
596a855f | 811 | return kTRUE; |
812 | } | |
813 | ||
b26c3770 | 814 | //_____________________________________________________________________________ |
815 | Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors) | |
816 | { | |
817 | // run the local reconstruction | |
818 | ||
819 | TStopwatch stopwatch; | |
820 | stopwatch.Start(); | |
821 | ||
822 | TString detStr = detectors; | |
823 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
824 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
825 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
826 | if (!reconstructor) continue; | |
827 | AliLoader* loader = fLoader[iDet]; | |
828 | ||
829 | // conversion of digits | |
830 | if (fRawReader && reconstructor->HasDigitConversion()) { | |
831 | AliInfo(Form("converting raw data digits into root objects for %s", | |
832 | fgkDetectorName[iDet])); | |
833 | TStopwatch stopwatchDet; | |
834 | stopwatchDet.Start(); | |
835 | loader->LoadDigits("update"); | |
836 | loader->CleanDigits(); | |
837 | loader->MakeDigitsContainer(); | |
838 | TTree* digitsTree = loader->TreeD(); | |
839 | reconstructor->ConvertDigits(fRawReader, digitsTree); | |
840 | loader->WriteDigits("OVERWRITE"); | |
841 | loader->UnloadDigits(); | |
5f8272e1 | 842 | AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs", |
843 | fgkDetectorName[iDet], | |
844 | stopwatchDet.RealTime(),stopwatchDet.CpuTime())); | |
b26c3770 | 845 | } |
846 | ||
847 | // local reconstruction | |
848 | if (!reconstructor->HasLocalReconstruction()) continue; | |
849 | AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); | |
850 | TStopwatch stopwatchDet; | |
851 | stopwatchDet.Start(); | |
852 | loader->LoadRecPoints("update"); | |
853 | loader->CleanRecPoints(); | |
854 | loader->MakeRecPointsContainer(); | |
855 | TTree* clustersTree = loader->TreeR(); | |
856 | if (fRawReader && !reconstructor->HasDigitConversion()) { | |
857 | reconstructor->Reconstruct(fRawReader, clustersTree); | |
858 | } else { | |
859 | loader->LoadDigits("read"); | |
860 | TTree* digitsTree = loader->TreeD(); | |
861 | if (!digitsTree) { | |
862 | AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet])); | |
863 | if (fStopOnError) return kFALSE; | |
864 | } else { | |
865 | reconstructor->Reconstruct(digitsTree, clustersTree); | |
866 | } | |
867 | loader->UnloadDigits(); | |
868 | } | |
869 | loader->WriteRecPoints("OVERWRITE"); | |
870 | loader->UnloadRecPoints(); | |
5f8272e1 | 871 | AliDebug(1,Form("Execution time for %s: R:%.2fs C:%.2fs", |
872 | fgkDetectorName[iDet], | |
873 | stopwatchDet.RealTime(),stopwatchDet.CpuTime())); | |
b26c3770 | 874 | } |
875 | ||
876 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
877 | AliError(Form("the following detectors were not found: %s", | |
878 | detStr.Data())); | |
879 | if (fStopOnError) return kFALSE; | |
880 | } | |
5f8272e1 | 881 | |
882 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", | |
883 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
b26c3770 | 884 | |
885 | return kTRUE; | |
886 | } | |
887 | ||
596a855f | 888 | //_____________________________________________________________________________ |
2257f27e | 889 | Bool_t AliReconstruction::RunVertexFinder(AliESD*& esd) |
596a855f | 890 | { |
891 | // run the barrel tracking | |
892 | ||
030b532d | 893 | TStopwatch stopwatch; |
894 | stopwatch.Start(); | |
895 | ||
2257f27e | 896 | AliESDVertex* vertex = NULL; |
897 | Double_t vtxPos[3] = {0, 0, 0}; | |
898 | Double_t vtxErr[3] = {0.07, 0.07, 0.1}; | |
899 | TArrayF mcVertex(3); | |
a6b0b91b | 900 | if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) { |
901 | fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex); | |
902 | for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i]; | |
903 | } | |
2257f27e | 904 | |
b8cd5251 | 905 | if (fVertexer) { |
815c2b38 | 906 | AliInfo("running the ITS vertex finder"); |
b26c3770 | 907 | if (fLoader[0]) fLoader[0]->LoadRecPoints(); |
b8cd5251 | 908 | vertex = fVertexer->FindVertexForCurrentEvent(fRunLoader->GetEventNumber()); |
b26c3770 | 909 | if (fLoader[0]) fLoader[0]->UnloadRecPoints(); |
2257f27e | 910 | if(!vertex){ |
815c2b38 | 911 | AliWarning("Vertex not found"); |
c710f220 | 912 | vertex = new AliESDVertex(); |
d1a50cb5 | 913 | vertex->SetName("default"); |
2257f27e | 914 | } |
915 | else { | |
916 | vertex->SetTruePos(vtxPos); // store also the vertex from MC | |
d1a50cb5 | 917 | vertex->SetName("reconstructed"); |
2257f27e | 918 | } |
919 | ||
920 | } else { | |
815c2b38 | 921 | AliInfo("getting the primary vertex from MC"); |
2257f27e | 922 | vertex = new AliESDVertex(vtxPos, vtxErr); |
923 | } | |
924 | ||
925 | if (vertex) { | |
926 | vertex->GetXYZ(vtxPos); | |
927 | vertex->GetSigmaXYZ(vtxErr); | |
928 | } else { | |
815c2b38 | 929 | AliWarning("no vertex reconstructed"); |
2257f27e | 930 | vertex = new AliESDVertex(vtxPos, vtxErr); |
931 | } | |
932 | esd->SetVertex(vertex); | |
b8cd5251 | 933 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
934 | if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr); | |
935 | } | |
2257f27e | 936 | delete vertex; |
937 | ||
5f8272e1 | 938 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", |
939 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
2257f27e | 940 | |
941 | return kTRUE; | |
942 | } | |
943 | ||
1f46a9ae | 944 | //_____________________________________________________________________________ |
945 | Bool_t AliReconstruction::RunHLTTracking(AliESD*& esd) | |
946 | { | |
947 | // run the HLT barrel tracking | |
948 | ||
949 | TStopwatch stopwatch; | |
950 | stopwatch.Start(); | |
951 | ||
952 | if (!fRunLoader) { | |
953 | AliError("Missing runLoader!"); | |
954 | return kFALSE; | |
955 | } | |
956 | ||
957 | AliInfo("running HLT tracking"); | |
958 | ||
959 | // Get a pointer to the HLT reconstructor | |
960 | AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1); | |
961 | if (!reconstructor) return kFALSE; | |
962 | ||
963 | // TPC + ITS | |
964 | for (Int_t iDet = 1; iDet >= 0; iDet--) { | |
965 | TString detName = fgkDetectorName[iDet]; | |
966 | AliDebug(1, Form("%s HLT tracking", detName.Data())); | |
967 | reconstructor->SetOption(detName.Data()); | |
968 | AliTracker *tracker = reconstructor->CreateTracker(fRunLoader); | |
969 | if (!tracker) { | |
970 | AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data())); | |
971 | if (fStopOnError) return kFALSE; | |
9dcc06e1 | 972 | continue; |
1f46a9ae | 973 | } |
974 | Double_t vtxPos[3]; | |
975 | Double_t vtxErr[3]={0.005,0.005,0.010}; | |
976 | const AliESDVertex *vertex = esd->GetVertex(); | |
977 | vertex->GetXYZ(vtxPos); | |
978 | tracker->SetVertex(vtxPos,vtxErr); | |
979 | if(iDet != 1) { | |
980 | fLoader[iDet]->LoadRecPoints("read"); | |
981 | TTree* tree = fLoader[iDet]->TreeR(); | |
982 | if (!tree) { | |
983 | AliError(Form("Can't get the %s cluster tree", detName.Data())); | |
984 | return kFALSE; | |
985 | } | |
986 | tracker->LoadClusters(tree); | |
987 | } | |
988 | if (tracker->Clusters2Tracks(esd) != 0) { | |
989 | AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
990 | return kFALSE; | |
991 | } | |
992 | if(iDet != 1) { | |
993 | tracker->UnloadClusters(); | |
994 | } | |
995 | delete tracker; | |
996 | } | |
997 | ||
5f8272e1 | 998 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", |
999 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
1f46a9ae | 1000 | |
1001 | return kTRUE; | |
1002 | } | |
1003 | ||
2257f27e | 1004 | //_____________________________________________________________________________ |
1005 | Bool_t AliReconstruction::RunTracking(AliESD*& esd) | |
1006 | { | |
1007 | // run the barrel tracking | |
1008 | ||
1009 | TStopwatch stopwatch; | |
1010 | stopwatch.Start(); | |
24f7a148 | 1011 | |
815c2b38 | 1012 | AliInfo("running tracking"); |
596a855f | 1013 | |
b8cd5251 | 1014 | // pass 1: TPC + ITS inwards |
1015 | for (Int_t iDet = 1; iDet >= 0; iDet--) { | |
1016 | if (!fTracker[iDet]) continue; | |
1017 | AliDebug(1, Form("%s tracking", fgkDetectorName[iDet])); | |
24f7a148 | 1018 | |
b8cd5251 | 1019 | // load clusters |
1020 | fLoader[iDet]->LoadRecPoints("read"); | |
1021 | TTree* tree = fLoader[iDet]->TreeR(); | |
1022 | if (!tree) { | |
1023 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); | |
24f7a148 | 1024 | return kFALSE; |
1025 | } | |
b8cd5251 | 1026 | fTracker[iDet]->LoadClusters(tree); |
1027 | ||
1028 | // run tracking | |
1029 | if (fTracker[iDet]->Clusters2Tracks(esd) != 0) { | |
1030 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
24f7a148 | 1031 | return kFALSE; |
1032 | } | |
b8cd5251 | 1033 | if (fCheckPointLevel > 1) { |
1034 | WriteESD(esd, Form("%s.tracking", fgkDetectorName[iDet])); | |
1035 | } | |
878e1fe1 | 1036 | // preliminary PID in TPC needed by the ITS tracker |
1037 | if (iDet == 1) { | |
1038 | GetReconstructor(1)->FillESD(fRunLoader, esd); | |
b26c3770 | 1039 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); |
878e1fe1 | 1040 | AliESDpid::MakePID(esd); |
1041 | } | |
b8cd5251 | 1042 | } |
596a855f | 1043 | |
b8cd5251 | 1044 | // pass 2: ALL backwards |
1045 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1046 | if (!fTracker[iDet]) continue; | |
1047 | AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet])); | |
1048 | ||
1049 | // load clusters | |
1050 | if (iDet > 1) { // all except ITS, TPC | |
1051 | TTree* tree = NULL; | |
7b61cd9c | 1052 | fLoader[iDet]->LoadRecPoints("read"); |
1053 | tree = fLoader[iDet]->TreeR(); | |
b8cd5251 | 1054 | if (!tree) { |
1055 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); | |
24f7a148 | 1056 | return kFALSE; |
1057 | } | |
b8cd5251 | 1058 | fTracker[iDet]->LoadClusters(tree); |
1059 | } | |
24f7a148 | 1060 | |
b8cd5251 | 1061 | // run tracking |
1062 | if (fTracker[iDet]->PropagateBack(esd) != 0) { | |
1063 | AliError(Form("%s backward propagation failed", fgkDetectorName[iDet])); | |
1064 | return kFALSE; | |
1065 | } | |
1066 | if (fCheckPointLevel > 1) { | |
1067 | WriteESD(esd, Form("%s.back", fgkDetectorName[iDet])); | |
1068 | } | |
24f7a148 | 1069 | |
b8cd5251 | 1070 | // unload clusters |
1071 | if (iDet > 2) { // all except ITS, TPC, TRD | |
1072 | fTracker[iDet]->UnloadClusters(); | |
7b61cd9c | 1073 | fLoader[iDet]->UnloadRecPoints(); |
b8cd5251 | 1074 | } |
8f37df88 | 1075 | // updated PID in TPC needed by the ITS tracker -MI |
1076 | if (iDet == 1) { | |
1077 | GetReconstructor(1)->FillESD(fRunLoader, esd); | |
1078 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); | |
1079 | AliESDpid::MakePID(esd); | |
1080 | } | |
b8cd5251 | 1081 | } |
596a855f | 1082 | |
98937d93 | 1083 | // write space-points to the ESD in case alignment data output |
1084 | // is switched on | |
1085 | if (fWriteAlignmentData) | |
1086 | WriteAlignmentData(esd); | |
1087 | ||
b8cd5251 | 1088 | // pass 3: TRD + TPC + ITS refit inwards |
1089 | for (Int_t iDet = 2; iDet >= 0; iDet--) { | |
1090 | if (!fTracker[iDet]) continue; | |
1091 | AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet])); | |
596a855f | 1092 | |
b8cd5251 | 1093 | // run tracking |
1094 | if (fTracker[iDet]->RefitInward(esd) != 0) { | |
1095 | AliError(Form("%s inward refit failed", fgkDetectorName[iDet])); | |
1096 | return kFALSE; | |
1097 | } | |
1098 | if (fCheckPointLevel > 1) { | |
1099 | WriteESD(esd, Form("%s.refit", fgkDetectorName[iDet])); | |
1100 | } | |
596a855f | 1101 | |
b8cd5251 | 1102 | // unload clusters |
1103 | fTracker[iDet]->UnloadClusters(); | |
1104 | fLoader[iDet]->UnloadRecPoints(); | |
1105 | } | |
ff8bb5ae | 1106 | // |
1107 | // Propagate track to the vertex - if not done by ITS | |
1108 | // | |
1109 | Int_t ntracks = esd->GetNumberOfTracks(); | |
1110 | for (Int_t itrack=0; itrack<ntracks; itrack++){ | |
1111 | const Double_t kRadius = 3; // beam pipe radius | |
1112 | const Double_t kMaxStep = 5; // max step | |
1113 | const Double_t kMaxD = 123456; // max distance to prim vertex | |
1114 | Double_t fieldZ = AliTracker::GetBz(); // | |
1115 | AliESDtrack * track = esd->GetTrack(itrack); | |
1116 | if (!track) continue; | |
1117 | if (track->IsOn(AliESDtrack::kITSrefit)) continue; | |
a28195f7 | 1118 | track->PropagateTo(kRadius, fieldZ, track->GetMass(),kMaxStep,kTRUE); |
ff8bb5ae | 1119 | track->RelateToVertex(esd->GetVertex(),fieldZ, kMaxD); |
1120 | } | |
1121 | ||
5f8272e1 | 1122 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", |
1123 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
030b532d | 1124 | |
596a855f | 1125 | return kTRUE; |
1126 | } | |
1127 | ||
1128 | //_____________________________________________________________________________ | |
24f7a148 | 1129 | Bool_t AliReconstruction::FillESD(AliESD*& esd, const TString& detectors) |
596a855f | 1130 | { |
1131 | // fill the event summary data | |
1132 | ||
030b532d | 1133 | TStopwatch stopwatch; |
1134 | stopwatch.Start(); | |
815c2b38 | 1135 | AliInfo("filling ESD"); |
030b532d | 1136 | |
596a855f | 1137 | TString detStr = detectors; |
b8cd5251 | 1138 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1139 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
1140 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
1141 | if (!reconstructor) continue; | |
1142 | ||
1143 | if (!ReadESD(esd, fgkDetectorName[iDet])) { | |
1144 | AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet])); | |
b26c3770 | 1145 | TTree* clustersTree = NULL; |
1146 | if (reconstructor->HasLocalReconstruction() && fLoader[iDet]) { | |
1147 | fLoader[iDet]->LoadRecPoints("read"); | |
1148 | clustersTree = fLoader[iDet]->TreeR(); | |
1149 | if (!clustersTree) { | |
1150 | AliError(Form("Can't get the %s clusters tree", | |
1151 | fgkDetectorName[iDet])); | |
1152 | if (fStopOnError) return kFALSE; | |
1153 | } | |
1154 | } | |
1155 | if (fRawReader && !reconstructor->HasDigitConversion()) { | |
1156 | reconstructor->FillESD(fRawReader, clustersTree, esd); | |
1157 | } else { | |
1158 | TTree* digitsTree = NULL; | |
1159 | if (fLoader[iDet]) { | |
1160 | fLoader[iDet]->LoadDigits("read"); | |
1161 | digitsTree = fLoader[iDet]->TreeD(); | |
1162 | if (!digitsTree) { | |
1163 | AliError(Form("Can't get the %s digits tree", | |
1164 | fgkDetectorName[iDet])); | |
1165 | if (fStopOnError) return kFALSE; | |
1166 | } | |
1167 | } | |
1168 | reconstructor->FillESD(digitsTree, clustersTree, esd); | |
1169 | if (fLoader[iDet]) fLoader[iDet]->UnloadDigits(); | |
1170 | } | |
1171 | if (reconstructor->HasLocalReconstruction() && fLoader[iDet]) { | |
1172 | fLoader[iDet]->UnloadRecPoints(); | |
1173 | } | |
1174 | ||
b8cd5251 | 1175 | if (fRawReader) { |
1176 | reconstructor->FillESD(fRunLoader, fRawReader, esd); | |
1177 | } else { | |
1178 | reconstructor->FillESD(fRunLoader, esd); | |
24f7a148 | 1179 | } |
b8cd5251 | 1180 | if (fCheckPointLevel > 2) WriteESD(esd, fgkDetectorName[iDet]); |
596a855f | 1181 | } |
1182 | } | |
1183 | ||
1184 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
815c2b38 | 1185 | AliError(Form("the following detectors were not found: %s", |
1186 | detStr.Data())); | |
596a855f | 1187 | if (fStopOnError) return kFALSE; |
1188 | } | |
1189 | ||
5f8272e1 | 1190 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", |
1191 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
030b532d | 1192 | |
596a855f | 1193 | return kTRUE; |
1194 | } | |
1195 | ||
b647652d | 1196 | //_____________________________________________________________________________ |
1197 | Bool_t AliReconstruction::FillTriggerESD(AliESD*& esd) | |
1198 | { | |
1199 | // Reads the trigger decision which is | |
1200 | // stored in Trigger.root file and fills | |
1201 | // the corresponding esd entries | |
1202 | ||
1203 | AliInfo("Filling trigger information into the ESD"); | |
1204 | ||
1205 | if (fRawReader) { | |
1206 | AliCTPRawStream input(fRawReader); | |
1207 | if (!input.Next()) { | |
1208 | AliError("No valid CTP (trigger) DDL raw data is found ! The trigger information is not stored in the ESD !"); | |
1209 | return kFALSE; | |
1210 | } | |
1211 | esd->SetTriggerMask(input.GetClassMask()); | |
1212 | esd->SetTriggerCluster(input.GetClusterMask()); | |
1213 | } | |
1214 | else { | |
1215 | AliRunLoader *runloader = AliRunLoader::GetRunLoader(); | |
1216 | if (runloader) { | |
1217 | if (!runloader->LoadTrigger()) { | |
1218 | AliCentralTrigger *aCTP = runloader->GetTrigger(); | |
1219 | esd->SetTriggerMask(aCTP->GetClassMask()); | |
1220 | esd->SetTriggerCluster(aCTP->GetClusterMask()); | |
1221 | } | |
1222 | else { | |
1223 | AliWarning("No trigger can be loaded! The trigger information is not stored in the ESD !"); | |
1224 | return kFALSE; | |
1225 | } | |
1226 | } | |
1227 | else { | |
1228 | AliError("No run loader is available! The trigger information is not stored in the ESD !"); | |
1229 | return kFALSE; | |
1230 | } | |
1231 | } | |
1232 | ||
1233 | return kTRUE; | |
1234 | } | |
596a855f | 1235 | |
1236 | //_____________________________________________________________________________ | |
1237 | Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const | |
1238 | { | |
1239 | // check whether detName is contained in detectors | |
1240 | // if yes, it is removed from detectors | |
1241 | ||
1242 | // check if all detectors are selected | |
1243 | if ((detectors.CompareTo("ALL") == 0) || | |
1244 | detectors.BeginsWith("ALL ") || | |
1245 | detectors.EndsWith(" ALL") || | |
1246 | detectors.Contains(" ALL ")) { | |
1247 | detectors = "ALL"; | |
1248 | return kTRUE; | |
1249 | } | |
1250 | ||
1251 | // search for the given detector | |
1252 | Bool_t result = kFALSE; | |
1253 | if ((detectors.CompareTo(detName) == 0) || | |
1254 | detectors.BeginsWith(detName+" ") || | |
1255 | detectors.EndsWith(" "+detName) || | |
1256 | detectors.Contains(" "+detName+" ")) { | |
1257 | detectors.ReplaceAll(detName, ""); | |
1258 | result = kTRUE; | |
1259 | } | |
1260 | ||
1261 | // clean up the detectors string | |
1262 | while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " "); | |
1263 | while (detectors.BeginsWith(" ")) detectors.Remove(0, 1); | |
1264 | while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1); | |
1265 | ||
1266 | return result; | |
1267 | } | |
e583c30d | 1268 | |
f08fc9f5 | 1269 | //_____________________________________________________________________________ |
1270 | Bool_t AliReconstruction::InitRunLoader() | |
1271 | { | |
1272 | // get or create the run loader | |
1273 | ||
1274 | if (gAlice) delete gAlice; | |
1275 | gAlice = NULL; | |
1276 | ||
b26c3770 | 1277 | if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists |
1278 | // load all base libraries to get the loader classes | |
1279 | TString libs = gSystem->GetLibraries(); | |
1280 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1281 | TString detName = fgkDetectorName[iDet]; | |
1282 | if (detName == "HLT") continue; | |
1283 | if (libs.Contains("lib" + detName + "base.so")) continue; | |
1284 | gSystem->Load("lib" + detName + "base.so"); | |
1285 | } | |
f08fc9f5 | 1286 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); |
1287 | if (!fRunLoader) { | |
1288 | AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); | |
1289 | CleanUp(); | |
1290 | return kFALSE; | |
1291 | } | |
b26c3770 | 1292 | fRunLoader->CdGAFile(); |
1293 | if (gFile->GetKey(AliRunLoader::GetGAliceName())) { | |
1294 | if (fRunLoader->LoadgAlice() == 0) { | |
1295 | gAlice = fRunLoader->GetAliRun(); | |
c84a5e9e | 1296 | AliTracker::SetFieldMap(gAlice->Field(),fUniformField); |
b26c3770 | 1297 | } |
f08fc9f5 | 1298 | } |
1299 | if (!gAlice && !fRawReader) { | |
1300 | AliError(Form("no gAlice object found in file %s", | |
1301 | fGAliceFileName.Data())); | |
1302 | CleanUp(); | |
1303 | return kFALSE; | |
1304 | } | |
1305 | ||
1306 | } else { // galice.root does not exist | |
1307 | if (!fRawReader) { | |
1308 | AliError(Form("the file %s does not exist", fGAliceFileName.Data())); | |
1309 | CleanUp(); | |
1310 | return kFALSE; | |
1311 | } | |
1312 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(), | |
1313 | AliConfig::GetDefaultEventFolderName(), | |
1314 | "recreate"); | |
1315 | if (!fRunLoader) { | |
1316 | AliError(Form("could not create run loader in file %s", | |
1317 | fGAliceFileName.Data())); | |
1318 | CleanUp(); | |
1319 | return kFALSE; | |
1320 | } | |
1321 | fRunLoader->MakeTree("E"); | |
1322 | Int_t iEvent = 0; | |
1323 | while (fRawReader->NextEvent()) { | |
1324 | fRunLoader->SetEventNumber(iEvent); | |
1325 | fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(), | |
1326 | iEvent, iEvent); | |
1327 | fRunLoader->MakeTree("H"); | |
1328 | fRunLoader->TreeE()->Fill(); | |
1329 | iEvent++; | |
1330 | } | |
1331 | fRawReader->RewindEvents(); | |
1332 | fRunLoader->WriteHeader("OVERWRITE"); | |
1333 | fRunLoader->CdGAFile(); | |
1334 | fRunLoader->Write(0, TObject::kOverwrite); | |
1335 | // AliTracker::SetFieldMap(???); | |
1336 | } | |
1337 | ||
1338 | return kTRUE; | |
1339 | } | |
1340 | ||
c757bafd | 1341 | //_____________________________________________________________________________ |
b8cd5251 | 1342 | AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet) |
c757bafd | 1343 | { |
f08fc9f5 | 1344 | // get the reconstructor object and the loader for a detector |
c757bafd | 1345 | |
b8cd5251 | 1346 | if (fReconstructor[iDet]) return fReconstructor[iDet]; |
1347 | ||
1348 | // load the reconstructor object | |
1349 | TPluginManager* pluginManager = gROOT->GetPluginManager(); | |
1350 | TString detName = fgkDetectorName[iDet]; | |
1351 | TString recName = "Ali" + detName + "Reconstructor"; | |
f08fc9f5 | 1352 | if (gAlice && !gAlice->GetDetector(detName) && (detName != "HLT")) return NULL; |
b8cd5251 | 1353 | |
1354 | if (detName == "HLT") { | |
1355 | if (!gROOT->GetClass("AliLevel3")) { | |
1356 | gSystem->Load("libAliL3Src.so"); | |
1357 | gSystem->Load("libAliL3Misc.so"); | |
1358 | gSystem->Load("libAliL3Hough.so"); | |
1359 | gSystem->Load("libAliL3Comp.so"); | |
1360 | } | |
1361 | } | |
1362 | ||
1363 | AliReconstructor* reconstructor = NULL; | |
1364 | // first check if a plugin is defined for the reconstructor | |
1365 | TPluginHandler* pluginHandler = | |
1366 | pluginManager->FindHandler("AliReconstructor", detName); | |
f08fc9f5 | 1367 | // if not, add a plugin for it |
1368 | if (!pluginHandler) { | |
b8cd5251 | 1369 | AliDebug(1, Form("defining plugin for %s", recName.Data())); |
b26c3770 | 1370 | TString libs = gSystem->GetLibraries(); |
1371 | if (libs.Contains("lib" + detName + "base.so") || | |
1372 | (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
b8cd5251 | 1373 | pluginManager->AddHandler("AliReconstructor", detName, |
1374 | recName, detName + "rec", recName + "()"); | |
1375 | } else { | |
1376 | pluginManager->AddHandler("AliReconstructor", detName, | |
1377 | recName, detName, recName + "()"); | |
c757bafd | 1378 | } |
b8cd5251 | 1379 | pluginHandler = pluginManager->FindHandler("AliReconstructor", detName); |
1380 | } | |
1381 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
1382 | reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0); | |
c757bafd | 1383 | } |
b8cd5251 | 1384 | if (reconstructor) { |
1385 | TObject* obj = fOptions.FindObject(detName.Data()); | |
1386 | if (obj) reconstructor->SetOption(obj->GetTitle()); | |
b26c3770 | 1387 | reconstructor->Init(fRunLoader); |
b8cd5251 | 1388 | fReconstructor[iDet] = reconstructor; |
1389 | } | |
1390 | ||
f08fc9f5 | 1391 | // get or create the loader |
1392 | if (detName != "HLT") { | |
1393 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); | |
1394 | if (!fLoader[iDet]) { | |
1395 | AliConfig::Instance() | |
1396 | ->CreateDetectorFolders(fRunLoader->GetEventFolder(), | |
1397 | detName, detName); | |
1398 | // first check if a plugin is defined for the loader | |
1399 | TPluginHandler* pluginHandler = | |
1400 | pluginManager->FindHandler("AliLoader", detName); | |
1401 | // if not, add a plugin for it | |
1402 | if (!pluginHandler) { | |
1403 | TString loaderName = "Ali" + detName + "Loader"; | |
1404 | AliDebug(1, Form("defining plugin for %s", loaderName.Data())); | |
1405 | pluginManager->AddHandler("AliLoader", detName, | |
1406 | loaderName, detName + "base", | |
1407 | loaderName + "(const char*, TFolder*)"); | |
1408 | pluginHandler = pluginManager->FindHandler("AliLoader", detName); | |
1409 | } | |
1410 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
1411 | fLoader[iDet] = | |
1412 | (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(), | |
1413 | fRunLoader->GetEventFolder()); | |
1414 | } | |
1415 | if (!fLoader[iDet]) { // use default loader | |
1416 | fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder()); | |
1417 | } | |
1418 | if (!fLoader[iDet]) { | |
1419 | AliWarning(Form("couldn't get loader for %s", detName.Data())); | |
6667b602 | 1420 | if (fStopOnError) return NULL; |
f08fc9f5 | 1421 | } else { |
1422 | fRunLoader->AddLoader(fLoader[iDet]); | |
1423 | fRunLoader->CdGAFile(); | |
1424 | if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE"); | |
1425 | fRunLoader->Write(0, TObject::kOverwrite); | |
1426 | } | |
1427 | } | |
1428 | } | |
1429 | ||
b8cd5251 | 1430 | return reconstructor; |
c757bafd | 1431 | } |
1432 | ||
2257f27e | 1433 | //_____________________________________________________________________________ |
1434 | Bool_t AliReconstruction::CreateVertexer() | |
1435 | { | |
1436 | // create the vertexer | |
1437 | ||
b8cd5251 | 1438 | fVertexer = NULL; |
1439 | AliReconstructor* itsReconstructor = GetReconstructor(0); | |
59697224 | 1440 | if (itsReconstructor) { |
b8cd5251 | 1441 | fVertexer = itsReconstructor->CreateVertexer(fRunLoader); |
2257f27e | 1442 | } |
b8cd5251 | 1443 | if (!fVertexer) { |
815c2b38 | 1444 | AliWarning("couldn't create a vertexer for ITS"); |
2257f27e | 1445 | if (fStopOnError) return kFALSE; |
1446 | } | |
1447 | ||
1448 | return kTRUE; | |
1449 | } | |
1450 | ||
24f7a148 | 1451 | //_____________________________________________________________________________ |
b8cd5251 | 1452 | Bool_t AliReconstruction::CreateTrackers(const TString& detectors) |
24f7a148 | 1453 | { |
f08fc9f5 | 1454 | // create the trackers |
24f7a148 | 1455 | |
b8cd5251 | 1456 | TString detStr = detectors; |
1457 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1458 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
1459 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
1460 | if (!reconstructor) continue; | |
1461 | TString detName = fgkDetectorName[iDet]; | |
1f46a9ae | 1462 | if (detName == "HLT") { |
1463 | fRunHLTTracking = kTRUE; | |
1464 | continue; | |
1465 | } | |
f08fc9f5 | 1466 | |
1467 | fTracker[iDet] = reconstructor->CreateTracker(fRunLoader); | |
1468 | if (!fTracker[iDet] && (iDet < 7)) { | |
1469 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); | |
8250d5f5 | 1470 | if (fStopOnError) return kFALSE; |
1471 | } | |
1472 | } | |
1473 | ||
24f7a148 | 1474 | return kTRUE; |
1475 | } | |
1476 | ||
e583c30d | 1477 | //_____________________________________________________________________________ |
b26c3770 | 1478 | void AliReconstruction::CleanUp(TFile* file, TFile* fileOld) |
e583c30d | 1479 | { |
1480 | // delete trackers and the run loader and close and delete the file | |
1481 | ||
b8cd5251 | 1482 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1483 | delete fReconstructor[iDet]; | |
1484 | fReconstructor[iDet] = NULL; | |
1485 | fLoader[iDet] = NULL; | |
1486 | delete fTracker[iDet]; | |
1487 | fTracker[iDet] = NULL; | |
1488 | } | |
1489 | delete fVertexer; | |
1490 | fVertexer = NULL; | |
e583c30d | 1491 | |
1492 | delete fRunLoader; | |
1493 | fRunLoader = NULL; | |
b649205a | 1494 | delete fRawReader; |
1495 | fRawReader = NULL; | |
e583c30d | 1496 | |
1497 | if (file) { | |
1498 | file->Close(); | |
1499 | delete file; | |
1500 | } | |
b26c3770 | 1501 | |
1502 | if (fileOld) { | |
1503 | fileOld->Close(); | |
1504 | delete fileOld; | |
1505 | gSystem->Unlink("AliESDs.old.root"); | |
1506 | } | |
e583c30d | 1507 | } |
24f7a148 | 1508 | |
1509 | ||
1510 | //_____________________________________________________________________________ | |
1511 | Bool_t AliReconstruction::ReadESD(AliESD*& esd, const char* recStep) const | |
1512 | { | |
1513 | // read the ESD event from a file | |
1514 | ||
1515 | if (!esd) return kFALSE; | |
1516 | char fileName[256]; | |
1517 | sprintf(fileName, "ESD_%d.%d_%s.root", | |
1518 | esd->GetRunNumber(), esd->GetEventNumber(), recStep); | |
1519 | if (gSystem->AccessPathName(fileName)) return kFALSE; | |
1520 | ||
f3a97c86 | 1521 | AliInfo(Form("reading ESD from file %s", fileName)); |
815c2b38 | 1522 | AliDebug(1, Form("reading ESD from file %s", fileName)); |
24f7a148 | 1523 | TFile* file = TFile::Open(fileName); |
1524 | if (!file || !file->IsOpen()) { | |
815c2b38 | 1525 | AliError(Form("opening %s failed", fileName)); |
24f7a148 | 1526 | delete file; |
1527 | return kFALSE; | |
1528 | } | |
1529 | ||
1530 | gROOT->cd(); | |
1531 | delete esd; | |
1532 | esd = (AliESD*) file->Get("ESD"); | |
1533 | file->Close(); | |
1534 | delete file; | |
1535 | return kTRUE; | |
1536 | } | |
1537 | ||
1538 | //_____________________________________________________________________________ | |
1539 | void AliReconstruction::WriteESD(AliESD* esd, const char* recStep) const | |
1540 | { | |
1541 | // write the ESD event to a file | |
1542 | ||
1543 | if (!esd) return; | |
1544 | char fileName[256]; | |
1545 | sprintf(fileName, "ESD_%d.%d_%s.root", | |
1546 | esd->GetRunNumber(), esd->GetEventNumber(), recStep); | |
1547 | ||
815c2b38 | 1548 | AliDebug(1, Form("writing ESD to file %s", fileName)); |
24f7a148 | 1549 | TFile* file = TFile::Open(fileName, "recreate"); |
1550 | if (!file || !file->IsOpen()) { | |
815c2b38 | 1551 | AliError(Form("opening %s failed", fileName)); |
24f7a148 | 1552 | } else { |
1553 | esd->Write("ESD"); | |
1554 | file->Close(); | |
1555 | } | |
1556 | delete file; | |
1557 | } | |
f3a97c86 | 1558 | |
1559 | ||
1560 | ||
1561 | ||
1562 | //_____________________________________________________________________________ | |
1563 | void AliReconstruction::CreateTag(TFile* file) | |
1564 | { | |
2bdb9d38 | 1565 | ///////////// |
1566 | //muon code// | |
1567 | //////////// | |
56982dd1 | 1568 | Double_t fMUONMASS = 0.105658369; |
2bdb9d38 | 1569 | //Variables |
56982dd1 | 1570 | Double_t fX,fY,fZ ; |
1571 | Double_t fThetaX, fThetaY, fPyz, fChisquare; | |
1572 | Double_t fPxRec,fPyRec, fPzRec, fEnergy; | |
1573 | Int_t fCharge; | |
1574 | TLorentzVector fEPvector; | |
1575 | ||
1576 | Float_t fZVertexCut = 10.0; | |
1577 | Float_t fRhoVertexCut = 2.0; | |
1578 | ||
1579 | Float_t fLowPtCut = 1.0; | |
1580 | Float_t fHighPtCut = 3.0; | |
1581 | Float_t fVeryHighPtCut = 10.0; | |
2bdb9d38 | 1582 | //////////// |
1583 | ||
1584 | Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05}; | |
1585 | ||
089bf903 | 1586 | // Creates the tags for all the events in a given ESD file |
4302e20f | 1587 | Int_t ntrack; |
089bf903 | 1588 | Int_t nProtons, nKaons, nPions, nMuons, nElectrons; |
1589 | Int_t nPos, nNeg, nNeutr; | |
1590 | Int_t nK0s, nNeutrons, nPi0s, nGamas; | |
1591 | Int_t nCh1GeV, nCh3GeV, nCh10GeV; | |
1592 | Int_t nMu1GeV, nMu3GeV, nMu10GeV; | |
1593 | Int_t nEl1GeV, nEl3GeV, nEl10GeV; | |
1594 | Float_t maxPt = .0, meanPt = .0, totalP = .0; | |
d1a50cb5 | 1595 | Int_t fVertexflag; |
1387d165 | 1596 | Int_t iRunNumber = 0; |
547d75a6 | 1597 | TString fVertexName("default"); |
4302e20f | 1598 | |
f3a97c86 | 1599 | AliRunTag *tag = new AliRunTag(); |
f3a97c86 | 1600 | AliEventTag *evTag = new AliEventTag(); |
1601 | TTree ttag("T","A Tree with event tags"); | |
2bdb9d38 | 1602 | TBranch * btag = ttag.Branch("AliTAG", &tag); |
f3a97c86 | 1603 | btag->SetCompressionLevel(9); |
2bdb9d38 | 1604 | |
f3a97c86 | 1605 | AliInfo(Form("Creating the tags.......")); |
1606 | ||
1607 | if (!file || !file->IsOpen()) { | |
1608 | AliError(Form("opening failed")); | |
1609 | delete file; | |
1610 | return ; | |
2bdb9d38 | 1611 | } |
1612 | Int_t firstEvent = 0,lastEvent = 0; | |
f3a97c86 | 1613 | TTree *t = (TTree*) file->Get("esdTree"); |
1614 | TBranch * b = t->GetBranch("ESD"); | |
1615 | AliESD *esd = 0; | |
1616 | b->SetAddress(&esd); | |
1387d165 | 1617 | |
1618 | b->GetEntry(0); | |
1619 | Int_t iInitRunNumber = esd->GetRunNumber(); | |
2bdb9d38 | 1620 | |
089bf903 | 1621 | Int_t iNumberOfEvents = b->GetEntries(); |
2bdb9d38 | 1622 | for (Int_t iEventNumber = 0; iEventNumber < iNumberOfEvents; iEventNumber++) { |
1623 | ntrack = 0; | |
1624 | nPos = 0; | |
1625 | nNeg = 0; | |
1626 | nNeutr =0; | |
1627 | nK0s = 0; | |
1628 | nNeutrons = 0; | |
1629 | nPi0s = 0; | |
1630 | nGamas = 0; | |
1631 | nProtons = 0; | |
1632 | nKaons = 0; | |
1633 | nPions = 0; | |
1634 | nMuons = 0; | |
1635 | nElectrons = 0; | |
1636 | nCh1GeV = 0; | |
1637 | nCh3GeV = 0; | |
1638 | nCh10GeV = 0; | |
1639 | nMu1GeV = 0; | |
1640 | nMu3GeV = 0; | |
1641 | nMu10GeV = 0; | |
1642 | nEl1GeV = 0; | |
1643 | nEl3GeV = 0; | |
1644 | nEl10GeV = 0; | |
1645 | maxPt = .0; | |
1646 | meanPt = .0; | |
1647 | totalP = .0; | |
547d75a6 | 1648 | fVertexflag = 0; |
d1a50cb5 | 1649 | |
2bdb9d38 | 1650 | b->GetEntry(iEventNumber); |
1387d165 | 1651 | iRunNumber = esd->GetRunNumber(); |
1652 | if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!"); | |
2bdb9d38 | 1653 | const AliESDVertex * vertexIn = esd->GetVertex(); |
547d75a6 | 1654 | if (!vertexIn) AliError("ESD has not defined vertex."); |
1655 | if (vertexIn) fVertexName = vertexIn->GetName(); | |
1656 | if(fVertexName != "default") fVertexflag = 1; | |
2bdb9d38 | 1657 | for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) { |
1658 | AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber); | |
1659 | UInt_t status = esdTrack->GetStatus(); | |
f3a97c86 | 1660 | |
2bdb9d38 | 1661 | //select only tracks with ITS refit |
1662 | if ((status&AliESDtrack::kITSrefit)==0) continue; | |
1663 | //select only tracks with TPC refit | |
1664 | if ((status&AliESDtrack::kTPCrefit)==0) continue; | |
4302e20f | 1665 | |
2bdb9d38 | 1666 | //select only tracks with the "combined PID" |
1667 | if ((status&AliESDtrack::kESDpid)==0) continue; | |
1668 | Double_t p[3]; | |
1669 | esdTrack->GetPxPyPz(p); | |
1670 | Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2)); | |
1671 | Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2)); | |
1672 | totalP += momentum; | |
1673 | meanPt += fPt; | |
1674 | if(fPt > maxPt) maxPt = fPt; | |
4302e20f | 1675 | |
2bdb9d38 | 1676 | if(esdTrack->GetSign() > 0) { |
1677 | nPos++; | |
56982dd1 | 1678 | if(fPt > fLowPtCut) nCh1GeV++; |
1679 | if(fPt > fHighPtCut) nCh3GeV++; | |
1680 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
2bdb9d38 | 1681 | } |
1682 | if(esdTrack->GetSign() < 0) { | |
1683 | nNeg++; | |
56982dd1 | 1684 | if(fPt > fLowPtCut) nCh1GeV++; |
1685 | if(fPt > fHighPtCut) nCh3GeV++; | |
1686 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
2bdb9d38 | 1687 | } |
1688 | if(esdTrack->GetSign() == 0) nNeutr++; | |
4302e20f | 1689 | |
2bdb9d38 | 1690 | //PID |
1691 | Double_t prob[5]; | |
1692 | esdTrack->GetESDpid(prob); | |
4302e20f | 1693 | |
2bdb9d38 | 1694 | Double_t rcc = 0.0; |
1695 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i]; | |
1696 | if(rcc == 0.0) continue; | |
1697 | //Bayes' formula | |
1698 | Double_t w[5]; | |
1699 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc; | |
4302e20f | 1700 | |
2bdb9d38 | 1701 | //protons |
1702 | if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++; | |
1703 | //kaons | |
1704 | if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++; | |
1705 | //pions | |
1706 | if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++; | |
1707 | //electrons | |
1708 | if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) { | |
1709 | nElectrons++; | |
56982dd1 | 1710 | if(fPt > fLowPtCut) nEl1GeV++; |
1711 | if(fPt > fHighPtCut) nEl3GeV++; | |
1712 | if(fPt > fVeryHighPtCut) nEl10GeV++; | |
2bdb9d38 | 1713 | } |
1714 | ntrack++; | |
1715 | }//track loop | |
1716 | ||
1717 | ///////////// | |
1718 | //muon code// | |
1719 | //////////// | |
1720 | Int_t nMuonTracks = esd->GetNumberOfMuonTracks(); | |
1721 | // loop over all reconstructed tracks (also first track of combination) | |
1722 | for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) { | |
1723 | AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack); | |
1724 | if (muonTrack == 0x0) continue; | |
4302e20f | 1725 | |
2bdb9d38 | 1726 | // Coordinates at vertex |
56982dd1 | 1727 | fZ = muonTrack->GetZ(); |
1728 | fY = muonTrack->GetBendingCoor(); | |
1729 | fX = muonTrack->GetNonBendingCoor(); | |
4302e20f | 1730 | |
56982dd1 | 1731 | fThetaX = muonTrack->GetThetaX(); |
1732 | fThetaY = muonTrack->GetThetaY(); | |
4302e20f | 1733 | |
56982dd1 | 1734 | fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum()); |
1735 | fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY)); | |
1736 | fPxRec = fPzRec * TMath::Tan(fThetaX); | |
1737 | fPyRec = fPzRec * TMath::Tan(fThetaY); | |
1738 | fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum())); | |
f3a97c86 | 1739 | |
2bdb9d38 | 1740 | //ChiSquare of the track if needed |
56982dd1 | 1741 | fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5); |
1742 | fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec); | |
1743 | fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy); | |
4302e20f | 1744 | |
2bdb9d38 | 1745 | // total number of muons inside a vertex cut |
56982dd1 | 1746 | if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) { |
2bdb9d38 | 1747 | nMuons++; |
56982dd1 | 1748 | if(fEPvector.Pt() > fLowPtCut) { |
2bdb9d38 | 1749 | nMu1GeV++; |
56982dd1 | 1750 | if(fEPvector.Pt() > fHighPtCut) { |
2bdb9d38 | 1751 | nMu3GeV++; |
56982dd1 | 1752 | if (fEPvector.Pt() > fVeryHighPtCut) { |
2bdb9d38 | 1753 | nMu10GeV++; |
1754 | } | |
1755 | } | |
1756 | } | |
1757 | } | |
1758 | }//muon track loop | |
1759 | ||
1760 | // Fill the event tags | |
1761 | if(ntrack != 0) | |
1762 | meanPt = meanPt/ntrack; | |
1763 | ||
1764 | evTag->SetEventId(iEventNumber+1); | |
547d75a6 | 1765 | if (vertexIn) { |
1766 | evTag->SetVertexX(vertexIn->GetXv()); | |
1767 | evTag->SetVertexY(vertexIn->GetYv()); | |
1768 | evTag->SetVertexZ(vertexIn->GetZv()); | |
1769 | evTag->SetVertexZError(vertexIn->GetZRes()); | |
1770 | } | |
d1a50cb5 | 1771 | evTag->SetVertexFlag(fVertexflag); |
1772 | ||
2bdb9d38 | 1773 | evTag->SetT0VertexZ(esd->GetT0zVertex()); |
1774 | ||
8bd8ac26 | 1775 | evTag->SetTriggerMask(esd->GetTriggerMask()); |
1776 | evTag->SetTriggerCluster(esd->GetTriggerCluster()); | |
2bdb9d38 | 1777 | |
32a5cab4 | 1778 | evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy()); |
1779 | evTag->SetZDCProton1Energy(esd->GetZDCP1Energy()); | |
1780 | evTag->SetZDCNeutron2Energy(esd->GetZDCN2Energy()); | |
1781 | evTag->SetZDCProton2Energy(esd->GetZDCP2Energy()); | |
2bdb9d38 | 1782 | evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy()); |
1783 | evTag->SetNumOfParticipants(esd->GetZDCParticipants()); | |
1784 | ||
1785 | ||
1786 | evTag->SetNumOfTracks(esd->GetNumberOfTracks()); | |
1787 | evTag->SetNumOfPosTracks(nPos); | |
1788 | evTag->SetNumOfNegTracks(nNeg); | |
1789 | evTag->SetNumOfNeutrTracks(nNeutr); | |
1790 | ||
1791 | evTag->SetNumOfV0s(esd->GetNumberOfV0s()); | |
1792 | evTag->SetNumOfCascades(esd->GetNumberOfCascades()); | |
1793 | evTag->SetNumOfKinks(esd->GetNumberOfKinks()); | |
1794 | evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks()); | |
1795 | ||
1796 | evTag->SetNumOfProtons(nProtons); | |
1797 | evTag->SetNumOfKaons(nKaons); | |
1798 | evTag->SetNumOfPions(nPions); | |
1799 | evTag->SetNumOfMuons(nMuons); | |
1800 | evTag->SetNumOfElectrons(nElectrons); | |
1801 | evTag->SetNumOfPhotons(nGamas); | |
1802 | evTag->SetNumOfPi0s(nPi0s); | |
1803 | evTag->SetNumOfNeutrons(nNeutrons); | |
1804 | evTag->SetNumOfKaon0s(nK0s); | |
1805 | ||
1806 | evTag->SetNumOfChargedAbove1GeV(nCh1GeV); | |
1807 | evTag->SetNumOfChargedAbove3GeV(nCh3GeV); | |
1808 | evTag->SetNumOfChargedAbove10GeV(nCh10GeV); | |
1809 | evTag->SetNumOfMuonsAbove1GeV(nMu1GeV); | |
1810 | evTag->SetNumOfMuonsAbove3GeV(nMu3GeV); | |
1811 | evTag->SetNumOfMuonsAbove10GeV(nMu10GeV); | |
1812 | evTag->SetNumOfElectronsAbove1GeV(nEl1GeV); | |
1813 | evTag->SetNumOfElectronsAbove3GeV(nEl3GeV); | |
1814 | evTag->SetNumOfElectronsAbove10GeV(nEl10GeV); | |
1815 | ||
85c60a8e | 1816 | evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters()); |
1817 | evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters()); | |
2bdb9d38 | 1818 | |
1819 | evTag->SetTotalMomentum(totalP); | |
1820 | evTag->SetMeanPt(meanPt); | |
1821 | evTag->SetMaxPt(maxPt); | |
1822 | ||
1387d165 | 1823 | tag->SetRunId(iInitRunNumber); |
2bdb9d38 | 1824 | tag->AddEventTag(*evTag); |
1825 | } | |
089bf903 | 1826 | lastEvent = iNumberOfEvents; |
f3a97c86 | 1827 | |
1828 | ttag.Fill(); | |
1829 | tag->Clear(); | |
1830 | ||
1831 | char fileName[256]; | |
1832 | sprintf(fileName, "Run%d.Event%d_%d.ESD.tag.root", | |
1833 | tag->GetRunId(),firstEvent,lastEvent ); | |
1834 | AliInfo(Form("writing tags to file %s", fileName)); | |
1835 | AliDebug(1, Form("writing tags to file %s", fileName)); | |
1836 | ||
1837 | TFile* ftag = TFile::Open(fileName, "recreate"); | |
1838 | ftag->cd(); | |
1839 | ttag.Write(); | |
1840 | ftag->Close(); | |
1841 | file->cd(); | |
1842 | delete tag; | |
f3a97c86 | 1843 | delete evTag; |
1844 | } | |
1845 | ||
98937d93 | 1846 | void AliReconstruction::WriteAlignmentData(AliESD* esd) |
1847 | { | |
1848 | // Write space-points which are then used in the alignment procedures | |
1849 | // For the moment only ITS, TRD and TPC | |
1850 | ||
1851 | // Load TOF clusters | |
d528ee75 | 1852 | if (fTracker[3]){ |
1853 | fLoader[3]->LoadRecPoints("read"); | |
1854 | TTree* tree = fLoader[3]->TreeR(); | |
1855 | if (!tree) { | |
1856 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[3])); | |
1857 | return; | |
1858 | } | |
1859 | fTracker[3]->LoadClusters(tree); | |
98937d93 | 1860 | } |
98937d93 | 1861 | Int_t ntracks = esd->GetNumberOfTracks(); |
1862 | for (Int_t itrack = 0; itrack < ntracks; itrack++) | |
1863 | { | |
1864 | AliESDtrack *track = esd->GetTrack(itrack); | |
1865 | Int_t nsp = 0; | |
ef7253ac | 1866 | Int_t idx[200]; |
98937d93 | 1867 | for (Int_t iDet = 3; iDet >= 0; iDet--) |
1868 | nsp += track->GetNcls(iDet); | |
1869 | if (nsp) { | |
1870 | AliTrackPointArray *sp = new AliTrackPointArray(nsp); | |
1871 | track->SetTrackPointArray(sp); | |
1872 | Int_t isptrack = 0; | |
1873 | for (Int_t iDet = 3; iDet >= 0; iDet--) { | |
1874 | AliTracker *tracker = fTracker[iDet]; | |
1875 | if (!tracker) continue; | |
1876 | Int_t nspdet = track->GetNcls(iDet); | |
98937d93 | 1877 | if (nspdet <= 0) continue; |
1878 | track->GetClusters(iDet,idx); | |
1879 | AliTrackPoint p; | |
1880 | Int_t isp = 0; | |
1881 | Int_t isp2 = 0; | |
1882 | while (isp < nspdet) { | |
1883 | Bool_t isvalid = tracker->GetTrackPoint(idx[isp2],p); isp2++; | |
160db090 | 1884 | const Int_t kNTPCmax = 159; |
1885 | if (iDet==1 && isp2>kNTPCmax) break; // to be fixed | |
98937d93 | 1886 | if (!isvalid) continue; |
1887 | sp->AddPoint(isptrack,&p); isptrack++; isp++; | |
1888 | } | |
98937d93 | 1889 | } |
1890 | } | |
1891 | } | |
d528ee75 | 1892 | if (fTracker[3]){ |
1893 | fTracker[3]->UnloadClusters(); | |
1894 | fLoader[3]->UnloadRecPoints(); | |
1895 | } | |
98937d93 | 1896 | } |