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