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