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