Tag filename was incorrectly composed if reconstruction started not from 1st ev.
[u/mrichter/AliRoot.git] / STEER / STEER / AliReconstruction.cxx
CommitLineData
596a855f 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
fc07289e 3 * *
596a855f 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// //
596a855f 109///////////////////////////////////////////////////////////////////////////////
110
f7a1cc68 111#include <TArrayD.h>
024a7e64 112#include <TArrayF.h>
f7a1cc68 113#include <TArrayS.h>
114#include <TChain.h>
024a7e64 115#include <TFile.h>
f7a1cc68 116#include <TGeoGlobalMagField.h>
3103d196 117#include <TGeoManager.h>
f7a1cc68 118#include <TList.h>
2bdb9d38 119#include <TLorentzVector.h>
325aa76f 120#include <TMap.h>
f7a1cc68 121#include <TObjArray.h>
122#include <TPRegexp.h>
123#include <TParameter.h>
124#include <TPluginManager.h>
4b71572b 125#include <TProof.h>
db4aeca1 126#include <TProofOutputFile.h>
f7a1cc68 127#include <TROOT.h>
128#include <TSystem.h>
77ba28ba 129#include <THashTable.h>
6c6f2624 130#include <TGrid.h>
131#include <TMessage.h>
0a035be5 132#include <TUrl.h>
fc01854a 133#include <TRandom.h>
596a855f 134
f7a1cc68 135#include "AliAlignObj.h"
42457748 136#include "AliAnalysisManager.h"
137#include "AliAnalysisDataContainer.h"
f7a1cc68 138#include "AliCDBEntry.h"
139#include "AliCDBManager.h"
140#include "AliCDBStorage.h"
141#include "AliCTPRawStream.h"
142#include "AliCascadeVertexer.h"
143#include "AliCentralTrigger.h"
87932dab 144#include "AliCodeTimer.h"
f7a1cc68 145#include "AliDAQ.h"
146#include "AliDetectorRecoParam.h"
147#include "AliESDCaloCells.h"
148#include "AliESDCaloCluster.h"
af885e0f 149#include "AliESDEvent.h"
faffd83e 150#include "AliESDMuonTrack.h"
f7a1cc68 151#include "AliESDPmdTrack.h"
152#include "AliESDTagCreator.h"
2257f27e 153#include "AliESDVertex.h"
faffd83e 154#include "AliESDcascade.h"
f7a1cc68 155#include "AliESDfriend.h"
faffd83e 156#include "AliESDkink.h"
596a855f 157#include "AliESDpid.h"
ff8bb5ae 158#include "AliESDtrack.h"
f7a1cc68 159#include "AliESDtrack.h"
160#include "AliEventInfo.h"
161#include "AliGRPObject.h"
162#include "AliGRPRecoParam.h"
163#include "AliGenEventHeader.h"
25be1e5c 164#include "AliGeomManager.h"
aa3c69a9 165#include "AliGlobalQADataMaker.h"
f7a1cc68 166#include "AliHeader.h"
167#include "AliLog.h"
168#include "AliMagF.h"
169#include "AliMultiplicity.h"
170#include "AliPID.h"
171#include "AliPlaneEff.h"
4e25ac79 172#include "AliQAv1.h"
f7a1cc68 173#include "AliQADataMakerRec.h"
b03591ab 174#include "AliQAManager.h"
33314186 175#include "AliRawVEvent.h"
f7a1cc68 176#include "AliRawEventHeaderBase.h"
cd0b062e 177#include "AliRawHLTManager.h"
f7a1cc68 178#include "AliRawReaderDate.h"
179#include "AliRawReaderFile.h"
180#include "AliRawReaderRoot.h"
42457748 181#include "AliRecoInputHandler.h"
f7a1cc68 182#include "AliReconstruction.h"
183#include "AliReconstructor.h"
184#include "AliRun.h"
7e88424f 185#include "AliRunInfo.h"
f7a1cc68 186#include "AliRunLoader.h"
187#include "AliSysInfo.h" // memory snapshots
188#include "AliTrackPointArray.h"
189#include "AliTracker.h"
190#include "AliTriggerClass.h"
191#include "AliTriggerCluster.h"
a6dd87ad 192#include "AliTriggerIR.h"
f7a1cc68 193#include "AliTriggerConfiguration.h"
194#include "AliV0vertexer.h"
195#include "AliVertexer.h"
1f9831ab 196#include "AliTrackleter.h"
f7a1cc68 197#include "AliVertexerTracks.h"
52dd4a8c 198#include "AliTriggerRunScalers.h"
199#include "AliCTPTimeParams.h"
8b12d288 200#include "AliESDHLTDecision.h"
6ef9caeb 201#include "AliTriggerInput.h"
3d84ad67 202#include "AliLHCData.h"
27aa8455 203#include "ARVersion.h"
204#include <RVersion.h>
596a855f 205ClassImp(AliReconstruction)
206
596a855f 207//_____________________________________________________________________________
820b4d9e 208const char* AliReconstruction::fgkDetectorName[AliReconstruction::kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE"
209// #ifdef MFT_UPGRADE
210// , "MFT"
211// #endif
212 , "MFT" // AU
213 , "HLT"
214};
c757bafd 215
216//_____________________________________________________________________________
4b71572b 217AliReconstruction::AliReconstruction(const char* gAliceFilename) :
218 TSelector(),
2257f27e 219 fRunVertexFinder(kTRUE),
a84e2607 220 fRunVertexFinderTracks(kTRUE),
1f46a9ae 221 fRunHLTTracking(kFALSE),
e66fbafb 222 fRunMuonTracking(kFALSE),
d1683eef 223 fRunV0Finder(kTRUE),
224 fRunCascadeFinder(kTRUE),
1f9831ab 225 fRunMultFinder(kTRUE),
c8025cc8 226 fStopOnError(kTRUE),
1d99986f 227 fWriteAlignmentData(kFALSE),
228 fWriteESDfriend(kFALSE),
b647652d 229 fFillTriggerESD(kTRUE),
1d99986f 230
7f68891d 231 fCleanESD(kTRUE),
a023d8d8 232 fV0DCAmax(3.),
233 fV0CsPmin(0.),
7f68891d 234 fDmax(50.),
235 fZmax(50.),
236
1d99986f 237 fRunLocalReconstruction("ALL"),
b8cd5251 238 fRunTracking("ALL"),
e583c30d 239 fFillESD("ALL"),
7d566c20 240 fLoadCDB(""),
48ce48d1 241 fUseTrackingErrorsForAlignment(""),
e583c30d 242 fGAliceFileName(gAliceFilename),
4b71572b 243 fRawInput(""),
975320a0 244 fESDOutput(""),
81d57268 245 fProofOutputFileName(""),
246 fProofOutputLocation(""),
247 fProofOutputDataset(kFALSE),
248 fProofOutputArchive(""),
35042093 249 fEquipIdMap(""),
b26c3770 250 fFirstEvent(0),
251 fLastEvent(-1),
9d705769 252 fNumberOfEventsPerFile((UInt_t)-1),
fc01854a 253 fFractionFriends(0.04),
b8cd5251 254 fOptions(),
6bae477a 255 fLoadAlignFromCDB(kTRUE),
256 fLoadAlignData("ALL"),
cd0b062e 257 fUseHLTData(),
7e88424f 258 fRunInfo(NULL),
259 fEventInfo(),
522fdd91 260 fRunScalers(NULL),
52dd4a8c 261 fCTPTimeParams(NULL),
c7ff1a33 262 fCTPTimeAlign(NULL),
e583c30d 263
264 fRunLoader(NULL),
b649205a 265 fRawReader(NULL),
cd0b062e 266 fParentRawReader(NULL),
b8cd5251 267
7e88424f 268 fRecoParam(),
269
58e8dc31 270 fSPDTrackleter(NULL),
271
f2a195c1 272 fDiamondProfileSPD(NULL),
9178838a 273 fDiamondProfile(NULL),
43c9dae1 274 fDiamondProfileTPC(NULL),
77ba28ba 275 fListOfCosmicTriggers(NULL),
f2a195c1 276
6b6e4472 277 fGRPData(NULL),
444753c6 278
6bae477a 279 fAlignObjArray(NULL),
795e4a22 280 fCDBUri(),
f1c1204d 281 fQARefUri(),
759c1df1 282 fSpecCDBUri(),
795e4a22 283 fInitCDBCalled(kFALSE),
647d2bb8 284 fFromCDBSnapshot(kFALSE),
69e8e906 285 fSnapshotFileName(""),
795e4a22 286 fSetRunNumberFromDataCalled(kFALSE),
ce43afbe 287 fQADetectors("ALL"),
288 fQATasks("ALL"),
7e963665 289 fRunQA(kTRUE),
6b150027 290 fRunGlobalQA(kTRUE),
e4a998ed 291 fSameQACycle(kFALSE),
f1c1204d 292 fInitQACalled(kFALSE),
75373542 293 fWriteQAExpertData(kTRUE),
21a3aa09 294 fRunPlaneEff(kFALSE),
295
296 fesd(NULL),
297 fhltesd(NULL),
298 fesdf(NULL),
299 ffile(NULL),
ee7c441c 300 ffileF(NULL),
21a3aa09 301 ftree(NULL),
ee7c441c 302 ftreeF(NULL),
21a3aa09 303 fhlttree(NULL),
21a3aa09 304 ftVertexer(NULL),
14dd053c 305 fIsNewRunLoader(kFALSE),
4b71572b 306 fRunAliEVE(kFALSE),
f00558b6 307 fChain(NULL),
308 fNall(0),
309 fNspecie(0),
310 fSspecie(0),
311 fNhighPt(0),
f9fc20b4 312 fShighPt(0),
42457748 313 fUpgradeModule(""),
314 fAnalysisMacro(),
315 fAnalysis(0),
764daca3 316 fRecoHandler(0),
317 fDeclTriggerClasses("")
596a855f 318{
319// create reconstruction object with default parameters
002c9d1b 320 gGeoManager = NULL;
b8cd5251 321
ac4a7581 322 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b8cd5251 323 fReconstructor[iDet] = NULL;
f9fc20b4 324 fUpgradeMask[iDet]=kFALSE;
b8cd5251 325 fLoader[iDet] = NULL;
326 fTracker[iDet] = NULL;
327 }
4e25ac79 328 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
252f8aa8 329 fQACycles[iDet] = 999999 ;
330 fQAWriteExpert[iDet] = kFALSE ;
331 }
3d84ad67 332 fBeamInt[0][0]=fBeamInt[0][1]=fBeamInt[1][0]=fBeamInt[1][1] = -1;
333
e47c4c2e 334 AliPID pid;
596a855f 335}
336
337//_____________________________________________________________________________
338AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
4b71572b 339 TSelector(),
2257f27e 340 fRunVertexFinder(rec.fRunVertexFinder),
a84e2607 341 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
1f46a9ae 342 fRunHLTTracking(rec.fRunHLTTracking),
e66fbafb 343 fRunMuonTracking(rec.fRunMuonTracking),
d1683eef 344 fRunV0Finder(rec.fRunV0Finder),
345 fRunCascadeFinder(rec.fRunCascadeFinder),
1f9831ab 346 fRunMultFinder(rec.fRunMultFinder),
1d99986f 347 fStopOnError(rec.fStopOnError),
348 fWriteAlignmentData(rec.fWriteAlignmentData),
349 fWriteESDfriend(rec.fWriteESDfriend),
b647652d 350 fFillTriggerESD(rec.fFillTriggerESD),
1d99986f 351
7f68891d 352 fCleanESD(rec.fCleanESD),
a023d8d8 353 fV0DCAmax(rec.fV0DCAmax),
5e5c1aa9 354 fV0CsPmin(rec.fV0CsPmin),
7f68891d 355 fDmax(rec.fDmax),
356 fZmax(rec.fZmax),
357
1d99986f 358 fRunLocalReconstruction(rec.fRunLocalReconstruction),
e583c30d 359 fRunTracking(rec.fRunTracking),
360 fFillESD(rec.fFillESD),
7d566c20 361 fLoadCDB(rec.fLoadCDB),
48ce48d1 362 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
e583c30d 363 fGAliceFileName(rec.fGAliceFileName),
4b71572b 364 fRawInput(rec.fRawInput),
975320a0 365 fESDOutput(rec.fESDOutput),
81d57268 366 fProofOutputFileName(rec.fProofOutputFileName),
367 fProofOutputLocation(rec.fProofOutputLocation),
368 fProofOutputDataset(rec.fProofOutputDataset),
369 fProofOutputArchive(rec.fProofOutputArchive),
35042093 370 fEquipIdMap(rec.fEquipIdMap),
b26c3770 371 fFirstEvent(rec.fFirstEvent),
372 fLastEvent(rec.fLastEvent),
973388c2 373 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
fc01854a 374 fFractionFriends(rec.fFractionFriends),
b8cd5251 375 fOptions(),
6bae477a 376 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
377 fLoadAlignData(rec.fLoadAlignData),
2972d4eb 378 fUseHLTData(rec.fUseHLTData),
7e88424f 379 fRunInfo(NULL),
380 fEventInfo(),
522fdd91 381 fRunScalers(NULL),
52dd4a8c 382 fCTPTimeParams(NULL),
c7ff1a33 383 fCTPTimeAlign(NULL),
e583c30d 384
385 fRunLoader(NULL),
b649205a 386 fRawReader(NULL),
2972d4eb 387 fParentRawReader(NULL),
b8cd5251 388
4b71572b 389 fRecoParam(rec.fRecoParam),
7e88424f 390
58e8dc31 391 fSPDTrackleter(NULL),
392
f2a195c1 393 fDiamondProfileSPD(rec.fDiamondProfileSPD),
4b71572b 394 fDiamondProfile(rec.fDiamondProfile),
395 fDiamondProfileTPC(rec.fDiamondProfileTPC),
77ba28ba 396 fListOfCosmicTriggers(NULL),
f2a195c1 397
6b6e4472 398 fGRPData(NULL),
444753c6 399
6bae477a 400 fAlignObjArray(rec.fAlignObjArray),
ec92bee0 401 fCDBUri(rec.fCDBUri),
f1c1204d 402 fQARefUri(rec.fQARefUri),
7e963665 403 fSpecCDBUri(),
795e4a22 404 fInitCDBCalled(rec.fInitCDBCalled),
647d2bb8 405 fFromCDBSnapshot(rec.fFromCDBSnapshot),
69e8e906 406 fSnapshotFileName(rec.fSnapshotFileName),
795e4a22 407 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
ce43afbe 408 fQADetectors(rec.fQADetectors),
409 fQATasks(rec.fQATasks),
aa3c69a9 410 fRunQA(rec.fRunQA),
411 fRunGlobalQA(rec.fRunGlobalQA),
e4a998ed 412 fSameQACycle(rec.fSameQACycle),
f1c1204d 413 fInitQACalled(rec.fInitQACalled),
75373542 414 fWriteQAExpertData(rec.fWriteQAExpertData),
21a3aa09 415 fRunPlaneEff(rec.fRunPlaneEff),
416
417 fesd(NULL),
418 fhltesd(NULL),
419 fesdf(NULL),
420 ffile(NULL),
ee7c441c 421 ffileF(NULL),
21a3aa09 422 ftree(NULL),
ee7c441c 423 ftreeF(NULL),
21a3aa09 424 fhlttree(NULL),
21a3aa09 425 ftVertexer(NULL),
14dd053c 426 fIsNewRunLoader(rec.fIsNewRunLoader),
4b71572b 427 fRunAliEVE(kFALSE),
f00558b6 428 fChain(NULL),
429 fNall(0),
430 fNspecie(0),
431 fSspecie(0),
432 fNhighPt(0),
f9fc20b4 433 fShighPt(0),
42457748 434 fUpgradeModule(""),
435 fAnalysisMacro(rec.fAnalysisMacro),
436 fAnalysis(0),
764daca3 437 fRecoHandler(0),
438 fDeclTriggerClasses(rec.fDeclTriggerClasses)
596a855f 439{
440// copy constructor
441
ec92bee0 442 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
efd2085e 443 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
444 }
ac4a7581 445 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b8cd5251 446 fReconstructor[iDet] = NULL;
f9fc20b4 447 fUpgradeMask[iDet] = kFALSE;
b8cd5251 448 fLoader[iDet] = NULL;
449 fTracker[iDet] = NULL;
b1af1125 450 }
451
4e25ac79 452 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
b1af1125 453 fQACycles[iDet] = rec.fQACycles[iDet];
252f8aa8 454 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
455 }
b1af1125 456
ec92bee0 457 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
458 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
459 }
3d84ad67 460
461 for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
462
596a855f 463}
464
465//_____________________________________________________________________________
466AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
467{
468// assignment operator
4b71572b 469// Used in PROOF mode
470// Be very careful while modifing it!
471// Simple rules to follow:
472// for persistent data members - use their assignment operators
473// for non-persistent ones - do nothing or take the default values from constructor
474// TSelector members should not be touched
475 if(&rec == this) return *this;
476
4b71572b 477 fRunVertexFinder = rec.fRunVertexFinder;
478 fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
479 fRunHLTTracking = rec.fRunHLTTracking;
480 fRunMuonTracking = rec.fRunMuonTracking;
481 fRunV0Finder = rec.fRunV0Finder;
482 fRunCascadeFinder = rec.fRunCascadeFinder;
1f9831ab 483 fRunMultFinder = rec.fRunMultFinder;
4b71572b 484 fStopOnError = rec.fStopOnError;
485 fWriteAlignmentData = rec.fWriteAlignmentData;
486 fWriteESDfriend = rec.fWriteESDfriend;
487 fFillTriggerESD = rec.fFillTriggerESD;
488
489 fCleanESD = rec.fCleanESD;
490 fV0DCAmax = rec.fV0DCAmax;
491 fV0CsPmin = rec.fV0CsPmin;
492 fDmax = rec.fDmax;
493 fZmax = rec.fZmax;
494
495 fRunLocalReconstruction = rec.fRunLocalReconstruction;
496 fRunTracking = rec.fRunTracking;
497 fFillESD = rec.fFillESD;
7d566c20 498 fLoadCDB = rec.fLoadCDB;
4b71572b 499 fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
500 fGAliceFileName = rec.fGAliceFileName;
501 fRawInput = rec.fRawInput;
975320a0 502 fESDOutput = rec.fESDOutput;
81d57268 503 fProofOutputFileName = rec.fProofOutputFileName;
504 fProofOutputLocation = rec.fProofOutputLocation;
505 fProofOutputDataset = rec.fProofOutputDataset;
506 fProofOutputArchive = rec.fProofOutputArchive;
4b71572b 507 fEquipIdMap = rec.fEquipIdMap;
508 fFirstEvent = rec.fFirstEvent;
509 fLastEvent = rec.fLastEvent;
510 fNumberOfEventsPerFile = rec.fNumberOfEventsPerFile;
fc01854a 511 fFractionFriends = rec.fFractionFriends;
4b71572b 512
513 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
514 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
515 }
516
517 fLoadAlignFromCDB = rec.fLoadAlignFromCDB;
518 fLoadAlignData = rec.fLoadAlignData;
4b71572b 519 fUseHLTData = rec.fUseHLTData;
520
521 delete fRunInfo; fRunInfo = NULL;
522 if (rec.fRunInfo) fRunInfo = new AliRunInfo(*rec.fRunInfo);
523
524 fEventInfo = rec.fEventInfo;
525
522fdd91 526 delete fRunScalers; fRunScalers = NULL;
527 if (rec.fRunScalers) fRunScalers = new AliTriggerRunScalers(*rec.fRunScalers);
528
52dd4a8c 529 delete fCTPTimeParams; fCTPTimeParams = NULL;
530 if (rec.fCTPTimeParams) fCTPTimeParams = new AliCTPTimeParams(*rec.fCTPTimeParams);
c7ff1a33 531 delete fCTPTimeAlign; fCTPTimeAlign = NULL;
532 if (rec.fCTPTimeAlign) fCTPTimeAlign = new AliCTPTimeParams(*rec.fCTPTimeAlign);
52dd4a8c 533
4b71572b 534 fRunLoader = NULL;
535 fRawReader = NULL;
536 fParentRawReader = NULL;
537
538 fRecoParam = rec.fRecoParam;
539
ac4a7581 540 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
f9fc20b4 541 fUpgradeMask[iDet] = kFALSE;
4b71572b 542 delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
543 delete fLoader[iDet]; fLoader[iDet] = NULL;
544 delete fTracker[iDet]; fTracker[iDet] = NULL;
4b71572b 545 }
b1af1125 546
4e25ac79 547 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
b1af1125 548 fQACycles[iDet] = rec.fQACycles[iDet];
252f8aa8 549 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
550 }
58e8dc31 551
552 delete fSPDTrackleter; fSPDTrackleter = NULL;
252f8aa8 553
f2a195c1 554 delete fDiamondProfileSPD; fDiamondProfileSPD = NULL;
555 if (rec.fDiamondProfileSPD) fDiamondProfileSPD = new AliESDVertex(*rec.fDiamondProfileSPD);
4b71572b 556 delete fDiamondProfile; fDiamondProfile = NULL;
557 if (rec.fDiamondProfile) fDiamondProfile = new AliESDVertex(*rec.fDiamondProfile);
558 delete fDiamondProfileTPC; fDiamondProfileTPC = NULL;
559 if (rec.fDiamondProfileTPC) fDiamondProfileTPC = new AliESDVertex(*rec.fDiamondProfileTPC);
4b71572b 560
77ba28ba 561 delete fListOfCosmicTriggers; fListOfCosmicTriggers = NULL;
562 if (rec.fListOfCosmicTriggers) fListOfCosmicTriggers = (THashTable*)((rec.fListOfCosmicTriggers)->Clone());
563
4b71572b 564 delete fGRPData; fGRPData = NULL;
44e45fac 565 // if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
566 if (rec.fGRPData) fGRPData = (AliGRPObject*)((rec.fGRPData)->Clone());
4b71572b 567
568 delete fAlignObjArray; fAlignObjArray = NULL;
569
570 fCDBUri = "";
f1c1204d 571 fQARefUri = rec.fQARefUri;
4b71572b 572 fSpecCDBUri.Delete();
573 fInitCDBCalled = rec.fInitCDBCalled;
647d2bb8 574 fFromCDBSnapshot = rec.fFromCDBSnapshot;
69e8e906 575 fSnapshotFileName = rec.fSnapshotFileName;
4b71572b 576 fSetRunNumberFromDataCalled = rec.fSetRunNumberFromDataCalled;
577 fQADetectors = rec.fQADetectors;
4b71572b 578 fQATasks = rec.fQATasks;
579 fRunQA = rec.fRunQA;
580 fRunGlobalQA = rec.fRunGlobalQA;
4b71572b 581 fSameQACycle = rec.fSameQACycle;
f1c1204d 582 fInitQACalled = rec.fInitQACalled;
75373542 583 fWriteQAExpertData = rec.fWriteQAExpertData;
4b71572b 584 fRunPlaneEff = rec.fRunPlaneEff;
3d84ad67 585 for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
4b71572b 586 fesd = NULL;
587 fhltesd = NULL;
588 fesdf = NULL;
589 ffile = NULL;
ee7c441c 590 ffileF = NULL;
4b71572b 591 ftree = NULL;
ee7c441c 592 ftreeF = NULL;
4b71572b 593 fhlttree = NULL;
594 ftVertexer = NULL;
595 fIsNewRunLoader = rec.fIsNewRunLoader;
596 fRunAliEVE = kFALSE;
597 fChain = NULL;
f00558b6 598 fNall = 0;
599 fNspecie = 0;
600 fSspecie = 0;
601 fNhighPt = 0;
602 fShighPt = 0;
f9fc20b4 603 fUpgradeModule="";
42457748 604 fAnalysisMacro = rec.fAnalysisMacro;
605 fAnalysis = 0;
606 fRecoHandler = 0;
764daca3 607 fDeclTriggerClasses = rec.fDeclTriggerClasses;
596a855f 608
596a855f 609 return *this;
610}
611
612//_____________________________________________________________________________
613AliReconstruction::~AliReconstruction()
614{
615// clean up
616
e583c30d 617 CleanUp();
77ba28ba 618 if (fListOfCosmicTriggers) {
619 fListOfCosmicTriggers->Delete();
620 delete fListOfCosmicTriggers;
621 }
4f3c479a 622 delete fGRPData;
522fdd91 623 delete fRunScalers;
52dd4a8c 624 delete fCTPTimeParams;
c7ff1a33 625 delete fCTPTimeAlign;
efd2085e 626 fOptions.Delete();
4b71572b 627 if (fAlignObjArray) {
628 fAlignObjArray->Delete();
629 delete fAlignObjArray;
630 }
ec92bee0 631 fSpecCDBUri.Delete();
e6d66370 632
87932dab 633 AliCodeTimer::Instance()->Print();
596a855f 634}
635
024cf675 636//_____________________________________________________________________________
f1c1204d 637void AliReconstruction::InitQA()
638{
639 //Initialize the QA and start of cycle
52dd4a8c 640 AliCodeTimerAuto("",0);
f1c1204d 641
642 if (fInitQACalled) return;
643 fInitQACalled = kTRUE;
644
92664bc8 645 if (fGRPData) AliQADataMaker::SetCloningRequest( fGRPData->GetQATrigClasses(), fGRPData->GetQACloningRequest());
646
647
634696f5 648 AliQAManager * qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ;
75373542 649 if (fWriteQAExpertData)
eca4fa66 650 qam->SetWriteExpert() ;
75373542 651
eca4fa66 652 if (qam->IsDefaultStorageSet()) {
f1c1204d 653 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
654 AliWarning("Default QA reference storage has been already set !");
655 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fQARefUri.Data()));
656 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
eca4fa66 657 fQARefUri = qam->GetDefaultStorage()->GetURI();
f1c1204d 658 } else {
659 if (fQARefUri.Length() > 0) {
660 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
661 AliDebug(2, Form("Default QA reference storage is set to: %s", fQARefUri.Data()));
662 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
663 } else {
664 fQARefUri="local://$ALICE_ROOT/QAref";
665 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
666 AliWarning("Default QA refeference storage not yet set !!!!");
667 AliWarning(Form("Setting it now to: %s", fQARefUri.Data()));
668 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
669
670 }
eca4fa66 671 qam->SetDefaultStorage(fQARefUri);
f1c1204d 672 }
673
674 if (fRunQA) {
eca4fa66 675 qam->SetActiveDetectors(fQADetectors) ;
4e25ac79 676 for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++) {
eca4fa66 677 qam->SetCycleLength(AliQAv1::DETECTORINDEX_t(det), fQACycles[det]) ;
678 qam->SetWriteExpert(AliQAv1::DETECTORINDEX_t(det)) ;
f1c1204d 679 }
514cb8c7 680 if (!fRawReader && !fInput && IsInTasks(AliQAv1::kRAWS))
4e25ac79 681 fQATasks.ReplaceAll(Form("%d",AliQAv1::kRAWS), "") ;
eca4fa66 682 qam->SetTasks(fQATasks) ;
683 qam->InitQADataMaker(AliCDBManager::Instance()->GetRun()) ;
f1c1204d 684 }
685 if (fRunGlobalQA) {
686 Bool_t sameCycle = kFALSE ;
eca4fa66 687 AliQADataMaker *qadm = qam->GetQADataMaker(AliQAv1::kGLOBAL);
f1c1204d 688 AliInfo(Form("Initializing the global QA data maker"));
514cb8c7 689 if (IsInTasks(AliQAv1::kRECPOINTS)) {
4e25ac79 690 qadm->StartOfCycle(AliQAv1::kRECPOINTS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
691 TObjArray **arr=qadm->Init(AliQAv1::kRECPOINTS);
f1c1204d 692 AliTracker::SetResidualsArray(arr);
693 sameCycle = kTRUE ;
694 }
514cb8c7 695 if (IsInTasks(AliQAv1::kESDS)) {
4e25ac79 696 qadm->StartOfCycle(AliQAv1::kESDS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
697 qadm->Init(AliQAv1::kESDS);
f1c1204d 698 }
f1c1204d 699 }
fc07289e 700 AliSysInfo::AddStamp("InitQA") ;
f1c1204d 701}
702
703//_____________________________________________________________________________
87da0921 704void AliReconstruction::MergeQA(const char *fileName)
fc07289e 705{
706 //Initialize the QA and start of cycle
52dd4a8c 707 AliCodeTimerAuto("",0) ;
eca4fa66 708 AliQAManager::QAManager()->Merge(AliCDBManager::Instance()->GetRun(),fileName) ;
fc07289e 709 AliSysInfo::AddStamp("MergeQA") ;
710}
711
712//_____________________________________________________________________________
795e4a22 713void AliReconstruction::InitCDB()
024cf675 714{
715// activate a default CDB storage
716// First check if we have any CDB storage set, because it is used
717// to retrieve the calibration and alignment constants
52dd4a8c 718 AliCodeTimerAuto("",0);
024cf675 719
795e4a22 720 if (fInitCDBCalled) return;
721 fInitCDBCalled = kTRUE;
722
024cf675 723 AliCDBManager* man = AliCDBManager::Instance();
ec92bee0 724 if (man->IsDefaultStorageSet())
024cf675 725 {
726 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
ec92bee0 727 AliWarning("Default CDB storage has been already set !");
728 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
024cf675 729 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
795e4a22 730 fCDBUri = man->GetDefaultStorage()->GetURI();
ec92bee0 731 }
732 else {
795e4a22 733 if (fCDBUri.Length() > 0)
734 {
735 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
736 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
737 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
52dd4a8c 738 man->SetDefaultStorage(fCDBUri);
739 }
740 else if (!man->GetRaw()){
741 fCDBUri="local://$ALICE_ROOT/OCDB";
795e4a22 742 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
743 AliWarning("Default CDB storage not yet set !!!!");
744 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
745 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
52dd4a8c 746 man->SetDefaultStorage(fCDBUri);
747 }
748 else {
749 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
750 AliWarning("Default storage will be set after setting the Run Number!!!");
751 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
795e4a22 752 }
ec92bee0 753 }
754
755 // Now activate the detector specific CDB storage locations
c3a7b59a 756 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
757 TObject* obj = fSpecCDBUri[i];
758 if (!obj) continue;
b8ec52f6 759 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
760 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
761 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
c3a7b59a 762 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
ec92bee0 763 }
002c9d1b 764 AliSysInfo::AddStamp("InitCDB");
024cf675 765}
766
767//_____________________________________________________________________________
768void AliReconstruction::SetDefaultStorage(const char* uri) {
ec92bee0 769// Store the desired default CDB storage location
770// Activate it later within the Run() method
024cf675 771
ec92bee0 772 fCDBUri = uri;
024cf675 773
774}
775
776//_____________________________________________________________________________
f1c1204d 777void AliReconstruction::SetQARefDefaultStorage(const char* uri) {
778 // Store the desired default CDB storage location
779 // Activate it later within the Run() method
780
781 fQARefUri = uri;
4e25ac79 782 AliQAv1::SetQARefStorage(fQARefUri.Data()) ;
f1c1204d 783
784}
785//_____________________________________________________________________________
c3a7b59a 786void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
ec92bee0 787// Store a detector-specific CDB storage location
788// Activate it later within the Run() method
024cf675 789
c3a7b59a 790 AliCDBPath aPath(calibType);
791 if(!aPath.IsValid()){
792 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
ac4a7581 793 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
c3a7b59a 794 if(!strcmp(calibType, fgkDetectorName[iDet])) {
795 aPath.SetPath(Form("%s/*", calibType));
796 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
797 break;
798 }
799 }
800 if(!aPath.IsValid()){
801 AliError(Form("Not a valid path or detector: %s", calibType));
802 return;
803 }
804 }
805
53dd3c3d 806// // check that calibType refers to a "valid" detector name
807// Bool_t isDetector = kFALSE;
ac4a7581 808// for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
53dd3c3d 809// TString detName = fgkDetectorName[iDet];
810// if(aPath.GetLevel0() == detName) {
811// isDetector = kTRUE;
812// break;
813// }
814// }
815//
816// if(!isDetector) {
817// AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
818// return;
819// }
c3a7b59a 820
821 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
ec92bee0 822 if (obj) fSpecCDBUri.Remove(obj);
c3a7b59a 823 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
024cf675 824
825}
826
6bae477a 827//_____________________________________________________________________________
795e4a22 828Bool_t AliReconstruction::SetRunNumberFromData()
6bae477a 829{
830 // The method is called in Run() in order
831 // to set a correct run number.
832 // In case of raw data reconstruction the
833 // run number is taken from the raw data header
834
795e4a22 835 if (fSetRunNumberFromDataCalled) return kTRUE;
836 fSetRunNumberFromDataCalled = kTRUE;
837
838 AliCDBManager* man = AliCDBManager::Instance();
4b71572b 839
840 if(fRawReader) {
841 if(fRawReader->NextEvent()) {
842 if(man->GetRun() > 0) {
21a3aa09 843 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
4b71572b 844 }
845 man->SetRun(fRawReader->GetRunNumber());
846 fRawReader->RewindEvents();
847 }
848 else {
849 if(man->GetRun() > 0) {
850 AliWarning("No raw-data events are found ! Using settings in AliCDBManager !");
851 }
852 else {
853 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
854 return kFALSE;
855 }
856 }
857 }
858 else {
859 AliRunLoader *rl = AliRunLoader::Open(fGAliceFileName.Data());
860 if (!rl) {
861 AliError(Form("No run loader found in file %s", fGAliceFileName.Data()));
6bae477a 862 return kFALSE;
863 }
ec92bee0 864 else {
4b71572b 865 rl->LoadHeader();
866 // read run number from gAlice
867 if(rl->GetHeader()) {
868 man->SetRun(rl->GetHeader()->GetRun());
869 rl->UnloadHeader();
870 delete rl;
ec92bee0 871 }
872 else {
4b71572b 873 AliError("Neither run-loader header nor RawReader objects are found !");
874 delete rl;
ec92bee0 875 return kFALSE;
876 }
4b71572b 877 }
6bae477a 878 }
795e4a22 879
880 man->Print();
881
6bae477a 882 return kTRUE;
883}
884
885//_____________________________________________________________________________
795e4a22 886void AliReconstruction::SetCDBLock() {
887 // Set CDB lock: from now on it is forbidden to reset the run number
888 // or the default storage or to activate any further storage!
889
890 AliCDBManager::Instance()->SetLock(1);
891}
892
893//_____________________________________________________________________________
f9fc20b4 894void AliReconstruction::MatchUpgradeDetector() {
895 // Translates detector name in a boolean.
896 // The boolean is used in GetReconstructor to load the
897 // upgrade reconstructor instead of the standard one.
898 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
899 if(fUpgradeModule.Contains(fgkDetectorName[iDet])) fUpgradeMask[iDet]=kTRUE;
900 }
901}
902//_____________________________________________________________________________
6bae477a 903Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
904{
905 // Read the alignment objects from CDB.
906 // Each detector is supposed to have the
907 // alignment objects in DET/Align/Data CDB path.
908 // All the detector objects are then collected,
909 // sorted by geometry level (starting from ALIC) and
910 // then applied to the TGeo geometry.
911 // Finally an overlaps check is performed.
912
913 // Load alignment data from CDB and fill fAlignObjArray
914 if(fLoadAlignFromCDB){
6bae477a 915
25be1e5c 916 TString detStr = detectors;
917 TString loadAlObjsListOfDets = "";
918
ac4a7581 919 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
8cb26cdf 920 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
f12d42ce 921 if(!strcmp(fgkDetectorName[iDet],"HLT")) continue;
4fbb8e9d 922
923 if(AliGeomManager::GetNalignable(fgkDetectorName[iDet]) != 0)
8cb26cdf 924 {
925 loadAlObjsListOfDets += fgkDetectorName[iDet];
926 loadAlObjsListOfDets += " ";
927 }
25be1e5c 928 } // end loop over detectors
4fbb8e9d 929
930 if(AliGeomManager::GetNalignable("GRP") != 0)
8cb26cdf 931 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
98e303d9 932 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
25be1e5c 933 }else{
934 // Check if the array with alignment objects was
935 // provided by the user. If yes, apply the objects
936 // to the present TGeo geometry
937 if (fAlignObjArray) {
938 if (gGeoManager && gGeoManager->IsClosed()) {
98e303d9 939 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
25be1e5c 940 AliError("The misalignment of one or more volumes failed!"
941 "Compare the list of simulated detectors and the list of detector alignment data!");
942 return kFALSE;
943 }
944 }
945 else {
946 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
6bae477a 947 return kFALSE;
948 }
949 }
6bae477a 950 }
25be1e5c 951
4b71572b 952 if (fAlignObjArray) {
953 fAlignObjArray->Delete();
954 delete fAlignObjArray; fAlignObjArray=NULL;
955 }
a03b0371 956
6bae477a 957 return kTRUE;
958}
596a855f 959
960//_____________________________________________________________________________
961void AliReconstruction::SetGAliceFile(const char* fileName)
962{
963// set the name of the galice file
964
965 fGAliceFileName = fileName;
966}
967
efd2085e 968//_____________________________________________________________________________
b58710ef 969void AliReconstruction::SetInput(const char* input)
21a3aa09 970{
b58710ef 971 // In case the input string starts with 'mem://', we run in an online mode
972 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
973 // file is assumed. One can give as an input:
974 // mem://: - events taken from DAQ monitoring libs online
975 // or
976 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
4b71572b 977 if (input) fRawInput = input;
21a3aa09 978}
979
980//_____________________________________________________________________________
975320a0 981void AliReconstruction::SetOutput(const char* output)
982{
983 // Set the output ESD filename
984 // 'output' is a normalt ROOT url
985 // The method is used in case of raw-data reco with PROOF
81d57268 986 if (output) fESDOutput = output;
975320a0 987}
988
989//_____________________________________________________________________________
efd2085e 990void AliReconstruction::SetOption(const char* detector, const char* option)
991{
992// set options for the reconstruction of a detector
993
994 TObject* obj = fOptions.FindObject(detector);
995 if (obj) fOptions.Remove(obj);
996 fOptions.Add(new TNamed(detector, option));
997}
998
596a855f 999//_____________________________________________________________________________
7e88424f 1000void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
1001{
1002 // Set custom reconstruction parameters for a given detector
1003 // Single set of parameters for all the events
a00021a7 1004
1005 // First check if the reco-params are global
1006 if(!strcmp(detector, "GRP")) {
1007 par->SetAsDefault();
ac4a7581 1008 fRecoParam.AddDetRecoParam(kNDetectors,par);
a00021a7 1009 return;
1010 }
1011
ac4a7581 1012 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
7e88424f 1013 if(!strcmp(detector, fgkDetectorName[iDet])) {
1014 par->SetAsDefault();
1015 fRecoParam.AddDetRecoParam(iDet,par);
1016 break;
1017 }
1018 }
1019
1020}
1021
1022//_____________________________________________________________________________
61807e09 1023Bool_t AliReconstruction::InitGRP() {
1024 //------------------------------------
1025 // Initialization of the GRP entry
1026 //------------------------------------
1027 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
1028
4b71572b 1029 if (entry) {
44e45fac 1030
1031 TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
1032
1033 if (m) {
1034 AliInfo("Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject");
1035 m->Print();
1036 fGRPData = new AliGRPObject();
1037 fGRPData->ReadValuesFromMap(m);
1038 }
1039
1040 else {
1041 AliInfo("Found an AliGRPObject in GRP/GRP/Data, reading it");
1042 fGRPData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
1043 entry->SetOwner(0);
1044 }
1045
f168abba 1046 // FIX ME: The unloading of GRP entry is temporarily disabled
1047 // because ZDC and VZERO are using it in order to initialize
1048 // their reconstructor objects. In the future one has to think
1049 // of propagating AliRunInfo to the reconstructors.
1050 // AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
4b71572b 1051 }
61807e09 1052
1053 if (!fGRPData) {
1054 AliError("No GRP entry found in OCDB!");
1055 return kFALSE;
1056 }
1057
44e45fac 1058 TString lhcState = fGRPData->GetLHCState();
1059 if (lhcState==AliGRPObject::GetInvalidString()) {
7e88424f 1060 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
44e45fac 1061 lhcState = "UNKNOWN";
7e88424f 1062 }
1063
44e45fac 1064 TString beamType = fGRPData->GetBeamType();
1065 if (beamType==AliGRPObject::GetInvalidString()) {
7e88424f 1066 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
44e45fac 1067 beamType = "UNKNOWN";
7e88424f 1068 }
1069
44e45fac 1070 Float_t beamEnergy = fGRPData->GetBeamEnergy();
1071 if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
7e88424f 1072 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
44e45fac 1073 beamEnergy = 0;
7e88424f 1074 }
1075
44e45fac 1076 TString runType = fGRPData->GetRunType();
1077 if (runType==AliGRPObject::GetInvalidString()) {
7e88424f 1078 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
44e45fac 1079 runType = "UNKNOWN";
7e88424f 1080 }
1081
44e45fac 1082 Int_t activeDetectors = fGRPData->GetDetectorMask();
a5dede5c 1083 if (activeDetectors==AliGRPObject::GetInvalidUInt()) {
7e88424f 1084 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
44e45fac 1085 activeDetectors = 1074790399;
7e88424f 1086 }
820b4d9e 1087 AliDebug(1, Form("activeDetectors = %d", activeDetectors));
7e88424f 1088
44e45fac 1089 fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
44e45fac 1090 fRunInfo->Dump();
1091
7e88424f 1092
1093 // Process the list of active detectors
44e45fac 1094 if (activeDetectors) {
1095 UInt_t detMask = activeDetectors;
820b4d9e 1096 AliDebug(1, Form("Detector List = %s", fRunLocalReconstruction.Data()));
7a317bef 1097 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
820b4d9e 1098 AliDebug(1, Form("Detector List = %s", fRunLocalReconstruction.Data()));
7a317bef 1099 fRunTracking = MatchDetectorList(fRunTracking,detMask);
1100 fFillESD = MatchDetectorList(fFillESD,detMask);
1101 fQADetectors = MatchDetectorList(fQADetectors,detMask);
7d566c20 1102 fLoadCDB.Form("%s %s %s %s",
1103 fRunLocalReconstruction.Data(),
1104 fRunTracking.Data(),
1105 fFillESD.Data(),
1106 fQADetectors.Data());
7d566c20 1107 fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
d0f84c42 1108 if (!((detMask >> AliDAQ::DetectorID("ITSSPD")) & 0x1) &&
1109 !((detMask >> AliDAQ::DetectorID("ITSSDD")) & 0x1) &&
1110 !((detMask >> AliDAQ::DetectorID("ITSSSD")) & 0x1) ) {
91e2f025 1111 // switch off the vertexer
1f9831ab 1112 AliInfo("SPD,SDD,SSD is not in the list of active detectors. Vertexer and Trackleter are switched off.");
91e2f025 1113 fRunVertexFinder = kFALSE;
1f9831ab 1114 fRunMultFinder = kFALSE;
91e2f025 1115 }
304d7f0b 1116 if (!((detMask >> AliDAQ::DetectorID("TRG")) & 0x1)) {
1117 // switch off the reading of CTP raw-data payload
1118 if (fFillTriggerESD) {
1119 AliInfo("CTP is not in the list of active detectors. CTP data reading switched off.");
1120 fFillTriggerESD = kFALSE;
1121 }
1122 }
7e88424f 1123 }
1124
1125 AliInfo("===================================================================================");
1126 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
1127 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
1128 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
ca13fb87 1129 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
7d566c20 1130 AliInfo(Form("CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data()));
7e88424f 1131 AliInfo("===================================================================================");
61807e09 1132
1133 //*** Dealing with the magnetic field map
5a004fb4 1134 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
1135 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
1136 AliInfo("ExpertMode!!! GRP information will be ignored !");
1137 AliInfo("ExpertMode!!! Running with the externally locked B field !");
1138 }
1139 else {
1140 AliInfo("Destroying existing B field instance!");
1141 delete TGeoGlobalMagField::Instance();
1142 }
1143 }
1144 if ( !TGeoGlobalMagField::Instance()->IsLocked() ) {
61807e09 1145 // Construct the field map out of the information retrieved from GRP.
856024f0 1146 Bool_t ok = kTRUE;
61807e09 1147 // L3
44e45fac 1148 Float_t l3Current = fGRPData->GetL3Current((AliGRPObject::Stats)0);
1149 if (l3Current == AliGRPObject::GetInvalidFloat()) {
1150 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
1151 ok = kFALSE;
1152 }
f7a1cc68 1153
44e45fac 1154 Char_t l3Polarity = fGRPData->GetL3Polarity();
1155 if (l3Polarity == AliGRPObject::GetInvalidChar()) {
1156 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
1157 ok = kFALSE;
1158 }
1159
1160 // Dipole
1161 Float_t diCurrent = fGRPData->GetDipoleCurrent((AliGRPObject::Stats)0);
1162 if (diCurrent == AliGRPObject::GetInvalidFloat()) {
1163 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
1164 ok = kFALSE;
1165 }
1166
1167 Char_t diPolarity = fGRPData->GetDipolePolarity();
1168 if (diPolarity == AliGRPObject::GetInvalidChar()) {
1169 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
1170 ok = kFALSE;
1171 }
1172
99c7d495 1173 // read special bits for the polarity convention and map type
1174 Int_t polConvention = fGRPData->IsPolarityConventionLHC() ? AliMagF::kConvLHC : AliMagF::kConvDCS2008;
1175 Bool_t uniformB = fGRPData->IsUniformBMap();
61807e09 1176
856024f0 1177 if (ok) {
33fe5eb1 1178 AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1),
1179 TMath::Abs(diCurrent) * (diPolarity ? -1:1),
1180 polConvention,uniformB,beamEnergy, beamType.Data());
1181 if (fld) {
1182 TGeoGlobalMagField::Instance()->SetField( fld );
1183 TGeoGlobalMagField::Instance()->Lock();
1184 AliInfo("Running with the B field constructed out of GRP !");
1185 }
1186 else AliFatal("Failed to create a B field map !");
856024f0 1187 }
f7a1cc68 1188 else AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
61807e09 1189 }
f7a1cc68 1190
f2a195c1 1191 //*** Get the diamond profiles from OCDB
1192 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
1193 if (entry) {
1194 fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject());
1195 } else {
1196 AliError("No SPD diamond profile found in OCDB!");
1197 }
1198
61807e09 1199 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
1200 if (entry) {
f2a195c1 1201 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
61807e09 1202 } else {
1203 AliError("No diamond profile found in OCDB!");
1204 }
1205
1206 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
1207 if (entry) {
f2a195c1 1208 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
61807e09 1209 } else {
f2a195c1 1210 AliError("No TPC diamond profile found in OCDB!");
61807e09 1211 }
1212
77ba28ba 1213 entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers");
1214 if (entry) {
1215 fListOfCosmicTriggers = dynamic_cast<THashTable*>(entry->GetObject());
1216 entry->SetOwner(0);
77ba28ba 1217 }
1218
1219 if (!fListOfCosmicTriggers) {
1220 AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will be effectively disabled!");
1221 }
1222
61807e09 1223 return kTRUE;
1224}
1225
1226//_____________________________________________________________________________
4b71572b 1227Bool_t AliReconstruction::LoadCDB()
1228{
0a035be5 1229 // Load CDB entries for all active detectors.
1230 // By default we load all the entries in <det>/Calib
1231 // folder.
1232
52dd4a8c 1233 AliCodeTimerAuto("",0);
4b71572b 1234
1235 AliCDBManager::Instance()->Get("GRP/CTP/Config");
1236
30d5d647 1237 AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase");
1238
7d566c20 1239 TString detStr = fLoadCDB;
ac4a7581 1240 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
4b71572b 1241 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1242 AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
b6af2cb6 1243 AliCDBManager::Instance()->GetAll(Form("%s/Trigger/*",fgkDetectorName[iDet]));
4b71572b 1244 }
e122592f 1245
1246 // Temporary fix - one has to define the correct policy in order
1247 // to load the trigger OCDB entries only for the detectors that
1248 // in the trigger or that are needed in order to put correct
1249 // information in ESD
1250 AliCDBManager::Instance()->GetAll("TRIGGER/*/*");
1251
4b71572b 1252 return kTRUE;
1253}
522fdd91 1254//_____________________________________________________________________________
1255Bool_t AliReconstruction::LoadTriggerScalersCDB()
1256{
0a035be5 1257 // Load CTP scalers from OCDB.
1258 // The scalers are checked for consistency.
1259
52dd4a8c 1260 AliCodeTimerAuto("",0);
522fdd91 1261
1262 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Scalers");
4b71572b 1263
522fdd91 1264 if (entry) {
1265
1266 AliInfo("Found an AliTriggerRunScalers in GRP/CTP/Scalers, reading it");
1267 fRunScalers = dynamic_cast<AliTriggerRunScalers*> (entry->GetObject());
1268 entry->SetOwner(0);
c7a22819 1269 if (fRunScalers && (fRunScalers->CorrectScalersOverflow() == 0)) AliInfo("32bit Trigger counters corrected for overflow");
82ebedd6 1270
522fdd91 1271 }
1272 return kTRUE;
1273}
4b71572b 1274//_____________________________________________________________________________
52dd4a8c 1275Bool_t AliReconstruction::LoadCTPTimeParamsCDB()
1276{
0a035be5 1277 // Load CTP timing information (alignment)
1278 // from OCDB.
1279
52dd4a8c 1280 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
c7ff1a33 1281 if (!entry) return kFALSE;
52dd4a8c 1282
c7ff1a33 1283 AliInfo("Found an AliCTPTimeParams in GRP/CTP/CTPtiming, reading it");
1284 fCTPTimeParams = dynamic_cast<AliCTPTimeParams*> (entry->GetObject());
1285 entry->SetOwner(0);
52dd4a8c 1286
c7ff1a33 1287 AliCDBEntry* entry2 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign");
1288 if (!entry2) return kFALSE;
1289
1290 AliInfo("Found an AliCTPTimeParams in GRP/CTP/TimeAlign, reading it");
028be258 1291 fCTPTimeAlign = dynamic_cast<AliCTPTimeParams*> (entry2->GetObject());
1292 entry2->SetOwner(0);
c7ff1a33 1293
1294 return kTRUE;
52dd4a8c 1295}
3d84ad67 1296
1297//_____________________________________________________________________________
1298Bool_t AliReconstruction::ReadIntensityInfoCDB()
1299{
1300 // Load LHC DIP data
2af04ffd 1301 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/LHCData");
1302 AliCDBEntry* entryCTP = AliCDBManager::Instance()->Get("GRP/CTP/Config");
1303 //
bc5c8516 1304 if (!entry || !entryCTP) {
1305 AliError(Form("Failed to extract CDB objects GRP/GRP/LHCData: %p or GRP/CTP/Config: %p",entry,entryCTP));
1306 return kFALSE;
1307 }
2af04ffd 1308 // extract BC masks
1309 enum {kA,kB,kC,kE,kNMasks};
1310 AliTriggerConfiguration* conf = (AliTriggerConfiguration*)entryCTP->GetObject();
1311 const TObjArray& clArr = conf->GetClasses();
1312 TObjArray masks(kNMasks);
1313 TIter next(&clArr);
1314 AliTriggerClass* trClass = 0;
1315 int nFound = 0;
1316 masks.SetOwner(kFALSE);
1317 //
1318 while ( (trClass=(AliTriggerClass*)next()) ) {
1319 TString trName = trClass->GetName();
1320 int ind = trName.Index("-"); // prefix in front of A,B,C,E
1321 if (ind<1) continue; // anomaly
1322 //
1323 trName = trName.Data() + ind;
1324 AliTriggerBCMask* bcMask = trClass->GetBCMask();
1325 if (!bcMask) continue;
1326 UInt_t which = 0;
1327 if (trName.BeginsWith("-A-")) which |= 0x1<<kA;
1328 else if (trName.BeginsWith("-B-")) which |= 0x1<<kB;
1329 else if (trName.BeginsWith("-C-")) which |= 0x1<<kC;
1330 else if (trName.BeginsWith("-E-")) which |= 0x1<<kE;
1331 else if (trName.BeginsWith("-AC-")) which |= (0x1<<kA) | (0x1<<kC);
1332 else if (trName.BeginsWith("-CA-")) which |= (0x1<<kA) | (0x1<<kC);
1333 else { AliWarning(Form("Unknown trigger type %s\n",trClass->GetName())); continue;}
1334 //
1335 for (int ip=kNMasks;ip--;) {
1336 if ( !(which&(0x1<<ip)) || masks[ip] ) continue; // does not match or already done
1337 masks[ip] = (TObject*)bcMask;
1338 nFound++;
1339 }
1340 if (nFound==kNMasks) break;
1341 }
1342 //
1343 AliInfo("Reading mean bunch intensities from GRP/GRP/LHCData");
1344 AliLHCData* dipData = dynamic_cast<AliLHCData*> (entry->GetObject());
1345 //
1346 for (int ib=2;ib--;) {
1347 double intI,intNI;
1348 if (dipData && (dipData->GetMeanIntensity(ib,intI,intNI,&masks)>=0)) {
1349 fBeamInt[ib][0] = intI;
1350 fBeamInt[ib][1] = intNI;
1351 AliInfo(Form("Mean intensity for beam %d: Interacting:%.2e Non-Interacting:%.2e",ib,intI,intNI));
3d84ad67 1352 }
3d84ad67 1353 }
2af04ffd 1354 return kTRUE;
1355 //
3d84ad67 1356}
1357
1358
52dd4a8c 1359//_____________________________________________________________________________
21a3aa09 1360Bool_t AliReconstruction::Run(const char* input)
596a855f 1361{
21a3aa09 1362 // Run Run Run
52dd4a8c 1363 AliCodeTimerAuto("",0);
596a855f 1364
4b71572b 1365 InitRun(input);
1366 if (GetAbort() != TSelector::kContinue) return kFALSE;
1367
1368 TChain *chain = NULL;
1369 if (fRawReader && (chain = fRawReader->GetChain())) {
2a284cef 1370 Long64_t nEntries = (fLastEvent < 0) ? (TChain::kBigNumber) : (fLastEvent - fFirstEvent + 1);
4b71572b 1371 // Proof mode
1372 if (gProof) {
52dd4a8c 1373 // Temporary fix for long raw-data runs (until socket timeout handling in PROOF is revised)
1374 gProof->Exec("gEnv->SetValue(\"Proof.SocketActivityTimeout\",-1)", kTRUE);
6c6f2624 1375
1376 if (gGrid)
1377 gProof->Exec("TGrid::Connect(\"alien://\")",kTRUE);
1378
1379 TMessage::EnableSchemaEvolutionForAll(kTRUE);
1380 gProof->Exec("TMessage::EnableSchemaEvolutionForAll(kTRUE)",kTRUE);
1381
4b71572b 1382 gProof->AddInput(this);
81d57268 1383
1384 if (!ParseOutput()) return kFALSE;
1385
975320a0 1386 gProof->SetParameter("PROOF_MaxSlavesPerNode", 9999);
4b71572b 1387 chain->SetProof();
2a284cef 1388 chain->Process("AliReconstruction","",nEntries,fFirstEvent);
4b71572b 1389 }
1390 else {
2a284cef 1391 chain->Process(this,"",nEntries,fFirstEvent);
4b71572b 1392 }
1393 }
1394 else {
1395 Begin(NULL);
1396 if (GetAbort() != TSelector::kContinue) return kFALSE;
1397 SlaveBegin(NULL);
1398 if (GetAbort() != TSelector::kContinue) return kFALSE;
1399 //******* The loop over events
44e45fac 1400 AliInfo("Starting looping over events");
4b71572b 1401 Int_t iEvent = 0;
1402 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
1403 (fRawReader && fRawReader->NextEvent())) {
1404 if (!ProcessEvent(iEvent)) {
930e6e3e 1405 Abort("ProcessEvent",TSelector::kAbortFile);
1406 return kFALSE;
4b71572b 1407 }
1408 iEvent++;
1409 }
1410 SlaveTerminate();
1411 if (GetAbort() != TSelector::kContinue) return kFALSE;
1412 Terminate();
1413 if (GetAbort() != TSelector::kContinue) return kFALSE;
21a3aa09 1414 }
21a3aa09 1415
1416 return kTRUE;
1417}
1418
1419//_____________________________________________________________________________
4b71572b 1420void AliReconstruction::InitRawReader(const char* input)
21a3aa09 1421{
4b71572b 1422 // Init raw-reader and
21a3aa09 1423 // set the input in case of raw data
0a035be5 1424
1425 AliCodeTimerAuto("",0);
1426
4b71572b 1427 if (input) fRawInput = input;
1428 fRawReader = AliRawReader::Create(fRawInput.Data());
c35f192e 1429 if (!fRawReader) {
1430 if (fRawInput.IsNull()) {
1431 AliInfo("Reconstruction will run over digits");
1432 }
1433 else {
1434 AliFatal("Can not create raw-data reader ! Exiting...");
1435 }
1436 }
e0027792 1437
35042093 1438 if (!fEquipIdMap.IsNull() && fRawReader)
1439 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
1440
cd0b062e 1441 if (!fUseHLTData.IsNull()) {
1442 // create the RawReaderHLT which performs redirection of HLT input data for
1443 // the specified detectors
1444 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
1445 if (pRawReader) {
1446 fParentRawReader=fRawReader;
1447 fRawReader=pRawReader;
1448 } else {
1449 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
1450 }
1451 }
4b71572b 1452 AliSysInfo::AddStamp("CreateRawReader");
1453}
cd0b062e 1454
4b71572b 1455//_____________________________________________________________________________
1456void AliReconstruction::InitRun(const char* input)
1457{
1458 // Initialization of raw-reader,
1459 // run number, CDB etc.
52dd4a8c 1460 AliCodeTimerAuto("",0);
4b71572b 1461 AliSysInfo::AddStamp("Start");
1462
002c9d1b 1463 // Initialize raw-reader if any
4b71572b 1464 InitRawReader(input);
596a855f 1465
ec92bee0 1466 // Initialize the CDB storage
795e4a22 1467 InitCDB();
ec92bee0 1468
6bae477a 1469 // Set run number in CDBManager (if it is not already set by the user)
4b71572b 1470 if (!SetRunNumberFromData()) {
1471 Abort("SetRunNumberFromData", TSelector::kAbortProcess);
1472 return;
1473 }
002c9d1b 1474
795e4a22 1475 // Set CDB lock: from now on it is forbidden to reset the run number
1476 // or the default storage or to activate any further storage!
1477 SetCDBLock();
1478
002c9d1b 1479}
1480
1481//_____________________________________________________________________________
1482void AliReconstruction::Begin(TTree *)
1483{
1484 // Initialize AlReconstruction before
1485 // going into the event loop
1486 // Should follow the TSelector convention
1487 // i.e. initialize only the object on the client side
52dd4a8c 1488 AliCodeTimerAuto("",0);
db4aeca1 1489
b4fef0d2 1490 AliReconstruction *reco = NULL;
002c9d1b 1491 if (fInput) {
8fb1f1dc 1492 if ((reco = (AliReconstruction*)fInput->FindObject("AliReconstruction"))) {
002c9d1b 1493 *this = *reco;
002c9d1b 1494 }
1495 AliSysInfo::AddStamp("ReadInputInBegin");
1496 }
1497
6bae477a 1498 // Import ideal TGeo geometry and apply misalignment
1499 if (!gGeoManager) {
1500 TString geom(gSystem->DirName(fGAliceFileName));
1501 geom += "/geometry.root";
98e303d9 1502 AliGeomManager::LoadGeometry(geom.Data());
4b71572b 1503 if (!gGeoManager) {
1504 Abort("LoadGeometry", TSelector::kAbortProcess);
1505 return;
1506 }
281270d3 1507 AliSysInfo::AddStamp("LoadGeom");
ff5970a3 1508 TString detsToCheck=fRunLocalReconstruction;
4b71572b 1509 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) {
1510 Abort("CheckSymNamesLUT", TSelector::kAbortProcess);
1511 return;
1512 }
281270d3 1513 AliSysInfo::AddStamp("CheckGeom");
6bae477a 1514 }
8e245d15 1515
7ec0d3df 1516 Bool_t loadedFromSnapshot=kFALSE;
1517 Bool_t toCDBSnapshot=kFALSE;
1518 TString snapshotFileOut(""); // we could use fSnapshotFileName if we are not interested
1519 // in reading from and writing to a snapshot file at the same time
1520 if(TString(gSystem->Getenv("OCDB_SNAPSHOT_CREATE")) == TString("kTRUE")){
1521 toCDBSnapshot=kTRUE;
1522 //fFromCDBSnapshot=kFALSE;
1523 TString snapshotFile(gSystem->Getenv("OCDB_SNAPSHOT_FILENAME"));
1524 if(!(snapshotFile.IsNull() || snapshotFile.IsWhitespace()))
1525 snapshotFileOut = snapshotFile;
1526 else
1527 snapshotFileOut="OCDB.root";
1528 }
647d2bb8 1529 if(fFromCDBSnapshot){
1530 AliDebug(2,"Initializing from a CDB snapshot");
7ec0d3df 1531 loadedFromSnapshot = AliCDBManager::Instance()->InitFromSnapshot(fSnapshotFileName.Data());
647d2bb8 1532 }
1533
4b71572b 1534 if (!MisalignGeometry(fLoadAlignData)) {
1535 Abort("MisalignGeometry", TSelector::kAbortProcess);
1536 return;
1537 }
1538 AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
e0a6e696 1539 if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
281270d3 1540 AliSysInfo::AddStamp("MisalignGeom");
6bae477a 1541
8cb26cdf 1542 if (!InitGRP()) {
1543 Abort("InitGRP", TSelector::kAbortProcess);
1544 return;
1545 }
1546 AliSysInfo::AddStamp("InitGRP");
e0a6e696 1547 if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
8cb26cdf 1548
7ec0d3df 1549 if(!loadedFromSnapshot){
647d2bb8 1550 if (!LoadCDB()) {
1551 Abort("LoadCDB", TSelector::kAbortProcess);
1552 return;
1553 }
1554 AliSysInfo::AddStamp("LoadCDB");
4b71572b 1555 }
325aa76f 1556
a6dd87ad 1557 if (!LoadTriggerScalersCDB()) {
1558 Abort("LoadTriggerScalersCDB", TSelector::kAbortProcess);
1559 return;
1560 }
1561 AliSysInfo::AddStamp("LoadTriggerScalersCDB");
1562
52dd4a8c 1563 if (!LoadCTPTimeParamsCDB()) {
1564 Abort("LoadCTPTimeParamsCDB", TSelector::kAbortProcess);
1565 return;
1566 }
1567 AliSysInfo::AddStamp("LoadCTPTimeParamsCDB");
a6dd87ad 1568
bd26f597 1569 if (!ReadIntensityInfoCDB()) {
1570 Abort("ReadIntensityInfoCDB", TSelector::kAbortProcess);
1571 return;
1572 }
1573 AliSysInfo::AddStamp("ReadIntensityInfoCDB");
1574
7e88424f 1575 // Read the reconstruction parameters from OCDB
1576 if (!InitRecoParams()) {
002c9d1b 1577 AliWarning("Not all detectors have correct RecoParam objects initialized");
4b71572b 1578 }
1579 AliSysInfo::AddStamp("InitRecoParams");
1580
e0a6e696 1581 if(toCDBSnapshot)
7ec0d3df 1582 AliCDBManager::Instance()->DumpToSnapshotFile(snapshotFileOut.Data());
e0a6e696 1583 AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
1584 AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
7ec0d3df 1585
fd2b273c 1586 if (fInput && gProof) {
b4fef0d2 1587 if (reco) *reco = *this;
fd2b273c 1588
45a6dee6 1589 gGeoManager->SetName("Geometry");
fd2b273c 1590 gProof->AddInputData(gGeoManager,kTRUE);
002c9d1b 1591 gGeoManager = NULL;
fd2b273c 1592 gProof->AddInputData(const_cast<TMap*>(AliCDBManager::Instance()->GetEntryCache()),kTRUE);
002c9d1b 1593 fInput->Add(new TParameter<Int_t>("RunNumber",AliCDBManager::Instance()->GetRun()));
f7a1cc68 1594 AliMagF *magFieldMap = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
ead7b391 1595 magFieldMap->SetName("MagneticFieldMap");
fd2b273c 1596 gProof->AddInputData(magFieldMap,kTRUE);
42457748 1597 if (fAnalysis) {
1598 fAnalysis->SetName("Analysis");
1599 gProof->AddInputData(fAnalysis,kTRUE);
1600 }
002c9d1b 1601 }
4b71572b 1602
1603}
1604
1605//_____________________________________________________________________________
1606void AliReconstruction::SlaveBegin(TTree*)
1607{
1608 // Initialization related to run-loader,
1609 // vertexer, trackers, recontructors
1610 // In proof mode it is executed on the slave
52dd4a8c 1611 AliCodeTimerAuto("",0);
4b71572b 1612
db4aeca1 1613 TProofOutputFile *outProofFile = NULL;
81d57268 1614 if (fInput) {
1615 if (AliDebugLevel() > 0) fInput->Print();
ef5e52f6 1616 if (AliDebugLevel() > 10) fInput->Dump();
db4aeca1 1617 if (AliReconstruction *reco = (AliReconstruction*)fInput->FindObject("AliReconstruction")) {
1618 *this = *reco;
1619 }
4b71572b 1620 if (TGeoManager *tgeo = (TGeoManager*)fInput->FindObject("Geometry")) {
1621 gGeoManager = tgeo;
1622 AliGeomManager::SetGeometry(tgeo);
7e88424f 1623 }
281270d3 1624 if (TMap *entryCache = (TMap*)fInput->FindObject("CDBEntryCache")) {
1625 Int_t runNumber = -1;
1626 if (TProof::GetParameter(fInput,"RunNumber",runNumber) == 0) {
1627 AliCDBManager *man = AliCDBManager::Instance(entryCache,runNumber);
1628 man->SetCacheFlag(kTRUE);
1629 man->SetLock(kTRUE);
1630 man->Print();
1631 }
4b71572b 1632 }
ead7b391 1633 if (AliMagF *map = (AliMagF*)fInput->FindObject("MagneticFieldMap")) {
ef5e52f6 1634 AliMagF *newMap = new AliMagF(*map);
1635 if (!newMap->LoadParameterization()) {
1636 Abort("AliMagF::LoadParameterization", TSelector::kAbortProcess);
1637 return;
1638 }
1639 TGeoGlobalMagField::Instance()->SetField(newMap);
1640 TGeoGlobalMagField::Instance()->Lock();
4b71572b 1641 }
42457748 1642 if (!fAnalysis) {
1643 // Attempt to get the analysis manager from the input list
1644 fAnalysis = (AliAnalysisManager*)fInput->FindObject("Analysis");
1645 if (fAnalysis) AliInfo("==== Analysis manager retrieved from input list ====");
1646 }
81d57268 1647 if (TNamed *outputFileName = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE"))
1648 fProofOutputFileName = outputFileName->GetTitle();
1649 if (TNamed *outputLocation = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_LOCATION"))
1650 fProofOutputLocation = outputLocation->GetTitle();
1651 if (fInput->FindObject("PROOF_OUTPUTFILE_DATASET"))
1652 fProofOutputDataset = kTRUE;
1653 if (TNamed *archiveList = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_ARCHIVE"))
1654 fProofOutputArchive = archiveList->GetTitle();
1655 if (!fProofOutputFileName.IsNull() &&
1656 !fProofOutputLocation.IsNull() &&
1657 fProofOutputArchive.IsNull()) {
1658 if (!fProofOutputDataset) {
1659 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"M");
1660 outProofFile->SetOutputFileName(Form("%s%s",fProofOutputLocation.Data(),fProofOutputFileName.Data()));
1661 }
1662 else {
1663 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"DROV",fProofOutputLocation.Data());
1664 }
1665 if (AliDebugLevel() > 0) outProofFile->Dump();
db4aeca1 1666 fOutput->Add(outProofFile);
4b71572b 1667 }
002c9d1b 1668 AliSysInfo::AddStamp("ReadInputInSlaveBegin");
7e88424f 1669 }
42457748 1670 // Check if analysis was requested in the reconstruction event loop
1671 if (!fAnalysis) {
1672 // Attempt to connect in-memory singleton
1673 fAnalysis = AliAnalysisManager::GetAnalysisManager();
1674 if (fAnalysis) AliInfo(Form("==== Analysis manager <%s> found in memory ====", fAnalysis->GetName()));
1675 // Check if an analysis macro was specified
1676 if (!fAnalysis && !fAnalysisMacro.IsNull()) {
1677 // Run specified analysis macro
1678 gROOT->ProcessLine(Form(".x %s",fAnalysisMacro.Data()));
1679 fAnalysis = AliAnalysisManager::GetAnalysisManager();
1680 if (!fAnalysis) AliError(Form("No analysis manager produced by analysis macro %s", fAnalysisMacro.Data()));
1681 else AliInfo(Form("==== Analysis manager <%s> produced by analysis macro <%s> ====",
1682 fAnalysis->GetName(), fAnalysisMacro.Data()));
1683 }
1684 }
1685
4b71572b 1686 // get the run loader
1687 if (!InitRunLoader()) {
1688 Abort("InitRunLoader", TSelector::kAbortProcess);
1689 return;
1690 }
1691 AliSysInfo::AddStamp("LoadLoader");
1692
325aa76f 1693 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
2257f27e 1694
f08fc9f5 1695 // get trackers
b8cd5251 1696 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
4b71572b 1697 Abort("CreateTrackers", TSelector::kAbortProcess);
1698 return;
1699 }
1700 AliSysInfo::AddStamp("CreateTrackers");
24f7a148 1701
36711aa4 1702 // create the ESD output file and tree
db4aeca1 1703 if (!outProofFile) {
1704 ffile = TFile::Open("AliESDs.root", "RECREATE");
1705 ffile->SetCompressionLevel(2);
1706 if (!ffile->IsOpen()) {
1707 Abort("OpenESDFile", TSelector::kAbortProcess);
1708 return;
1709 }
1710 }
1711 else {
81d57268 1712 AliInfo(Form("Opening output PROOF file: %s/%s",
1713 outProofFile->GetDir(), outProofFile->GetFileName()));
db4aeca1 1714 if (!(ffile = outProofFile->OpenFile("RECREATE"))) {
1715 Abort(Form("Problems opening output PROOF file: %s/%s",
1716 outProofFile->GetDir(), outProofFile->GetFileName()),
1717 TSelector::kAbortProcess);
1718 return;
1719 }
596a855f 1720 }
46698ae4 1721
21a3aa09 1722 ftree = new TTree("esdTree", "Tree with ESD objects");
1723 fesd = new AliESDEvent();
1724 fesd->CreateStdContent();
8b12d288 1725 // add a so far non-std object to the ESD, this will
1726 // become part of the std content
1727 fesd->AddObject(new AliESDHLTDecision);
1728
32ba9c61 1729 fesd->WriteToTree(ftree);
1d99986f 1730 if (fWriteESDfriend) {
ee7c441c 1731 ffileF = TFile::Open("AliESDfriends.root", "RECREATE");
03a8000a 1732 ftreeF = new TTree("esdFriendTree", "Tree with ESD Friend objects");
ee7c441c 1733 fesdf = new AliESDfriend();
03a8000a 1734 ftreeF->Branch("ESDfriend.","AliESDfriend", &fesdf);
21a3aa09 1735 fesd->AddObject(fesdf);
ee7c441c 1736 ffile->cd();
1d99986f 1737 }
f9604a22 1738 ftree->GetUserInfo()->Add(fesd);
1739
1740 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1741 fhltesd = new AliESDEvent();
1742 fhltesd->CreateStdContent();
7491aea6 1743 // read the ESD template from CDB
1744 // HLT is allowed to put non-std content to its ESD, the non-std
1745 // objects need to be created before invocation of WriteToTree in
1746 // order to create all branches. Initialization is done from an
1747 // ESD layout template in CDB
1748 AliCDBManager* man = AliCDBManager::Instance();
1749 AliCDBPath hltESDConfigPath("HLT/ConfigHLT/esdLayout");
1750 AliCDBEntry* hltESDConfig=NULL;
1751 if (man->GetId(hltESDConfigPath)!=NULL &&
1752 (hltESDConfig=man->Get(hltESDConfigPath))!=NULL) {
1753 AliESDEvent* pESDLayout=dynamic_cast<AliESDEvent*>(hltESDConfig->GetObject());
1754 if (pESDLayout) {
1755 // init all internal variables from the list of objects
1756 pESDLayout->GetStdContent();
1757
1758 // copy content and create non-std objects
1759 *fhltesd=*pESDLayout;
1760 fhltesd->Reset();
1761 } else {
1762 AliError(Form("error setting hltEsd layout from %s: invalid object type",
1763 hltESDConfigPath.GetPath().Data()));
1764 }
1765 }
1766
f9604a22 1767 fhltesd->WriteToTree(fhlttree);
1768 fhlttree->GetUserInfo()->Add(fhltesd);
5728d3d5 1769
ac4a7581 1770 ProcInfo_t procInfo;
1771 gSystem->GetProcInfo(&procInfo);
73bbf779 1772 AliInfo(Form("Current memory usage %ld %ld", procInfo.fMemResident, procInfo.fMemVirtual));
8661738e 1773
325aa76f 1774 //QA
930e6e3e 1775 //Initialize the QA and start of cycle
f1c1204d 1776 if (fRunQA || fRunGlobalQA)
1777 InitQA() ;
aa3c69a9 1778
7167ae53 1779 //Initialize the Plane Efficiency framework
1780 if (fRunPlaneEff && !InitPlaneEff()) {
4b71572b 1781 Abort("InitPlaneEff", TSelector::kAbortProcess);
1782 return;
7167ae53 1783 }
aa3c69a9 1784
14dd053c 1785 if (strcmp(gProgName,"alieve") == 0)
1786 fRunAliEVE = InitAliEVE();
42457748 1787 // If we have an analysis manager, connect the AliRecoInputHandler here
1788 if (fAnalysis) {
1789 if (!dynamic_cast<AliRecoInputHandler*>(fAnalysis->GetInputEventHandler())) {
1790 AliError("Analysis manager used in reconstruction should use AliRecoInputHandler - \
1791 \n ->Replacing with AliRecoInputHandler instance.");
1792 delete fAnalysis->GetInputEventHandler();
1793 }
1794 // Set the event and other data pointers
1795 fRecoHandler = new AliRecoInputHandler();
1796 fRecoHandler->Init(ftree, "LOCAL");
1797 fRecoHandler->SetEvent(fesd);
1798 fRecoHandler->SetESDfriend(fesdf);
1799 fRecoHandler->SetHLTEvent(fhltesd);
1800 fRecoHandler->SetHLTTree(fhlttree);
1801 fAnalysis->SetInputEventHandler(fRecoHandler);
1802 // Enter external loop mode
1803 fAnalysis->SetExternalLoop(kTRUE);
1804 // Initialize analysis
1805 fAnalysis->StartAnalysis("local", (TTree*)0);
1806 // Connect ESD tree with the input container
1807 fAnalysis->GetCommonInputContainer()->SetData(ftree);
1808 }
4b71572b 1809 return;
21a3aa09 1810}
1811
1812//_____________________________________________________________________________
4b71572b 1813Bool_t AliReconstruction::Process(Long64_t entry)
1814{
1815 // run the reconstruction over a single entry
1816 // from the chain with raw data
52dd4a8c 1817 AliCodeTimerAuto("",0);
4b71572b 1818
1819 TTree *currTree = fChain->GetTree();
33314186 1820 AliRawVEvent *event = NULL;
4b71572b 1821 currTree->SetBranchAddress("rawevent",&event);
1822 currTree->GetEntry(entry);
1823 fRawReader = new AliRawReaderRoot(event);
42457748 1824 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
4b71572b 1825 delete fRawReader;
1826 fRawReader = NULL;
1827 delete event;
1828
1829 return fStatus;
1830}
1831
1832//_____________________________________________________________________________
1833void AliReconstruction::Init(TTree *tree)
1834{
0a035be5 1835 // Implementation of TSelector::Init()
1836 // method
4b71572b 1837 if (tree == 0) {
1838 AliError("The input tree is not found!");
1839 return;
1840 }
1841 fChain = tree;
1842}
1843
1844//_____________________________________________________________________________
1845Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
21a3aa09 1846{
1847 // run the reconstruction over a single event
1848 // The event loop is steered in Run method
1849
10d100d4 1850
470f88b0 1851 static Long_t oldMres=0;
1852 static Long_t oldMvir=0;
1853 static Float_t oldCPU=0;
d97f1dbe 1854 static Long_t aveDMres=0;
1855 static Long_t aveDMvir=0;
1856 static Float_t aveDCPU=0;
470f88b0 1857
52dd4a8c 1858 AliCodeTimerAuto("",0);
21a3aa09 1859
0a035be5 1860 AliESDpid pid;
10d100d4 1861
8d25d294 1862 AliSysInfo::AddStamp(Form("StartEv_%d",iEvent), 0,0,iEvent);
1863
21a3aa09 1864 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1865 fRunLoader->SetEventNumber(iEvent);
4018c387 1866 if (fRawReader)
1867 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1868 iEvent, iEvent);
21a3aa09 1869 fRunLoader->TreeE()->Fill();
5b3ea9c5 1870
396f89bc 1871 if (fRawReader && fRawReader->UseAutoSaveESD())
4b71572b 1872 fRunLoader->TreeE()->AutoSave("SaveSelf");
21a3aa09 1873 }
1874
1875 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
21a3aa09 1876 return kTRUE;
1877 }
1878
aa3c69a9 1879
16447f18 1880 fRunLoader->GetEvent(iEvent);
1881
7e88424f 1882 // Fill Event-info object
1883 GetEventInfo();
77ba28ba 1884 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo,fListOfCosmicTriggers);
d97f1dbe 1885
1886 ProcInfo_t procInfo;
1887 if(iEvent==fFirstEvent) {
1888 gSystem->GetProcInfo(&procInfo);
1889 oldMres=procInfo.fMemResident;
1890 oldMvir=procInfo.fMemVirtual;
1891 oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
1892 }
470f88b0 1893 AliInfo(Form("================================= Processing event %d of type %-10s ==================================", iEvent,fRecoParam.PrintEventSpecie()));
7e88424f 1894
8d25d294 1895 AliSysInfo::AddStamp(Form("StartReco_%d",iEvent), 0,0,iEvent);
1896
a00021a7 1897 // Set the reco-params
1898 {
1899 TString detStr = fLoadCDB;
ac4a7581 1900 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
a00021a7 1901 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1902 AliReconstructor *reconstructor = GetReconstructor(iDet);
1903 if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
57acd2d2 1904 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
1905 reconstructor->SetRecoParam(par);
0a035be5 1906 reconstructor->GetPidSettings(&pid);
10d100d4 1907 reconstructor->SetEventInfo(&fEventInfo);
57acd2d2 1908 if (fRunQA) {
c3c10397 1909 AliQAManager::QAManager()->SetEventInfo(&fEventInfo) ;
eca4fa66 1910 AliQAManager::QAManager()->SetRecoParam(iDet, par) ;
619aafe6 1911 if (par) AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(par->GetEventSpecie())) ;
57acd2d2 1912 }
a00021a7 1913 }
1914 }
92664bc8 1915 //
1916 if (fRunQA || fRunGlobalQA) AliQADataMaker::SetEventTrigClasses(fEventInfo.GetTriggerClasses()); // RS: select which histo clones are to be filled
1917 //
9dad1020 1918 if (fRunQA) {
1919 const AliDetectorRecoParam *grppar = fRecoParam.GetDetRecoParam(kNDetectors);
1920 AliQAManager::QAManager()->SetRecoParam(AliQAv1::kGLOBAL, grppar) ;
1921 AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(grppar->GetEventSpecie())) ;
1922 }
a00021a7 1923 }
1924
ca13fb87 1925 // QA on single raw
514cb8c7 1926 if (fRunQA && IsInTasks(AliQAv1::kRAWS)) {
eca4fa66 1927 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1928 AliQAManager::QAManager()->RunOneEvent(fRawReader) ;
8d25d294 1929 AliSysInfo::AddStamp(Form("RawQA_%d",iEvent), 0,0,iEvent);
57acd2d2 1930 }
d506c543 1931 // local single event reconstruction
b26c3770 1932 if (!fRunLocalReconstruction.IsNull()) {
d506c543 1933 TString detectors=fRunLocalReconstruction;
a441bf51 1934 // run HLT event reconstruction first
d506c543 1935 // ;-( IsSelected changes the string
1936 if (IsSelected("HLT", detectors) &&
1937 !RunLocalEventReconstruction("HLT")) {
4b71572b 1938 if (fStopOnError) {CleanUp(); return kFALSE;}
a441bf51 1939 }
1940 detectors=fRunLocalReconstruction;
1941 detectors.ReplaceAll("HLT", "");
1942 if (!RunLocalEventReconstruction(detectors)) {
13effe3f 1943 if (fStopOnError) {
1944 CleanUp();
1945 return kFALSE;
1946 }
b26c3770 1947 }
1948 }
1949
6b3a883f 1950
1951 // fill Event header information from the RawEventHeader
1952 if (fRawReader){FillRawEventHeaderESD(fesd);}
1953 if (fRawReader){FillRawEventHeaderESD(fhltesd);}
1954
21a3aa09 1955 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1956 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
7b649c02 1957
1958 ((AliESDRun*)fesd->GetESDRun())->SetDetectorsInDAQ(fRunInfo->GetDetectorMask());
1959 ((AliESDRun*)fhltesd->GetESDRun())->SetDetectorsInDAQ(fRunInfo->GetDetectorMask());
1960 ((AliESDRun*)fesd->GetESDRun())->SetDetectorsInReco(AliDAQ::DetectorPatternOffline(fFillESD.Data()));
1961 ((AliESDRun*)fhltesd->GetESDRun())->SetDetectorsInReco(AliDAQ::DetectorPatternOffline(fFillESD.Data()));
1962
21a3aa09 1963 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1964 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
fd2e2210 1965
1966 fesd->SetEventSpecie(fRecoParam.GetEventSpecie());
1967 fhltesd->SetEventSpecie(fRecoParam.GetEventSpecie());
46698ae4 1968
d6ee376f 1969 // Set magnetic field from the tracker
21a3aa09 1970 fesd->SetMagneticField(AliTracker::GetBz());
1971 fhltesd->SetMagneticField(AliTracker::GetBz());
33fe5eb1 1972 //
3d84ad67 1973 AliESDRun *esdRun,*esdRunH;
1974 esdRun = (AliESDRun*)fesd->GetESDRun();
1975 esdRunH = (AliESDRun*)fhltesd->GetESDRun();
1976 esdRun->SetBeamEnergyIsSqrtSHalfGeV();
1977 esdRunH->SetBeamEnergyIsSqrtSHalfGeV();
1978 //
1979 for (int ib=2;ib--;) for (int it=2;it--;) {
1980 esdRun->SetMeanIntensity(ib,it, fBeamInt[ib][it]);
1981 esdRunH->SetMeanIntensity(ib,it, fBeamInt[ib][it]);
1982 }
c587bcde 1983 //
91460b26 1984 fesd->SetBeamEnergy(fGRPData->GetBeamEnergy());
1985 fesd->SetBeamType(fGRPData->GetBeamType().Data());
1986 fesd->SetBeamParticle(fGRPData->GetSingleBeamType(0).Atoi(),0);
1987 fesd->SetBeamParticle(fGRPData->GetSingleBeamType(1).Atoi(),1);
1988 fhltesd->SetBeamEnergy(fGRPData->GetBeamEnergy());
1989 fhltesd->SetBeamType(fGRPData->GetBeamType().Data());
1990 fhltesd->SetBeamParticle(fGRPData->GetSingleBeamType(0).Atoi(),0);
1991 fhltesd->SetBeamParticle(fGRPData->GetSingleBeamType(1).Atoi(),1);
1992 //
33fe5eb1 1993 AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1994 if (fld) { // set info needed for field initialization
1995 fesd->SetCurrentL3(fld->GetCurrentSol());
1996 fesd->SetCurrentDip(fld->GetCurrentDip());
33fe5eb1 1997 fesd->SetUniformBMap(fld->IsUniform());
1998 fesd->SetBInfoStored();
1999 //
2000 fhltesd->SetCurrentL3(fld->GetCurrentSol());
2001 fhltesd->SetCurrentDip(fld->GetCurrentDip());
33fe5eb1 2002 fhltesd->SetUniformBMap(fld->IsUniform());
2003 fhltesd->SetBInfoStored();
2004 }
2005 //
71f6cda4 2006 // Set most probable pt, for B=0 tracking
9257a1bd 2007 // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
ac4a7581 2008 const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(kNDetectors));
71f6cda4 2009 if (grpRecoParam) AliExternalTrackParam::SetMostProbablePt(grpRecoParam->GetMostProbablePt());
46698ae4 2010
2e3550da 2011 // Fill raw-data error log into the ESD
21a3aa09 2012 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
2e3550da 2013
8d25d294 2014 AliSysInfo::AddStamp(Form("FillHeadErrs_%d",iEvent), 0,0,iEvent);
2015
2257f27e 2016 // vertex finder
2017 if (fRunVertexFinder) {
4b71572b 2018 if (!RunVertexFinder(fesd)) {
2019 if (fStopOnError) {CleanUp(); return kFALSE;}
2257f27e 2020 }
8d25d294 2021 AliSysInfo::AddStamp(Form("VtxFinder_%d",iEvent), 0,0,iEvent);
2257f27e 2022 }
2023
58e8dc31 2024 // For Plane Efficiency: run the SPD trackleter
2025 if (fRunPlaneEff && fSPDTrackleter) {
2026 if (!RunSPDTrackleting(fesd)) {
2027 if (fStopOnError) {CleanUp(); return kFALSE;}
2028 }
8d25d294 2029 AliSysInfo::AddStamp(Form("TrackletEff_%d",iEvent), 0,0,iEvent);
58e8dc31 2030 }
2031
e66fbafb 2032 // Muon tracking
b8cd5251 2033 if (!fRunTracking.IsNull()) {
e66fbafb 2034 if (fRunMuonTracking) {
21a3aa09 2035 if (!RunMuonTracking(fesd)) {
4b71572b 2036 if (fStopOnError) {CleanUp(); return kFALSE;}
24f7a148 2037 }
596a855f 2038 }
8d25d294 2039 AliSysInfo::AddStamp(Form("TrackingMUON_%d",iEvent), 0,0,iEvent);
596a855f 2040 }
2041
e66fbafb 2042 // barrel tracking
2043 if (!fRunTracking.IsNull()) {
0a035be5 2044 if (!RunTracking(fesd,pid)) {
4b71572b 2045 if (fStopOnError) {CleanUp(); return kFALSE;}
e66fbafb 2046 }
2047 }
21c573b7 2048
596a855f 2049 // fill ESD
2050 if (!fFillESD.IsNull()) {
d506c543 2051 TString detectors=fFillESD;
f6806ad3 2052 // run HLT first and on hltesd
d506c543 2053 // ;-( IsSelected changes the string
2054 if (IsSelected("HLT", detectors) &&
2055 !FillESD(fhltesd, "HLT")) {
4b71572b 2056 if (fStopOnError) {CleanUp(); return kFALSE;}
f6806ad3 2057 }
2058 detectors=fFillESD;
d5105682 2059 // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
2060 if (detectors.Contains("ALL")) {
2061 detectors="";
ac4a7581 2062 for (Int_t idet=0; idet<kNDetectors; ++idet){
d5105682 2063 detectors += fgkDetectorName[idet];
2064 detectors += " ";
2065 }
2066 }
f6806ad3 2067 detectors.ReplaceAll("HLT", "");
2068 if (!FillESD(fesd, detectors)) {
4b71572b 2069 if (fStopOnError) {CleanUp(); return kFALSE;}
596a855f 2070 }
2071 }
f7812afc 2072
b647652d 2073
21a3aa09 2074 ffile->cd();
a6ee503a 2075
3c3709c4 2076 //
67be5c77 2077 // Propagate track to the beam pipe (if not already done by ITS)
3c3709c4 2078 //
21a3aa09 2079 const Int_t ntracks = fesd->GetNumberOfTracks();
3c3709c4 2080 const Double_t kRadius = 2.8; //something less than the beam pipe radius
2081
2082 TObjArray trkArray;
2083 UShort_t *selectedIdx=new UShort_t[ntracks];
2084
2085 for (Int_t itrack=0; itrack<ntracks; itrack++){
98a50ff3 2086 const Double_t kMaxStep = 1; //max step over the material
3c3709c4 2087 Bool_t ok;
2088
21a3aa09 2089 AliESDtrack *track = fesd->GetTrack(itrack);
3c3709c4 2090 if (!track) continue;
2091
2092 AliExternalTrackParam *tpcTrack =
2093 (AliExternalTrackParam *)track->GetTPCInnerParam();
bcabd6af 2094 ok = kFALSE;
2095 if (tpcTrack)
2096 ok = AliTracker::
52dd4a8c 2097 PropagateTrackToBxByBz(tpcTrack,kRadius,track->GetMass(),kMaxStep,kFALSE);
43c9dae1 2098
3c3709c4 2099 if (ok) {
2100 Int_t n=trkArray.GetEntriesFast();
2101 selectedIdx[n]=track->GetID();
2102 trkArray.AddLast(tpcTrack);
2103 }
2104
3d65e645 2105 //Tracks refitted by ITS should already be at the SPD vertex
2106 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
2107
2108 AliTracker::
52dd4a8c 2109 PropagateTrackToBxByBz(track,kRadius,track->GetMass(),kMaxStep,kFALSE);
2110 Double_t x[3]; track->GetXYZ(x);
2111 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2112 track->RelateToVertexBxByBz(fesd->GetPrimaryVertexSPD(), b, kVeryBig);
3c3709c4 2113
3c3709c4 2114 }
8d25d294 2115 AliSysInfo::AddStamp(Form("RelToSPDVtx_%d",iEvent), 0,0,iEvent);
3c3709c4 2116 //
2117 // Improve the reconstructed primary vertex position using the tracks
2118 //
59224b2b 2119 Bool_t runVertexFinderTracks = fRunVertexFinderTracks;
2120 if(fesd->GetPrimaryVertexSPD()) {
2121 TString vtitle = fesd->GetPrimaryVertexSPD()->GetTitle();
2122 if(vtitle.Contains("cosmics")) {
2123 runVertexFinderTracks=kFALSE;
2124 }
c060d7fe 2125 }
a00021a7 2126
2127 if (runVertexFinderTracks) {
3c3709c4 2128 // TPC + ITS primary vertex
f09c879d 2129 ftVertexer->SetITSMode();
f2a195c1 2130 ftVertexer->SetConstraintOff();
a00021a7 2131 // get cuts for vertexer from AliGRPRecoParam
1c7554f9 2132 Bool_t constrSPD=kFALSE;
a00021a7 2133 if (grpRecoParam) {
2134 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
2135 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
8eaa1a42 2136 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer,nCutsVertexer);
2137 ftVertexer->SetCuts(cutsVertexer,nCutsVertexer);
a00021a7 2138 delete [] cutsVertexer; cutsVertexer = NULL;
1c7554f9 2139 if(grpRecoParam->GetVertexerTracksConstraintITS()) {
2140 if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius){
2141 ftVertexer->SetVtxStart(fDiamondProfile); // apply constraint only if sigmax is smaller than the beam pipe radius
2142 }else{
2143 if(fDiamondProfileSPD && fDiamondProfileSPD->GetXRes()<kRadius){
2144 ftVertexer->SetVtxStart(fDiamondProfileSPD);
2145 constrSPD=kTRUE;
2146 }
2147 }
dd15203b 2148 }
43c9dae1 2149 }
21a3aa09 2150 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
3c3709c4 2151 if (pvtx) {
1c7554f9 2152 if(constrSPD){
2153 TString title=pvtx->GetTitle();
2154 title.Append("SPD");
2155 pvtx->SetTitle(title);
2156 }
3c3709c4 2157 if (pvtx->GetStatus()) {
c264b61b 2158 fesd->SetPrimaryVertexTracks(pvtx);
3c3709c4 2159 for (Int_t i=0; i<ntracks; i++) {
21a3aa09 2160 AliESDtrack *t = fesd->GetTrack(i);
52dd4a8c 2161 Double_t x[3]; t->GetXYZ(x);
2162 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2163 t->RelateToVertexBxByBz(pvtx, b, kVeryBig);
3c3709c4 2164 }
2165 }
9bcaa1d7 2166 delete pvtx; pvtx=NULL;
3c3709c4 2167 }
8d25d294 2168 AliSysInfo::AddStamp(Form("VtxTrk_%d",iEvent), 0,0,iEvent);
3c3709c4 2169
2170 // TPC-only primary vertex
f09c879d 2171 ftVertexer->SetTPCMode();
f2a195c1 2172 ftVertexer->SetConstraintOff();
a00021a7 2173 // get cuts for vertexer from AliGRPRecoParam
2174 if (grpRecoParam) {
2175 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
2176 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
8eaa1a42 2177 grpRecoParam->GetVertexerTracksCutsTPC(cutsVertexer,nCutsVertexer);
2178 ftVertexer->SetCuts(cutsVertexer,nCutsVertexer);
a00021a7 2179 delete [] cutsVertexer; cutsVertexer = NULL;
dd15203b 2180 if(fDiamondProfileTPC && grpRecoParam->GetVertexerTracksConstraintTPC()) {
2181 if(fDiamondProfileTPC->GetXRes()<kRadius) ftVertexer->SetVtxStart(fDiamondProfileTPC); // apply constraint only if sigmax is smaller than the beam pipe radius
2182 }
43c9dae1 2183 }
21a3aa09 2184 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
3c3709c4 2185 if (pvtx) {
2186 if (pvtx->GetStatus()) {
21a3aa09 2187 fesd->SetPrimaryVertexTPC(pvtx);
3d65e645 2188 for (Int_t i=0; i<ntracks; i++) {
2189 AliESDtrack *t = fesd->GetTrack(i);
52dd4a8c 2190 Double_t x[3]; t->GetXYZ(x);
2191 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2192 t->RelateToVertexTPCBxByBz(pvtx, b, kVeryBig);
3c3709c4 2193 }
2194 }
9bcaa1d7 2195 delete pvtx; pvtx=NULL;
3c3709c4 2196 }
8d25d294 2197 AliSysInfo::AddStamp(Form("VtxTPC_%d",iEvent), 0,0,iEvent);
3c3709c4 2198
2199 }
2200 delete[] selectedIdx;
2201
1c7554f9 2202 if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius) fesd->SetDiamond(fDiamondProfile);
2203 else fesd->SetDiamond(fDiamondProfileSPD);
c5e3e5d1 2204
d1683eef 2205 if (fRunV0Finder) {
2206 // V0 finding
2207 AliV0vertexer vtxer;
61a14552 2208 // get cuts for V0vertexer from AliGRPRecoParam
2209 if (grpRecoParam) {
2210 Int_t nCutsV0vertexer = grpRecoParam->GetVertexerV0NCuts();
2211 Double_t *cutsV0vertexer = new Double_t[nCutsV0vertexer];
2212 grpRecoParam->GetVertexerV0Cuts(cutsV0vertexer);
2213 vtxer.SetCuts(cutsV0vertexer);
2214 delete [] cutsV0vertexer; cutsV0vertexer = NULL;
2215 }
21a3aa09 2216 vtxer.Tracks2V0vertices(fesd);
8d25d294 2217 AliSysInfo::AddStamp(Form("V0Finder_%d",iEvent), 0,0,iEvent);
5e4ff34d 2218
d1683eef 2219 if (fRunCascadeFinder) {
2220 // Cascade finding
2221 AliCascadeVertexer cvtxer;
61a14552 2222 // get cuts for CascadeVertexer from AliGRPRecoParam
2223 if (grpRecoParam) {
2224 Int_t nCutsCascadeVertexer = grpRecoParam->GetVertexerCascadeNCuts();
2225 Double_t *cutsCascadeVertexer = new Double_t[nCutsCascadeVertexer];
2226 grpRecoParam->GetVertexerCascadeCuts(cutsCascadeVertexer);
2227 cvtxer.SetCuts(cutsCascadeVertexer);
2228 delete [] cutsCascadeVertexer; cutsCascadeVertexer = NULL;
2229 }
21a3aa09 2230 cvtxer.V0sTracks2CascadeVertices(fesd);
8d25d294 2231 AliSysInfo::AddStamp(Form("CascadeFinder_%d",iEvent), 0,0,iEvent);
d1683eef 2232 }
5e4ff34d 2233 }
c8122432 2234
50f012a8 2235 // AdC+FN
2236 if (fReconstructor[3])
2237 GetReconstructor(3)->FillEventTimeWithTOF(fesd,&pid);
2238
2239 // combined PID
2240 pid.MakePID(fesd);
2241
2242 if (fFillTriggerESD) {
2243 if (!FillTriggerESD(fesd)) {
2244 if (fStopOnError) {CleanUp(); return kFALSE;}
2245 }
2246 }
2247 // Always fill scalers
2248 if (!FillTriggerScalers(fesd)) {
2249 if (fStopOnError) {CleanUp(); return kFALSE;}
2250 }
2251
8d25d294 2252 AliSysInfo::AddStamp(Form("FillVaria_%d",iEvent), 0,0,iEvent);
2253
c8122432 2254 // write ESD
8d25d294 2255 if (fCleanESD) {
2256 CleanESD(fesd);
2257 AliSysInfo::AddStamp(Form("CleanESD_%d",iEvent), 0,0,iEvent);
2258 }
c8122432 2259 //
1f9831ab 2260 // RS run updated trackleter: since we want to mark the clusters used by tracks and also mark the
2261 // tracks interpreted as primary, this step should be done in the very end, when full
2262 // ESD info is available (particulalry, V0s)
2263 // vertex finder
c8122432 2264 if (fRunMultFinder) {
2265 if (!RunMultFinder(fesd)) {
2266 if (fStopOnError) {CleanUp(); return kFALSE;}
2267 }
8d25d294 2268 AliSysInfo::AddStamp(Form("MultFinder_%d",iEvent), 0,0,iEvent);
c8122432 2269 }
854c6476 2270
514cb8c7 2271 if (fRunQA && IsInTasks(AliQAv1::kESDS)) {
eca4fa66 2272 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
aeb8fc30 2273 AliQAManager::QAManager()->RunOneEvent(fesd, fhltesd) ;
8d25d294 2274 AliSysInfo::AddStamp(Form("RunQA_%d",iEvent), 0,0,iEvent);
57acd2d2 2275 }
bea94759 2276 if (fRunGlobalQA) {
eca4fa66 2277 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
4018c387 2278 if (qadm)
57acd2d2 2279 qadm->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
514cb8c7 2280 if (qadm && IsInTasks(AliQAv1::kESDS))
4e25ac79 2281 qadm->Exec(AliQAv1::kESDS, fesd);
8d25d294 2282 AliSysInfo::AddStamp(Form("RunGlobQA_%d",iEvent), 0,0,iEvent);
b03591ab 2283 }
854c6476 2284
8b12d288 2285 // copy HLT decision from HLTesd to esd
2286 // the most relevant information is stored in a reduced container in the esd,
2287 // while the full information can be found in the HLTesd
2288 TObject* pHLTSrc=fhltesd->FindListObject(AliESDHLTDecision::Name());
2289 TObject* pHLTTgt=fesd->FindListObject(AliESDHLTDecision::Name());
2290 if (pHLTSrc && pHLTTgt) {
2291 pHLTSrc->Copy(*pHLTTgt);
2292 }
3ba71cb5 2293 //
2294 // Perform analysis of this event if requested
2295 // RS: Should be done before WriteESDfriend, since the latter may clean the esdfriend
2296 if (fAnalysis) {
2297 fRecoHandler->BeginEvent(iEvent);
2298 fAnalysis->ExecAnalysis();
2299 fRecoHandler->FinishEvent();
8d25d294 2300 AliSysInfo::AddStamp(Form("Analysis_%d",iEvent), 0,0,iEvent);
3ba71cb5 2301 }
2302 //
ee7c441c 2303 if (fWriteESDfriend)
21a3aa09 2304 fesd->GetESDfriend(fesdf);
ee7c441c 2305
21a3aa09 2306 ftree->Fill();
fc01854a 2307 if (fWriteESDfriend) {
f00558b6 2308 WriteESDfriend();
fc01854a 2309 }
2d91a353 2310 // Auto-save the ESD tree in case of prompt reco @P2
396f89bc 2311 if (fRawReader && fRawReader->UseAutoSaveESD()) {
2d91a353 2312 ftree->AutoSave("SaveSelf");
ee7c441c 2313 if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
be103ac8 2314 }
2d91a353 2315
500d54ab 2316 // write HLT ESD
21a3aa09 2317 fhlttree->Fill();
1d99986f 2318
8d25d294 2319 AliSysInfo::AddStamp(Form("WriteESDs_%d",iEvent), 0,0,iEvent);
2320
14dd053c 2321 // call AliEVE
2322 if (fRunAliEVE) RunAliEVE();
0c4df52e 2323 //
21a3aa09 2324 fesd->Reset();
2325 fhltesd->Reset();
5728d3d5 2326 if (fWriteESDfriend) {
21a3aa09 2327 fesdf->~AliESDfriend();
2328 new (fesdf) AliESDfriend(); // Reset...
5728d3d5 2329 }
a5fa6165 2330
ac4a7581 2331 gSystem->GetProcInfo(&procInfo);
d97f1dbe 2332 Long_t dMres=(procInfo.fMemResident-oldMres)/1024;
2333 Long_t dMvir=(procInfo.fMemVirtual-oldMvir)/1024;
2334 Float_t dCPU=procInfo.fCpuUser+procInfo.fCpuSys-oldCPU;
2335 aveDMres+=(dMres-aveDMres)/(iEvent-fFirstEvent+1);
2336 aveDMvir+=(dMvir-aveDMvir)/(iEvent-fFirstEvent+1);
2337 aveDCPU+=(dCPU-aveDCPU)/(iEvent-fFirstEvent+1);
73bbf779 2338 AliInfo(Form("======================= End Event %d: Res %ld(%3ld <%3ld>) Vir %ld(%3ld <%3ld>) CPU %5.2f <%5.2f> ===================",
d97f1dbe 2339 iEvent, procInfo.fMemResident/1024, dMres, aveDMres, procInfo.fMemVirtual/1024, dMvir, aveDMvir, dCPU, aveDCPU));
470f88b0 2340 oldMres=procInfo.fMemResident;
2341 oldMvir=procInfo.fMemVirtual;
2342 oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
a5fa6165 2343
ca13fb87 2344 fEventInfo.Reset();
ac4a7581 2345 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
42ec5d3d 2346 if (fReconstructor[iDet]) {
a00021a7 2347 fReconstructor[iDet]->SetRecoParam(NULL);
42ec5d3d 2348 fReconstructor[iDet]->SetEventInfo(NULL);
2349 }
1f26f3e7 2350 if (fTracker[iDet]) fTracker[iDet]->SetEventInfo(NULL);
ca13fb87 2351 }
2352
53c8f690 2353 if (fRunQA || fRunGlobalQA)
eca4fa66 2354 AliQAManager::QAManager()->Increment() ;
0c4df52e 2355
ca13fb87 2356 return kTRUE;
21a3aa09 2357}
2358
2359//_____________________________________________________________________________
4b71572b 2360void AliReconstruction::SlaveTerminate()
21a3aa09 2361{
4b71572b 2362 // Finalize the run on the slave side
21a3aa09 2363 // Called after the exit
2364 // from the event loop
52dd4a8c 2365 AliCodeTimerAuto("",0);
42457748 2366 // If analysis was done during reconstruction, we need to call SlaveTerminate for it
2367 if (fAnalysis) {
2368 fAnalysis->PackOutput(fOutput);
2369 fAnalysis->SetSkipTerminate(kTRUE);
2370 fAnalysis->Terminate();
2371 }
21a3aa09 2372
2373 if (fIsNewRunLoader) { // galice.root didn't exist
2374 fRunLoader->WriteHeader("OVERWRITE");
5b3ea9c5 2375 fRunLoader->WriteTrigger("OVERWRITE");
21a3aa09 2376 fRunLoader->CdGAFile();
2377 fRunLoader->Write(0, TObject::kOverwrite);
2378 }
2379
f747912b 2380 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
2381 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
2382
2383 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
2384 cdbMapCopy->SetOwner(1);
2385 cdbMapCopy->SetName("cdbMap");
2386 TIter iter(cdbMap->GetTable());
2387
2388 TPair* pair = 0;
2389 while((pair = dynamic_cast<TPair*> (iter.Next()))){
2390 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
c7a22819 2391 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
2392 if (keyStr && valStr)
2393 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
f747912b 2394 }
2395
2396 TList *cdbListCopy = new TList();
2397 cdbListCopy->SetOwner(1);
2398 cdbListCopy->SetName("cdbList");
2399
2400 TIter iter2(cdbList);
2401
b940cb9b 2402 AliCDBId* id=0;
e84c88f5 2403 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
a4970db9 2404 cdbListCopy->Add(new TObjString(id->ToString().Data()));
f747912b 2405 }
2406
21a3aa09 2407 ftree->GetUserInfo()->Add(cdbMapCopy);
2408 ftree->GetUserInfo()->Add(cdbListCopy);
abe0c04e 2409
27aa8455 2410 // Add the AliRoot version that created this file
2411 TString sVersion("aliroot ");
2412 sVersion += ALIROOT_SVN_BRANCH;
2413 sVersion += ":";
2414 sVersion += ALIROOT_SVN_REVISION;
2415 sVersion += "; root ";
2416 sVersion += ROOT_SVN_BRANCH;
2417 sVersion += ":";
2418 sVersion += ROOT_SVN_REVISION;
2419 sVersion += "; metadata ";
2420 sVersion += gSystem->Getenv("PRODUCTION_METADATA");
2421
2422
2423 TNamed * alirootVersion = new TNamed("alirootVersion",sVersion.Data());
2424 ftree->GetUserInfo()->Add(alirootVersion); // The list becomes owner of alirootVersion
46698ae4 2425
21a3aa09 2426 ffile->cd();
aa3c69a9 2427
562dd0b4 2428 // we want to have only one tree version number
21a3aa09 2429 ftree->Write(ftree->GetName(),TObject::kOverwrite);
63314086 2430 fhlttree->Write(fhlttree->GetName(),TObject::kOverwrite);
f3a97c86 2431
ee7c441c 2432 if (fWriteESDfriend) {
2433 ffileF->cd();
2434 ftreeF->Write(ftreeF->GetName(),TObject::kOverwrite);
2435 }
2436
a7a1e1c7 2437// Finish with Plane Efficiency evaluation: before of CleanUp !!!
2438 if (fRunPlaneEff && !FinishPlaneEff()) {
2439 AliWarning("Finish PlaneEff evaluation failed");
2440 }
2441
323a7f87 2442 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
0d45a46a 2443 if (fReconstructor[iDet]) fReconstructor[iDet]->Terminate();
323a7f87 2444 }
930e6e3e 2445 // End of cycle for the in-loop
87da0921 2446
2447 if (fRunQA || fRunGlobalQA) {
5cbed243 2448 AliQAManager::QAManager()->EndOfCycle() ;
81d57268 2449 if (fInput &&
2450 !fProofOutputLocation.IsNull() &&
2451 fProofOutputArchive.IsNull() &&
2452 !fProofOutputDataset) {
2453 TString qaOutputFile(Form("%sMerged.%s.Data.root",
2454 fProofOutputLocation.Data(),
2455 AliQAv1::GetQADataFileName()));
2456 TProofOutputFile *qaProofFile = new TProofOutputFile(Form("Merged.%s.Data.root",
2457 AliQAv1::GetQADataFileName()));
2458 qaProofFile->SetOutputFileName(qaOutputFile.Data());
2459 if (AliDebugLevel() > 0) qaProofFile->Dump();
2460 fOutput->Add(qaProofFile);
2461 MergeQA(qaProofFile->GetFileName());
87da0921 2462 }
2463 else {
2464 MergeQA();
2465 }
2466 }
2467
4b71572b 2468 gROOT->cd();
2469 CleanUp();
81d57268 2470
2471 if (fInput) {
2472 if (!fProofOutputFileName.IsNull() &&
2473 !fProofOutputLocation.IsNull() &&
2474 fProofOutputDataset &&
2475 !fProofOutputArchive.IsNull()) {
2476 TProofOutputFile *zipProofFile = new TProofOutputFile(fProofOutputFileName.Data(),
2477 "DROV",
2478 fProofOutputLocation.Data());
2479 if (AliDebugLevel() > 0) zipProofFile->Dump();
2480 fOutput->Add(zipProofFile);
2481 TString fileList(fProofOutputArchive.Data());
2482 fileList.ReplaceAll(","," ");
38c18bf1 2483 TString command;
2484#if ROOT_SVN_REVISION >= 30174
2485 command.Form("zip -n root %s/%s %s",zipProofFile->GetDir(kTRUE),zipProofFile->GetFileName(),fileList.Data());
2486#else
2487 command.Form("zip -n root %s/%s %s",zipProofFile->GetDir(),zipProofFile->GetFileName(),fileList.Data());
2488#endif
2489 AliInfo(Form("Executing: %s",command.Data()));
2490 gSystem->Exec(command.Data());
81d57268 2491 }
2492 }
4b71572b 2493}
2494
2495//_____________________________________________________________________________
2496void AliReconstruction::Terminate()
2497{
f3a97c86 2498 // Create tags for the events in the ESD tree (the ESD tree is always present)
2499 // In case of empty events the tags will contain dummy values
52dd4a8c 2500 AliCodeTimerAuto("",0);
4b71572b 2501
e6d66370 2502 // Do not call the ESD tag creator in case of PROOF-based reconstruction
2503 if (!fInput) {
2504 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
2505 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData, AliQAv1::Instance()->GetQA(), AliQAv1::Instance()->GetEventSpecies(), AliQAv1::kNDET, AliRecoParam::kNSpecies);
9bcaa1d7 2506 delete esdtagCreator;
e6d66370 2507 }
e84c88f5 2508
795e4a22 2509 // Cleanup of CDB manager: cache and active storages!
2510 AliCDBManager::Instance()->ClearCache();
596a855f 2511}
2512
2513//_____________________________________________________________________________
b26c3770 2514Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
2515{
2516// run the local reconstruction
aa3c69a9 2517
0f88822a 2518 static Int_t eventNr=0;
52dd4a8c 2519 AliCodeTimerAuto("",0)
b26c3770 2520
2521 TString detStr = detectors;
9533b54d 2522 // execute HLT reconstruction first since other detector reconstruction
2523 // might depend on HLT data
2524 // key 'HLT' is removed from detStr by IsSelected
2525 if (!IsSelected("HLT", detStr)) {
2526 AliReconstructor* reconstructor = GetReconstructor(kNDetectors-1);
2527 if (reconstructor) {
2528 // there is no AliLoader for HLT, see
2529 // https://savannah.cern.ch/bugs/?35473
2530 AliInfo("running reconstruction for HLT");
f6806ad3 2531 if (fRawReader) {
820b4d9e 2532 AliInfo("reconstructor->Reconstruct(fRawReader, NULL)");
44ed7a66 2533 reconstructor->Reconstruct(fRawReader, NULL);
820b4d9e 2534 }
2535 else {
2536 AliInfo("reconstructor->Reconstruct(dummy, NULL)");
44ed7a66 2537 TTree* dummy=NULL;
2538 reconstructor->Reconstruct(dummy, NULL);
f6806ad3 2539 }
f6806ad3 2540 }
8d25d294 2541 AliSysInfo::AddStamp(Form("LRecHLT_%d",eventNr), -1,1,eventNr);
9533b54d 2542 }
820b4d9e 2543
2544 AliInfo(Form("kNDetectors = %d",kNDetectors));
2545
9533b54d 2546 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2547 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
820b4d9e 2548 AliDebug(1, Form("Detector: %s", fgkDetectorName[iDet]));
9533b54d 2549 AliReconstructor* reconstructor = GetReconstructor(iDet);
2550 if (!reconstructor) continue;
2551 AliLoader* loader = fLoader[iDet];
d76c31f4 2552 if (!loader) {
2553 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
2554 continue;
2555 }
b26c3770 2556 // conversion of digits
2557 if (fRawReader && reconstructor->HasDigitConversion()) {
2558 AliInfo(Form("converting raw data digits into root objects for %s",
2559 fgkDetectorName[iDet]));
30bbd491 2560// AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
52dd4a8c 2561// fgkDetectorName[iDet]),0);
b26c3770 2562 loader->LoadDigits("update");
2563 loader->CleanDigits();
2564 loader->MakeDigitsContainer();
2565 TTree* digitsTree = loader->TreeD();
2566 reconstructor->ConvertDigits(fRawReader, digitsTree);
2567 loader->WriteDigits("OVERWRITE");
2568 loader->UnloadDigits();
b26c3770 2569 }
b26c3770 2570 // local reconstruction
b26c3770 2571 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
52dd4a8c 2572 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]),0);
820b4d9e 2573 AliDebug(1, "Loading Rec Points");
b26c3770 2574 loader->LoadRecPoints("update");
820b4d9e 2575 AliDebug(1, "Cleaning Rec Points");
b26c3770 2576 loader->CleanRecPoints();
820b4d9e 2577 AliDebug(1, "Making Rec Points Container");
b26c3770 2578 loader->MakeRecPointsContainer();
2579 TTree* clustersTree = loader->TreeR();
2580 if (fRawReader && !reconstructor->HasDigitConversion()) {
2581 reconstructor->Reconstruct(fRawReader, clustersTree);
820b4d9e 2582 }
2583 else {
2584 AliDebug(1, "Loading Digits");
b26c3770 2585 loader->LoadDigits("read");
2586 TTree* digitsTree = loader->TreeD();
820b4d9e 2587 AliDebug(1, Form("Digits Tree = %p",digitsTree));
b26c3770 2588 if (!digitsTree) {
44ed7a66 2589 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
13effe3f 2590 if (fStopOnError)
2591 return kFALSE;
820b4d9e 2592 }
2593 else {
2594 AliDebug(1, "Digits -> Clusters");
44ed7a66 2595 reconstructor->Reconstruct(digitsTree, clustersTree);
514cb8c7 2596 if (fRunQA && IsInTasks(AliQAv1::kDIGITSR)) {
eca4fa66 2597 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2598 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, digitsTree) ;
44ed7a66 2599 }
b26c3770 2600 }
2601 loader->UnloadDigits();
2602 }
92664bc8 2603 if (fRunQA && IsInTasks(AliQAv1::kRECPOINTS)) {
eca4fa66 2604 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
92664bc8 2605 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, clustersTree) ;
57acd2d2 2606 }
eca4fa66 2607 loader->WriteRecPoints("OVERWRITE");
2608 loader->UnloadRecPoints();
2609 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
a00021a7 2610 }
c7a22819 2611 if (!IsSelected("CTP", detStr)) AliDebug(10,"No CTP");
a00021a7 2612 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
b26c3770 2613 AliError(Form("the following detectors were not found: %s",
2614 detStr.Data()));
13effe3f 2615 if (fStopOnError)
2616 return kFALSE;
b26c3770 2617 }
0f88822a 2618 eventNr++;
b26c3770 2619 return kTRUE;
2620}
58e8dc31 2621//_____________________________________________________________________________
2622Bool_t AliReconstruction::RunSPDTrackleting(AliESDEvent*& esd)
2623{
2624// run the SPD trackleting (for SPD efficiency purpouses)
2625
52dd4a8c 2626 AliCodeTimerAuto("",0)
58e8dc31 2627
2628 Double_t vtxPos[3] = {0, 0, 0};
2629 Double_t vtxErr[3] = {0.0, 0.0, 0.0};
2630/*
09b62f0a 2631 TArrayF m
2632/
2633cVertex(3);
58e8dc31 2634 // if(MC)
2635 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
2636 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
2637 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
2638 }
2639*/
2640 const AliESDVertex *vertex = esd->GetVertex();
2641 if(!vertex){
2642 AliWarning("Vertex not found");
2643 return kFALSE;
2644 }
2645 vertex->GetXYZ(vtxPos);
2646 vertex->GetSigmaXYZ(vtxErr);
2647 if (fSPDTrackleter) {
2648 AliInfo("running the SPD Trackleter for Plane Efficiency Evaluation");
2649
2650 // load clusters
2651 fLoader[0]->LoadRecPoints("read");
2652 TTree* tree = fLoader[0]->TreeR();
2653 if (!tree) {
2654 AliError("Can't get the ITS cluster tree");
2655 return kFALSE;
2656 }
2657 fSPDTrackleter->LoadClusters(tree);
2658 fSPDTrackleter->SetVertex(vtxPos, vtxErr);
2659 // run trackleting
2660 if (fSPDTrackleter->Clusters2Tracks(esd) != 0) {
84290fcc 2661 AliWarning("AliITSTrackleterSPDEff Clusters2Tracks failed");
58e8dc31 2662 // fLoader[0]->UnloadRecPoints();
2663 return kFALSE;
2664 }
2665//fSPDTrackleter->UnloadRecPoints();
2666 } else {
2667 AliWarning("SPDTrackleter not available");
2668 return kFALSE;
2669 }
2670 return kTRUE;
2671}
b26c3770 2672
2673//_____________________________________________________________________________
af885e0f 2674Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
596a855f 2675{
2676// run the barrel tracking
2677
52dd4a8c 2678 AliCodeTimerAuto("",0)
030b532d 2679
92bffc4d 2680 AliVertexer *vertexer = CreateVertexer();
2681 if (!vertexer) return kFALSE;
2682
3c99b88f 2683 AliInfo(Form("running the ITS vertex finder: %s",vertexer->ClassName()));
2257f27e 2684 AliESDVertex* vertex = NULL;
92bffc4d 2685 if (fLoader[0]) {
2686 fLoader[0]->LoadRecPoints();
2687 TTree* cltree = fLoader[0]->TreeR();
2688 if (cltree) {
2689 if(fDiamondProfileSPD) vertexer->SetVtxStart(fDiamondProfileSPD);
2690 vertex = vertexer->FindVertexForCurrentEvent(cltree);
308c2f7c 2691 }
2692 else {
92bffc4d 2693 AliError("Can't get the ITS cluster tree");
308c2f7c 2694 }
92bffc4d 2695 fLoader[0]->UnloadRecPoints();
2257f27e 2696 }
92bffc4d 2697 else {
2698 AliError("Can't get the ITS loader");
2699 }
2700 if(!vertex){
2701 AliWarning("Vertex not found");
2702 vertex = new AliESDVertex();
2703 vertex->SetName("default");
2704 }
2705 else {
2706 vertex->SetName("reconstructed");
2257f27e 2707 }
92bffc4d 2708
2709 Double_t vtxPos[3];
2710 Double_t vtxErr[3];
2711 vertex->GetXYZ(vtxPos);
2712 vertex->GetSigmaXYZ(vtxErr);
2713
06cc9d95 2714 esd->SetPrimaryVertexSPD(vertex);
73c51de2 2715 AliESDVertex *vpileup = NULL;
2716 Int_t novertices = 0;
2717 vpileup = vertexer->GetAllVertices(novertices);
2718 if(novertices>1){
2719 for (Int_t kk=1; kk<novertices; kk++)esd->AddPileupVertexSPD(&vpileup[kk]);
2720 }
1f9831ab 2721 /*
32e449be 2722 // if SPD multiplicity has been determined, it is stored in the ESD
92bffc4d 2723 AliMultiplicity *mult = vertexer->GetMultiplicity();
32e449be 2724 if(mult)esd->SetMultiplicity(mult);
1f9831ab 2725 */
ac4a7581 2726 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b8cd5251 2727 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
2728 }
2257f27e 2729 delete vertex;
2730
92bffc4d 2731 delete vertexer;
2732
2257f27e 2733 return kTRUE;
2734}
2735
2736//_____________________________________________________________________________
1f9831ab 2737Bool_t AliReconstruction::RunMultFinder(AliESDEvent*& esd)
2738{
2739 // run the trackleter for multiplicity study
2740
2741 AliCodeTimerAuto("",0)
2742
2743 AliTrackleter *trackleter = CreateMultFinder();
2744 if (!trackleter) return kFALSE;
2745
2746 AliInfo(Form("running the ITS multiplicity finder: %s",trackleter->ClassName()));
2747
2748 if (fLoader[0]) {
2749 fLoader[0]->LoadRecPoints();
2750 TTree* cltree = fLoader[0]->TreeR();
2751 if (cltree) {
2752 trackleter->Reconstruct(esd,cltree);
2753 AliMultiplicity *mult = trackleter->GetMultiplicity();
2754 if(mult) esd->SetMultiplicity(mult);
2755 }
2756 else {
2757 AliError("Can't get the ITS cluster tree");
2758 }
2759 fLoader[0]->UnloadRecPoints();
2760 }
2761 else {
2762 AliError("Can't get the ITS loader");
2763 }
2764
2765 delete trackleter;
2766
2767 return kTRUE;
2768}
2769
2770//_____________________________________________________________________________
af885e0f 2771Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
1f46a9ae 2772{
2773// run the HLT barrel tracking
2774
52dd4a8c 2775 AliCodeTimerAuto("",0)
1f46a9ae 2776
2777 if (!fRunLoader) {
2778 AliError("Missing runLoader!");
2779 return kFALSE;
2780 }
2781
2782 AliInfo("running HLT tracking");
2783
2784 // Get a pointer to the HLT reconstructor
ac4a7581 2785 AliReconstructor *reconstructor = GetReconstructor(kNDetectors-1);
1f46a9ae 2786 if (!reconstructor) return kFALSE;
2787
2788 // TPC + ITS
2789 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2790 TString detName = fgkDetectorName[iDet];
2791 AliDebug(1, Form("%s HLT tracking", detName.Data()));
2792 reconstructor->SetOption(detName.Data());
d76c31f4 2793 AliTracker *tracker = reconstructor->CreateTracker();
1f46a9ae 2794 if (!tracker) {
2795 AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
2796 if (fStopOnError) return kFALSE;
9dcc06e1 2797 continue;
1f46a9ae 2798 }
2799 Double_t vtxPos[3];
2800 Double_t vtxErr[3]={0.005,0.005,0.010};
2801 const AliESDVertex *vertex = esd->GetVertex();
2802 vertex->GetXYZ(vtxPos);
2803 tracker->SetVertex(vtxPos,vtxErr);
2804 if(iDet != 1) {
2805 fLoader[iDet]->LoadRecPoints("read");
2806 TTree* tree = fLoader[iDet]->TreeR();
2807 if (!tree) {
2808 AliError(Form("Can't get the %s cluster tree", detName.Data()));
2809 return kFALSE;
2810 }
2811 tracker->LoadClusters(tree);
2812 }
2813 if (tracker->Clusters2Tracks(esd) != 0) {
2814 AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
2815 return kFALSE;
2816 }
2817 if(iDet != 1) {
2818 tracker->UnloadClusters();
2819 }
2820 delete tracker;
2821 }
2822
1f46a9ae 2823 return kTRUE;
2824}
2825
2826//_____________________________________________________________________________
af885e0f 2827Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
e66fbafb 2828{
2829// run the muon spectrometer tracking
2830
52dd4a8c 2831 AliCodeTimerAuto("",0)
e66fbafb 2832
2833 if (!fRunLoader) {
2834 AliError("Missing runLoader!");
2835 return kFALSE;
2836 }
cfeca9e2 2837 Int_t iDet = GetDetIndex("MUON"); // for MUON
e66fbafb 2838
2839 // Get a pointer to the MUON reconstructor
2840 AliReconstructor *reconstructor = GetReconstructor(iDet);
2841 if (!reconstructor) return kFALSE;
2842
2843
2844 TString detName = fgkDetectorName[iDet];
2845 AliDebug(1, Form("%s tracking", detName.Data()));
d76c31f4 2846 AliTracker *tracker = reconstructor->CreateTracker();
e66fbafb 2847 if (!tracker) {
2848 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2849 return kFALSE;
2850 }
2851
e66fbafb 2852 // read RecPoints
761350a6 2853 fLoader[iDet]->LoadRecPoints("read");
c1954ee5 2854
761350a6 2855 tracker->LoadClusters(fLoader[iDet]->TreeR());
2856
2857 Int_t rv = tracker->Clusters2Tracks(esd);
2858
e66fbafb 2859 fLoader[iDet]->UnloadRecPoints();
2860
c1954ee5 2861 tracker->UnloadClusters();
2862
cb23c6ca 2863 if ( rv )
2864 {
2865 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2866 return kFALSE;
2867 }
2868
e66fbafb 2869 return kTRUE;
2870}
2871
2872
2873//_____________________________________________________________________________
10d100d4 2874Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
2257f27e 2875{
2876// run the barrel tracking
0f88822a 2877 static Int_t eventNr=0;
52dd4a8c 2878 AliCodeTimerAuto("",0)
24f7a148 2879
815c2b38 2880 AliInfo("running tracking");
596a855f 2881
1f26f3e7 2882 // Set the event info which is used
2883 // by the trackers in order to obtain
2884 // information about read-out detectors,
2885 // trigger etc.
2886 AliDebug(1, "Setting event info");
2887 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2888 if (!fTracker[iDet]) continue;
2889 fTracker[iDet]->SetEventInfo(&fEventInfo);
2890 }
2891
91b876d1 2892 //Fill the ESD with the T0 info (will be used by the TOF)
d76c31f4 2893 if (fReconstructor[11] && fLoader[11]) {
2894 fLoader[11]->LoadRecPoints("READ");
2895 TTree *treeR = fLoader[11]->TreeR();
89916438 2896 if (treeR) {
2897 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
2898 }
d76c31f4 2899 }
91b876d1 2900
b8cd5251 2901 // pass 1: TPC + ITS inwards
2902 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2903 if (!fTracker[iDet]) continue;
2904 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
24f7a148 2905
b8cd5251 2906 // load clusters
2907 fLoader[iDet]->LoadRecPoints("read");
6efecea1 2908 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
b8cd5251 2909 TTree* tree = fLoader[iDet]->TreeR();
2910 if (!tree) {
2911 AliError(Form("Can't get the %s cluster tree", fgkDet