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