]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliReconstruction.cxx
trend plots for DET and ESD performance tasks
[u/mrichter/AliRoot.git] / 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>
596a855f 132
f7a1cc68 133#include "AliAlignObj.h"
134#include "AliCDBEntry.h"
135#include "AliCDBManager.h"
136#include "AliCDBStorage.h"
137#include "AliCTPRawStream.h"
138#include "AliCascadeVertexer.h"
139#include "AliCentralTrigger.h"
87932dab 140#include "AliCodeTimer.h"
f7a1cc68 141#include "AliDAQ.h"
142#include "AliDetectorRecoParam.h"
143#include "AliESDCaloCells.h"
144#include "AliESDCaloCluster.h"
af885e0f 145#include "AliESDEvent.h"
faffd83e 146#include "AliESDMuonTrack.h"
f7a1cc68 147#include "AliESDPmdTrack.h"
148#include "AliESDTagCreator.h"
2257f27e 149#include "AliESDVertex.h"
faffd83e 150#include "AliESDcascade.h"
f7a1cc68 151#include "AliESDfriend.h"
faffd83e 152#include "AliESDkink.h"
596a855f 153#include "AliESDpid.h"
ff8bb5ae 154#include "AliESDtrack.h"
f7a1cc68 155#include "AliESDtrack.h"
156#include "AliEventInfo.h"
157#include "AliGRPObject.h"
158#include "AliGRPRecoParam.h"
159#include "AliGenEventHeader.h"
25be1e5c 160#include "AliGeomManager.h"
aa3c69a9 161#include "AliGlobalQADataMaker.h"
f7a1cc68 162#include "AliHeader.h"
163#include "AliLog.h"
164#include "AliMagF.h"
165#include "AliMultiplicity.h"
166#include "AliPID.h"
167#include "AliPlaneEff.h"
4e25ac79 168#include "AliQAv1.h"
f7a1cc68 169#include "AliQADataMakerRec.h"
b03591ab 170#include "AliQAManager.h"
33314186 171#include "AliRawVEvent.h"
f7a1cc68 172#include "AliRawEventHeaderBase.h"
cd0b062e 173#include "AliRawHLTManager.h"
f7a1cc68 174#include "AliRawReaderDate.h"
175#include "AliRawReaderFile.h"
176#include "AliRawReaderRoot.h"
177#include "AliReconstruction.h"
178#include "AliReconstructor.h"
179#include "AliRun.h"
7e88424f 180#include "AliRunInfo.h"
f7a1cc68 181#include "AliRunLoader.h"
182#include "AliSysInfo.h" // memory snapshots
183#include "AliTrackPointArray.h"
184#include "AliTracker.h"
185#include "AliTriggerClass.h"
186#include "AliTriggerCluster.h"
a6dd87ad 187#include "AliTriggerIR.h"
f7a1cc68 188#include "AliTriggerConfiguration.h"
189#include "AliV0vertexer.h"
190#include "AliVertexer.h"
191#include "AliVertexerTracks.h"
44e45fac 192
596a855f 193ClassImp(AliReconstruction)
194
c757bafd 195//_____________________________________________________________________________
ac4a7581 196const char* AliReconstruction::fgkDetectorName[AliReconstruction::kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
c757bafd 197
596a855f 198//_____________________________________________________________________________
4b71572b 199AliReconstruction::AliReconstruction(const char* gAliceFilename) :
200 TSelector(),
2257f27e 201 fRunVertexFinder(kTRUE),
a84e2607 202 fRunVertexFinderTracks(kTRUE),
1f46a9ae 203 fRunHLTTracking(kFALSE),
e66fbafb 204 fRunMuonTracking(kFALSE),
d1683eef 205 fRunV0Finder(kTRUE),
206 fRunCascadeFinder(kTRUE),
1d99986f 207 fStopOnError(kFALSE),
208 fWriteAlignmentData(kFALSE),
209 fWriteESDfriend(kFALSE),
b647652d 210 fFillTriggerESD(kTRUE),
1d99986f 211
7f68891d 212 fCleanESD(kTRUE),
a023d8d8 213 fV0DCAmax(3.),
214 fV0CsPmin(0.),
7f68891d 215 fDmax(50.),
216 fZmax(50.),
217
1d99986f 218 fRunLocalReconstruction("ALL"),
b8cd5251 219 fRunTracking("ALL"),
e583c30d 220 fFillESD("ALL"),
7d566c20 221 fLoadCDB(""),
48ce48d1 222 fUseTrackingErrorsForAlignment(""),
e583c30d 223 fGAliceFileName(gAliceFilename),
4b71572b 224 fRawInput(""),
975320a0 225 fESDOutput(""),
81d57268 226 fProofOutputFileName(""),
227 fProofOutputLocation(""),
228 fProofOutputDataset(kFALSE),
229 fProofOutputArchive(""),
35042093 230 fEquipIdMap(""),
b26c3770 231 fFirstEvent(0),
232 fLastEvent(-1),
9d705769 233 fNumberOfEventsPerFile((UInt_t)-1),
b8cd5251 234 fOptions(),
6bae477a 235 fLoadAlignFromCDB(kTRUE),
236 fLoadAlignData("ALL"),
cd0b062e 237 fUseHLTData(),
7e88424f 238 fRunInfo(NULL),
239 fEventInfo(),
522fdd91 240 fRunScalers(NULL),
e583c30d 241
242 fRunLoader(NULL),
b649205a 243 fRawReader(NULL),
cd0b062e 244 fParentRawReader(NULL),
b8cd5251 245
7e88424f 246 fRecoParam(),
247
58e8dc31 248 fSPDTrackleter(NULL),
249
f2a195c1 250 fDiamondProfileSPD(NULL),
9178838a 251 fDiamondProfile(NULL),
43c9dae1 252 fDiamondProfileTPC(NULL),
77ba28ba 253 fListOfCosmicTriggers(NULL),
f2a195c1 254
6b6e4472 255 fGRPData(NULL),
444753c6 256
6bae477a 257 fAlignObjArray(NULL),
795e4a22 258 fCDBUri(),
f1c1204d 259 fQARefUri(),
759c1df1 260 fSpecCDBUri(),
795e4a22 261 fInitCDBCalled(kFALSE),
262 fSetRunNumberFromDataCalled(kFALSE),
ce43afbe 263 fQADetectors("ALL"),
264 fQATasks("ALL"),
7e963665 265 fRunQA(kTRUE),
6b150027 266 fRunGlobalQA(kTRUE),
e4a998ed 267 fSameQACycle(kFALSE),
f1c1204d 268 fInitQACalled(kFALSE),
75373542 269 fWriteQAExpertData(kTRUE),
21a3aa09 270 fRunPlaneEff(kFALSE),
271
272 fesd(NULL),
273 fhltesd(NULL),
274 fesdf(NULL),
275 ffile(NULL),
276 ftree(NULL),
277 fhlttree(NULL),
21a3aa09 278 ftVertexer(NULL),
14dd053c 279 fIsNewRunLoader(kFALSE),
4b71572b 280 fRunAliEVE(kFALSE),
281 fChain(NULL)
596a855f 282{
283// create reconstruction object with default parameters
002c9d1b 284 gGeoManager = NULL;
b8cd5251 285
ac4a7581 286 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b8cd5251 287 fReconstructor[iDet] = NULL;
288 fLoader[iDet] = NULL;
289 fTracker[iDet] = NULL;
290 }
4e25ac79 291 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
252f8aa8 292 fQACycles[iDet] = 999999 ;
293 fQAWriteExpert[iDet] = kFALSE ;
294 }
295
e47c4c2e 296 AliPID pid;
596a855f 297}
298
299//_____________________________________________________________________________
300AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
4b71572b 301 TSelector(),
2257f27e 302 fRunVertexFinder(rec.fRunVertexFinder),
a84e2607 303 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
1f46a9ae 304 fRunHLTTracking(rec.fRunHLTTracking),
e66fbafb 305 fRunMuonTracking(rec.fRunMuonTracking),
d1683eef 306 fRunV0Finder(rec.fRunV0Finder),
307 fRunCascadeFinder(rec.fRunCascadeFinder),
1d99986f 308 fStopOnError(rec.fStopOnError),
309 fWriteAlignmentData(rec.fWriteAlignmentData),
310 fWriteESDfriend(rec.fWriteESDfriend),
b647652d 311 fFillTriggerESD(rec.fFillTriggerESD),
1d99986f 312
7f68891d 313 fCleanESD(rec.fCleanESD),
a023d8d8 314 fV0DCAmax(rec.fV0DCAmax),
5e5c1aa9 315 fV0CsPmin(rec.fV0CsPmin),
7f68891d 316 fDmax(rec.fDmax),
317 fZmax(rec.fZmax),
318
1d99986f 319 fRunLocalReconstruction(rec.fRunLocalReconstruction),
e583c30d 320 fRunTracking(rec.fRunTracking),
321 fFillESD(rec.fFillESD),
7d566c20 322 fLoadCDB(rec.fLoadCDB),
48ce48d1 323 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
e583c30d 324 fGAliceFileName(rec.fGAliceFileName),
4b71572b 325 fRawInput(rec.fRawInput),
975320a0 326 fESDOutput(rec.fESDOutput),
81d57268 327 fProofOutputFileName(rec.fProofOutputFileName),
328 fProofOutputLocation(rec.fProofOutputLocation),
329 fProofOutputDataset(rec.fProofOutputDataset),
330 fProofOutputArchive(rec.fProofOutputArchive),
35042093 331 fEquipIdMap(rec.fEquipIdMap),
b26c3770 332 fFirstEvent(rec.fFirstEvent),
333 fLastEvent(rec.fLastEvent),
973388c2 334 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
b8cd5251 335 fOptions(),
6bae477a 336 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
337 fLoadAlignData(rec.fLoadAlignData),
2972d4eb 338 fUseHLTData(rec.fUseHLTData),
7e88424f 339 fRunInfo(NULL),
340 fEventInfo(),
522fdd91 341 fRunScalers(NULL),
e583c30d 342
343 fRunLoader(NULL),
b649205a 344 fRawReader(NULL),
2972d4eb 345 fParentRawReader(NULL),
b8cd5251 346
4b71572b 347 fRecoParam(rec.fRecoParam),
7e88424f 348
58e8dc31 349 fSPDTrackleter(NULL),
350
f2a195c1 351 fDiamondProfileSPD(rec.fDiamondProfileSPD),
4b71572b 352 fDiamondProfile(rec.fDiamondProfile),
353 fDiamondProfileTPC(rec.fDiamondProfileTPC),
77ba28ba 354 fListOfCosmicTriggers(NULL),
f2a195c1 355
6b6e4472 356 fGRPData(NULL),
444753c6 357
6bae477a 358 fAlignObjArray(rec.fAlignObjArray),
ec92bee0 359 fCDBUri(rec.fCDBUri),
f1c1204d 360 fQARefUri(rec.fQARefUri),
7e963665 361 fSpecCDBUri(),
795e4a22 362 fInitCDBCalled(rec.fInitCDBCalled),
363 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
ce43afbe 364 fQADetectors(rec.fQADetectors),
365 fQATasks(rec.fQATasks),
aa3c69a9 366 fRunQA(rec.fRunQA),
367 fRunGlobalQA(rec.fRunGlobalQA),
e4a998ed 368 fSameQACycle(rec.fSameQACycle),
f1c1204d 369 fInitQACalled(rec.fInitQACalled),
75373542 370 fWriteQAExpertData(rec.fWriteQAExpertData),
21a3aa09 371 fRunPlaneEff(rec.fRunPlaneEff),
372
373 fesd(NULL),
374 fhltesd(NULL),
375 fesdf(NULL),
376 ffile(NULL),
377 ftree(NULL),
378 fhlttree(NULL),
21a3aa09 379 ftVertexer(NULL),
14dd053c 380 fIsNewRunLoader(rec.fIsNewRunLoader),
4b71572b 381 fRunAliEVE(kFALSE),
382 fChain(NULL)
596a855f 383{
384// copy constructor
385
ec92bee0 386 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
efd2085e 387 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
388 }
ac4a7581 389 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b8cd5251 390 fReconstructor[iDet] = NULL;
391 fLoader[iDet] = NULL;
392 fTracker[iDet] = NULL;
b1af1125 393 }
394
4e25ac79 395 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
b1af1125 396 fQACycles[iDet] = rec.fQACycles[iDet];
252f8aa8 397 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
398 }
b1af1125 399
ec92bee0 400 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
401 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
402 }
596a855f 403}
404
405//_____________________________________________________________________________
406AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
407{
408// assignment operator
4b71572b 409// Used in PROOF mode
410// Be very careful while modifing it!
411// Simple rules to follow:
412// for persistent data members - use their assignment operators
413// for non-persistent ones - do nothing or take the default values from constructor
414// TSelector members should not be touched
415 if(&rec == this) return *this;
416
4b71572b 417 fRunVertexFinder = rec.fRunVertexFinder;
418 fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
419 fRunHLTTracking = rec.fRunHLTTracking;
420 fRunMuonTracking = rec.fRunMuonTracking;
421 fRunV0Finder = rec.fRunV0Finder;
422 fRunCascadeFinder = rec.fRunCascadeFinder;
423 fStopOnError = rec.fStopOnError;
424 fWriteAlignmentData = rec.fWriteAlignmentData;
425 fWriteESDfriend = rec.fWriteESDfriend;
426 fFillTriggerESD = rec.fFillTriggerESD;
427
428 fCleanESD = rec.fCleanESD;
429 fV0DCAmax = rec.fV0DCAmax;
430 fV0CsPmin = rec.fV0CsPmin;
431 fDmax = rec.fDmax;
432 fZmax = rec.fZmax;
433
434 fRunLocalReconstruction = rec.fRunLocalReconstruction;
435 fRunTracking = rec.fRunTracking;
436 fFillESD = rec.fFillESD;
7d566c20 437 fLoadCDB = rec.fLoadCDB;
4b71572b 438 fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
439 fGAliceFileName = rec.fGAliceFileName;
440 fRawInput = rec.fRawInput;
975320a0 441 fESDOutput = rec.fESDOutput;
81d57268 442 fProofOutputFileName = rec.fProofOutputFileName;
443 fProofOutputLocation = rec.fProofOutputLocation;
444 fProofOutputDataset = rec.fProofOutputDataset;
445 fProofOutputArchive = rec.fProofOutputArchive;
4b71572b 446 fEquipIdMap = rec.fEquipIdMap;
447 fFirstEvent = rec.fFirstEvent;
448 fLastEvent = rec.fLastEvent;
449 fNumberOfEventsPerFile = rec.fNumberOfEventsPerFile;
450
451 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
452 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
453 }
454
455 fLoadAlignFromCDB = rec.fLoadAlignFromCDB;
456 fLoadAlignData = rec.fLoadAlignData;
4b71572b 457 fUseHLTData = rec.fUseHLTData;
458
459 delete fRunInfo; fRunInfo = NULL;
460 if (rec.fRunInfo) fRunInfo = new AliRunInfo(*rec.fRunInfo);
461
462 fEventInfo = rec.fEventInfo;
463
522fdd91 464 delete fRunScalers; fRunScalers = NULL;
465 if (rec.fRunScalers) fRunScalers = new AliTriggerRunScalers(*rec.fRunScalers);
466
467
4b71572b 468 fRunLoader = NULL;
469 fRawReader = NULL;
470 fParentRawReader = NULL;
471
472 fRecoParam = rec.fRecoParam;
473
ac4a7581 474 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
4b71572b 475 delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
476 delete fLoader[iDet]; fLoader[iDet] = NULL;
477 delete fTracker[iDet]; fTracker[iDet] = NULL;
4b71572b 478 }
b1af1125 479
4e25ac79 480 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
b1af1125 481 fQACycles[iDet] = rec.fQACycles[iDet];
252f8aa8 482 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
483 }
58e8dc31 484
485 delete fSPDTrackleter; fSPDTrackleter = NULL;
252f8aa8 486
f2a195c1 487 delete fDiamondProfileSPD; fDiamondProfileSPD = NULL;
488 if (rec.fDiamondProfileSPD) fDiamondProfileSPD = new AliESDVertex(*rec.fDiamondProfileSPD);
4b71572b 489 delete fDiamondProfile; fDiamondProfile = NULL;
490 if (rec.fDiamondProfile) fDiamondProfile = new AliESDVertex(*rec.fDiamondProfile);
491 delete fDiamondProfileTPC; fDiamondProfileTPC = NULL;
492 if (rec.fDiamondProfileTPC) fDiamondProfileTPC = new AliESDVertex(*rec.fDiamondProfileTPC);
4b71572b 493
77ba28ba 494 delete fListOfCosmicTriggers; fListOfCosmicTriggers = NULL;
495 if (rec.fListOfCosmicTriggers) fListOfCosmicTriggers = (THashTable*)((rec.fListOfCosmicTriggers)->Clone());
496
4b71572b 497 delete fGRPData; fGRPData = NULL;
44e45fac 498 // if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
499 if (rec.fGRPData) fGRPData = (AliGRPObject*)((rec.fGRPData)->Clone());
4b71572b 500
501 delete fAlignObjArray; fAlignObjArray = NULL;
502
503 fCDBUri = "";
f1c1204d 504 fQARefUri = rec.fQARefUri;
4b71572b 505 fSpecCDBUri.Delete();
506 fInitCDBCalled = rec.fInitCDBCalled;
507 fSetRunNumberFromDataCalled = rec.fSetRunNumberFromDataCalled;
508 fQADetectors = rec.fQADetectors;
4b71572b 509 fQATasks = rec.fQATasks;
510 fRunQA = rec.fRunQA;
511 fRunGlobalQA = rec.fRunGlobalQA;
4b71572b 512 fSameQACycle = rec.fSameQACycle;
f1c1204d 513 fInitQACalled = rec.fInitQACalled;
75373542 514 fWriteQAExpertData = rec.fWriteQAExpertData;
4b71572b 515 fRunPlaneEff = rec.fRunPlaneEff;
516
517 fesd = NULL;
518 fhltesd = NULL;
519 fesdf = NULL;
520 ffile = NULL;
521 ftree = NULL;
522 fhlttree = NULL;
523 ftVertexer = NULL;
524 fIsNewRunLoader = rec.fIsNewRunLoader;
525 fRunAliEVE = kFALSE;
526 fChain = NULL;
596a855f 527
596a855f 528 return *this;
529}
530
531//_____________________________________________________________________________
532AliReconstruction::~AliReconstruction()
533{
534// clean up
535
e583c30d 536 CleanUp();
77ba28ba 537 if (fListOfCosmicTriggers) {
538 fListOfCosmicTriggers->Delete();
539 delete fListOfCosmicTriggers;
540 }
4f3c479a 541 delete fGRPData;
522fdd91 542 delete fRunScalers;
efd2085e 543 fOptions.Delete();
4b71572b 544 if (fAlignObjArray) {
545 fAlignObjArray->Delete();
546 delete fAlignObjArray;
547 }
ec92bee0 548 fSpecCDBUri.Delete();
e6d66370 549
87932dab 550 AliCodeTimer::Instance()->Print();
596a855f 551}
552
f1c1204d 553//_____________________________________________________________________________
554void AliReconstruction::InitQA()
555{
556 //Initialize the QA and start of cycle
557 AliCodeTimerAuto("");
558
559 if (fInitQACalled) return;
560 fInitQACalled = kTRUE;
561
634696f5 562 AliQAManager * qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ;
75373542 563 if (fWriteQAExpertData)
eca4fa66 564 qam->SetWriteExpert() ;
75373542 565
eca4fa66 566 if (qam->IsDefaultStorageSet()) {
f1c1204d 567 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
568 AliWarning("Default QA reference storage has been already set !");
569 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fQARefUri.Data()));
570 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
eca4fa66 571 fQARefUri = qam->GetDefaultStorage()->GetURI();
f1c1204d 572 } else {
573 if (fQARefUri.Length() > 0) {
574 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
575 AliDebug(2, Form("Default QA reference storage is set to: %s", fQARefUri.Data()));
576 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
577 } else {
578 fQARefUri="local://$ALICE_ROOT/QAref";
579 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
580 AliWarning("Default QA refeference storage not yet set !!!!");
581 AliWarning(Form("Setting it now to: %s", fQARefUri.Data()));
582 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
583
584 }
eca4fa66 585 qam->SetDefaultStorage(fQARefUri);
f1c1204d 586 }
587
588 if (fRunQA) {
eca4fa66 589 qam->SetActiveDetectors(fQADetectors) ;
4e25ac79 590 for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++) {
eca4fa66 591 qam->SetCycleLength(AliQAv1::DETECTORINDEX_t(det), fQACycles[det]) ;
592 qam->SetWriteExpert(AliQAv1::DETECTORINDEX_t(det)) ;
f1c1204d 593 }
87da0921 594 if (!fRawReader && !fInput && fQATasks.Contains(AliQAv1::kRAWS))
4e25ac79 595 fQATasks.ReplaceAll(Form("%d",AliQAv1::kRAWS), "") ;
eca4fa66 596 qam->SetTasks(fQATasks) ;
597 qam->InitQADataMaker(AliCDBManager::Instance()->GetRun()) ;
f1c1204d 598 }
599 if (fRunGlobalQA) {
600 Bool_t sameCycle = kFALSE ;
eca4fa66 601 AliQADataMaker *qadm = qam->GetQADataMaker(AliQAv1::kGLOBAL);
f1c1204d 602 AliInfo(Form("Initializing the global QA data maker"));
4e25ac79 603 if (fQATasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
604 qadm->StartOfCycle(AliQAv1::kRECPOINTS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
605 TObjArray **arr=qadm->Init(AliQAv1::kRECPOINTS);
f1c1204d 606 AliTracker::SetResidualsArray(arr);
607 sameCycle = kTRUE ;
608 }
4e25ac79 609 if (fQATasks.Contains(Form("%d", AliQAv1::kESDS))) {
610 qadm->StartOfCycle(AliQAv1::kESDS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
611 qadm->Init(AliQAv1::kESDS);
f1c1204d 612 }
f1c1204d 613 }
fc07289e 614 AliSysInfo::AddStamp("InitQA") ;
f1c1204d 615}
616
fc07289e 617//_____________________________________________________________________________
87da0921 618void AliReconstruction::MergeQA(const char *fileName)
fc07289e 619{
620 //Initialize the QA and start of cycle
621 AliCodeTimerAuto("") ;
eca4fa66 622 AliQAManager::QAManager()->Merge(AliCDBManager::Instance()->GetRun(),fileName) ;
fc07289e 623 AliSysInfo::AddStamp("MergeQA") ;
624}
625
024cf675 626//_____________________________________________________________________________
795e4a22 627void AliReconstruction::InitCDB()
024cf675 628{
629// activate a default CDB storage
630// First check if we have any CDB storage set, because it is used
631// to retrieve the calibration and alignment constants
002c9d1b 632 AliCodeTimerAuto("");
024cf675 633
795e4a22 634 if (fInitCDBCalled) return;
635 fInitCDBCalled = kTRUE;
636
024cf675 637 AliCDBManager* man = AliCDBManager::Instance();
ec92bee0 638 if (man->IsDefaultStorageSet())
024cf675 639 {
640 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
ec92bee0 641 AliWarning("Default CDB storage has been already set !");
642 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
024cf675 643 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
795e4a22 644 fCDBUri = man->GetDefaultStorage()->GetURI();
ec92bee0 645 }
646 else {
795e4a22 647 if (fCDBUri.Length() > 0)
648 {
649 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
650 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
651 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
652 } else {
162637e4 653 fCDBUri="local://$ALICE_ROOT/OCDB";
795e4a22 654 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
655 AliWarning("Default CDB storage not yet set !!!!");
656 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
657 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
658
659 }
ec92bee0 660 man->SetDefaultStorage(fCDBUri);
661 }
662
663 // Now activate the detector specific CDB storage locations
c3a7b59a 664 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
665 TObject* obj = fSpecCDBUri[i];
666 if (!obj) continue;
b8ec52f6 667 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
668 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
669 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
c3a7b59a 670 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
ec92bee0 671 }
002c9d1b 672 AliSysInfo::AddStamp("InitCDB");
024cf675 673}
674
675//_____________________________________________________________________________
676void AliReconstruction::SetDefaultStorage(const char* uri) {
ec92bee0 677// Store the desired default CDB storage location
678// Activate it later within the Run() method
024cf675 679
ec92bee0 680 fCDBUri = uri;
024cf675 681
682}
683
f1c1204d 684//_____________________________________________________________________________
685void AliReconstruction::SetQARefDefaultStorage(const char* uri) {
686 // Store the desired default CDB storage location
687 // Activate it later within the Run() method
688
689 fQARefUri = uri;
4e25ac79 690 AliQAv1::SetQARefStorage(fQARefUri.Data()) ;
f1c1204d 691
692}
00aa02d5 693//_____________________________________________________________________________
c3a7b59a 694void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
ec92bee0 695// Store a detector-specific CDB storage location
696// Activate it later within the Run() method
024cf675 697
c3a7b59a 698 AliCDBPath aPath(calibType);
699 if(!aPath.IsValid()){
700 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
ac4a7581 701 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
c3a7b59a 702 if(!strcmp(calibType, fgkDetectorName[iDet])) {
703 aPath.SetPath(Form("%s/*", calibType));
704 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
705 break;
706 }
707 }
708 if(!aPath.IsValid()){
709 AliError(Form("Not a valid path or detector: %s", calibType));
710 return;
711 }
712 }
713
53dd3c3d 714// // check that calibType refers to a "valid" detector name
715// Bool_t isDetector = kFALSE;
ac4a7581 716// for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
53dd3c3d 717// TString detName = fgkDetectorName[iDet];
718// if(aPath.GetLevel0() == detName) {
719// isDetector = kTRUE;
720// break;
721// }
722// }
723//
724// if(!isDetector) {
725// AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
726// return;
727// }
c3a7b59a 728
729 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
ec92bee0 730 if (obj) fSpecCDBUri.Remove(obj);
c3a7b59a 731 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
024cf675 732
733}
734
6bae477a 735//_____________________________________________________________________________
795e4a22 736Bool_t AliReconstruction::SetRunNumberFromData()
6bae477a 737{
738 // The method is called in Run() in order
739 // to set a correct run number.
740 // In case of raw data reconstruction the
741 // run number is taken from the raw data header
742
795e4a22 743 if (fSetRunNumberFromDataCalled) return kTRUE;
744 fSetRunNumberFromDataCalled = kTRUE;
745
746 AliCDBManager* man = AliCDBManager::Instance();
4b71572b 747
748 if(fRawReader) {
749 if(fRawReader->NextEvent()) {
750 if(man->GetRun() > 0) {
21a3aa09 751 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
4b71572b 752 }
753 man->SetRun(fRawReader->GetRunNumber());
754 fRawReader->RewindEvents();
755 }
756 else {
757 if(man->GetRun() > 0) {
758 AliWarning("No raw-data events are found ! Using settings in AliCDBManager !");
759 }
760 else {
761 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
762 return kFALSE;
763 }
764 }
765 }
766 else {
767 AliRunLoader *rl = AliRunLoader::Open(fGAliceFileName.Data());
768 if (!rl) {
769 AliError(Form("No run loader found in file %s", fGAliceFileName.Data()));
6bae477a 770 return kFALSE;
771 }
ec92bee0 772 else {
4b71572b 773 rl->LoadHeader();
774 // read run number from gAlice
775 if(rl->GetHeader()) {
776 man->SetRun(rl->GetHeader()->GetRun());
777 rl->UnloadHeader();
778 delete rl;
ec92bee0 779 }
780 else {
4b71572b 781 AliError("Neither run-loader header nor RawReader objects are found !");
782 delete rl;
ec92bee0 783 return kFALSE;
784 }
4b71572b 785 }
6bae477a 786 }
795e4a22 787
788 man->Print();
789
6bae477a 790 return kTRUE;
791}
792
795e4a22 793//_____________________________________________________________________________
794void AliReconstruction::SetCDBLock() {
795 // Set CDB lock: from now on it is forbidden to reset the run number
796 // or the default storage or to activate any further storage!
797
798 AliCDBManager::Instance()->SetLock(1);
799}
800
6bae477a 801//_____________________________________________________________________________
802Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
803{
804 // Read the alignment objects from CDB.
805 // Each detector is supposed to have the
806 // alignment objects in DET/Align/Data CDB path.
807 // All the detector objects are then collected,
808 // sorted by geometry level (starting from ALIC) and
809 // then applied to the TGeo geometry.
810 // Finally an overlaps check is performed.
811
812 // Load alignment data from CDB and fill fAlignObjArray
813 if(fLoadAlignFromCDB){
6bae477a 814
25be1e5c 815 TString detStr = detectors;
816 TString loadAlObjsListOfDets = "";
817
ac4a7581 818 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
8cb26cdf 819 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
f12d42ce 820 if(!strcmp(fgkDetectorName[iDet],"HLT")) continue;
4fbb8e9d 821
822 if(AliGeomManager::GetNalignable(fgkDetectorName[iDet]) != 0)
8cb26cdf 823 {
824 loadAlObjsListOfDets += fgkDetectorName[iDet];
825 loadAlObjsListOfDets += " ";
826 }
25be1e5c 827 } // end loop over detectors
4fbb8e9d 828
829 if(AliGeomManager::GetNalignable("GRP") != 0)
8cb26cdf 830 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
98e303d9 831 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
e30a9b4d 832 AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
25be1e5c 833 }else{
834 // Check if the array with alignment objects was
835 // provided by the user. If yes, apply the objects
836 // to the present TGeo geometry
837 if (fAlignObjArray) {
838 if (gGeoManager && gGeoManager->IsClosed()) {
98e303d9 839 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
25be1e5c 840 AliError("The misalignment of one or more volumes failed!"
841 "Compare the list of simulated detectors and the list of detector alignment data!");
842 return kFALSE;
843 }
844 }
845 else {
846 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
6bae477a 847 return kFALSE;
848 }
849 }
6bae477a 850 }
25be1e5c 851
4b71572b 852 if (fAlignObjArray) {
853 fAlignObjArray->Delete();
854 delete fAlignObjArray; fAlignObjArray=NULL;
855 }
a03b0371 856
6bae477a 857 return kTRUE;
858}
596a855f 859
860//_____________________________________________________________________________
861void AliReconstruction::SetGAliceFile(const char* fileName)
862{
863// set the name of the galice file
864
865 fGAliceFileName = fileName;
866}
867
21a3aa09 868//_____________________________________________________________________________
b58710ef 869void AliReconstruction::SetInput(const char* input)
21a3aa09 870{
b58710ef 871 // In case the input string starts with 'mem://', we run in an online mode
872 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
873 // file is assumed. One can give as an input:
874 // mem://: - events taken from DAQ monitoring libs online
875 // or
876 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
4b71572b 877 if (input) fRawInput = input;
21a3aa09 878}
879
975320a0 880//_____________________________________________________________________________
881void AliReconstruction::SetOutput(const char* output)
882{
883 // Set the output ESD filename
884 // 'output' is a normalt ROOT url
885 // The method is used in case of raw-data reco with PROOF
81d57268 886 if (output) fESDOutput = output;
975320a0 887}
888
efd2085e 889//_____________________________________________________________________________
890void AliReconstruction::SetOption(const char* detector, const char* option)
891{
892// set options for the reconstruction of a detector
893
894 TObject* obj = fOptions.FindObject(detector);
895 if (obj) fOptions.Remove(obj);
896 fOptions.Add(new TNamed(detector, option));
897}
898
7e88424f 899//_____________________________________________________________________________
900void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
901{
902 // Set custom reconstruction parameters for a given detector
903 // Single set of parameters for all the events
a00021a7 904
905 // First check if the reco-params are global
906 if(!strcmp(detector, "GRP")) {
907 par->SetAsDefault();
ac4a7581 908 fRecoParam.AddDetRecoParam(kNDetectors,par);
a00021a7 909 return;
910 }
911
ac4a7581 912 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
7e88424f 913 if(!strcmp(detector, fgkDetectorName[iDet])) {
914 par->SetAsDefault();
915 fRecoParam.AddDetRecoParam(iDet,par);
916 break;
917 }
918 }
919
920}
921
61807e09 922//_____________________________________________________________________________
61807e09 923Bool_t AliReconstruction::InitGRP() {
924 //------------------------------------
925 // Initialization of the GRP entry
926 //------------------------------------
927 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
928
4b71572b 929 if (entry) {
44e45fac 930
931 TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
932
933 if (m) {
934 AliInfo("Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject");
935 m->Print();
936 fGRPData = new AliGRPObject();
937 fGRPData->ReadValuesFromMap(m);
938 }
939
940 else {
941 AliInfo("Found an AliGRPObject in GRP/GRP/Data, reading it");
942 fGRPData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
943 entry->SetOwner(0);
944 }
945
f168abba 946 // FIX ME: The unloading of GRP entry is temporarily disabled
947 // because ZDC and VZERO are using it in order to initialize
948 // their reconstructor objects. In the future one has to think
949 // of propagating AliRunInfo to the reconstructors.
950 // AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
4b71572b 951 }
61807e09 952
953 if (!fGRPData) {
954 AliError("No GRP entry found in OCDB!");
955 return kFALSE;
956 }
957
44e45fac 958 TString lhcState = fGRPData->GetLHCState();
959 if (lhcState==AliGRPObject::GetInvalidString()) {
7e88424f 960 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
44e45fac 961 lhcState = "UNKNOWN";
7e88424f 962 }
963
44e45fac 964 TString beamType = fGRPData->GetBeamType();
965 if (beamType==AliGRPObject::GetInvalidString()) {
7e88424f 966 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
44e45fac 967 beamType = "UNKNOWN";
7e88424f 968 }
969
44e45fac 970 Float_t beamEnergy = fGRPData->GetBeamEnergy();
971 if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
7e88424f 972 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
44e45fac 973 beamEnergy = 0;
7e88424f 974 }
1e500f25 975 // LHC: "multiply by 120 to get the energy in MeV"
976 beamEnergy *= 0.120;
7e88424f 977
44e45fac 978 TString runType = fGRPData->GetRunType();
979 if (runType==AliGRPObject::GetInvalidString()) {
7e88424f 980 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
44e45fac 981 runType = "UNKNOWN";
7e88424f 982 }
983
44e45fac 984 Int_t activeDetectors = fGRPData->GetDetectorMask();
a5dede5c 985 if (activeDetectors==AliGRPObject::GetInvalidUInt()) {
7e88424f 986 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
44e45fac 987 activeDetectors = 1074790399;
7e88424f 988 }
989
44e45fac 990 fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
44e45fac 991 fRunInfo->Dump();
992
7e88424f 993
994 // Process the list of active detectors
44e45fac 995 if (activeDetectors) {
996 UInt_t detMask = activeDetectors;
7a317bef 997 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
998 fRunTracking = MatchDetectorList(fRunTracking,detMask);
999 fFillESD = MatchDetectorList(fFillESD,detMask);
1000 fQADetectors = MatchDetectorList(fQADetectors,detMask);
7d566c20 1001 fLoadCDB.Form("%s %s %s %s",
1002 fRunLocalReconstruction.Data(),
1003 fRunTracking.Data(),
1004 fFillESD.Data(),
1005 fQADetectors.Data());
7d566c20 1006 fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
91e2f025 1007 if (!((detMask >> AliDAQ::DetectorID("ITSSPD")) & 0x1)) {
1008 // switch off the vertexer
1009 AliInfo("SPD is not in the list of active detectors. Vertexer switched off.");
1010 fRunVertexFinder = kFALSE;
1011 }
304d7f0b 1012 if (!((detMask >> AliDAQ::DetectorID("TRG")) & 0x1)) {
1013 // switch off the reading of CTP raw-data payload
1014 if (fFillTriggerESD) {
1015 AliInfo("CTP is not in the list of active detectors. CTP data reading switched off.");
1016 fFillTriggerESD = kFALSE;
1017 }
1018 }
7e88424f 1019 }
1020
1021 AliInfo("===================================================================================");
1022 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
1023 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
1024 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
ca13fb87 1025 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
7d566c20 1026 AliInfo(Form("CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data()));
7e88424f 1027 AliInfo("===================================================================================");
61807e09 1028
1029 //*** Dealing with the magnetic field map
5a004fb4 1030 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
1031 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
1032 AliInfo("ExpertMode!!! GRP information will be ignored !");
1033 AliInfo("ExpertMode!!! Running with the externally locked B field !");
1034 }
1035 else {
1036 AliInfo("Destroying existing B field instance!");
1037 delete TGeoGlobalMagField::Instance();
1038 }
1039 }
1040 if ( !TGeoGlobalMagField::Instance()->IsLocked() ) {
61807e09 1041 // Construct the field map out of the information retrieved from GRP.
856024f0 1042 Bool_t ok = kTRUE;
61807e09 1043 // L3
44e45fac 1044 Float_t l3Current = fGRPData->GetL3Current((AliGRPObject::Stats)0);
1045 if (l3Current == AliGRPObject::GetInvalidFloat()) {
1046 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
1047 ok = kFALSE;
1048 }
f7a1cc68 1049
44e45fac 1050 Char_t l3Polarity = fGRPData->GetL3Polarity();
1051 if (l3Polarity == AliGRPObject::GetInvalidChar()) {
1052 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
1053 ok = kFALSE;
1054 }
1055
1056 // Dipole
1057 Float_t diCurrent = fGRPData->GetDipoleCurrent((AliGRPObject::Stats)0);
1058 if (diCurrent == AliGRPObject::GetInvalidFloat()) {
1059 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
1060 ok = kFALSE;
1061 }
1062
1063 Char_t diPolarity = fGRPData->GetDipolePolarity();
1064 if (diPolarity == AliGRPObject::GetInvalidChar()) {
1065 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
1066 ok = kFALSE;
1067 }
1068
99c7d495 1069 // read special bits for the polarity convention and map type
1070 Int_t polConvention = fGRPData->IsPolarityConventionLHC() ? AliMagF::kConvLHC : AliMagF::kConvDCS2008;
1071 Bool_t uniformB = fGRPData->IsUniformBMap();
61807e09 1072
856024f0 1073 if (ok) {
33fe5eb1 1074 AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1),
1075 TMath::Abs(diCurrent) * (diPolarity ? -1:1),
1076 polConvention,uniformB,beamEnergy, beamType.Data());
1077 if (fld) {
1078 TGeoGlobalMagField::Instance()->SetField( fld );
1079 TGeoGlobalMagField::Instance()->Lock();
1080 AliInfo("Running with the B field constructed out of GRP !");
1081 }
1082 else AliFatal("Failed to create a B field map !");
856024f0 1083 }
f7a1cc68 1084 else AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
61807e09 1085 }
f7a1cc68 1086
f2a195c1 1087 //*** Get the diamond profiles from OCDB
1088 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
1089 if (entry) {
1090 fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject());
1091 } else {
1092 AliError("No SPD diamond profile found in OCDB!");
1093 }
1094
61807e09 1095 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
1096 if (entry) {
f2a195c1 1097 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
61807e09 1098 } else {
1099 AliError("No diamond profile found in OCDB!");
1100 }
1101
1102 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
1103 if (entry) {
f2a195c1 1104 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
61807e09 1105 } else {
f2a195c1 1106 AliError("No TPC diamond profile found in OCDB!");
61807e09 1107 }
1108
77ba28ba 1109 entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers");
1110 if (entry) {
1111 fListOfCosmicTriggers = dynamic_cast<THashTable*>(entry->GetObject());
1112 entry->SetOwner(0);
1113 AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
1114 }
1115
1116 if (!fListOfCosmicTriggers) {
1117 AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will be effectively disabled!");
1118 }
1119
61807e09 1120 return kTRUE;
1121}
1122
4b71572b 1123//_____________________________________________________________________________
1124Bool_t AliReconstruction::LoadCDB()
1125{
1126 AliCodeTimerAuto("");
1127
1128 AliCDBManager::Instance()->Get("GRP/CTP/Config");
1129
7d566c20 1130 TString detStr = fLoadCDB;
ac4a7581 1131 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
4b71572b 1132 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1133 AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
1134 }
1135 return kTRUE;
1136}
522fdd91 1137//_____________________________________________________________________________
1138Bool_t AliReconstruction::LoadTriggerScalersCDB()
1139{
1140 AliCodeTimerAuto("");
1141
1142 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Scalers");
4b71572b 1143
522fdd91 1144 if (entry) {
1145
1146 AliInfo("Found an AliTriggerRunScalers in GRP/CTP/Scalers, reading it");
1147 fRunScalers = dynamic_cast<AliTriggerRunScalers*> (entry->GetObject());
1148 entry->SetOwner(0);
82ebedd6 1149 if (fRunScalers->CorrectScalersOverflow() == 0) AliInfo("32bit Trigger counters corrected for overflow");
1150
522fdd91 1151 }
1152 return kTRUE;
1153}
596a855f 1154//_____________________________________________________________________________
21a3aa09 1155Bool_t AliReconstruction::Run(const char* input)
596a855f 1156{
21a3aa09 1157 // Run Run Run
1158 AliCodeTimerAuto("");
596a855f 1159
4b71572b 1160 InitRun(input);
1161 if (GetAbort() != TSelector::kContinue) return kFALSE;
1162
1163 TChain *chain = NULL;
1164 if (fRawReader && (chain = fRawReader->GetChain())) {
2a284cef 1165 Long64_t nEntries = (fLastEvent < 0) ? (TChain::kBigNumber) : (fLastEvent - fFirstEvent + 1);
4b71572b 1166 // Proof mode
1167 if (gProof) {
6c6f2624 1168
1169 if (gGrid)
1170 gProof->Exec("TGrid::Connect(\"alien://\")",kTRUE);
1171
1172 TMessage::EnableSchemaEvolutionForAll(kTRUE);
1173 gProof->Exec("TMessage::EnableSchemaEvolutionForAll(kTRUE)",kTRUE);
1174
4b71572b 1175 gProof->AddInput(this);
81d57268 1176
1177 if (!ParseOutput()) return kFALSE;
1178
975320a0 1179 gProof->SetParameter("PROOF_MaxSlavesPerNode", 9999);
4b71572b 1180 chain->SetProof();
2a284cef 1181 chain->Process("AliReconstruction","",nEntries,fFirstEvent);
4b71572b 1182 }
1183 else {
2a284cef 1184 chain->Process(this,"",nEntries,fFirstEvent);
4b71572b 1185 }
1186 }
1187 else {
1188 Begin(NULL);
1189 if (GetAbort() != TSelector::kContinue) return kFALSE;
1190 SlaveBegin(NULL);
1191 if (GetAbort() != TSelector::kContinue) return kFALSE;
1192 //******* The loop over events
44e45fac 1193 AliInfo("Starting looping over events");
4b71572b 1194 Int_t iEvent = 0;
1195 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
1196 (fRawReader && fRawReader->NextEvent())) {
1197 if (!ProcessEvent(iEvent)) {
930e6e3e 1198 Abort("ProcessEvent",TSelector::kAbortFile);
1199 return kFALSE;
4b71572b 1200 }
1201 iEvent++;
1202 }
1203 SlaveTerminate();
1204 if (GetAbort() != TSelector::kContinue) return kFALSE;
1205 Terminate();
1206 if (GetAbort() != TSelector::kContinue) return kFALSE;
21a3aa09 1207 }
21a3aa09 1208
1209 return kTRUE;
1210}
1211
1212//_____________________________________________________________________________
4b71572b 1213void AliReconstruction::InitRawReader(const char* input)
21a3aa09 1214{
21a3aa09 1215 AliCodeTimerAuto("");
1216
4b71572b 1217 // Init raw-reader and
21a3aa09 1218 // set the input in case of raw data
4b71572b 1219 if (input) fRawInput = input;
1220 fRawReader = AliRawReader::Create(fRawInput.Data());
b58710ef 1221 if (!fRawReader)
21a3aa09 1222 AliInfo("Reconstruction will run over digits");
e0027792 1223
35042093 1224 if (!fEquipIdMap.IsNull() && fRawReader)
1225 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
1226
cd0b062e 1227 if (!fUseHLTData.IsNull()) {
1228 // create the RawReaderHLT which performs redirection of HLT input data for
1229 // the specified detectors
1230 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
1231 if (pRawReader) {
1232 fParentRawReader=fRawReader;
1233 fRawReader=pRawReader;
1234 } else {
1235 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
1236 }
1237 }
4b71572b 1238 AliSysInfo::AddStamp("CreateRawReader");
1239}
cd0b062e 1240
4b71572b 1241//_____________________________________________________________________________
1242void AliReconstruction::InitRun(const char* input)
1243{
1244 // Initialization of raw-reader,
1245 // run number, CDB etc.
1246 AliCodeTimerAuto("");
1247 AliSysInfo::AddStamp("Start");
1248
002c9d1b 1249 // Initialize raw-reader if any
4b71572b 1250 InitRawReader(input);
596a855f 1251
ec92bee0 1252 // Initialize the CDB storage
795e4a22 1253 InitCDB();
ec92bee0 1254
6bae477a 1255 // Set run number in CDBManager (if it is not already set by the user)
4b71572b 1256 if (!SetRunNumberFromData()) {
1257 Abort("SetRunNumberFromData", TSelector::kAbortProcess);
1258 return;
1259 }
002c9d1b 1260
795e4a22 1261 // Set CDB lock: from now on it is forbidden to reset the run number
1262 // or the default storage or to activate any further storage!
1263 SetCDBLock();
1264
002c9d1b 1265}
1266
1267//_____________________________________________________________________________
1268void AliReconstruction::Begin(TTree *)
1269{
1270 // Initialize AlReconstruction before
1271 // going into the event loop
1272 // Should follow the TSelector convention
1273 // i.e. initialize only the object on the client side
db4aeca1 1274 AliCodeTimerAuto("");
1275
b4fef0d2 1276 AliReconstruction *reco = NULL;
002c9d1b 1277 if (fInput) {
8fb1f1dc 1278 if ((reco = (AliReconstruction*)fInput->FindObject("AliReconstruction"))) {
002c9d1b 1279 *this = *reco;
002c9d1b 1280 }
1281 AliSysInfo::AddStamp("ReadInputInBegin");
1282 }
1283
6bae477a 1284 // Import ideal TGeo geometry and apply misalignment
1285 if (!gGeoManager) {
1286 TString geom(gSystem->DirName(fGAliceFileName));
1287 geom += "/geometry.root";
98e303d9 1288 AliGeomManager::LoadGeometry(geom.Data());
4b71572b 1289 if (!gGeoManager) {
1290 Abort("LoadGeometry", TSelector::kAbortProcess);
1291 return;
1292 }
281270d3 1293 AliSysInfo::AddStamp("LoadGeom");
ff5970a3 1294 TString detsToCheck=fRunLocalReconstruction;
4b71572b 1295 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) {
1296 Abort("CheckSymNamesLUT", TSelector::kAbortProcess);
1297 return;
1298 }
281270d3 1299 AliSysInfo::AddStamp("CheckGeom");
6bae477a 1300 }
8e245d15 1301
4b71572b 1302 if (!MisalignGeometry(fLoadAlignData)) {
1303 Abort("MisalignGeometry", TSelector::kAbortProcess);
1304 return;
1305 }
1306 AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
281270d3 1307 AliSysInfo::AddStamp("MisalignGeom");
6bae477a 1308
8cb26cdf 1309 if (!InitGRP()) {
1310 Abort("InitGRP", TSelector::kAbortProcess);
1311 return;
1312 }
1313 AliSysInfo::AddStamp("InitGRP");
1314
4b71572b 1315 if (!LoadCDB()) {
1316 Abort("LoadCDB", TSelector::kAbortProcess);
1317 return;
1318 }
1319 AliSysInfo::AddStamp("LoadCDB");
325aa76f 1320
a6dd87ad 1321 if (!LoadTriggerScalersCDB()) {
1322 Abort("LoadTriggerScalersCDB", TSelector::kAbortProcess);
1323 return;
1324 }
1325 AliSysInfo::AddStamp("LoadTriggerScalersCDB");
1326
1327
7e88424f 1328 // Read the reconstruction parameters from OCDB
1329 if (!InitRecoParams()) {
002c9d1b 1330 AliWarning("Not all detectors have correct RecoParam objects initialized");
4b71572b 1331 }
1332 AliSysInfo::AddStamp("InitRecoParams");
1333
fd2b273c 1334 if (fInput && gProof) {
b4fef0d2 1335 if (reco) *reco = *this;
fd2b273c 1336
45a6dee6 1337 gGeoManager->SetName("Geometry");
fd2b273c 1338 gProof->AddInputData(gGeoManager,kTRUE);
002c9d1b 1339 gGeoManager = NULL;
fd2b273c 1340 gProof->AddInputData(const_cast<TMap*>(AliCDBManager::Instance()->GetEntryCache()),kTRUE);
002c9d1b 1341 fInput->Add(new TParameter<Int_t>("RunNumber",AliCDBManager::Instance()->GetRun()));
f7a1cc68 1342 AliMagF *magFieldMap = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
ead7b391 1343 magFieldMap->SetName("MagneticFieldMap");
fd2b273c 1344 gProof->AddInputData(magFieldMap,kTRUE);
002c9d1b 1345 }
4b71572b 1346
1347}
1348
1349//_____________________________________________________________________________
1350void AliReconstruction::SlaveBegin(TTree*)
1351{
1352 // Initialization related to run-loader,
1353 // vertexer, trackers, recontructors
1354 // In proof mode it is executed on the slave
1355 AliCodeTimerAuto("");
1356
db4aeca1 1357 TProofOutputFile *outProofFile = NULL;
81d57268 1358 if (fInput) {
1359 if (AliDebugLevel() > 0) fInput->Print();
db4aeca1 1360 if (AliReconstruction *reco = (AliReconstruction*)fInput->FindObject("AliReconstruction")) {
1361 *this = *reco;
1362 }
4b71572b 1363 if (TGeoManager *tgeo = (TGeoManager*)fInput->FindObject("Geometry")) {
1364 gGeoManager = tgeo;
1365 AliGeomManager::SetGeometry(tgeo);
7e88424f 1366 }
281270d3 1367 if (TMap *entryCache = (TMap*)fInput->FindObject("CDBEntryCache")) {
1368 Int_t runNumber = -1;
1369 if (TProof::GetParameter(fInput,"RunNumber",runNumber) == 0) {
1370 AliCDBManager *man = AliCDBManager::Instance(entryCache,runNumber);
1371 man->SetCacheFlag(kTRUE);
1372 man->SetLock(kTRUE);
1373 man->Print();
1374 }
4b71572b 1375 }
ead7b391 1376 if (AliMagF *map = (AliMagF*)fInput->FindObject("MagneticFieldMap")) {
f7a1cc68 1377 TGeoGlobalMagField::Instance()->SetField(map);
4b71572b 1378 }
81d57268 1379 if (TNamed *outputFileName = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE"))
1380 fProofOutputFileName = outputFileName->GetTitle();
1381 if (TNamed *outputLocation = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_LOCATION"))
1382 fProofOutputLocation = outputLocation->GetTitle();
1383 if (fInput->FindObject("PROOF_OUTPUTFILE_DATASET"))
1384 fProofOutputDataset = kTRUE;
1385 if (TNamed *archiveList = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_ARCHIVE"))
1386 fProofOutputArchive = archiveList->GetTitle();
1387 if (!fProofOutputFileName.IsNull() &&
1388 !fProofOutputLocation.IsNull() &&
1389 fProofOutputArchive.IsNull()) {
1390 if (!fProofOutputDataset) {
1391 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"M");
1392 outProofFile->SetOutputFileName(Form("%s%s",fProofOutputLocation.Data(),fProofOutputFileName.Data()));
1393 }
1394 else {
1395 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"DROV",fProofOutputLocation.Data());
1396 }
1397 if (AliDebugLevel() > 0) outProofFile->Dump();
db4aeca1 1398 fOutput->Add(outProofFile);
4b71572b 1399 }
002c9d1b 1400 AliSysInfo::AddStamp("ReadInputInSlaveBegin");
7e88424f 1401 }
325aa76f 1402
4b71572b 1403 // get the run loader
1404 if (!InitRunLoader()) {
1405 Abort("InitRunLoader", TSelector::kAbortProcess);
1406 return;
1407 }
1408 AliSysInfo::AddStamp("LoadLoader");
1409
325aa76f 1410 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
2257f27e 1411
f08fc9f5 1412 // get trackers
b8cd5251 1413 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
4b71572b 1414 Abort("CreateTrackers", TSelector::kAbortProcess);
1415 return;
1416 }
1417 AliSysInfo::AddStamp("CreateTrackers");
24f7a148 1418
36711aa4 1419 // create the ESD output file and tree
db4aeca1 1420 if (!outProofFile) {
1421 ffile = TFile::Open("AliESDs.root", "RECREATE");
1422 ffile->SetCompressionLevel(2);
1423 if (!ffile->IsOpen()) {
1424 Abort("OpenESDFile", TSelector::kAbortProcess);
1425 return;
1426 }
1427 }
1428 else {
81d57268 1429 AliInfo(Form("Opening output PROOF file: %s/%s",
1430 outProofFile->GetDir(), outProofFile->GetFileName()));
db4aeca1 1431 if (!(ffile = outProofFile->OpenFile("RECREATE"))) {
1432 Abort(Form("Problems opening output PROOF file: %s/%s",
1433 outProofFile->GetDir(), outProofFile->GetFileName()),
1434 TSelector::kAbortProcess);
1435 return;
1436 }
596a855f 1437 }
46698ae4 1438
21a3aa09 1439 ftree = new TTree("esdTree", "Tree with ESD objects");
1440 fesd = new AliESDEvent();
1441 fesd->CreateStdContent();
32ba9c61 1442
1443 fesd->WriteToTree(ftree);
1d99986f 1444 if (fWriteESDfriend) {
32ba9c61 1445 // careful:
1446 // Since we add the branch manually we must
1447 // book and add it after WriteToTree
1448 // otherwise it is created twice,
1449 // once via writetotree and once here.
1450 // The case for AliESDfriend is now
1451 // caught also in AlIESDEvent::WriteToTree but
1452 // be careful when changing the name (AliESDfriend is not
1453 // a TNamed so we had to hardwire it)
21a3aa09 1454 fesdf = new AliESDfriend();
1455 TBranch *br=ftree->Branch("ESDfriend.","AliESDfriend", &fesdf);
46698ae4 1456 br->SetFile("AliESDfriends.root");
21a3aa09 1457 fesd->AddObject(fesdf);
1d99986f 1458 }
f9604a22 1459 ftree->GetUserInfo()->Add(fesd);
1460
1461 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1462 fhltesd = new AliESDEvent();
1463 fhltesd->CreateStdContent();
7491aea6 1464
1465 // read the ESD template from CDB
1466 // HLT is allowed to put non-std content to its ESD, the non-std
1467 // objects need to be created before invocation of WriteToTree in
1468 // order to create all branches. Initialization is done from an
1469 // ESD layout template in CDB
1470 AliCDBManager* man = AliCDBManager::Instance();
1471 AliCDBPath hltESDConfigPath("HLT/ConfigHLT/esdLayout");
1472 AliCDBEntry* hltESDConfig=NULL;
1473 if (man->GetId(hltESDConfigPath)!=NULL &&
1474 (hltESDConfig=man->Get(hltESDConfigPath))!=NULL) {
1475 AliESDEvent* pESDLayout=dynamic_cast<AliESDEvent*>(hltESDConfig->GetObject());
1476 if (pESDLayout) {
1477 // init all internal variables from the list of objects
1478 pESDLayout->GetStdContent();
1479
1480 // copy content and create non-std objects
1481 *fhltesd=*pESDLayout;
1482 fhltesd->Reset();
1483 } else {
1484 AliError(Form("error setting hltEsd layout from %s: invalid object type",
1485 hltESDConfigPath.GetPath().Data()));
1486 }
1487 }
1488
f9604a22 1489 fhltesd->WriteToTree(fhlttree);
1490 fhlttree->GetUserInfo()->Add(fhltesd);
5728d3d5 1491
ac4a7581 1492 ProcInfo_t procInfo;
1493 gSystem->GetProcInfo(&procInfo);
1494 AliInfo(Form("Current memory usage %d %d", procInfo.fMemResident, procInfo.fMemVirtual));
8661738e 1495
325aa76f 1496 //QA
930e6e3e 1497 //Initialize the QA and start of cycle
f1c1204d 1498 if (fRunQA || fRunGlobalQA)
1499 InitQA() ;
aa3c69a9 1500
7167ae53 1501 //Initialize the Plane Efficiency framework
1502 if (fRunPlaneEff && !InitPlaneEff()) {
4b71572b 1503 Abort("InitPlaneEff", TSelector::kAbortProcess);
1504 return;
7167ae53 1505 }
aa3c69a9 1506
14dd053c 1507 if (strcmp(gProgName,"alieve") == 0)
1508 fRunAliEVE = InitAliEVE();
1509
4b71572b 1510 return;
21a3aa09 1511}
1512
1513//_____________________________________________________________________________
4b71572b 1514Bool_t AliReconstruction::Process(Long64_t entry)
1515{
1516 // run the reconstruction over a single entry
1517 // from the chain with raw data
1518 AliCodeTimerAuto("");
1519
1520 TTree *currTree = fChain->GetTree();
33314186 1521 AliRawVEvent *event = NULL;
4b71572b 1522 currTree->SetBranchAddress("rawevent",&event);
1523 currTree->GetEntry(entry);
1524 fRawReader = new AliRawReaderRoot(event);
1525 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
1526 delete fRawReader;
1527 fRawReader = NULL;
1528 delete event;
1529
1530 return fStatus;
1531}
1532
1533//_____________________________________________________________________________
1534void AliReconstruction::Init(TTree *tree)
1535{
1536 if (tree == 0) {
1537 AliError("The input tree is not found!");
1538 return;
1539 }
1540 fChain = tree;
1541}
1542
1543//_____________________________________________________________________________
1544Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
21a3aa09 1545{
1546 // run the reconstruction over a single event
1547 // The event loop is steered in Run method
1548
1549 AliCodeTimerAuto("");
1550
1551 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1552 fRunLoader->SetEventNumber(iEvent);
1553 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1554 iEvent, iEvent);
21a3aa09 1555 fRunLoader->TreeE()->Fill();
4b71572b 1556 if (fRawReader && fRawReader->UseAutoSaveESD())
1557 fRunLoader->TreeE()->AutoSave("SaveSelf");
21a3aa09 1558 }
1559
1560 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
21a3aa09 1561 return kTRUE;
1562 }
1563
1564 AliInfo(Form("processing event %d", iEvent));
aa3c69a9 1565
16447f18 1566 fRunLoader->GetEvent(iEvent);
1567
7e88424f 1568 // Fill Event-info object
1569 GetEventInfo();
77ba28ba 1570 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo,fListOfCosmicTriggers);
48f5e52d 1571 AliInfo(Form("Current event specie: %s",fRecoParam.PrintEventSpecie()));
7e88424f 1572
a00021a7 1573 // Set the reco-params
1574 {
1575 TString detStr = fLoadCDB;
ac4a7581 1576 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
a00021a7 1577 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1578 AliReconstructor *reconstructor = GetReconstructor(iDet);
1579 if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
57acd2d2 1580 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
1581 reconstructor->SetRecoParam(par);
42ec5d3d 1582 reconstructor->SetEventInfo(&fEventInfo);
57acd2d2 1583 if (fRunQA) {
eca4fa66 1584 AliQAManager::QAManager()->SetRecoParam(iDet, par) ;
6252ceeb 1585 AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(par->GetEventSpecie())) ;
57acd2d2 1586 }
a00021a7 1587 }
1588 }
1589 }
1590
ca13fb87 1591 // QA on single raw
57acd2d2 1592 if (fRunQA) {
eca4fa66 1593 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1594 AliQAManager::QAManager()->RunOneEvent(fRawReader) ;
57acd2d2 1595 }
d506c543 1596 // local single event reconstruction
b26c3770 1597 if (!fRunLocalReconstruction.IsNull()) {
d506c543 1598 TString detectors=fRunLocalReconstruction;
a441bf51 1599 // run HLT event reconstruction first
d506c543 1600 // ;-( IsSelected changes the string
1601 if (IsSelected("HLT", detectors) &&
1602 !RunLocalEventReconstruction("HLT")) {
4b71572b 1603 if (fStopOnError) {CleanUp(); return kFALSE;}
a441bf51 1604 }
1605 detectors=fRunLocalReconstruction;
1606 detectors.ReplaceAll("HLT", "");
1607 if (!RunLocalEventReconstruction(detectors)) {
4b71572b 1608 if (fStopOnError) {CleanUp(); return kFALSE;}
b26c3770 1609 }
1610 }
1611
21a3aa09 1612 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1613 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1614 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1615 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
46698ae4 1616
d6ee376f 1617 // Set magnetic field from the tracker
21a3aa09 1618 fesd->SetMagneticField(AliTracker::GetBz());
1619 fhltesd->SetMagneticField(AliTracker::GetBz());
33fe5eb1 1620 //
1621 AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1622 if (fld) { // set info needed for field initialization
1623 fesd->SetCurrentL3(fld->GetCurrentSol());
1624 fesd->SetCurrentDip(fld->GetCurrentDip());
1625 fesd->SetBeamEnergy(fld->GetBeamEnergy());
1626 fesd->SetBeamType(fld->GetBeamTypeText());
1627 fesd->SetUniformBMap(fld->IsUniform());
1628 fesd->SetBInfoStored();
1629 //
1630 fhltesd->SetCurrentL3(fld->GetCurrentSol());
1631 fhltesd->SetCurrentDip(fld->GetCurrentDip());
1632 fhltesd->SetBeamEnergy(fld->GetBeamEnergy());
1633 fhltesd->SetBeamType(fld->GetBeamTypeText());
1634 fhltesd->SetUniformBMap(fld->IsUniform());
1635 fhltesd->SetBInfoStored();
1636 }
1637 //
71f6cda4 1638 // Set most probable pt, for B=0 tracking
9257a1bd 1639 // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
ac4a7581 1640 const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(kNDetectors));
71f6cda4 1641 if (grpRecoParam) AliExternalTrackParam::SetMostProbablePt(grpRecoParam->GetMostProbablePt());
46698ae4 1642
2e3550da 1643 // Fill raw-data error log into the ESD
21a3aa09 1644 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
2e3550da 1645
2257f27e 1646 // vertex finder
1647 if (fRunVertexFinder) {
4b71572b 1648 if (!RunVertexFinder(fesd)) {
1649 if (fStopOnError) {CleanUp(); return kFALSE;}
2257f27e 1650 }
1651 }
1652
58e8dc31 1653 // For Plane Efficiency: run the SPD trackleter
1654 if (fRunPlaneEff && fSPDTrackleter) {
1655 if (!RunSPDTrackleting(fesd)) {
1656 if (fStopOnError) {CleanUp(); return kFALSE;}
1657 }
1658 }
1659
e66fbafb 1660 // Muon tracking
b8cd5251 1661 if (!fRunTracking.IsNull()) {
e66fbafb 1662 if (fRunMuonTracking) {
21a3aa09 1663 if (!RunMuonTracking(fesd)) {
4b71572b 1664 if (fStopOnError) {CleanUp(); return kFALSE;}
24f7a148 1665 }
596a855f 1666 }
1667 }
1668
e66fbafb 1669 // barrel tracking
1670 if (!fRunTracking.IsNull()) {
4b71572b 1671 if (!RunTracking(fesd)) {
1672 if (fStopOnError) {CleanUp(); return kFALSE;}
e66fbafb 1673 }
1674 }
21c573b7 1675
596a855f 1676 // fill ESD
1677 if (!fFillESD.IsNull()) {
d506c543 1678 TString detectors=fFillESD;
f6806ad3 1679 // run HLT first and on hltesd
d506c543 1680 // ;-( IsSelected changes the string
1681 if (IsSelected("HLT", detectors) &&
1682 !FillESD(fhltesd, "HLT")) {
4b71572b 1683 if (fStopOnError) {CleanUp(); return kFALSE;}
f6806ad3 1684 }
1685 detectors=fFillESD;
d5105682 1686 // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
1687 if (detectors.Contains("ALL")) {
1688 detectors="";
ac4a7581 1689 for (Int_t idet=0; idet<kNDetectors; ++idet){
d5105682 1690 detectors += fgkDetectorName[idet];
1691 detectors += " ";
1692 }
1693 }
f6806ad3 1694 detectors.ReplaceAll("HLT", "");
1695 if (!FillESD(fesd, detectors)) {
4b71572b 1696 if (fStopOnError) {CleanUp(); return kFALSE;}
596a855f 1697 }
1698 }
a5fa6165 1699
001397cd 1700 // fill Event header information from the RawEventHeader
21a3aa09 1701 if (fRawReader){FillRawEventHeaderESD(fesd);}
63314086 1702 if (fRawReader){FillRawEventHeaderESD(fhltesd);}
596a855f 1703
1704 // combined PID
21a3aa09 1705 AliESDpid::MakePID(fesd);
596a855f 1706
b647652d 1707 if (fFillTriggerESD) {
4b71572b 1708 if (!FillTriggerESD(fesd)) {
1709 if (fStopOnError) {CleanUp(); return kFALSE;}
b647652d 1710 }
1711 }
f7812afc 1712 // Always fill scalers
1713 if (!FillTriggerScalers(fesd)) {
1714 if (fStopOnError) {CleanUp(); return kFALSE;}
1715 }
1716
b647652d 1717
21a3aa09 1718 ffile->cd();
a6ee503a 1719
3c3709c4 1720 //
67be5c77 1721 // Propagate track to the beam pipe (if not already done by ITS)
3c3709c4 1722 //
21a3aa09 1723 const Int_t ntracks = fesd->GetNumberOfTracks();
3c3709c4 1724 const Double_t kRadius = 2.8; //something less than the beam pipe radius
1725
1726 TObjArray trkArray;
1727 UShort_t *selectedIdx=new UShort_t[ntracks];
1728
1729 for (Int_t itrack=0; itrack<ntracks; itrack++){
98a50ff3 1730 const Double_t kMaxStep = 1; //max step over the material
3c3709c4 1731 Bool_t ok;
1732
21a3aa09 1733 AliESDtrack *track = fesd->GetTrack(itrack);
3c3709c4 1734 if (!track) continue;
1735
1736 AliExternalTrackParam *tpcTrack =
1737 (AliExternalTrackParam *)track->GetTPCInnerParam();
bcabd6af 1738 ok = kFALSE;
1739 if (tpcTrack)
1740 ok = AliTracker::
266a0f9b 1741 PropagateTrackToBxByBz(tpcTrack,kRadius,track->GetMass(),kMaxStep,kFALSE);
43c9dae1 1742
3c3709c4 1743 if (ok) {
1744 Int_t n=trkArray.GetEntriesFast();
1745 selectedIdx[n]=track->GetID();
1746 trkArray.AddLast(tpcTrack);
1747 }
1748
3d65e645 1749 //Tracks refitted by ITS should already be at the SPD vertex
1750 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
1751
1752 AliTracker::
266a0f9b 1753 PropagateTrackToBxByBz(track,kRadius,track->GetMass(),kMaxStep,kFALSE);
1754 Double_t x[3]; track->GetXYZ(x);
1755 Double_t b[3]; AliTracker::GetBxByBz(x,b);
1756 track->RelateToVertexBxByBz(fesd->GetPrimaryVertexSPD(), b, kVeryBig);
3c3709c4 1757
3c3709c4 1758 }
1759
1760 //
1761 // Improve the reconstructed primary vertex position using the tracks
1762 //
59224b2b 1763 Bool_t runVertexFinderTracks = fRunVertexFinderTracks;
1764 if(fesd->GetPrimaryVertexSPD()) {
1765 TString vtitle = fesd->GetPrimaryVertexSPD()->GetTitle();
1766 if(vtitle.Contains("cosmics")) {
1767 runVertexFinderTracks=kFALSE;
1768 }
c060d7fe 1769 }
a00021a7 1770
1771 if (runVertexFinderTracks) {
3c3709c4 1772 // TPC + ITS primary vertex
f09c879d 1773 ftVertexer->SetITSMode();
f2a195c1 1774 ftVertexer->SetConstraintOff();
a00021a7 1775 // get cuts for vertexer from AliGRPRecoParam
1776 if (grpRecoParam) {
1777 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
1778 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
1779 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer);
1780 ftVertexer->SetCuts(cutsVertexer);
1781 delete [] cutsVertexer; cutsVertexer = NULL;
f2a195c1 1782 if(fDiamondProfile && grpRecoParam->GetVertexerTracksConstraintITS())
1783 ftVertexer->SetVtxStart(fDiamondProfile);
43c9dae1 1784 }
21a3aa09 1785 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
3c3709c4 1786 if (pvtx) {
1787 if (pvtx->GetStatus()) {
c264b61b 1788 fesd->SetPrimaryVertexTracks(pvtx);
3c3709c4 1789 for (Int_t i=0; i<ntracks; i++) {
21a3aa09 1790 AliESDtrack *t = fesd->GetTrack(i);
266a0f9b 1791 Double_t x[3]; t->GetXYZ(x);
1792 Double_t b[3]; AliTracker::GetBxByBz(x,b);
1793 t->RelateToVertexBxByBz(pvtx, b, kVeryBig);
3c3709c4 1794 }
1795 }
1796 }
1797
1798 // TPC-only primary vertex
f09c879d 1799 ftVertexer->SetTPCMode();
f2a195c1 1800 ftVertexer->SetConstraintOff();
a00021a7 1801 // get cuts for vertexer from AliGRPRecoParam
1802 if (grpRecoParam) {
1803 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
1804 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
1805 grpRecoParam->GetVertexerTracksCutsTPC(cutsVertexer);
1806 ftVertexer->SetCuts(cutsVertexer);
1807 delete [] cutsVertexer; cutsVertexer = NULL;
f2a195c1 1808 if(fDiamondProfileTPC && grpRecoParam->GetVertexerTracksConstraintTPC())
1809 ftVertexer->SetVtxStart(fDiamondProfileTPC);
43c9dae1 1810 }
21a3aa09 1811 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
3c3709c4 1812 if (pvtx) {
1813 if (pvtx->GetStatus()) {
21a3aa09 1814 fesd->SetPrimaryVertexTPC(pvtx);
3d65e645 1815 for (Int_t i=0; i<ntracks; i++) {
1816 AliESDtrack *t = fesd->GetTrack(i);
266a0f9b 1817 Double_t x[3]; t->GetXYZ(x);
1818 Double_t b[3]; AliTracker::GetBxByBz(x,b);
1819 t->RelateToVertexTPCBxByBz(pvtx, b, kVeryBig);
3c3709c4 1820 }
1821 }
1822 }
1823
1824 }
1825 delete[] selectedIdx;
1826
21a3aa09 1827 if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile);
17c86e90 1828
c5e3e5d1 1829
d1683eef 1830 if (fRunV0Finder) {
1831 // V0 finding
1832 AliV0vertexer vtxer;
21a3aa09 1833 vtxer.Tracks2V0vertices(fesd);
5e4ff34d 1834
d1683eef 1835 if (fRunCascadeFinder) {
1836 // Cascade finding
1837 AliCascadeVertexer cvtxer;
21a3aa09 1838 cvtxer.V0sTracks2CascadeVertices(fesd);
d1683eef 1839 }
5e4ff34d 1840 }
1841
596a855f 1842 // write ESD
21a3aa09 1843 if (fCleanESD) CleanESD(fesd);
854c6476 1844
57acd2d2 1845 if (fRunQA) {
eca4fa66 1846 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1847 AliQAManager::QAManager()->RunOneEvent(fesd) ;
57acd2d2 1848 }
bea94759 1849 if (fRunGlobalQA) {
eca4fa66 1850 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
57acd2d2 1851 qadm->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
4e25ac79 1852 if (qadm && fQATasks.Contains(Form("%d", AliQAv1::kESDS)))
1853 qadm->Exec(AliQAv1::kESDS, fesd);
b03591ab 1854 }
854c6476 1855
1d99986f 1856 if (fWriteESDfriend) {
b090e6a3 1857 // fesdf->~AliESDfriend();
1858 // new (fesdf) AliESDfriend(); // Reset...
21a3aa09 1859 fesd->GetESDfriend(fesdf);
1d99986f 1860 }
21a3aa09 1861 ftree->Fill();
500d54ab 1862
2d91a353 1863 // Auto-save the ESD tree in case of prompt reco @P2
be103ac8 1864 if (fRawReader && fRawReader->UseAutoSaveESD()) {
2d91a353 1865 ftree->AutoSave("SaveSelf");
be103ac8 1866 TFile *friendfile = (TFile *)(gROOT->GetListOfFiles()->FindObject("AliESDfriends.root"));
1867 if (friendfile) friendfile->Save();
1868 }
2d91a353 1869
500d54ab 1870 // write HLT ESD
21a3aa09 1871 fhlttree->Fill();
1d99986f 1872
14dd053c 1873 // call AliEVE
1874 if (fRunAliEVE) RunAliEVE();
1875
21a3aa09 1876 fesd->Reset();
1877 fhltesd->Reset();
5728d3d5 1878 if (fWriteESDfriend) {
21a3aa09 1879 fesdf->~AliESDfriend();
1880 new (fesdf) AliESDfriend(); // Reset...
5728d3d5 1881 }
a5fa6165 1882
ac4a7581 1883 ProcInfo_t procInfo;
1884 gSystem->GetProcInfo(&procInfo);
1885 AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, procInfo.fMemResident, procInfo.fMemVirtual));
a5fa6165 1886
ca13fb87 1887 fEventInfo.Reset();
ac4a7581 1888 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
42ec5d3d 1889 if (fReconstructor[iDet]) {
a00021a7 1890 fReconstructor[iDet]->SetRecoParam(NULL);
42ec5d3d 1891 fReconstructor[iDet]->SetEventInfo(NULL);
1892 }
1f26f3e7 1893 if (fTracker[iDet]) fTracker[iDet]->SetEventInfo(NULL);
ca13fb87 1894 }
1895
53c8f690 1896 if (fRunQA || fRunGlobalQA)
eca4fa66 1897 AliQAManager::QAManager()->Increment() ;
53c8f690 1898
ca13fb87 1899 return kTRUE;
21a3aa09 1900}
1901
21a3aa09 1902//_____________________________________________________________________________
4b71572b 1903void AliReconstruction::SlaveTerminate()
21a3aa09 1904{
4b71572b 1905 // Finalize the run on the slave side
21a3aa09 1906 // Called after the exit
1907 // from the event loop
1908 AliCodeTimerAuto("");
1909
1910 if (fIsNewRunLoader) { // galice.root didn't exist
1911 fRunLoader->WriteHeader("OVERWRITE");
1912 fRunLoader->CdGAFile();
1913 fRunLoader->Write(0, TObject::kOverwrite);
1914 }
1915
f747912b 1916 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
1917 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
1918
1919 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
1920 cdbMapCopy->SetOwner(1);
1921 cdbMapCopy->SetName("cdbMap");
1922 TIter iter(cdbMap->GetTable());
1923
1924 TPair* pair = 0;
1925 while((pair = dynamic_cast<TPair*> (iter.Next()))){
1926 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
1927 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
1928 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
1929 }
1930
1931 TList *cdbListCopy = new TList();
1932 cdbListCopy->SetOwner(1);
1933 cdbListCopy->SetName("cdbList");
1934
1935 TIter iter2(cdbList);
1936
b940cb9b 1937 AliCDBId* id=0;
e84c88f5 1938 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
a4970db9 1939 cdbListCopy->Add(new TObjString(id->ToString().Data()));
f747912b 1940 }
1941
21a3aa09 1942 ftree->GetUserInfo()->Add(cdbMapCopy);
1943 ftree->GetUserInfo()->Add(cdbListCopy);
abe0c04e 1944
46698ae4 1945
21a3aa09 1946 ffile->cd();
aa3c69a9 1947
a9c0e6db 1948 if (fWriteESDfriend)
21a3aa09 1949 ftree->SetBranchStatus("ESDfriend*",0);
562dd0b4 1950 // we want to have only one tree version number
21a3aa09 1951 ftree->Write(ftree->GetName(),TObject::kOverwrite);
63314086 1952 fhlttree->Write(fhlttree->GetName(),TObject::kOverwrite);
f3a97c86 1953
a7a1e1c7 1954// Finish with Plane Efficiency evaluation: before of CleanUp !!!
1955 if (fRunPlaneEff && !FinishPlaneEff()) {
1956 AliWarning("Finish PlaneEff evaluation failed");
1957 }
1958
930e6e3e 1959 // End of cycle for the in-loop
57acd2d2 1960 if (fRunQA)
eca4fa66 1961 AliQAManager::QAManager()->EndOfCycle() ;
57acd2d2 1962
930e6e3e 1963 if (fRunGlobalQA) {
eca4fa66 1964 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
4b71572b 1965 if (qadm) {
4e25ac79 1966 if (fQATasks.Contains(Form("%d", AliQAv1::kRECPOINTS)))
1967 qadm->EndOfCycle(AliQAv1::kRECPOINTS);
1968 if (fQATasks.Contains(Form("%d", AliQAv1::kESDS)))
1969 qadm->EndOfCycle(AliQAv1::kESDS);
4b71572b 1970 qadm->Finish();
1971 }
a7807689 1972 }
87da0921 1973
1974 if (fRunQA || fRunGlobalQA) {
81d57268 1975 if (fInput &&
1976 !fProofOutputLocation.IsNull() &&
1977 fProofOutputArchive.IsNull() &&
1978 !fProofOutputDataset) {
1979 TString qaOutputFile(Form("%sMerged.%s.Data.root",
1980 fProofOutputLocation.Data(),
1981 AliQAv1::GetQADataFileName()));
1982 TProofOutputFile *qaProofFile = new TProofOutputFile(Form("Merged.%s.Data.root",
1983 AliQAv1::GetQADataFileName()));
1984 qaProofFile->SetOutputFileName(qaOutputFile.Data());
1985 if (AliDebugLevel() > 0) qaProofFile->Dump();
1986 fOutput->Add(qaProofFile);
1987 MergeQA(qaProofFile->GetFileName());
87da0921 1988 }
1989 else {
1990 MergeQA();
1991 }
1992 }
1993
4b71572b 1994 gROOT->cd();
1995 CleanUp();
81d57268 1996
1997 if (fInput) {
1998 if (!fProofOutputFileName.IsNull() &&
1999 !fProofOutputLocation.IsNull() &&
2000 fProofOutputDataset &&
2001 !fProofOutputArchive.IsNull()) {
2002 TProofOutputFile *zipProofFile = new TProofOutputFile(fProofOutputFileName.Data(),
2003 "DROV",
2004 fProofOutputLocation.Data());
2005 if (AliDebugLevel() > 0) zipProofFile->Dump();
2006 fOutput->Add(zipProofFile);
2007 TString fileList(fProofOutputArchive.Data());
2008 fileList.ReplaceAll(","," ");
2009 AliInfo(Form("Executing: zip -n root %s %s",zipProofFile->GetFileName(),fileList.Data()));
2010 gSystem->Exec(Form("zip -n root %s %s",zipProofFile->GetFileName(),fileList.Data()));
2011 }
2012 }
4b71572b 2013}
2014
2015//_____________________________________________________________________________
2016void AliReconstruction::Terminate()
2017{
f3a97c86 2018 // Create tags for the events in the ESD tree (the ESD tree is always present)
2019 // In case of empty events the tags will contain dummy values
4b71572b 2020 AliCodeTimerAuto("");
2021
e6d66370 2022 // Do not call the ESD tag creator in case of PROOF-based reconstruction
2023 if (!fInput) {
2024 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
2025 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData, AliQAv1::Instance()->GetQA(), AliQAv1::Instance()->GetEventSpecies(), AliQAv1::kNDET, AliRecoParam::kNSpecies);
2026 }
e84c88f5 2027
795e4a22 2028 // Cleanup of CDB manager: cache and active storages!
2029 AliCDBManager::Instance()->ClearCache();
596a855f 2030}
2031
b26c3770 2032//_____________________________________________________________________________
2033Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
2034{
2035// run the local reconstruction
aa3c69a9 2036
0f88822a 2037 static Int_t eventNr=0;
87932dab 2038 AliCodeTimerAuto("")
b26c3770 2039
2040 TString detStr = detectors;
ac4a7581 2041 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b26c3770 2042 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2043 AliReconstructor* reconstructor = GetReconstructor(iDet);
2044 if (!reconstructor) continue;
2045 AliLoader* loader = fLoader[iDet];
f6806ad3 2046 // Matthias April 2008: temporary fix to run HLT reconstruction
2047 // although the HLT loader is missing
2048 if (strcmp(fgkDetectorName[iDet], "HLT")==0) {
2049 if (fRawReader) {
44ed7a66 2050 reconstructor->Reconstruct(fRawReader, NULL);
f6806ad3 2051 } else {
44ed7a66 2052 TTree* dummy=NULL;
2053 reconstructor->Reconstruct(dummy, NULL);
f6806ad3 2054 }
2055 continue;
2056 }
d76c31f4 2057 if (!loader) {
2058 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
2059 continue;
2060 }
b26c3770 2061 // conversion of digits
2062 if (fRawReader && reconstructor->HasDigitConversion()) {
2063 AliInfo(Form("converting raw data digits into root objects for %s",
2064 fgkDetectorName[iDet]));
30bbd491 2065// AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
2066// fgkDetectorName[iDet]));
b26c3770 2067 loader->LoadDigits("update");
2068 loader->CleanDigits();
2069 loader->MakeDigitsContainer();
2070 TTree* digitsTree = loader->TreeD();
2071 reconstructor->ConvertDigits(fRawReader, digitsTree);
2072 loader->WriteDigits("OVERWRITE");
2073 loader->UnloadDigits();
b26c3770 2074 }
b26c3770 2075 // local reconstruction
b26c3770 2076 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
30bbd491 2077 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]));
b26c3770 2078 loader->LoadRecPoints("update");
2079 loader->CleanRecPoints();
2080 loader->MakeRecPointsContainer();
2081 TTree* clustersTree = loader->TreeR();
2082 if (fRawReader && !reconstructor->HasDigitConversion()) {
2083 reconstructor->Reconstruct(fRawReader, clustersTree);
2084 } else {
2085 loader->LoadDigits("read");
2086 TTree* digitsTree = loader->TreeD();
2087 if (!digitsTree) {
44ed7a66 2088 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
2089 if (fStopOnError) return kFALSE;
b26c3770 2090 } else {
44ed7a66 2091 reconstructor->Reconstruct(digitsTree, clustersTree);
2092 if (fRunQA) {
eca4fa66 2093 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2094 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, digitsTree) ;
44ed7a66 2095 }
b26c3770 2096 }
2097 loader->UnloadDigits();
2098 }
57acd2d2 2099 if (fRunQA) {
eca4fa66 2100 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2101 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, clustersTree) ;
57acd2d2 2102 }
eca4fa66 2103 loader->WriteRecPoints("OVERWRITE");
2104 loader->UnloadRecPoints();
2105 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
a00021a7 2106 }
2107 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
b26c3770 2108 AliError(Form("the following detectors were not found: %s",
2109 detStr.Data()));
2110 if (fStopOnError) return kFALSE;
2111 }
0f88822a 2112 eventNr++;
b26c3770 2113 return kTRUE;
2114}
58e8dc31 2115//_____________________________________________________________________________
2116Bool_t AliReconstruction::RunSPDTrackleting(AliESDEvent*& esd)
2117{
2118// run the SPD trackleting (for SPD efficiency purpouses)
2119
2120 AliCodeTimerAuto("")
2121
2122 Double_t vtxPos[3] = {0, 0, 0};
2123 Double_t vtxErr[3] = {0.0, 0.0, 0.0};
2124/*
2125 TArrayF mcVertex(3);
2126 // if(MC)
2127 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
2128 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
2129 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
2130 }
2131*/
2132 const AliESDVertex *vertex = esd->GetVertex();
2133 if(!vertex){
2134 AliWarning("Vertex not found");
2135 return kFALSE;
2136 }
2137 vertex->GetXYZ(vtxPos);
2138 vertex->GetSigmaXYZ(vtxErr);
2139 if (fSPDTrackleter) {
2140 AliInfo("running the SPD Trackleter for Plane Efficiency Evaluation");
2141
2142 // load clusters
2143 fLoader[0]->LoadRecPoints("read");
2144 TTree* tree = fLoader[0]->TreeR();
2145 if (!tree) {
2146 AliError("Can't get the ITS cluster tree");
2147 return kFALSE;
2148 }
2149 fSPDTrackleter->LoadClusters(tree);
2150 fSPDTrackleter->SetVertex(vtxPos, vtxErr);
2151 // run trackleting
2152 if (fSPDTrackleter->Clusters2Tracks(esd) != 0) {
2153 AliError("AliITSTrackleterSPDEff Clusters2Tracks failed");
2154 // fLoader[0]->UnloadRecPoints();
2155 return kFALSE;
2156 }
2157//fSPDTrackleter->UnloadRecPoints();
2158 } else {
2159 AliWarning("SPDTrackleter not available");
2160 return kFALSE;
2161 }
2162 return kTRUE;
2163}
b26c3770 2164
596a855f 2165//_____________________________________________________________________________
af885e0f 2166Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
596a855f 2167{
2168// run the barrel tracking
2169
87932dab 2170 AliCodeTimerAuto("")
030b532d 2171
92bffc4d 2172 AliVertexer *vertexer = CreateVertexer();
2173 if (!vertexer) return kFALSE;
2174
2175 AliInfo("running the ITS vertex finder");
2257f27e 2176 AliESDVertex* vertex = NULL;
92bffc4d 2177 if (fLoader[0]) {
2178 fLoader[0]->LoadRecPoints();
2179 TTree* cltree = fLoader[0]->TreeR();
2180 if (cltree) {
2181 if(fDiamondProfileSPD) vertexer->SetVtxStart(fDiamondProfileSPD);
2182 vertex = vertexer->FindVertexForCurrentEvent(cltree);
308c2f7c 2183 }
2184 else {
92bffc4d 2185 AliError("Can't get the ITS cluster tree");
308c2f7c 2186 }
92bffc4d 2187 fLoader[0]->UnloadRecPoints();
2257f27e 2188 }
92bffc4d 2189 else {
2190 AliError("Can't get the ITS loader");
2191 }
2192 if(!vertex){
2193 AliWarning("Vertex not found");
2194 vertex = new AliESDVertex();
2195 vertex->SetName("default");
2196 }
2197 else {
2198 vertex->SetName("reconstructed");
2257f27e 2199 }
92bffc4d 2200
2201 Double_t vtxPos[3];
2202 Double_t vtxErr[3];
2203 vertex->GetXYZ(vtxPos);
2204 vertex->GetSigmaXYZ(vtxErr);
2205
06cc9d95 2206 esd->SetPrimaryVertexSPD(vertex);
73c51de2 2207 AliESDVertex *vpileup = NULL;
2208 Int_t novertices = 0;
2209 vpileup = vertexer->GetAllVertices(novertices);
2210 if(novertices>1){
2211 for (Int_t kk=1; kk<novertices; kk++)esd->AddPileupVertexSPD(&vpileup[kk]);
2212 }
32e449be 2213 // if SPD multiplicity has been determined, it is stored in the ESD
92bffc4d 2214 AliMultiplicity *mult = vertexer->GetMultiplicity();
32e449be 2215 if(mult)esd->SetMultiplicity(mult);
2216
ac4a7581 2217 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b8cd5251 2218 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
2219 }
2257f27e 2220 delete vertex;
2221
92bffc4d 2222 delete vertexer;
2223
2257f27e 2224 return kTRUE;
2225}
2226
1f46a9ae 2227//_____________________________________________________________________________
af885e0f 2228Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
1f46a9ae 2229{
2230// run the HLT barrel tracking
2231
87932dab 2232 AliCodeTimerAuto("")
1f46a9ae 2233
2234 if (!fRunLoader) {
2235 AliError("Missing runLoader!");
2236 return kFALSE;
2237 }
2238
2239 AliInfo("running HLT tracking");
2240
2241 // Get a pointer to the HLT reconstructor
ac4a7581 2242 AliReconstructor *reconstructor = GetReconstructor(kNDetectors-1);
1f46a9ae 2243 if (!reconstructor) return kFALSE;
2244
2245 // TPC + ITS
2246 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2247 TString detName = fgkDetectorName[iDet];
2248 AliDebug(1, Form("%s HLT tracking", detName.Data()));
2249 reconstructor->SetOption(detName.Data());
d76c31f4 2250 AliTracker *tracker = reconstructor->CreateTracker();
1f46a9ae 2251 if (!tracker) {
2252 AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
2253 if (fStopOnError) return kFALSE;
9dcc06e1 2254 continue;
1f46a9ae 2255 }
2256 Double_t vtxPos[3];
2257 Double_t vtxErr[3]={0.005,0.005,0.010};
2258 const AliESDVertex *vertex = esd->GetVertex();
2259 vertex->GetXYZ(vtxPos);
2260 tracker->SetVertex(vtxPos,vtxErr);
2261 if(iDet != 1) {
2262 fLoader[iDet]->LoadRecPoints("read");
2263 TTree* tree = fLoader[iDet]->TreeR();
2264 if (!tree) {
2265 AliError(Form("Can't get the %s cluster tree", detName.Data()));
2266 return kFALSE;
2267 }
2268 tracker->LoadClusters(tree);
2269 }
2270 if (tracker->Clusters2Tracks(esd) != 0) {
2271 AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
2272 return kFALSE;
2273 }
2274 if(iDet != 1) {
2275 tracker->UnloadClusters();
2276 }
2277 delete tracker;
2278 }
2279
1f46a9ae 2280 return kTRUE;
2281}
2282
e66fbafb 2283//_____________________________________________________________________________
af885e0f 2284Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
e66fbafb 2285{
2286// run the muon spectrometer tracking
2287
87932dab 2288 AliCodeTimerAuto("")
e66fbafb 2289
2290 if (!fRunLoader) {
2291 AliError("Missing runLoader!");
2292 return kFALSE;
2293 }
2294 Int_t iDet = 7; // for MUON
2295
2296 AliInfo("is running...");
2297
2298 // Get a pointer to the MUON reconstructor
2299 AliReconstructor *reconstructor = GetReconstructor(iDet);
2300 if (!reconstructor) return kFALSE;
2301
2302
2303 TString detName = fgkDetectorName[iDet];
2304 AliDebug(1, Form("%s tracking", detName.Data()));
d76c31f4 2305 AliTracker *tracker = reconstructor->CreateTracker();
e66fbafb 2306 if (!tracker) {
2307 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2308 return kFALSE;
2309 }
2310
e66fbafb 2311 // read RecPoints
761350a6 2312 fLoader[iDet]->LoadRecPoints("read");
c1954ee5 2313
761350a6 2314 tracker->LoadClusters(fLoader[iDet]->TreeR());
2315
2316 Int_t rv = tracker->Clusters2Tracks(esd);
2317
761350a6 2318 if ( rv )
2319 {
e66fbafb 2320 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2321 return kFALSE;
2322 }
761350a6 2323
e66fbafb 2324 fLoader[iDet]->UnloadRecPoints();
2325
c1954ee5 2326 tracker->UnloadClusters();
2327
e66fbafb 2328 delete tracker;
2329
e66fbafb 2330 return kTRUE;
2331}
2332
2333
2257f27e 2334//_____________________________________________________________________________
af885e0f 2335Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd)
2257f27e 2336{
2337// run the barrel tracking
0f88822a 2338 static Int_t eventNr=0;
87932dab 2339 AliCodeTimerAuto("")
24f7a148 2340
815c2b38 2341 AliInfo("running tracking");
596a855f 2342
1f26f3e7 2343 // Set the event info which is used
2344 // by the trackers in order to obtain
2345 // information about read-out detectors,
2346 // trigger etc.
2347 AliDebug(1, "Setting event info");
2348 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2349 if (!fTracker[iDet]) continue;
2350 fTracker[iDet]->SetEventInfo(&fEventInfo);
2351 }
2352
91b876d1 2353 //Fill the ESD with the T0 info (will be used by the TOF)
d76c31f4 2354 if (fReconstructor[11] && fLoader[11]) {
2355 fLoader[11]->LoadRecPoints("READ");
2356 TTree *treeR = fLoader[11]->TreeR();
89916438 2357 if (treeR) {
2358 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
2359 }
d76c31f4 2360 }
91b876d1 2361
b8cd5251 2362 // pass 1: TPC + ITS inwards
2363 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2364 if (!fTracker[iDet]) continue;
2365 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
24f7a148 2366
b8cd5251 2367 // load clusters
2368 fLoader[iDet]->LoadRecPoints("read");
6efecea1 2369 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
b8cd5251 2370 TTree* tree = fLoader[iDet]->TreeR();
2371 if (!tree) {
2372 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
24f7a148 2373 return kFALSE;
2374 }
b8cd5251 2375 fTracker[iDet]->LoadClusters(tree);
6efecea1 2376 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
b8cd5251 2377 // run tracking
2378 if (fTracker[iDet]->Clusters2Tracks(esd) != 0) {
2379 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
24f7a148 2380 return kFALSE;
2381 }
878e1fe1 2382 // preliminary PID in TPC needed by the ITS tracker
2383 if (iDet == 1) {
b26c3770 2384 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
878e1fe1 2385 AliESDpid::MakePID(esd);
0f88822a 2386 }
6efecea1 2387 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
b8cd5251 2388 }
596a855f 2389
b8cd5251 2390 // pass 2: ALL backwards
aa3c69a9 2391
ac4a7581 2392 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b8cd5251 2393 if (!fTracker[iDet]) continue;
2394 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
2395
2396 // load clusters
2397 if (iDet > 1) { // all except ITS, TPC
2398 TTree* tree = NULL;
7b61cd9c 2399 fLoader[iDet]->LoadRecPoints("read");
6efecea1 2400 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
7b61cd9c 2401 tree = fLoader[iDet]->TreeR();
b8cd5251 2402 if (!tree) {
eca4fa66 2403 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2404 return kFALSE;
24f7a148 2405 }
0f88822a 2406 fTracker[iDet]->LoadClusters(tree);
6efecea1 2407 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
b8cd5251 2408 }
24f7a148 2409
b8cd5251 2410 // run tracking
283f39c6 2411 if (iDet>1) // start filling residuals for the "outer" detectors
eca4fa66 2412 if (fRunGlobalQA) {
2413 AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
2414 TObjArray ** arr = AliTracker::GetResidualsArray() ;
c9526f68 2415 if (arr) {
0a349581 2416 AliRecoParam::EventSpecie_t es=fRecoParam.GetEventSpecie();
2417 TObjArray * elem = arr[AliRecoParam::AConvert(es)];
c9526f68 2418 if ( elem && (! elem->At(0)) ) {
2419 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
2420 if (qadm) qadm->InitRecPointsForTracker() ;
2421 }
2422 }
eca4fa66 2423 }
b8cd5251 2424 if (fTracker[iDet]->PropagateBack(esd) != 0) {
2425 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
49dfd67a 2426 // return kFALSE;
b8cd5251 2427 }
24f7a148 2428
b8cd5251 2429 // unload clusters
6e65648b 2430 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
b8cd5251 2431 fTracker[iDet]->UnloadClusters();
7b61cd9c 2432 fLoader[iDet]->UnloadRecPoints();
b8cd5251 2433 }
8f37df88 2434 // updated PID in TPC needed by the ITS tracker -MI
2435 if (iDet == 1) {
8f37df88 2436 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2437 AliESDpid::MakePID(esd);
2438 }
6efecea1 2439 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
b8cd5251 2440 }
283f39c6 2441 //stop filling residuals for the "outer" detectors
57acd2d2 2442 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
596a855f 2443
b8cd5251 2444 // pass 3: TRD + TPC + ITS refit inwards
aa3c69a9 2445
b8cd5251 2446 for (Int_t iDet = 2; iDet >= 0; iDet--) {
2447 if (!fTracker[iDet]) continue;
2448 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
596a855f 2449
b8cd5251 2450 // run tracking
283f39c6 2451 if (iDet<2) // start filling residuals for TPC and ITS
eca4fa66 2452 if (fRunGlobalQA) {
2453 AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
2454 TObjArray ** arr = AliTracker::GetResidualsArray() ;
c9526f68 2455 if (arr) {
0a349581 2456 AliRecoParam::EventSpecie_t es=fRecoParam.GetEventSpecie();
2457 TObjArray * elem = arr[AliRecoParam::AConvert(es)];
c9526f68 2458 if ( elem && (! elem->At(0)) ) {
2459 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
2460 if (qadm) qadm->InitRecPointsForTracker() ;
2461 }
2462 }
eca4fa66 2463 }
2464
b8cd5251 2465 if (fTracker[iDet]->RefitInward(esd) != 0) {
2466 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
49dfd67a 2467 // return kFALSE;
b8cd5251 2468 }
db2368d0 2469 // run postprocessing
2470 if (fTracker[iDet]->PostProcess(esd) != 0) {
2471 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
2472 // return kFALSE;
2473 }
6efecea1 2474 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
6e65648b 2475 }
2476
2477 // write space-points to the ESD in case alignment data output
2478 // is switched on
2479 if (fWriteAlignmentData)
2480 WriteAlignmentData(esd);
2481
2482 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2483 if (!fTracker[iDet]) continue;
b8cd5251 2484 // unload clusters
2485 fTracker[iDet]->UnloadClusters();
6efecea1 2486 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
b8cd5251 2487 fLoader[iDet]->UnloadRecPoints();
6efecea1 2488 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
b8cd5251 2489 }
283f39c6 2490 // stop filling residuals for TPC and ITS
57acd2d2 2491 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
854c6476 2492
0f88822a 2493 eventNr++;
596a855f 2494 return kTRUE;
2495}
2496
d64bd07d 2497//_____________________________________________________________________________
2498Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
2499 //
2500 // Remove the data which are not needed for the physics analysis.
2501 //
2502
d64bd07d 2503 Int_t nTracks=esd->GetNumberOfTracks();
18571674 2504 Int_t nV0s=esd->GetNumberOfV0s();
cf37fd88 2505 AliInfo
2506 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
d64bd07d 2507
18571674 2508 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
7f68891d 2509 Bool_t rc=esd->Clean(cleanPars);
d64bd07d 2510
7f68891d 2511 nTracks=esd->GetNumberOfTracks();
18571674 2512 nV0s=esd->GetNumberOfV0s();
cf37fd88 2513 AliInfo
ae5d5566 2514 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
d64bd07d 2515
7f68891d 2516 return rc;
d64bd07d 2517}
2518
596a855f 2519//_____________________________________________________________________________
af885e0f 2520Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
596a855f 2521{
2522// fill the event summary data
2523
87932dab 2524 AliCodeTimerAuto("")
0f88822a 2525 static Int_t eventNr=0;
596a855f 2526 TString detStr = detectors;
abe0c04e 2527
ac4a7581 2528 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
abe0c04e 2529 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
b8cd5251 2530 AliReconstructor* reconstructor = GetReconstructor(iDet);
2531 if (!reconstructor) continue;
4b71572b 2532 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
2533 TTree* clustersTree = NULL;
2534 if (fLoader[iDet]) {
2535 fLoader[iDet]->LoadRecPoints("read");
2536 clustersTree = fLoader[iDet]->TreeR();
2537 if (!clustersTree) {
2538 AliError(Form("Can't get the %s clusters tree",
2539 fgkDetectorName[iDet]));
2540 if (fStopOnError) return kFALSE;
2541 }
2542 }
2543 if (fRawReader && !reconstructor->HasDigitConversion()) {
2544 reconstructor->FillESD(fRawReader, clustersTree, esd);
2545 } else {
2546 TTree* digitsTree = NULL;
d76c31f4 2547 if (fLoader[iDet]) {
4b71572b 2548 fLoader[iDet]->LoadDigits("read");
2549 digitsTree = fLoader[iDet]->TreeD();
2550 if (!digitsTree) {
2551 AliError(Form("Can't get the %s digits tree",
b26c3770 2552 fgkDetectorName[iDet]));
2553 if (fStopOnError) return kFALSE;
2554 }
2555 }
4b71572b 2556 reconstructor->FillESD(digitsTree, clustersTree, esd);
2557 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
2558 }
2559 if (fLoader[iDet]) {
2560 fLoader[iDet]->UnloadRecPoints();
596a855f 2561 }
2562 }
2563
2564 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
815c2b38 2565 AliError(Form("the following detectors were not found: %s",
2566 detStr.Data()));
596a855f 2567 if (fStopOnError) return kFALSE;
2568 }
6efecea1 2569 AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr);
0f88822a 2570 eventNr++;
596a855f 2571 return kTRUE;
2572}
2573
b647652d 2574//_____________________________________________________________________________
af885e0f 2575Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
b647652d 2576{
2577 // Reads the trigger decision which is
2578 // stored in Trigger.root file and fills
2579 // the corresponding esd entries
2580
87932dab 2581 AliCodeTimerAuto("")
2582
b647652d 2583 AliInfo("Filling trigger information into the ESD");
2584
2585 if (fRawReader) {
2586 AliCTPRawStream input(fRawReader);
2587 if (!input.Next()) {
7e88424f 2588 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
b647652d 2589 }
2590 else {
7e88424f 2591 if (esd->GetTriggerMask() != input.GetClassMask())
2592 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
2593 input.GetClassMask(),esd->GetTriggerMask()));
2594 if (esd->GetOrbitNumber() != input.GetOrbitID())
2595 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
2596 input.GetOrbitID(),esd->GetOrbitNumber()));
2597 if (esd->GetBunchCrossNumber() != input.GetBCID())
2598 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
2599 input.GetBCID(),esd->GetBunchCrossNumber()));
e61ed4b1 2600 AliESDHeader* esdheader = esd->GetHeader();
2601 esdheader->SetL0TriggerInputs(input.GetL0Inputs());
2602 esdheader->SetL1TriggerInputs(input.GetL1Inputs());
2603 esdheader->SetL2TriggerInputs(input.GetL2Inputs());
a6dd87ad 2604 // IR
2605 UInt_t orbit=input.GetOrbitID();
2606 for(Int_t i=0 ; i<input.GetNIRs() ; i++ )
2607 if(TMath::Abs(Int_t(orbit-(input.GetIR(i))->GetOrbit()))<=1){
2608 esdheader->AddTriggerIR(input.GetIR(i));
2609 }
b647652d 2610 }
b024fd7f 2611 }
f7812afc 2612 return kTRUE;
2613}
2614//_____________________________________________________________________________
2615Bool_t AliReconstruction::FillTriggerScalers(AliESDEvent*& esd)
2616{
522fdd91 2617 //Scalers
82ebedd6 2618 //fRunScalers->Print();
2619 if(fRunScalers && fRunScalers->CheckRunScalers()){
a6dd87ad 2620 AliTimeStamp* timestamp = new AliTimeStamp(esd->GetOrbitNumber(), esd->GetPeriodNumber(), esd->GetBunchCrossNumber());
82ebedd6 2621 //AliTimeStamp* timestamp = new AliTimeStamp(10308000, 0, (ULong64_t)486238);
522fdd91 2622 AliESDHeader* esdheader = fesd->GetHeader();
2623 for(Int_t i=0;i<50;i++){
82ebedd6 2624 if((1<<i) & esd->GetTriggerMask()){
6863d231 2625 AliTriggerScalersESD* scalesd = fRunScalers->GetScalersForEventClass( timestamp, i+1);
82ebedd6 2626 if(scalesd)esdheader->SetTriggerScalersRecord(scalesd);
522fdd91 2627 }
2628 }
2629 }
b647652d 2630 return kTRUE;
2631}
001397cd 2632//_____________________________________________________________________________
af885e0f 2633Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
001397cd 2634{
2635 //
2636 // Filling information from RawReader Header
2637 //
2638
151bea4e 2639 if (!fRawReader) return kFALSE;
2640
001397cd 2641 AliInfo("Filling information from RawReader Header");
151bea4e 2642
2643 esd->SetBunchCrossNumber(fRawReader->GetBCID());
2644 esd->SetOrbitNumber(fRawReader->GetOrbitID());
2645 esd->SetPeriodNumber(fRawReader->GetPeriod());
2646
2647 esd->SetTimeStamp(fRawReader->GetTimestamp());
2648 esd->SetEventType(fRawReader->GetType());
001397cd 2649
2650 return kTRUE;
2651}
2652
2653
596a855f 2654//_____________________________________________________________________________
2655Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
2656{
2657// check whether detName is contained in detectors
2658// if yes, it is removed from detectors
2659
2660 // check if all detectors are selected
2661 if ((detectors.CompareTo("ALL") == 0) ||
2662 detectors.BeginsWith("ALL ") ||
2663 detectors.EndsWith(" ALL") ||
2664 detectors.Contains(" ALL ")) {
2665 detectors = "ALL";
2666 return kTRUE;
2667 }
2668
2669 // search for the given detector
2670 Bool_t result = kFALSE;
2671 if ((detectors.CompareTo(detName) == 0) ||
2672 detectors.BeginsWith(detName+" ") ||
2673 detectors.EndsWith(" "+detName) ||
2674 detectors.Contains(" "+detName+" ")) {
2675 detectors.ReplaceAll(detName, "");
2676 result = kTRUE;
2677 }
2678
2679 // clean up the detectors string
2680 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
2681 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
2682 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
2683
2684 return result;
2685}
e583c30d 2686
f08fc9f5 2687//_____________________________________________________________________________
2688Bool_t AliReconstruction::InitRunLoader()
2689{
2690// get or create the run loader
2691
2692 if (gAlice) delete gAlice;
2693 gAlice = NULL;
2694
b4a74dd9 2695 TFile *gafile = TFile::Open(fGAliceFileName.Data());
2696 // if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
2697 if (gafile) { // galice.root exists
2698 gafile->Close();
2699 delete gafile;
2700
b26c3770 2701 // load all base libraries to get the loader classes
2702 TString libs = gSystem->GetLibraries();
ac4a7581 2703 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b26c3770 2704 TString detName = fgkDetectorName[iDet];
2705 if (detName == "HLT") continue;
2706 if (libs.Contains("lib" + detName + "base.so")) continue;
2707 gSystem->Load("lib" + detName + "base.so");
2708 }
f08fc9f5 2709 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
2710 if (!fRunLoader) {
2711 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
2712 CleanUp();
2713 return kFALSE;
2714 }
325aa76f 2715
b26c3770 2716 fRunLoader->CdGAFile();
325aa76f 2717 fRunLoader->LoadgAlice();
f08fc9f5 2718
6cae184e 2719 //PH This is a temporary fix to give access to the kinematics
2720 //PH that is needed for the labels of ITS clusters
f2ee4290 2721 fRunLoader->LoadHeader();
6cae184e 2722 fRunLoader->LoadKinematics();
2723
f08fc9f5 2724 } else { // galice.root does not exist
2725 if (!fRawReader) {
2726 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
f08fc9f5 2727 }
2728 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
2729 AliConfig::GetDefaultEventFolderName(),
2730 "recreate");
2731 if (!fRunLoader) {
2732 AliError(Form("could not create run loader in file %s",
2733 fGAliceFileName.Data()));
2734 CleanUp();
2735 return kFALSE;
2736 }
21a3aa09 2737 fIsNewRunLoader = kTRUE;
f08fc9f5 2738 fRunLoader->MakeTree("E");
21a3aa09 2739
973388c2 2740 if (fNumberOfEventsPerFile > 0)
2741 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
2742 else
21a3aa09 2743 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
f08fc9f5 2744 }
2745
2746 return kTRUE;
2747}
2748
c757bafd 2749//_____________________________________________________________________________
b8cd5251 2750AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
c757bafd 2751{
f08fc9f5 2752// get the reconstructor object and the loader for a detector
c757bafd 2753
7e88424f 2754 if (fReconstructor[iDet]) {
2755 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2756 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2757 fReconstructor[iDet]->SetRecoParam(par);
42ec5d3d 2758 fReconstructor[iDet]->SetRunInfo(fRunInfo);
7e88424f 2759 }
2760 return fReconstructor[iDet];
2761 }
b8cd5251 2762
2763 // load the reconstructor object
2764 TPluginManager* pluginManager = gROOT->GetPluginManager();
2765 TString detName = fgkDetectorName[iDet];
2766 TString recName = "Ali" + detName + "Reconstructor";
f0999a9a 2767
2768 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
b8cd5251 2769
b8cd5251 2770 AliReconstructor* reconstructor = NULL;
2771 // first check if a plugin is defined for the reconstructor
2772 TPluginHandler* pluginHandler =
2773 pluginManager->FindHandler("AliReconstructor", detName);
f08fc9f5 2774 // if not, add a plugin for it
2775 if (!pluginHandler) {
b8cd5251 2776 AliDebug(1, Form("defining plugin for %s", recName.Data()));
b26c3770 2777 TString libs = gSystem->GetLibraries();
2778 if (libs.Contains("lib" + detName + "base.so") ||
2779 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
b8cd5251 2780 pluginManager->AddHandler("AliReconstructor", detName,
2781 recName, detName + "rec", recName + "()");
2782 } else {
2783 pluginManager->AddHandler("AliReconstructor", detName,
2784 recName, detName, recName + "()");
c757bafd 2785 }
b8cd5251 2786 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
2787 }
2788 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2789 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
c757bafd 2790 }
b8cd5251 2791 if (reconstructor) {
2792 TObject* obj = fOptions.FindObject(detName.Data());
2793 if (obj) reconstructor->SetOption(obj->GetTitle());
1e500f25 2794 reconstructor->SetRunInfo(fRunInfo);
d76c31f4 2795 reconstructor->Init();
b8cd5251 2796 fReconstructor[iDet] = reconstructor;
2797 }
2798
f08fc9f5 2799 // get or create the loader
2800 if (detName != "HLT") {
2801 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
2802 if (!fLoader[iDet]) {
2803 AliConfig::Instance()
2804 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
2805 detName, detName);
2806 // first check if a plugin is defined for the loader
bb0901a4 2807 pluginHandler =
f08fc9f5 2808 pluginManager->FindHandler("AliLoader", detName);
2809 // if not, add a plugin for it
2810 if (!pluginHandler) {
2811 TString loaderName = "Ali" + detName + "Loader";
2812 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
2813 pluginManager->AddHandler("AliLoader", detName,
2814 loaderName, detName + "base",
2815 loaderName + "(const char*, TFolder*)");
2816 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
2817 }
2818 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2819 fLoader[iDet] =
2820 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
2821 fRunLoader->GetEventFolder());
2822 }
2823 if (!fLoader[iDet]) { // use default loader
2824 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
2825 }
2826 if (!fLoader[iDet]) {
2827 AliWarning(Form("couldn't get loader for %s", detName.Data()));
6667b602 2828 if (fStopOnError) return NULL;
f08fc9f5 2829 } else {
2830 fRunLoader->AddLoader(fLoader[iDet]);
2831 fRunLoader->CdGAFile();
2832 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
2833 fRunLoader->Write(0, TObject::kOverwrite);
2834 }
2835 }
2836 }
2837
7e88424f 2838 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2839 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2840 reconstructor->SetRecoParam(par);
42ec5d3d 2841 reconstructor->SetRunInfo(fRunInfo);
7e88424f 2842 }
b8cd5251 2843 return reconstructor;
c757bafd 2844}
2845
2257f27e 2846//_____________________________________________________________________________
92bffc4d 2847AliVertexer* AliReconstruction::CreateVertexer()
2257f27e 2848{
2849// create the vertexer
92bffc4d 2850// Please note that the caller is the owner of the
2851// vertexer
2257f27e 2852
92bffc4d 2853 AliVertexer* vertexer = NULL;
b8cd5251 2854 AliReconstructor* itsReconstructor = GetReconstructor(0);
5ec10f5d 2855 if (itsReconstructor && ((fRunLocalReconstruction.Contains("ITS")) || fRunTracking.Contains("ITS"))) {
92bffc4d 2856 vertexer = itsReconstructor->CreateVertexer();
2257f27e 2857 }
92bffc4d 2858 if (!vertexer) {
815c2b38 2859 AliWarning("couldn't create a vertexer for ITS");
2257f27e 2860 }
2861
92bffc4d 2862 return vertexer;
2257f27e 2863}
2864
24f7a148 2865//_____________________________________________________________________________
b8cd5251 2866Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
24f7a148 2867{
f08fc9f5 2868// create the trackers
44e45fac 2869 AliInfo("Creating trackers");
24f7a148 2870
b8cd5251 2871 TString detStr = detectors;
ac4a7581 2872 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b8cd5251 2873 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2874 AliReconstructor* reconstructor = GetReconstructor(iDet);
2875 if (!reconstructor) continue;
2876 TString detName = fgkDetectorName[iDet];
1f46a9ae 2877 if (detName == "HLT") {
2878 fRunHLTTracking = kTRUE;
2879 continue;
2880 }
e66fbafb 2881 if (detName == "MUON") {
2882 fRunMuonTracking = kTRUE;
2883 continue;
2884 }
2885
f08fc9f5 2886
d76c31f4 2887 fTracker[iDet] = reconstructor->CreateTracker();
f08fc9f5 2888 if (!fTracker[iDet] && (iDet < 7)) {
2889 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
8250d5f5 2890 if (fStopOnError) return kFALSE;
2891 }
6efecea1 2892 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
8250d5f5 2893 }
2894
24f7a148 2895 return kTRUE;
2896}
2897
e583c30d 2898//_____________________________________________________________________________
4b71572b 2899void AliReconstruction::CleanUp()
e583c30d 2900{
2901// delete trackers and the run loader and close and delete the file
2902
ac4a7581 2903 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b8cd5251 2904 delete fReconstructor[iDet];
2905 fReconstructor[iDet] = NULL;
2906 fLoader[iDet] = NULL;
2907 delete fTracker[iDet];
2908 fTracker[iDet] = NULL;
2909 }
4b71572b 2910 delete fRunInfo;
7e88424f 2911 fRunInfo = NULL;
2912
58e8dc31 2913 delete fSPDTrackleter;
2914 fSPDTrackleter = NULL;
2915
4b71572b 2916 delete ftVertexer;
21a3aa09 2917 ftVertexer = NULL;
795e4a22 2918
e583c30d 2919 delete fRunLoader;
2920 fRunLoader = NULL;
b649205a 2921 delete fRawReader;
2922 fRawReader = NULL;
4b71572b 2923 delete fParentRawReader;
cd0b062e 2924 fParentRawReader=NULL;
e583c30d 2925
4b71572b 2926 if (ffile) {
2927 ffile->Close();
2928 delete ffile;
2929 ffile = NULL;
24f7a148 2930 }
87da0921 2931
bf76b847 2932 if (AliQAManager::QAManager())
2933 AliQAManager::QAManager()->ShowQA() ;
eca4fa66 2934 AliQAManager::Destroy() ;
2935
87da0921 2936 TGeoGlobalMagField::Instance()->SetField(NULL);
24f7a148 2937}
f3a97c86 2938
af885e0f 2939void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
98937d93 2940{
2941 // Write space-points which are then used in the alignment procedures
6e65648b 2942 // For the moment only ITS, TPC, TRD and TOF
98937d93 2943
98937d93 2944 Int_t ntracks = esd->GetNumberOfTracks();
2945 for (Int_t itrack = 0; itrack < ntracks; itrack++)
2946 {
2947 AliESDtrack *track = esd->GetTrack(itrack);
2948 Int_t nsp = 0;
ef7253ac 2949 Int_t idx[200];
76741755 2950 for (Int_t i=0; i<200; ++i) idx[i] = -1; //PH avoid uninitialized values
81aa7a0d 2951 for (Int_t iDet = 5; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
6e65648b 2952 nsp += track->GetNcls(iDet);
2953
2954 if (iDet==0) { // ITS "extra" clusters
2955 track->GetClusters(iDet,idx);
2956 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
2957 }
2958 }
2959
98937d93 2960 if (nsp) {
2961 AliTrackPointArray *sp = new AliTrackPointArray(nsp);
2962 track->SetTrackPointArray(sp);
2963 Int_t isptrack = 0;
81aa7a0d 2964 for (Int_t iDet = 5; iDet >= 0; iDet--) {
98937d93 2965 AliTracker *tracker = fTracker[iDet];
2966 if (!tracker) continue;
6e65648b 2967 Int_t nspdet = track->GetClusters(iDet,idx);
2968
2969 if (iDet==0) // ITS "extra" clusters
2970 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
2971
98937d93 2972 if (nspdet <= 0) continue;
98937d93 2973 AliTrackPoint p;
2974 Int_t isp = 0;
2975 Int_t isp2 = 0;
4ed6fb1c 2976 while (isp2 < nspdet) {
f3c6e4c9 2977 Bool_t isvalid=kTRUE;
2978
2979 Int_t index=idx[isp++];
2980 if (index < 0) continue;
2981
c12b6e44 2982 TString dets = fgkDetectorName[iDet];
2983 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
2984 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
2985 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
2986 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
f3c6e4c9 2987 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
48ce48d1 2988 } else {
f3c6e4c9 2989 isvalid = tracker->GetTrackPoint(index,p);
48ce48d1 2990 }
2991 isp2++;
98937d93 2992 if (!isvalid) continue;
eb2d90b9 2993 if (iDet==0 && (isp-1)>=6) p.SetExtra();
f3c6e4c9 2994 sp->AddPoint(isptrack,&p); isptrack++;
98937d93 2995 }
98937d93 2996 }
2997 }
2998 }
98937d93 2999}
2e3550da 3000
3001//_____________________________________________________________________________
af885e0f 3002void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
2e3550da 3003{
3004 // The method reads the raw-data error log
3005 // accumulated within the rawReader.
3006 // It extracts the raw-data errors related to
3007 // the current event and stores them into
3008 // a TClonesArray inside the esd object.
3009
3010 if (!fRawReader) return;
3011
3012 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
3013
3014 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
3015 if (!log) continue;
3016 if (iEvent != log->GetEventNumber()) continue;
3017
3018 esd->AddRawDataErrorLog(log);
3019 }
3020
3021}
46698ae4 3022
8661738e 3023//_____________________________________________________________________________
3024void AliReconstruction::CheckQA()
3025{
3026// check the QA of SIM for this run and remove the detectors
3027// with status Fatal
3028
57acd2d2 3029// TString newRunLocalReconstruction ;
3030// TString newRunTracking ;
3031// TString newFillESD ;
3032//
4e25ac79 3033// for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
3034// TString detName(AliQAv1::GetDetName(iDet)) ;
3035// AliQAv1 * qa = AliQAv1::Instance(AliQAv1::DETECTORINDEX_t(iDet)) ;
3036// if ( qa->IsSet(AliQAv1::DETECTORINDEX_t(iDet), AliQAv1::kSIM, specie, AliQAv1::kFATAL)) {
57acd2d2 3037// AliInfo(Form("QA status for %s %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed",
3038// detName.Data(), AliRecoParam::GetEventSpecieName(es))) ;
3039// } else {
4e25ac79 3040// if ( fRunLocalReconstruction.Contains(AliQAv1::GetDetName(iDet)) ||
57acd2d2 3041// fRunLocalReconstruction.Contains("ALL") ) {
3042// newRunLocalReconstruction += detName ;
3043// newRunLocalReconstruction += " " ;
3044// }
4e25ac79 3045// if ( fRunTracking.Contains(AliQAv1::GetDetName(iDet)) ||
57acd2d2 3046// fRunTracking.Contains("ALL") ) {
3047// newRunTracking += detName ;
3048// newRunTracking += " " ;
3049// }
4e25ac79 3050// if ( fFillESD.Contains(AliQAv1::GetDetName(iDet)) ||
57acd2d2 3051// fFillESD.Contains("ALL") ) {
3052// newFillESD += detName ;
3053// newFillESD += " " ;
3054// }
3055// }
3056// }
3057// fRunLocalReconstruction = newRunLocalReconstruction ;
3058// fRunTracking = newRunTracking ;
3059// fFillESD = newFillESD ;
a5fa6165 3060}
5b188f2f 3061
3062//_____________________________________________________________________________
3063Int_t AliReconstruction::GetDetIndex(const char* detector)
3064{
3065 // return the detector index corresponding to detector
3066 Int_t index = -1 ;
ac4a7581 3067 for (index = 0; index < kNDetectors ; index++) {
5b188f2f 3068 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
3069 break ;
3070 }
3071 return index ;
3072}
7167ae53 3073//_____________________________________________________________________________
3074Bool_t AliReconstruction::FinishPlaneEff() {
3075 //
3076 // Here execute all the necessary operationis, at the end of the tracking phase,
d7f8fd68 3077 // in case that evaluation of PlaneEfficiencies was required for some detector.
3078 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
7167ae53 3079 //
3080 // This Preliminary version works only FOR ITS !!!!!
3081 // other detectors (TOF,TRD, etc. have to develop their specific codes)
3082 //
3083 // Input: none
d7f8fd68 3084 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
7167ae53 3085 //
3086 Bool_t ret=kFALSE;
58e8dc31 3087 //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
d7f8fd68 3088 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
7167ae53 3089 //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
58e8dc31 3090 if(fTracker[iDet] && fTracker[iDet]->GetPlaneEff()) {
d7f8fd68 3091 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
3092 TString name=planeeff->GetName();
3093 name+=".root";
3094 TFile* pefile = TFile::Open(name, "RECREATE");
3095 ret=(Bool_t)planeeff->Write();
3096 pefile->Close();
5fbd4fd6 3097 if(planeeff->GetCreateHistos()) {
d7f8fd68 3098 TString hname=planeeff->GetName();
3099 hname+="Histo.root";
3100 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
5fbd4fd6 3101 }
3102 }
58e8dc31 3103 if(fSPDTrackleter) {
3104 AliPlaneEff *planeeff=fSPDTrackleter->GetPlaneEff();
3105 TString name="AliITSPlaneEffSPDtracklet.root";
3106 TFile* pefile = TFile::Open(name, "RECREATE");
3107 ret=(Bool_t)planeeff->Write();
3108 pefile->Close();
3109 AliESDEvent *dummy=NULL;
3110 ret=(Bool_t)fSPDTrackleter->PostProcess(dummy); // take care of writing other files
3111 }
7167ae53 3112 }
3113 return ret;
3114}
3115//_____________________________________________________________________________
3116Bool_t AliReconstruction::InitPlaneEff() {
3117//
3118 // Here execute all the necessary operations, before of the tracking phase,
3119 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
58e8dc31 3120 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
7167ae53 3121 // which should be updated/recalculated.
3122 //
3123 // This Preliminary version will work only FOR ITS !!!!!
3124 // other detectors (TOF,TRD, etc. have to develop their specific codes)
3125 //
3126 // Input: none
3127 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
3128 //
58e8dc31 3129 AliWarning(Form("Implementation of this method not yet completed !! Method return kTRUE"));
3130
3131 fSPDTrackleter = NULL;
3132 AliReconstructor* itsReconstructor = GetReconstructor(0);
3133 if (itsReconstructor) {
3134 fSPDTrackleter = itsReconstructor->CreateTrackleter(); // this is NULL unless required in RecoParam
3135 }
3136 if (fSPDTrackleter) {
3137 AliInfo("Trackleter for SPD has been created");
3138 }
3139
7167ae53 3140 return kTRUE;
7520312d 3141}
14dd053c 3142
3143//_____________________________________________________________________________
3144Bool_t AliReconstruction::InitAliEVE()
3145{
3146 // This method should be called only in case
3147 // AliReconstruction is run
3148 // within the alieve environment.
3149 // It will initialize AliEVE in a way
3150 // so that it can visualize event processed
3151 // by AliReconstruction.
3152 // The return flag shows whenever the
3153 // AliEVE initialization was successful or not.
3154
3155 TString macroStr;
3156 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
3157 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
3158 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
3159
6a840f1e 3160 gROOT->ProcessLine("if (!AliEveEventManager::GetMaster()){new AliEveEventManager();AliEveEventManager::GetMaster()->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(AliEveEventManager::GetMaster());};");
de33999e 3161 gROOT->ProcessLine("alieve_online_init()");
14dd053c 3162
3163 return kTRUE;
3164}
3165
3166//_____________________________________________________________________________
3167void AliReconstruction::RunAliEVE()
3168{
3169 // Runs AliEVE visualisation of
3170 // the current event.
3171 // Should be executed only after
3172 // successful initialization of AliEVE.
3173
3174 AliInfo("Running AliEVE...");
519975fe 3175 gROOT->ProcessLine(Form("AliEveEventManager::GetMaster()->SetEvent((AliRunLoader*)0x%lx,(AliRawReader*)0x%lx,(AliESDEvent*)0x%lx,(AliESDfriend*)0x%lx);",fRunLoader,fRawReader,fesd,fesdf));
14dd053c 3176 gSystem->Run();
3177}
ce43afbe 3178
3179//_____________________________________________________________________________
3180Bool_t AliReconstruction::SetRunQA(TString detAndAction)
3181{
3182 // Allows to run QA for a selected set of detectors
44ed7a66 3183 // and a selected set of tasks among RAWS, DIGITSR, RECPOINTS and ESDS
ce43afbe 3184 // all selected detectors run the same selected tasks
3185
3186 if (!detAndAction.Contains(":")) {
3187 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
3188 fRunQA = kFALSE ;
3189 return kFALSE ;
3190 }
3191 Int_t colon = detAndAction.Index(":") ;
3192 fQADetectors = detAndAction(0, colon) ;
3193 if (fQADetectors.Contains("ALL") )
3194 fQADetectors = fFillESD ;
e84c88f5 3195 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
ce43afbe 3196 if (fQATasks.Contains("ALL") ) {
44ed7a66 3197 fQATasks = Form("%d %d %d %d", AliQAv1::kRAWS, AliQAv1::kDIGITSR, AliQAv1::kRECPOINTS, AliQAv1::kESDS) ;
ce43afbe 3198 } else {
3199 fQATasks.ToUpper() ;
3200 TString tempo("") ;
3201 if ( fQATasks.Contains("RAW") )
4e25ac79 3202 tempo = Form("%d ", AliQAv1::kRAWS) ;
44ed7a66 3203 if ( fQATasks.Contains("DIGIT") )
3204 tempo += Form("%d ", AliQAv1::kDIGITSR) ;
ce43afbe 3205 if ( fQATasks.Contains("RECPOINT") )
4e25ac79 3206 tempo += Form("%d ", AliQAv1::kRECPOINTS) ;
ce43afbe 3207 if ( fQATasks.Contains("ESD") )
4e25ac79 3208 tempo += Form("%d ", AliQAv1::kESDS) ;
ce43afbe 3209 fQATasks = tempo ;
3210 if (fQATasks.IsNull()) {
3211 AliInfo("No QA requested\n") ;
3212 fRunQA = kFALSE ;
3213 return kTRUE ;
3214 }
3215 }
3216 TString tempo(fQATasks) ;
4e25ac79 3217 tempo.ReplaceAll(Form("%d", AliQAv1::kRAWS), AliQAv1::GetTaskName(AliQAv1::kRAWS)) ;
44ed7a66 3218 tempo.ReplaceAll(Form("%d", AliQAv1::kDIGITSR), AliQAv1::GetTaskName(AliQAv1::kDIGITSR)) ;
4e25ac79 3219 tempo.ReplaceAll(Form("%d", AliQAv1::kRECPOINTS), AliQAv1::GetTaskName(AliQAv1::kRECPOINTS)) ;
3220 tempo.ReplaceAll(Form("%d", AliQAv1::kESDS), AliQAv1::GetTaskName(AliQAv1::kESDS)) ;
ce43afbe 3221 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
3222 fRunQA = kTRUE ;
3223 return kTRUE;
3224}
3225
7e88424f 3226//_____________________________________________________________________________
3227Bool_t AliReconstruction::InitRecoParams()
3228{
3229 // The method accesses OCDB and retrieves all
3230 // the available reco-param objects from there.
3231
3232 Bool_t isOK = kTRUE;
3233
8b26452d 3234 if (fRecoParam.GetDetRecoParamArray(kNDetectors)) {
3235 AliInfo("Using custom GRP reconstruction parameters");
3236 }
3237 else {
3238 AliInfo("Loading GRP reconstruction parameter objects");
3239
3240 AliCDBPath path("GRP","Calib","RecoParam");
3241 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
3242 if(!entry){
3243 AliWarning("Couldn't find GRP RecoParam entry in OCDB");
3244 isOK = kFALSE;
3245 }
3246 else {
3247 TObject *recoParamObj = entry->GetObject();
3248 if (dynamic_cast<TObjArray*>(recoParamObj)) {
3249 // GRP has a normal TobjArray of AliDetectorRecoParam objects
3250 // Registering them in AliRecoParam
3251 fRecoParam.AddDetRecoParamArray(kNDetectors,dynamic_cast<TObjArray*>(recoParamObj));
3252 }
3253 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
3254 // GRP has only onse set of reco parameters
3255 // Registering it in AliRecoParam
3256 AliInfo("Single set of GRP reconstruction parameters found");
3257 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
3258 fRecoParam.AddDetRecoParam(kNDetectors,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
3259 }
3260 else {
3261 AliError("No valid GRP RecoParam object found in the OCDB");
3262 isOK = kFALSE;
3263 }
3264 entry->SetOwner(0);
3265 }
3266 }
3267
7d566c20 3268 TString detStr = fLoadCDB;
ac4a7581 3269 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
7e88424f 3270
7d566c20 3271 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3272
7e88424f 3273 if (fRecoParam.GetDetRecoParamArray(iDet)) {
3274 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
3275 continue;
3276 }
3277
ac232c75 3278 AliInfo(Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
7e88424f 3279
3280 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
3281 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
3282 if(!entry){
3283 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
3284 isOK = kFALSE;
3285 }
3286 else {
3287 TObject *recoParamObj = entry->GetObject();
3288 if (dynamic_cast<TObjArray*>(recoParamObj)) {
3289 // The detector has a normal TobjArray of AliDetectorRecoParam objects
3290 // Registering them in AliRecoParam
3291 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
3292 }
3293 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
3294 // The detector has only onse set of reco parameters
3295 // Registering it in AliRecoParam
ac232c75 3296 AliInfo(Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
7e88424f 3297 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
3298 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
3299 }
3300 else {
3301 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
3302 isOK = kFALSE;
3303 }
3304 entry->SetOwner(0);
f168abba 3305 // FIX ME: We have to disable the unloading of reco-param CDB
3306 // entries because QA framework is using them. Has to be fix in
3307 // a way that the QA takes the objects already constructed in
3308 // this method.
3309 // AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
7e88424f 3310 }
3311 }
3312
e30a9b4d 3313 if (AliDebugLevel() > 0) fRecoParam.Print();
ac232c75 3314
7e88424f 3315 return isOK;
3316}
3317
3318//_____________________________________________________________________________
3319Bool_t AliReconstruction::GetEventInfo()
3320{
3321 // Fill the event info object
3322 // ...
3323 AliCodeTimerAuto("")
3324
3325 AliCentralTrigger *aCTP = NULL;
3326 if (fRawReader) {
3327 fEventInfo.SetEventType(fRawReader->GetType());
3328
3329 ULong64_t mask = fRawReader->GetClassMask();
3330 fEventInfo.SetTriggerMask(mask);
3331 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
3332 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
3333
3334 aCTP = new AliCentralTrigger();
3335 TString configstr("");
3336 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
3337 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
3338 delete aCTP;
3339 return kFALSE;
3340 }
3341 aCTP->SetClassMask(mask);
3342 aCTP->SetClusterMask(clmask);
3343 }
3344 else {
3345 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
3346
3347 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
3348 aCTP = fRunLoader->GetTrigger();
3349 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
e61ed4b1 3350 // get inputs from actp - just get
3351 AliESDHeader* esdheader = fesd->GetHeader();
3352 esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs());
3353 esdheader->SetL1TriggerInputs(aCTP->GetL1TriggerInputs());
3354 esdheader->SetL2TriggerInputs(aCTP->GetL2TriggerInputs());
7e88424f 3355 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
3356 }
3357 else {
3358 AliWarning("No trigger can be loaded! The trigger information will not be used!");
3359 return kFALSE;
3360 }
3361 }
3362
3363 AliTriggerConfiguration *config = aCTP->GetConfiguration();
3364 if (!config) {
3365 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
3366 if (fRawReader) delete aCTP;
3367 return kFALSE;
3368 }
3369
a0c2cf2d 3370 UChar_t clustmask = 0;
7e88424f 3371 TString trclasses;
3372 ULong64_t trmask = fEventInfo.GetTriggerMask();
3373 const TObjArray& classesArray = config->GetClasses();
3374 Int_t nclasses = classesArray.GetEntriesFast();
3375 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
3376 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
3377 if (trclass) {
a4b0683d 3378 Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask()));
7e88424f 3379 fesd->SetTriggerClass(trclass->GetName(),trindex);
8a933107 3380 if (fRawReader) fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
e61ed4b1 3381 if (trmask & (1ull << trindex)) {
7e88424f 3382 trclasses += " ";
3383 trclasses += trclass->GetName();
3384 trclasses += " ";
a0c2cf2d 3385 clustmask |= trclass->GetCluster()->GetClusterMask();
7e88424f 3386 }
3387 }
3388 }
3389 fEventInfo.SetTriggerClasses(trclasses);
3390
a0c2cf2d 3391 // Set the information in ESD
3392 fesd->SetTriggerMask(trmask);
3393 fesd->SetTriggerCluster(clustmask);
3394
7e88424f 3395 if (!aCTP->CheckTriggeredDetectors()) {
3396 if (fRawReader) delete aCTP;
3397 return kFALSE;
3398 }
3399
3400 if (fRawReader) delete aCTP;
3401
3402 // We have to fill also the HLT decision here!!
3403 // ...
3404
3405 return kTRUE;
3406}
3407
3408const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
3409{
3410 // Match the detector list found in the rec.C or the default 'ALL'
3411 // to the list found in the GRP (stored there by the shuttle PP which
3412 // gets the information from ECS)
3413 static TString resultList;
3414 TString detList = detectorList;
3415
3416 resultList = "";
3417
3418 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
3419 if ((detectorMask >> iDet) & 0x1) {
3420 TString det = AliDAQ::OfflineModuleName(iDet);
3421 if ((detList.CompareTo("ALL") == 0) ||
a101e1dd 3422 ((detList.BeginsWith("ALL ") ||
3423 detList.EndsWith(" ALL") ||
3424 detList.Contains(" ALL ")) &&
3425 !(detList.BeginsWith("-"+det+" ") ||
3426 detList.EndsWith(" -"+det) ||
3427 detList.Contains(" -"+det+" "))) ||
7e88424f 3428 (detList.CompareTo(det) == 0) ||
a101e1dd 3429 detList.BeginsWith(det+" ") ||
3430 detList.EndsWith(" "+det) ||
7e88424f 3431 detList.Contains( " "+det+" " )) {
3432 if (!resultList.EndsWith(det + " ")) {
3433 resultList += det;
3434 resultList += " ";
3435 }
3436 }
3437 }
3438 }
3439
3440 // HLT
3441 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
3442 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
3443 if ((detList.CompareTo("ALL") == 0) ||
a101e1dd 3444 ((detList.BeginsWith("ALL ") ||
3445 detList.EndsWith(" ALL") ||
3446 detList.Contains(" ALL ")) &&
3447 !(detList.BeginsWith("-"+hltDet+" ") ||
3448 detList.EndsWith(" -"+hltDet) ||
3449 detList.Contains(" -"+hltDet+" "))) ||
7e88424f 3450 (detList.CompareTo(hltDet) == 0) ||
a101e1dd 3451 detList.BeginsWith(hltDet+" ") ||
3452 detList.EndsWith(" "+hltDet) ||
7e88424f 3453 detList.Contains( " "+hltDet+" " )) {
3454 resultList += hltDet;
3455 }
3456 }
3457
3458 return resultList.Data();
3459
3460}
4b71572b 3461
3462//______________________________________________________________________________
3463void AliReconstruction::Abort(const char *method, EAbort what)
3464{
3465 // Abort processing. If what = kAbortProcess, the Process() loop will be
3466 // aborted. If what = kAbortFile, the current file in a chain will be
3467 // aborted and the processing will continue with the next file, if there
3468 // is no next file then Process() will be aborted. Abort() can also be
3469 // called from Begin(), SlaveBegin(), Init() and Notify(). After abort
3470 // the SlaveTerminate() and Terminate() are always called. The abort flag
3471 // can be checked in these methods using GetAbort().
3472 //
3473 // The method is overwritten in AliReconstruction for better handling of
3474 // reco specific errors
3475
3476 if (!fStopOnError) return;
3477
3478 CleanUp();
3479
3480 TString whyMess = method;
3481 whyMess += " failed! Aborting...";
3482
3483 AliError(whyMess.Data());
3484
3485 fAbort = what;
3486 TString mess = "Abort";
3487 if (fAbort == kAbortProcess)
3488 mess = "AbortProcess";
3489 else if (fAbort == kAbortFile)
3490 mess = "AbortFile";
3491
3492 Info(mess, whyMess.Data());
3493}
3494
2f954aba 3495//______________________________________________________________________________
3496Bool_t AliReconstruction::ProcessEvent(void* event)
3497{
3498 // Method that is used in case the event loop
3499 // is steered from outside, for example by AMORE
3500 // 'event' is a pointer to the DATE event in the memory
3501
3502 if (fRawReader) delete fRawReader;
3503 fRawReader = new AliRawReaderDate(event);
3504 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
3505 delete fRawReader;
3506 fRawReader = NULL;
3507
3508 return fStatus;
3509}
81d57268 3510
3511//______________________________________________________________________________
3512Bool_t AliReconstruction::ParseOutput()
3513{
3514 // The method parses the output file
3515 // location string in order to steer
3516 // properly the selector
3517
3518 TPMERegexp re1("(\\w+\\.zip#\\w+\\.root):([,*\\w+\\.root,*]+)@dataset://(\\w++)");
3519 TPMERegexp re2("(\\w+\\.root)?@?dataset://(\\w++)");
3520
3521 if (re1.Match(fESDOutput) == 4) {
3522 // root archive with output files stored and regustered
3523 // in proof dataset
3524 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",re1[1].Data()));
3525 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",re1[3].Data()));
3526 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_DATASET",""));
3527 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_ARCHIVE",re1[2].Data()));
3528 AliInfo(Form("%s files will be stored within %s in dataset %s",
3529 re1[2].Data(),
3530 re1[1].Data(),
3531 re1[3].Data()));
3532 }
3533 else if (re2.Match(fESDOutput) == 3) {
3534 // output file stored and registered
3535 // in proof dataset
3536 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",(re2[1].IsNull()) ? "AliESDs.root" : re2[1].Data()));
3537 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",re2[2].Data()));
3538 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_DATASET",""));
3539 AliInfo(Form("%s will be stored in dataset %s",
3540 (re2[1].IsNull()) ? "AliESDs.root" : re2[1].Data(),
3541 re2[2].Data()));
3542 }
3543 else {
3544 if (fESDOutput.IsNull()) {
3545 // Output location not given.
3546 // Assuming xrootd has been already started and
3547 // the output file has to be sent back
3548 // to the client machine
3549 TString esdUrl(Form("root://%s/%s/",
3550 TUrl(gSystem->HostName()).GetHostFQDN(),
3551 gSystem->pwd()));
3552 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE","AliESDs.root"));
3553 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",esdUrl.Data()));
3554 AliInfo(Form("AliESDs.root will be stored in %s",
3555 esdUrl.Data()));
3556 }
3557 else {
3558 // User specified an output location.
3559 // Ones has just to parse it here
3560 TUrl outputUrl(fESDOutput.Data());
3561 TString outputFile(gSystem->BaseName(outputUrl.GetFile()));
3562 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",outputFile.IsNull() ? "AliESDs.root" : outputFile.Data()));
3563 TString outputLocation(outputUrl.GetUrl());
3564 outputLocation.ReplaceAll(outputFile.Data(),"");
3565 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",outputLocation.Data()));
3566 AliInfo(Form("%s will be stored in %s",
3567 outputFile.IsNull() ? "AliESDs.root" : outputFile.Data(),
3568 outputLocation.Data()));
3569 }
3570 }
3571
3572 return kTRUE;
3573}