596a855f |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * |
4 | * Author: The ALICE Off-line Project. * |
5 | * Contributors are mentioned in the code where appropriate. * |
6 | * * |
7 | * Permission to use, copy, modify and distribute this software and its * |
8 | * documentation strictly for non-commercial purposes is hereby granted * |
9 | * without fee, provided that the above copyright notice appears in all * |
10 | * copies and that both the copyright notice and this permission notice * |
11 | * appear in the supporting documentation. The authors make no claims * |
12 | * about the suitability of this software for any purpose. It is * |
13 | * provided "as is" without express or implied warranty. * |
14 | **************************************************************************/ |
15 | |
16 | /* $Id$ */ |
17 | |
18 | /////////////////////////////////////////////////////////////////////////////// |
19 | // // |
20 | // class for running the reconstruction // |
21 | // // |
22 | // Clusters and tracks are created for all detectors and all events by // |
23 | // typing: // |
24 | // // |
25 | // AliReconstruction rec; // |
26 | // rec.Run(); // |
27 | // // |
28 | // The Run method returns kTRUE in case of successful execution. // |
c71de921 |
29 | // // |
30 | // If the input to the reconstruction are not simulated digits but raw data, // |
31 | // this can be specified by an argument of the Run method or by the method // |
32 | // // |
33 | // rec.SetInput("..."); // |
34 | // // |
35 | // The input formats and the corresponding argument are: // |
36 | // - DDL raw data files: directory name, ends with "/" // |
37 | // - raw data root file: root file name, extension ".root" // |
38 | // - raw data DATE file: DATE file name, any other non-empty string // |
39 | // - MC root files : empty string, default // |
40 | // // |
b26c3770 |
41 | // By default all events are reconstructed. The reconstruction can be // |
42 | // limited to a range of events by giving the index of the first and the // |
43 | // last event as an argument to the Run method or by calling // |
44 | // // |
45 | // rec.SetEventRange(..., ...); // |
46 | // // |
47 | // The index -1 (default) can be used for the last event to indicate no // |
48 | // upper limit of the event range. // |
49 | // // |
973388c2 |
50 | // In case of raw-data reconstruction the user can modify the default // |
51 | // number of events per digits/clusters/tracks file. In case the option // |
52 | // is not used the number is set 1. In case the user provides 0, than // |
53 | // the number of events is equal to the number of events inside the // |
54 | // raw-data file (i.e. one digits/clusters/tracks file): // |
55 | // // |
56 | // rec.SetNumberOfEventsPerFile(...); // |
57 | // // |
58 | // // |
596a855f |
59 | // The name of the galice file can be changed from the default // |
e583c30d |
60 | // "galice.root" by passing it as argument to the AliReconstruction // |
61 | // constructor or by // |
596a855f |
62 | // // |
63 | // rec.SetGAliceFile("..."); // |
64 | // // |
59697224 |
65 | // The local reconstruction can be switched on or off for individual // |
66 | // detectors by // |
596a855f |
67 | // // |
59697224 |
68 | // rec.SetRunLocalReconstruction("..."); // |
596a855f |
69 | // // |
70 | // The argument is a (case sensitive) string with the names of the // |
71 | // detectors separated by a space. The special string "ALL" selects all // |
72 | // available detectors. This is the default. // |
73 | // // |
c71de921 |
74 | // The reconstruction of the primary vertex position can be switched off by // |
75 | // // |
76 | // rec.SetRunVertexFinder(kFALSE); // |
77 | // // |
b8cd5251 |
78 | // The tracking and the creation of ESD tracks can be switched on for // |
79 | // selected detectors by // |
596a855f |
80 | // // |
b8cd5251 |
81 | // rec.SetRunTracking("..."); // |
596a855f |
82 | // // |
c84a5e9e |
83 | // Uniform/nonuniform field tracking switches (default: uniform field) // |
84 | // // |
1d99986f |
85 | // rec.SetUniformFieldTracking(); ( rec.SetUniformFieldTracking(kFALSE); ) // |
c84a5e9e |
86 | // // |
596a855f |
87 | // The filling of additional ESD information can be steered by // |
88 | // // |
89 | // rec.SetFillESD("..."); // |
90 | // // |
b8cd5251 |
91 | // Again, for both methods the string specifies the list of detectors. // |
92 | // The default is "ALL". // |
93 | // // |
94 | // The call of the shortcut method // |
95 | // // |
96 | // rec.SetRunReconstruction("..."); // |
97 | // // |
98 | // is equivalent to calling SetRunLocalReconstruction, SetRunTracking and // |
99 | // SetFillESD with the same detector selecting string as argument. // |
596a855f |
100 | // // |
c71de921 |
101 | // The reconstruction requires digits or raw data as input. For the creation // |
102 | // of digits and raw data have a look at the class AliSimulation. // |
596a855f |
103 | // // |
cd0b062e |
104 | // The input data of a detector can be replaced by the corresponding HLT // |
105 | // data by calling (usual detector string) // |
106 | // SetUseHLTData("..."); // |
107 | // // |
24f7a148 |
108 | // For debug purposes the method SetCheckPointLevel can be used. If the // |
109 | // argument is greater than 0, files with ESD events will be written after // |
110 | // selected steps of the reconstruction for each event: // |
111 | // level 1: after tracking and after filling of ESD (final) // |
112 | // level 2: in addition after each tracking step // |
113 | // level 3: in addition after the filling of ESD for each detector // |
114 | // If a final check point file exists for an event, this event will be // |
115 | // skipped in the reconstruction. The tracking and the filling of ESD for // |
116 | // a detector will be skipped as well, if the corresponding check point // |
117 | // file exists. The ESD event will then be loaded from the file instead. // |
118 | // // |
596a855f |
119 | /////////////////////////////////////////////////////////////////////////////// |
120 | |
024a7e64 |
121 | #include <TArrayF.h> |
122 | #include <TFile.h> |
444753c6 |
123 | #include <TList.h> |
024a7e64 |
124 | #include <TSystem.h> |
125 | #include <TROOT.h> |
126 | #include <TPluginManager.h> |
3103d196 |
127 | #include <TGeoManager.h> |
2bdb9d38 |
128 | #include <TLorentzVector.h> |
3dd9f9e3 |
129 | #include <TArrayS.h> |
130 | #include <TArrayD.h> |
3c3709c4 |
131 | #include <TObjArray.h> |
596a855f |
132 | |
133 | #include "AliReconstruction.h" |
87932dab |
134 | #include "AliCodeTimer.h" |
b8cd5251 |
135 | #include "AliReconstructor.h" |
815c2b38 |
136 | #include "AliLog.h" |
596a855f |
137 | #include "AliRunLoader.h" |
138 | #include "AliRun.h" |
b649205a |
139 | #include "AliRawReaderFile.h" |
140 | #include "AliRawReaderDate.h" |
141 | #include "AliRawReaderRoot.h" |
001397cd |
142 | #include "AliRawEventHeaderBase.h" |
af885e0f |
143 | #include "AliESDEvent.h" |
faffd83e |
144 | #include "AliESDMuonTrack.h" |
1d99986f |
145 | #include "AliESDfriend.h" |
2257f27e |
146 | #include "AliESDVertex.h" |
faffd83e |
147 | #include "AliESDcascade.h" |
148 | #include "AliESDkink.h" |
149 | #include "AliESDtrack.h" |
150 | #include "AliESDCaloCluster.h" |
e649177a |
151 | #include "AliESDCaloCells.h" |
32e449be |
152 | #include "AliMultiplicity.h" |
c84a5e9e |
153 | #include "AliTracker.h" |
2257f27e |
154 | #include "AliVertexer.h" |
c5e3e5d1 |
155 | #include "AliVertexerTracks.h" |
5e4ff34d |
156 | #include "AliV0vertexer.h" |
157 | #include "AliCascadeVertexer.h" |
596a855f |
158 | #include "AliHeader.h" |
159 | #include "AliGenEventHeader.h" |
b26c3770 |
160 | #include "AliPID.h" |
596a855f |
161 | #include "AliESDpid.h" |
ff8bb5ae |
162 | #include "AliESDtrack.h" |
3dd9f9e3 |
163 | #include "AliESDPmdTrack.h" |
f3a97c86 |
164 | |
08e1a23e |
165 | #include "AliESDTagCreator.h" |
a1069ee1 |
166 | #include "AliAODTagCreator.h" |
f3a97c86 |
167 | |
25be1e5c |
168 | #include "AliGeomManager.h" |
98937d93 |
169 | #include "AliTrackPointArray.h" |
b0314964 |
170 | #include "AliCDBManager.h" |
795e4a22 |
171 | #include "AliCDBStorage.h" |
6bae477a |
172 | #include "AliCDBEntry.h" |
173 | #include "AliAlignObj.h" |
f3a97c86 |
174 | |
b647652d |
175 | #include "AliCentralTrigger.h" |
b024fd7f |
176 | #include "AliTriggerConfiguration.h" |
177 | #include "AliTriggerClass.h" |
b647652d |
178 | #include "AliCTPRawStream.h" |
179 | |
04236e67 |
180 | #include "AliQADataMakerRec.h" |
aa3c69a9 |
181 | #include "AliGlobalQADataMaker.h" |
c65c502a |
182 | #include "AliQA.h" |
183 | #include "AliQADataMakerSteer.h" |
f29f1726 |
184 | |
7167ae53 |
185 | #include "AliPlaneEff.h" |
186 | |
0f88822a |
187 | #include "AliSysInfo.h" // memory snapshots |
cd0b062e |
188 | #include "AliRawHLTManager.h" |
0f88822a |
189 | |
6efecea1 |
190 | |
596a855f |
191 | ClassImp(AliReconstruction) |
192 | |
193 | |
c757bafd |
194 | //_____________________________________________________________________________ |
b384f8a4 |
195 | const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"}; |
c757bafd |
196 | |
596a855f |
197 | //_____________________________________________________________________________ |
795e4a22 |
198 | AliReconstruction::AliReconstruction(const char* gAliceFilename, |
e583c30d |
199 | const char* name, const char* title) : |
200 | TNamed(name, title), |
201 | |
c84a5e9e |
202 | fUniformField(kTRUE), |
2257f27e |
203 | fRunVertexFinder(kTRUE), |
a84e2607 |
204 | fRunVertexFinderTracks(kTRUE), |
1f46a9ae |
205 | fRunHLTTracking(kFALSE), |
e66fbafb |
206 | fRunMuonTracking(kFALSE), |
d1683eef |
207 | fRunV0Finder(kTRUE), |
208 | fRunCascadeFinder(kTRUE), |
1d99986f |
209 | fStopOnError(kFALSE), |
210 | fWriteAlignmentData(kFALSE), |
211 | fWriteESDfriend(kFALSE), |
a7807689 |
212 | fWriteAOD(kFALSE), |
b647652d |
213 | fFillTriggerESD(kTRUE), |
1d99986f |
214 | |
7f68891d |
215 | fCleanESD(kTRUE), |
a023d8d8 |
216 | fV0DCAmax(3.), |
217 | fV0CsPmin(0.), |
7f68891d |
218 | fDmax(50.), |
219 | fZmax(50.), |
220 | |
1d99986f |
221 | fRunLocalReconstruction("ALL"), |
b8cd5251 |
222 | fRunTracking("ALL"), |
e583c30d |
223 | fFillESD("ALL"), |
48ce48d1 |
224 | fUseTrackingErrorsForAlignment(""), |
e583c30d |
225 | fGAliceFileName(gAliceFilename), |
b649205a |
226 | fInput(""), |
35042093 |
227 | fEquipIdMap(""), |
b26c3770 |
228 | fFirstEvent(0), |
229 | fLastEvent(-1), |
973388c2 |
230 | fNumberOfEventsPerFile(1), |
24f7a148 |
231 | fCheckPointLevel(0), |
b8cd5251 |
232 | fOptions(), |
6bae477a |
233 | fLoadAlignFromCDB(kTRUE), |
234 | fLoadAlignData("ALL"), |
46698ae4 |
235 | fESDPar(""), |
cd0b062e |
236 | fUseHLTData(), |
e583c30d |
237 | |
238 | fRunLoader(NULL), |
b649205a |
239 | fRawReader(NULL), |
cd0b062e |
240 | fParentRawReader(NULL), |
b8cd5251 |
241 | |
98937d93 |
242 | fVertexer(NULL), |
9178838a |
243 | fDiamondProfile(NULL), |
43c9dae1 |
244 | fDiamondProfileTPC(NULL), |
87317a47 |
245 | fMeanVertexConstraint(kTRUE), |
98937d93 |
246 | |
444753c6 |
247 | fGRPList(NULL), |
248 | |
6bae477a |
249 | fAlignObjArray(NULL), |
795e4a22 |
250 | fCDBUri(), |
759c1df1 |
251 | fSpecCDBUri(), |
795e4a22 |
252 | fInitCDBCalled(kFALSE), |
253 | fSetRunNumberFromDataCalled(kFALSE), |
7e963665 |
254 | fRunQA(kTRUE), |
6b150027 |
255 | fRunGlobalQA(kTRUE), |
7167ae53 |
256 | fInLoopQA(kFALSE), |
257 | |
258 | fRunPlaneEff(kFALSE) |
596a855f |
259 | { |
260 | // create reconstruction object with default parameters |
b8cd5251 |
261 | |
262 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
263 | fReconstructor[iDet] = NULL; |
264 | fLoader[iDet] = NULL; |
265 | fTracker[iDet] = NULL; |
7e963665 |
266 | fQADataMaker[iDet] = NULL; |
267 | fQACycles[iDet] = 999999; |
b8cd5251 |
268 | } |
aa3c69a9 |
269 | fQADataMaker[fgkNDetectors]=NULL; //Global QA |
e47c4c2e |
270 | AliPID pid; |
596a855f |
271 | } |
272 | |
273 | //_____________________________________________________________________________ |
274 | AliReconstruction::AliReconstruction(const AliReconstruction& rec) : |
e583c30d |
275 | TNamed(rec), |
276 | |
c84a5e9e |
277 | fUniformField(rec.fUniformField), |
2257f27e |
278 | fRunVertexFinder(rec.fRunVertexFinder), |
a84e2607 |
279 | fRunVertexFinderTracks(rec.fRunVertexFinderTracks), |
1f46a9ae |
280 | fRunHLTTracking(rec.fRunHLTTracking), |
e66fbafb |
281 | fRunMuonTracking(rec.fRunMuonTracking), |
d1683eef |
282 | fRunV0Finder(rec.fRunV0Finder), |
283 | fRunCascadeFinder(rec.fRunCascadeFinder), |
1d99986f |
284 | fStopOnError(rec.fStopOnError), |
285 | fWriteAlignmentData(rec.fWriteAlignmentData), |
286 | fWriteESDfriend(rec.fWriteESDfriend), |
a7807689 |
287 | fWriteAOD(rec.fWriteAOD), |
b647652d |
288 | fFillTriggerESD(rec.fFillTriggerESD), |
1d99986f |
289 | |
7f68891d |
290 | fCleanESD(rec.fCleanESD), |
a023d8d8 |
291 | fV0DCAmax(rec.fV0DCAmax), |
5e5c1aa9 |
292 | fV0CsPmin(rec.fV0CsPmin), |
7f68891d |
293 | fDmax(rec.fDmax), |
294 | fZmax(rec.fZmax), |
295 | |
1d99986f |
296 | fRunLocalReconstruction(rec.fRunLocalReconstruction), |
e583c30d |
297 | fRunTracking(rec.fRunTracking), |
298 | fFillESD(rec.fFillESD), |
48ce48d1 |
299 | fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment), |
e583c30d |
300 | fGAliceFileName(rec.fGAliceFileName), |
b649205a |
301 | fInput(rec.fInput), |
35042093 |
302 | fEquipIdMap(rec.fEquipIdMap), |
b26c3770 |
303 | fFirstEvent(rec.fFirstEvent), |
304 | fLastEvent(rec.fLastEvent), |
973388c2 |
305 | fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile), |
24f7a148 |
306 | fCheckPointLevel(0), |
b8cd5251 |
307 | fOptions(), |
6bae477a |
308 | fLoadAlignFromCDB(rec.fLoadAlignFromCDB), |
309 | fLoadAlignData(rec.fLoadAlignData), |
46698ae4 |
310 | fESDPar(rec.fESDPar), |
2972d4eb |
311 | fUseHLTData(rec.fUseHLTData), |
e583c30d |
312 | |
313 | fRunLoader(NULL), |
b649205a |
314 | fRawReader(NULL), |
2972d4eb |
315 | fParentRawReader(NULL), |
b8cd5251 |
316 | |
98937d93 |
317 | fVertexer(NULL), |
9178838a |
318 | fDiamondProfile(NULL), |
43c9dae1 |
319 | fDiamondProfileTPC(NULL), |
87317a47 |
320 | fMeanVertexConstraint(rec.fMeanVertexConstraint), |
98937d93 |
321 | |
444753c6 |
322 | fGRPList(NULL), |
323 | |
6bae477a |
324 | fAlignObjArray(rec.fAlignObjArray), |
ec92bee0 |
325 | fCDBUri(rec.fCDBUri), |
7e963665 |
326 | fSpecCDBUri(), |
795e4a22 |
327 | fInitCDBCalled(rec.fInitCDBCalled), |
328 | fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled), |
aa3c69a9 |
329 | fRunQA(rec.fRunQA), |
330 | fRunGlobalQA(rec.fRunGlobalQA), |
7167ae53 |
331 | fInLoopQA(rec.fInLoopQA), |
332 | fRunPlaneEff(rec.fRunPlaneEff) |
596a855f |
333 | { |
334 | // copy constructor |
335 | |
ec92bee0 |
336 | for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) { |
efd2085e |
337 | if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone()); |
338 | } |
b8cd5251 |
339 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
340 | fReconstructor[iDet] = NULL; |
341 | fLoader[iDet] = NULL; |
342 | fTracker[iDet] = NULL; |
7e963665 |
343 | fQADataMaker[iDet] = NULL; |
344 | fQACycles[iDet] = rec.fQACycles[iDet]; |
b8cd5251 |
345 | } |
aa3c69a9 |
346 | fQADataMaker[fgkNDetectors]=NULL; //Global QA |
ec92bee0 |
347 | for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) { |
348 | if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone()); |
349 | } |
596a855f |
350 | } |
351 | |
352 | //_____________________________________________________________________________ |
353 | AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec) |
354 | { |
355 | // assignment operator |
356 | |
357 | this->~AliReconstruction(); |
358 | new(this) AliReconstruction(rec); |
359 | return *this; |
360 | } |
361 | |
362 | //_____________________________________________________________________________ |
363 | AliReconstruction::~AliReconstruction() |
364 | { |
365 | // clean up |
366 | |
e583c30d |
367 | CleanUp(); |
efd2085e |
368 | fOptions.Delete(); |
ec92bee0 |
369 | fSpecCDBUri.Delete(); |
87932dab |
370 | |
371 | AliCodeTimer::Instance()->Print(); |
596a855f |
372 | } |
373 | |
024cf675 |
374 | //_____________________________________________________________________________ |
795e4a22 |
375 | void AliReconstruction::InitCDB() |
024cf675 |
376 | { |
377 | // activate a default CDB storage |
378 | // First check if we have any CDB storage set, because it is used |
379 | // to retrieve the calibration and alignment constants |
380 | |
795e4a22 |
381 | if (fInitCDBCalled) return; |
382 | fInitCDBCalled = kTRUE; |
383 | |
024cf675 |
384 | AliCDBManager* man = AliCDBManager::Instance(); |
ec92bee0 |
385 | if (man->IsDefaultStorageSet()) |
024cf675 |
386 | { |
387 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
ec92bee0 |
388 | AliWarning("Default CDB storage has been already set !"); |
389 | AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data())); |
024cf675 |
390 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
795e4a22 |
391 | fCDBUri = man->GetDefaultStorage()->GetURI(); |
ec92bee0 |
392 | } |
393 | else { |
795e4a22 |
394 | if (fCDBUri.Length() > 0) |
395 | { |
396 | AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
397 | AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data())); |
398 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
399 | } else { |
400 | fCDBUri="local://$ALICE_ROOT"; |
401 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
402 | AliWarning("Default CDB storage not yet set !!!!"); |
403 | AliWarning(Form("Setting it now to: %s", fCDBUri.Data())); |
404 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
405 | |
406 | } |
ec92bee0 |
407 | man->SetDefaultStorage(fCDBUri); |
408 | } |
409 | |
410 | // Now activate the detector specific CDB storage locations |
c3a7b59a |
411 | for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) { |
412 | TObject* obj = fSpecCDBUri[i]; |
413 | if (!obj) continue; |
b8ec52f6 |
414 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
415 | AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle())); |
416 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
c3a7b59a |
417 | man->SetSpecificStorage(obj->GetName(), obj->GetTitle()); |
ec92bee0 |
418 | } |
795e4a22 |
419 | |
024cf675 |
420 | } |
421 | |
422 | //_____________________________________________________________________________ |
423 | void AliReconstruction::SetDefaultStorage(const char* uri) { |
ec92bee0 |
424 | // Store the desired default CDB storage location |
425 | // Activate it later within the Run() method |
024cf675 |
426 | |
ec92bee0 |
427 | fCDBUri = uri; |
024cf675 |
428 | |
429 | } |
430 | |
00aa02d5 |
431 | //_____________________________________________________________________________ |
c3a7b59a |
432 | void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) { |
ec92bee0 |
433 | // Store a detector-specific CDB storage location |
434 | // Activate it later within the Run() method |
024cf675 |
435 | |
c3a7b59a |
436 | AliCDBPath aPath(calibType); |
437 | if(!aPath.IsValid()){ |
438 | // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path |
439 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
440 | if(!strcmp(calibType, fgkDetectorName[iDet])) { |
441 | aPath.SetPath(Form("%s/*", calibType)); |
442 | AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data())); |
443 | break; |
444 | } |
445 | } |
446 | if(!aPath.IsValid()){ |
447 | AliError(Form("Not a valid path or detector: %s", calibType)); |
448 | return; |
449 | } |
450 | } |
451 | |
53dd3c3d |
452 | // // check that calibType refers to a "valid" detector name |
453 | // Bool_t isDetector = kFALSE; |
454 | // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
455 | // TString detName = fgkDetectorName[iDet]; |
456 | // if(aPath.GetLevel0() == detName) { |
457 | // isDetector = kTRUE; |
458 | // break; |
459 | // } |
460 | // } |
461 | // |
462 | // if(!isDetector) { |
463 | // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data())); |
464 | // return; |
465 | // } |
c3a7b59a |
466 | |
467 | TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data()); |
ec92bee0 |
468 | if (obj) fSpecCDBUri.Remove(obj); |
c3a7b59a |
469 | fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri)); |
024cf675 |
470 | |
471 | } |
472 | |
6bae477a |
473 | //_____________________________________________________________________________ |
795e4a22 |
474 | Bool_t AliReconstruction::SetRunNumberFromData() |
6bae477a |
475 | { |
476 | // The method is called in Run() in order |
477 | // to set a correct run number. |
478 | // In case of raw data reconstruction the |
479 | // run number is taken from the raw data header |
480 | |
795e4a22 |
481 | if (fSetRunNumberFromDataCalled) return kTRUE; |
482 | fSetRunNumberFromDataCalled = kTRUE; |
483 | |
484 | AliCDBManager* man = AliCDBManager::Instance(); |
485 | |
486 | if(man->GetRun() > 0) { |
487 | AliWarning("Run number is taken from event header! Ignoring settings in AliCDBManager!"); |
488 | } |
489 | |
490 | if (!fRunLoader) { |
6bae477a |
491 | AliError("No run loader is found !"); |
492 | return kFALSE; |
493 | } |
494 | // read run number from gAlice |
ec92bee0 |
495 | if(fRunLoader->GetAliRun()) |
f2ee4290 |
496 | AliCDBManager::Instance()->SetRun(fRunLoader->GetHeader()->GetRun()); |
ec92bee0 |
497 | else { |
498 | if(fRawReader) { |
499 | if(fRawReader->NextEvent()) { |
500 | AliCDBManager::Instance()->SetRun(fRawReader->GetRunNumber()); |
501 | fRawReader->RewindEvents(); |
502 | } |
503 | else { |
504 | AliError("No raw-data events found !"); |
505 | return kFALSE; |
506 | } |
507 | } |
508 | else { |
509 | AliError("Neither gAlice nor RawReader objects are found !"); |
510 | return kFALSE; |
511 | } |
6bae477a |
512 | } |
795e4a22 |
513 | |
514 | man->Print(); |
515 | |
6bae477a |
516 | return kTRUE; |
517 | } |
518 | |
795e4a22 |
519 | //_____________________________________________________________________________ |
520 | void AliReconstruction::SetCDBLock() { |
521 | // Set CDB lock: from now on it is forbidden to reset the run number |
522 | // or the default storage or to activate any further storage! |
523 | |
524 | AliCDBManager::Instance()->SetLock(1); |
525 | } |
526 | |
6bae477a |
527 | //_____________________________________________________________________________ |
528 | Bool_t AliReconstruction::MisalignGeometry(const TString& detectors) |
529 | { |
530 | // Read the alignment objects from CDB. |
531 | // Each detector is supposed to have the |
532 | // alignment objects in DET/Align/Data CDB path. |
533 | // All the detector objects are then collected, |
534 | // sorted by geometry level (starting from ALIC) and |
535 | // then applied to the TGeo geometry. |
536 | // Finally an overlaps check is performed. |
537 | |
538 | // Load alignment data from CDB and fill fAlignObjArray |
539 | if(fLoadAlignFromCDB){ |
6bae477a |
540 | |
25be1e5c |
541 | TString detStr = detectors; |
542 | TString loadAlObjsListOfDets = ""; |
543 | |
544 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
545 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; |
546 | loadAlObjsListOfDets += fgkDetectorName[iDet]; |
547 | loadAlObjsListOfDets += " "; |
548 | } // end loop over detectors |
53dd3c3d |
549 | loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules |
98e303d9 |
550 | AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data()); |
25be1e5c |
551 | }else{ |
552 | // Check if the array with alignment objects was |
553 | // provided by the user. If yes, apply the objects |
554 | // to the present TGeo geometry |
555 | if (fAlignObjArray) { |
556 | if (gGeoManager && gGeoManager->IsClosed()) { |
98e303d9 |
557 | if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) { |
25be1e5c |
558 | AliError("The misalignment of one or more volumes failed!" |
559 | "Compare the list of simulated detectors and the list of detector alignment data!"); |
560 | return kFALSE; |
561 | } |
562 | } |
563 | else { |
564 | AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!"); |
6bae477a |
565 | return kFALSE; |
566 | } |
567 | } |
6bae477a |
568 | } |
25be1e5c |
569 | |
8e245d15 |
570 | delete fAlignObjArray; fAlignObjArray=0; |
a03b0371 |
571 | |
6bae477a |
572 | return kTRUE; |
573 | } |
596a855f |
574 | |
575 | //_____________________________________________________________________________ |
576 | void AliReconstruction::SetGAliceFile(const char* fileName) |
577 | { |
578 | // set the name of the galice file |
579 | |
580 | fGAliceFileName = fileName; |
581 | } |
582 | |
efd2085e |
583 | //_____________________________________________________________________________ |
584 | void AliReconstruction::SetOption(const char* detector, const char* option) |
585 | { |
586 | // set options for the reconstruction of a detector |
587 | |
588 | TObject* obj = fOptions.FindObject(detector); |
589 | if (obj) fOptions.Remove(obj); |
590 | fOptions.Add(new TNamed(detector, option)); |
591 | } |
592 | |
596a855f |
593 | |
594 | //_____________________________________________________________________________ |
e0027792 |
595 | Bool_t AliReconstruction::Run(const char* input, Bool_t IsOnline) |
596a855f |
596 | { |
597 | // run the reconstruction |
598 | |
87932dab |
599 | AliCodeTimerAuto("") |
600 | |
b649205a |
601 | // set the input |
e0027792 |
602 | if (!IsOnline) { |
603 | if (!input) input = fInput.Data(); |
604 | TString fileName(input); |
605 | if (fileName.EndsWith("/")) { |
606 | fRawReader = new AliRawReaderFile(fileName); |
607 | } else if (fileName.EndsWith(".root")) { |
608 | fRawReader = new AliRawReaderRoot(fileName); |
609 | } else if (!fileName.IsNull()) { |
610 | fRawReader = new AliRawReaderDate(fileName); |
611 | } |
612 | } |
613 | else { |
614 | if (!input) { |
615 | AliError("Null pointer to the event structure!"); |
616 | return kFALSE; |
617 | } |
618 | fRawReader = new AliRawReaderDate((void *)input); |
b649205a |
619 | } |
e0027792 |
620 | |
35042093 |
621 | if (!fEquipIdMap.IsNull() && fRawReader) |
622 | fRawReader->LoadEquipmentIdsMap(fEquipIdMap); |
623 | |
cd0b062e |
624 | if (!fUseHLTData.IsNull()) { |
625 | // create the RawReaderHLT which performs redirection of HLT input data for |
626 | // the specified detectors |
627 | AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data()); |
628 | if (pRawReader) { |
629 | fParentRawReader=fRawReader; |
630 | fRawReader=pRawReader; |
631 | } else { |
632 | AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data())); |
633 | } |
634 | } |
635 | |
0f88822a |
636 | AliSysInfo::AddStamp("Start"); |
f08fc9f5 |
637 | // get the run loader |
638 | if (!InitRunLoader()) return kFALSE; |
0f88822a |
639 | AliSysInfo::AddStamp("LoadLoader"); |
596a855f |
640 | |
ec92bee0 |
641 | // Initialize the CDB storage |
795e4a22 |
642 | InitCDB(); |
643 | |
644 | AliSysInfo::AddStamp("LoadCDB"); |
ec92bee0 |
645 | |
6bae477a |
646 | // Set run number in CDBManager (if it is not already set by the user) |
795e4a22 |
647 | if (!SetRunNumberFromData()) if (fStopOnError) return kFALSE; |
648 | |
649 | // Set CDB lock: from now on it is forbidden to reset the run number |
650 | // or the default storage or to activate any further storage! |
651 | SetCDBLock(); |
652 | |
6bae477a |
653 | // Import ideal TGeo geometry and apply misalignment |
654 | if (!gGeoManager) { |
655 | TString geom(gSystem->DirName(fGAliceFileName)); |
656 | geom += "/geometry.root"; |
98e303d9 |
657 | AliGeomManager::LoadGeometry(geom.Data()); |
6bae477a |
658 | if (!gGeoManager) if (fStopOnError) return kFALSE; |
659 | } |
8e245d15 |
660 | |
6bae477a |
661 | if (!MisalignGeometry(fLoadAlignData)) if (fStopOnError) return kFALSE; |
0f88822a |
662 | AliSysInfo::AddStamp("LoadGeom"); |
6bae477a |
663 | |
7c002d48 |
664 | //QA |
665 | Int_t sameQACycle = kFALSE ; |
e0176e97 |
666 | AliQADataMakerSteer qas ; |
7c002d48 |
667 | if (fRunQA && fRawReader) { |
668 | qas.Run(fRunLocalReconstruction, fRawReader) ; |
669 | sameQACycle = kTRUE; |
670 | } |
671 | // checking the QA of previous steps |
04236e67 |
672 | //CheckQA() ; |
e0176e97 |
673 | |
aa3c69a9 |
674 | /* |
596a855f |
675 | // local reconstruction |
59697224 |
676 | if (!fRunLocalReconstruction.IsNull()) { |
677 | if (!RunLocalReconstruction(fRunLocalReconstruction)) { |
e583c30d |
678 | if (fStopOnError) {CleanUp(); return kFALSE;} |
596a855f |
679 | } |
680 | } |
aa3c69a9 |
681 | */ |
2257f27e |
682 | |
683 | // get vertexer |
684 | if (fRunVertexFinder && !CreateVertexer()) { |
685 | if (fStopOnError) { |
686 | CleanUp(); |
687 | return kFALSE; |
688 | } |
689 | } |
0f88822a |
690 | AliSysInfo::AddStamp("Vertexer"); |
596a855f |
691 | |
f08fc9f5 |
692 | // get trackers |
b8cd5251 |
693 | if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) { |
24f7a148 |
694 | if (fStopOnError) { |
695 | CleanUp(); |
696 | return kFALSE; |
697 | } |
596a855f |
698 | } |
0f88822a |
699 | AliSysInfo::AddStamp("LoadTrackers"); |
24f7a148 |
700 | |
b26c3770 |
701 | // get the possibly already existing ESD file and tree |
af885e0f |
702 | AliESDEvent* esd = new AliESDEvent(); AliESDEvent* hltesd = new AliESDEvent(); |
b26c3770 |
703 | TFile* fileOld = NULL; |
1f46a9ae |
704 | TTree* treeOld = NULL; TTree *hlttreeOld = NULL; |
b26c3770 |
705 | if (!gSystem->AccessPathName("AliESDs.root")){ |
706 | gSystem->CopyFile("AliESDs.root", "AliESDs.old.root", kTRUE); |
707 | fileOld = TFile::Open("AliESDs.old.root"); |
708 | if (fileOld && fileOld->IsOpen()) { |
709 | treeOld = (TTree*) fileOld->Get("esdTree"); |
46698ae4 |
710 | if (treeOld)esd->ReadFromTree(treeOld); |
1f46a9ae |
711 | hlttreeOld = (TTree*) fileOld->Get("HLTesdTree"); |
46698ae4 |
712 | if (hlttreeOld) hltesd->ReadFromTree(hlttreeOld); |
b26c3770 |
713 | } |
714 | } |
715 | |
36711aa4 |
716 | // create the ESD output file and tree |
596a855f |
717 | TFile* file = TFile::Open("AliESDs.root", "RECREATE"); |
46698ae4 |
718 | file->SetCompressionLevel(2); |
596a855f |
719 | if (!file->IsOpen()) { |
815c2b38 |
720 | AliError("opening AliESDs.root failed"); |
b26c3770 |
721 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
596a855f |
722 | } |
46698ae4 |
723 | |
36711aa4 |
724 | TTree* tree = new TTree("esdTree", "Tree with ESD objects"); |
af885e0f |
725 | esd = new AliESDEvent(); |
46698ae4 |
726 | esd->CreateStdContent(); |
727 | esd->WriteToTree(tree); |
728 | |
1f46a9ae |
729 | TTree* hlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects"); |
af885e0f |
730 | hltesd = new AliESDEvent(); |
46698ae4 |
731 | hltesd->CreateStdContent(); |
732 | hltesd->WriteToTree(hlttree); |
733 | |
734 | /* CKB Why? |
1f46a9ae |
735 | delete esd; delete hltesd; |
736 | esd = NULL; hltesd = NULL; |
46698ae4 |
737 | */ |
500d54ab |
738 | // create the branch with ESD additions |
5728d3d5 |
739 | |
740 | |
741 | |
46698ae4 |
742 | AliESDfriend *esdf = 0; |
1d99986f |
743 | if (fWriteESDfriend) { |
46698ae4 |
744 | esdf = new AliESDfriend(); |
745 | TBranch *br=tree->Branch("ESDfriend.","AliESDfriend", &esdf); |
746 | br->SetFile("AliESDfriends.root"); |
747 | esd->AddObject(esdf); |
1d99986f |
748 | } |
5728d3d5 |
749 | |
46698ae4 |
750 | |
444753c6 |
751 | // Get the GRP CDB entry |
752 | AliCDBEntry* entryGRP = AliCDBManager::Instance()->Get("GRP/GRP/Data"); |
753 | |
754 | if(entryGRP) { |
755 | fGRPList = dynamic_cast<TList*> (entryGRP->GetObject()); |
756 | } else { |
757 | AliError("No GRP entry found in OCDB!"); |
758 | } |
759 | |
17c86e90 |
760 | // Get the diamond profile from OCDB |
761 | AliCDBEntry* entry = AliCDBManager::Instance() |
762 | ->Get("GRP/Calib/MeanVertex"); |
763 | |
764 | if(entry) { |
765 | fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject()); |
766 | } else { |
767 | AliError("No diamond profile found in OCDB!"); |
768 | } |
769 | |
43c9dae1 |
770 | entry = 0; |
771 | entry = AliCDBManager::Instance() |
772 | ->Get("GRP/Calib/MeanVertexTPC"); |
773 | |
774 | if(entry) { |
775 | fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject()); |
776 | } else { |
777 | AliError("No diamond profile found in OCDB!"); |
778 | } |
779 | |
20e5681c |
780 | AliVertexerTracks tVertexer(AliTracker::GetBz()); |
87317a47 |
781 | if(fDiamondProfile && fMeanVertexConstraint) tVertexer.SetVtxStart(fDiamondProfile); |
c5e3e5d1 |
782 | |
b649205a |
783 | if (fRawReader) fRawReader->RewindEvents(); |
a5fa6165 |
784 | |
95cee32f |
785 | ProcInfo_t ProcInfo; |
786 | gSystem->GetProcInfo(&ProcInfo); |
787 | AliInfo(Form("Current memory usage %d %d", ProcInfo.fMemResident, ProcInfo.fMemVirtual)); |
8661738e |
788 | |
aa3c69a9 |
789 | |
790 | //Initialize the QA and start of cycle for out-of-cycle QA |
791 | if (fRunQA) { |
792 | TString detStr(fFillESD); |
793 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
794 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; |
04236e67 |
795 | AliQADataMakerRec *qadm = GetQADataMaker(iDet); |
aa3c69a9 |
796 | if (!qadm) continue; |
797 | AliInfo(Form("Initializing the QA data maker for %s", |
798 | fgkDetectorName[iDet])); |
799 | qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun()); |
800 | qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun()); |
7c002d48 |
801 | // if (!fInLoopQA) { |
802 | // qadm->StartOfCycle(AliQA::kRECPOINTS); |
803 | // qadm->StartOfCycle(AliQA::kESDS,"same"); |
804 | // } |
aa3c69a9 |
805 | } |
3b378a42 |
806 | } |
807 | if (fRunGlobalQA) { |
7c002d48 |
808 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); |
3b378a42 |
809 | AliInfo(Form("Initializing the global QA data maker")); |
810 | TObjArray *arr= |
aa3c69a9 |
811 | qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun()); |
3b378a42 |
812 | AliTracker::SetResidualsArray(arr); |
813 | qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun()); |
814 | if (!fInLoopQA) { |
7c002d48 |
815 | qadm->StartOfCycle(AliQA::kRECPOINTS, sameQACycle); |
816 | qadm->StartOfCycle(AliQA::kESDS, "same"); |
aa3c69a9 |
817 | } |
818 | } |
819 | |
7167ae53 |
820 | //Initialize the Plane Efficiency framework |
821 | if (fRunPlaneEff && !InitPlaneEff()) { |
822 | if(fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
823 | } |
aa3c69a9 |
824 | |
825 | //******* The loop over events |
596a855f |
826 | for (Int_t iEvent = 0; iEvent < fRunLoader->GetNumberOfEvents(); iEvent++) { |
b26c3770 |
827 | if (fRawReader) fRawReader->NextEvent(); |
4a33489c |
828 | if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) { |
b26c3770 |
829 | // copy old ESD to the new one |
830 | if (treeOld) { |
46698ae4 |
831 | esd->ReadFromTree(treeOld); |
b26c3770 |
832 | treeOld->GetEntry(iEvent); |
d5c2df59 |
833 | tree->Fill(); |
b26c3770 |
834 | } |
1f46a9ae |
835 | if (hlttreeOld) { |
46698ae4 |
836 | esd->ReadFromTree(hlttreeOld); |
1f46a9ae |
837 | hlttreeOld->GetEntry(iEvent); |
d5c2df59 |
838 | hlttree->Fill(); |
1f46a9ae |
839 | } |
b26c3770 |
840 | continue; |
841 | } |
46698ae4 |
842 | |
815c2b38 |
843 | AliInfo(Form("processing event %d", iEvent)); |
aa3c69a9 |
844 | |
845 | //Start of cycle for the in-loop QA |
3b378a42 |
846 | if (fInLoopQA) { |
847 | if (fRunQA) { |
848 | TString detStr(fFillESD); |
849 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
850 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; |
851 | AliQADataMakerRec *qadm = GetQADataMaker(iDet); |
852 | if (!qadm) continue; |
7c002d48 |
853 | qadm->StartOfCycle(AliQA::kRECPOINTS, sameQACycle); |
3b378a42 |
854 | qadm->StartOfCycle(AliQA::kESDS, "same") ; |
855 | } |
aa3c69a9 |
856 | } |
857 | if (fRunGlobalQA) { |
7c002d48 |
858 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); |
859 | qadm->StartOfCycle(AliQA::kRECPOINTS, sameQACycle); |
860 | qadm->StartOfCycle(AliQA::kESDS, "same"); |
aa3c69a9 |
861 | } |
862 | } |
863 | |
596a855f |
864 | fRunLoader->GetEvent(iEvent); |
24f7a148 |
865 | |
bb0901a4 |
866 | char aFileName[256]; |
867 | sprintf(aFileName, "ESD_%d.%d_final.root", |
f08fc9f5 |
868 | fRunLoader->GetHeader()->GetRun(), |
869 | fRunLoader->GetHeader()->GetEventNrInRun()); |
bb0901a4 |
870 | if (!gSystem->AccessPathName(aFileName)) continue; |
24f7a148 |
871 | |
aa3c69a9 |
872 | // local signle event reconstruction |
b26c3770 |
873 | if (!fRunLocalReconstruction.IsNull()) { |
874 | if (!RunLocalEventReconstruction(fRunLocalReconstruction)) { |
875 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
876 | } |
877 | } |
878 | |
f08fc9f5 |
879 | esd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); |
1f46a9ae |
880 | hltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); |
31fd97b2 |
881 | esd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun()); |
882 | hltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun()); |
46698ae4 |
883 | |
d6ee376f |
884 | // Set magnetic field from the tracker |
885 | esd->SetMagneticField(AliTracker::GetBz()); |
886 | hltesd->SetMagneticField(AliTracker::GetBz()); |
596a855f |
887 | |
46698ae4 |
888 | |
889 | |
2e3550da |
890 | // Fill raw-data error log into the ESD |
891 | if (fRawReader) FillRawDataErrorLog(iEvent,esd); |
892 | |
2257f27e |
893 | // vertex finder |
894 | if (fRunVertexFinder) { |
895 | if (!ReadESD(esd, "vertex")) { |
896 | if (!RunVertexFinder(esd)) { |
b26c3770 |
897 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
2257f27e |
898 | } |
899 | if (fCheckPointLevel > 0) WriteESD(esd, "vertex"); |
900 | } |
901 | } |
902 | |
1f46a9ae |
903 | // HLT tracking |
904 | if (!fRunTracking.IsNull()) { |
905 | if (fRunHLTTracking) { |
06cc9d95 |
906 | hltesd->SetPrimaryVertexSPD(esd->GetVertex()); |
1f46a9ae |
907 | if (!RunHLTTracking(hltesd)) { |
908 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
909 | } |
910 | } |
911 | } |
912 | |
e66fbafb |
913 | // Muon tracking |
b8cd5251 |
914 | if (!fRunTracking.IsNull()) { |
e66fbafb |
915 | if (fRunMuonTracking) { |
761350a6 |
916 | if (!RunMuonTracking(esd)) { |
b26c3770 |
917 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
24f7a148 |
918 | } |
596a855f |
919 | } |
920 | } |
921 | |
e66fbafb |
922 | // barrel tracking |
923 | if (!fRunTracking.IsNull()) { |
21c573b7 |
924 | if (!ReadESD(esd, "tracking")) { |
925 | if (!RunTracking(esd)) { |
926 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
e66fbafb |
927 | } |
21c573b7 |
928 | if (fCheckPointLevel > 0) WriteESD(esd, "tracking"); |
e66fbafb |
929 | } |
930 | } |
21c573b7 |
931 | |
596a855f |
932 | // fill ESD |
933 | if (!fFillESD.IsNull()) { |
934 | if (!FillESD(esd, fFillESD)) { |
b26c3770 |
935 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
596a855f |
936 | } |
937 | } |
a5fa6165 |
938 | |
001397cd |
939 | // fill Event header information from the RawEventHeader |
940 | if (fRawReader){FillRawEventHeaderESD(esd);} |
596a855f |
941 | |
942 | // combined PID |
943 | AliESDpid::MakePID(esd); |
24f7a148 |
944 | if (fCheckPointLevel > 1) WriteESD(esd, "PID"); |
596a855f |
945 | |
b647652d |
946 | if (fFillTriggerESD) { |
947 | if (!ReadESD(esd, "trigger")) { |
948 | if (!FillTriggerESD(esd)) { |
949 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
950 | } |
951 | if (fCheckPointLevel > 1) WriteESD(esd, "trigger"); |
952 | } |
953 | } |
954 | |
a6ee503a |
955 | file->cd(); |
956 | |
3c3709c4 |
957 | // |
958 | // Propagate track to the beam pipe (if not laready done by ITS) |
959 | // |
960 | const Int_t ntracks = esd->GetNumberOfTracks(); |
961 | const Double_t kBz = esd->GetMagneticField(); |
962 | const Double_t kRadius = 2.8; //something less than the beam pipe radius |
963 | |
964 | TObjArray trkArray; |
965 | UShort_t *selectedIdx=new UShort_t[ntracks]; |
966 | |
967 | for (Int_t itrack=0; itrack<ntracks; itrack++){ |
968 | const Double_t kMaxStep = 5; //max step over the material |
969 | Bool_t ok; |
970 | |
971 | AliESDtrack *track = esd->GetTrack(itrack); |
972 | if (!track) continue; |
973 | |
974 | AliExternalTrackParam *tpcTrack = |
975 | (AliExternalTrackParam *)track->GetTPCInnerParam(); |
bcabd6af |
976 | ok = kFALSE; |
977 | if (tpcTrack) |
978 | ok = AliTracker:: |
979 | PropagateTrackTo(tpcTrack,kRadius,track->GetMass(),kMaxStep,kTRUE); |
43c9dae1 |
980 | |
981 | |
982 | |
3c3709c4 |
983 | if (ok) { |
984 | Int_t n=trkArray.GetEntriesFast(); |
985 | selectedIdx[n]=track->GetID(); |
986 | trkArray.AddLast(tpcTrack); |
987 | } |
988 | |
989 | if (track->GetX() < kRadius) continue; |
990 | |
991 | ok = AliTracker:: |
992 | PropagateTrackTo(track,kRadius,track->GetMass(),kMaxStep,kTRUE); |
993 | if (ok) { |
994 | track->RelateToVertex(esd->GetPrimaryVertexSPD(), kBz, kRadius); |
995 | } |
996 | } |
997 | |
998 | // |
999 | // Improve the reconstructed primary vertex position using the tracks |
1000 | // |
1001 | TObject *obj = fOptions.FindObject("ITS"); |
c060d7fe |
1002 | if (obj) { |
1003 | TString optITS = obj->GetTitle(); |
1004 | if (optITS.Contains("cosmics") || optITS.Contains("COSMICS")) |
a84e2607 |
1005 | fRunVertexFinderTracks=kFALSE; |
c060d7fe |
1006 | } |
3c3709c4 |
1007 | if (fRunVertexFinderTracks) { |
1008 | // TPC + ITS primary vertex |
43c9dae1 |
1009 | tVertexer.SetITSrefitRequired(); |
1010 | if(fDiamondProfile && fMeanVertexConstraint) { |
1011 | tVertexer.SetVtxStart(fDiamondProfile); |
1012 | } else { |
1013 | tVertexer.SetConstraintOff(); |
1014 | } |
3c3709c4 |
1015 | AliESDVertex *pvtx=tVertexer.FindPrimaryVertex(esd); |
1016 | if (pvtx) { |
1017 | if (pvtx->GetStatus()) { |
1018 | esd->SetPrimaryVertex(pvtx); |
1019 | for (Int_t i=0; i<ntracks; i++) { |
1020 | AliESDtrack *t = esd->GetTrack(i); |
1021 | t->RelateToVertex(pvtx, kBz, kRadius); |
1022 | } |
1023 | } |
1024 | } |
1025 | |
1026 | // TPC-only primary vertex |
43c9dae1 |
1027 | tVertexer.SetITSrefitNotRequired(); |
1028 | if(fDiamondProfileTPC && fMeanVertexConstraint) { |
1029 | tVertexer.SetVtxStart(fDiamondProfileTPC); |
1030 | } else { |
1031 | tVertexer.SetConstraintOff(); |
1032 | } |
3c3709c4 |
1033 | pvtx=tVertexer.FindPrimaryVertex(&trkArray,selectedIdx); |
1034 | if (pvtx) { |
1035 | if (pvtx->GetStatus()) { |
1036 | esd->SetPrimaryVertexTPC(pvtx); |
1037 | Int_t nsel=trkArray.GetEntriesFast(); |
1038 | for (Int_t i=0; i<nsel; i++) { |
1039 | AliExternalTrackParam *t = |
1040 | (AliExternalTrackParam *)trkArray.UncheckedAt(i); |
1041 | t->PropagateToDCA(pvtx, kBz, kRadius); |
1042 | } |
1043 | } |
1044 | } |
1045 | |
1046 | } |
1047 | delete[] selectedIdx; |
1048 | |
17c86e90 |
1049 | if(fDiamondProfile) esd->SetDiamond(fDiamondProfile); |
1050 | |
c5e3e5d1 |
1051 | |
d1683eef |
1052 | if (fRunV0Finder) { |
1053 | // V0 finding |
1054 | AliV0vertexer vtxer; |
1055 | vtxer.Tracks2V0vertices(esd); |
5e4ff34d |
1056 | |
d1683eef |
1057 | if (fRunCascadeFinder) { |
1058 | // Cascade finding |
1059 | AliCascadeVertexer cvtxer; |
1060 | cvtxer.V0sTracks2CascadeVertices(esd); |
1061 | } |
5e4ff34d |
1062 | } |
1063 | |
596a855f |
1064 | // write ESD |
d64bd07d |
1065 | if (fCleanESD) CleanESD(esd); |
854c6476 |
1066 | |
3b378a42 |
1067 | if (fRunGlobalQA) { |
7c002d48 |
1068 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); |
854c6476 |
1069 | if (qadm) qadm->Exec(AliQA::kESDS, esd); |
1070 | } |
1071 | |
1d99986f |
1072 | if (fWriteESDfriend) { |
99f99e0e |
1073 | esdf->~AliESDfriend(); |
46698ae4 |
1074 | new (esdf) AliESDfriend(); // Reset... |
1075 | esd->GetESDfriend(esdf); |
1d99986f |
1076 | } |
500d54ab |
1077 | tree->Fill(); |
1078 | |
1079 | // write HLT ESD |
1080 | hlttree->Fill(); |
1d99986f |
1081 | |
f3a97c86 |
1082 | if (fCheckPointLevel > 0) WriteESD(esd, "final"); |
46698ae4 |
1083 | esd->Reset(); |
1084 | hltesd->Reset(); |
5728d3d5 |
1085 | if (fWriteESDfriend) { |
99f99e0e |
1086 | esdf->~AliESDfriend(); |
5728d3d5 |
1087 | new (esdf) AliESDfriend(); // Reset... |
1088 | } |
a5fa6165 |
1089 | |
95cee32f |
1090 | gSystem->GetProcInfo(&ProcInfo); |
1091 | AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, ProcInfo.fMemResident, ProcInfo.fMemVirtual)); |
a5fa6165 |
1092 | |
7e963665 |
1093 | |
aa3c69a9 |
1094 | // End of cycle for the in-loop QA |
3b378a42 |
1095 | if (fInLoopQA) { |
1096 | if (fRunQA) { |
1097 | RunQA(fFillESD.Data(), esd); |
1098 | TString detStr(fFillESD); |
1099 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
7c002d48 |
1100 | if (!IsSelected(fgkDetectorName[iDet], detStr)) |
1101 | continue; |
1102 | AliQADataMakerRec * qadm = GetQADataMaker(iDet); |
1103 | if (!qadm) |
1104 | continue; |
1105 | qadm->EndOfCycle(AliQA::kRECPOINTS); |
1106 | qadm->EndOfCycle(AliQA::kESDS); |
1107 | qadm->Finish(); |
1108 | } |
aa3c69a9 |
1109 | } |
1110 | if (fRunGlobalQA) { |
7c002d48 |
1111 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); |
aa3c69a9 |
1112 | if (qadm) { |
1113 | qadm->EndOfCycle(AliQA::kRECPOINTS); |
d7259b2e |
1114 | qadm->EndOfCycle(AliQA::kESDS); |
aa3c69a9 |
1115 | qadm->Finish(); |
1116 | } |
1117 | } |
1118 | } |
1119 | } |
1120 | //******** End of the loop over events |
1121 | |
1122 | |
5728d3d5 |
1123 | |
46698ae4 |
1124 | tree->GetUserInfo()->Add(esd); |
1125 | hlttree->GetUserInfo()->Add(hltesd); |
f747912b |
1126 | |
1127 | const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap(); |
1128 | const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds(); |
1129 | |
1130 | TMap *cdbMapCopy = new TMap(cdbMap->GetEntries()); |
1131 | cdbMapCopy->SetOwner(1); |
1132 | cdbMapCopy->SetName("cdbMap"); |
1133 | TIter iter(cdbMap->GetTable()); |
1134 | |
1135 | TPair* pair = 0; |
1136 | while((pair = dynamic_cast<TPair*> (iter.Next()))){ |
1137 | TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key()); |
1138 | TObjString* valStr = dynamic_cast<TObjString*> (pair->Value()); |
1139 | cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName())); |
1140 | } |
1141 | |
1142 | TList *cdbListCopy = new TList(); |
1143 | cdbListCopy->SetOwner(1); |
1144 | cdbListCopy->SetName("cdbList"); |
1145 | |
1146 | TIter iter2(cdbList); |
1147 | |
1148 | AliCDBId* id=0; |
1149 | while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){ |
a4970db9 |
1150 | cdbListCopy->Add(new TObjString(id->ToString().Data())); |
f747912b |
1151 | } |
1152 | |
1153 | tree->GetUserInfo()->Add(cdbMapCopy); |
1154 | tree->GetUserInfo()->Add(cdbListCopy); |
abe0c04e |
1155 | |
46698ae4 |
1156 | |
1157 | if(fESDPar.Contains("ESD.par")){ |
1158 | AliInfo("Attaching ESD.par to Tree"); |
1159 | TNamed *fn = CopyFileToTNamed(fESDPar.Data(),"ESD.par"); |
1160 | tree->GetUserInfo()->Add(fn); |
596a855f |
1161 | } |
1162 | |
46698ae4 |
1163 | |
36711aa4 |
1164 | file->cd(); |
aa3c69a9 |
1165 | |
a9c0e6db |
1166 | if (fWriteESDfriend) |
1167 | tree->SetBranchStatus("ESDfriend*",0); |
562dd0b4 |
1168 | // we want to have only one tree version number |
1169 | tree->Write(tree->GetName(),TObject::kOverwrite); |
1f46a9ae |
1170 | hlttree->Write(); |
f3a97c86 |
1171 | |
a7a1e1c7 |
1172 | // Finish with Plane Efficiency evaluation: before of CleanUp !!! |
1173 | if (fRunPlaneEff && !FinishPlaneEff()) { |
1174 | AliWarning("Finish PlaneEff evaluation failed"); |
1175 | } |
1176 | |
eae191bc |
1177 | gROOT->cd(); |
1178 | CleanUp(file, fileOld); |
1179 | |
a7807689 |
1180 | if (fWriteAOD) { |
7a3b2050 |
1181 | AliWarning("AOD creation not supported anymore during reconstruction. See ANALYSIS/AliAnalysisTaskESDfilter.cxx instead."); |
a7807689 |
1182 | } |
1183 | |
f3a97c86 |
1184 | // Create tags for the events in the ESD tree (the ESD tree is always present) |
1185 | // In case of empty events the tags will contain dummy values |
08e1a23e |
1186 | AliESDTagCreator *esdtagCreator = new AliESDTagCreator(); |
444753c6 |
1187 | esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPList); |
a1069ee1 |
1188 | if (fWriteAOD) { |
7a3b2050 |
1189 | AliWarning("AOD tag creation not supported anymore during reconstruction."); |
a1069ee1 |
1190 | } |
596a855f |
1191 | |
aa3c69a9 |
1192 | //Finish QA and end of cycle for out-of-loop QA |
3b378a42 |
1193 | if (!fInLoopQA) { |
1194 | if (fRunQA) { |
7c002d48 |
1195 | qas.Run(fRunLocalReconstruction.Data(), AliQA::kRECPOINTS, sameQACycle); |
3b378a42 |
1196 | //qas.Reset() ; |
7c002d48 |
1197 | qas.Run(fRunTracking.Data(), AliQA::kESDS, sameQACycle); |
3b378a42 |
1198 | } |
aa3c69a9 |
1199 | if (fRunGlobalQA) { |
7c002d48 |
1200 | AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL); |
aa3c69a9 |
1201 | if (qadm) { |
1202 | qadm->EndOfCycle(AliQA::kRECPOINTS); |
d7259b2e |
1203 | qadm->EndOfCycle(AliQA::kESDS); |
aa3c69a9 |
1204 | qadm->Finish(); |
1205 | } |
1206 | } |
759c1df1 |
1207 | } |
795e4a22 |
1208 | |
1209 | // Cleanup of CDB manager: cache and active storages! |
1210 | AliCDBManager::Instance()->ClearCache(); |
1211 | |
1212 | |
596a855f |
1213 | return kTRUE; |
1214 | } |
1215 | |
1216 | |
1217 | //_____________________________________________________________________________ |
c4aa7a4c |
1218 | Bool_t AliReconstruction::RunLocalReconstruction(const TString& /*detectors*/) |
596a855f |
1219 | { |
59697224 |
1220 | // run the local reconstruction |
0f88822a |
1221 | static Int_t eventNr=0; |
87932dab |
1222 | AliCodeTimerAuto("") |
030b532d |
1223 | |
d76c31f4 |
1224 | // AliCDBManager* man = AliCDBManager::Instance(); |
1225 | // Bool_t origCache = man->GetCacheFlag(); |
8e245d15 |
1226 | |
d76c31f4 |
1227 | // TString detStr = detectors; |
1228 | // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1229 | // if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; |
1230 | // AliReconstructor* reconstructor = GetReconstructor(iDet); |
1231 | // if (!reconstructor) continue; |
1232 | // if (reconstructor->HasLocalReconstruction()) continue; |
b8cd5251 |
1233 | |
d76c31f4 |
1234 | // AliCodeTimerStart(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
1235 | // AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
87932dab |
1236 | |
d76c31f4 |
1237 | // AliCodeTimerStart(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); |
1238 | // AliInfo(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); |
8e245d15 |
1239 | |
d76c31f4 |
1240 | // man->SetCacheFlag(kTRUE); |
1241 | // TString calibPath = Form("%s/Calib/*", fgkDetectorName[iDet]); |
1242 | // man->GetAll(calibPath); // entries are cached! |
8e245d15 |
1243 | |
d76c31f4 |
1244 | // AliCodeTimerStop(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); |
87932dab |
1245 | |
d76c31f4 |
1246 | // if (fRawReader) { |
1247 | // fRawReader->RewindEvents(); |
1248 | // reconstructor->Reconstruct(fRunLoader, fRawReader); |
1249 | // } else { |
1250 | // reconstructor->Reconstruct(fRunLoader); |
1251 | // } |
87932dab |
1252 | |
d76c31f4 |
1253 | // AliCodeTimerStop(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
0f88822a |
1254 | // AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr)); |
8e245d15 |
1255 | |
d76c31f4 |
1256 | // // unload calibration data |
1257 | // man->UnloadFromCache(calibPath); |
1258 | // //man->ClearCache(); |
1259 | // } |
596a855f |
1260 | |
d76c31f4 |
1261 | // man->SetCacheFlag(origCache); |
8e245d15 |
1262 | |
d76c31f4 |
1263 | // if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { |
1264 | // AliError(Form("the following detectors were not found: %s", |
1265 | // detStr.Data())); |
1266 | // if (fStopOnError) return kFALSE; |
1267 | // } |
596a855f |
1268 | |
0f88822a |
1269 | eventNr++; |
596a855f |
1270 | return kTRUE; |
1271 | } |
1272 | |
b26c3770 |
1273 | //_____________________________________________________________________________ |
1274 | Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors) |
1275 | { |
1276 | // run the local reconstruction |
aa3c69a9 |
1277 | |
0f88822a |
1278 | static Int_t eventNr=0; |
87932dab |
1279 | AliCodeTimerAuto("") |
b26c3770 |
1280 | |
1281 | TString detStr = detectors; |
1282 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1283 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; |
1284 | AliReconstructor* reconstructor = GetReconstructor(iDet); |
1285 | if (!reconstructor) continue; |
1286 | AliLoader* loader = fLoader[iDet]; |
d76c31f4 |
1287 | if (!loader) { |
1288 | AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet])); |
1289 | continue; |
1290 | } |
b26c3770 |
1291 | // conversion of digits |
1292 | if (fRawReader && reconstructor->HasDigitConversion()) { |
1293 | AliInfo(Form("converting raw data digits into root objects for %s", |
1294 | fgkDetectorName[iDet])); |
87932dab |
1295 | AliCodeTimerAuto(Form("converting raw data digits into root objects for %s", |
1296 | fgkDetectorName[iDet])); |
b26c3770 |
1297 | loader->LoadDigits("update"); |
1298 | loader->CleanDigits(); |
1299 | loader->MakeDigitsContainer(); |
1300 | TTree* digitsTree = loader->TreeD(); |
1301 | reconstructor->ConvertDigits(fRawReader, digitsTree); |
1302 | loader->WriteDigits("OVERWRITE"); |
1303 | loader->UnloadDigits(); |
b26c3770 |
1304 | } |
b26c3770 |
1305 | // local reconstruction |
b26c3770 |
1306 | AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
87932dab |
1307 | AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet])); |
b26c3770 |
1308 | loader->LoadRecPoints("update"); |
1309 | loader->CleanRecPoints(); |
1310 | loader->MakeRecPointsContainer(); |
1311 | TTree* clustersTree = loader->TreeR(); |
1312 | if (fRawReader && !reconstructor->HasDigitConversion()) { |
1313 | reconstructor->Reconstruct(fRawReader, clustersTree); |
1314 | } else { |
1315 | loader->LoadDigits("read"); |
1316 | TTree* digitsTree = loader->TreeD(); |
1317 | if (!digitsTree) { |
1318 | AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet])); |
1319 | if (fStopOnError) return kFALSE; |
1320 | } else { |
1321 | reconstructor->Reconstruct(digitsTree, clustersTree); |
1322 | } |
1323 | loader->UnloadDigits(); |
1324 | } |
d76c31f4 |
1325 | |
aa3c69a9 |
1326 | // In-loop QA for local reconstrucion |
1327 | if (fRunQA && fInLoopQA) { |
04236e67 |
1328 | AliQADataMakerRec * qadm = GetQADataMaker(iDet); |
aa3c69a9 |
1329 | if (qadm) { |
1330 | //AliCodeTimerStart |
1331 | //(Form("Running QA data maker for %s", fgkDetectorName[iDet])); |
1332 | //AliInfo |
1333 | //(Form("Running QA data maker for %s", fgkDetectorName[iDet])); |
1334 | |
1335 | qadm->Exec(AliQA::kRECPOINTS, clustersTree) ; |
1336 | |
1337 | //AliCodeTimerStop |
1338 | //(Form("Running QA data maker for %s", fgkDetectorName[iDet])); |
1339 | } |
1340 | } |
d76c31f4 |
1341 | |
aa3c69a9 |
1342 | loader->WriteRecPoints("OVERWRITE"); |
b26c3770 |
1343 | loader->UnloadRecPoints(); |
6efecea1 |
1344 | AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr); |
b26c3770 |
1345 | } |
1346 | |
1347 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { |
1348 | AliError(Form("the following detectors were not found: %s", |
1349 | detStr.Data())); |
1350 | if (fStopOnError) return kFALSE; |
1351 | } |
0f88822a |
1352 | eventNr++; |
b26c3770 |
1353 | return kTRUE; |
1354 | } |
1355 | |
596a855f |
1356 | //_____________________________________________________________________________ |
af885e0f |
1357 | Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd) |
596a855f |
1358 | { |
1359 | // run the barrel tracking |
1360 | |
87932dab |
1361 | AliCodeTimerAuto("") |
030b532d |
1362 | |
2257f27e |
1363 | AliESDVertex* vertex = NULL; |
1364 | Double_t vtxPos[3] = {0, 0, 0}; |
1365 | Double_t vtxErr[3] = {0.07, 0.07, 0.1}; |
1366 | TArrayF mcVertex(3); |
a6b0b91b |
1367 | if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) { |
1368 | fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex); |
1369 | for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i]; |
1370 | } |
2257f27e |
1371 | |
b8cd5251 |
1372 | if (fVertexer) { |
17c86e90 |
1373 | if(fDiamondProfile) fVertexer->SetVtxStart(fDiamondProfile); |
815c2b38 |
1374 | AliInfo("running the ITS vertex finder"); |
b26c3770 |
1375 | if (fLoader[0]) fLoader[0]->LoadRecPoints(); |
b8cd5251 |
1376 | vertex = fVertexer->FindVertexForCurrentEvent(fRunLoader->GetEventNumber()); |
b26c3770 |
1377 | if (fLoader[0]) fLoader[0]->UnloadRecPoints(); |
2257f27e |
1378 | if(!vertex){ |
815c2b38 |
1379 | AliWarning("Vertex not found"); |
c710f220 |
1380 | vertex = new AliESDVertex(); |
d1a50cb5 |
1381 | vertex->SetName("default"); |
2257f27e |
1382 | } |
1383 | else { |
d1a50cb5 |
1384 | vertex->SetName("reconstructed"); |
2257f27e |
1385 | } |
1386 | |
1387 | } else { |
815c2b38 |
1388 | AliInfo("getting the primary vertex from MC"); |
2257f27e |
1389 | vertex = new AliESDVertex(vtxPos, vtxErr); |
1390 | } |
1391 | |
1392 | if (vertex) { |
1393 | vertex->GetXYZ(vtxPos); |
1394 | vertex->GetSigmaXYZ(vtxErr); |
1395 | } else { |
815c2b38 |
1396 | AliWarning("no vertex reconstructed"); |
2257f27e |
1397 | vertex = new AliESDVertex(vtxPos, vtxErr); |
1398 | } |
06cc9d95 |
1399 | esd->SetPrimaryVertexSPD(vertex); |
32e449be |
1400 | // if SPD multiplicity has been determined, it is stored in the ESD |
25be1e5c |
1401 | AliMultiplicity *mult = fVertexer->GetMultiplicity(); |
32e449be |
1402 | if(mult)esd->SetMultiplicity(mult); |
1403 | |
b8cd5251 |
1404 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1405 | if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr); |
1406 | } |
2257f27e |
1407 | delete vertex; |
1408 | |
2257f27e |
1409 | return kTRUE; |
1410 | } |
1411 | |
1f46a9ae |
1412 | //_____________________________________________________________________________ |
af885e0f |
1413 | Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd) |
1f46a9ae |
1414 | { |
1415 | // run the HLT barrel tracking |
1416 | |
87932dab |
1417 | AliCodeTimerAuto("") |
1f46a9ae |
1418 | |
1419 | if (!fRunLoader) { |
1420 | AliError("Missing runLoader!"); |
1421 | return kFALSE; |
1422 | } |
1423 | |
1424 | AliInfo("running HLT tracking"); |
1425 | |
1426 | // Get a pointer to the HLT reconstructor |
1427 | AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1); |
1428 | if (!reconstructor) return kFALSE; |
1429 | |
1430 | // TPC + ITS |
1431 | for (Int_t iDet = 1; iDet >= 0; iDet--) { |
1432 | TString detName = fgkDetectorName[iDet]; |
1433 | AliDebug(1, Form("%s HLT tracking", detName.Data())); |
1434 | reconstructor->SetOption(detName.Data()); |
d76c31f4 |
1435 | AliTracker *tracker = reconstructor->CreateTracker(); |
1f46a9ae |
1436 | if (!tracker) { |
1437 | AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data())); |
1438 | if (fStopOnError) return kFALSE; |
9dcc06e1 |
1439 | continue; |
1f46a9ae |
1440 | } |
1441 | Double_t vtxPos[3]; |
1442 | Double_t vtxErr[3]={0.005,0.005,0.010}; |
1443 | const AliESDVertex *vertex = esd->GetVertex(); |
1444 | vertex->GetXYZ(vtxPos); |
1445 | tracker->SetVertex(vtxPos,vtxErr); |
1446 | if(iDet != 1) { |
1447 | fLoader[iDet]->LoadRecPoints("read"); |
1448 | TTree* tree = fLoader[iDet]->TreeR(); |
1449 | if (!tree) { |
1450 | AliError(Form("Can't get the %s cluster tree", detName.Data())); |
1451 | return kFALSE; |
1452 | } |
1453 | tracker->LoadClusters(tree); |
1454 | } |
1455 | if (tracker->Clusters2Tracks(esd) != 0) { |
1456 | AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet])); |
1457 | return kFALSE; |
1458 | } |
1459 | if(iDet != 1) { |
1460 | tracker->UnloadClusters(); |
1461 | } |
1462 | delete tracker; |
1463 | } |
1464 | |
1f46a9ae |
1465 | return kTRUE; |
1466 | } |
1467 | |
e66fbafb |
1468 | //_____________________________________________________________________________ |
af885e0f |
1469 | Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd) |
e66fbafb |
1470 | { |
1471 | // run the muon spectrometer tracking |
1472 | |
87932dab |
1473 | AliCodeTimerAuto("") |
e66fbafb |
1474 | |
1475 | if (!fRunLoader) { |
1476 | AliError("Missing runLoader!"); |
1477 | return kFALSE; |
1478 | } |
1479 | Int_t iDet = 7; // for MUON |
1480 | |
1481 | AliInfo("is running..."); |
1482 | |
1483 | // Get a pointer to the MUON reconstructor |
1484 | AliReconstructor *reconstructor = GetReconstructor(iDet); |
1485 | if (!reconstructor) return kFALSE; |
1486 | |
1487 | |
1488 | TString detName = fgkDetectorName[iDet]; |
1489 | AliDebug(1, Form("%s tracking", detName.Data())); |
d76c31f4 |
1490 | AliTracker *tracker = reconstructor->CreateTracker(); |
e66fbafb |
1491 | if (!tracker) { |
1492 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); |
1493 | return kFALSE; |
1494 | } |
1495 | |
e66fbafb |
1496 | // read RecPoints |
761350a6 |
1497 | fLoader[iDet]->LoadRecPoints("read"); |
c1954ee5 |
1498 | |
761350a6 |
1499 | tracker->LoadClusters(fLoader[iDet]->TreeR()); |
1500 | |
1501 | Int_t rv = tracker->Clusters2Tracks(esd); |
1502 | |
761350a6 |
1503 | if ( rv ) |
1504 | { |
e66fbafb |
1505 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); |
1506 | return kFALSE; |
1507 | } |
761350a6 |
1508 | |
e66fbafb |
1509 | fLoader[iDet]->UnloadRecPoints(); |
1510 | |
c1954ee5 |
1511 | tracker->UnloadClusters(); |
1512 | |
e66fbafb |
1513 | delete tracker; |
1514 | |
e66fbafb |
1515 | return kTRUE; |
1516 | } |
1517 | |
1518 | |
2257f27e |
1519 | //_____________________________________________________________________________ |
af885e0f |
1520 | Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd) |
2257f27e |
1521 | { |
1522 | // run the barrel tracking |
0f88822a |
1523 | static Int_t eventNr=0; |
87932dab |
1524 | AliCodeTimerAuto("") |
24f7a148 |
1525 | |
815c2b38 |
1526 | AliInfo("running tracking"); |
596a855f |
1527 | |
91b876d1 |
1528 | //Fill the ESD with the T0 info (will be used by the TOF) |
d76c31f4 |
1529 | if (fReconstructor[11] && fLoader[11]) { |
1530 | fLoader[11]->LoadRecPoints("READ"); |
1531 | TTree *treeR = fLoader[11]->TreeR(); |
1532 | GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd); |
1533 | } |
91b876d1 |
1534 | |
b8cd5251 |
1535 | // pass 1: TPC + ITS inwards |
1536 | for (Int_t iDet = 1; iDet >= 0; iDet--) { |
1537 | if (!fTracker[iDet]) continue; |
1538 | AliDebug(1, Form("%s tracking", fgkDetectorName[iDet])); |
24f7a148 |
1539 | |
b8cd5251 |
1540 | // load clusters |
1541 | fLoader[iDet]->LoadRecPoints("read"); |
6efecea1 |
1542 | AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr); |
b8cd5251 |
1543 | TTree* tree = fLoader[iDet]->TreeR(); |
1544 | if (!tree) { |
1545 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); |
24f7a148 |
1546 | return kFALSE; |
1547 | } |
b8cd5251 |
1548 | fTracker[iDet]->LoadClusters(tree); |
6efecea1 |
1549 | AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr); |
b8cd5251 |
1550 | // run tracking |
1551 | if (fTracker[iDet]->Clusters2Tracks(esd) != 0) { |
1552 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); |
24f7a148 |
1553 | return kFALSE; |
1554 | } |
b8cd5251 |
1555 | if (fCheckPointLevel > 1) { |
1556 | WriteESD(esd, Form("%s.tracking", fgkDetectorName[iDet])); |
1557 | } |
878e1fe1 |
1558 | // preliminary PID in TPC needed by the ITS tracker |
1559 | if (iDet == 1) { |
b26c3770 |
1560 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); |
878e1fe1 |
1561 | AliESDpid::MakePID(esd); |
0f88822a |
1562 | } |
6efecea1 |
1563 | AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr); |
b8cd5251 |
1564 | } |
596a855f |
1565 | |
b8cd5251 |
1566 | // pass 2: ALL backwards |
aa3c69a9 |
1567 | |
b8cd5251 |
1568 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1569 | if (!fTracker[iDet]) continue; |
1570 | AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet])); |
1571 | |
1572 | // load clusters |
1573 | if (iDet > 1) { // all except ITS, TPC |
1574 | TTree* tree = NULL; |
7b61cd9c |
1575 | fLoader[iDet]->LoadRecPoints("read"); |
6efecea1 |
1576 | AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr); |
7b61cd9c |
1577 | tree = fLoader[iDet]->TreeR(); |
b8cd5251 |
1578 | if (!tree) { |
1579 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); |
24f7a148 |
1580 | return kFALSE; |
1581 | } |
0f88822a |
1582 | fTracker[iDet]->LoadClusters(tree); |
6efecea1 |
1583 | AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr); |
b8cd5251 |
1584 | } |
24f7a148 |
1585 | |
b8cd5251 |
1586 | // run tracking |
283f39c6 |
1587 | if (iDet>1) // start filling residuals for the "outer" detectors |
1588 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE); |
1589 | |
b8cd5251 |
1590 | if (fTracker[iDet]->PropagateBack(esd) != 0) { |
1591 | AliError(Form("%s backward propagation failed", fgkDetectorName[iDet])); |
49dfd67a |
1592 | // return kFALSE; |
b8cd5251 |
1593 | } |
1594 | if (fCheckPointLevel > 1) { |
1595 | WriteESD(esd, Form("%s.back", fgkDetectorName[iDet])); |
1596 | } |
24f7a148 |
1597 | |
b8cd5251 |
1598 | // unload clusters |
1599 | if (iDet > 2) { // all except ITS, TPC, TRD |
1600 | fTracker[iDet]->UnloadClusters(); |
7b61cd9c |
1601 | fLoader[iDet]->UnloadRecPoints(); |
b8cd5251 |
1602 | } |
8f37df88 |
1603 | // updated PID in TPC needed by the ITS tracker -MI |
1604 | if (iDet == 1) { |
8f37df88 |
1605 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); |
1606 | AliESDpid::MakePID(esd); |
1607 | } |
6efecea1 |
1608 | AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr); |
b8cd5251 |
1609 | } |
283f39c6 |
1610 | //stop filling residuals for the "outer" detectors |
1611 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE); |
596a855f |
1612 | |
98937d93 |
1613 | // write space-points to the ESD in case alignment data output |
1614 | // is switched on |
1615 | if (fWriteAlignmentData) |
1616 | WriteAlignmentData(esd); |
1617 | |
b8cd5251 |
1618 | // pass 3: TRD + TPC + ITS refit inwards |
aa3c69a9 |
1619 | |
b8cd5251 |
1620 | for (Int_t iDet = 2; iDet >= 0; iDet--) { |
1621 | if (!fTracker[iDet]) continue; |
1622 | AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet])); |
596a855f |
1623 | |
b8cd5251 |
1624 | // run tracking |
283f39c6 |
1625 | if (iDet<2) // start filling residuals for TPC and ITS |
1626 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE); |
1627 | |
b8cd5251 |
1628 | if (fTracker[iDet]->RefitInward(esd) != 0) { |
1629 | AliError(Form("%s inward refit failed", fgkDetectorName[iDet])); |
49dfd67a |
1630 | // return kFALSE; |
b8cd5251 |
1631 | } |
db2368d0 |
1632 | // run postprocessing |
1633 | if (fTracker[iDet]->PostProcess(esd) != 0) { |
1634 | AliError(Form("%s postprocessing failed", fgkDetectorName[iDet])); |
1635 | // return kFALSE; |
1636 | } |
b8cd5251 |
1637 | if (fCheckPointLevel > 1) { |
1638 | WriteESD(esd, Form("%s.refit", fgkDetectorName[iDet])); |
1639 | } |
6efecea1 |
1640 | AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr); |
b8cd5251 |
1641 | // unload clusters |
1642 | fTracker[iDet]->UnloadClusters(); |
6efecea1 |
1643 | AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr); |
b8cd5251 |
1644 | fLoader[iDet]->UnloadRecPoints(); |
6efecea1 |
1645 | AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr); |
b8cd5251 |
1646 | } |
283f39c6 |
1647 | // stop filling residuals for TPC and ITS |
3b378a42 |
1648 | if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE); |
854c6476 |
1649 | |
0f88822a |
1650 | eventNr++; |
596a855f |
1651 | return kTRUE; |
1652 | } |
1653 | |
d64bd07d |
1654 | //_____________________________________________________________________________ |
1655 | Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){ |
1656 | // |
1657 | // Remove the data which are not needed for the physics analysis. |
1658 | // |
1659 | |
d64bd07d |
1660 | Int_t nTracks=esd->GetNumberOfTracks(); |
18571674 |
1661 | Int_t nV0s=esd->GetNumberOfV0s(); |
cf37fd88 |
1662 | AliInfo |
1663 | (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s)); |
d64bd07d |
1664 | |
18571674 |
1665 | Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax}; |
7f68891d |
1666 | Bool_t rc=esd->Clean(cleanPars); |
d64bd07d |
1667 | |
7f68891d |
1668 | nTracks=esd->GetNumberOfTracks(); |
18571674 |
1669 | nV0s=esd->GetNumberOfV0s(); |
cf37fd88 |
1670 | AliInfo |
ae5d5566 |
1671 | (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s)); |
d64bd07d |
1672 | |
7f68891d |
1673 | return rc; |
d64bd07d |
1674 | } |
1675 | |
596a855f |
1676 | //_____________________________________________________________________________ |
af885e0f |
1677 | Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors) |
596a855f |
1678 | { |
1679 | // fill the event summary data |
1680 | |
87932dab |
1681 | AliCodeTimerAuto("") |
0f88822a |
1682 | static Int_t eventNr=0; |
596a855f |
1683 | TString detStr = detectors; |
abe0c04e |
1684 | |
b8cd5251 |
1685 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
abe0c04e |
1686 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; |
b8cd5251 |
1687 | AliReconstructor* reconstructor = GetReconstructor(iDet); |
1688 | if (!reconstructor) continue; |
b8cd5251 |
1689 | if (!ReadESD(esd, fgkDetectorName[iDet])) { |
1690 | AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet])); |
b26c3770 |
1691 | TTree* clustersTree = NULL; |
d76c31f4 |
1692 | if (fLoader[iDet]) { |
b26c3770 |
1693 | fLoader[iDet]->LoadRecPoints("read"); |
1694 | clustersTree = fLoader[iDet]->TreeR(); |
1695 | if (!clustersTree) { |
1696 | AliError(Form("Can't get the %s clusters tree", |
1697 | fgkDetectorName[iDet])); |
1698 | if (fStopOnError) return kFALSE; |
1699 | } |
1700 | } |
1701 | if (fRawReader && !reconstructor->HasDigitConversion()) { |
1702 | reconstructor->FillESD(fRawReader, clustersTree, esd); |
1703 | } else { |
1704 | TTree* digitsTree = NULL; |
1705 | if (fLoader[iDet]) { |
1706 | fLoader[iDet]->LoadDigits("read"); |
1707 | digitsTree = fLoader[iDet]->TreeD(); |
1708 | if (!digitsTree) { |
1709 | AliError(Form("Can't get the %s digits tree", |
1710 | fgkDetectorName[iDet])); |
1711 | if (fStopOnError) return kFALSE; |
1712 | } |
1713 | } |
1714 | reconstructor->FillESD(digitsTree, clustersTree, esd); |
1715 | if (fLoader[iDet]) fLoader[iDet]->UnloadDigits(); |
1716 | } |
d76c31f4 |
1717 | if (fLoader[iDet]) { |
b26c3770 |
1718 | fLoader[iDet]->UnloadRecPoints(); |
1719 | } |
1720 | |
b8cd5251 |
1721 | if (fCheckPointLevel > 2) WriteESD(esd, fgkDetectorName[iDet]); |
596a855f |
1722 | } |
1723 | } |
1724 | |
1725 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { |
815c2b38 |
1726 | AliError(Form("the following detectors were not found: %s", |
1727 | detStr.Data())); |
596a855f |
1728 | if (fStopOnError) return kFALSE; |
1729 | } |
6efecea1 |
1730 | AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr); |
0f88822a |
1731 | eventNr++; |
596a855f |
1732 | return kTRUE; |
1733 | } |
1734 | |
b647652d |
1735 | //_____________________________________________________________________________ |
af885e0f |
1736 | Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd) |
b647652d |
1737 | { |
1738 | // Reads the trigger decision which is |
1739 | // stored in Trigger.root file and fills |
1740 | // the corresponding esd entries |
1741 | |
87932dab |
1742 | AliCodeTimerAuto("") |
1743 | |
b647652d |
1744 | AliInfo("Filling trigger information into the ESD"); |
1745 | |
b024fd7f |
1746 | AliCentralTrigger *aCTP = NULL; |
1747 | |
b647652d |
1748 | if (fRawReader) { |
1749 | AliCTPRawStream input(fRawReader); |
1750 | if (!input.Next()) { |
1751 | AliError("No valid CTP (trigger) DDL raw data is found ! The trigger information is not stored in the ESD !"); |
1752 | return kFALSE; |
1753 | } |
1754 | esd->SetTriggerMask(input.GetClassMask()); |
1755 | esd->SetTriggerCluster(input.GetClusterMask()); |
b024fd7f |
1756 | |
1757 | aCTP = new AliCentralTrigger(); |
1758 | TString configstr(""); |
1759 | if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB |
1760 | AliError("No trigger configuration found in OCDB! The trigger classes information will no be stored in ESD!"); |
1761 | return kFALSE; |
1762 | } |
b647652d |
1763 | } |
1764 | else { |
1765 | AliRunLoader *runloader = AliRunLoader::GetRunLoader(); |
1766 | if (runloader) { |
1767 | if (!runloader->LoadTrigger()) { |
1ea86aa2 |
1768 | aCTP = runloader->GetTrigger(); |
b647652d |
1769 | esd->SetTriggerMask(aCTP->GetClassMask()); |
1770 | esd->SetTriggerCluster(aCTP->GetClusterMask()); |
1771 | } |
1772 | else { |
1773 | AliWarning("No trigger can be loaded! The trigger information is not stored in the ESD !"); |
1774 | return kFALSE; |
1775 | } |
1776 | } |
1777 | else { |
1778 | AliError("No run loader is available! The trigger information is not stored in the ESD !"); |
1779 | return kFALSE; |
1780 | } |
1781 | } |
1782 | |
b024fd7f |
1783 | // Now fill the trigger class names into AliESDRun object |
1784 | AliTriggerConfiguration *config = aCTP->GetConfiguration(); |
1785 | if (!config) { |
1786 | AliError("No trigger configuration has been found! The trigger classes information will no be stored in ESD!"); |
1787 | return kFALSE; |
1788 | } |
1789 | |
1790 | const TObjArray& classesArray = config->GetClasses(); |
1791 | Int_t nclasses = classesArray.GetEntriesFast(); |
1792 | for( Int_t j=0; j<nclasses; j++ ) { |
1793 | AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At( j ); |
1794 | Int_t trindex = (Int_t)TMath::Log2(trclass->GetMask()); |
1795 | esd->SetTriggerClass(trclass->GetName(),trindex); |
1796 | } |
1797 | |
b647652d |
1798 | return kTRUE; |
1799 | } |
596a855f |
1800 | |
001397cd |
1801 | |
1802 | |
1803 | |
1804 | |
1805 | //_____________________________________________________________________________ |
af885e0f |
1806 | Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd) |
001397cd |
1807 | { |
1808 | // |
1809 | // Filling information from RawReader Header |
1810 | // |
1811 | |
1812 | AliInfo("Filling information from RawReader Header"); |
31fd97b2 |
1813 | esd->SetBunchCrossNumber(0); |
1814 | esd->SetOrbitNumber(0); |
9bcc1e45 |
1815 | esd->SetPeriodNumber(0); |
001397cd |
1816 | esd->SetTimeStamp(0); |
1817 | esd->SetEventType(0); |
1818 | const AliRawEventHeaderBase * eventHeader = fRawReader->GetEventHeader(); |
1819 | if (eventHeader){ |
9bcc1e45 |
1820 | |
1821 | const UInt_t *id = eventHeader->GetP("Id"); |
1822 | esd->SetBunchCrossNumber((id)[1]&0x00000fff); |
1823 | esd->SetOrbitNumber((((id)[0]<<20)&0xf00000)|(((id)[1]>>12)&0xfffff)); |
1824 | esd->SetPeriodNumber(((id)[0]>>4)&0x0fffffff); |
1825 | |
001397cd |
1826 | esd->SetTimeStamp((eventHeader->Get("Timestamp"))); |
31fd97b2 |
1827 | esd->SetEventType((eventHeader->Get("Type"))); |
001397cd |
1828 | } |
1829 | |
1830 | return kTRUE; |
1831 | } |
1832 | |
1833 | |
596a855f |
1834 | //_____________________________________________________________________________ |
1835 | Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const |
1836 | { |
1837 | // check whether detName is contained in detectors |
1838 | // if yes, it is removed from detectors |
1839 | |
1840 | // check if all detectors are selected |
1841 | if ((detectors.CompareTo("ALL") == 0) || |
1842 | detectors.BeginsWith("ALL ") || |
1843 | detectors.EndsWith(" ALL") || |
1844 | detectors.Contains(" ALL ")) { |
1845 | detectors = "ALL"; |
1846 | return kTRUE; |
1847 | } |
1848 | |
1849 | // search for the given detector |
1850 | Bool_t result = kFALSE; |
1851 | if ((detectors.CompareTo(detName) == 0) || |
1852 | detectors.BeginsWith(detName+" ") || |
1853 | detectors.EndsWith(" "+detName) || |
1854 | detectors.Contains(" "+detName+" ")) { |
1855 | detectors.ReplaceAll(detName, ""); |
1856 | result = kTRUE; |
1857 | } |
1858 | |
1859 | // clean up the detectors string |
1860 | while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " "); |
1861 | while (detectors.BeginsWith(" ")) detectors.Remove(0, 1); |
1862 | while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1); |
1863 | |
1864 | return result; |
1865 | } |
e583c30d |
1866 | |
f08fc9f5 |
1867 | //_____________________________________________________________________________ |
1868 | Bool_t AliReconstruction::InitRunLoader() |
1869 | { |
1870 | // get or create the run loader |
1871 | |
1872 | if (gAlice) delete gAlice; |
1873 | gAlice = NULL; |
1874 | |
b26c3770 |
1875 | if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists |
1876 | // load all base libraries to get the loader classes |
1877 | TString libs = gSystem->GetLibraries(); |
1878 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1879 | TString detName = fgkDetectorName[iDet]; |
1880 | if (detName == "HLT") continue; |
1881 | if (libs.Contains("lib" + detName + "base.so")) continue; |
1882 | gSystem->Load("lib" + detName + "base.so"); |
1883 | } |
f08fc9f5 |
1884 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); |
1885 | if (!fRunLoader) { |
1886 | AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); |
1887 | CleanUp(); |
1888 | return kFALSE; |
1889 | } |
b26c3770 |
1890 | fRunLoader->CdGAFile(); |
1891 | if (gFile->GetKey(AliRunLoader::GetGAliceName())) { |
1892 | if (fRunLoader->LoadgAlice() == 0) { |
1893 | gAlice = fRunLoader->GetAliRun(); |
c84a5e9e |
1894 | AliTracker::SetFieldMap(gAlice->Field(),fUniformField); |
b26c3770 |
1895 | } |
f08fc9f5 |
1896 | } |
1897 | if (!gAlice && !fRawReader) { |
1898 | AliError(Form("no gAlice object found in file %s", |
1899 | fGAliceFileName.Data())); |
1900 | CleanUp(); |
1901 | return kFALSE; |
1902 | } |
1903 | |
6cae184e |
1904 | //PH This is a temporary fix to give access to the kinematics |
1905 | //PH that is needed for the labels of ITS clusters |
f2ee4290 |
1906 | fRunLoader->LoadHeader(); |
6cae184e |
1907 | fRunLoader->LoadKinematics(); |
1908 | |
f08fc9f5 |
1909 | } else { // galice.root does not exist |
1910 | if (!fRawReader) { |
1911 | AliError(Form("the file %s does not exist", fGAliceFileName.Data())); |
1912 | CleanUp(); |
1913 | return kFALSE; |
1914 | } |
1915 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(), |
1916 | AliConfig::GetDefaultEventFolderName(), |
1917 | "recreate"); |
1918 | if (!fRunLoader) { |
1919 | AliError(Form("could not create run loader in file %s", |
1920 | fGAliceFileName.Data())); |
1921 | CleanUp(); |
1922 | return kFALSE; |
1923 | } |
1924 | fRunLoader->MakeTree("E"); |
1925 | Int_t iEvent = 0; |
1926 | while (fRawReader->NextEvent()) { |
1927 | fRunLoader->SetEventNumber(iEvent); |
1928 | fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(), |
1929 | iEvent, iEvent); |
1930 | fRunLoader->MakeTree("H"); |
1931 | fRunLoader->TreeE()->Fill(); |
1932 | iEvent++; |
1933 | } |
1934 | fRawReader->RewindEvents(); |
973388c2 |
1935 | if (fNumberOfEventsPerFile > 0) |
1936 | fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile); |
1937 | else |
1938 | fRunLoader->SetNumberOfEventsPerFile(iEvent); |
f08fc9f5 |
1939 | fRunLoader->WriteHeader("OVERWRITE"); |
1940 | fRunLoader->CdGAFile(); |
1941 | fRunLoader->Write(0, TObject::kOverwrite); |
1942 | // AliTracker::SetFieldMap(???); |
1943 | } |
1944 | |
1945 | return kTRUE; |
1946 | } |
1947 | |
c757bafd |
1948 | //_____________________________________________________________________________ |
b8cd5251 |
1949 | AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet) |
c757bafd |
1950 | { |
f08fc9f5 |
1951 | // get the reconstructor object and the loader for a detector |
c757bafd |
1952 | |
b8cd5251 |
1953 | if (fReconstructor[iDet]) return fReconstructor[iDet]; |
1954 | |
1955 | // load the reconstructor object |
1956 | TPluginManager* pluginManager = gROOT->GetPluginManager(); |
1957 | TString detName = fgkDetectorName[iDet]; |
1958 | TString recName = "Ali" + detName + "Reconstructor"; |
f08fc9f5 |
1959 | if (gAlice && !gAlice->GetDetector(detName) && (detName != "HLT")) return NULL; |
b8cd5251 |
1960 | |
b8cd5251 |
1961 | AliReconstructor* reconstructor = NULL; |
1962 | // first check if a plugin is defined for the reconstructor |
1963 | TPluginHandler* pluginHandler = |
1964 | pluginManager->FindHandler("AliReconstructor", detName); |
f08fc9f5 |
1965 | // if not, add a plugin for it |
1966 | if (!pluginHandler) { |
b8cd5251 |
1967 | AliDebug(1, Form("defining plugin for %s", recName.Data())); |
b26c3770 |
1968 | TString libs = gSystem->GetLibraries(); |
1969 | if (libs.Contains("lib" + detName + "base.so") || |
1970 | (gSystem->Load("lib" + detName + "base.so") >= 0)) { |
b8cd5251 |
1971 | pluginManager->AddHandler("AliReconstructor", detName, |
1972 | recName, detName + "rec", recName + "()"); |
1973 | } else { |
1974 | pluginManager->AddHandler("AliReconstructor", detName, |
1975 | recName, detName, recName + "()"); |
c757bafd |
1976 | } |
b8cd5251 |
1977 | pluginHandler = pluginManager->FindHandler("AliReconstructor", detName); |
1978 | } |
1979 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { |
1980 | reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0); |
c757bafd |
1981 | } |
b8cd5251 |
1982 | if (reconstructor) { |
1983 | TObject* obj = fOptions.FindObject(detName.Data()); |
1984 | if (obj) reconstructor->SetOption(obj->GetTitle()); |
d76c31f4 |
1985 | reconstructor->Init(); |
b8cd5251 |
1986 | fReconstructor[iDet] = reconstructor; |
1987 | } |
1988 | |
f08fc9f5 |
1989 | // get or create the loader |
1990 | if (detName != "HLT") { |
1991 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); |
1992 | if (!fLoader[iDet]) { |
1993 | AliConfig::Instance() |
1994 | ->CreateDetectorFolders(fRunLoader->GetEventFolder(), |
1995 | detName, detName); |
1996 | // first check if a plugin is defined for the loader |
bb0901a4 |
1997 | pluginHandler = |
f08fc9f5 |
1998 | pluginManager->FindHandler("AliLoader", detName); |
1999 | // if not, add a plugin for it |
2000 | if (!pluginHandler) { |
2001 | TString loaderName = "Ali" + detName + "Loader"; |
2002 | AliDebug(1, Form("defining plugin for %s", loaderName.Data())); |
2003 | pluginManager->AddHandler("AliLoader", detName, |
2004 | loaderName, detName + "base", |
2005 | loaderName + "(const char*, TFolder*)"); |
2006 | pluginHandler = pluginManager->FindHandler("AliLoader", detName); |
2007 | } |
2008 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { |
2009 | fLoader[iDet] = |
2010 | (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(), |
2011 | fRunLoader->GetEventFolder()); |
2012 | } |
2013 | if (!fLoader[iDet]) { // use default loader |
2014 | fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder()); |
2015 | } |
2016 | if (!fLoader[iDet]) { |
2017 | AliWarning(Form("couldn't get loader for %s", detName.Data())); |
6667b602 |
2018 | if (fStopOnError) return NULL; |
f08fc9f5 |
2019 | } else { |
2020 | fRunLoader->AddLoader(fLoader[iDet]); |
2021 | fRunLoader->CdGAFile(); |
2022 | if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE"); |
2023 | fRunLoader->Write(0, TObject::kOverwrite); |
2024 | } |
2025 | } |
2026 | } |
2027 | |
b8cd5251 |
2028 | return reconstructor; |
c757bafd |
2029 | } |
2030 | |
2257f27e |
2031 | //_____________________________________________________________________________ |
2032 | Bool_t AliReconstruction::CreateVertexer() |
2033 | { |
2034 | // create the vertexer |
2035 | |
b8cd5251 |
2036 | fVertexer = NULL; |
2037 | AliReconstructor* itsReconstructor = GetReconstructor(0); |
59697224 |
2038 | if (itsReconstructor) { |
d76c31f4 |
2039 | fVertexer = itsReconstructor->CreateVertexer(); |
2257f27e |
2040 | } |
b8cd5251 |
2041 | if (!fVertexer) { |
815c2b38 |
2042 | AliWarning("couldn't create a vertexer for ITS"); |
2257f27e |
2043 | if (fStopOnError) return kFALSE; |
2044 | } |
2045 | |
2046 | return kTRUE; |
2047 | } |
2048 | |
24f7a148 |
2049 | //_____________________________________________________________________________ |
b8cd5251 |
2050 | Bool_t AliReconstruction::CreateTrackers(const TString& detectors) |
24f7a148 |
2051 | { |
f08fc9f5 |
2052 | // create the trackers |
24f7a148 |
2053 | |
b8cd5251 |
2054 | TString detStr = detectors; |
2055 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
2056 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; |
2057 | AliReconstructor* reconstructor = GetReconstructor(iDet); |
2058 | if (!reconstructor) continue; |
2059 | TString detName = fgkDetectorName[iDet]; |
1f46a9ae |
2060 | if (detName == "HLT") { |
2061 | fRunHLTTracking = kTRUE; |
2062 | continue; |
2063 | } |
e66fbafb |
2064 | if (detName == "MUON") { |
2065 | fRunMuonTracking = kTRUE; |
2066 | continue; |
2067 | } |
2068 | |
f08fc9f5 |
2069 | |
d76c31f4 |
2070 | fTracker[iDet] = reconstructor->CreateTracker(); |
f08fc9f5 |
2071 | if (!fTracker[iDet] && (iDet < 7)) { |
2072 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); |
8250d5f5 |
2073 | if (fStopOnError) return kFALSE; |
2074 | } |
6efecea1 |
2075 | AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0); |
8250d5f5 |
2076 | } |
2077 | |
24f7a148 |
2078 | return kTRUE; |
2079 | } |
2080 | |
e583c30d |
2081 | //_____________________________________________________________________________ |
b26c3770 |
2082 | void AliReconstruction::CleanUp(TFile* file, TFile* fileOld) |
e583c30d |
2083 | { |
2084 | // delete trackers and the run loader and close and delete the file |
2085 | |
b8cd5251 |
2086 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
2087 | delete fReconstructor[iDet]; |
2088 | fReconstructor[iDet] = NULL; |
2089 | fLoader[iDet] = NULL; |
2090 | delete fTracker[iDet]; |
2091 | fTracker[iDet] = NULL; |
c65c502a |
2092 | // delete fQADataMaker[iDet]; |
2093 | // fQADataMaker[iDet] = NULL; |
b8cd5251 |
2094 | } |
2095 | delete fVertexer; |
2096 | fVertexer = NULL; |
795e4a22 |
2097 | |
2098 | if(!(AliCDBManager::Instance()->GetCacheFlag())) { |
2099 | delete fDiamondProfile; |
2100 | fDiamondProfile = NULL; |
43c9dae1 |
2101 | delete fDiamondProfileTPC; |
2102 | fDiamondProfileTPC = NULL; |
de95c208 |
2103 | delete fGRPList; |
2104 | fGRPList = NULL; |
795e4a22 |
2105 | } |
e583c30d |
2106 | |
444753c6 |
2107 | |
e583c30d |
2108 | delete fRunLoader; |
2109 | fRunLoader = NULL; |
b649205a |
2110 | delete fRawReader; |
2111 | fRawReader = NULL; |
cd0b062e |
2112 | if (fParentRawReader) delete fParentRawReader; |
2113 | fParentRawReader=NULL; |
e583c30d |
2114 | |
2115 | if (file) { |
2116 | file->Close(); |
2117 | delete file; |
2118 | } |
b26c3770 |
2119 | |
2120 | if (fileOld) { |
2121 | fileOld->Close(); |
2122 | delete fileOld; |
2123 | gSystem->Unlink("AliESDs.old.root"); |
2124 | } |
e583c30d |
2125 | } |
24f7a148 |
2126 | |
24f7a148 |
2127 | //_____________________________________________________________________________ |
af885e0f |
2128 | |
2129 | Bool_t AliReconstruction::ReadESD(AliESDEvent*& esd, const char* recStep) const |
24f7a148 |
2130 | { |
2131 | // read the ESD event from a file |
2132 | |
2133 | if (!esd) return kFALSE; |
2134 | char fileName[256]; |
2135 | sprintf(fileName, "ESD_%d.%d_%s.root", |
31fd97b2 |
2136 | esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep); |
24f7a148 |
2137 | if (gSystem->AccessPathName(fileName)) return kFALSE; |
2138 | |
f3a97c86 |
2139 | AliInfo(Form("reading ESD from file %s", fileName)); |
815c2b38 |
2140 | AliDebug(1, Form("reading ESD from file %s", fileName)); |
24f7a148 |
2141 | TFile* file = TFile::Open(fileName); |
2142 | if (!file || !file->IsOpen()) { |
815c2b38 |
2143 | AliError(Form("opening %s failed", fileName)); |
24f7a148 |
2144 | delete file; |
2145 | return kFALSE; |
2146 | } |
2147 | |
2148 | gROOT->cd(); |
2149 | delete esd; |
af885e0f |
2150 | esd = (AliESDEvent*) file->Get("ESD"); |
24f7a148 |
2151 | file->Close(); |
2152 | delete file; |
2153 | return kTRUE; |
af885e0f |
2154 | |
24f7a148 |
2155 | } |
2156 | |
af885e0f |
2157 | |
2158 | |
24f7a148 |
2159 | //_____________________________________________________________________________ |
af885e0f |
2160 | void AliReconstruction::WriteESD(AliESDEvent* esd, const char* recStep) const |
24f7a148 |
2161 | { |
2162 | // write the ESD event to a file |
2163 | |
2164 | if (!esd) return; |
2165 | char fileName[256]; |
2166 | sprintf(fileName, "ESD_%d.%d_%s.root", |
31fd97b2 |
2167 | esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep); |
24f7a148 |
2168 | |
815c2b38 |
2169 | AliDebug(1, Form("writing ESD to file %s", fileName)); |
24f7a148 |
2170 | TFile* file = TFile::Open(fileName, "recreate"); |
2171 | if (!file || !file->IsOpen()) { |
815c2b38 |
2172 | AliError(Form("opening %s failed", fileName)); |
24f7a148 |
2173 | } else { |
2174 | esd->Write("ESD"); |
2175 | file->Close(); |
2176 | } |
2177 | delete file; |
2178 | } |
f3a97c86 |
2179 | |
2180 | |
af885e0f |
2181 | void AliReconstruction::WriteAlignmentData(AliESDEvent* esd) |
98937d93 |
2182 | { |
2183 | // Write space-points which are then used in the alignment procedures |
2184 | // For the moment only ITS, TRD and TPC |
2185 | |
2186 | // Load TOF clusters |
d528ee75 |
2187 | if (fTracker[3]){ |
2188 | fLoader[3]->LoadRecPoints("read"); |
2189 | TTree* tree = fLoader[3]->TreeR(); |
2190 | if (!tree) { |
2191 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[3])); |
2192 | return; |
2193 | } |
2194 | fTracker[3]->LoadClusters(tree); |
98937d93 |
2195 | } |
98937d93 |
2196 | Int_t ntracks = esd->GetNumberOfTracks(); |
2197 | for (Int_t itrack = 0; itrack < ntracks; itrack++) |
2198 | { |
2199 | AliESDtrack *track = esd->GetTrack(itrack); |
2200 | Int_t nsp = 0; |
ef7253ac |
2201 | Int_t idx[200]; |
98937d93 |
2202 | for (Int_t iDet = 3; iDet >= 0; iDet--) |
2203 | nsp += track->GetNcls(iDet); |
2204 | if (nsp) { |
2205 | AliTrackPointArray *sp = new AliTrackPointArray(nsp); |
2206 | track->SetTrackPointArray(sp); |
2207 | Int_t isptrack = 0; |
2208 | for (Int_t iDet = 3; iDet >= 0; iDet--) { |
2209 | AliTracker *tracker = fTracker[iDet]; |
2210 | if (!tracker) continue; |
2211 | Int_t nspdet = track->GetNcls(iDet); |
98937d93 |
2212 | if (nspdet <= 0) continue; |
2213 | track->GetClusters(iDet,idx); |
2214 | AliTrackPoint p; |
2215 | Int_t isp = 0; |
2216 | Int_t isp2 = 0; |
4ed6fb1c |
2217 | while (isp2 < nspdet) { |
48ce48d1 |
2218 | Bool_t isvalid; |
c12b6e44 |
2219 | TString dets = fgkDetectorName[iDet]; |
2220 | if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) || |
2221 | fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") || |
2222 | fUseTrackingErrorsForAlignment.EndsWith(" "+dets) || |
2223 | fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) { |
2224 | isvalid = tracker->GetTrackPointTrackingError(idx[isp2],p,track); |
48ce48d1 |
2225 | } else { |
2226 | isvalid = tracker->GetTrackPoint(idx[isp2],p); |
2227 | } |
2228 | isp2++; |
160db090 |
2229 | const Int_t kNTPCmax = 159; |
2230 | if (iDet==1 && isp2>kNTPCmax) break; // to be fixed |
98937d93 |
2231 | if (!isvalid) continue; |
2232 | sp->AddPoint(isptrack,&p); isptrack++; isp++; |
2233 | } |
98937d93 |
2234 | } |
2235 | } |
2236 | } |
d528ee75 |
2237 | if (fTracker[3]){ |
2238 | fTracker[3]->UnloadClusters(); |
2239 | fLoader[3]->UnloadRecPoints(); |
2240 | } |
98937d93 |
2241 | } |
2e3550da |
2242 | |
2243 | //_____________________________________________________________________________ |
af885e0f |
2244 | void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd) |
2e3550da |
2245 | { |
2246 | // The method reads the raw-data error log |
2247 | // accumulated within the rawReader. |
2248 | // It extracts the raw-data errors related to |
2249 | // the current event and stores them into |
2250 | // a TClonesArray inside the esd object. |
2251 | |
2252 | if (!fRawReader) return; |
2253 | |
2254 | for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) { |
2255 | |
2256 | AliRawDataErrorLog *log = fRawReader->GetErrorLog(i); |
2257 | if (!log) continue; |
2258 | if (iEvent != log->GetEventNumber()) continue; |
2259 | |
2260 | esd->AddRawDataErrorLog(log); |
2261 | } |
2262 | |
2263 | } |
46698ae4 |
2264 | |
2265 | TNamed* AliReconstruction::CopyFileToTNamed(TString fPath,TString fName){ |
b545009a |
2266 | // Dump a file content into a char in TNamed |
46698ae4 |
2267 | ifstream in; |
2268 | in.open(fPath.Data(),ios::in | ios::binary|ios::ate); |
2269 | Int_t kBytes = (Int_t)in.tellg(); |
2270 | printf("Size: %d \n",kBytes); |
2271 | TNamed *fn = 0; |
2272 | if(in.good()){ |
2273 | char* memblock = new char [kBytes]; |
2274 | in.seekg (0, ios::beg); |
2275 | in.read (memblock, kBytes); |
2276 | in.close(); |
2277 | TString fData(memblock,kBytes); |
2278 | fn = new TNamed(fName,fData); |
2279 | printf("fData Size: %d \n",fData.Sizeof()); |
2280 | printf("fName Size: %d \n",fName.Sizeof()); |
2281 | printf("fn Size: %d \n",fn->Sizeof()); |
2282 | delete[] memblock; |
2283 | } |
2284 | else{ |
2285 | AliInfo(Form("Could not Open %s\n",fPath.Data())); |
2286 | } |
2287 | |
2288 | return fn; |
2289 | } |
2290 | |
2291 | void AliReconstruction::TNamedToFile(TTree* fTree, TString fName){ |
46698ae4 |
2292 | // This is not really needed in AliReconstruction at the moment |
2293 | // but can serve as a template |
2294 | |
2295 | TList *fList = fTree->GetUserInfo(); |
2296 | TNamed *fn = (TNamed*)fList->FindObject(fName.Data()); |
2297 | printf("fn Size: %d \n",fn->Sizeof()); |
2298 | |
2299 | TString fTmp(fn->GetName()); // to be 100% sure in principle fName also works |
2300 | const char* cdata = fn->GetTitle(); |
2301 | printf("fTmp Size %d\n",fTmp.Sizeof()); |
2302 | |
2303 | int size = fn->Sizeof()-fTmp.Sizeof()-sizeof(UChar_t)-sizeof(Int_t); // see dfinition of TString::SizeOf()... |
2304 | printf("calculated size %d\n",size); |
2305 | ofstream out(fName.Data(),ios::out | ios::binary); |
2306 | out.write(cdata,size); |
2307 | out.close(); |
2308 | |
2309 | } |
6efecea1 |
2310 | |
7e963665 |
2311 | //_____________________________________________________________________________ |
04236e67 |
2312 | AliQADataMakerRec * AliReconstruction::GetQADataMaker(Int_t iDet) |
7e963665 |
2313 | { |
2314 | // get the quality assurance data maker object and the loader for a detector |
6efecea1 |
2315 | |
7e963665 |
2316 | if (fQADataMaker[iDet]) |
2317 | return fQADataMaker[iDet]; |
2318 | |
04236e67 |
2319 | AliQADataMakerRec * qadm = NULL; |
2320 | if (iDet == fgkNDetectors) { //Global QA |
2321 | qadm = new AliGlobalQADataMaker(); |
aa3c69a9 |
2322 | fQADataMaker[iDet] = qadm; |
2323 | return qadm; |
2324 | } |
2325 | |
7e963665 |
2326 | // load the QA data maker object |
2327 | TPluginManager* pluginManager = gROOT->GetPluginManager(); |
2328 | TString detName = fgkDetectorName[iDet]; |
04236e67 |
2329 | TString qadmName = "Ali" + detName + "QADataMakerRec"; |
7e963665 |
2330 | if (gAlice && !gAlice->GetDetector(detName) && (detName != "HLT")) |
2331 | return NULL; |
2332 | |
7e963665 |
2333 | // first check if a plugin is defined for the quality assurance data maker |
04236e67 |
2334 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMakerRec", detName); |
7e963665 |
2335 | // if not, add a plugin for it |
2336 | if (!pluginHandler) { |
2337 | AliDebug(1, Form("defining plugin for %s", qadmName.Data())); |
2338 | TString libs = gSystem->GetLibraries(); |
2339 | if (libs.Contains("lib" + detName + "base.so") || |
2340 | (gSystem->Load("lib" + detName + "base.so") >= 0)) { |
04236e67 |
2341 | pluginManager->AddHandler("AliQADataMakerRec", detName, |
7e963665 |
2342 | qadmName, detName + "qadm", qadmName + "()"); |
2343 | } else { |
04236e67 |
2344 | pluginManager->AddHandler("AliQADataMakerRec", detName, |
7e963665 |
2345 | qadmName, detName, qadmName + "()"); |
2346 | } |
04236e67 |
2347 | pluginHandler = pluginManager->FindHandler("AliQADataMakerRec", detName); |
7e963665 |
2348 | } |
2349 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { |
04236e67 |
2350 | qadm = (AliQADataMakerRec *) pluginHandler->ExecPlugin(0); |
7e963665 |
2351 | } |
aa3c69a9 |
2352 | |
2353 | fQADataMaker[iDet] = qadm; |
7e963665 |
2354 | |
2355 | return qadm; |
2356 | } |
46698ae4 |
2357 | |
a5fa6165 |
2358 | //_____________________________________________________________________________ |
7e963665 |
2359 | Bool_t AliReconstruction::RunQA(const char* detectors, AliESDEvent *& esd) |
2360 | { |
2361 | // run the Quality Assurance data producer |
2362 | |
2363 | AliCodeTimerAuto("") |
2364 | TString detStr = detectors; |
2365 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
2366 | if (!IsSelected(fgkDetectorName[iDet], detStr)) |
2367 | continue; |
04236e67 |
2368 | AliQADataMakerRec * qadm = GetQADataMaker(iDet); |
7e963665 |
2369 | if (!qadm) |
2370 | continue; |
2371 | AliCodeTimerStart(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); |
2372 | AliInfo(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); |
2373 | |
2374 | qadm->Exec(AliQA::kESDS, esd) ; |
2375 | qadm->Increment() ; |
2376 | |
2377 | AliCodeTimerStop(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); |
2378 | } |
2379 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { |
2380 | AliError(Form("the following detectors were not found: %s", |
2381 | detStr.Data())); |
2382 | if (fStopOnError) |
2383 | return kFALSE; |
2384 | } |
2385 | |
2386 | return kTRUE; |
2387 | |
2388 | } |
8661738e |
2389 | |
2390 | //_____________________________________________________________________________ |
2391 | void AliReconstruction::CheckQA() |
2392 | { |
2393 | // check the QA of SIM for this run and remove the detectors |
2394 | // with status Fatal |
2395 | |
abe0c04e |
2396 | TString newRunLocalReconstruction ; |
2397 | TString newRunTracking ; |
2398 | TString newFillESD ; |
2399 | |
8661738e |
2400 | for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) { |
2401 | TString detName(AliQA::GetDetName(iDet)) ; |
96d67a8d |
2402 | AliQA * qa = AliQA::Instance(AliQA::DETECTORINDEX_t(iDet)) ; |
2403 | if ( qa->IsSet(AliQA::DETECTORINDEX_t(iDet), AliQA::kSIM, AliQA::kFATAL)) { |
8661738e |
2404 | AliInfo(Form("QA status for %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed", detName.Data())) ; |
abe0c04e |
2405 | } else { |
2406 | if ( fRunLocalReconstruction.Contains(AliQA::GetDetName(iDet)) || |
2407 | fRunLocalReconstruction.Contains("ALL") ) { |
2408 | newRunLocalReconstruction += detName ; |
2409 | newRunLocalReconstruction += " " ; |
2410 | } |
2411 | if ( fRunTracking.Contains(AliQA::GetDetName(iDet)) || |
2412 | fRunTracking.Contains("ALL") ) { |
2413 | newRunTracking += detName ; |
2414 | newRunTracking += " " ; |
2415 | } |
2416 | if ( fFillESD.Contains(AliQA::GetDetName(iDet)) || |
2417 | fFillESD.Contains("ALL") ) { |
2418 | newFillESD += detName ; |
2419 | newFillESD += " " ; |
8661738e |
2420 | } |
2421 | } |
2422 | } |
abe0c04e |
2423 | fRunLocalReconstruction = newRunLocalReconstruction ; |
2424 | fRunTracking = newRunTracking ; |
2425 | fFillESD = newFillESD ; |
a5fa6165 |
2426 | } |
5b188f2f |
2427 | |
2428 | //_____________________________________________________________________________ |
2429 | Int_t AliReconstruction::GetDetIndex(const char* detector) |
2430 | { |
2431 | // return the detector index corresponding to detector |
2432 | Int_t index = -1 ; |
2433 | for (index = 0; index < fgkNDetectors ; index++) { |
2434 | if ( strcmp(detector, fgkDetectorName[index]) == 0 ) |
2435 | break ; |
2436 | } |
2437 | return index ; |
2438 | } |
7167ae53 |
2439 | //_____________________________________________________________________________ |
2440 | Bool_t AliReconstruction::FinishPlaneEff() { |
2441 | // |
2442 | // Here execute all the necessary operationis, at the end of the tracking phase, |
2443 | // in case that evaluation of PlaneEfficiencies was required for some detector. |
2444 | // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated. |
2445 | // |
2446 | // This Preliminary version works only FOR ITS !!!!! |
2447 | // other detectors (TOF,TRD, etc. have to develop their specific codes) |
2448 | // |
2449 | // Input: none |
2450 | // Return: kTRUE if all operations have been done properly, kFALSE otherwise |
2451 | // |
2452 | Bool_t ret=kFALSE; |
2453 | //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
2454 | for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS |
2455 | //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; |
5fbd4fd6 |
2456 | if(fTracker[iDet]) { |
2457 | AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff(); |
2458 | ret=planeeff->WriteIntoCDB(); |
2459 | if(planeeff->GetCreateHistos()) { |
2460 | TString name="PlaneEffHisto"; |
2461 | name+=fgkDetectorName[iDet]; |
2462 | name+=".root"; |
2463 | ret*=planeeff->WriteHistosToFile(name,"RECREATE"); |
2464 | } |
2465 | } |
7167ae53 |
2466 | } |
2467 | return ret; |
2468 | } |
2469 | //_____________________________________________________________________________ |
2470 | Bool_t AliReconstruction::InitPlaneEff() { |
2471 | // |
2472 | // Here execute all the necessary operations, before of the tracking phase, |
2473 | // for the evaluation of PlaneEfficiencies, in case required for some detectors. |
2474 | // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency |
2475 | // which should be updated/recalculated. |
2476 | // |
2477 | // This Preliminary version will work only FOR ITS !!!!! |
2478 | // other detectors (TOF,TRD, etc. have to develop their specific codes) |
2479 | // |
2480 | // Input: none |
2481 | // Return: kTRUE if all operations have been done properly, kFALSE otherwise |
2482 | // |
2483 | AliWarning(Form("Implementation of this method not yet done !! Method return kTRUE")); |
2484 | return kTRUE; |
7520312d |
2485 | } |