]>
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()); |
ff5970a3 | 717 | |
718 | TString detsToCheck=fRunLocalReconstruction; | |
719 | if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) | |
0bf7aade | 720 | AliFatalClass("Current loaded geometry differs in the definition of symbolic names!"); |
6bae477a | 721 | if (!gGeoManager) if (fStopOnError) return kFALSE; |
722 | } | |
8e245d15 | 723 | |
6bae477a | 724 | if (!MisalignGeometry(fLoadAlignData)) if (fStopOnError) return kFALSE; |
0f88822a | 725 | AliSysInfo::AddStamp("LoadGeom"); |
6bae477a | 726 | |
325aa76f | 727 | |
728 | // Get the GRP CDB entry | |
729 | AliCDBEntry* entryGRP = AliCDBManager::Instance()->Get("GRP/GRP/Data"); | |
730 | ||
325aa76f | 731 | if (entryGRP) |
ff5b314b | 732 | fGRPData = dynamic_cast<TMap*>(entryGRP->GetObject()); |
325aa76f | 733 | |
734 | if (!fGRPData) { | |
735 | AliError("No GRP entry found in OCDB!"); | |
736 | return kFALSE; | |
f6806ad3 | 737 | } |
325aa76f | 738 | |
739 | ||
740 | // Magnetic field map | |
741 | if (!AliTracker::GetFieldMap()) { | |
742 | // Construct the field map out of the information retrieved from GRP. | |
743 | // | |
744 | // For the moment, this is a dummy piece of code. | |
745 | // The actual map is expected to be already created in rec.C ! | |
746 | // | |
747 | ||
748 | Float_t factor=1.; | |
749 | Int_t map=AliMagWrapCheb::k5kG; | |
750 | Bool_t dipoleON=kTRUE; | |
751 | ||
752 | // L3 | |
753 | TObjString *l3Current= | |
754 | dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Current")); | |
755 | if (!l3Current) { | |
756 | AliError("GRP/GRP/Data entry: missing value for the L3 current !"); | |
757 | return kFALSE; | |
758 | } | |
759 | TObjString *l3Polarity= | |
760 | dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Polarity")); | |
761 | if (!l3Polarity) { | |
762 | AliError("GRP/GRP/Data entry: missing value for the L3 polarity !"); | |
763 | return kFALSE; | |
596a855f | 764 | } |
325aa76f | 765 | |
766 | // Dipole | |
767 | TObjString *diCurrent= | |
768 | dynamic_cast<TObjString*>(fGRPData->GetValue("fDipoleCurrent")); | |
769 | if (!diCurrent) { | |
770 | AliError("GRP/GRP/Data entry: missing value for the dipole current !"); | |
771 | return kFALSE; | |
772 | } | |
773 | TObjString *diPolarity= | |
774 | dynamic_cast<TObjString*>(fGRPData->GetValue("fDipolePolarity")); | |
775 | if (!diPolarity) { | |
776 | AliError("GRP/GRP/Data entry: missing value for the dipole polarity !"); | |
777 | return kFALSE; | |
778 | } | |
779 | ||
780 | ||
781 | AliMagF *field= | |
782 | new AliMagWrapCheb("Maps","Maps",2,factor,10.,map,dipoleON); | |
783 | AliTracker::SetFieldMap(field,fUniformField); | |
784 | ||
785 | //Temporary measure | |
786 | AliFatal("Please, provide the field map ! Crashing deliberately..."); | |
787 | ||
788 | } | |
789 | ||
790 | ||
791 | // Get the diamond profile from OCDB | |
792 | AliCDBEntry* entry = AliCDBManager::Instance() | |
793 | ->Get("GRP/Calib/MeanVertex"); | |
794 | ||
795 | if(entry) { | |
796 | fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
797 | } else { | |
798 | AliError("No diamond profile found in OCDB!"); | |
799 | } | |
800 | ||
801 | entry = 0; | |
802 | entry = AliCDBManager::Instance() | |
803 | ->Get("GRP/Calib/MeanVertexTPC"); | |
804 | ||
805 | if(entry) { | |
806 | fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
807 | } else { | |
808 | AliError("No diamond profile found in OCDB!"); | |
596a855f | 809 | } |
325aa76f | 810 | |
811 | ftVertexer = new AliVertexerTracks(AliTracker::GetBz()); | |
812 | if(fDiamondProfile && fMeanVertexConstraint) ftVertexer->SetVtxStart(fDiamondProfile); | |
2257f27e | 813 | |
814 | // get vertexer | |
815 | if (fRunVertexFinder && !CreateVertexer()) { | |
816 | if (fStopOnError) { | |
817 | CleanUp(); | |
818 | return kFALSE; | |
819 | } | |
820 | } | |
0f88822a | 821 | AliSysInfo::AddStamp("Vertexer"); |
596a855f | 822 | |
f08fc9f5 | 823 | // get trackers |
b8cd5251 | 824 | if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) { |
24f7a148 | 825 | if (fStopOnError) { |
826 | CleanUp(); | |
827 | return kFALSE; | |
828 | } | |
596a855f | 829 | } |
0f88822a | 830 | AliSysInfo::AddStamp("LoadTrackers"); |
24f7a148 | 831 | |
b26c3770 | 832 | // get the possibly already existing ESD file and tree |
21a3aa09 | 833 | fesd = new AliESDEvent(); fhltesd = new AliESDEvent(); |
b26c3770 | 834 | if (!gSystem->AccessPathName("AliESDs.root")){ |
835 | gSystem->CopyFile("AliESDs.root", "AliESDs.old.root", kTRUE); | |
21a3aa09 | 836 | ffileOld = TFile::Open("AliESDs.old.root"); |
837 | if (ffileOld && ffileOld->IsOpen()) { | |
838 | ftreeOld = (TTree*) ffileOld->Get("esdTree"); | |
839 | if (ftreeOld)fesd->ReadFromTree(ftreeOld); | |
840 | fhlttreeOld = (TTree*) ffileOld->Get("HLTesdTree"); | |
841 | if (fhlttreeOld) fhltesd->ReadFromTree(fhlttreeOld); | |
b26c3770 | 842 | } |
843 | } | |
844 | ||
36711aa4 | 845 | // create the ESD output file and tree |
21a3aa09 | 846 | ffile = TFile::Open("AliESDs.root", "RECREATE"); |
847 | ffile->SetCompressionLevel(2); | |
848 | if (!ffile->IsOpen()) { | |
815c2b38 | 849 | AliError("opening AliESDs.root failed"); |
21a3aa09 | 850 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
596a855f | 851 | } |
46698ae4 | 852 | |
21a3aa09 | 853 | ftree = new TTree("esdTree", "Tree with ESD objects"); |
854 | fesd = new AliESDEvent(); | |
855 | fesd->CreateStdContent(); | |
856 | fesd->WriteToTree(ftree); | |
46698ae4 | 857 | |
21a3aa09 | 858 | fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects"); |
859 | fhltesd = new AliESDEvent(); | |
860 | fhltesd->CreateStdContent(); | |
861 | fhltesd->WriteToTree(fhlttree); | |
46698ae4 | 862 | |
5728d3d5 | 863 | |
1d99986f | 864 | if (fWriteESDfriend) { |
21a3aa09 | 865 | fesdf = new AliESDfriend(); |
866 | TBranch *br=ftree->Branch("ESDfriend.","AliESDfriend", &fesdf); | |
46698ae4 | 867 | br->SetFile("AliESDfriends.root"); |
21a3aa09 | 868 | fesd->AddObject(fesdf); |
1d99986f | 869 | } |
5728d3d5 | 870 | |
444753c6 | 871 | |
c5e3e5d1 | 872 | |
b649205a | 873 | if (fRawReader) fRawReader->RewindEvents(); |
a5fa6165 | 874 | |
95cee32f | 875 | ProcInfo_t ProcInfo; |
876 | gSystem->GetProcInfo(&ProcInfo); | |
877 | AliInfo(Form("Current memory usage %d %d", ProcInfo.fMemResident, ProcInfo.fMemVirtual)); | |
8661738e | 878 | |
aa3c69a9 | 879 | |
325aa76f | 880 | //QA |
881 | AliQADataMakerSteer qas ; | |
882 | if (fRunQA && fRawReader) { | |
883 | qas.Run(fRunLocalReconstruction, fRawReader) ; | |
884 | fSameQACycle = kTRUE ; | |
885 | } | |
aa3c69a9 | 886 | //Initialize the QA and start of cycle for out-of-cycle QA |
f6806ad3 | 887 | if (fRunQA) { |
459fdee0 | 888 | // TString detStr(fFillESD); |
889 | // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
890 | // if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
891 | // AliQADataMakerRec *qadm = GetQADataMaker(iDet); | |
892 | // if (!qadm) continue; | |
893 | // AliInfo(Form("Initializing the QA data maker for %s", | |
894 | // fgkDetectorName[iDet])); | |
895 | // qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun()); | |
896 | // qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun()); | |
897 | // if (!fInLoopQA) { | |
898 | // qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle); | |
899 | // qadm->StartOfCycle(AliQA::kESDS,"same"); | |
900 | // } | |
901 | // } | |
e4a998ed | 902 | if (fRunGlobalQA) { |
903 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); | |
904 | AliInfo(Form("Initializing the global QA data maker")); | |
905 | TObjArray *arr= | |
906 | qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun()); | |
907 | AliTracker::SetResidualsArray(arr); | |
908 | qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun()); | |
909 | if (!fInLoopQA) { | |
910 | qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle); | |
911 | qadm->StartOfCycle(AliQA::kESDS, "same"); | |
912 | } | |
913 | } | |
914 | if (!fInLoopQA) | |
915 | fSameQACycle = kTRUE; | |
aa3c69a9 | 916 | } |
917 | ||
7167ae53 | 918 | //Initialize the Plane Efficiency framework |
919 | if (fRunPlaneEff && !InitPlaneEff()) { | |
21a3aa09 | 920 | if(fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
7167ae53 | 921 | } |
aa3c69a9 | 922 | |
14dd053c | 923 | if (strcmp(gProgName,"alieve") == 0) |
924 | fRunAliEVE = InitAliEVE(); | |
925 | ||
21a3aa09 | 926 | return kTRUE; |
927 | } | |
928 | ||
929 | //_____________________________________________________________________________ | |
930 | Bool_t AliReconstruction::RunEvent(Int_t iEvent) | |
931 | { | |
932 | // run the reconstruction over a single event | |
933 | // The event loop is steered in Run method | |
934 | ||
935 | AliCodeTimerAuto(""); | |
936 | ||
937 | if (iEvent >= fRunLoader->GetNumberOfEvents()) { | |
938 | fRunLoader->SetEventNumber(iEvent); | |
939 | fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(), | |
940 | iEvent, iEvent); | |
941 | //?? fRunLoader->MakeTree("H"); | |
942 | fRunLoader->TreeE()->Fill(); | |
943 | } | |
944 | ||
945 | if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) { | |
946 | // copy old ESD to the new one | |
947 | if (ftreeOld) { | |
948 | fesd->ReadFromTree(ftreeOld); | |
949 | ftreeOld->GetEntry(iEvent); | |
950 | ftree->Fill(); | |
b26c3770 | 951 | } |
21a3aa09 | 952 | if (fhlttreeOld) { |
f6806ad3 | 953 | fhltesd->ReadFromTree(fhlttreeOld); |
21a3aa09 | 954 | fhlttreeOld->GetEntry(iEvent); |
955 | fhlttree->Fill(); | |
956 | } | |
957 | return kTRUE; | |
958 | } | |
959 | ||
960 | AliInfo(Form("processing event %d", iEvent)); | |
aa3c69a9 | 961 | |
962 | //Start of cycle for the in-loop QA | |
3b378a42 | 963 | if (fInLoopQA) { |
964 | if (fRunQA) { | |
965 | TString detStr(fFillESD); | |
966 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
e4a998ed | 967 | if (!IsSelected(fgkDetectorName[iDet], detStr)) |
968 | continue; | |
3b378a42 | 969 | AliQADataMakerRec *qadm = GetQADataMaker(iDet); |
e4a998ed | 970 | if (!qadm) |
971 | continue; | |
972 | qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle); | |
3b378a42 | 973 | qadm->StartOfCycle(AliQA::kESDS, "same") ; |
974 | } | |
e4a998ed | 975 | if (fRunGlobalQA) { |
976 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); | |
977 | qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle); | |
978 | qadm->StartOfCycle(AliQA::kESDS, "same"); | |
979 | } | |
980 | } | |
aa3c69a9 | 981 | } |
982 | ||
596a855f | 983 | fRunLoader->GetEvent(iEvent); |
24f7a148 | 984 | |
bb0901a4 | 985 | char aFileName[256]; |
986 | sprintf(aFileName, "ESD_%d.%d_final.root", | |
f08fc9f5 | 987 | fRunLoader->GetHeader()->GetRun(), |
988 | fRunLoader->GetHeader()->GetEventNrInRun()); | |
21a3aa09 | 989 | if (!gSystem->AccessPathName(aFileName)) return kTRUE; |
24f7a148 | 990 | |
d506c543 | 991 | // local single event reconstruction |
b26c3770 | 992 | if (!fRunLocalReconstruction.IsNull()) { |
d506c543 | 993 | TString detectors=fRunLocalReconstruction; |
a441bf51 | 994 | // run HLT event reconstruction first |
d506c543 | 995 | // ;-( IsSelected changes the string |
996 | if (IsSelected("HLT", detectors) && | |
997 | !RunLocalEventReconstruction("HLT")) { | |
a441bf51 | 998 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
999 | } | |
1000 | detectors=fRunLocalReconstruction; | |
1001 | detectors.ReplaceAll("HLT", ""); | |
1002 | if (!RunLocalEventReconstruction(detectors)) { | |
21a3aa09 | 1003 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
b26c3770 | 1004 | } |
1005 | } | |
1006 | ||
21a3aa09 | 1007 | fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); |
1008 | fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); | |
1009 | fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun()); | |
1010 | fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun()); | |
46698ae4 | 1011 | |
d6ee376f | 1012 | // Set magnetic field from the tracker |
21a3aa09 | 1013 | fesd->SetMagneticField(AliTracker::GetBz()); |
1014 | fhltesd->SetMagneticField(AliTracker::GetBz()); | |
596a855f | 1015 | |
46698ae4 | 1016 | |
1017 | ||
2e3550da | 1018 | // Fill raw-data error log into the ESD |
21a3aa09 | 1019 | if (fRawReader) FillRawDataErrorLog(iEvent,fesd); |
2e3550da | 1020 | |
2257f27e | 1021 | // vertex finder |
1022 | if (fRunVertexFinder) { | |
21a3aa09 | 1023 | if (!ReadESD(fesd, "vertex")) { |
1024 | if (!RunVertexFinder(fesd)) { | |
1025 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} | |
2257f27e | 1026 | } |
21a3aa09 | 1027 | if (fCheckPointLevel > 0) WriteESD(fesd, "vertex"); |
2257f27e | 1028 | } |
1029 | } | |
1030 | ||
e66fbafb | 1031 | // Muon tracking |
b8cd5251 | 1032 | if (!fRunTracking.IsNull()) { |
e66fbafb | 1033 | if (fRunMuonTracking) { |
21a3aa09 | 1034 | if (!RunMuonTracking(fesd)) { |
1035 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} | |
24f7a148 | 1036 | } |
596a855f | 1037 | } |
1038 | } | |
1039 | ||
e66fbafb | 1040 | // barrel tracking |
1041 | if (!fRunTracking.IsNull()) { | |
21a3aa09 | 1042 | if (!ReadESD(fesd, "tracking")) { |
1043 | if (!RunTracking(fesd)) { | |
1044 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} | |
e66fbafb | 1045 | } |
21a3aa09 | 1046 | if (fCheckPointLevel > 0) WriteESD(fesd, "tracking"); |
e66fbafb | 1047 | } |
1048 | } | |
21c573b7 | 1049 | |
596a855f | 1050 | // fill ESD |
1051 | if (!fFillESD.IsNull()) { | |
d506c543 | 1052 | TString detectors=fFillESD; |
f6806ad3 | 1053 | // run HLT first and on hltesd |
d506c543 | 1054 | // ;-( IsSelected changes the string |
1055 | if (IsSelected("HLT", detectors) && | |
1056 | !FillESD(fhltesd, "HLT")) { | |
f6806ad3 | 1057 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
1058 | } | |
1059 | detectors=fFillESD; | |
d5105682 | 1060 | // Temporary fix to avoid problems with HLT that overwrites the offline ESDs |
1061 | if (detectors.Contains("ALL")) { | |
1062 | detectors=""; | |
1063 | for (Int_t idet=0; idet<fgkNDetectors; ++idet){ | |
1064 | detectors += fgkDetectorName[idet]; | |
1065 | detectors += " "; | |
1066 | } | |
1067 | } | |
f6806ad3 | 1068 | detectors.ReplaceAll("HLT", ""); |
1069 | if (!FillESD(fesd, detectors)) { | |
21a3aa09 | 1070 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} |
596a855f | 1071 | } |
1072 | } | |
a5fa6165 | 1073 | |
001397cd | 1074 | // fill Event header information from the RawEventHeader |
21a3aa09 | 1075 | if (fRawReader){FillRawEventHeaderESD(fesd);} |
596a855f | 1076 | |
1077 | // combined PID | |
21a3aa09 | 1078 | AliESDpid::MakePID(fesd); |
1079 | if (fCheckPointLevel > 1) WriteESD(fesd, "PID"); | |
596a855f | 1080 | |
b647652d | 1081 | if (fFillTriggerESD) { |
21a3aa09 | 1082 | if (!ReadESD(fesd, "trigger")) { |
1083 | if (!FillTriggerESD(fesd)) { | |
1084 | if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;} | |
b647652d | 1085 | } |
21a3aa09 | 1086 | if (fCheckPointLevel > 1) WriteESD(fesd, "trigger"); |
b647652d | 1087 | } |
1088 | } | |
1089 | ||
21a3aa09 | 1090 | ffile->cd(); |
a6ee503a | 1091 | |
3c3709c4 | 1092 | // |
67be5c77 | 1093 | // Propagate track to the beam pipe (if not already done by ITS) |
3c3709c4 | 1094 | // |
21a3aa09 | 1095 | const Int_t ntracks = fesd->GetNumberOfTracks(); |
1096 | const Double_t kBz = fesd->GetMagneticField(); | |
3c3709c4 | 1097 | const Double_t kRadius = 2.8; //something less than the beam pipe radius |
1098 | ||
1099 | TObjArray trkArray; | |
1100 | UShort_t *selectedIdx=new UShort_t[ntracks]; | |
1101 | ||
1102 | for (Int_t itrack=0; itrack<ntracks; itrack++){ | |
1103 | const Double_t kMaxStep = 5; //max step over the material | |
1104 | Bool_t ok; | |
1105 | ||
21a3aa09 | 1106 | AliESDtrack *track = fesd->GetTrack(itrack); |
3c3709c4 | 1107 | if (!track) continue; |
1108 | ||
1109 | AliExternalTrackParam *tpcTrack = | |
1110 | (AliExternalTrackParam *)track->GetTPCInnerParam(); | |
bcabd6af | 1111 | ok = kFALSE; |
1112 | if (tpcTrack) | |
1113 | ok = AliTracker:: | |
1114 | PropagateTrackTo(tpcTrack,kRadius,track->GetMass(),kMaxStep,kTRUE); | |
43c9dae1 | 1115 | |
1116 | ||
1117 | ||
3c3709c4 | 1118 | if (ok) { |
1119 | Int_t n=trkArray.GetEntriesFast(); | |
1120 | selectedIdx[n]=track->GetID(); | |
1121 | trkArray.AddLast(tpcTrack); | |
1122 | } | |
1123 | ||
f6806ad3 | 1124 | if (track->GetX() < kRadius) continue; |
3c3709c4 | 1125 | |
f6806ad3 | 1126 | ok = AliTracker:: |
3c3709c4 | 1127 | PropagateTrackTo(track,kRadius,track->GetMass(),kMaxStep,kTRUE); |
f6806ad3 | 1128 | if (ok) { |
1129 | track->RelateToVertex(fesd->GetPrimaryVertexSPD(), kBz, kRadius); | |
1130 | } | |
3c3709c4 | 1131 | } |
1132 | ||
1133 | // | |
1134 | // Improve the reconstructed primary vertex position using the tracks | |
1135 | // | |
1136 | TObject *obj = fOptions.FindObject("ITS"); | |
c060d7fe | 1137 | if (obj) { |
1138 | TString optITS = obj->GetTitle(); | |
1139 | if (optITS.Contains("cosmics") || optITS.Contains("COSMICS")) | |
a84e2607 | 1140 | fRunVertexFinderTracks=kFALSE; |
c060d7fe | 1141 | } |
3c3709c4 | 1142 | if (fRunVertexFinderTracks) { |
1143 | // TPC + ITS primary vertex | |
21a3aa09 | 1144 | ftVertexer->SetITSrefitRequired(); |
43c9dae1 | 1145 | if(fDiamondProfile && fMeanVertexConstraint) { |
21a3aa09 | 1146 | ftVertexer->SetVtxStart(fDiamondProfile); |
43c9dae1 | 1147 | } else { |
21a3aa09 | 1148 | ftVertexer->SetConstraintOff(); |
43c9dae1 | 1149 | } |
21a3aa09 | 1150 | AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd); |
3c3709c4 | 1151 | if (pvtx) { |
1152 | if (pvtx->GetStatus()) { | |
21a3aa09 | 1153 | fesd->SetPrimaryVertex(pvtx); |
3c3709c4 | 1154 | for (Int_t i=0; i<ntracks; i++) { |
21a3aa09 | 1155 | AliESDtrack *t = fesd->GetTrack(i); |
f6806ad3 | 1156 | t->RelateToVertex(pvtx, kBz, kRadius); |
3c3709c4 | 1157 | } |
1158 | } | |
1159 | } | |
1160 | ||
1161 | // TPC-only primary vertex | |
21a3aa09 | 1162 | ftVertexer->SetITSrefitNotRequired(); |
43c9dae1 | 1163 | if(fDiamondProfileTPC && fMeanVertexConstraint) { |
21a3aa09 | 1164 | ftVertexer->SetVtxStart(fDiamondProfileTPC); |
43c9dae1 | 1165 | } else { |
21a3aa09 | 1166 | ftVertexer->SetConstraintOff(); |
43c9dae1 | 1167 | } |
21a3aa09 | 1168 | pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx); |
3c3709c4 | 1169 | if (pvtx) { |
1170 | if (pvtx->GetStatus()) { | |
21a3aa09 | 1171 | fesd->SetPrimaryVertexTPC(pvtx); |
3c3709c4 | 1172 | Int_t nsel=trkArray.GetEntriesFast(); |
1173 | for (Int_t i=0; i<nsel; i++) { | |
1174 | AliExternalTrackParam *t = | |
1175 | (AliExternalTrackParam *)trkArray.UncheckedAt(i); | |
1176 | t->PropagateToDCA(pvtx, kBz, kRadius); | |
1177 | } | |
1178 | } | |
1179 | } | |
1180 | ||
1181 | } | |
1182 | delete[] selectedIdx; | |
1183 | ||
21a3aa09 | 1184 | if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile); |
17c86e90 | 1185 | |
c5e3e5d1 | 1186 | |
d1683eef | 1187 | if (fRunV0Finder) { |
1188 | // V0 finding | |
1189 | AliV0vertexer vtxer; | |
21a3aa09 | 1190 | vtxer.Tracks2V0vertices(fesd); |
5e4ff34d | 1191 | |
d1683eef | 1192 | if (fRunCascadeFinder) { |
1193 | // Cascade finding | |
1194 | AliCascadeVertexer cvtxer; | |
21a3aa09 | 1195 | cvtxer.V0sTracks2CascadeVertices(fesd); |
d1683eef | 1196 | } |
5e4ff34d | 1197 | } |
1198 | ||
596a855f | 1199 | // write ESD |
21a3aa09 | 1200 | if (fCleanESD) CleanESD(fesd); |
854c6476 | 1201 | |
79740dfc | 1202 | if (fRunQA) { |
1203 | if (fRunGlobalQA) { | |
1204 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); | |
1205 | if (qadm) qadm->Exec(AliQA::kESDS, fesd); | |
1206 | } | |
1207 | } | |
854c6476 | 1208 | |
1d99986f | 1209 | if (fWriteESDfriend) { |
21a3aa09 | 1210 | fesdf->~AliESDfriend(); |
1211 | new (fesdf) AliESDfriend(); // Reset... | |
1212 | fesd->GetESDfriend(fesdf); | |
1d99986f | 1213 | } |
21a3aa09 | 1214 | ftree->Fill(); |
500d54ab | 1215 | |
1216 | // write HLT ESD | |
21a3aa09 | 1217 | fhlttree->Fill(); |
1d99986f | 1218 | |
14dd053c | 1219 | // call AliEVE |
1220 | if (fRunAliEVE) RunAliEVE(); | |
1221 | ||
21a3aa09 | 1222 | if (fCheckPointLevel > 0) WriteESD(fesd, "final"); |
1223 | fesd->Reset(); | |
1224 | fhltesd->Reset(); | |
5728d3d5 | 1225 | if (fWriteESDfriend) { |
21a3aa09 | 1226 | fesdf->~AliESDfriend(); |
1227 | new (fesdf) AliESDfriend(); // Reset... | |
5728d3d5 | 1228 | } |
a5fa6165 | 1229 | |
21a3aa09 | 1230 | ProcInfo_t ProcInfo; |
95cee32f | 1231 | gSystem->GetProcInfo(&ProcInfo); |
1232 | AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, ProcInfo.fMemResident, ProcInfo.fMemVirtual)); | |
a5fa6165 | 1233 | |
7e963665 | 1234 | |
aa3c69a9 | 1235 | // End of cycle for the in-loop QA |
3b378a42 | 1236 | if (fInLoopQA) { |
1237 | if (fRunQA) { | |
21a3aa09 | 1238 | RunQA(fFillESD.Data(), fesd); |
3b378a42 | 1239 | TString detStr(fFillESD); |
1240 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
7c002d48 | 1241 | if (!IsSelected(fgkDetectorName[iDet], detStr)) |
1242 | continue; | |
1243 | AliQADataMakerRec * qadm = GetQADataMaker(iDet); | |
1244 | if (!qadm) | |
1245 | continue; | |
1246 | qadm->EndOfCycle(AliQA::kRECPOINTS); | |
1247 | qadm->EndOfCycle(AliQA::kESDS); | |
1248 | qadm->Finish(); | |
1249 | } | |
aa3c69a9 | 1250 | } |
1251 | if (fRunGlobalQA) { | |
7c002d48 | 1252 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); |
aa3c69a9 | 1253 | if (qadm) { |
1254 | qadm->EndOfCycle(AliQA::kRECPOINTS); | |
d7259b2e | 1255 | qadm->EndOfCycle(AliQA::kESDS); |
aa3c69a9 | 1256 | qadm->Finish(); |
1257 | } | |
1258 | } | |
1259 | } | |
aa3c69a9 | 1260 | |
21a3aa09 | 1261 | return kTRUE; |
1262 | } | |
1263 | ||
21a3aa09 | 1264 | //_____________________________________________________________________________ |
1265 | Bool_t AliReconstruction::FinishRun() | |
1266 | { | |
1267 | // Finalize the run | |
1268 | // Called after the exit | |
1269 | // from the event loop | |
1270 | AliCodeTimerAuto(""); | |
1271 | ||
1272 | if (fIsNewRunLoader) { // galice.root didn't exist | |
1273 | fRunLoader->WriteHeader("OVERWRITE"); | |
1274 | fRunLoader->CdGAFile(); | |
1275 | fRunLoader->Write(0, TObject::kOverwrite); | |
1276 | } | |
1277 | ||
1278 | ftree->GetUserInfo()->Add(fesd); | |
1279 | fhlttree->GetUserInfo()->Add(fhltesd); | |
f747912b | 1280 | |
1281 | const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap(); | |
1282 | const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds(); | |
1283 | ||
1284 | TMap *cdbMapCopy = new TMap(cdbMap->GetEntries()); | |
1285 | cdbMapCopy->SetOwner(1); | |
1286 | cdbMapCopy->SetName("cdbMap"); | |
1287 | TIter iter(cdbMap->GetTable()); | |
1288 | ||
1289 | TPair* pair = 0; | |
1290 | while((pair = dynamic_cast<TPair*> (iter.Next()))){ | |
1291 | TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key()); | |
1292 | TObjString* valStr = dynamic_cast<TObjString*> (pair->Value()); | |
1293 | cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName())); | |
1294 | } | |
1295 | ||
1296 | TList *cdbListCopy = new TList(); | |
1297 | cdbListCopy->SetOwner(1); | |
1298 | cdbListCopy->SetName("cdbList"); | |
1299 | ||
1300 | TIter iter2(cdbList); | |
1301 | ||
1302 | AliCDBId* id=0; | |
1303 | while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){ | |
a4970db9 | 1304 | cdbListCopy->Add(new TObjString(id->ToString().Data())); |
f747912b | 1305 | } |
1306 | ||
21a3aa09 | 1307 | ftree->GetUserInfo()->Add(cdbMapCopy); |
1308 | ftree->GetUserInfo()->Add(cdbListCopy); | |
abe0c04e | 1309 | |
46698ae4 | 1310 | |
1311 | if(fESDPar.Contains("ESD.par")){ | |
1312 | AliInfo("Attaching ESD.par to Tree"); | |
1313 | TNamed *fn = CopyFileToTNamed(fESDPar.Data(),"ESD.par"); | |
21a3aa09 | 1314 | ftree->GetUserInfo()->Add(fn); |
596a855f | 1315 | } |
1316 | ||
46698ae4 | 1317 | |
21a3aa09 | 1318 | ffile->cd(); |
aa3c69a9 | 1319 | |
a9c0e6db | 1320 | if (fWriteESDfriend) |
21a3aa09 | 1321 | ftree->SetBranchStatus("ESDfriend*",0); |
562dd0b4 | 1322 | // we want to have only one tree version number |
21a3aa09 | 1323 | ftree->Write(ftree->GetName(),TObject::kOverwrite); |
1324 | fhlttree->Write(); | |
f3a97c86 | 1325 | |
a7a1e1c7 | 1326 | // Finish with Plane Efficiency evaluation: before of CleanUp !!! |
1327 | if (fRunPlaneEff && !FinishPlaneEff()) { | |
1328 | AliWarning("Finish PlaneEff evaluation failed"); | |
1329 | } | |
1330 | ||
eae191bc | 1331 | gROOT->cd(); |
21a3aa09 | 1332 | CleanUp(ffile, ffileOld); |
eae191bc | 1333 | |
a7807689 | 1334 | if (fWriteAOD) { |
7a3b2050 | 1335 | AliWarning("AOD creation not supported anymore during reconstruction. See ANALYSIS/AliAnalysisTaskESDfilter.cxx instead."); |
a7807689 | 1336 | } |
1337 | ||
f3a97c86 | 1338 | // Create tags for the events in the ESD tree (the ESD tree is always present) |
1339 | // In case of empty events the tags will contain dummy values | |
08e1a23e | 1340 | AliESDTagCreator *esdtagCreator = new AliESDTagCreator(); |
6b6e4472 | 1341 | esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData); |
a1069ee1 | 1342 | if (fWriteAOD) { |
7a3b2050 | 1343 | AliWarning("AOD tag creation not supported anymore during reconstruction."); |
a1069ee1 | 1344 | } |
596a855f | 1345 | |
aa3c69a9 | 1346 | //Finish QA and end of cycle for out-of-loop QA |
3b378a42 | 1347 | if (!fInLoopQA) { |
79740dfc | 1348 | if (fRunQA) { |
1349 | AliQADataMakerSteer qas; | |
1350 | qas.Run(fRunLocalReconstruction.Data(), AliQA::kRECPOINTS, fSameQACycle); | |
1351 | //qas.Reset() ; | |
459fdee0 | 1352 | qas.Run(fRunLocalReconstruction.Data(), AliQA::kESDS, fSameQACycle); |
79740dfc | 1353 | if (fRunGlobalQA) { |
1354 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); | |
1355 | if (qadm) { | |
1356 | qadm->EndOfCycle(AliQA::kRECPOINTS); | |
1357 | qadm->EndOfCycle(AliQA::kESDS); | |
1358 | qadm->Finish(); | |
1359 | } | |
1360 | } | |
1361 | } | |
759c1df1 | 1362 | } |
795e4a22 | 1363 | |
1364 | // Cleanup of CDB manager: cache and active storages! | |
1365 | AliCDBManager::Instance()->ClearCache(); | |
1366 | ||
596a855f | 1367 | return kTRUE; |
1368 | } | |
1369 | ||
1370 | ||
1371 | //_____________________________________________________________________________ | |
c4aa7a4c | 1372 | Bool_t AliReconstruction::RunLocalReconstruction(const TString& /*detectors*/) |
596a855f | 1373 | { |
59697224 | 1374 | // run the local reconstruction |
0f88822a | 1375 | static Int_t eventNr=0; |
87932dab | 1376 | AliCodeTimerAuto("") |
030b532d | 1377 | |
d76c31f4 | 1378 | // AliCDBManager* man = AliCDBManager::Instance(); |
1379 | // Bool_t origCache = man->GetCacheFlag(); | |
8e245d15 | 1380 | |
d76c31f4 | 1381 | // TString detStr = detectors; |
1382 | // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1383 | // if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
1384 | // AliReconstructor* reconstructor = GetReconstructor(iDet); | |
1385 | // if (!reconstructor) continue; | |
1386 | // if (reconstructor->HasLocalReconstruction()) continue; | |
b8cd5251 | 1387 | |
d76c31f4 | 1388 | // AliCodeTimerStart(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
1389 | // AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); | |
87932dab | 1390 | |
d76c31f4 | 1391 | // AliCodeTimerStart(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); |
1392 | // AliInfo(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); | |
8e245d15 | 1393 | |
d76c31f4 | 1394 | // man->SetCacheFlag(kTRUE); |
1395 | // TString calibPath = Form("%s/Calib/*", fgkDetectorName[iDet]); | |
1396 | // man->GetAll(calibPath); // entries are cached! | |
8e245d15 | 1397 | |
d76c31f4 | 1398 | // AliCodeTimerStop(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); |
87932dab | 1399 | |
d76c31f4 | 1400 | // if (fRawReader) { |
1401 | // fRawReader->RewindEvents(); | |
1402 | // reconstructor->Reconstruct(fRunLoader, fRawReader); | |
1403 | // } else { | |
1404 | // reconstructor->Reconstruct(fRunLoader); | |
1405 | // } | |
87932dab | 1406 | |
d76c31f4 | 1407 | // AliCodeTimerStop(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
0f88822a | 1408 | // AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr)); |
8e245d15 | 1409 | |
d76c31f4 | 1410 | // // unload calibration data |
1411 | // man->UnloadFromCache(calibPath); | |
1412 | // //man->ClearCache(); | |
1413 | // } | |
596a855f | 1414 | |
d76c31f4 | 1415 | // man->SetCacheFlag(origCache); |
8e245d15 | 1416 | |
d76c31f4 | 1417 | // if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { |
1418 | // AliError(Form("the following detectors were not found: %s", | |
1419 | // detStr.Data())); | |
1420 | // if (fStopOnError) return kFALSE; | |
1421 | // } | |
596a855f | 1422 | |
0f88822a | 1423 | eventNr++; |
596a855f | 1424 | return kTRUE; |
1425 | } | |
1426 | ||
b26c3770 | 1427 | //_____________________________________________________________________________ |
1428 | Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors) | |
1429 | { | |
1430 | // run the local reconstruction | |
aa3c69a9 | 1431 | |
0f88822a | 1432 | static Int_t eventNr=0; |
87932dab | 1433 | AliCodeTimerAuto("") |
b26c3770 | 1434 | |
1435 | TString detStr = detectors; | |
1436 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1437 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
1438 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
1439 | if (!reconstructor) continue; | |
1440 | AliLoader* loader = fLoader[iDet]; | |
f6806ad3 | 1441 | // Matthias April 2008: temporary fix to run HLT reconstruction |
1442 | // although the HLT loader is missing | |
1443 | if (strcmp(fgkDetectorName[iDet], "HLT")==0) { | |
1444 | if (fRawReader) { | |
1445 | reconstructor->Reconstruct(fRawReader, NULL); | |
1446 | } else { | |
1447 | TTree* dummy=NULL; | |
1448 | reconstructor->Reconstruct(dummy, NULL); | |
1449 | } | |
1450 | continue; | |
1451 | } | |
d76c31f4 | 1452 | if (!loader) { |
1453 | AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet])); | |
1454 | continue; | |
1455 | } | |
b26c3770 | 1456 | // conversion of digits |
1457 | if (fRawReader && reconstructor->HasDigitConversion()) { | |
1458 | AliInfo(Form("converting raw data digits into root objects for %s", | |
1459 | fgkDetectorName[iDet])); | |
87932dab | 1460 | AliCodeTimerAuto(Form("converting raw data digits into root objects for %s", |
1461 | fgkDetectorName[iDet])); | |
b26c3770 | 1462 | loader->LoadDigits("update"); |
1463 | loader->CleanDigits(); | |
1464 | loader->MakeDigitsContainer(); | |
1465 | TTree* digitsTree = loader->TreeD(); | |
1466 | reconstructor->ConvertDigits(fRawReader, digitsTree); | |
1467 | loader->WriteDigits("OVERWRITE"); | |
1468 | loader->UnloadDigits(); | |
b26c3770 | 1469 | } |
b26c3770 | 1470 | // local reconstruction |
b26c3770 | 1471 | AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
87932dab | 1472 | AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
b26c3770 | 1473 | loader->LoadRecPoints("update"); |
1474 | loader->CleanRecPoints(); | |
1475 | loader->MakeRecPointsContainer(); | |
1476 | TTree* clustersTree = loader->TreeR(); | |
1477 | if (fRawReader && !reconstructor->HasDigitConversion()) { | |
1478 | reconstructor->Reconstruct(fRawReader, clustersTree); | |
1479 | } else { | |
1480 | loader->LoadDigits("read"); | |
1481 | TTree* digitsTree = loader->TreeD(); | |
1482 | if (!digitsTree) { | |
1483 | AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet])); | |
1484 | if (fStopOnError) return kFALSE; | |
1485 | } else { | |
1486 | reconstructor->Reconstruct(digitsTree, clustersTree); | |
1487 | } | |
1488 | loader->UnloadDigits(); | |
1489 | } | |
d76c31f4 | 1490 | |
aa3c69a9 | 1491 | // In-loop QA for local reconstrucion |
1492 | if (fRunQA && fInLoopQA) { | |
04236e67 | 1493 | AliQADataMakerRec * qadm = GetQADataMaker(iDet); |
aa3c69a9 | 1494 | if (qadm) { |
1495 | //AliCodeTimerStart | |
1496 | //(Form("Running QA data maker for %s", fgkDetectorName[iDet])); | |
1497 | //AliInfo | |
1498 | //(Form("Running QA data maker for %s", fgkDetectorName[iDet])); | |
1499 | ||
1500 | qadm->Exec(AliQA::kRECPOINTS, clustersTree) ; | |
1501 | ||
1502 | //AliCodeTimerStop | |
1503 | //(Form("Running QA data maker for %s", fgkDetectorName[iDet])); | |
1504 | } | |
1505 | } | |
d76c31f4 | 1506 | |
aa3c69a9 | 1507 | loader->WriteRecPoints("OVERWRITE"); |
b26c3770 | 1508 | loader->UnloadRecPoints(); |
6efecea1 | 1509 | AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr); |
b26c3770 | 1510 | } |
1511 | ||
1512 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
1513 | AliError(Form("the following detectors were not found: %s", | |
1514 | detStr.Data())); | |
1515 | if (fStopOnError) return kFALSE; | |
1516 | } | |
0f88822a | 1517 | eventNr++; |
b26c3770 | 1518 | return kTRUE; |
1519 | } | |
1520 | ||
596a855f | 1521 | //_____________________________________________________________________________ |
af885e0f | 1522 | Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd) |
596a855f | 1523 | { |
1524 | // run the barrel tracking | |
1525 | ||
87932dab | 1526 | AliCodeTimerAuto("") |
030b532d | 1527 | |
2257f27e | 1528 | AliESDVertex* vertex = NULL; |
1529 | Double_t vtxPos[3] = {0, 0, 0}; | |
1530 | Double_t vtxErr[3] = {0.07, 0.07, 0.1}; | |
1531 | TArrayF mcVertex(3); | |
a6b0b91b | 1532 | if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) { |
1533 | fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex); | |
1534 | for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i]; | |
1535 | } | |
2257f27e | 1536 | |
b8cd5251 | 1537 | if (fVertexer) { |
17c86e90 | 1538 | if(fDiamondProfile) fVertexer->SetVtxStart(fDiamondProfile); |
815c2b38 | 1539 | AliInfo("running the ITS vertex finder"); |
b26c3770 | 1540 | if (fLoader[0]) fLoader[0]->LoadRecPoints(); |
b8cd5251 | 1541 | vertex = fVertexer->FindVertexForCurrentEvent(fRunLoader->GetEventNumber()); |
b26c3770 | 1542 | if (fLoader[0]) fLoader[0]->UnloadRecPoints(); |
2257f27e | 1543 | if(!vertex){ |
815c2b38 | 1544 | AliWarning("Vertex not found"); |
c710f220 | 1545 | vertex = new AliESDVertex(); |
d1a50cb5 | 1546 | vertex->SetName("default"); |
2257f27e | 1547 | } |
1548 | else { | |
d1a50cb5 | 1549 | vertex->SetName("reconstructed"); |
2257f27e | 1550 | } |
1551 | ||
1552 | } else { | |
815c2b38 | 1553 | AliInfo("getting the primary vertex from MC"); |
2257f27e | 1554 | vertex = new AliESDVertex(vtxPos, vtxErr); |
1555 | } | |
1556 | ||
1557 | if (vertex) { | |
1558 | vertex->GetXYZ(vtxPos); | |
1559 | vertex->GetSigmaXYZ(vtxErr); | |
1560 | } else { | |
815c2b38 | 1561 | AliWarning("no vertex reconstructed"); |
2257f27e | 1562 | vertex = new AliESDVertex(vtxPos, vtxErr); |
1563 | } | |
06cc9d95 | 1564 | esd->SetPrimaryVertexSPD(vertex); |
32e449be | 1565 | // if SPD multiplicity has been determined, it is stored in the ESD |
25be1e5c | 1566 | AliMultiplicity *mult = fVertexer->GetMultiplicity(); |
32e449be | 1567 | if(mult)esd->SetMultiplicity(mult); |
1568 | ||
b8cd5251 | 1569 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1570 | if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr); | |
1571 | } | |
2257f27e | 1572 | delete vertex; |
1573 | ||
2257f27e | 1574 | return kTRUE; |
1575 | } | |
1576 | ||
1f46a9ae | 1577 | //_____________________________________________________________________________ |
af885e0f | 1578 | Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd) |
1f46a9ae | 1579 | { |
1580 | // run the HLT barrel tracking | |
1581 | ||
87932dab | 1582 | AliCodeTimerAuto("") |
1f46a9ae | 1583 | |
1584 | if (!fRunLoader) { | |
1585 | AliError("Missing runLoader!"); | |
1586 | return kFALSE; | |
1587 | } | |
1588 | ||
1589 | AliInfo("running HLT tracking"); | |
1590 | ||
1591 | // Get a pointer to the HLT reconstructor | |
1592 | AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1); | |
1593 | if (!reconstructor) return kFALSE; | |
1594 | ||
1595 | // TPC + ITS | |
1596 | for (Int_t iDet = 1; iDet >= 0; iDet--) { | |
1597 | TString detName = fgkDetectorName[iDet]; | |
1598 | AliDebug(1, Form("%s HLT tracking", detName.Data())); | |
1599 | reconstructor->SetOption(detName.Data()); | |
d76c31f4 | 1600 | AliTracker *tracker = reconstructor->CreateTracker(); |
1f46a9ae | 1601 | if (!tracker) { |
1602 | AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data())); | |
1603 | if (fStopOnError) return kFALSE; | |
9dcc06e1 | 1604 | continue; |
1f46a9ae | 1605 | } |
1606 | Double_t vtxPos[3]; | |
1607 | Double_t vtxErr[3]={0.005,0.005,0.010}; | |
1608 | const AliESDVertex *vertex = esd->GetVertex(); | |
1609 | vertex->GetXYZ(vtxPos); | |
1610 | tracker->SetVertex(vtxPos,vtxErr); | |
1611 | if(iDet != 1) { | |
1612 | fLoader[iDet]->LoadRecPoints("read"); | |
1613 | TTree* tree = fLoader[iDet]->TreeR(); | |
1614 | if (!tree) { | |
1615 | AliError(Form("Can't get the %s cluster tree", detName.Data())); | |
1616 | return kFALSE; | |
1617 | } | |
1618 | tracker->LoadClusters(tree); | |
1619 | } | |
1620 | if (tracker->Clusters2Tracks(esd) != 0) { | |
1621 | AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
1622 | return kFALSE; | |
1623 | } | |
1624 | if(iDet != 1) { | |
1625 | tracker->UnloadClusters(); | |
1626 | } | |
1627 | delete tracker; | |
1628 | } | |
1629 | ||
1f46a9ae | 1630 | return kTRUE; |
1631 | } | |
1632 | ||
e66fbafb | 1633 | //_____________________________________________________________________________ |
af885e0f | 1634 | Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd) |
e66fbafb | 1635 | { |
1636 | // run the muon spectrometer tracking | |
1637 | ||
87932dab | 1638 | AliCodeTimerAuto("") |
e66fbafb | 1639 | |
1640 | if (!fRunLoader) { | |
1641 | AliError("Missing runLoader!"); | |
1642 | return kFALSE; | |
1643 | } | |
1644 | Int_t iDet = 7; // for MUON | |
1645 | ||
1646 | AliInfo("is running..."); | |
1647 | ||
1648 | // Get a pointer to the MUON reconstructor | |
1649 | AliReconstructor *reconstructor = GetReconstructor(iDet); | |
1650 | if (!reconstructor) return kFALSE; | |
1651 | ||
1652 | ||
1653 | TString detName = fgkDetectorName[iDet]; | |
1654 | AliDebug(1, Form("%s tracking", detName.Data())); | |
d76c31f4 | 1655 | AliTracker *tracker = reconstructor->CreateTracker(); |
e66fbafb | 1656 | if (!tracker) { |
1657 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); | |
1658 | return kFALSE; | |
1659 | } | |
1660 | ||
e66fbafb | 1661 | // read RecPoints |
761350a6 | 1662 | fLoader[iDet]->LoadRecPoints("read"); |
c1954ee5 | 1663 | |
761350a6 | 1664 | tracker->LoadClusters(fLoader[iDet]->TreeR()); |
1665 | ||
1666 | Int_t rv = tracker->Clusters2Tracks(esd); | |
1667 | ||
761350a6 | 1668 | if ( rv ) |
1669 | { | |
e66fbafb | 1670 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); |
1671 | return kFALSE; | |
1672 | } | |
761350a6 | 1673 | |
e66fbafb | 1674 | fLoader[iDet]->UnloadRecPoints(); |
1675 | ||
c1954ee5 | 1676 | tracker->UnloadClusters(); |
1677 | ||
e66fbafb | 1678 | delete tracker; |
1679 | ||
e66fbafb | 1680 | return kTRUE; |
1681 | } | |
1682 | ||
1683 | ||
2257f27e | 1684 | //_____________________________________________________________________________ |
af885e0f | 1685 | Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd) |
2257f27e | 1686 | { |
1687 | // run the barrel tracking | |
0f88822a | 1688 | static Int_t eventNr=0; |
87932dab | 1689 | AliCodeTimerAuto("") |
24f7a148 | 1690 | |
815c2b38 | 1691 | AliInfo("running tracking"); |
596a855f | 1692 | |
91b876d1 | 1693 | //Fill the ESD with the T0 info (will be used by the TOF) |
d76c31f4 | 1694 | if (fReconstructor[11] && fLoader[11]) { |
1695 | fLoader[11]->LoadRecPoints("READ"); | |
1696 | TTree *treeR = fLoader[11]->TreeR(); | |
1697 | GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd); | |
1698 | } | |
91b876d1 | 1699 | |
b8cd5251 | 1700 | // pass 1: TPC + ITS inwards |
1701 | for (Int_t iDet = 1; iDet >= 0; iDet--) { | |
1702 | if (!fTracker[iDet]) continue; | |
1703 | AliDebug(1, Form("%s tracking", fgkDetectorName[iDet])); | |
24f7a148 | 1704 | |
b8cd5251 | 1705 | // load clusters |
1706 | fLoader[iDet]->LoadRecPoints("read"); | |
6efecea1 | 1707 | AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr); |
b8cd5251 | 1708 | TTree* tree = fLoader[iDet]->TreeR(); |
1709 | if (!tree) { | |
1710 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); | |
24f7a148 | 1711 | return kFALSE; |
1712 | } | |
b8cd5251 | 1713 | fTracker[iDet]->LoadClusters(tree); |
6efecea1 | 1714 | AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr); |
b8cd5251 | 1715 | // run tracking |
1716 | if (fTracker[iDet]->Clusters2Tracks(esd) != 0) { | |
1717 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
24f7a148 | 1718 | return kFALSE; |
1719 | } | |
b8cd5251 | 1720 | if (fCheckPointLevel > 1) { |
1721 | WriteESD(esd, Form("%s.tracking", fgkDetectorName[iDet])); | |
1722 | } | |
878e1fe1 | 1723 | // preliminary PID in TPC needed by the ITS tracker |
1724 | if (iDet == 1) { | |
b26c3770 | 1725 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); |
878e1fe1 | 1726 | AliESDpid::MakePID(esd); |
0f88822a | 1727 | } |
6efecea1 | 1728 | AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr); |
b8cd5251 | 1729 | } |
596a855f | 1730 | |
b8cd5251 | 1731 | // pass 2: ALL backwards |
aa3c69a9 | 1732 | |
b8cd5251 | 1733 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1734 | if (!fTracker[iDet]) continue; | |
1735 | AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet])); | |
1736 | ||
1737 | // load clusters | |
1738 | if (iDet > 1) { // all except ITS, TPC | |
1739 | TTree* tree = NULL; | |
7b61cd9c | 1740 | fLoader[iDet]->LoadRecPoints("read"); |
6efecea1 | 1741 | AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr); |
7b61cd9c | 1742 | tree = fLoader[iDet]->TreeR(); |
b8cd5251 | 1743 | if (!tree) { |
1744 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); | |
24f7a148 | 1745 | return kFALSE; |
1746 | } | |
0f88822a | 1747 | fTracker[iDet]->LoadClusters(tree); |
6efecea1 | 1748 | AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr); |
b8cd5251 | 1749 | } |
24f7a148 | 1750 | |
b8cd5251 | 1751 | // run tracking |
283f39c6 | 1752 | if (iDet>1) // start filling residuals for the "outer" detectors |
1753 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE); | |
1754 | ||
b8cd5251 | 1755 | if (fTracker[iDet]->PropagateBack(esd) != 0) { |
1756 | AliError(Form("%s backward propagation failed", fgkDetectorName[iDet])); | |
49dfd67a | 1757 | // return kFALSE; |
b8cd5251 | 1758 | } |
1759 | if (fCheckPointLevel > 1) { | |
1760 | WriteESD(esd, Form("%s.back", fgkDetectorName[iDet])); | |
1761 | } | |
24f7a148 | 1762 | |
b8cd5251 | 1763 | // unload clusters |
1764 | if (iDet > 2) { // all except ITS, TPC, TRD | |
1765 | fTracker[iDet]->UnloadClusters(); | |
7b61cd9c | 1766 | fLoader[iDet]->UnloadRecPoints(); |
b8cd5251 | 1767 | } |
8f37df88 | 1768 | // updated PID in TPC needed by the ITS tracker -MI |
1769 | if (iDet == 1) { | |
8f37df88 | 1770 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); |
1771 | AliESDpid::MakePID(esd); | |
1772 | } | |
6efecea1 | 1773 | AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr); |
b8cd5251 | 1774 | } |
283f39c6 | 1775 | //stop filling residuals for the "outer" detectors |
1776 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE); | |
596a855f | 1777 | |
98937d93 | 1778 | // write space-points to the ESD in case alignment data output |
1779 | // is switched on | |
1780 | if (fWriteAlignmentData) | |
1781 | WriteAlignmentData(esd); | |
1782 | ||
b8cd5251 | 1783 | // pass 3: TRD + TPC + ITS refit inwards |
aa3c69a9 | 1784 | |
b8cd5251 | 1785 | for (Int_t iDet = 2; iDet >= 0; iDet--) { |
1786 | if (!fTracker[iDet]) continue; | |
1787 | AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet])); | |
596a855f | 1788 | |
b8cd5251 | 1789 | // run tracking |
283f39c6 | 1790 | if (iDet<2) // start filling residuals for TPC and ITS |
1791 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE); | |
1792 | ||
b8cd5251 | 1793 | if (fTracker[iDet]->RefitInward(esd) != 0) { |
1794 | AliError(Form("%s inward refit failed", fgkDetectorName[iDet])); | |
49dfd67a | 1795 | // return kFALSE; |
b8cd5251 | 1796 | } |
db2368d0 | 1797 | // run postprocessing |
1798 | if (fTracker[iDet]->PostProcess(esd) != 0) { | |
1799 | AliError(Form("%s postprocessing failed", fgkDetectorName[iDet])); | |
1800 | // return kFALSE; | |
1801 | } | |
b8cd5251 | 1802 | if (fCheckPointLevel > 1) { |
1803 | WriteESD(esd, Form("%s.refit", fgkDetectorName[iDet])); | |
1804 | } | |
6efecea1 | 1805 | AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr); |
b8cd5251 | 1806 | // unload clusters |
1807 | fTracker[iDet]->UnloadClusters(); | |
6efecea1 | 1808 | AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr); |
b8cd5251 | 1809 | fLoader[iDet]->UnloadRecPoints(); |
6efecea1 | 1810 | AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr); |
b8cd5251 | 1811 | } |
283f39c6 | 1812 | // stop filling residuals for TPC and ITS |
3b378a42 | 1813 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE); |
854c6476 | 1814 | |
0f88822a | 1815 | eventNr++; |
596a855f | 1816 | return kTRUE; |
1817 | } | |
1818 | ||
d64bd07d | 1819 | //_____________________________________________________________________________ |
1820 | Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){ | |
1821 | // | |
1822 | // Remove the data which are not needed for the physics analysis. | |
1823 | // | |
1824 | ||
d64bd07d | 1825 | Int_t nTracks=esd->GetNumberOfTracks(); |
18571674 | 1826 | Int_t nV0s=esd->GetNumberOfV0s(); |
cf37fd88 | 1827 | AliInfo |
1828 | (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s)); | |
d64bd07d | 1829 | |
18571674 | 1830 | Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax}; |
7f68891d | 1831 | Bool_t rc=esd->Clean(cleanPars); |
d64bd07d | 1832 | |
7f68891d | 1833 | nTracks=esd->GetNumberOfTracks(); |
18571674 | 1834 | nV0s=esd->GetNumberOfV0s(); |
cf37fd88 | 1835 | AliInfo |
ae5d5566 | 1836 | (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s)); |
d64bd07d | 1837 | |
7f68891d | 1838 | return rc; |
d64bd07d | 1839 | } |
1840 | ||
596a855f | 1841 | //_____________________________________________________________________________ |
af885e0f | 1842 | Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors) |
596a855f | 1843 | { |
1844 | // fill the event summary data | |
1845 | ||
87932dab | 1846 | AliCodeTimerAuto("") |
0f88822a | 1847 | static Int_t eventNr=0; |
596a855f | 1848 | TString detStr = detectors; |
abe0c04e | 1849 | |
b8cd5251 | 1850 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
abe0c04e | 1851 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; |
b8cd5251 | 1852 | AliReconstructor* reconstructor = GetReconstructor(iDet); |
1853 | if (!reconstructor) continue; | |
b8cd5251 | 1854 | if (!ReadESD(esd, fgkDetectorName[iDet])) { |
1855 | AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet])); | |
b26c3770 | 1856 | TTree* clustersTree = NULL; |
d76c31f4 | 1857 | if (fLoader[iDet]) { |
b26c3770 | 1858 | fLoader[iDet]->LoadRecPoints("read"); |
1859 | clustersTree = fLoader[iDet]->TreeR(); | |
1860 | if (!clustersTree) { | |
1861 | AliError(Form("Can't get the %s clusters tree", | |
1862 | fgkDetectorName[iDet])); | |
1863 | if (fStopOnError) return kFALSE; | |
1864 | } | |
1865 | } | |
1866 | if (fRawReader && !reconstructor->HasDigitConversion()) { | |
1867 | reconstructor->FillESD(fRawReader, clustersTree, esd); | |
1868 | } else { | |
1869 | TTree* digitsTree = NULL; | |
1870 | if (fLoader[iDet]) { | |
1871 | fLoader[iDet]->LoadDigits("read"); | |
1872 | digitsTree = fLoader[iDet]->TreeD(); | |
1873 | if (!digitsTree) { | |
1874 | AliError(Form("Can't get the %s digits tree", | |
1875 | fgkDetectorName[iDet])); | |
1876 | if (fStopOnError) return kFALSE; | |
1877 | } | |
1878 | } | |
1879 | reconstructor->FillESD(digitsTree, clustersTree, esd); | |
1880 | if (fLoader[iDet]) fLoader[iDet]->UnloadDigits(); | |
1881 | } | |
d76c31f4 | 1882 | if (fLoader[iDet]) { |
b26c3770 | 1883 | fLoader[iDet]->UnloadRecPoints(); |
1884 | } | |
1885 | ||
b8cd5251 | 1886 | if (fCheckPointLevel > 2) WriteESD(esd, fgkDetectorName[iDet]); |
596a855f | 1887 | } |
1888 | } | |
1889 | ||
1890 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
815c2b38 | 1891 | AliError(Form("the following detectors were not found: %s", |
1892 | detStr.Data())); | |
596a855f | 1893 | if (fStopOnError) return kFALSE; |
1894 | } | |
6efecea1 | 1895 | AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr); |
0f88822a | 1896 | eventNr++; |
596a855f | 1897 | return kTRUE; |
1898 | } | |
1899 | ||
b647652d | 1900 | //_____________________________________________________________________________ |
af885e0f | 1901 | Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd) |
b647652d | 1902 | { |
1903 | // Reads the trigger decision which is | |
1904 | // stored in Trigger.root file and fills | |
1905 | // the corresponding esd entries | |
1906 | ||
87932dab | 1907 | AliCodeTimerAuto("") |
1908 | ||
b647652d | 1909 | AliInfo("Filling trigger information into the ESD"); |
1910 | ||
b024fd7f | 1911 | AliCentralTrigger *aCTP = NULL; |
1912 | ||
b647652d | 1913 | if (fRawReader) { |
1914 | AliCTPRawStream input(fRawReader); | |
1915 | if (!input.Next()) { | |
1916 | AliError("No valid CTP (trigger) DDL raw data is found ! The trigger information is not stored in the ESD !"); | |
1917 | return kFALSE; | |
1918 | } | |
1919 | esd->SetTriggerMask(input.GetClassMask()); | |
1920 | esd->SetTriggerCluster(input.GetClusterMask()); | |
b024fd7f | 1921 | |
1922 | aCTP = new AliCentralTrigger(); | |
1923 | TString configstr(""); | |
1924 | if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB | |
1925 | AliError("No trigger configuration found in OCDB! The trigger classes information will no be stored in ESD!"); | |
259e35c9 | 1926 | delete aCTP; |
b024fd7f | 1927 | return kFALSE; |
1928 | } | |
b647652d | 1929 | } |
1930 | else { | |
1931 | AliRunLoader *runloader = AliRunLoader::GetRunLoader(); | |
1932 | if (runloader) { | |
1933 | if (!runloader->LoadTrigger()) { | |
1ea86aa2 | 1934 | aCTP = runloader->GetTrigger(); |
b647652d | 1935 | esd->SetTriggerMask(aCTP->GetClassMask()); |
1936 | esd->SetTriggerCluster(aCTP->GetClusterMask()); | |
1937 | } | |
1938 | else { | |
1939 | AliWarning("No trigger can be loaded! The trigger information is not stored in the ESD !"); | |
1940 | return kFALSE; | |
1941 | } | |
1942 | } | |
1943 | else { | |
1944 | AliError("No run loader is available! The trigger information is not stored in the ESD !"); | |
1945 | return kFALSE; | |
1946 | } | |
1947 | } | |
1948 | ||
b024fd7f | 1949 | // Now fill the trigger class names into AliESDRun object |
1950 | AliTriggerConfiguration *config = aCTP->GetConfiguration(); | |
1951 | if (!config) { | |
1952 | AliError("No trigger configuration has been found! The trigger classes information will no be stored in ESD!"); | |
d74294be | 1953 | if (fRawReader) delete aCTP; |
b024fd7f | 1954 | return kFALSE; |
1955 | } | |
1956 | ||
1957 | const TObjArray& classesArray = config->GetClasses(); | |
1958 | Int_t nclasses = classesArray.GetEntriesFast(); | |
1959 | for( Int_t j=0; j<nclasses; j++ ) { | |
1960 | AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At( j ); | |
1961 | Int_t trindex = (Int_t)TMath::Log2(trclass->GetMask()); | |
1962 | esd->SetTriggerClass(trclass->GetName(),trindex); | |
1963 | } | |
1964 | ||
d74294be | 1965 | if (fRawReader) delete aCTP; |
b647652d | 1966 | return kTRUE; |
1967 | } | |
596a855f | 1968 | |
001397cd | 1969 | |
1970 | ||
1971 | ||
1972 | ||
1973 | //_____________________________________________________________________________ | |
af885e0f | 1974 | Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd) |
001397cd | 1975 | { |
1976 | // | |
1977 | // Filling information from RawReader Header | |
1978 | // | |
1979 | ||
1980 | AliInfo("Filling information from RawReader Header"); | |
31fd97b2 | 1981 | esd->SetBunchCrossNumber(0); |
1982 | esd->SetOrbitNumber(0); | |
9bcc1e45 | 1983 | esd->SetPeriodNumber(0); |
001397cd | 1984 | esd->SetTimeStamp(0); |
1985 | esd->SetEventType(0); | |
1986 | const AliRawEventHeaderBase * eventHeader = fRawReader->GetEventHeader(); | |
1987 | if (eventHeader){ | |
9bcc1e45 | 1988 | |
1989 | const UInt_t *id = eventHeader->GetP("Id"); | |
1990 | esd->SetBunchCrossNumber((id)[1]&0x00000fff); | |
1991 | esd->SetOrbitNumber((((id)[0]<<20)&0xf00000)|(((id)[1]>>12)&0xfffff)); | |
1992 | esd->SetPeriodNumber(((id)[0]>>4)&0x0fffffff); | |
1993 | ||
001397cd | 1994 | esd->SetTimeStamp((eventHeader->Get("Timestamp"))); |
31fd97b2 | 1995 | esd->SetEventType((eventHeader->Get("Type"))); |
001397cd | 1996 | } |
1997 | ||
1998 | return kTRUE; | |
1999 | } | |
2000 | ||
2001 | ||
596a855f | 2002 | //_____________________________________________________________________________ |
2003 | Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const | |
2004 | { | |
2005 | // check whether detName is contained in detectors | |
2006 | // if yes, it is removed from detectors | |
2007 | ||
2008 | // check if all detectors are selected | |
2009 | if ((detectors.CompareTo("ALL") == 0) || | |
2010 | detectors.BeginsWith("ALL ") || | |
2011 | detectors.EndsWith(" ALL") || | |
2012 | detectors.Contains(" ALL ")) { | |
2013 | detectors = "ALL"; | |
2014 | return kTRUE; | |
2015 | } | |
2016 | ||
2017 | // search for the given detector | |
2018 | Bool_t result = kFALSE; | |
2019 | if ((detectors.CompareTo(detName) == 0) || | |
2020 | detectors.BeginsWith(detName+" ") || | |
2021 | detectors.EndsWith(" "+detName) || | |
2022 | detectors.Contains(" "+detName+" ")) { | |
2023 | detectors.ReplaceAll(detName, ""); | |
2024 | result = kTRUE; | |
2025 | } | |
2026 | ||
2027 | // clean up the detectors string | |
2028 | while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " "); | |
2029 | while (detectors.BeginsWith(" ")) detectors.Remove(0, 1); | |
2030 | while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1); | |
2031 | ||
2032 | return result; | |
2033 | } | |
e583c30d | 2034 | |
f08fc9f5 | 2035 | //_____________________________________________________________________________ |
2036 | Bool_t AliReconstruction::InitRunLoader() | |
2037 | { | |
2038 | // get or create the run loader | |
2039 | ||
2040 | if (gAlice) delete gAlice; | |
2041 | gAlice = NULL; | |
2042 | ||
b26c3770 | 2043 | if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists |
2044 | // load all base libraries to get the loader classes | |
2045 | TString libs = gSystem->GetLibraries(); | |
2046 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
2047 | TString detName = fgkDetectorName[iDet]; | |
2048 | if (detName == "HLT") continue; | |
2049 | if (libs.Contains("lib" + detName + "base.so")) continue; | |
2050 | gSystem->Load("lib" + detName + "base.so"); | |
2051 | } | |
f08fc9f5 | 2052 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); |
2053 | if (!fRunLoader) { | |
2054 | AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); | |
2055 | CleanUp(); | |
2056 | return kFALSE; | |
2057 | } | |
325aa76f | 2058 | |
b26c3770 | 2059 | fRunLoader->CdGAFile(); |
325aa76f | 2060 | fRunLoader->LoadgAlice(); |
f08fc9f5 | 2061 | |
6cae184e | 2062 | //PH This is a temporary fix to give access to the kinematics |
2063 | //PH that is needed for the labels of ITS clusters | |
f2ee4290 | 2064 | fRunLoader->LoadHeader(); |
6cae184e | 2065 | fRunLoader->LoadKinematics(); |
2066 | ||
f08fc9f5 | 2067 | } else { // galice.root does not exist |
2068 | if (!fRawReader) { | |
2069 | AliError(Form("the file %s does not exist", fGAliceFileName.Data())); | |
2070 | CleanUp(); | |
2071 | return kFALSE; | |
2072 | } | |
2073 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(), | |
2074 | AliConfig::GetDefaultEventFolderName(), | |
2075 | "recreate"); | |
2076 | if (!fRunLoader) { | |
2077 | AliError(Form("could not create run loader in file %s", | |
2078 | fGAliceFileName.Data())); | |
2079 | CleanUp(); | |
2080 | return kFALSE; | |
2081 | } | |
21a3aa09 | 2082 | fIsNewRunLoader = kTRUE; |
f08fc9f5 | 2083 | fRunLoader->MakeTree("E"); |
21a3aa09 | 2084 | |
973388c2 | 2085 | if (fNumberOfEventsPerFile > 0) |
2086 | fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile); | |
2087 | else | |
21a3aa09 | 2088 | fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1); |
f08fc9f5 | 2089 | } |
2090 | ||
2091 | return kTRUE; | |
2092 | } | |
2093 | ||
c757bafd | 2094 | //_____________________________________________________________________________ |
b8cd5251 | 2095 | AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet) |
c757bafd | 2096 | { |
f08fc9f5 | 2097 | // get the reconstructor object and the loader for a detector |
c757bafd | 2098 | |
b8cd5251 | 2099 | if (fReconstructor[iDet]) return fReconstructor[iDet]; |
2100 | ||
2101 | // load the reconstructor object | |
2102 | TPluginManager* pluginManager = gROOT->GetPluginManager(); | |
2103 | TString detName = fgkDetectorName[iDet]; | |
2104 | TString recName = "Ali" + detName + "Reconstructor"; | |
f0999a9a | 2105 | |
2106 | if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL; | |
b8cd5251 | 2107 | |
b8cd5251 | 2108 | AliReconstructor* reconstructor = NULL; |
2109 | // first check if a plugin is defined for the reconstructor | |
2110 | TPluginHandler* pluginHandler = | |
2111 | pluginManager->FindHandler("AliReconstructor", detName); | |
f08fc9f5 | 2112 | // if not, add a plugin for it |
2113 | if (!pluginHandler) { | |
b8cd5251 | 2114 | AliDebug(1, Form("defining plugin for %s", recName.Data())); |
b26c3770 | 2115 | TString libs = gSystem->GetLibraries(); |
2116 | if (libs.Contains("lib" + detName + "base.so") || | |
2117 | (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
b8cd5251 | 2118 | pluginManager->AddHandler("AliReconstructor", detName, |
2119 | recName, detName + "rec", recName + "()"); | |
2120 | } else { | |
2121 | pluginManager->AddHandler("AliReconstructor", detName, | |
2122 | recName, detName, recName + "()"); | |
c757bafd | 2123 | } |
b8cd5251 | 2124 | pluginHandler = pluginManager->FindHandler("AliReconstructor", detName); |
2125 | } | |
2126 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
2127 | reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0); | |
c757bafd | 2128 | } |
b8cd5251 | 2129 | if (reconstructor) { |
2130 | TObject* obj = fOptions.FindObject(detName.Data()); | |
2131 | if (obj) reconstructor->SetOption(obj->GetTitle()); | |
d76c31f4 | 2132 | reconstructor->Init(); |
b8cd5251 | 2133 | fReconstructor[iDet] = reconstructor; |
2134 | } | |
2135 | ||
f08fc9f5 | 2136 | // get or create the loader |
2137 | if (detName != "HLT") { | |
2138 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); | |
2139 | if (!fLoader[iDet]) { | |
2140 | AliConfig::Instance() | |
2141 | ->CreateDetectorFolders(fRunLoader->GetEventFolder(), | |
2142 | detName, detName); | |
2143 | // first check if a plugin is defined for the loader | |
bb0901a4 | 2144 | pluginHandler = |
f08fc9f5 | 2145 | pluginManager->FindHandler("AliLoader", detName); |
2146 | // if not, add a plugin for it | |
2147 | if (!pluginHandler) { | |
2148 | TString loaderName = "Ali" + detName + "Loader"; | |
2149 | AliDebug(1, Form("defining plugin for %s", loaderName.Data())); | |
2150 | pluginManager->AddHandler("AliLoader", detName, | |
2151 | loaderName, detName + "base", | |
2152 | loaderName + "(const char*, TFolder*)"); | |
2153 | pluginHandler = pluginManager->FindHandler("AliLoader", detName); | |
2154 | } | |
2155 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
2156 | fLoader[iDet] = | |
2157 | (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(), | |
2158 | fRunLoader->GetEventFolder()); | |
2159 | } | |
2160 | if (!fLoader[iDet]) { // use default loader | |
2161 | fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder()); | |
2162 | } | |
2163 | if (!fLoader[iDet]) { | |
2164 | AliWarning(Form("couldn't get loader for %s", detName.Data())); | |
6667b602 | 2165 | if (fStopOnError) return NULL; |
f08fc9f5 | 2166 | } else { |
2167 | fRunLoader->AddLoader(fLoader[iDet]); | |
2168 | fRunLoader->CdGAFile(); | |
2169 | if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE"); | |
2170 | fRunLoader->Write(0, TObject::kOverwrite); | |
2171 | } | |
2172 | } | |
2173 | } | |
2174 | ||
b8cd5251 | 2175 | return reconstructor; |
c757bafd | 2176 | } |
2177 | ||
2257f27e | 2178 | //_____________________________________________________________________________ |
2179 | Bool_t AliReconstruction::CreateVertexer() | |
2180 | { | |
2181 | // create the vertexer | |
2182 | ||
b8cd5251 | 2183 | fVertexer = NULL; |
2184 | AliReconstructor* itsReconstructor = GetReconstructor(0); | |
59697224 | 2185 | if (itsReconstructor) { |
d76c31f4 | 2186 | fVertexer = itsReconstructor->CreateVertexer(); |
2257f27e | 2187 | } |
b8cd5251 | 2188 | if (!fVertexer) { |
815c2b38 | 2189 | AliWarning("couldn't create a vertexer for ITS"); |
2257f27e | 2190 | if (fStopOnError) return kFALSE; |
2191 | } | |
2192 | ||
2193 | return kTRUE; | |
2194 | } | |
2195 | ||
24f7a148 | 2196 | //_____________________________________________________________________________ |
b8cd5251 | 2197 | Bool_t AliReconstruction::CreateTrackers(const TString& detectors) |
24f7a148 | 2198 | { |
f08fc9f5 | 2199 | // create the trackers |
24f7a148 | 2200 | |
b8cd5251 | 2201 | TString detStr = detectors; |
2202 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
2203 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
2204 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
2205 | if (!reconstructor) continue; | |
2206 | TString detName = fgkDetectorName[iDet]; | |
1f46a9ae | 2207 | if (detName == "HLT") { |
2208 | fRunHLTTracking = kTRUE; | |
2209 | continue; | |
2210 | } | |
e66fbafb | 2211 | if (detName == "MUON") { |
2212 | fRunMuonTracking = kTRUE; | |
2213 | continue; | |
2214 | } | |
2215 | ||
f08fc9f5 | 2216 | |
d76c31f4 | 2217 | fTracker[iDet] = reconstructor->CreateTracker(); |
f08fc9f5 | 2218 | if (!fTracker[iDet] && (iDet < 7)) { |
2219 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); | |
8250d5f5 | 2220 | if (fStopOnError) return kFALSE; |
2221 | } | |
6efecea1 | 2222 | AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0); |
8250d5f5 | 2223 | } |
2224 | ||
24f7a148 | 2225 | return kTRUE; |
2226 | } | |
2227 | ||
e583c30d | 2228 | //_____________________________________________________________________________ |
b26c3770 | 2229 | void AliReconstruction::CleanUp(TFile* file, TFile* fileOld) |
e583c30d | 2230 | { |
2231 | // delete trackers and the run loader and close and delete the file | |
2232 | ||
b8cd5251 | 2233 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
2234 | delete fReconstructor[iDet]; | |
2235 | fReconstructor[iDet] = NULL; | |
2236 | fLoader[iDet] = NULL; | |
2237 | delete fTracker[iDet]; | |
2238 | fTracker[iDet] = NULL; | |
c65c502a | 2239 | // delete fQADataMaker[iDet]; |
2240 | // fQADataMaker[iDet] = NULL; | |
b8cd5251 | 2241 | } |
2242 | delete fVertexer; | |
2243 | fVertexer = NULL; | |
21a3aa09 | 2244 | |
2245 | if (ftVertexer) delete ftVertexer; | |
2246 | ftVertexer = NULL; | |
795e4a22 | 2247 | |
2248 | if(!(AliCDBManager::Instance()->GetCacheFlag())) { | |
2249 | delete fDiamondProfile; | |
2250 | fDiamondProfile = NULL; | |
43c9dae1 | 2251 | delete fDiamondProfileTPC; |
2252 | fDiamondProfileTPC = NULL; | |
6b6e4472 | 2253 | delete fGRPData; |
2254 | fGRPData = NULL; | |
795e4a22 | 2255 | } |
e583c30d | 2256 | |
444753c6 | 2257 | |
e583c30d | 2258 | delete fRunLoader; |
2259 | fRunLoader = NULL; | |
b649205a | 2260 | delete fRawReader; |
2261 | fRawReader = NULL; | |
cd0b062e | 2262 | if (fParentRawReader) delete fParentRawReader; |
2263 | fParentRawReader=NULL; | |
e583c30d | 2264 | |
2265 | if (file) { | |
2266 | file->Close(); | |
2267 | delete file; | |
2268 | } | |
b26c3770 | 2269 | |
2270 | if (fileOld) { | |
2271 | fileOld->Close(); | |
2272 | delete fileOld; | |
2273 | gSystem->Unlink("AliESDs.old.root"); | |
2274 | } | |
21a3aa09 | 2275 | |
e583c30d | 2276 | } |
24f7a148 | 2277 | |
24f7a148 | 2278 | //_____________________________________________________________________________ |
af885e0f | 2279 | |
2280 | Bool_t AliReconstruction::ReadESD(AliESDEvent*& esd, const char* recStep) const | |
24f7a148 | 2281 | { |
2282 | // read the ESD event from a file | |
2283 | ||
2284 | if (!esd) return kFALSE; | |
2285 | char fileName[256]; | |
2286 | sprintf(fileName, "ESD_%d.%d_%s.root", | |
31fd97b2 | 2287 | esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep); |
24f7a148 | 2288 | if (gSystem->AccessPathName(fileName)) return kFALSE; |
2289 | ||
f3a97c86 | 2290 | AliInfo(Form("reading ESD from file %s", fileName)); |
815c2b38 | 2291 | AliDebug(1, Form("reading ESD from file %s", fileName)); |
24f7a148 | 2292 | TFile* file = TFile::Open(fileName); |
2293 | if (!file || !file->IsOpen()) { | |
815c2b38 | 2294 | AliError(Form("opening %s failed", fileName)); |
24f7a148 | 2295 | delete file; |
2296 | return kFALSE; | |
2297 | } | |
2298 | ||
2299 | gROOT->cd(); | |
2300 | delete esd; | |
af885e0f | 2301 | esd = (AliESDEvent*) file->Get("ESD"); |
24f7a148 | 2302 | file->Close(); |
2303 | delete file; | |
2304 | return kTRUE; | |
af885e0f | 2305 | |
24f7a148 | 2306 | } |
2307 | ||
af885e0f | 2308 | |
2309 | ||
24f7a148 | 2310 | //_____________________________________________________________________________ |
af885e0f | 2311 | void AliReconstruction::WriteESD(AliESDEvent* esd, const char* recStep) const |
24f7a148 | 2312 | { |
2313 | // write the ESD event to a file | |
2314 | ||
2315 | if (!esd) return; | |
2316 | char fileName[256]; | |
2317 | sprintf(fileName, "ESD_%d.%d_%s.root", | |
31fd97b2 | 2318 | esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep); |
24f7a148 | 2319 | |
815c2b38 | 2320 | AliDebug(1, Form("writing ESD to file %s", fileName)); |
24f7a148 | 2321 | TFile* file = TFile::Open(fileName, "recreate"); |
2322 | if (!file || !file->IsOpen()) { | |
815c2b38 | 2323 | AliError(Form("opening %s failed", fileName)); |
24f7a148 | 2324 | } else { |
2325 | esd->Write("ESD"); | |
2326 | file->Close(); | |
2327 | } | |
2328 | delete file; | |
2329 | } | |
f3a97c86 | 2330 | |
2331 | ||
af885e0f | 2332 | void AliReconstruction::WriteAlignmentData(AliESDEvent* esd) |
98937d93 | 2333 | { |
2334 | // Write space-points which are then used in the alignment procedures | |
2335 | // For the moment only ITS, TRD and TPC | |
2336 | ||
2337 | // Load TOF clusters | |
d528ee75 | 2338 | if (fTracker[3]){ |
2339 | fLoader[3]->LoadRecPoints("read"); | |
2340 | TTree* tree = fLoader[3]->TreeR(); | |
2341 | if (!tree) { | |
2342 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[3])); | |
2343 | return; | |
2344 | } | |
2345 | fTracker[3]->LoadClusters(tree); | |
98937d93 | 2346 | } |
98937d93 | 2347 | Int_t ntracks = esd->GetNumberOfTracks(); |
2348 | for (Int_t itrack = 0; itrack < ntracks; itrack++) | |
2349 | { | |
2350 | AliESDtrack *track = esd->GetTrack(itrack); | |
2351 | Int_t nsp = 0; | |
ef7253ac | 2352 | Int_t idx[200]; |
98937d93 | 2353 | for (Int_t iDet = 3; iDet >= 0; iDet--) |
2354 | nsp += track->GetNcls(iDet); | |
2355 | if (nsp) { | |
2356 | AliTrackPointArray *sp = new AliTrackPointArray(nsp); | |
2357 | track->SetTrackPointArray(sp); | |
2358 | Int_t isptrack = 0; | |
2359 | for (Int_t iDet = 3; iDet >= 0; iDet--) { | |
2360 | AliTracker *tracker = fTracker[iDet]; | |
2361 | if (!tracker) continue; | |
2362 | Int_t nspdet = track->GetNcls(iDet); | |
98937d93 | 2363 | if (nspdet <= 0) continue; |
2364 | track->GetClusters(iDet,idx); | |
2365 | AliTrackPoint p; | |
2366 | Int_t isp = 0; | |
2367 | Int_t isp2 = 0; | |
4ed6fb1c | 2368 | while (isp2 < nspdet) { |
48ce48d1 | 2369 | Bool_t isvalid; |
c12b6e44 | 2370 | TString dets = fgkDetectorName[iDet]; |
2371 | if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) || | |
2372 | fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") || | |
2373 | fUseTrackingErrorsForAlignment.EndsWith(" "+dets) || | |
2374 | fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) { | |
2375 | isvalid = tracker->GetTrackPointTrackingError(idx[isp2],p,track); | |
48ce48d1 | 2376 | } else { |
2377 | isvalid = tracker->GetTrackPoint(idx[isp2],p); | |
2378 | } | |
2379 | isp2++; | |
160db090 | 2380 | const Int_t kNTPCmax = 159; |
2381 | if (iDet==1 && isp2>kNTPCmax) break; // to be fixed | |
98937d93 | 2382 | if (!isvalid) continue; |
2383 | sp->AddPoint(isptrack,&p); isptrack++; isp++; | |
2384 | } | |
98937d93 | 2385 | } |
2386 | } | |
2387 | } | |
d528ee75 | 2388 | if (fTracker[3]){ |
2389 | fTracker[3]->UnloadClusters(); | |
2390 | fLoader[3]->UnloadRecPoints(); | |
2391 | } | |
98937d93 | 2392 | } |
2e3550da | 2393 | |
2394 | //_____________________________________________________________________________ | |
af885e0f | 2395 | void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd) |
2e3550da | 2396 | { |
2397 | // The method reads the raw-data error log | |
2398 | // accumulated within the rawReader. | |
2399 | // It extracts the raw-data errors related to | |
2400 | // the current event and stores them into | |
2401 | // a TClonesArray inside the esd object. | |
2402 | ||
2403 | if (!fRawReader) return; | |
2404 | ||
2405 | for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) { | |
2406 | ||
2407 | AliRawDataErrorLog *log = fRawReader->GetErrorLog(i); | |
2408 | if (!log) continue; | |
2409 | if (iEvent != log->GetEventNumber()) continue; | |
2410 | ||
2411 | esd->AddRawDataErrorLog(log); | |
2412 | } | |
2413 | ||
2414 | } | |
46698ae4 | 2415 | |
605cb8bb | 2416 | TNamed* AliReconstruction::CopyFileToTNamed(TString fPath,TString pName){ |
b545009a | 2417 | // Dump a file content into a char in TNamed |
46698ae4 | 2418 | ifstream in; |
2419 | in.open(fPath.Data(),ios::in | ios::binary|ios::ate); | |
2420 | Int_t kBytes = (Int_t)in.tellg(); | |
2421 | printf("Size: %d \n",kBytes); | |
2422 | TNamed *fn = 0; | |
2423 | if(in.good()){ | |
2424 | char* memblock = new char [kBytes]; | |
2425 | in.seekg (0, ios::beg); | |
2426 | in.read (memblock, kBytes); | |
2427 | in.close(); | |
2428 | TString fData(memblock,kBytes); | |
605cb8bb | 2429 | fn = new TNamed(pName,fData); |
46698ae4 | 2430 | printf("fData Size: %d \n",fData.Sizeof()); |
605cb8bb | 2431 | printf("pName Size: %d \n",pName.Sizeof()); |
46698ae4 | 2432 | printf("fn Size: %d \n",fn->Sizeof()); |
2433 | delete[] memblock; | |
2434 | } | |
2435 | else{ | |
2436 | AliInfo(Form("Could not Open %s\n",fPath.Data())); | |
2437 | } | |
2438 | ||
2439 | return fn; | |
2440 | } | |
2441 | ||
605cb8bb | 2442 | void AliReconstruction::TNamedToFile(TTree* fTree, TString pName){ |
46698ae4 | 2443 | // This is not really needed in AliReconstruction at the moment |
2444 | // but can serve as a template | |
2445 | ||
2446 | TList *fList = fTree->GetUserInfo(); | |
605cb8bb | 2447 | TNamed *fn = (TNamed*)fList->FindObject(pName.Data()); |
46698ae4 | 2448 | printf("fn Size: %d \n",fn->Sizeof()); |
2449 | ||
605cb8bb | 2450 | TString fTmp(fn->GetName()); // to be 100% sure in principle pName also works |
46698ae4 | 2451 | const char* cdata = fn->GetTitle(); |
2452 | printf("fTmp Size %d\n",fTmp.Sizeof()); | |
2453 | ||
2454 | int size = fn->Sizeof()-fTmp.Sizeof()-sizeof(UChar_t)-sizeof(Int_t); // see dfinition of TString::SizeOf()... | |
2455 | printf("calculated size %d\n",size); | |
605cb8bb | 2456 | ofstream out(pName.Data(),ios::out | ios::binary); |
46698ae4 | 2457 | out.write(cdata,size); |
2458 | out.close(); | |
2459 | ||
2460 | } | |
6efecea1 | 2461 | |
7e963665 | 2462 | //_____________________________________________________________________________ |
04236e67 | 2463 | AliQADataMakerRec * AliReconstruction::GetQADataMaker(Int_t iDet) |
7e963665 | 2464 | { |
2465 | // get the quality assurance data maker object and the loader for a detector | |
6efecea1 | 2466 | |
7e963665 | 2467 | if (fQADataMaker[iDet]) |
2468 | return fQADataMaker[iDet]; | |
2469 | ||
04236e67 | 2470 | AliQADataMakerRec * qadm = NULL; |
2471 | if (iDet == fgkNDetectors) { //Global QA | |
2472 | qadm = new AliGlobalQADataMaker(); | |
aa3c69a9 | 2473 | fQADataMaker[iDet] = qadm; |
2474 | return qadm; | |
2475 | } | |
2476 | ||
7e963665 | 2477 | // load the QA data maker object |
2478 | TPluginManager* pluginManager = gROOT->GetPluginManager(); | |
2479 | TString detName = fgkDetectorName[iDet]; | |
04236e67 | 2480 | TString qadmName = "Ali" + detName + "QADataMakerRec"; |
f0999a9a | 2481 | if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) |
7e963665 | 2482 | return NULL; |
2483 | ||
7e963665 | 2484 | // first check if a plugin is defined for the quality assurance data maker |
04236e67 | 2485 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMakerRec", detName); |
7e963665 | 2486 | // if not, add a plugin for it |
2487 | if (!pluginHandler) { | |
2488 | AliDebug(1, Form("defining plugin for %s", qadmName.Data())); | |
2489 | TString libs = gSystem->GetLibraries(); | |
2490 | if (libs.Contains("lib" + detName + "base.so") || | |
2491 | (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
04236e67 | 2492 | pluginManager->AddHandler("AliQADataMakerRec", detName, |
7e963665 | 2493 | qadmName, detName + "qadm", qadmName + "()"); |
2494 | } else { | |
04236e67 | 2495 | pluginManager->AddHandler("AliQADataMakerRec", detName, |
7e963665 | 2496 | qadmName, detName, qadmName + "()"); |
2497 | } | |
04236e67 | 2498 | pluginHandler = pluginManager->FindHandler("AliQADataMakerRec", detName); |
7e963665 | 2499 | } |
2500 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
04236e67 | 2501 | qadm = (AliQADataMakerRec *) pluginHandler->ExecPlugin(0); |
7e963665 | 2502 | } |
aa3c69a9 | 2503 | |
2504 | fQADataMaker[iDet] = qadm; | |
7e963665 | 2505 | |
2506 | return qadm; | |
2507 | } | |
46698ae4 | 2508 | |
a5fa6165 | 2509 | //_____________________________________________________________________________ |
7e963665 | 2510 | Bool_t AliReconstruction::RunQA(const char* detectors, AliESDEvent *& esd) |
2511 | { | |
2512 | // run the Quality Assurance data producer | |
2513 | ||
2514 | AliCodeTimerAuto("") | |
2515 | TString detStr = detectors; | |
2516 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
2517 | if (!IsSelected(fgkDetectorName[iDet], detStr)) | |
2518 | continue; | |
04236e67 | 2519 | AliQADataMakerRec * qadm = GetQADataMaker(iDet); |
7e963665 | 2520 | if (!qadm) |
2521 | continue; | |
2522 | AliCodeTimerStart(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); | |
2523 | AliInfo(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); | |
2524 | ||
2525 | qadm->Exec(AliQA::kESDS, esd) ; | |
2526 | qadm->Increment() ; | |
2527 | ||
2528 | AliCodeTimerStop(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); | |
2529 | } | |
2530 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
2531 | AliError(Form("the following detectors were not found: %s", | |
2532 | detStr.Data())); | |
2533 | if (fStopOnError) | |
2534 | return kFALSE; | |
2535 | } | |
2536 | ||
2537 | return kTRUE; | |
2538 | ||
2539 | } | |
8661738e | 2540 | |
2541 | //_____________________________________________________________________________ | |
2542 | void AliReconstruction::CheckQA() | |
2543 | { | |
2544 | // check the QA of SIM for this run and remove the detectors | |
2545 | // with status Fatal | |
2546 | ||
abe0c04e | 2547 | TString newRunLocalReconstruction ; |
2548 | TString newRunTracking ; | |
2549 | TString newFillESD ; | |
2550 | ||
8661738e | 2551 | for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) { |
2552 | TString detName(AliQA::GetDetName(iDet)) ; | |
96d67a8d | 2553 | AliQA * qa = AliQA::Instance(AliQA::DETECTORINDEX_t(iDet)) ; |
2554 | if ( qa->IsSet(AliQA::DETECTORINDEX_t(iDet), AliQA::kSIM, AliQA::kFATAL)) { | |
8661738e | 2555 | AliInfo(Form("QA status for %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed", detName.Data())) ; |
abe0c04e | 2556 | } else { |
2557 | if ( fRunLocalReconstruction.Contains(AliQA::GetDetName(iDet)) || | |
2558 | fRunLocalReconstruction.Contains("ALL") ) { | |
2559 | newRunLocalReconstruction += detName ; | |
2560 | newRunLocalReconstruction += " " ; | |
2561 | } | |
2562 | if ( fRunTracking.Contains(AliQA::GetDetName(iDet)) || | |
2563 | fRunTracking.Contains("ALL") ) { | |
2564 | newRunTracking += detName ; | |
2565 | newRunTracking += " " ; | |
2566 | } | |
2567 | if ( fFillESD.Contains(AliQA::GetDetName(iDet)) || | |
2568 | fFillESD.Contains("ALL") ) { | |
2569 | newFillESD += detName ; | |
2570 | newFillESD += " " ; | |
8661738e | 2571 | } |
2572 | } | |
2573 | } | |
abe0c04e | 2574 | fRunLocalReconstruction = newRunLocalReconstruction ; |
2575 | fRunTracking = newRunTracking ; | |
2576 | fFillESD = newFillESD ; | |
a5fa6165 | 2577 | } |
5b188f2f | 2578 | |
2579 | //_____________________________________________________________________________ | |
2580 | Int_t AliReconstruction::GetDetIndex(const char* detector) | |
2581 | { | |
2582 | // return the detector index corresponding to detector | |
2583 | Int_t index = -1 ; | |
2584 | for (index = 0; index < fgkNDetectors ; index++) { | |
2585 | if ( strcmp(detector, fgkDetectorName[index]) == 0 ) | |
2586 | break ; | |
2587 | } | |
2588 | return index ; | |
2589 | } | |
7167ae53 | 2590 | //_____________________________________________________________________________ |
2591 | Bool_t AliReconstruction::FinishPlaneEff() { | |
2592 | // | |
2593 | // Here execute all the necessary operationis, at the end of the tracking phase, | |
2594 | // in case that evaluation of PlaneEfficiencies was required for some detector. | |
2595 | // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated. | |
2596 | // | |
2597 | // This Preliminary version works only FOR ITS !!!!! | |
2598 | // other detectors (TOF,TRD, etc. have to develop their specific codes) | |
2599 | // | |
2600 | // Input: none | |
2601 | // Return: kTRUE if all operations have been done properly, kFALSE otherwise | |
2602 | // | |
2603 | Bool_t ret=kFALSE; | |
2604 | //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
2605 | for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS | |
2606 | //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
5fbd4fd6 | 2607 | if(fTracker[iDet]) { |
2608 | AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff(); | |
2609 | ret=planeeff->WriteIntoCDB(); | |
2610 | if(planeeff->GetCreateHistos()) { | |
2611 | TString name="PlaneEffHisto"; | |
2612 | name+=fgkDetectorName[iDet]; | |
2613 | name+=".root"; | |
2614 | ret*=planeeff->WriteHistosToFile(name,"RECREATE"); | |
2615 | } | |
2616 | } | |
7167ae53 | 2617 | } |
2618 | return ret; | |
2619 | } | |
2620 | //_____________________________________________________________________________ | |
2621 | Bool_t AliReconstruction::InitPlaneEff() { | |
2622 | // | |
2623 | // Here execute all the necessary operations, before of the tracking phase, | |
2624 | // for the evaluation of PlaneEfficiencies, in case required for some detectors. | |
2625 | // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency | |
2626 | // which should be updated/recalculated. | |
2627 | // | |
2628 | // This Preliminary version will work only FOR ITS !!!!! | |
2629 | // other detectors (TOF,TRD, etc. have to develop their specific codes) | |
2630 | // | |
2631 | // Input: none | |
2632 | // Return: kTRUE if all operations have been done properly, kFALSE otherwise | |
2633 | // | |
2634 | AliWarning(Form("Implementation of this method not yet done !! Method return kTRUE")); | |
2635 | return kTRUE; | |
7520312d | 2636 | } |
14dd053c | 2637 | |
2638 | //_____________________________________________________________________________ | |
2639 | Bool_t AliReconstruction::InitAliEVE() | |
2640 | { | |
2641 | // This method should be called only in case | |
2642 | // AliReconstruction is run | |
2643 | // within the alieve environment. | |
2644 | // It will initialize AliEVE in a way | |
2645 | // so that it can visualize event processed | |
2646 | // by AliReconstruction. | |
2647 | // The return flag shows whenever the | |
2648 | // AliEVE initialization was successful or not. | |
2649 | ||
2650 | TString macroStr; | |
2651 | macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT")); | |
2652 | AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data())); | |
2653 | if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE; | |
2654 | ||
de33999e | 2655 | gROOT->ProcessLine("if (!gAliEveEvent) {gAliEveEvent = new AliEveEventManager();gAliEveEvent->SetAutoLoad(kTRUE);gAliEveEvent->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(gAliEveEvent);};"); |
2656 | gROOT->ProcessLine("alieve_online_init()"); | |
14dd053c | 2657 | |
2658 | return kTRUE; | |
2659 | } | |
2660 | ||
2661 | //_____________________________________________________________________________ | |
2662 | void AliReconstruction::RunAliEVE() | |
2663 | { | |
2664 | // Runs AliEVE visualisation of | |
2665 | // the current event. | |
2666 | // Should be executed only after | |
2667 | // successful initialization of AliEVE. | |
2668 | ||
2669 | AliInfo("Running AliEVE..."); | |
2670 | gROOT->ProcessLine(Form("gAliEveEvent->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p);",fRunLoader,fRawReader,fesd)); | |
2671 | gROOT->ProcessLine("gAliEveEvent->StartStopAutoLoadTimer();"); | |
2672 | gSystem->Run(); | |
2673 | } |