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