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