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