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