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