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