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