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