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