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