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