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