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