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