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