]>
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 | // // |
cd0b062e | 104 | // The input data of a detector can be replaced by the corresponding HLT // |
105 | // data by calling (usual detector string) // | |
106 | // SetUseHLTData("..."); // | |
107 | // // | |
24f7a148 | 108 | // For debug purposes the method SetCheckPointLevel can be used. If the // |
109 | // argument is greater than 0, files with ESD events will be written after // | |
110 | // selected steps of the reconstruction for each event: // | |
111 | // level 1: after tracking and after filling of ESD (final) // | |
112 | // level 2: in addition after each tracking step // | |
113 | // level 3: in addition after the filling of ESD for each detector // | |
114 | // If a final check point file exists for an event, this event will be // | |
115 | // skipped in the reconstruction. The tracking and the filling of ESD for // | |
116 | // a detector will be skipped as well, if the corresponding check point // | |
117 | // file exists. The ESD event will then be loaded from the file instead. // | |
118 | // // | |
596a855f | 119 | /////////////////////////////////////////////////////////////////////////////// |
120 | ||
024a7e64 | 121 | #include <TArrayF.h> |
122 | #include <TFile.h> | |
444753c6 | 123 | #include <TList.h> |
024a7e64 | 124 | #include <TSystem.h> |
125 | #include <TROOT.h> | |
126 | #include <TPluginManager.h> | |
3103d196 | 127 | #include <TGeoManager.h> |
2bdb9d38 | 128 | #include <TLorentzVector.h> |
3dd9f9e3 | 129 | #include <TArrayS.h> |
130 | #include <TArrayD.h> | |
3c3709c4 | 131 | #include <TObjArray.h> |
325aa76f | 132 | #include <TMap.h> |
596a855f | 133 | |
134 | #include "AliReconstruction.h" | |
87932dab | 135 | #include "AliCodeTimer.h" |
b8cd5251 | 136 | #include "AliReconstructor.h" |
815c2b38 | 137 | #include "AliLog.h" |
596a855f | 138 | #include "AliRunLoader.h" |
139 | #include "AliRun.h" | |
b649205a | 140 | #include "AliRawReaderFile.h" |
141 | #include "AliRawReaderDate.h" | |
142 | #include "AliRawReaderRoot.h" | |
001397cd | 143 | #include "AliRawEventHeaderBase.h" |
af885e0f | 144 | #include "AliESDEvent.h" |
faffd83e | 145 | #include "AliESDMuonTrack.h" |
1d99986f | 146 | #include "AliESDfriend.h" |
2257f27e | 147 | #include "AliESDVertex.h" |
faffd83e | 148 | #include "AliESDcascade.h" |
149 | #include "AliESDkink.h" | |
150 | #include "AliESDtrack.h" | |
151 | #include "AliESDCaloCluster.h" | |
e649177a | 152 | #include "AliESDCaloCells.h" |
32e449be | 153 | #include "AliMultiplicity.h" |
c84a5e9e | 154 | #include "AliTracker.h" |
2257f27e | 155 | #include "AliVertexer.h" |
c5e3e5d1 | 156 | #include "AliVertexerTracks.h" |
5e4ff34d | 157 | #include "AliV0vertexer.h" |
158 | #include "AliCascadeVertexer.h" | |
596a855f | 159 | #include "AliHeader.h" |
160 | #include "AliGenEventHeader.h" | |
b26c3770 | 161 | #include "AliPID.h" |
596a855f | 162 | #include "AliESDpid.h" |
ff8bb5ae | 163 | #include "AliESDtrack.h" |
3dd9f9e3 | 164 | #include "AliESDPmdTrack.h" |
f3a97c86 | 165 | |
08e1a23e | 166 | #include "AliESDTagCreator.h" |
a1069ee1 | 167 | #include "AliAODTagCreator.h" |
f3a97c86 | 168 | |
25be1e5c | 169 | #include "AliGeomManager.h" |
98937d93 | 170 | #include "AliTrackPointArray.h" |
b0314964 | 171 | #include "AliCDBManager.h" |
795e4a22 | 172 | #include "AliCDBStorage.h" |
6bae477a | 173 | #include "AliCDBEntry.h" |
174 | #include "AliAlignObj.h" | |
f3a97c86 | 175 | |
b647652d | 176 | #include "AliCentralTrigger.h" |
b024fd7f | 177 | #include "AliTriggerConfiguration.h" |
178 | #include "AliTriggerClass.h" | |
b647652d | 179 | #include "AliCTPRawStream.h" |
180 | ||
04236e67 | 181 | #include "AliQADataMakerRec.h" |
aa3c69a9 | 182 | #include "AliGlobalQADataMaker.h" |
c65c502a | 183 | #include "AliQA.h" |
184 | #include "AliQADataMakerSteer.h" | |
f29f1726 | 185 | |
7167ae53 | 186 | #include "AliPlaneEff.h" |
187 | ||
0f88822a | 188 | #include "AliSysInfo.h" // memory snapshots |
cd0b062e | 189 | #include "AliRawHLTManager.h" |
0f88822a | 190 | |
325aa76f | 191 | #include "AliMagWrapCheb.h" |
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 | ||
f8b507e0 | 204 | fUniformField(kFALSE), |
2257f27e | 205 | fRunVertexFinder(kTRUE), |
a84e2607 | 206 | fRunVertexFinderTracks(kTRUE), |
1f46a9ae | 207 | fRunHLTTracking(kFALSE), |
e66fbafb | 208 | fRunMuonTracking(kFALSE), |
d1683eef | 209 | fRunV0Finder(kTRUE), |
210 | fRunCascadeFinder(kTRUE), | |
1d99986f | 211 | fStopOnError(kFALSE), |
212 | fWriteAlignmentData(kFALSE), | |
213 | fWriteESDfriend(kFALSE), | |
a7807689 | 214 | fWriteAOD(kFALSE), |
b647652d | 215 | fFillTriggerESD(kTRUE), |
1d99986f | 216 | |
7f68891d | 217 | fCleanESD(kTRUE), |
a023d8d8 | 218 | fV0DCAmax(3.), |
219 | fV0CsPmin(0.), | |
7f68891d | 220 | fDmax(50.), |
221 | fZmax(50.), | |
222 | ||
1d99986f | 223 | fRunLocalReconstruction("ALL"), |
b8cd5251 | 224 | fRunTracking("ALL"), |
e583c30d | 225 | fFillESD("ALL"), |
48ce48d1 | 226 | fUseTrackingErrorsForAlignment(""), |
e583c30d | 227 | fGAliceFileName(gAliceFilename), |
b649205a | 228 | fInput(""), |
35042093 | 229 | fEquipIdMap(""), |
b26c3770 | 230 | fFirstEvent(0), |
231 | fLastEvent(-1), | |
973388c2 | 232 | fNumberOfEventsPerFile(1), |
24f7a148 | 233 | fCheckPointLevel(0), |
b8cd5251 | 234 | fOptions(), |
6bae477a | 235 | fLoadAlignFromCDB(kTRUE), |
236 | fLoadAlignData("ALL"), | |
46698ae4 | 237 | fESDPar(""), |
cd0b062e | 238 | fUseHLTData(), |
e583c30d | 239 | |
240 | fRunLoader(NULL), | |
b649205a | 241 | fRawReader(NULL), |
cd0b062e | 242 | fParentRawReader(NULL), |
b8cd5251 | 243 | |
98937d93 | 244 | fVertexer(NULL), |
9178838a | 245 | fDiamondProfile(NULL), |
43c9dae1 | 246 | fDiamondProfileTPC(NULL), |
87317a47 | 247 | fMeanVertexConstraint(kTRUE), |
98937d93 | 248 | |
6b6e4472 | 249 | fGRPData(NULL), |
444753c6 | 250 | |
6bae477a | 251 | fAlignObjArray(NULL), |
795e4a22 | 252 | fCDBUri(), |
759c1df1 | 253 | fSpecCDBUri(), |
795e4a22 | 254 | fInitCDBCalled(kFALSE), |
255 | fSetRunNumberFromDataCalled(kFALSE), | |
7e963665 | 256 | fRunQA(kTRUE), |
6b150027 | 257 | fRunGlobalQA(kTRUE), |
7167ae53 | 258 | fInLoopQA(kFALSE), |
e4a998ed | 259 | fSameQACycle(kFALSE), |
7167ae53 | 260 | |
21a3aa09 | 261 | fRunPlaneEff(kFALSE), |
262 | ||
263 | fesd(NULL), | |
264 | fhltesd(NULL), | |
265 | fesdf(NULL), | |
266 | ffile(NULL), | |
267 | ftree(NULL), | |
268 | fhlttree(NULL), | |
269 | ffileOld(NULL), | |
270 | ftreeOld(NULL), | |
271 | fhlttreeOld(NULL), | |
272 | ftVertexer(NULL), | |
14dd053c | 273 | fIsNewRunLoader(kFALSE), |
274 | fRunAliEVE(kFALSE) | |
596a855f | 275 | { |
276 | // create reconstruction object with default parameters | |
b8cd5251 | 277 | |
278 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
279 | fReconstructor[iDet] = NULL; | |
280 | fLoader[iDet] = NULL; | |
281 | fTracker[iDet] = NULL; | |
7e963665 | 282 | fQADataMaker[iDet] = NULL; |
283 | fQACycles[iDet] = 999999; | |
b8cd5251 | 284 | } |
aa3c69a9 | 285 | fQADataMaker[fgkNDetectors]=NULL; //Global QA |
e47c4c2e | 286 | AliPID pid; |
596a855f | 287 | } |
288 | ||
289 | //_____________________________________________________________________________ | |
290 | AliReconstruction::AliReconstruction(const AliReconstruction& rec) : | |
e583c30d | 291 | TNamed(rec), |
292 | ||
c84a5e9e | 293 | fUniformField(rec.fUniformField), |
2257f27e | 294 | fRunVertexFinder(rec.fRunVertexFinder), |
a84e2607 | 295 | fRunVertexFinderTracks(rec.fRunVertexFinderTracks), |
1f46a9ae | 296 | fRunHLTTracking(rec.fRunHLTTracking), |
e66fbafb | 297 | fRunMuonTracking(rec.fRunMuonTracking), |
d1683eef | 298 | fRunV0Finder(rec.fRunV0Finder), |
299 | fRunCascadeFinder(rec.fRunCascadeFinder), | |
1d99986f | 300 | fStopOnError(rec.fStopOnError), |
301 | fWriteAlignmentData(rec.fWriteAlignmentData), | |
302 | fWriteESDfriend(rec.fWriteESDfriend), | |
a7807689 | 303 | fWriteAOD(rec.fWriteAOD), |
b647652d | 304 | fFillTriggerESD(rec.fFillTriggerESD), |
1d99986f | 305 | |
7f68891d | 306 | fCleanESD(rec.fCleanESD), |
a023d8d8 | 307 | fV0DCAmax(rec.fV0DCAmax), |
5e5c1aa9 | 308 | fV0CsPmin(rec.fV0CsPmin), |
7f68891d | 309 | fDmax(rec.fDmax), |
310 | fZmax(rec.fZmax), | |
311 | ||
1d99986f | 312 | fRunLocalReconstruction(rec.fRunLocalReconstruction), |
e583c30d | 313 | fRunTracking(rec.fRunTracking), |
314 | fFillESD(rec.fFillESD), | |
48ce48d1 | 315 | fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment), |
e583c30d | 316 | fGAliceFileName(rec.fGAliceFileName), |
b649205a | 317 | fInput(rec.fInput), |
35042093 | 318 | fEquipIdMap(rec.fEquipIdMap), |
b26c3770 | 319 | fFirstEvent(rec.fFirstEvent), |
320 | fLastEvent(rec.fLastEvent), | |
973388c2 | 321 | fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile), |
24f7a148 | 322 | fCheckPointLevel(0), |
b8cd5251 | 323 | fOptions(), |
6bae477a | 324 | fLoadAlignFromCDB(rec.fLoadAlignFromCDB), |
325 | fLoadAlignData(rec.fLoadAlignData), | |
46698ae4 | 326 | fESDPar(rec.fESDPar), |
2972d4eb | 327 | fUseHLTData(rec.fUseHLTData), |
e583c30d | 328 | |
329 | fRunLoader(NULL), | |
b649205a | 330 | fRawReader(NULL), |
2972d4eb | 331 | fParentRawReader(NULL), |
b8cd5251 | 332 | |
98937d93 | 333 | fVertexer(NULL), |
9178838a | 334 | fDiamondProfile(NULL), |
43c9dae1 | 335 | fDiamondProfileTPC(NULL), |
87317a47 | 336 | fMeanVertexConstraint(rec.fMeanVertexConstraint), |
98937d93 | 337 | |
6b6e4472 | 338 | fGRPData(NULL), |
444753c6 | 339 | |
6bae477a | 340 | fAlignObjArray(rec.fAlignObjArray), |
ec92bee0 | 341 | fCDBUri(rec.fCDBUri), |
7e963665 | 342 | fSpecCDBUri(), |
795e4a22 | 343 | fInitCDBCalled(rec.fInitCDBCalled), |
344 | fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled), | |
aa3c69a9 | 345 | fRunQA(rec.fRunQA), |
346 | fRunGlobalQA(rec.fRunGlobalQA), | |
7167ae53 | 347 | fInLoopQA(rec.fInLoopQA), |
e4a998ed | 348 | fSameQACycle(rec.fSameQACycle), |
21a3aa09 | 349 | fRunPlaneEff(rec.fRunPlaneEff), |
350 | ||
351 | fesd(NULL), | |
352 | fhltesd(NULL), | |
353 | fesdf(NULL), | |
354 | ffile(NULL), | |
355 | ftree(NULL), | |
356 | fhlttree(NULL), | |
357 | ffileOld(NULL), | |
358 | ftreeOld(NULL), | |
359 | fhlttreeOld(NULL), | |
360 | ftVertexer(NULL), | |
14dd053c | 361 | fIsNewRunLoader(rec.fIsNewRunLoader), |
362 | fRunAliEVE(kFALSE) | |
596a855f | 363 | { |
364 | // copy constructor | |
365 | ||
ec92bee0 | 366 | for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) { |
efd2085e | 367 | if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone()); |
368 | } | |
b8cd5251 | 369 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
370 | fReconstructor[iDet] = NULL; | |
371 | fLoader[iDet] = NULL; | |
372 | fTracker[iDet] = NULL; | |
7e963665 | 373 | fQADataMaker[iDet] = NULL; |
374 | fQACycles[iDet] = rec.fQACycles[iDet]; | |
b8cd5251 | 375 | } |
aa3c69a9 | 376 | fQADataMaker[fgkNDetectors]=NULL; //Global QA |
ec92bee0 | 377 | for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) { |
378 | if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone()); | |
379 | } | |
596a855f | 380 | } |
381 | ||
382 | //_____________________________________________________________________________ | |
383 | AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec) | |
384 | { | |
385 | // assignment operator | |
386 | ||
387 | this->~AliReconstruction(); | |
388 | new(this) AliReconstruction(rec); | |
389 | return *this; | |
390 | } | |
391 | ||
392 | //_____________________________________________________________________________ | |
393 | AliReconstruction::~AliReconstruction() | |
394 | { | |
395 | // clean up | |
396 | ||
e583c30d | 397 | CleanUp(); |
efd2085e | 398 | fOptions.Delete(); |
ec92bee0 | 399 | fSpecCDBUri.Delete(); |
87932dab | 400 | |
401 | AliCodeTimer::Instance()->Print(); | |
596a855f | 402 | } |
403 | ||
024cf675 | 404 | //_____________________________________________________________________________ |
795e4a22 | 405 | void AliReconstruction::InitCDB() |
024cf675 | 406 | { |
407 | // activate a default CDB storage | |
408 | // First check if we have any CDB storage set, because it is used | |
409 | // to retrieve the calibration and alignment constants | |
410 | ||
795e4a22 | 411 | if (fInitCDBCalled) return; |
412 | fInitCDBCalled = kTRUE; | |
413 | ||
024cf675 | 414 | AliCDBManager* man = AliCDBManager::Instance(); |
ec92bee0 | 415 | if (man->IsDefaultStorageSet()) |
024cf675 | 416 | { |
417 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
ec92bee0 | 418 | AliWarning("Default CDB storage has been already set !"); |
419 | AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data())); | |
024cf675 | 420 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
795e4a22 | 421 | fCDBUri = man->GetDefaultStorage()->GetURI(); |
ec92bee0 | 422 | } |
423 | else { | |
795e4a22 | 424 | if (fCDBUri.Length() > 0) |
425 | { | |
426 | AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
427 | AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data())); | |
428 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
429 | } else { | |
430 | fCDBUri="local://$ALICE_ROOT"; | |
431 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
432 | AliWarning("Default CDB storage not yet set !!!!"); | |
433 | AliWarning(Form("Setting it now to: %s", fCDBUri.Data())); | |
434 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
435 | ||
436 | } | |
ec92bee0 | 437 | man->SetDefaultStorage(fCDBUri); |
438 | } | |
439 | ||
440 | // Now activate the detector specific CDB storage locations | |
c3a7b59a | 441 | for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) { |
442 | TObject* obj = fSpecCDBUri[i]; | |
443 | if (!obj) continue; | |
b8ec52f6 | 444 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
445 | AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle())); | |
446 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
c3a7b59a | 447 | man->SetSpecificStorage(obj->GetName(), obj->GetTitle()); |
ec92bee0 | 448 | } |
795e4a22 | 449 | |
024cf675 | 450 | } |
451 | ||
452 | //_____________________________________________________________________________ | |
453 | void AliReconstruction::SetDefaultStorage(const char* uri) { | |
ec92bee0 | 454 | // Store the desired default CDB storage location |
455 | // Activate it later within the Run() method | |
024cf675 | 456 | |
ec92bee0 | 457 | fCDBUri = uri; |
024cf675 | 458 | |
459 | } | |
460 | ||
00aa02d5 | 461 | //_____________________________________________________________________________ |
c3a7b59a | 462 | void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) { |
ec92bee0 | 463 | // Store a detector-specific CDB storage location |
464 | // Activate it later within the Run() method | |
024cf675 | 465 | |
c3a7b59a | 466 | AliCDBPath aPath(calibType); |
467 | if(!aPath.IsValid()){ | |
468 | // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path | |
469 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
470 | if(!strcmp(calibType, fgkDetectorName[iDet])) { | |
471 | aPath.SetPath(Form("%s/*", calibType)); | |
472 | AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data())); | |
473 | break; | |
474 | } | |
475 | } | |
476 | if(!aPath.IsValid()){ | |
477 | AliError(Form("Not a valid path or detector: %s", calibType)); | |
478 | return; | |
479 | } | |
480 | } | |
481 | ||
53dd3c3d | 482 | // // check that calibType refers to a "valid" detector name |
483 | // Bool_t isDetector = kFALSE; | |
484 | // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
485 | // TString detName = fgkDetectorName[iDet]; | |
486 | // if(aPath.GetLevel0() == detName) { | |
487 | // isDetector = kTRUE; | |
488 | // break; | |
489 | // } | |
490 | // } | |
491 | // | |
492 | // if(!isDetector) { | |
493 | // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data())); | |
494 | // return; | |
495 | // } | |
c3a7b59a | 496 | |
497 | TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data()); | |
ec92bee0 | 498 | if (obj) fSpecCDBUri.Remove(obj); |
c3a7b59a | 499 | fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri)); |
024cf675 | 500 | |
501 | } | |
502 | ||
6bae477a | 503 | //_____________________________________________________________________________ |
795e4a22 | 504 | Bool_t AliReconstruction::SetRunNumberFromData() |
6bae477a | 505 | { |
506 | // The method is called in Run() in order | |
507 | // to set a correct run number. | |
508 | // In case of raw data reconstruction the | |
509 | // run number is taken from the raw data header | |
510 | ||
795e4a22 | 511 | if (fSetRunNumberFromDataCalled) return kTRUE; |
512 | fSetRunNumberFromDataCalled = kTRUE; | |
513 | ||
514 | AliCDBManager* man = AliCDBManager::Instance(); | |
515 | ||
516 | if(man->GetRun() > 0) { | |
21a3aa09 | 517 | AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!"); |
795e4a22 | 518 | } |
519 | ||
520 | if (!fRunLoader) { | |
6bae477a | 521 | AliError("No run loader is found !"); |
522 | return kFALSE; | |
523 | } | |
524 | // read run number from gAlice | |
ec92bee0 | 525 | if(fRunLoader->GetAliRun()) |
f2ee4290 | 526 | AliCDBManager::Instance()->SetRun(fRunLoader->GetHeader()->GetRun()); |
ec92bee0 | 527 | else { |
528 | if(fRawReader) { | |
529 | if(fRawReader->NextEvent()) { | |
530 | AliCDBManager::Instance()->SetRun(fRawReader->GetRunNumber()); | |
531 | fRawReader->RewindEvents(); | |
532 | } | |
533 | else { | |
21a3aa09 | 534 | if(man->GetRun() > 0) { |
535 | AliWarning("No raw events is found ! Using settings in AliCDBManager !"); | |
536 | man->Print(); | |
537 | return kTRUE; | |
538 | } | |
539 | else { | |
540 | AliWarning("Neither raw events nor settings in AliCDBManager are found !"); | |
541 | return kFALSE; | |
542 | } | |
ec92bee0 | 543 | } |
544 | } | |
545 | else { | |
546 | AliError("Neither gAlice nor RawReader objects are found !"); | |
547 | return kFALSE; | |
548 | } | |
6bae477a | 549 | } |
795e4a22 | 550 | |
551 | man->Print(); | |
552 | ||
6bae477a | 553 | return kTRUE; |
554 | } | |
555 | ||
795e4a22 | 556 | //_____________________________________________________________________________ |
557 | void AliReconstruction::SetCDBLock() { | |
558 | // Set CDB lock: from now on it is forbidden to reset the run number | |
559 | // or the default storage or to activate any further storage! | |
560 | ||
561 | AliCDBManager::Instance()->SetLock(1); | |
562 | } | |
563 | ||
6bae477a | 564 | //_____________________________________________________________________________ |
565 | Bool_t AliReconstruction::MisalignGeometry(const TString& detectors) | |
566 | { | |
567 | // Read the alignment objects from CDB. | |
568 | // Each detector is supposed to have the | |
569 | // alignment objects in DET/Align/Data CDB path. | |
570 | // All the detector objects are then collected, | |
571 | // sorted by geometry level (starting from ALIC) and | |
572 | // then applied to the TGeo geometry. | |
573 | // Finally an overlaps check is performed. | |
574 | ||
575 | // Load alignment data from CDB and fill fAlignObjArray | |
576 | if(fLoadAlignFromCDB){ | |
6bae477a | 577 | |
25be1e5c | 578 | TString detStr = detectors; |
579 | TString loadAlObjsListOfDets = ""; | |
580 | ||
581 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
582 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
583 | loadAlObjsListOfDets += fgkDetectorName[iDet]; | |
584 | loadAlObjsListOfDets += " "; | |
585 | } // end loop over detectors | |
53dd3c3d | 586 | loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules |
98e303d9 | 587 | AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data()); |
25be1e5c | 588 | }else{ |
589 | // Check if the array with alignment objects was | |
590 | // provided by the user. If yes, apply the objects | |
591 | // to the present TGeo geometry | |
592 | if (fAlignObjArray) { | |
593 | if (gGeoManager && gGeoManager->IsClosed()) { | |
98e303d9 | 594 | if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) { |
25be1e5c | 595 | AliError("The misalignment of one or more volumes failed!" |
596 | "Compare the list of simulated detectors and the list of detector alignment data!"); | |
597 | return kFALSE; | |
598 | } | |
599 | } | |
600 | else { | |
601 | AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!"); | |
6bae477a | 602 | return kFALSE; |
603 | } | |
604 | } | |
6bae477a | 605 | } |
25be1e5c | 606 | |
8e245d15 | 607 | delete fAlignObjArray; fAlignObjArray=0; |
a03b0371 | 608 | |
6bae477a | 609 | return kTRUE; |
610 | } | |
596a855f | 611 | |
612 | //_____________________________________________________________________________ | |
613 | void AliReconstruction::SetGAliceFile(const char* fileName) | |
614 | { | |
615 | // set the name of the galice file | |
616 | ||
617 | fGAliceFileName = fileName; | |
618 | } | |
619 | ||
21a3aa09 | 620 | //_____________________________________________________________________________ |
b58710ef | 621 | void AliReconstruction::SetInput(const char* input) |
21a3aa09 | 622 | { |
b58710ef | 623 | // In case the input string starts with 'mem://', we run in an online mode |
624 | // and AliRawReaderDateOnline object is created. In all other cases a raw-data | |
625 | // file is assumed. One can give as an input: | |
626 | // mem://: - events taken from DAQ monitoring libs online | |
627 | // or | |
628 | // mem://<filename> - emulation of the above mode (via DATE monitoring libs) | |
629 | fInput = input; | |
21a3aa09 | 630 | } |
631 | ||
efd2085e | 632 | //_____________________________________________________________________________ |
633 | void AliReconstruction::SetOption(const char* detector, const char* option) | |
634 | { | |
635 | // set options for the reconstruction of a detector | |
636 | ||
637 | TObject* obj = fOptions.FindObject(detector); | |
638 | if (obj) fOptions.Remove(obj); | |
639 | fOptions.Add(new TNamed(detector, option)); | |
640 | } | |
641 | ||
596a855f | 642 | //_____________________________________________________________________________ |
21a3aa09 | 643 | Bool_t AliReconstruction::Run(const char* input) |
596a855f | 644 | { |
21a3aa09 | 645 | // Run Run Run |
646 | AliCodeTimerAuto(""); | |
596a855f | 647 | |
21a3aa09 | 648 | if (!InitRun(input)) return kFALSE; |
319f3084 | 649 | |
21a3aa09 | 650 | //******* The loop over events |
651 | Int_t iEvent = 0; | |
652 | while ((iEvent < fRunLoader->GetNumberOfEvents()) || | |
653 | (fRawReader && fRawReader->NextEvent())) { | |
654 | if (!RunEvent(iEvent)) return kFALSE; | |
655 | iEvent++; | |
656 | } | |
657 | ||
658 | if (!FinishRun()) return kFALSE; | |
659 | ||
660 | return kTRUE; | |
661 | } | |
662 | ||
663 | //_____________________________________________________________________________ | |
b58710ef | 664 | Bool_t AliReconstruction::InitRun(const char* input) |
21a3aa09 | 665 | { |
666 | // Initialize all the stuff before | |
667 | // going into the event loop | |
668 | // If the second argument is given, the first one is ignored and | |
669 | // the reconstruction works in an online mode | |
670 | AliCodeTimerAuto(""); | |
671 | ||
b58710ef | 672 | // Overwrite the previous setting |
21a3aa09 | 673 | if (input) fInput = input; |
674 | ||
675 | // set the input in case of raw data | |
b58710ef | 676 | fRawReader = AliRawReader::Create(fInput.Data()); |
677 | if (!fRawReader) | |
21a3aa09 | 678 | AliInfo("Reconstruction will run over digits"); |
e0027792 | 679 | |
35042093 | 680 | if (!fEquipIdMap.IsNull() && fRawReader) |
681 | fRawReader->LoadEquipmentIdsMap(fEquipIdMap); | |
682 | ||
cd0b062e | 683 | if (!fUseHLTData.IsNull()) { |
684 | // create the RawReaderHLT which performs redirection of HLT input data for | |
685 | // the specified detectors | |
686 | AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data()); | |
687 | if (pRawReader) { | |
688 | fParentRawReader=fRawReader; | |
689 | fRawReader=pRawReader; | |
690 | } else { | |
691 | AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data())); | |
692 | } | |
693 | } | |
694 | ||
0f88822a | 695 | AliSysInfo::AddStamp("Start"); |
f08fc9f5 | 696 | // get the run loader |
697 | if (!InitRunLoader()) return kFALSE; | |
0f88822a | 698 | AliSysInfo::AddStamp("LoadLoader"); |
596a855f | 699 | |
ec92bee0 | 700 | // Initialize the CDB storage |
795e4a22 | 701 | InitCDB(); |
702 | ||
703 | AliSysInfo::AddStamp("LoadCDB"); | |
ec92bee0 | 704 | |
6bae477a | 705 | // Set run number in CDBManager (if it is not already set by the user) |
795e4a22 | 706 | if (!SetRunNumberFromData()) if (fStopOnError) return kFALSE; |
707 | ||
708 | // Set CDB lock: from now on it is forbidden to reset the run number | |
709 | // or the default storage or to activate any further storage! | |
710 | SetCDBLock(); | |
711 | ||
6bae477a | 712 | // Import ideal TGeo geometry and apply misalignment |
713 | if (!gGeoManager) { | |
714 | TString geom(gSystem->DirName(fGAliceFileName)); | |
715 | geom += "/geometry.root"; | |
98e303d9 | 716 | AliGeomManager::LoadGeometry(geom.Data()); |
6bae477a | 717 | if (!gGeoManager) if (fStopOnError) return kFALSE; |
718 | } | |
8e245d15 | 719 | |
6bae477a | 720 | if (!MisalignGeometry(fLoadAlignData)) if (fStopOnError) return kFALSE; |
0f88822a | 721 | AliSysInfo::AddStamp("LoadGeom"); |
6bae477a | 722 | |
325aa76f | 723 | |
724 | // Get the GRP CDB entry | |
725 | AliCDBEntry* entryGRP = AliCDBManager::Instance()->Get("GRP/GRP/Data"); | |
726 | ||
727 | TList *list=0; | |
728 | if (entryGRP) | |
729 | list = dynamic_cast<TList*>(entryGRP->GetObject()); | |
730 | fGRPData=dynamic_cast<TMap*>(list->FindObject("pp")); // ????????? | |
731 | ||
732 | if (!fGRPData) { | |
733 | AliError("No GRP entry found in OCDB!"); | |
734 | return kFALSE; | |
f6806ad3 | 735 | } |
325aa76f | 736 | |
737 | ||
738 | // Magnetic field map | |
739 | if (!AliTracker::GetFieldMap()) { | |
740 | // Construct the field map out of the information retrieved from GRP. | |
741 | // | |
742 | // For the moment, this is a dummy piece of code. | |
743 | // The actual map is expected to be already created in rec.C ! | |
744 | // | |
745 | ||
746 | Float_t factor=1.; | |
747 | Int_t map=AliMagWrapCheb::k5kG; | |
748 | Bool_t dipoleON=kTRUE; | |
749 | ||
750 | // L3 | |
751 | TObjString *l3Current= | |
752 | dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Current")); | |
753 | if (!l3Current) { | |
754 | AliError("GRP/GRP/Data entry: missing value for the L3 current !"); | |
755 | return kFALSE; | |
756 | } | |
757 | TObjString *l3Polarity= | |
758 | dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Polarity")); | |
759 | if (!l3Polarity) { | |
760 | AliError("GRP/GRP/Data entry: missing value for the L3 polarity !"); | |
761 | return kFALSE; | |
596a855f | 762 | } |
325aa76f | 763 | |
764 | // Dipole | |
765 | TObjString *diCurrent= | |
766 | dynamic_cast<TObjString*>(fGRPData->GetValue("fDipoleCurrent")); | |
767 | if (!diCurrent) { | |
768 | AliError("GRP/GRP/Data entry: missing value for the dipole current !"); | |
769 | return kFALSE; | |
770 | } | |
771 | TObjString *diPolarity= | |
772 | dynamic_cast<TObjString*>(fGRPData->GetValue("fDipolePolarity")); | |
773 | if (!diPolarity) { | |
774 | AliError("GRP/GRP/Data entry: missing value for the dipole polarity !"); | |
775 | return kFALSE; | |
776 | } | |
777 | ||
778 | ||
779 | AliMagF *field= | |
780 | new AliMagWrapCheb("Maps","Maps",2,factor,10.,map,dipoleON); | |
781 | AliTracker::SetFieldMap(field,fUniformField); | |
782 | ||
783 | //Temporary measure | |
784 | AliFatal("Please, provide the field map ! Crashing deliberately..."); | |
785 | ||
786 | } | |
787 | ||
788 | ||
789 | // Get the diamond profile from OCDB | |
790 | AliCDBEntry* entry = AliCDBManager::Instance() | |
791 | ->Get("GRP/Calib/MeanVertex"); | |
792 | ||
793 | if(entry) { | |
794 | fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
795 | } else { | |
796 | AliError("No diamond profile found in OCDB!"); | |
797 | } | |
798 | ||
799 | entry = 0; | |
800 | entry = AliCDBManager::Instance() | |
801 | ->Get("GRP/Calib/MeanVertexTPC"); | |
802 | ||
803 | if(entry) { | |
804 | fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
805 | } else { | |
806 | AliError("No diamond profile found in OCDB!"); | |
596a855f | 807 | } |
325aa76f | 808 | |
809 | ftVertexer = new AliVertexerTracks(AliTracker::GetBz()); | |
810 | if(fDiamondProfile && fMeanVertexConstraint) ftVertexer->SetVtxStart(fDiamondProfile); | |
2257f27e | 811 | |
812 | // get vertexer | |
813 | if (fRunVertexFinder && !CreateVertexer()) { | |
814 | if (fStopOnError) { | |
815 | CleanUp(); | |
816 | return kFALSE; | |
817 | } | |
818 | } | |
0f88822a | 819 | AliSysInfo::AddStamp("Vertexer"); |
596a855f | 820 | |
f08fc9f5 | 821 | // get trackers |
b8cd5251 | 822 | if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) { |
24f7a148 | 823 | if (fStopOnError) { |
824 | CleanUp(); | |
825 | return kFALSE; | |
826 | } | |
596a855f | 827 | } |
0f88822a | 828 | AliSysInfo::AddStamp("LoadTrackers"); |
24f7a148 | 829 | |
b26c3770 | 830 | // get the possibly already existing ESD file and tree |
21a3aa09 | 831 | fesd = new AliESDEvent(); fhltesd = new AliESDEvent(); |
b26c3770 | 832 | if (!gSystem->AccessPathName("AliESDs.root")){ |
833 | gSystem->CopyFile("AliESDs.root", "AliESDs.old.root", kTRUE); | |
21a3aa09 | 834 | ffileOld = TFile::Open("AliESDs.old.root"); |
835 | if (ffileOld && ffileOld->IsOpen()) { | |
836 | ftreeOld = (TTree*) ffileOld->Get("esdTree"); | |
837 | if (ftreeOld)fesd->ReadFromTree(ftreeOld); | |
838 | fhlttreeOld = (TTree*) ffileOld->Get("HLTesdTree"); | |
839 | if (fhlttreeOld) fhltesd->ReadFromTree(fhlttreeOld); | |
b26c3770 | 840 | } |
841 | } | |
842 | ||
36711aa4 | 843 | // create the ESD output file and tree |
21a3aa09 | 844 | ffile = TFile::Open("AliESDs.root", "RECREATE"); |
845 | ffile->SetCompressionLevel(2); | |
846 | if (!ffile->IsOpen()) { | |
815c2b38 | 847 | AliError("opening AliESDs.root failed"); |
21a3aa09 | 848 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
596a855f | 849 | } |
46698ae4 | 850 | |
21a3aa09 | 851 | ftree = new TTree("esdTree", "Tree with ESD objects"); |
852 | fesd = new AliESDEvent(); | |
853 | fesd->CreateStdContent(); | |
854 | fesd->WriteToTree(ftree); | |
46698ae4 | 855 | |
21a3aa09 | 856 | fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects"); |
857 | fhltesd = new AliESDEvent(); | |
858 | fhltesd->CreateStdContent(); | |
859 | fhltesd->WriteToTree(fhlttree); | |
46698ae4 | 860 | |
5728d3d5 | 861 | |
1d99986f | 862 | if (fWriteESDfriend) { |
21a3aa09 | 863 | fesdf = new AliESDfriend(); |
864 | TBranch *br=ftree->Branch("ESDfriend.","AliESDfriend", &fesdf); | |
46698ae4 | 865 | br->SetFile("AliESDfriends.root"); |
21a3aa09 | 866 | fesd->AddObject(fesdf); |
1d99986f | 867 | } |
5728d3d5 | 868 | |
444753c6 | 869 | |
c5e3e5d1 | 870 | |
b649205a | 871 | if (fRawReader) fRawReader->RewindEvents(); |
a5fa6165 | 872 | |
95cee32f | 873 | ProcInfo_t ProcInfo; |
874 | gSystem->GetProcInfo(&ProcInfo); | |
875 | AliInfo(Form("Current memory usage %d %d", ProcInfo.fMemResident, ProcInfo.fMemVirtual)); | |
8661738e | 876 | |
aa3c69a9 | 877 | |
325aa76f | 878 | //QA |
879 | AliQADataMakerSteer qas ; | |
880 | if (fRunQA && fRawReader) { | |
881 | qas.Run(fRunLocalReconstruction, fRawReader) ; | |
882 | fSameQACycle = kTRUE ; | |
883 | } | |
aa3c69a9 | 884 | //Initialize the QA and start of cycle for out-of-cycle QA |
f6806ad3 | 885 | if (fRunQA) { |
886 | TString detStr(fFillESD); | |
887 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
888 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
889 | AliQADataMakerRec *qadm = GetQADataMaker(iDet); | |
890 | if (!qadm) continue; | |
891 | AliInfo(Form("Initializing the QA data maker for %s", | |
892 | fgkDetectorName[iDet])); | |
893 | qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun()); | |
894 | qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun()); | |
895 | if (!fInLoopQA) { | |
896 | qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle); | |
897 | qadm->StartOfCycle(AliQA::kESDS,"same"); | |
898 | } | |
899 | } | |
e4a998ed | 900 | if (fRunGlobalQA) { |
901 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); | |
902 | AliInfo(Form("Initializing the global QA data maker")); | |
903 | TObjArray *arr= | |
904 | qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun()); | |
905 | AliTracker::SetResidualsArray(arr); | |
906 | qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun()); | |
907 | if (!fInLoopQA) { | |
908 | qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle); | |
909 | qadm->StartOfCycle(AliQA::kESDS, "same"); | |
910 | } | |
911 | } | |
912 | if (!fInLoopQA) | |
913 | fSameQACycle = kTRUE; | |
aa3c69a9 | 914 | } |
915 | ||
7167ae53 | 916 | //Initialize the Plane Efficiency framework |
917 | if (fRunPlaneEff && !InitPlaneEff()) { | |
21a3aa09 | 918 | if(fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
7167ae53 | 919 | } |
aa3c69a9 | 920 | |
14dd053c | 921 | if (strcmp(gProgName,"alieve") == 0) |
922 | fRunAliEVE = InitAliEVE(); | |
923 | ||
21a3aa09 | 924 | return kTRUE; |
925 | } | |
926 | ||
927 | //_____________________________________________________________________________ | |
928 | Bool_t AliReconstruction::RunEvent(Int_t iEvent) | |
929 | { | |
930 | // run the reconstruction over a single event | |
931 | // The event loop is steered in Run method | |
932 | ||
933 | AliCodeTimerAuto(""); | |
934 | ||
935 | if (iEvent >= fRunLoader->GetNumberOfEvents()) { | |
936 | fRunLoader->SetEventNumber(iEvent); | |
937 | fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(), | |
938 | iEvent, iEvent); | |
939 | //?? fRunLoader->MakeTree("H"); | |
940 | fRunLoader->TreeE()->Fill(); | |
941 | } | |
942 | ||
943 | if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) { | |
944 | // copy old ESD to the new one | |
945 | if (ftreeOld) { | |
946 | fesd->ReadFromTree(ftreeOld); | |
947 | ftreeOld->GetEntry(iEvent); | |
948 | ftree->Fill(); | |
b26c3770 | 949 | } |
21a3aa09 | 950 | if (fhlttreeOld) { |
f6806ad3 | 951 | fhltesd->ReadFromTree(fhlttreeOld); |
21a3aa09 | 952 | fhlttreeOld->GetEntry(iEvent); |
953 | fhlttree->Fill(); | |
954 | } | |
955 | return kTRUE; | |
956 | } | |
957 | ||
958 | AliInfo(Form("processing event %d", iEvent)); | |
aa3c69a9 | 959 | |
960 | //Start of cycle for the in-loop QA | |
3b378a42 | 961 | if (fInLoopQA) { |
962 | if (fRunQA) { | |
963 | TString detStr(fFillESD); | |
964 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
e4a998ed | 965 | if (!IsSelected(fgkDetectorName[iDet], detStr)) |
966 | continue; | |
3b378a42 | 967 | AliQADataMakerRec *qadm = GetQADataMaker(iDet); |
e4a998ed | 968 | if (!qadm) |
969 | continue; | |
970 | qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle); | |
3b378a42 | 971 | qadm->StartOfCycle(AliQA::kESDS, "same") ; |
972 | } | |
e4a998ed | 973 | if (fRunGlobalQA) { |
974 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); | |
975 | qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle); | |
976 | qadm->StartOfCycle(AliQA::kESDS, "same"); | |
977 | } | |
978 | } | |
aa3c69a9 | 979 | } |
980 | ||
596a855f | 981 | fRunLoader->GetEvent(iEvent); |
24f7a148 | 982 | |
bb0901a4 | 983 | char aFileName[256]; |
984 | sprintf(aFileName, "ESD_%d.%d_final.root", | |
f08fc9f5 | 985 | fRunLoader->GetHeader()->GetRun(), |
986 | fRunLoader->GetHeader()->GetEventNrInRun()); | |
21a3aa09 | 987 | if (!gSystem->AccessPathName(aFileName)) return kTRUE; |
24f7a148 | 988 | |
d506c543 | 989 | // local single event reconstruction |
b26c3770 | 990 | if (!fRunLocalReconstruction.IsNull()) { |
d506c543 | 991 | TString detectors=fRunLocalReconstruction; |
a441bf51 | 992 | // run HLT event reconstruction first |
d506c543 | 993 | // ;-( IsSelected changes the string |
994 | if (IsSelected("HLT", detectors) && | |
995 | !RunLocalEventReconstruction("HLT")) { | |
a441bf51 | 996 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
997 | } | |
998 | detectors=fRunLocalReconstruction; | |
999 | detectors.ReplaceAll("HLT", ""); | |
1000 | if (!RunLocalEventReconstruction(detectors)) { | |
21a3aa09 | 1001 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
b26c3770 | 1002 | } |
1003 | } | |
1004 | ||
21a3aa09 | 1005 | fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); |
1006 | fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); | |
1007 | fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun()); | |
1008 | fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun()); | |
46698ae4 | 1009 | |
d6ee376f | 1010 | // Set magnetic field from the tracker |
21a3aa09 | 1011 | fesd->SetMagneticField(AliTracker::GetBz()); |
1012 | fhltesd->SetMagneticField(AliTracker::GetBz()); | |
596a855f | 1013 | |
46698ae4 | 1014 | |
1015 | ||
2e3550da | 1016 | // Fill raw-data error log into the ESD |
21a3aa09 | 1017 | if (fRawReader) FillRawDataErrorLog(iEvent,fesd); |
2e3550da | 1018 | |
2257f27e | 1019 | // vertex finder |
1020 | if (fRunVertexFinder) { | |
21a3aa09 | 1021 | if (!ReadESD(fesd, "vertex")) { |
1022 | if (!RunVertexFinder(fesd)) { | |
1023 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} | |
2257f27e | 1024 | } |
21a3aa09 | 1025 | if (fCheckPointLevel > 0) WriteESD(fesd, "vertex"); |
2257f27e | 1026 | } |
1027 | } | |
1028 | ||
e66fbafb | 1029 | // Muon tracking |
b8cd5251 | 1030 | if (!fRunTracking.IsNull()) { |
e66fbafb | 1031 | if (fRunMuonTracking) { |
21a3aa09 | 1032 | if (!RunMuonTracking(fesd)) { |
1033 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} | |
24f7a148 | 1034 | } |
596a855f | 1035 | } |
1036 | } | |
1037 | ||
e66fbafb | 1038 | // barrel tracking |
1039 | if (!fRunTracking.IsNull()) { | |
21a3aa09 | 1040 | if (!ReadESD(fesd, "tracking")) { |
1041 | if (!RunTracking(fesd)) { | |
1042 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} | |
e66fbafb | 1043 | } |
21a3aa09 | 1044 | if (fCheckPointLevel > 0) WriteESD(fesd, "tracking"); |
e66fbafb | 1045 | } |
1046 | } | |
21c573b7 | 1047 | |
596a855f | 1048 | // fill ESD |
1049 | if (!fFillESD.IsNull()) { | |
d506c543 | 1050 | TString detectors=fFillESD; |
f6806ad3 | 1051 | // run HLT first and on hltesd |
d506c543 | 1052 | // ;-( IsSelected changes the string |
1053 | if (IsSelected("HLT", detectors) && | |
1054 | !FillESD(fhltesd, "HLT")) { | |
f6806ad3 | 1055 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
1056 | } | |
1057 | detectors=fFillESD; | |
1058 | detectors.ReplaceAll("HLT", ""); | |
1059 | if (!FillESD(fesd, detectors)) { | |
21a3aa09 | 1060 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
596a855f | 1061 | } |
1062 | } | |
a5fa6165 | 1063 | |
001397cd | 1064 | // fill Event header information from the RawEventHeader |
21a3aa09 | 1065 | if (fRawReader){FillRawEventHeaderESD(fesd);} |
596a855f | 1066 | |
1067 | // combined PID | |
21a3aa09 | 1068 | AliESDpid::MakePID(fesd); |
1069 | if (fCheckPointLevel > 1) WriteESD(fesd, "PID"); | |
596a855f | 1070 | |
b647652d | 1071 | if (fFillTriggerESD) { |
21a3aa09 | 1072 | if (!ReadESD(fesd, "trigger")) { |
1073 | if (!FillTriggerESD(fesd)) { | |
1074 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} | |
b647652d | 1075 | } |
21a3aa09 | 1076 | if (fCheckPointLevel > 1) WriteESD(fesd, "trigger"); |
b647652d | 1077 | } |
1078 | } | |
1079 | ||
21a3aa09 | 1080 | ffile->cd(); |
a6ee503a | 1081 | |
3c3709c4 | 1082 | // |
67be5c77 | 1083 | // Propagate track to the beam pipe (if not already done by ITS) |
3c3709c4 | 1084 | // |
21a3aa09 | 1085 | const Int_t ntracks = fesd->GetNumberOfTracks(); |
1086 | const Double_t kBz = fesd->GetMagneticField(); | |
3c3709c4 | 1087 | const Double_t kRadius = 2.8; //something less than the beam pipe radius |
1088 | ||
1089 | TObjArray trkArray; | |
1090 | UShort_t *selectedIdx=new UShort_t[ntracks]; | |
1091 | ||
1092 | for (Int_t itrack=0; itrack<ntracks; itrack++){ | |
1093 | const Double_t kMaxStep = 5; //max step over the material | |
1094 | Bool_t ok; | |
1095 | ||
21a3aa09 | 1096 | AliESDtrack *track = fesd->GetTrack(itrack); |
3c3709c4 | 1097 | if (!track) continue; |
1098 | ||
1099 | AliExternalTrackParam *tpcTrack = | |
1100 | (AliExternalTrackParam *)track->GetTPCInnerParam(); | |
bcabd6af | 1101 | ok = kFALSE; |
1102 | if (tpcTrack) | |
1103 | ok = AliTracker:: | |
1104 | PropagateTrackTo(tpcTrack,kRadius,track->GetMass(),kMaxStep,kTRUE); | |
43c9dae1 | 1105 | |
1106 | ||
1107 | ||
3c3709c4 | 1108 | if (ok) { |
1109 | Int_t n=trkArray.GetEntriesFast(); | |
1110 | selectedIdx[n]=track->GetID(); | |
1111 | trkArray.AddLast(tpcTrack); | |
1112 | } | |
1113 | ||
f6806ad3 | 1114 | if (track->GetX() < kRadius) continue; |
3c3709c4 | 1115 | |
f6806ad3 | 1116 | ok = AliTracker:: |
3c3709c4 | 1117 | PropagateTrackTo(track,kRadius,track->GetMass(),kMaxStep,kTRUE); |
f6806ad3 | 1118 | if (ok) { |
1119 | track->RelateToVertex(fesd->GetPrimaryVertexSPD(), kBz, kRadius); | |
1120 | } | |
3c3709c4 | 1121 | } |
1122 | ||
1123 | // | |
1124 | // Improve the reconstructed primary vertex position using the tracks | |
1125 | // | |
1126 | TObject *obj = fOptions.FindObject("ITS"); | |
c060d7fe | 1127 | if (obj) { |
1128 | TString optITS = obj->GetTitle(); | |
1129 | if (optITS.Contains("cosmics") || optITS.Contains("COSMICS")) | |
a84e2607 | 1130 | fRunVertexFinderTracks=kFALSE; |
c060d7fe | 1131 | } |
3c3709c4 | 1132 | if (fRunVertexFinderTracks) { |
1133 | // TPC + ITS primary vertex | |
21a3aa09 | 1134 | ftVertexer->SetITSrefitRequired(); |
43c9dae1 | 1135 | if(fDiamondProfile && fMeanVertexConstraint) { |
21a3aa09 | 1136 | ftVertexer->SetVtxStart(fDiamondProfile); |
43c9dae1 | 1137 | } else { |
21a3aa09 | 1138 | ftVertexer->SetConstraintOff(); |
43c9dae1 | 1139 | } |
21a3aa09 | 1140 | AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd); |
3c3709c4 | 1141 | if (pvtx) { |
1142 | if (pvtx->GetStatus()) { | |
21a3aa09 | 1143 | fesd->SetPrimaryVertex(pvtx); |
3c3709c4 | 1144 | for (Int_t i=0; i<ntracks; i++) { |
21a3aa09 | 1145 | AliESDtrack *t = fesd->GetTrack(i); |
f6806ad3 | 1146 | t->RelateToVertex(pvtx, kBz, kRadius); |
3c3709c4 | 1147 | } |
1148 | } | |
1149 | } | |
1150 | ||
1151 | // TPC-only primary vertex | |
21a3aa09 | 1152 | ftVertexer->SetITSrefitNotRequired(); |
43c9dae1 | 1153 | if(fDiamondProfileTPC && fMeanVertexConstraint) { |
21a3aa09 | 1154 | ftVertexer->SetVtxStart(fDiamondProfileTPC); |
43c9dae1 | 1155 | } else { |
21a3aa09 | 1156 | ftVertexer->SetConstraintOff(); |
43c9dae1 | 1157 | } |
21a3aa09 | 1158 | pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx); |
3c3709c4 | 1159 | if (pvtx) { |
1160 | if (pvtx->GetStatus()) { | |
21a3aa09 | 1161 | fesd->SetPrimaryVertexTPC(pvtx); |
3c3709c4 | 1162 | Int_t nsel=trkArray.GetEntriesFast(); |
1163 | for (Int_t i=0; i<nsel; i++) { | |
1164 | AliExternalTrackParam *t = | |
1165 | (AliExternalTrackParam *)trkArray.UncheckedAt(i); | |
1166 | t->PropagateToDCA(pvtx, kBz, kRadius); | |
1167 | } | |
1168 | } | |
1169 | } | |
1170 | ||
1171 | } | |
1172 | delete[] selectedIdx; | |
1173 | ||
21a3aa09 | 1174 | if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile); |
17c86e90 | 1175 | |
c5e3e5d1 | 1176 | |
d1683eef | 1177 | if (fRunV0Finder) { |
1178 | // V0 finding | |
1179 | AliV0vertexer vtxer; | |
21a3aa09 | 1180 | vtxer.Tracks2V0vertices(fesd); |
5e4ff34d | 1181 | |
d1683eef | 1182 | if (fRunCascadeFinder) { |
1183 | // Cascade finding | |
1184 | AliCascadeVertexer cvtxer; | |
21a3aa09 | 1185 | cvtxer.V0sTracks2CascadeVertices(fesd); |
d1683eef | 1186 | } |
5e4ff34d | 1187 | } |
1188 | ||
596a855f | 1189 | // write ESD |
21a3aa09 | 1190 | if (fCleanESD) CleanESD(fesd); |
854c6476 | 1191 | |
79740dfc | 1192 | if (fRunQA) { |
1193 | if (fRunGlobalQA) { | |
1194 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); | |
1195 | if (qadm) qadm->Exec(AliQA::kESDS, fesd); | |
1196 | } | |
1197 | } | |
854c6476 | 1198 | |
1d99986f | 1199 | if (fWriteESDfriend) { |
21a3aa09 | 1200 | fesdf->~AliESDfriend(); |
1201 | new (fesdf) AliESDfriend(); // Reset... | |
1202 | fesd->GetESDfriend(fesdf); | |
1d99986f | 1203 | } |
21a3aa09 | 1204 | ftree->Fill(); |
500d54ab | 1205 | |
1206 | // write HLT ESD | |
21a3aa09 | 1207 | fhlttree->Fill(); |
1d99986f | 1208 | |
14dd053c | 1209 | // call AliEVE |
1210 | if (fRunAliEVE) RunAliEVE(); | |
1211 | ||
21a3aa09 | 1212 | if (fCheckPointLevel > 0) WriteESD(fesd, "final"); |
1213 | fesd->Reset(); | |
1214 | fhltesd->Reset(); | |
5728d3d5 | 1215 | if (fWriteESDfriend) { |
21a3aa09 | 1216 | fesdf->~AliESDfriend(); |
1217 | new (fesdf) AliESDfriend(); // Reset... | |
5728d3d5 | 1218 | } |
a5fa6165 | 1219 | |
21a3aa09 | 1220 | ProcInfo_t ProcInfo; |
95cee32f | 1221 | gSystem->GetProcInfo(&ProcInfo); |
1222 | AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, ProcInfo.fMemResident, ProcInfo.fMemVirtual)); | |
a5fa6165 | 1223 | |
7e963665 | 1224 | |
aa3c69a9 | 1225 | // End of cycle for the in-loop QA |
3b378a42 | 1226 | if (fInLoopQA) { |
1227 | if (fRunQA) { | |
21a3aa09 | 1228 | RunQA(fFillESD.Data(), fesd); |
3b378a42 | 1229 | TString detStr(fFillESD); |
1230 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
7c002d48 | 1231 | if (!IsSelected(fgkDetectorName[iDet], detStr)) |
1232 | continue; | |
1233 | AliQADataMakerRec * qadm = GetQADataMaker(iDet); | |
1234 | if (!qadm) | |
1235 | continue; | |
1236 | qadm->EndOfCycle(AliQA::kRECPOINTS); | |
1237 | qadm->EndOfCycle(AliQA::kESDS); | |
1238 | qadm->Finish(); | |
1239 | } | |
aa3c69a9 | 1240 | } |
1241 | if (fRunGlobalQA) { | |
7c002d48 | 1242 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); |
aa3c69a9 | 1243 | if (qadm) { |
1244 | qadm->EndOfCycle(AliQA::kRECPOINTS); | |
d7259b2e | 1245 | qadm->EndOfCycle(AliQA::kESDS); |
aa3c69a9 | 1246 | qadm->Finish(); |
1247 | } | |
1248 | } | |
1249 | } | |
aa3c69a9 | 1250 | |
21a3aa09 | 1251 | return kTRUE; |
1252 | } | |
1253 | ||
21a3aa09 | 1254 | //_____________________________________________________________________________ |
1255 | Bool_t AliReconstruction::FinishRun() | |
1256 | { | |
1257 | // Finalize the run | |
1258 | // Called after the exit | |
1259 | // from the event loop | |
1260 | AliCodeTimerAuto(""); | |
1261 | ||
1262 | if (fIsNewRunLoader) { // galice.root didn't exist | |
1263 | fRunLoader->WriteHeader("OVERWRITE"); | |
1264 | fRunLoader->CdGAFile(); | |
1265 | fRunLoader->Write(0, TObject::kOverwrite); | |
1266 | } | |
1267 | ||
1268 | ftree->GetUserInfo()->Add(fesd); | |
1269 | fhlttree->GetUserInfo()->Add(fhltesd); | |
f747912b | 1270 | |
1271 | const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap(); | |
1272 | const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds(); | |
1273 | ||
1274 | TMap *cdbMapCopy = new TMap(cdbMap->GetEntries()); | |
1275 | cdbMapCopy->SetOwner(1); | |
1276 | cdbMapCopy->SetName("cdbMap"); | |
1277 | TIter iter(cdbMap->GetTable()); | |
1278 | ||
1279 | TPair* pair = 0; | |
1280 | while((pair = dynamic_cast<TPair*> (iter.Next()))){ | |
1281 | TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key()); | |
1282 | TObjString* valStr = dynamic_cast<TObjString*> (pair->Value()); | |
1283 | cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName())); | |
1284 | } | |
1285 | ||
1286 | TList *cdbListCopy = new TList(); | |
1287 | cdbListCopy->SetOwner(1); | |
1288 | cdbListCopy->SetName("cdbList"); | |
1289 | ||
1290 | TIter iter2(cdbList); | |
1291 | ||
1292 | AliCDBId* id=0; | |
1293 | while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){ | |
a4970db9 | 1294 | cdbListCopy->Add(new TObjString(id->ToString().Data())); |
f747912b | 1295 | } |
1296 | ||
21a3aa09 | 1297 | ftree->GetUserInfo()->Add(cdbMapCopy); |
1298 | ftree->GetUserInfo()->Add(cdbListCopy); | |
abe0c04e | 1299 | |
46698ae4 | 1300 | |
1301 | if(fESDPar.Contains("ESD.par")){ | |
1302 | AliInfo("Attaching ESD.par to Tree"); | |
1303 | TNamed *fn = CopyFileToTNamed(fESDPar.Data(),"ESD.par"); | |
21a3aa09 | 1304 | ftree->GetUserInfo()->Add(fn); |
596a855f | 1305 | } |
1306 | ||
46698ae4 | 1307 | |
21a3aa09 | 1308 | ffile->cd(); |
aa3c69a9 | 1309 | |
a9c0e6db | 1310 | if (fWriteESDfriend) |
21a3aa09 | 1311 | ftree->SetBranchStatus("ESDfriend*",0); |
562dd0b4 | 1312 | // we want to have only one tree version number |
21a3aa09 | 1313 | ftree->Write(ftree->GetName(),TObject::kOverwrite); |
1314 | fhlttree->Write(); | |
f3a97c86 | 1315 | |
a7a1e1c7 | 1316 | // Finish with Plane Efficiency evaluation: before of CleanUp !!! |
1317 | if (fRunPlaneEff && !FinishPlaneEff()) { | |
1318 | AliWarning("Finish PlaneEff evaluation failed"); | |
1319 | } | |
1320 | ||
eae191bc | 1321 | gROOT->cd(); |
21a3aa09 | 1322 | CleanUp(ffile, ffileOld); |
eae191bc | 1323 | |
a7807689 | 1324 | if (fWriteAOD) { |
7a3b2050 | 1325 | AliWarning("AOD creation not supported anymore during reconstruction. See ANALYSIS/AliAnalysisTaskESDfilter.cxx instead."); |
a7807689 | 1326 | } |
1327 | ||
f3a97c86 | 1328 | // Create tags for the events in the ESD tree (the ESD tree is always present) |
1329 | // In case of empty events the tags will contain dummy values | |
08e1a23e | 1330 | AliESDTagCreator *esdtagCreator = new AliESDTagCreator(); |
6b6e4472 | 1331 | esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData); |
a1069ee1 | 1332 | if (fWriteAOD) { |
7a3b2050 | 1333 | AliWarning("AOD tag creation not supported anymore during reconstruction."); |
a1069ee1 | 1334 | } |
596a855f | 1335 | |
aa3c69a9 | 1336 | //Finish QA and end of cycle for out-of-loop QA |
3b378a42 | 1337 | if (!fInLoopQA) { |
79740dfc | 1338 | if (fRunQA) { |
1339 | AliQADataMakerSteer qas; | |
1340 | qas.Run(fRunLocalReconstruction.Data(), AliQA::kRECPOINTS, fSameQACycle); | |
1341 | //qas.Reset() ; | |
f6806ad3 | 1342 | qas.Run(fRunTracking.Data(), AliQA::kESDS, fSameQACycle); |
79740dfc | 1343 | if (fRunGlobalQA) { |
1344 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); | |
1345 | if (qadm) { | |
1346 | qadm->EndOfCycle(AliQA::kRECPOINTS); | |
1347 | qadm->EndOfCycle(AliQA::kESDS); | |
1348 | qadm->Finish(); | |
1349 | } | |
1350 | } | |
1351 | } | |
759c1df1 | 1352 | } |
795e4a22 | 1353 | |
1354 | // Cleanup of CDB manager: cache and active storages! | |
1355 | AliCDBManager::Instance()->ClearCache(); | |
1356 | ||
596a855f | 1357 | return kTRUE; |
1358 | } | |
1359 | ||
1360 | ||
1361 | //_____________________________________________________________________________ | |
c4aa7a4c | 1362 | Bool_t AliReconstruction::RunLocalReconstruction(const TString& /*detectors*/) |
596a855f | 1363 | { |
59697224 | 1364 | // run the local reconstruction |
0f88822a | 1365 | static Int_t eventNr=0; |
87932dab | 1366 | AliCodeTimerAuto("") |
030b532d | 1367 | |
d76c31f4 | 1368 | // AliCDBManager* man = AliCDBManager::Instance(); |
1369 | // Bool_t origCache = man->GetCacheFlag(); | |
8e245d15 | 1370 | |
d76c31f4 | 1371 | // TString detStr = detectors; |
1372 | // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1373 | // if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
1374 | // AliReconstructor* reconstructor = GetReconstructor(iDet); | |
1375 | // if (!reconstructor) continue; | |
1376 | // if (reconstructor->HasLocalReconstruction()) continue; | |
b8cd5251 | 1377 | |
d76c31f4 | 1378 | // AliCodeTimerStart(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
1379 | // AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); | |
87932dab | 1380 | |
d76c31f4 | 1381 | // AliCodeTimerStart(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); |
1382 | // AliInfo(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); | |
8e245d15 | 1383 | |
d76c31f4 | 1384 | // man->SetCacheFlag(kTRUE); |
1385 | // TString calibPath = Form("%s/Calib/*", fgkDetectorName[iDet]); | |
1386 | // man->GetAll(calibPath); // entries are cached! | |
8e245d15 | 1387 | |
d76c31f4 | 1388 | // AliCodeTimerStop(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); |
87932dab | 1389 | |
d76c31f4 | 1390 | // if (fRawReader) { |
1391 | // fRawReader->RewindEvents(); | |
1392 | // reconstructor->Reconstruct(fRunLoader, fRawReader); | |
1393 | // } else { | |
1394 | // reconstructor->Reconstruct(fRunLoader); | |
1395 | // } | |
87932dab | 1396 | |
d76c31f4 | 1397 | // AliCodeTimerStop(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
0f88822a | 1398 | // AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr)); |
8e245d15 | 1399 | |
d76c31f4 | 1400 | // // unload calibration data |
1401 | // man->UnloadFromCache(calibPath); | |
1402 | // //man->ClearCache(); | |
1403 | // } | |
596a855f | 1404 | |
d76c31f4 | 1405 | // man->SetCacheFlag(origCache); |
8e245d15 | 1406 | |
d76c31f4 | 1407 | // if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { |
1408 | // AliError(Form("the following detectors were not found: %s", | |
1409 | // detStr.Data())); | |
1410 | // if (fStopOnError) return kFALSE; | |
1411 | // } | |
596a855f | 1412 | |
0f88822a | 1413 | eventNr++; |
596a855f | 1414 | return kTRUE; |
1415 | } | |
1416 | ||
b26c3770 | 1417 | //_____________________________________________________________________________ |
1418 | Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors) | |
1419 | { | |
1420 | // run the local reconstruction | |
aa3c69a9 | 1421 | |
0f88822a | 1422 | static Int_t eventNr=0; |
87932dab | 1423 | AliCodeTimerAuto("") |
b26c3770 | 1424 | |
1425 | TString detStr = detectors; | |
1426 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1427 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
1428 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
1429 | if (!reconstructor) continue; | |
1430 | AliLoader* loader = fLoader[iDet]; | |
f6806ad3 | 1431 | // Matthias April 2008: temporary fix to run HLT reconstruction |
1432 | // although the HLT loader is missing | |
1433 | if (strcmp(fgkDetectorName[iDet], "HLT")==0) { | |
1434 | if (fRawReader) { | |
1435 | reconstructor->Reconstruct(fRawReader, NULL); | |
1436 | } else { | |
1437 | TTree* dummy=NULL; | |
1438 | reconstructor->Reconstruct(dummy, NULL); | |
1439 | } | |
1440 | continue; | |
1441 | } | |
d76c31f4 | 1442 | if (!loader) { |
1443 | AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet])); | |
1444 | continue; | |
1445 | } | |
b26c3770 | 1446 | // conversion of digits |
1447 | if (fRawReader && reconstructor->HasDigitConversion()) { | |
1448 | AliInfo(Form("converting raw data digits into root objects for %s", | |
1449 | fgkDetectorName[iDet])); | |
87932dab | 1450 | AliCodeTimerAuto(Form("converting raw data digits into root objects for %s", |
1451 | fgkDetectorName[iDet])); | |
b26c3770 | 1452 | loader->LoadDigits("update"); |
1453 | loader->CleanDigits(); | |
1454 | loader->MakeDigitsContainer(); | |
1455 | TTree* digitsTree = loader->TreeD(); | |
1456 | reconstructor->ConvertDigits(fRawReader, digitsTree); | |
1457 | loader->WriteDigits("OVERWRITE"); | |
1458 | loader->UnloadDigits(); | |
b26c3770 | 1459 | } |
b26c3770 | 1460 | // local reconstruction |
b26c3770 | 1461 | AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
87932dab | 1462 | AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
b26c3770 | 1463 | loader->LoadRecPoints("update"); |
1464 | loader->CleanRecPoints(); | |
1465 | loader->MakeRecPointsContainer(); | |
1466 | TTree* clustersTree = loader->TreeR(); | |
1467 | if (fRawReader && !reconstructor->HasDigitConversion()) { | |
1468 | reconstructor->Reconstruct(fRawReader, clustersTree); | |
1469 | } else { | |
1470 | loader->LoadDigits("read"); | |
1471 | TTree* digitsTree = loader->TreeD(); | |
1472 | if (!digitsTree) { | |
1473 | AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet])); | |
1474 | if (fStopOnError) return kFALSE; | |
1475 | } else { | |
1476 | reconstructor->Reconstruct(digitsTree, clustersTree); | |
1477 | } | |
1478 | loader->UnloadDigits(); | |
1479 | } | |
d76c31f4 | 1480 | |
aa3c69a9 | 1481 | // In-loop QA for local reconstrucion |
1482 | if (fRunQA && fInLoopQA) { | |
04236e67 | 1483 | AliQADataMakerRec * qadm = GetQADataMaker(iDet); |
aa3c69a9 | 1484 | if (qadm) { |
1485 | //AliCodeTimerStart | |
1486 | //(Form("Running QA data maker for %s", fgkDetectorName[iDet])); | |
1487 | //AliInfo | |
1488 | //(Form("Running QA data maker for %s", fgkDetectorName[iDet])); | |
1489 | ||
1490 | qadm->Exec(AliQA::kRECPOINTS, clustersTree) ; | |
1491 | ||
1492 | //AliCodeTimerStop | |
1493 | //(Form("Running QA data maker for %s", fgkDetectorName[iDet])); | |
1494 | } | |
1495 | } | |
d76c31f4 | 1496 | |
aa3c69a9 | 1497 | loader->WriteRecPoints("OVERWRITE"); |
b26c3770 | 1498 | loader->UnloadRecPoints(); |
6efecea1 | 1499 | AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr); |
b26c3770 | 1500 | } |
1501 | ||
1502 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
1503 | AliError(Form("the following detectors were not found: %s", | |
1504 | detStr.Data())); | |
1505 | if (fStopOnError) return kFALSE; | |
1506 | } | |
0f88822a | 1507 | eventNr++; |
b26c3770 | 1508 | return kTRUE; |
1509 | } | |
1510 | ||
596a855f | 1511 | //_____________________________________________________________________________ |
af885e0f | 1512 | Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd) |
596a855f | 1513 | { |
1514 | // run the barrel tracking | |
1515 | ||
87932dab | 1516 | AliCodeTimerAuto("") |
030b532d | 1517 | |
2257f27e | 1518 | AliESDVertex* vertex = NULL; |
1519 | Double_t vtxPos[3] = {0, 0, 0}; | |
1520 | Double_t vtxErr[3] = {0.07, 0.07, 0.1}; | |
1521 | TArrayF mcVertex(3); | |
a6b0b91b | 1522 | if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) { |
1523 | fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex); | |
1524 | for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i]; | |
1525 | } | |
2257f27e | 1526 | |
b8cd5251 | 1527 | if (fVertexer) { |
17c86e90 | 1528 | if(fDiamondProfile) fVertexer->SetVtxStart(fDiamondProfile); |
815c2b38 | 1529 | AliInfo("running the ITS vertex finder"); |
b26c3770 | 1530 | if (fLoader[0]) fLoader[0]->LoadRecPoints(); |
b8cd5251 | 1531 | vertex = fVertexer->FindVertexForCurrentEvent(fRunLoader->GetEventNumber()); |
b26c3770 | 1532 | if (fLoader[0]) fLoader[0]->UnloadRecPoints(); |
2257f27e | 1533 | if(!vertex){ |
815c2b38 | 1534 | AliWarning("Vertex not found"); |
c710f220 | 1535 | vertex = new AliESDVertex(); |
d1a50cb5 | 1536 | vertex->SetName("default"); |
2257f27e | 1537 | } |
1538 | else { | |
d1a50cb5 | 1539 | vertex->SetName("reconstructed"); |
2257f27e | 1540 | } |
1541 | ||
1542 | } else { | |
815c2b38 | 1543 | AliInfo("getting the primary vertex from MC"); |
2257f27e | 1544 | vertex = new AliESDVertex(vtxPos, vtxErr); |
1545 | } | |
1546 | ||
1547 | if (vertex) { | |
1548 | vertex->GetXYZ(vtxPos); | |
1549 | vertex->GetSigmaXYZ(vtxErr); | |
1550 | } else { | |
815c2b38 | 1551 | AliWarning("no vertex reconstructed"); |
2257f27e | 1552 | vertex = new AliESDVertex(vtxPos, vtxErr); |
1553 | } | |
06cc9d95 | 1554 | esd->SetPrimaryVertexSPD(vertex); |
32e449be | 1555 | // if SPD multiplicity has been determined, it is stored in the ESD |
25be1e5c | 1556 | AliMultiplicity *mult = fVertexer->GetMultiplicity(); |
32e449be | 1557 | if(mult)esd->SetMultiplicity(mult); |
1558 | ||
b8cd5251 | 1559 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1560 | if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr); | |
1561 | } | |
2257f27e | 1562 | delete vertex; |
1563 | ||
2257f27e | 1564 | return kTRUE; |
1565 | } | |
1566 | ||
1f46a9ae | 1567 | //_____________________________________________________________________________ |
af885e0f | 1568 | Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd) |
1f46a9ae | 1569 | { |
1570 | // run the HLT barrel tracking | |
1571 | ||
87932dab | 1572 | AliCodeTimerAuto("") |
1f46a9ae | 1573 | |
1574 | if (!fRunLoader) { | |
1575 | AliError("Missing runLoader!"); | |
1576 | return kFALSE; | |
1577 | } | |
1578 | ||
1579 | AliInfo("running HLT tracking"); | |
1580 | ||
1581 | // Get a pointer to the HLT reconstructor | |
1582 | AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1); | |
1583 | if (!reconstructor) return kFALSE; | |
1584 | ||
1585 | // TPC + ITS | |
1586 | for (Int_t iDet = 1; iDet >= 0; iDet--) { | |
1587 | TString detName = fgkDetectorName[iDet]; | |
1588 | AliDebug(1, Form("%s HLT tracking", detName.Data())); | |
1589 | reconstructor->SetOption(detName.Data()); | |
d76c31f4 | 1590 | AliTracker *tracker = reconstructor->CreateTracker(); |
1f46a9ae | 1591 | if (!tracker) { |
1592 | AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data())); | |
1593 | if (fStopOnError) return kFALSE; | |
9dcc06e1 | 1594 | continue; |
1f46a9ae | 1595 | } |
1596 | Double_t vtxPos[3]; | |
1597 | Double_t vtxErr[3]={0.005,0.005,0.010}; | |
1598 | const AliESDVertex *vertex = esd->GetVertex(); | |
1599 | vertex->GetXYZ(vtxPos); | |
1600 | tracker->SetVertex(vtxPos,vtxErr); | |
1601 | if(iDet != 1) { | |
1602 | fLoader[iDet]->LoadRecPoints("read"); | |
1603 | TTree* tree = fLoader[iDet]->TreeR(); | |
1604 | if (!tree) { | |
1605 | AliError(Form("Can't get the %s cluster tree", detName.Data())); | |
1606 | return kFALSE; | |
1607 | } | |
1608 | tracker->LoadClusters(tree); | |
1609 | } | |
1610 | if (tracker->Clusters2Tracks(esd) != 0) { | |
1611 | AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
1612 | return kFALSE; | |
1613 | } | |
1614 | if(iDet != 1) { | |
1615 | tracker->UnloadClusters(); | |
1616 | } | |
1617 | delete tracker; | |
1618 | } | |
1619 | ||
1f46a9ae | 1620 | return kTRUE; |
1621 | } | |
1622 | ||
e66fbafb | 1623 | //_____________________________________________________________________________ |
af885e0f | 1624 | Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd) |
e66fbafb | 1625 | { |
1626 | // run the muon spectrometer tracking | |
1627 | ||
87932dab | 1628 | AliCodeTimerAuto("") |
e66fbafb | 1629 | |
1630 | if (!fRunLoader) { | |
1631 | AliError("Missing runLoader!"); | |
1632 | return kFALSE; | |
1633 | } | |
1634 | Int_t iDet = 7; // for MUON | |
1635 | ||
1636 | AliInfo("is running..."); | |
1637 | ||
1638 | // Get a pointer to the MUON reconstructor | |
1639 | AliReconstructor *reconstructor = GetReconstructor(iDet); | |
1640 | if (!reconstructor) return kFALSE; | |
1641 | ||
1642 | ||
1643 | TString detName = fgkDetectorName[iDet]; | |
1644 | AliDebug(1, Form("%s tracking", detName.Data())); | |
d76c31f4 | 1645 | AliTracker *tracker = reconstructor->CreateTracker(); |
e66fbafb | 1646 | if (!tracker) { |
1647 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); | |
1648 | return kFALSE; | |
1649 | } | |
1650 | ||
e66fbafb | 1651 | // read RecPoints |
761350a6 | 1652 | fLoader[iDet]->LoadRecPoints("read"); |
c1954ee5 | 1653 | |
761350a6 | 1654 | tracker->LoadClusters(fLoader[iDet]->TreeR()); |
1655 | ||
1656 | Int_t rv = tracker->Clusters2Tracks(esd); | |
1657 | ||
761350a6 | 1658 | if ( rv ) |
1659 | { | |
e66fbafb | 1660 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); |
1661 | return kFALSE; | |
1662 | } | |
761350a6 | 1663 | |
e66fbafb | 1664 | fLoader[iDet]->UnloadRecPoints(); |
1665 | ||
c1954ee5 | 1666 | tracker->UnloadClusters(); |
1667 | ||
e66fbafb | 1668 | delete tracker; |
1669 | ||
e66fbafb | 1670 | return kTRUE; |
1671 | } | |
1672 | ||
1673 | ||
2257f27e | 1674 | //_____________________________________________________________________________ |
af885e0f | 1675 | Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd) |
2257f27e | 1676 | { |
1677 | // run the barrel tracking | |
0f88822a | 1678 | static Int_t eventNr=0; |
87932dab | 1679 | AliCodeTimerAuto("") |
24f7a148 | 1680 | |
815c2b38 | 1681 | AliInfo("running tracking"); |
596a855f | 1682 | |
91b876d1 | 1683 | //Fill the ESD with the T0 info (will be used by the TOF) |
d76c31f4 | 1684 | if (fReconstructor[11] && fLoader[11]) { |
1685 | fLoader[11]->LoadRecPoints("READ"); | |
1686 | TTree *treeR = fLoader[11]->TreeR(); | |
1687 | GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd); | |
1688 | } | |
91b876d1 | 1689 | |
b8cd5251 | 1690 | // pass 1: TPC + ITS inwards |
1691 | for (Int_t iDet = 1; iDet >= 0; iDet--) { | |
1692 | if (!fTracker[iDet]) continue; | |
1693 | AliDebug(1, Form("%s tracking", fgkDetectorName[iDet])); | |
24f7a148 | 1694 | |
b8cd5251 | 1695 | // load clusters |
1696 | fLoader[iDet]->LoadRecPoints("read"); | |
6efecea1 | 1697 | AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr); |
b8cd5251 | 1698 | TTree* tree = fLoader[iDet]->TreeR(); |
1699 | if (!tree) { | |
1700 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); | |
24f7a148 | 1701 | return kFALSE; |
1702 | } | |
b8cd5251 | 1703 | fTracker[iDet]->LoadClusters(tree); |
6efecea1 | 1704 | AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr); |
b8cd5251 | 1705 | // run tracking |
1706 | if (fTracker[iDet]->Clusters2Tracks(esd) != 0) { | |
1707 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
24f7a148 | 1708 | return kFALSE; |
1709 | } | |
b8cd5251 | 1710 | if (fCheckPointLevel > 1) { |
1711 | WriteESD(esd, Form("%s.tracking", fgkDetectorName[iDet])); | |
1712 | } | |
878e1fe1 | 1713 | // preliminary PID in TPC needed by the ITS tracker |
1714 | if (iDet == 1) { | |
b26c3770 | 1715 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); |
878e1fe1 | 1716 | AliESDpid::MakePID(esd); |
0f88822a | 1717 | } |
6efecea1 | 1718 | AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr); |
b8cd5251 | 1719 | } |
596a855f | 1720 | |
b8cd5251 | 1721 | // pass 2: ALL backwards |
aa3c69a9 | 1722 | |
b8cd5251 | 1723 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1724 | if (!fTracker[iDet]) continue; | |
1725 | AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet])); | |
1726 | ||
1727 | // load clusters | |
1728 | if (iDet > 1) { // all except ITS, TPC | |
1729 | TTree* tree = NULL; | |
7b61cd9c | 1730 | fLoader[iDet]->LoadRecPoints("read"); |
6efecea1 | 1731 | AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr); |
7b61cd9c | 1732 | tree = fLoader[iDet]->TreeR(); |
b8cd5251 | 1733 | if (!tree) { |
1734 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); | |
24f7a148 | 1735 | return kFALSE; |
1736 | } | |
0f88822a | 1737 | fTracker[iDet]->LoadClusters(tree); |
6efecea1 | 1738 | AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr); |
b8cd5251 | 1739 | } |
24f7a148 | 1740 | |
b8cd5251 | 1741 | // run tracking |
283f39c6 | 1742 | if (iDet>1) // start filling residuals for the "outer" detectors |
1743 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE); | |
1744 | ||
b8cd5251 | 1745 | if (fTracker[iDet]->PropagateBack(esd) != 0) { |
1746 | AliError(Form("%s backward propagation failed", fgkDetectorName[iDet])); | |
49dfd67a | 1747 | // return kFALSE; |
b8cd5251 | 1748 | } |
1749 | if (fCheckPointLevel > 1) { | |
1750 | WriteESD(esd, Form("%s.back", fgkDetectorName[iDet])); | |
1751 | } | |
24f7a148 | 1752 | |
b8cd5251 | 1753 | // unload clusters |
1754 | if (iDet > 2) { // all except ITS, TPC, TRD | |
1755 | fTracker[iDet]->UnloadClusters(); | |
7b61cd9c | 1756 | fLoader[iDet]->UnloadRecPoints(); |
b8cd5251 | 1757 | } |
8f37df88 | 1758 | // updated PID in TPC needed by the ITS tracker -MI |
1759 | if (iDet == 1) { | |
8f37df88 | 1760 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); |
1761 | AliESDpid::MakePID(esd); | |
1762 | } | |
6efecea1 | 1763 | AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr); |
b8cd5251 | 1764 | } |
283f39c6 | 1765 | //stop filling residuals for the "outer" detectors |
1766 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE); | |
596a855f | 1767 | |
98937d93 | 1768 | // write space-points to the ESD in case alignment data output |
1769 | // is switched on | |
1770 | if (fWriteAlignmentData) | |
1771 | WriteAlignmentData(esd); | |
1772 | ||
b8cd5251 | 1773 | // pass 3: TRD + TPC + ITS refit inwards |
aa3c69a9 | 1774 | |
b8cd5251 | 1775 | for (Int_t iDet = 2; iDet >= 0; iDet--) { |
1776 | if (!fTracker[iDet]) continue; | |
1777 | AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet])); | |
596a855f | 1778 | |
b8cd5251 | 1779 | // run tracking |
283f39c6 | 1780 | if (iDet<2) // start filling residuals for TPC and ITS |
1781 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE); | |
1782 | ||
b8cd5251 | 1783 | if (fTracker[iDet]->RefitInward(esd) != 0) { |
1784 | AliError(Form("%s inward refit failed", fgkDetectorName[iDet])); | |
49dfd67a | 1785 | // return kFALSE; |
b8cd5251 | 1786 | } |
db2368d0 | 1787 | // run postprocessing |
1788 | if (fTracker[iDet]->PostProcess(esd) != 0) { | |
1789 | AliError(Form("%s postprocessing failed", fgkDetectorName[iDet])); | |
1790 | // return kFALSE; | |
1791 | } | |
b8cd5251 | 1792 | if (fCheckPointLevel > 1) { |
1793 | WriteESD(esd, Form("%s.refit", fgkDetectorName[iDet])); | |
1794 | } | |
6efecea1 | 1795 | AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr); |
b8cd5251 | 1796 | // unload clusters |
1797 | fTracker[iDet]->UnloadClusters(); | |
6efecea1 | 1798 | AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr); |
b8cd5251 | 1799 | fLoader[iDet]->UnloadRecPoints(); |
6efecea1 | 1800 | AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr); |
b8cd5251 | 1801 | } |
283f39c6 | 1802 | // stop filling residuals for TPC and ITS |
3b378a42 | 1803 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE); |
854c6476 | 1804 | |
0f88822a | 1805 | eventNr++; |
596a855f | 1806 | return kTRUE; |
1807 | } | |
1808 | ||
d64bd07d | 1809 | //_____________________________________________________________________________ |
1810 | Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){ | |
1811 | // | |
1812 | // Remove the data which are not needed for the physics analysis. | |
1813 | // | |
1814 | ||
d64bd07d | 1815 | Int_t nTracks=esd->GetNumberOfTracks(); |
18571674 | 1816 | Int_t nV0s=esd->GetNumberOfV0s(); |
cf37fd88 | 1817 | AliInfo |
1818 | (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s)); | |
d64bd07d | 1819 | |
18571674 | 1820 | Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax}; |
7f68891d | 1821 | Bool_t rc=esd->Clean(cleanPars); |
d64bd07d | 1822 | |
7f68891d | 1823 | nTracks=esd->GetNumberOfTracks(); |
18571674 | 1824 | nV0s=esd->GetNumberOfV0s(); |
cf37fd88 | 1825 | AliInfo |
ae5d5566 | 1826 | (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s)); |
d64bd07d | 1827 | |
7f68891d | 1828 | return rc; |
d64bd07d | 1829 | } |
1830 | ||
596a855f | 1831 | //_____________________________________________________________________________ |
af885e0f | 1832 | Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors) |
596a855f | 1833 | { |
1834 | // fill the event summary data | |
1835 | ||
87932dab | 1836 | AliCodeTimerAuto("") |
0f88822a | 1837 | static Int_t eventNr=0; |
596a855f | 1838 | TString detStr = detectors; |
abe0c04e | 1839 | |
b8cd5251 | 1840 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
abe0c04e | 1841 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; |
b8cd5251 | 1842 | AliReconstructor* reconstructor = GetReconstructor(iDet); |
1843 | if (!reconstructor) continue; | |
b8cd5251 | 1844 | if (!ReadESD(esd, fgkDetectorName[iDet])) { |
1845 | AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet])); | |
b26c3770 | 1846 | TTree* clustersTree = NULL; |
d76c31f4 | 1847 | if (fLoader[iDet]) { |
b26c3770 | 1848 | fLoader[iDet]->LoadRecPoints("read"); |
1849 | clustersTree = fLoader[iDet]->TreeR(); | |
1850 | if (!clustersTree) { | |
1851 | AliError(Form("Can't get the %s clusters tree", | |
1852 | fgkDetectorName[iDet])); | |
1853 | if (fStopOnError) return kFALSE; | |
1854 | } | |
1855 | } | |
1856 | if (fRawReader && !reconstructor->HasDigitConversion()) { | |
1857 | reconstructor->FillESD(fRawReader, clustersTree, esd); | |
1858 | } else { | |
1859 | TTree* digitsTree = NULL; | |
1860 | if (fLoader[iDet]) { | |
1861 | fLoader[iDet]->LoadDigits("read"); | |
1862 | digitsTree = fLoader[iDet]->TreeD(); | |
1863 | if (!digitsTree) { | |
1864 | AliError(Form("Can't get the %s digits tree", | |
1865 | fgkDetectorName[iDet])); | |
1866 | if (fStopOnError) return kFALSE; | |
1867 | } | |
1868 | } | |
1869 | reconstructor->FillESD(digitsTree, clustersTree, esd); | |
1870 | if (fLoader[iDet]) fLoader[iDet]->UnloadDigits(); | |
1871 | } | |
d76c31f4 | 1872 | if (fLoader[iDet]) { |
b26c3770 | 1873 | fLoader[iDet]->UnloadRecPoints(); |
1874 | } | |
1875 | ||
b8cd5251 | 1876 | if (fCheckPointLevel > 2) WriteESD(esd, fgkDetectorName[iDet]); |
596a855f | 1877 | } |
1878 | } | |
1879 | ||
1880 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
815c2b38 | 1881 | AliError(Form("the following detectors were not found: %s", |
1882 | detStr.Data())); | |
596a855f | 1883 | if (fStopOnError) return kFALSE; |
1884 | } | |
6efecea1 | 1885 | AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr); |
0f88822a | 1886 | eventNr++; |
596a855f | 1887 | return kTRUE; |
1888 | } | |
1889 | ||
b647652d | 1890 | //_____________________________________________________________________________ |
af885e0f | 1891 | Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd) |
b647652d | 1892 | { |
1893 | // Reads the trigger decision which is | |
1894 | // stored in Trigger.root file and fills | |
1895 | // the corresponding esd entries | |
1896 | ||
87932dab | 1897 | AliCodeTimerAuto("") |
1898 | ||
b647652d | 1899 | AliInfo("Filling trigger information into the ESD"); |
1900 | ||
b024fd7f | 1901 | AliCentralTrigger *aCTP = NULL; |
1902 | ||
b647652d | 1903 | if (fRawReader) { |
1904 | AliCTPRawStream input(fRawReader); | |
1905 | if (!input.Next()) { | |
1906 | AliError("No valid CTP (trigger) DDL raw data is found ! The trigger information is not stored in the ESD !"); | |
1907 | return kFALSE; | |
1908 | } | |
1909 | esd->SetTriggerMask(input.GetClassMask()); | |
1910 | esd->SetTriggerCluster(input.GetClusterMask()); | |
b024fd7f | 1911 | |
1912 | aCTP = new AliCentralTrigger(); | |
1913 | TString configstr(""); | |
1914 | if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB | |
1915 | AliError("No trigger configuration found in OCDB! The trigger classes information will no be stored in ESD!"); | |
259e35c9 | 1916 | delete aCTP; |
b024fd7f | 1917 | return kFALSE; |
1918 | } | |
b647652d | 1919 | } |
1920 | else { | |
1921 | AliRunLoader *runloader = AliRunLoader::GetRunLoader(); | |
1922 | if (runloader) { | |
1923 | if (!runloader->LoadTrigger()) { | |
1ea86aa2 | 1924 | aCTP = runloader->GetTrigger(); |
b647652d | 1925 | esd->SetTriggerMask(aCTP->GetClassMask()); |
1926 | esd->SetTriggerCluster(aCTP->GetClusterMask()); | |
1927 | } | |
1928 | else { | |
1929 | AliWarning("No trigger can be loaded! The trigger information is not stored in the ESD !"); | |
1930 | return kFALSE; | |
1931 | } | |
1932 | } | |
1933 | else { | |
1934 | AliError("No run loader is available! The trigger information is not stored in the ESD !"); | |
1935 | return kFALSE; | |
1936 | } | |
1937 | } | |
1938 | ||
b024fd7f | 1939 | // Now fill the trigger class names into AliESDRun object |
1940 | AliTriggerConfiguration *config = aCTP->GetConfiguration(); | |
1941 | if (!config) { | |
1942 | AliError("No trigger configuration has been found! The trigger classes information will no be stored in ESD!"); | |
d74294be | 1943 | if (fRawReader) delete aCTP; |
b024fd7f | 1944 | return kFALSE; |
1945 | } | |
1946 | ||
1947 | const TObjArray& classesArray = config->GetClasses(); | |
1948 | Int_t nclasses = classesArray.GetEntriesFast(); | |
1949 | for( Int_t j=0; j<nclasses; j++ ) { | |
1950 | AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At( j ); | |
1951 | Int_t trindex = (Int_t)TMath::Log2(trclass->GetMask()); | |
1952 | esd->SetTriggerClass(trclass->GetName(),trindex); | |
1953 | } | |
1954 | ||
d74294be | 1955 | if (fRawReader) delete aCTP; |
b647652d | 1956 | return kTRUE; |
1957 | } | |
596a855f | 1958 | |
001397cd | 1959 | |
1960 | ||
1961 | ||
1962 | ||
1963 | //_____________________________________________________________________________ | |
af885e0f | 1964 | Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd) |
001397cd | 1965 | { |
1966 | // | |
1967 | // Filling information from RawReader Header | |
1968 | // | |
1969 | ||
1970 | AliInfo("Filling information from RawReader Header"); | |
31fd97b2 | 1971 | esd->SetBunchCrossNumber(0); |
1972 | esd->SetOrbitNumber(0); | |
9bcc1e45 | 1973 | esd->SetPeriodNumber(0); |
001397cd | 1974 | esd->SetTimeStamp(0); |
1975 | esd->SetEventType(0); | |
1976 | const AliRawEventHeaderBase * eventHeader = fRawReader->GetEventHeader(); | |
1977 | if (eventHeader){ | |
9bcc1e45 | 1978 | |
1979 | const UInt_t *id = eventHeader->GetP("Id"); | |
1980 | esd->SetBunchCrossNumber((id)[1]&0x00000fff); | |
1981 | esd->SetOrbitNumber((((id)[0]<<20)&0xf00000)|(((id)[1]>>12)&0xfffff)); | |
1982 | esd->SetPeriodNumber(((id)[0]>>4)&0x0fffffff); | |
1983 | ||
001397cd | 1984 | esd->SetTimeStamp((eventHeader->Get("Timestamp"))); |
31fd97b2 | 1985 | esd->SetEventType((eventHeader->Get("Type"))); |
001397cd | 1986 | } |
1987 | ||
1988 | return kTRUE; | |
1989 | } | |
1990 | ||
1991 | ||
596a855f | 1992 | //_____________________________________________________________________________ |
1993 | Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const | |
1994 | { | |
1995 | // check whether detName is contained in detectors | |
1996 | // if yes, it is removed from detectors | |
1997 | ||
1998 | // check if all detectors are selected | |
1999 | if ((detectors.CompareTo("ALL") == 0) || | |
2000 | detectors.BeginsWith("ALL ") || | |
2001 | detectors.EndsWith(" ALL") || | |
2002 | detectors.Contains(" ALL ")) { | |
2003 | detectors = "ALL"; | |
2004 | return kTRUE; | |
2005 | } | |
2006 | ||
2007 | // search for the given detector | |
2008 | Bool_t result = kFALSE; | |
2009 | if ((detectors.CompareTo(detName) == 0) || | |
2010 | detectors.BeginsWith(detName+" ") || | |
2011 | detectors.EndsWith(" "+detName) || | |
2012 | detectors.Contains(" "+detName+" ")) { | |
2013 | detectors.ReplaceAll(detName, ""); | |
2014 | result = kTRUE; | |
2015 | } | |
2016 | ||
2017 | // clean up the detectors string | |
2018 | while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " "); | |
2019 | while (detectors.BeginsWith(" ")) detectors.Remove(0, 1); | |
2020 | while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1); | |
2021 | ||
2022 | return result; | |
2023 | } | |
e583c30d | 2024 | |
f08fc9f5 | 2025 | //_____________________________________________________________________________ |
2026 | Bool_t AliReconstruction::InitRunLoader() | |
2027 | { | |
2028 | // get or create the run loader | |
2029 | ||
2030 | if (gAlice) delete gAlice; | |
2031 | gAlice = NULL; | |
2032 | ||
b26c3770 | 2033 | if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists |
2034 | // load all base libraries to get the loader classes | |
2035 | TString libs = gSystem->GetLibraries(); | |
2036 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
2037 | TString detName = fgkDetectorName[iDet]; | |
2038 | if (detName == "HLT") continue; | |
2039 | if (libs.Contains("lib" + detName + "base.so")) continue; | |
2040 | gSystem->Load("lib" + detName + "base.so"); | |
2041 | } | |
f08fc9f5 | 2042 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); |
2043 | if (!fRunLoader) { | |
2044 | AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); | |
2045 | CleanUp(); | |
2046 | return kFALSE; | |
2047 | } | |
325aa76f | 2048 | |
b26c3770 | 2049 | fRunLoader->CdGAFile(); |
325aa76f | 2050 | fRunLoader->LoadgAlice(); |
f08fc9f5 | 2051 | |
6cae184e | 2052 | //PH This is a temporary fix to give access to the kinematics |
2053 | //PH that is needed for the labels of ITS clusters | |
f2ee4290 | 2054 | fRunLoader->LoadHeader(); |
6cae184e | 2055 | fRunLoader->LoadKinematics(); |
2056 | ||
f08fc9f5 | 2057 | } else { // galice.root does not exist |
2058 | if (!fRawReader) { | |
2059 | AliError(Form("the file %s does not exist", fGAliceFileName.Data())); | |
2060 | CleanUp(); | |
2061 | return kFALSE; | |
2062 | } | |
2063 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(), | |
2064 | AliConfig::GetDefaultEventFolderName(), | |
2065 | "recreate"); | |
2066 | if (!fRunLoader) { | |
2067 | AliError(Form("could not create run loader in file %s", | |
2068 | fGAliceFileName.Data())); | |
2069 | CleanUp(); | |
2070 | return kFALSE; | |
2071 | } | |
21a3aa09 | 2072 | fIsNewRunLoader = kTRUE; |
f08fc9f5 | 2073 | fRunLoader->MakeTree("E"); |
21a3aa09 | 2074 | |
973388c2 | 2075 | if (fNumberOfEventsPerFile > 0) |
2076 | fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile); | |
2077 | else | |
21a3aa09 | 2078 | fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1); |
f08fc9f5 | 2079 | } |
2080 | ||
2081 | return kTRUE; | |
2082 | } | |
2083 | ||
c757bafd | 2084 | //_____________________________________________________________________________ |
b8cd5251 | 2085 | AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet) |
c757bafd | 2086 | { |
f08fc9f5 | 2087 | // get the reconstructor object and the loader for a detector |
c757bafd | 2088 | |
b8cd5251 | 2089 | if (fReconstructor[iDet]) return fReconstructor[iDet]; |
2090 | ||
2091 | // load the reconstructor object | |
2092 | TPluginManager* pluginManager = gROOT->GetPluginManager(); | |
2093 | TString detName = fgkDetectorName[iDet]; | |
2094 | TString recName = "Ali" + detName + "Reconstructor"; | |
f0999a9a | 2095 | |
2096 | if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL; | |
b8cd5251 | 2097 | |
b8cd5251 | 2098 | AliReconstructor* reconstructor = NULL; |
2099 | // first check if a plugin is defined for the reconstructor | |
2100 | TPluginHandler* pluginHandler = | |
2101 | pluginManager->FindHandler("AliReconstructor", detName); | |
f08fc9f5 | 2102 | // if not, add a plugin for it |
2103 | if (!pluginHandler) { | |
b8cd5251 | 2104 | AliDebug(1, Form("defining plugin for %s", recName.Data())); |
b26c3770 | 2105 | TString libs = gSystem->GetLibraries(); |
2106 | if (libs.Contains("lib" + detName + "base.so") || | |
2107 | (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
b8cd5251 | 2108 | pluginManager->AddHandler("AliReconstructor", detName, |
2109 | recName, detName + "rec", recName + "()"); | |
2110 | } else { | |
2111 | pluginManager->AddHandler("AliReconstructor", detName, | |
2112 | recName, detName, recName + "()"); | |
c757bafd | 2113 | } |
b8cd5251 | 2114 | pluginHandler = pluginManager->FindHandler("AliReconstructor", detName); |
2115 | } | |
2116 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
2117 | reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0); | |
c757bafd | 2118 | } |
b8cd5251 | 2119 | if (reconstructor) { |
2120 | TObject* obj = fOptions.FindObject(detName.Data()); | |
2121 | if (obj) reconstructor->SetOption(obj->GetTitle()); | |
d76c31f4 | 2122 | reconstructor->Init(); |
b8cd5251 | 2123 | fReconstructor[iDet] = reconstructor; |
2124 | } | |
2125 | ||
f08fc9f5 | 2126 | // get or create the loader |
2127 | if (detName != "HLT") { | |
2128 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); | |
2129 | if (!fLoader[iDet]) { | |
2130 | AliConfig::Instance() | |
2131 | ->CreateDetectorFolders(fRunLoader->GetEventFolder(), | |
2132 | detName, detName); | |
2133 | // first check if a plugin is defined for the loader | |
bb0901a4 | 2134 | pluginHandler = |
f08fc9f5 | 2135 | pluginManager->FindHandler("AliLoader", detName); |
2136 | // if not, add a plugin for it | |
2137 | if (!pluginHandler) { | |
2138 | TString loaderName = "Ali" + detName + "Loader"; | |
2139 | AliDebug(1, Form("defining plugin for %s", loaderName.Data())); | |
2140 | pluginManager->AddHandler("AliLoader", detName, | |
2141 | loaderName, detName + "base", | |
2142 | loaderName + "(const char*, TFolder*)"); | |
2143 | pluginHandler = pluginManager->FindHandler("AliLoader", detName); | |
2144 | } | |
2145 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
2146 | fLoader[iDet] = | |
2147 | (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(), | |
2148 | fRunLoader->GetEventFolder()); | |
2149 | } | |
2150 | if (!fLoader[iDet]) { // use default loader | |
2151 | fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder()); | |
2152 | } | |
2153 | if (!fLoader[iDet]) { | |
2154 | AliWarning(Form("couldn't get loader for %s", detName.Data())); | |
6667b602 | 2155 | if (fStopOnError) return NULL; |
f08fc9f5 | 2156 | } else { |
2157 | fRunLoader->AddLoader(fLoader[iDet]); | |
2158 | fRunLoader->CdGAFile(); | |
2159 | if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE"); | |
2160 | fRunLoader->Write(0, TObject::kOverwrite); | |
2161 | } | |
2162 | } | |
2163 | } | |
2164 | ||
b8cd5251 | 2165 | return reconstructor; |
c757bafd | 2166 | } |
2167 | ||
2257f27e | 2168 | //_____________________________________________________________________________ |
2169 | Bool_t AliReconstruction::CreateVertexer() | |
2170 | { | |
2171 | // create the vertexer | |
2172 | ||
b8cd5251 | 2173 | fVertexer = NULL; |
2174 | AliReconstructor* itsReconstructor = GetReconstructor(0); | |
59697224 | 2175 | if (itsReconstructor) { |
d76c31f4 | 2176 | fVertexer = itsReconstructor->CreateVertexer(); |
2257f27e | 2177 | } |
b8cd5251 | 2178 | if (!fVertexer) { |
815c2b38 | 2179 | AliWarning("couldn't create a vertexer for ITS"); |
2257f27e | 2180 | if (fStopOnError) return kFALSE; |
2181 | } | |
2182 | ||
2183 | return kTRUE; | |
2184 | } | |
2185 | ||
24f7a148 | 2186 | //_____________________________________________________________________________ |
b8cd5251 | 2187 | Bool_t AliReconstruction::CreateTrackers(const TString& detectors) |
24f7a148 | 2188 | { |
f08fc9f5 | 2189 | // create the trackers |
24f7a148 | 2190 | |
b8cd5251 | 2191 | TString detStr = detectors; |
2192 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
2193 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
2194 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
2195 | if (!reconstructor) continue; | |
2196 | TString detName = fgkDetectorName[iDet]; | |
1f46a9ae | 2197 | if (detName == "HLT") { |
2198 | fRunHLTTracking = kTRUE; | |
2199 | continue; | |
2200 | } | |
e66fbafb | 2201 | if (detName == "MUON") { |
2202 | fRunMuonTracking = kTRUE; | |
2203 | continue; | |
2204 | } | |
2205 | ||
f08fc9f5 | 2206 | |
d76c31f4 | 2207 | fTracker[iDet] = reconstructor->CreateTracker(); |
f08fc9f5 | 2208 | if (!fTracker[iDet] && (iDet < 7)) { |
2209 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); | |
8250d5f5 | 2210 | if (fStopOnError) return kFALSE; |
2211 | } | |
6efecea1 | 2212 | AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0); |
8250d5f5 | 2213 | } |
2214 | ||
24f7a148 | 2215 | return kTRUE; |
2216 | } | |
2217 | ||
e583c30d | 2218 | //_____________________________________________________________________________ |
b26c3770 | 2219 | void AliReconstruction::CleanUp(TFile* file, TFile* fileOld) |
e583c30d | 2220 | { |
2221 | // delete trackers and the run loader and close and delete the file | |
2222 | ||
b8cd5251 | 2223 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
2224 | delete fReconstructor[iDet]; | |
2225 | fReconstructor[iDet] = NULL; | |
2226 | fLoader[iDet] = NULL; | |
2227 | delete fTracker[iDet]; | |
2228 | fTracker[iDet] = NULL; | |
c65c502a | 2229 | // delete fQADataMaker[iDet]; |
2230 | // fQADataMaker[iDet] = NULL; | |
b8cd5251 | 2231 | } |
2232 | delete fVertexer; | |
2233 | fVertexer = NULL; | |
21a3aa09 | 2234 | |
2235 | if (ftVertexer) delete ftVertexer; | |
2236 | ftVertexer = NULL; | |
795e4a22 | 2237 | |
2238 | if(!(AliCDBManager::Instance()->GetCacheFlag())) { | |
2239 | delete fDiamondProfile; | |
2240 | fDiamondProfile = NULL; | |
43c9dae1 | 2241 | delete fDiamondProfileTPC; |
2242 | fDiamondProfileTPC = NULL; | |
6b6e4472 | 2243 | delete fGRPData; |
2244 | fGRPData = NULL; | |
795e4a22 | 2245 | } |
e583c30d | 2246 | |
444753c6 | 2247 | |
e583c30d | 2248 | delete fRunLoader; |
2249 | fRunLoader = NULL; | |
b649205a | 2250 | delete fRawReader; |
2251 | fRawReader = NULL; | |
cd0b062e | 2252 | if (fParentRawReader) delete fParentRawReader; |
2253 | fParentRawReader=NULL; | |
e583c30d | 2254 | |
2255 | if (file) { | |
2256 | file->Close(); | |
2257 | delete file; | |
2258 | } | |
b26c3770 | 2259 | |
2260 | if (fileOld) { | |
2261 | fileOld->Close(); | |
2262 | delete fileOld; | |
2263 | gSystem->Unlink("AliESDs.old.root"); | |
2264 | } | |
21a3aa09 | 2265 | |
e583c30d | 2266 | } |
24f7a148 | 2267 | |
24f7a148 | 2268 | //_____________________________________________________________________________ |
af885e0f | 2269 | |
2270 | Bool_t AliReconstruction::ReadESD(AliESDEvent*& esd, const char* recStep) const | |
24f7a148 | 2271 | { |
2272 | // read the ESD event from a file | |
2273 | ||
2274 | if (!esd) return kFALSE; | |
2275 | char fileName[256]; | |
2276 | sprintf(fileName, "ESD_%d.%d_%s.root", | |
31fd97b2 | 2277 | esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep); |
24f7a148 | 2278 | if (gSystem->AccessPathName(fileName)) return kFALSE; |
2279 | ||
f3a97c86 | 2280 | AliInfo(Form("reading ESD from file %s", fileName)); |
815c2b38 | 2281 | AliDebug(1, Form("reading ESD from file %s", fileName)); |
24f7a148 | 2282 | TFile* file = TFile::Open(fileName); |
2283 | if (!file || !file->IsOpen()) { | |
815c2b38 | 2284 | AliError(Form("opening %s failed", fileName)); |
24f7a148 | 2285 | delete file; |
2286 | return kFALSE; | |
2287 | } | |
2288 | ||
2289 | gROOT->cd(); | |
2290 | delete esd; | |
af885e0f | 2291 | esd = (AliESDEvent*) file->Get("ESD"); |
24f7a148 | 2292 | file->Close(); |
2293 | delete file; | |
2294 | return kTRUE; | |
af885e0f | 2295 | |
24f7a148 | 2296 | } |
2297 | ||
af885e0f | 2298 | |
2299 | ||
24f7a148 | 2300 | //_____________________________________________________________________________ |
af885e0f | 2301 | void AliReconstruction::WriteESD(AliESDEvent* esd, const char* recStep) const |
24f7a148 | 2302 | { |
2303 | // write the ESD event to a file | |
2304 | ||
2305 | if (!esd) return; | |
2306 | char fileName[256]; | |
2307 | sprintf(fileName, "ESD_%d.%d_%s.root", | |
31fd97b2 | 2308 | esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep); |
24f7a148 | 2309 | |
815c2b38 | 2310 | AliDebug(1, Form("writing ESD to file %s", fileName)); |
24f7a148 | 2311 | TFile* file = TFile::Open(fileName, "recreate"); |
2312 | if (!file || !file->IsOpen()) { | |
815c2b38 | 2313 | AliError(Form("opening %s failed", fileName)); |
24f7a148 | 2314 | } else { |
2315 | esd->Write("ESD"); | |
2316 | file->Close(); | |
2317 | } | |
2318 | delete file; | |
2319 | } | |
f3a97c86 | 2320 | |
2321 | ||
af885e0f | 2322 | void AliReconstruction::WriteAlignmentData(AliESDEvent* esd) |
98937d93 | 2323 | { |
2324 | // Write space-points which are then used in the alignment procedures | |
2325 | // For the moment only ITS, TRD and TPC | |
2326 | ||
2327 | // Load TOF clusters | |
d528ee75 | 2328 | if (fTracker[3]){ |
2329 | fLoader[3]->LoadRecPoints("read"); | |
2330 | TTree* tree = fLoader[3]->TreeR(); | |
2331 | if (!tree) { | |
2332 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[3])); | |
2333 | return; | |
2334 | } | |
2335 | fTracker[3]->LoadClusters(tree); | |
98937d93 | 2336 | } |
98937d93 | 2337 | Int_t ntracks = esd->GetNumberOfTracks(); |
2338 | for (Int_t itrack = 0; itrack < ntracks; itrack++) | |
2339 | { | |
2340 | AliESDtrack *track = esd->GetTrack(itrack); | |
2341 | Int_t nsp = 0; | |
ef7253ac | 2342 | Int_t idx[200]; |
98937d93 | 2343 | for (Int_t iDet = 3; iDet >= 0; iDet--) |
2344 | nsp += track->GetNcls(iDet); | |
2345 | if (nsp) { | |
2346 | AliTrackPointArray *sp = new AliTrackPointArray(nsp); | |
2347 | track->SetTrackPointArray(sp); | |
2348 | Int_t isptrack = 0; | |
2349 | for (Int_t iDet = 3; iDet >= 0; iDet--) { | |
2350 | AliTracker *tracker = fTracker[iDet]; | |
2351 | if (!tracker) continue; | |
2352 | Int_t nspdet = track->GetNcls(iDet); | |
98937d93 | 2353 | if (nspdet <= 0) continue; |
2354 | track->GetClusters(iDet,idx); | |
2355 | AliTrackPoint p; | |
2356 | Int_t isp = 0; | |
2357 | Int_t isp2 = 0; | |
4ed6fb1c | 2358 | while (isp2 < nspdet) { |
48ce48d1 | 2359 | Bool_t isvalid; |
c12b6e44 | 2360 | TString dets = fgkDetectorName[iDet]; |
2361 | if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) || | |
2362 | fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") || | |
2363 | fUseTrackingErrorsForAlignment.EndsWith(" "+dets) || | |
2364 | fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) { | |
2365 | isvalid = tracker->GetTrackPointTrackingError(idx[isp2],p,track); | |
48ce48d1 | 2366 | } else { |
2367 | isvalid = tracker->GetTrackPoint(idx[isp2],p); | |
2368 | } | |
2369 | isp2++; | |
160db090 | 2370 | const Int_t kNTPCmax = 159; |
2371 | if (iDet==1 && isp2>kNTPCmax) break; // to be fixed | |
98937d93 | 2372 | if (!isvalid) continue; |
2373 | sp->AddPoint(isptrack,&p); isptrack++; isp++; | |
2374 | } | |
98937d93 | 2375 | } |
2376 | } | |
2377 | } | |
d528ee75 | 2378 | if (fTracker[3]){ |
2379 | fTracker[3]->UnloadClusters(); | |
2380 | fLoader[3]->UnloadRecPoints(); | |
2381 | } | |
98937d93 | 2382 | } |
2e3550da | 2383 | |
2384 | //_____________________________________________________________________________ | |
af885e0f | 2385 | void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd) |
2e3550da | 2386 | { |
2387 | // The method reads the raw-data error log | |
2388 | // accumulated within the rawReader. | |
2389 | // It extracts the raw-data errors related to | |
2390 | // the current event and stores them into | |
2391 | // a TClonesArray inside the esd object. | |
2392 | ||
2393 | if (!fRawReader) return; | |
2394 | ||
2395 | for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) { | |
2396 | ||
2397 | AliRawDataErrorLog *log = fRawReader->GetErrorLog(i); | |
2398 | if (!log) continue; | |
2399 | if (iEvent != log->GetEventNumber()) continue; | |
2400 | ||
2401 | esd->AddRawDataErrorLog(log); | |
2402 | } | |
2403 | ||
2404 | } | |
46698ae4 | 2405 | |
605cb8bb | 2406 | TNamed* AliReconstruction::CopyFileToTNamed(TString fPath,TString pName){ |
b545009a | 2407 | // Dump a file content into a char in TNamed |
46698ae4 | 2408 | ifstream in; |
2409 | in.open(fPath.Data(),ios::in | ios::binary|ios::ate); | |
2410 | Int_t kBytes = (Int_t)in.tellg(); | |
2411 | printf("Size: %d \n",kBytes); | |
2412 | TNamed *fn = 0; | |
2413 | if(in.good()){ | |
2414 | char* memblock = new char [kBytes]; | |
2415 | in.seekg (0, ios::beg); | |
2416 | in.read (memblock, kBytes); | |
2417 | in.close(); | |
2418 | TString fData(memblock,kBytes); | |
605cb8bb | 2419 | fn = new TNamed(pName,fData); |
46698ae4 | 2420 | printf("fData Size: %d \n",fData.Sizeof()); |
605cb8bb | 2421 | printf("pName Size: %d \n",pName.Sizeof()); |
46698ae4 | 2422 | printf("fn Size: %d \n",fn->Sizeof()); |
2423 | delete[] memblock; | |
2424 | } | |
2425 | else{ | |
2426 | AliInfo(Form("Could not Open %s\n",fPath.Data())); | |
2427 | } | |
2428 | ||
2429 | return fn; | |
2430 | } | |
2431 | ||
605cb8bb | 2432 | void AliReconstruction::TNamedToFile(TTree* fTree, TString pName){ |
46698ae4 | 2433 | // This is not really needed in AliReconstruction at the moment |
2434 | // but can serve as a template | |
2435 | ||
2436 | TList *fList = fTree->GetUserInfo(); | |
605cb8bb | 2437 | TNamed *fn = (TNamed*)fList->FindObject(pName.Data()); |
46698ae4 | 2438 | printf("fn Size: %d \n",fn->Sizeof()); |
2439 | ||
605cb8bb | 2440 | TString fTmp(fn->GetName()); // to be 100% sure in principle pName also works |
46698ae4 | 2441 | const char* cdata = fn->GetTitle(); |
2442 | printf("fTmp Size %d\n",fTmp.Sizeof()); | |
2443 | ||
2444 | int size = fn->Sizeof()-fTmp.Sizeof()-sizeof(UChar_t)-sizeof(Int_t); // see dfinition of TString::SizeOf()... | |
2445 | printf("calculated size %d\n",size); | |
605cb8bb | 2446 | ofstream out(pName.Data(),ios::out | ios::binary); |
46698ae4 | 2447 | out.write(cdata,size); |
2448 | out.close(); | |
2449 | ||
2450 | } | |
6efecea1 | 2451 | |
7e963665 | 2452 | //_____________________________________________________________________________ |
04236e67 | 2453 | AliQADataMakerRec * AliReconstruction::GetQADataMaker(Int_t iDet) |
7e963665 | 2454 | { |
2455 | // get the quality assurance data maker object and the loader for a detector | |
6efecea1 | 2456 | |
7e963665 | 2457 | if (fQADataMaker[iDet]) |
2458 | return fQADataMaker[iDet]; | |
2459 | ||
04236e67 | 2460 | AliQADataMakerRec * qadm = NULL; |
2461 | if (iDet == fgkNDetectors) { //Global QA | |
2462 | qadm = new AliGlobalQADataMaker(); | |
aa3c69a9 | 2463 | fQADataMaker[iDet] = qadm; |
2464 | return qadm; | |
2465 | } | |
2466 | ||
7e963665 | 2467 | // load the QA data maker object |
2468 | TPluginManager* pluginManager = gROOT->GetPluginManager(); | |
2469 | TString detName = fgkDetectorName[iDet]; | |
04236e67 | 2470 | TString qadmName = "Ali" + detName + "QADataMakerRec"; |
f0999a9a | 2471 | if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) |
7e963665 | 2472 | return NULL; |
2473 | ||
7e963665 | 2474 | // first check if a plugin is defined for the quality assurance data maker |
04236e67 | 2475 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMakerRec", detName); |
7e963665 | 2476 | // if not, add a plugin for it |
2477 | if (!pluginHandler) { | |
2478 | AliDebug(1, Form("defining plugin for %s", qadmName.Data())); | |
2479 | TString libs = gSystem->GetLibraries(); | |
2480 | if (libs.Contains("lib" + detName + "base.so") || | |
2481 | (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
04236e67 | 2482 | pluginManager->AddHandler("AliQADataMakerRec", detName, |
7e963665 | 2483 | qadmName, detName + "qadm", qadmName + "()"); |
2484 | } else { | |
04236e67 | 2485 | pluginManager->AddHandler("AliQADataMakerRec", detName, |
7e963665 | 2486 | qadmName, detName, qadmName + "()"); |
2487 | } | |
04236e67 | 2488 | pluginHandler = pluginManager->FindHandler("AliQADataMakerRec", detName); |
7e963665 | 2489 | } |
2490 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
04236e67 | 2491 | qadm = (AliQADataMakerRec *) pluginHandler->ExecPlugin(0); |
7e963665 | 2492 | } |
aa3c69a9 | 2493 | |
2494 | fQADataMaker[iDet] = qadm; | |
7e963665 | 2495 | |
2496 | return qadm; | |
2497 | } | |
46698ae4 | 2498 | |
a5fa6165 | 2499 | //_____________________________________________________________________________ |
7e963665 | 2500 | Bool_t AliReconstruction::RunQA(const char* detectors, AliESDEvent *& esd) |
2501 | { | |
2502 | // run the Quality Assurance data producer | |
2503 | ||
2504 | AliCodeTimerAuto("") | |
2505 | TString detStr = detectors; | |
2506 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
2507 | if (!IsSelected(fgkDetectorName[iDet], detStr)) | |
2508 | continue; | |
04236e67 | 2509 | AliQADataMakerRec * qadm = GetQADataMaker(iDet); |
7e963665 | 2510 | if (!qadm) |
2511 | continue; | |
2512 | AliCodeTimerStart(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); | |
2513 | AliInfo(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); | |
2514 | ||
2515 | qadm->Exec(AliQA::kESDS, esd) ; | |
2516 | qadm->Increment() ; | |
2517 | ||
2518 | AliCodeTimerStop(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); | |
2519 | } | |
2520 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
2521 | AliError(Form("the following detectors were not found: %s", | |
2522 | detStr.Data())); | |
2523 | if (fStopOnError) | |
2524 | return kFALSE; | |
2525 | } | |
2526 | ||
2527 | return kTRUE; | |
2528 | ||
2529 | } | |
8661738e | 2530 | |
2531 | //_____________________________________________________________________________ | |
2532 | void AliReconstruction::CheckQA() | |
2533 | { | |
2534 | // check the QA of SIM for this run and remove the detectors | |
2535 | // with status Fatal | |
2536 | ||
abe0c04e | 2537 | TString newRunLocalReconstruction ; |
2538 | TString newRunTracking ; | |
2539 | TString newFillESD ; | |
2540 | ||
8661738e | 2541 | for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) { |
2542 | TString detName(AliQA::GetDetName(iDet)) ; | |
96d67a8d | 2543 | AliQA * qa = AliQA::Instance(AliQA::DETECTORINDEX_t(iDet)) ; |
2544 | if ( qa->IsSet(AliQA::DETECTORINDEX_t(iDet), AliQA::kSIM, AliQA::kFATAL)) { | |
8661738e | 2545 | AliInfo(Form("QA status for %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed", detName.Data())) ; |
abe0c04e | 2546 | } else { |
2547 | if ( fRunLocalReconstruction.Contains(AliQA::GetDetName(iDet)) || | |
2548 | fRunLocalReconstruction.Contains("ALL") ) { | |
2549 | newRunLocalReconstruction += detName ; | |
2550 | newRunLocalReconstruction += " " ; | |
2551 | } | |
2552 | if ( fRunTracking.Contains(AliQA::GetDetName(iDet)) || | |
2553 | fRunTracking.Contains("ALL") ) { | |
2554 | newRunTracking += detName ; | |
2555 | newRunTracking += " " ; | |
2556 | } | |
2557 | if ( fFillESD.Contains(AliQA::GetDetName(iDet)) || | |
2558 | fFillESD.Contains("ALL") ) { | |
2559 | newFillESD += detName ; | |
2560 | newFillESD += " " ; | |
8661738e | 2561 | } |
2562 | } | |
2563 | } | |
abe0c04e | 2564 | fRunLocalReconstruction = newRunLocalReconstruction ; |
2565 | fRunTracking = newRunTracking ; | |
2566 | fFillESD = newFillESD ; | |
a5fa6165 | 2567 | } |
5b188f2f | 2568 | |
2569 | //_____________________________________________________________________________ | |
2570 | Int_t AliReconstruction::GetDetIndex(const char* detector) | |
2571 | { | |
2572 | // return the detector index corresponding to detector | |
2573 | Int_t index = -1 ; | |
2574 | for (index = 0; index < fgkNDetectors ; index++) { | |
2575 | if ( strcmp(detector, fgkDetectorName[index]) == 0 ) | |
2576 | break ; | |
2577 | } | |
2578 | return index ; | |
2579 | } | |
7167ae53 | 2580 | //_____________________________________________________________________________ |
2581 | Bool_t AliReconstruction::FinishPlaneEff() { | |
2582 | // | |
2583 | // Here execute all the necessary operationis, at the end of the tracking phase, | |
2584 | // in case that evaluation of PlaneEfficiencies was required for some detector. | |
2585 | // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated. | |
2586 | // | |
2587 | // This Preliminary version works only FOR ITS !!!!! | |
2588 | // other detectors (TOF,TRD, etc. have to develop their specific codes) | |
2589 | // | |
2590 | // Input: none | |
2591 | // Return: kTRUE if all operations have been done properly, kFALSE otherwise | |
2592 | // | |
2593 | Bool_t ret=kFALSE; | |
2594 | //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
2595 | for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS | |
2596 | //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
5fbd4fd6 | 2597 | if(fTracker[iDet]) { |
2598 | AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff(); | |
2599 | ret=planeeff->WriteIntoCDB(); | |
2600 | if(planeeff->GetCreateHistos()) { | |
2601 | TString name="PlaneEffHisto"; | |
2602 | name+=fgkDetectorName[iDet]; | |
2603 | name+=".root"; | |
2604 | ret*=planeeff->WriteHistosToFile(name,"RECREATE"); | |
2605 | } | |
2606 | } | |
7167ae53 | 2607 | } |
2608 | return ret; | |
2609 | } | |
2610 | //_____________________________________________________________________________ | |
2611 | Bool_t AliReconstruction::InitPlaneEff() { | |
2612 | // | |
2613 | // Here execute all the necessary operations, before of the tracking phase, | |
2614 | // for the evaluation of PlaneEfficiencies, in case required for some detectors. | |
2615 | // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency | |
2616 | // which should be updated/recalculated. | |
2617 | // | |
2618 | // This Preliminary version will work only FOR ITS !!!!! | |
2619 | // other detectors (TOF,TRD, etc. have to develop their specific codes) | |
2620 | // | |
2621 | // Input: none | |
2622 | // Return: kTRUE if all operations have been done properly, kFALSE otherwise | |
2623 | // | |
2624 | AliWarning(Form("Implementation of this method not yet done !! Method return kTRUE")); | |
2625 | return kTRUE; | |
7520312d | 2626 | } |
14dd053c | 2627 | |
2628 | //_____________________________________________________________________________ | |
2629 | Bool_t AliReconstruction::InitAliEVE() | |
2630 | { | |
2631 | // This method should be called only in case | |
2632 | // AliReconstruction is run | |
2633 | // within the alieve environment. | |
2634 | // It will initialize AliEVE in a way | |
2635 | // so that it can visualize event processed | |
2636 | // by AliReconstruction. | |
2637 | // The return flag shows whenever the | |
2638 | // AliEVE initialization was successful or not. | |
2639 | ||
2640 | TString macroStr; | |
2641 | macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT")); | |
2642 | AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data())); | |
2643 | if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE; | |
2644 | ||
de33999e | 2645 | gROOT->ProcessLine("if (!gAliEveEvent) {gAliEveEvent = new AliEveEventManager();gAliEveEvent->SetAutoLoad(kTRUE);gAliEveEvent->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(gAliEveEvent);};"); |
2646 | gROOT->ProcessLine("alieve_online_init()"); | |
14dd053c | 2647 | |
2648 | return kTRUE; | |
2649 | } | |
2650 | ||
2651 | //_____________________________________________________________________________ | |
2652 | void AliReconstruction::RunAliEVE() | |
2653 | { | |
2654 | // Runs AliEVE visualisation of | |
2655 | // the current event. | |
2656 | // Should be executed only after | |
2657 | // successful initialization of AliEVE. | |
2658 | ||
2659 | AliInfo("Running AliEVE..."); | |
2660 | gROOT->ProcessLine(Form("gAliEveEvent->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p);",fRunLoader,fRawReader,fesd)); | |
2661 | gROOT->ProcessLine("gAliEveEvent->StartStopAutoLoadTimer();"); | |
2662 | gSystem->Run(); | |
2663 | } |