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