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