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