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