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