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