]>
Commit | Line | Data |
---|---|---|
596a855f | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // class for running the reconstruction // | |
21 | // // | |
22 | // Clusters and tracks are created for all detectors and all events by // | |
23 | // typing: // | |
24 | // // | |
25 | // AliReconstruction rec; // | |
26 | // rec.Run(); // | |
27 | // // | |
28 | // The Run method returns kTRUE in case of successful execution. // | |
c71de921 | 29 | // // |
30 | // If the input to the reconstruction are not simulated digits but raw data, // | |
31 | // this can be specified by an argument of the Run method or by the method // | |
32 | // // | |
33 | // rec.SetInput("..."); // | |
34 | // // | |
35 | // The input formats and the corresponding argument are: // | |
36 | // - DDL raw data files: directory name, ends with "/" // | |
37 | // - raw data root file: root file name, extension ".root" // | |
38 | // - raw data DATE file: DATE file name, any other non-empty string // | |
39 | // - MC root files : empty string, default // | |
40 | // // | |
b26c3770 | 41 | // By default all events are reconstructed. The reconstruction can be // |
42 | // limited to a range of events by giving the index of the first and the // | |
43 | // last event as an argument to the Run method or by calling // | |
44 | // // | |
45 | // rec.SetEventRange(..., ...); // | |
46 | // // | |
47 | // The index -1 (default) can be used for the last event to indicate no // | |
48 | // upper limit of the event range. // | |
49 | // // | |
973388c2 | 50 | // In case of raw-data reconstruction the user can modify the default // |
51 | // number of events per digits/clusters/tracks file. In case the option // | |
52 | // is not used the number is set 1. In case the user provides 0, than // | |
53 | // the number of events is equal to the number of events inside the // | |
54 | // raw-data file (i.e. one digits/clusters/tracks file): // | |
55 | // // | |
56 | // rec.SetNumberOfEventsPerFile(...); // | |
57 | // // | |
58 | // // | |
596a855f | 59 | // The name of the galice file can be changed from the default // |
e583c30d | 60 | // "galice.root" by passing it as argument to the AliReconstruction // |
61 | // constructor or by // | |
596a855f | 62 | // // |
63 | // rec.SetGAliceFile("..."); // | |
64 | // // | |
59697224 | 65 | // The local reconstruction can be switched on or off for individual // |
66 | // detectors by // | |
596a855f | 67 | // // |
59697224 | 68 | // rec.SetRunLocalReconstruction("..."); // |
596a855f | 69 | // // |
70 | // The argument is a (case sensitive) string with the names of the // | |
71 | // detectors separated by a space. The special string "ALL" selects all // | |
72 | // available detectors. This is the default. // | |
73 | // // | |
c71de921 | 74 | // The reconstruction of the primary vertex position can be switched off by // |
75 | // // | |
76 | // rec.SetRunVertexFinder(kFALSE); // | |
77 | // // | |
b8cd5251 | 78 | // The tracking and the creation of ESD tracks can be switched on for // |
79 | // selected detectors by // | |
596a855f | 80 | // // |
b8cd5251 | 81 | // rec.SetRunTracking("..."); // |
596a855f | 82 | // // |
c84a5e9e | 83 | // Uniform/nonuniform field tracking switches (default: uniform field) // |
84 | // // | |
1d99986f | 85 | // rec.SetUniformFieldTracking(); ( rec.SetUniformFieldTracking(kFALSE); ) // |
c84a5e9e | 86 | // // |
596a855f | 87 | // The filling of additional ESD information can be steered by // |
88 | // // | |
89 | // rec.SetFillESD("..."); // | |
90 | // // | |
b8cd5251 | 91 | // Again, for both methods the string specifies the list of detectors. // |
92 | // The default is "ALL". // | |
93 | // // | |
94 | // The call of the shortcut method // | |
95 | // // | |
96 | // rec.SetRunReconstruction("..."); // | |
97 | // // | |
98 | // is equivalent to calling SetRunLocalReconstruction, SetRunTracking and // | |
99 | // SetFillESD with the same detector selecting string as argument. // | |
596a855f | 100 | // // |
c71de921 | 101 | // The reconstruction requires digits or raw data as input. For the creation // |
102 | // of digits and raw data have a look at the class AliSimulation. // | |
596a855f | 103 | // // |
24f7a148 | 104 | // For debug purposes the method SetCheckPointLevel can be used. If the // |
105 | // argument is greater than 0, files with ESD events will be written after // | |
106 | // selected steps of the reconstruction for each event: // | |
107 | // level 1: after tracking and after filling of ESD (final) // | |
108 | // level 2: in addition after each tracking step // | |
109 | // level 3: in addition after the filling of ESD for each detector // | |
110 | // If a final check point file exists for an event, this event will be // | |
111 | // skipped in the reconstruction. The tracking and the filling of ESD for // | |
112 | // a detector will be skipped as well, if the corresponding check point // | |
113 | // file exists. The ESD event will then be loaded from the file instead. // | |
114 | // // | |
596a855f | 115 | /////////////////////////////////////////////////////////////////////////////// |
116 | ||
024a7e64 | 117 | #include <TArrayF.h> |
118 | #include <TFile.h> | |
119 | #include <TSystem.h> | |
120 | #include <TROOT.h> | |
121 | #include <TPluginManager.h> | |
fd46e2d2 | 122 | #include <TStopwatch.h> |
3103d196 | 123 | #include <TGeoManager.h> |
2bdb9d38 | 124 | #include <TLorentzVector.h> |
596a855f | 125 | |
126 | #include "AliReconstruction.h" | |
b8cd5251 | 127 | #include "AliReconstructor.h" |
815c2b38 | 128 | #include "AliLog.h" |
596a855f | 129 | #include "AliRunLoader.h" |
130 | #include "AliRun.h" | |
b649205a | 131 | #include "AliRawReaderFile.h" |
132 | #include "AliRawReaderDate.h" | |
133 | #include "AliRawReaderRoot.h" | |
001397cd | 134 | #include "AliRawEventHeaderBase.h" |
596a855f | 135 | #include "AliESD.h" |
1d99986f | 136 | #include "AliESDfriend.h" |
2257f27e | 137 | #include "AliESDVertex.h" |
32e449be | 138 | #include "AliMultiplicity.h" |
c84a5e9e | 139 | #include "AliTracker.h" |
2257f27e | 140 | #include "AliVertexer.h" |
c5e3e5d1 | 141 | #include "AliVertexerTracks.h" |
5e4ff34d | 142 | #include "AliV0vertexer.h" |
143 | #include "AliCascadeVertexer.h" | |
596a855f | 144 | #include "AliHeader.h" |
145 | #include "AliGenEventHeader.h" | |
b26c3770 | 146 | #include "AliPID.h" |
596a855f | 147 | #include "AliESDpid.h" |
ff8bb5ae | 148 | #include "AliESDtrack.h" |
f3a97c86 | 149 | |
150 | #include "AliRunTag.h" | |
f3a97c86 | 151 | #include "AliDetectorTag.h" |
152 | #include "AliEventTag.h" | |
153 | ||
98937d93 | 154 | #include "AliTrackPointArray.h" |
b0314964 | 155 | #include "AliCDBManager.h" |
6bae477a | 156 | #include "AliCDBEntry.h" |
157 | #include "AliAlignObj.h" | |
f3a97c86 | 158 | |
b647652d | 159 | #include "AliCentralTrigger.h" |
160 | #include "AliCTPRawStream.h" | |
161 | ||
596a855f | 162 | ClassImp(AliReconstruction) |
163 | ||
164 | ||
c757bafd | 165 | //_____________________________________________________________________________ |
b384f8a4 | 166 | const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"}; |
c757bafd | 167 | |
596a855f | 168 | //_____________________________________________________________________________ |
024cf675 | 169 | AliReconstruction::AliReconstruction(const char* gAliceFilename, const char* cdbUri, |
e583c30d | 170 | const char* name, const char* title) : |
171 | TNamed(name, title), | |
172 | ||
c84a5e9e | 173 | fUniformField(kTRUE), |
2257f27e | 174 | fRunVertexFinder(kTRUE), |
1f46a9ae | 175 | fRunHLTTracking(kFALSE), |
e66fbafb | 176 | fRunMuonTracking(kFALSE), |
1d99986f | 177 | fStopOnError(kFALSE), |
178 | fWriteAlignmentData(kFALSE), | |
179 | fWriteESDfriend(kFALSE), | |
a7807689 | 180 | fWriteAOD(kFALSE), |
b647652d | 181 | fFillTriggerESD(kTRUE), |
1d99986f | 182 | |
183 | fRunLocalReconstruction("ALL"), | |
b8cd5251 | 184 | fRunTracking("ALL"), |
e583c30d | 185 | fFillESD("ALL"), |
186 | fGAliceFileName(gAliceFilename), | |
b649205a | 187 | fInput(""), |
35042093 | 188 | fEquipIdMap(""), |
b26c3770 | 189 | fFirstEvent(0), |
190 | fLastEvent(-1), | |
973388c2 | 191 | fNumberOfEventsPerFile(1), |
24f7a148 | 192 | fCheckPointLevel(0), |
b8cd5251 | 193 | fOptions(), |
6bae477a | 194 | fLoadAlignFromCDB(kTRUE), |
195 | fLoadAlignData("ALL"), | |
e583c30d | 196 | |
197 | fRunLoader(NULL), | |
b649205a | 198 | fRawReader(NULL), |
b8cd5251 | 199 | |
98937d93 | 200 | fVertexer(NULL), |
9178838a | 201 | fDiamondProfile(NULL), |
98937d93 | 202 | |
6bae477a | 203 | fAlignObjArray(NULL), |
ec92bee0 | 204 | fCDBUri(cdbUri), |
205 | fSpecCDBUri() | |
596a855f | 206 | { |
207 | // create reconstruction object with default parameters | |
b8cd5251 | 208 | |
209 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
210 | fReconstructor[iDet] = NULL; | |
211 | fLoader[iDet] = NULL; | |
212 | fTracker[iDet] = NULL; | |
213 | } | |
e47c4c2e | 214 | AliPID pid; |
596a855f | 215 | } |
216 | ||
217 | //_____________________________________________________________________________ | |
218 | AliReconstruction::AliReconstruction(const AliReconstruction& rec) : | |
e583c30d | 219 | TNamed(rec), |
220 | ||
c84a5e9e | 221 | fUniformField(rec.fUniformField), |
2257f27e | 222 | fRunVertexFinder(rec.fRunVertexFinder), |
1f46a9ae | 223 | fRunHLTTracking(rec.fRunHLTTracking), |
e66fbafb | 224 | fRunMuonTracking(rec.fRunMuonTracking), |
1d99986f | 225 | fStopOnError(rec.fStopOnError), |
226 | fWriteAlignmentData(rec.fWriteAlignmentData), | |
227 | fWriteESDfriend(rec.fWriteESDfriend), | |
a7807689 | 228 | fWriteAOD(rec.fWriteAOD), |
b647652d | 229 | fFillTriggerESD(rec.fFillTriggerESD), |
1d99986f | 230 | |
231 | fRunLocalReconstruction(rec.fRunLocalReconstruction), | |
e583c30d | 232 | fRunTracking(rec.fRunTracking), |
233 | fFillESD(rec.fFillESD), | |
234 | fGAliceFileName(rec.fGAliceFileName), | |
b649205a | 235 | fInput(rec.fInput), |
35042093 | 236 | fEquipIdMap(rec.fEquipIdMap), |
b26c3770 | 237 | fFirstEvent(rec.fFirstEvent), |
238 | fLastEvent(rec.fLastEvent), | |
973388c2 | 239 | fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile), |
24f7a148 | 240 | fCheckPointLevel(0), |
b8cd5251 | 241 | fOptions(), |
6bae477a | 242 | fLoadAlignFromCDB(rec.fLoadAlignFromCDB), |
243 | fLoadAlignData(rec.fLoadAlignData), | |
e583c30d | 244 | |
245 | fRunLoader(NULL), | |
b649205a | 246 | fRawReader(NULL), |
b8cd5251 | 247 | |
98937d93 | 248 | fVertexer(NULL), |
9178838a | 249 | fDiamondProfile(NULL), |
98937d93 | 250 | |
6bae477a | 251 | fAlignObjArray(rec.fAlignObjArray), |
ec92bee0 | 252 | fCDBUri(rec.fCDBUri), |
253 | fSpecCDBUri() | |
596a855f | 254 | { |
255 | // copy constructor | |
256 | ||
ec92bee0 | 257 | for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) { |
efd2085e | 258 | if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone()); |
259 | } | |
b8cd5251 | 260 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
261 | fReconstructor[iDet] = NULL; | |
262 | fLoader[iDet] = NULL; | |
263 | fTracker[iDet] = NULL; | |
264 | } | |
ec92bee0 | 265 | for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) { |
266 | if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone()); | |
267 | } | |
596a855f | 268 | } |
269 | ||
270 | //_____________________________________________________________________________ | |
271 | AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec) | |
272 | { | |
273 | // assignment operator | |
274 | ||
275 | this->~AliReconstruction(); | |
276 | new(this) AliReconstruction(rec); | |
277 | return *this; | |
278 | } | |
279 | ||
280 | //_____________________________________________________________________________ | |
281 | AliReconstruction::~AliReconstruction() | |
282 | { | |
283 | // clean up | |
284 | ||
e583c30d | 285 | CleanUp(); |
efd2085e | 286 | fOptions.Delete(); |
ec92bee0 | 287 | fSpecCDBUri.Delete(); |
596a855f | 288 | } |
289 | ||
024cf675 | 290 | //_____________________________________________________________________________ |
291 | void AliReconstruction::InitCDBStorage() | |
292 | { | |
293 | // activate a default CDB storage | |
294 | // First check if we have any CDB storage set, because it is used | |
295 | // to retrieve the calibration and alignment constants | |
296 | ||
297 | AliCDBManager* man = AliCDBManager::Instance(); | |
ec92bee0 | 298 | if (man->IsDefaultStorageSet()) |
024cf675 | 299 | { |
300 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
ec92bee0 | 301 | AliWarning("Default CDB storage has been already set !"); |
302 | AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data())); | |
024cf675 | 303 | AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
ec92bee0 | 304 | fCDBUri = ""; |
305 | } | |
306 | else { | |
b8ec52f6 | 307 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
308 | AliDebug(2, Form("Default CDB storage is set to: %s",fCDBUri.Data())); | |
309 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
ec92bee0 | 310 | man->SetDefaultStorage(fCDBUri); |
311 | } | |
312 | ||
313 | // Now activate the detector specific CDB storage locations | |
c3a7b59a | 314 | for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) { |
315 | TObject* obj = fSpecCDBUri[i]; | |
316 | if (!obj) continue; | |
b8ec52f6 | 317 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
318 | AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle())); | |
319 | AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | |
c3a7b59a | 320 | man->SetSpecificStorage(obj->GetName(), obj->GetTitle()); |
ec92bee0 | 321 | } |
727d0766 | 322 | man->Print(); |
024cf675 | 323 | } |
324 | ||
325 | //_____________________________________________________________________________ | |
326 | void AliReconstruction::SetDefaultStorage(const char* uri) { | |
ec92bee0 | 327 | // Store the desired default CDB storage location |
328 | // Activate it later within the Run() method | |
024cf675 | 329 | |
ec92bee0 | 330 | fCDBUri = uri; |
024cf675 | 331 | |
332 | } | |
333 | ||
334 | //_____________________________________________________________________________ | |
c3a7b59a | 335 | void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) { |
ec92bee0 | 336 | // Store a detector-specific CDB storage location |
337 | // Activate it later within the Run() method | |
024cf675 | 338 | |
c3a7b59a | 339 | AliCDBPath aPath(calibType); |
340 | if(!aPath.IsValid()){ | |
341 | // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path | |
342 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
343 | if(!strcmp(calibType, fgkDetectorName[iDet])) { | |
344 | aPath.SetPath(Form("%s/*", calibType)); | |
345 | AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data())); | |
346 | break; | |
347 | } | |
348 | } | |
349 | if(!aPath.IsValid()){ | |
350 | AliError(Form("Not a valid path or detector: %s", calibType)); | |
351 | return; | |
352 | } | |
353 | } | |
354 | ||
355 | // check that calibType refers to a "valid" detector name | |
356 | Bool_t isDetector = kFALSE; | |
357 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
358 | TString detName = fgkDetectorName[iDet]; | |
359 | if(aPath.GetLevel0() == detName) { | |
360 | isDetector = kTRUE; | |
361 | break; | |
362 | } | |
363 | } | |
364 | ||
365 | if(!isDetector) { | |
366 | AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data())); | |
367 | return; | |
368 | } | |
369 | ||
370 | TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data()); | |
ec92bee0 | 371 | if (obj) fSpecCDBUri.Remove(obj); |
c3a7b59a | 372 | fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri)); |
024cf675 | 373 | |
374 | } | |
375 | ||
6bae477a | 376 | //_____________________________________________________________________________ |
377 | Bool_t AliReconstruction::SetRunNumber() | |
378 | { | |
379 | // The method is called in Run() in order | |
380 | // to set a correct run number. | |
381 | // In case of raw data reconstruction the | |
382 | // run number is taken from the raw data header | |
383 | ||
384 | if(AliCDBManager::Instance()->GetRun() < 0) { | |
385 | if (!fRunLoader) { | |
386 | AliError("No run loader is found !"); | |
387 | return kFALSE; | |
388 | } | |
389 | // read run number from gAlice | |
ec92bee0 | 390 | if(fRunLoader->GetAliRun()) |
391 | AliCDBManager::Instance()->SetRun(fRunLoader->GetAliRun()->GetRunNumber()); | |
392 | else { | |
393 | if(fRawReader) { | |
394 | if(fRawReader->NextEvent()) { | |
395 | AliCDBManager::Instance()->SetRun(fRawReader->GetRunNumber()); | |
396 | fRawReader->RewindEvents(); | |
397 | } | |
398 | else { | |
399 | AliError("No raw-data events found !"); | |
400 | return kFALSE; | |
401 | } | |
402 | } | |
403 | else { | |
404 | AliError("Neither gAlice nor RawReader objects are found !"); | |
405 | return kFALSE; | |
406 | } | |
407 | } | |
408 | AliInfo(Form("CDB Run number: %d",AliCDBManager::Instance()->GetRun())); | |
6bae477a | 409 | } |
410 | return kTRUE; | |
411 | } | |
412 | ||
413 | //_____________________________________________________________________________ | |
414 | Bool_t AliReconstruction::ApplyAlignObjsToGeom(TObjArray* alObjArray) | |
415 | { | |
416 | // Read collection of alignment objects (AliAlignObj derived) saved | |
417 | // in the TClonesArray ClArrayName and apply them to the geometry | |
418 | // manager singleton. | |
419 | // | |
420 | alObjArray->Sort(); | |
421 | Int_t nvols = alObjArray->GetEntriesFast(); | |
422 | ||
dc0984f8 | 423 | Bool_t flag = kTRUE; |
424 | ||
6bae477a | 425 | for(Int_t j=0; j<nvols; j++) |
426 | { | |
427 | AliAlignObj* alobj = (AliAlignObj*) alObjArray->UncheckedAt(j); | |
dc0984f8 | 428 | if (alobj->ApplyToGeometry() == kFALSE) flag = kFALSE; |
6bae477a | 429 | } |
430 | ||
431 | if (AliDebugLevelClass() >= 1) { | |
e0625db4 | 432 | gGeoManager->GetTopNode()->CheckOverlaps(20); |
6bae477a | 433 | TObjArray* ovexlist = gGeoManager->GetListOfOverlaps(); |
434 | if(ovexlist->GetEntriesFast()){ | |
435 | AliError("The application of alignment objects to the geometry caused huge overlaps/extrusions!"); | |
436 | } | |
437 | } | |
438 | ||
dc0984f8 | 439 | return flag; |
6bae477a | 440 | |
441 | } | |
442 | ||
443 | //_____________________________________________________________________________ | |
444 | Bool_t AliReconstruction::SetAlignObjArraySingleDet(const char* detName) | |
445 | { | |
446 | // Fills array of single detector's alignable objects from CDB | |
447 | ||
448 | AliDebug(2, Form("Loading alignment data for detector: %s",detName)); | |
449 | ||
450 | AliCDBEntry *entry; | |
451 | ||
452 | AliCDBPath path(detName,"Align","Data"); | |
453 | ||
454 | entry=AliCDBManager::Instance()->Get(path.GetPath()); | |
455 | if(!entry){ | |
456 | AliDebug(2,Form("Couldn't load alignment data for detector %s",detName)); | |
457 | return kFALSE; | |
458 | } | |
459 | entry->SetOwner(1); | |
460 | TClonesArray *alignArray = (TClonesArray*) entry->GetObject(); | |
461 | alignArray->SetOwner(0); | |
462 | AliDebug(2,Form("Found %d alignment objects for %s", | |
463 | alignArray->GetEntries(),detName)); | |
464 | ||
465 | AliAlignObj *alignObj=0; | |
466 | TIter iter(alignArray); | |
467 | ||
468 | // loop over align objects in detector | |
469 | while( ( alignObj=(AliAlignObj *) iter.Next() ) ){ | |
470 | fAlignObjArray->Add(alignObj); | |
471 | } | |
472 | // delete entry --- Don't delete, it is cached! | |
473 | ||
474 | AliDebug(2, Form("fAlignObjArray entries: %d",fAlignObjArray->GetEntries() )); | |
475 | return kTRUE; | |
476 | ||
477 | } | |
478 | ||
479 | //_____________________________________________________________________________ | |
480 | Bool_t AliReconstruction::MisalignGeometry(const TString& detectors) | |
481 | { | |
482 | // Read the alignment objects from CDB. | |
483 | // Each detector is supposed to have the | |
484 | // alignment objects in DET/Align/Data CDB path. | |
485 | // All the detector objects are then collected, | |
486 | // sorted by geometry level (starting from ALIC) and | |
487 | // then applied to the TGeo geometry. | |
488 | // Finally an overlaps check is performed. | |
489 | ||
490 | // Load alignment data from CDB and fill fAlignObjArray | |
491 | if(fLoadAlignFromCDB){ | |
492 | if(!fAlignObjArray) fAlignObjArray = new TObjArray(); | |
493 | ||
494 | //fAlignObjArray->RemoveAll(); | |
495 | fAlignObjArray->Clear(); | |
496 | fAlignObjArray->SetOwner(0); | |
497 | ||
498 | TString detStr = detectors; | |
499 | TString dataNotLoaded=""; | |
500 | TString dataLoaded=""; | |
501 | ||
502 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
503 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
504 | if(!SetAlignObjArraySingleDet(fgkDetectorName[iDet])){ | |
505 | dataNotLoaded += fgkDetectorName[iDet]; | |
506 | dataNotLoaded += " "; | |
507 | } else { | |
508 | dataLoaded += fgkDetectorName[iDet]; | |
509 | dataLoaded += " "; | |
510 | } | |
511 | } // end loop over detectors | |
512 | ||
513 | if ((detStr.CompareTo("ALL") == 0)) detStr = ""; | |
514 | dataNotLoaded += detStr; | |
7250c343 | 515 | if(!dataLoaded.IsNull()) AliInfo(Form("Alignment data loaded for: %s", |
6bae477a | 516 | dataLoaded.Data())); |
7250c343 | 517 | if(!dataNotLoaded.IsNull()) AliInfo(Form("Didn't/couldn't load alignment data for: %s", |
6bae477a | 518 | dataNotLoaded.Data())); |
519 | } // fLoadAlignFromCDB flag | |
520 | ||
521 | // Check if the array with alignment objects was | |
522 | // provided by the user. If yes, apply the objects | |
523 | // to the present TGeo geometry | |
524 | if (fAlignObjArray) { | |
525 | if (gGeoManager && gGeoManager->IsClosed()) { | |
526 | if (ApplyAlignObjsToGeom(fAlignObjArray) == kFALSE) { | |
dc0984f8 | 527 | AliError("The misalignment of one or more volumes failed!" |
528 | "Compare the list of simulated detectors and the list of detector alignment data!"); | |
6bae477a | 529 | return kFALSE; |
530 | } | |
531 | } | |
532 | else { | |
533 | AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!"); | |
534 | return kFALSE; | |
535 | } | |
536 | } | |
537 | ||
8e245d15 | 538 | delete fAlignObjArray; fAlignObjArray=0; |
6bae477a | 539 | return kTRUE; |
540 | } | |
596a855f | 541 | |
542 | //_____________________________________________________________________________ | |
543 | void AliReconstruction::SetGAliceFile(const char* fileName) | |
544 | { | |
545 | // set the name of the galice file | |
546 | ||
547 | fGAliceFileName = fileName; | |
548 | } | |
549 | ||
efd2085e | 550 | //_____________________________________________________________________________ |
551 | void AliReconstruction::SetOption(const char* detector, const char* option) | |
552 | { | |
553 | // set options for the reconstruction of a detector | |
554 | ||
555 | TObject* obj = fOptions.FindObject(detector); | |
556 | if (obj) fOptions.Remove(obj); | |
557 | fOptions.Add(new TNamed(detector, option)); | |
558 | } | |
559 | ||
596a855f | 560 | |
561 | //_____________________________________________________________________________ | |
4a33489c | 562 | Bool_t AliReconstruction::Run(const char* input) |
596a855f | 563 | { |
564 | // run the reconstruction | |
565 | ||
b649205a | 566 | // set the input |
567 | if (!input) input = fInput.Data(); | |
568 | TString fileName(input); | |
569 | if (fileName.EndsWith("/")) { | |
570 | fRawReader = new AliRawReaderFile(fileName); | |
571 | } else if (fileName.EndsWith(".root")) { | |
572 | fRawReader = new AliRawReaderRoot(fileName); | |
573 | } else if (!fileName.IsNull()) { | |
574 | fRawReader = new AliRawReaderDate(fileName); | |
575 | fRawReader->SelectEvents(7); | |
576 | } | |
35042093 | 577 | if (!fEquipIdMap.IsNull() && fRawReader) |
578 | fRawReader->LoadEquipmentIdsMap(fEquipIdMap); | |
579 | ||
b649205a | 580 | |
f08fc9f5 | 581 | // get the run loader |
582 | if (!InitRunLoader()) return kFALSE; | |
596a855f | 583 | |
ec92bee0 | 584 | // Initialize the CDB storage |
585 | InitCDBStorage(); | |
586 | ||
6bae477a | 587 | // Set run number in CDBManager (if it is not already set by the user) |
588 | if (!SetRunNumber()) if (fStopOnError) return kFALSE; | |
589 | ||
590 | // Import ideal TGeo geometry and apply misalignment | |
591 | if (!gGeoManager) { | |
592 | TString geom(gSystem->DirName(fGAliceFileName)); | |
593 | geom += "/geometry.root"; | |
594 | TGeoManager::Import(geom.Data()); | |
595 | if (!gGeoManager) if (fStopOnError) return kFALSE; | |
596 | } | |
8e245d15 | 597 | |
598 | AliCDBManager* man = AliCDBManager::Instance(); | |
6bae477a | 599 | if (!MisalignGeometry(fLoadAlignData)) if (fStopOnError) return kFALSE; |
600 | ||
596a855f | 601 | // local reconstruction |
59697224 | 602 | if (!fRunLocalReconstruction.IsNull()) { |
603 | if (!RunLocalReconstruction(fRunLocalReconstruction)) { | |
e583c30d | 604 | if (fStopOnError) {CleanUp(); return kFALSE;} |
596a855f | 605 | } |
606 | } | |
b26c3770 | 607 | // if (!fRunVertexFinder && fRunTracking.IsNull() && |
608 | // fFillESD.IsNull()) return kTRUE; | |
2257f27e | 609 | |
610 | // get vertexer | |
611 | if (fRunVertexFinder && !CreateVertexer()) { | |
612 | if (fStopOnError) { | |
613 | CleanUp(); | |
614 | return kFALSE; | |
615 | } | |
616 | } | |
596a855f | 617 | |
f08fc9f5 | 618 | // get trackers |
b8cd5251 | 619 | if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) { |
24f7a148 | 620 | if (fStopOnError) { |
621 | CleanUp(); | |
622 | return kFALSE; | |
623 | } | |
596a855f | 624 | } |
24f7a148 | 625 | |
9db3a215 | 626 | |
627 | TStopwatch stopwatch; | |
628 | stopwatch.Start(); | |
629 | ||
b26c3770 | 630 | // get the possibly already existing ESD file and tree |
1f46a9ae | 631 | AliESD* esd = new AliESD; AliESD* hltesd = new AliESD; |
b26c3770 | 632 | TFile* fileOld = NULL; |
1f46a9ae | 633 | TTree* treeOld = NULL; TTree *hlttreeOld = NULL; |
b26c3770 | 634 | if (!gSystem->AccessPathName("AliESDs.root")){ |
635 | gSystem->CopyFile("AliESDs.root", "AliESDs.old.root", kTRUE); | |
636 | fileOld = TFile::Open("AliESDs.old.root"); | |
637 | if (fileOld && fileOld->IsOpen()) { | |
638 | treeOld = (TTree*) fileOld->Get("esdTree"); | |
639 | if (treeOld) treeOld->SetBranchAddress("ESD", &esd); | |
1f46a9ae | 640 | hlttreeOld = (TTree*) fileOld->Get("HLTesdTree"); |
641 | if (hlttreeOld) hlttreeOld->SetBranchAddress("ESD", &hltesd); | |
b26c3770 | 642 | } |
643 | } | |
644 | ||
36711aa4 | 645 | // create the ESD output file and tree |
596a855f | 646 | TFile* file = TFile::Open("AliESDs.root", "RECREATE"); |
647 | if (!file->IsOpen()) { | |
815c2b38 | 648 | AliError("opening AliESDs.root failed"); |
b26c3770 | 649 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
596a855f | 650 | } |
36711aa4 | 651 | TTree* tree = new TTree("esdTree", "Tree with ESD objects"); |
652 | tree->Branch("ESD", "AliESD", &esd); | |
1f46a9ae | 653 | TTree* hlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects"); |
654 | hlttree->Branch("ESD", "AliESD", &hltesd); | |
655 | delete esd; delete hltesd; | |
656 | esd = NULL; hltesd = NULL; | |
1d99986f | 657 | |
500d54ab | 658 | // create the branch with ESD additions |
659 | AliESDfriend *esdf=0; | |
1d99986f | 660 | if (fWriteESDfriend) { |
500d54ab | 661 | TBranch *br=tree->Branch("ESDfriend.", "AliESDfriend", &esdf); |
662 | br->SetFile("AliESDfriends.root"); | |
1d99986f | 663 | } |
664 | ||
c5e3e5d1 | 665 | AliVertexerTracks tVertexer; |
9178838a | 666 | if(fDiamondProfile) tVertexer.SetVtxStart(fDiamondProfile); |
c5e3e5d1 | 667 | |
596a855f | 668 | // loop over events |
b649205a | 669 | if (fRawReader) fRawReader->RewindEvents(); |
f08fc9f5 | 670 | |
596a855f | 671 | for (Int_t iEvent = 0; iEvent < fRunLoader->GetNumberOfEvents(); iEvent++) { |
b26c3770 | 672 | if (fRawReader) fRawReader->NextEvent(); |
4a33489c | 673 | if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) { |
b26c3770 | 674 | // copy old ESD to the new one |
675 | if (treeOld) { | |
676 | treeOld->SetBranchAddress("ESD", &esd); | |
677 | treeOld->GetEntry(iEvent); | |
678 | } | |
679 | tree->Fill(); | |
1f46a9ae | 680 | if (hlttreeOld) { |
681 | hlttreeOld->SetBranchAddress("ESD", &hltesd); | |
682 | hlttreeOld->GetEntry(iEvent); | |
683 | } | |
684 | hlttree->Fill(); | |
b26c3770 | 685 | continue; |
686 | } | |
687 | ||
815c2b38 | 688 | AliInfo(Form("processing event %d", iEvent)); |
596a855f | 689 | fRunLoader->GetEvent(iEvent); |
24f7a148 | 690 | |
bb0901a4 | 691 | char aFileName[256]; |
692 | sprintf(aFileName, "ESD_%d.%d_final.root", | |
f08fc9f5 | 693 | fRunLoader->GetHeader()->GetRun(), |
694 | fRunLoader->GetHeader()->GetEventNrInRun()); | |
bb0901a4 | 695 | if (!gSystem->AccessPathName(aFileName)) continue; |
24f7a148 | 696 | |
b26c3770 | 697 | // local reconstruction |
698 | if (!fRunLocalReconstruction.IsNull()) { | |
699 | if (!RunLocalEventReconstruction(fRunLocalReconstruction)) { | |
700 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
701 | } | |
702 | } | |
703 | ||
1f46a9ae | 704 | esd = new AliESD; hltesd = new AliESD; |
f08fc9f5 | 705 | esd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); |
1f46a9ae | 706 | hltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun()); |
31fd97b2 | 707 | esd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun()); |
708 | hltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun()); | |
d6ee376f | 709 | |
710 | // Set magnetic field from the tracker | |
711 | esd->SetMagneticField(AliTracker::GetBz()); | |
712 | hltesd->SetMagneticField(AliTracker::GetBz()); | |
596a855f | 713 | |
2e3550da | 714 | // Fill raw-data error log into the ESD |
715 | if (fRawReader) FillRawDataErrorLog(iEvent,esd); | |
716 | ||
2257f27e | 717 | // vertex finder |
718 | if (fRunVertexFinder) { | |
719 | if (!ReadESD(esd, "vertex")) { | |
720 | if (!RunVertexFinder(esd)) { | |
b26c3770 | 721 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
2257f27e | 722 | } |
723 | if (fCheckPointLevel > 0) WriteESD(esd, "vertex"); | |
724 | } | |
725 | } | |
726 | ||
1f46a9ae | 727 | // HLT tracking |
728 | if (!fRunTracking.IsNull()) { | |
729 | if (fRunHLTTracking) { | |
730 | hltesd->SetVertex(esd->GetVertex()); | |
731 | if (!RunHLTTracking(hltesd)) { | |
732 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
733 | } | |
734 | } | |
735 | } | |
736 | ||
e66fbafb | 737 | // Muon tracking |
b8cd5251 | 738 | if (!fRunTracking.IsNull()) { |
e66fbafb | 739 | if (fRunMuonTracking) { |
740 | if (!RunMuonTracking()) { | |
b26c3770 | 741 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
24f7a148 | 742 | } |
596a855f | 743 | } |
744 | } | |
745 | ||
e66fbafb | 746 | // barrel tracking |
747 | if (!fRunTracking.IsNull()) { | |
748 | if (!fRunMuonTracking) { | |
749 | if (!ReadESD(esd, "tracking")) { | |
750 | if (!RunTracking(esd)) { | |
751 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
752 | } | |
753 | if (fCheckPointLevel > 0) WriteESD(esd, "tracking"); | |
754 | } | |
755 | } | |
756 | } | |
596a855f | 757 | // fill ESD |
758 | if (!fFillESD.IsNull()) { | |
759 | if (!FillESD(esd, fFillESD)) { | |
b26c3770 | 760 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} |
596a855f | 761 | } |
762 | } | |
001397cd | 763 | // fill Event header information from the RawEventHeader |
764 | if (fRawReader){FillRawEventHeaderESD(esd);} | |
596a855f | 765 | |
766 | // combined PID | |
767 | AliESDpid::MakePID(esd); | |
24f7a148 | 768 | if (fCheckPointLevel > 1) WriteESD(esd, "PID"); |
596a855f | 769 | |
b647652d | 770 | if (fFillTriggerESD) { |
771 | if (!ReadESD(esd, "trigger")) { | |
772 | if (!FillTriggerESD(esd)) { | |
773 | if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} | |
774 | } | |
775 | if (fCheckPointLevel > 1) WriteESD(esd, "trigger"); | |
776 | } | |
777 | } | |
778 | ||
a03cd2e0 | 779 | //Try to improve the reconstructed primary vertex position using the tracks |
780 | AliESDVertex *pvtx=tVertexer.FindPrimaryVertex(esd); | |
781 | if (pvtx) | |
782 | if (pvtx->GetStatus()) { | |
783 | // Store the improved primary vertex | |
784 | esd->SetPrimaryVertex(pvtx); | |
785 | // Propagate the tracks to the DCA to the improved primary vertex | |
786 | Double_t somethingbig = 777.; | |
787 | Double_t bz = esd->GetMagneticField(); | |
788 | Int_t nt=esd->GetNumberOfTracks(); | |
789 | while (nt--) { | |
790 | AliESDtrack *t = esd->GetTrack(nt); | |
791 | t->RelateToVertex(pvtx, bz, somethingbig); | |
792 | } | |
793 | } | |
c5e3e5d1 | 794 | |
5e4ff34d | 795 | { |
796 | // V0 finding | |
797 | AliV0vertexer vtxer; | |
798 | vtxer.Tracks2V0vertices(esd); | |
799 | ||
800 | // Cascade finding | |
801 | AliCascadeVertexer cvtxer; | |
802 | cvtxer.V0sTracks2CascadeVertices(esd); | |
803 | } | |
804 | ||
596a855f | 805 | // write ESD |
1d99986f | 806 | if (fWriteESDfriend) { |
d75007f6 | 807 | esdf=new AliESDfriend(); |
808 | esd->GetESDfriend(esdf); | |
1d99986f | 809 | } |
500d54ab | 810 | tree->Fill(); |
811 | ||
812 | // write HLT ESD | |
813 | hlttree->Fill(); | |
1d99986f | 814 | |
f3a97c86 | 815 | if (fCheckPointLevel > 0) WriteESD(esd, "final"); |
816 | ||
500d54ab | 817 | delete esd; delete esdf; delete hltesd; |
818 | esd = NULL; esdf=NULL; hltesd = NULL; | |
596a855f | 819 | } |
820 | ||
9db3a215 | 821 | AliInfo(Form("Execution time for filling ESD : R:%.2fs C:%.2fs", |
822 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
823 | ||
36711aa4 | 824 | file->cd(); |
a9c0e6db | 825 | if (fWriteESDfriend) |
826 | tree->SetBranchStatus("ESDfriend*",0); | |
36711aa4 | 827 | tree->Write(); |
1f46a9ae | 828 | hlttree->Write(); |
f3a97c86 | 829 | |
a7807689 | 830 | if (fWriteAOD) { |
831 | CreateAOD(file); | |
832 | } | |
833 | ||
f3a97c86 | 834 | // Create tags for the events in the ESD tree (the ESD tree is always present) |
835 | // In case of empty events the tags will contain dummy values | |
836 | CreateTag(file); | |
b26c3770 | 837 | CleanUp(file, fileOld); |
596a855f | 838 | |
839 | return kTRUE; | |
840 | } | |
841 | ||
842 | ||
843 | //_____________________________________________________________________________ | |
59697224 | 844 | Bool_t AliReconstruction::RunLocalReconstruction(const TString& detectors) |
596a855f | 845 | { |
59697224 | 846 | // run the local reconstruction |
596a855f | 847 | |
030b532d | 848 | TStopwatch stopwatch; |
849 | stopwatch.Start(); | |
850 | ||
8e245d15 | 851 | AliCDBManager* man = AliCDBManager::Instance(); |
852 | Bool_t origCache = man->GetCacheFlag(); | |
853 | ||
596a855f | 854 | TString detStr = detectors; |
b8cd5251 | 855 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
856 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
857 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
858 | if (!reconstructor) continue; | |
b26c3770 | 859 | if (reconstructor->HasLocalReconstruction()) continue; |
b8cd5251 | 860 | |
861 | AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); | |
862 | TStopwatch stopwatchDet; | |
863 | stopwatchDet.Start(); | |
8e245d15 | 864 | |
865 | AliInfo(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet])); | |
866 | ||
867 | man->SetCacheFlag(kTRUE); | |
868 | TString calibPath = Form("%s/Calib/*", fgkDetectorName[iDet]); | |
869 | man->GetAll(calibPath); // entries are cached! | |
870 | ||
b8cd5251 | 871 | if (fRawReader) { |
872 | fRawReader->RewindEvents(); | |
873 | reconstructor->Reconstruct(fRunLoader, fRawReader); | |
874 | } else { | |
875 | reconstructor->Reconstruct(fRunLoader); | |
596a855f | 876 | } |
5f8272e1 | 877 | AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs", |
878 | fgkDetectorName[iDet], | |
879 | stopwatchDet.RealTime(),stopwatchDet.CpuTime())); | |
8e245d15 | 880 | |
881 | // unload calibration data | |
882 | man->ClearCache(); | |
596a855f | 883 | } |
884 | ||
8e245d15 | 885 | man->SetCacheFlag(origCache); |
886 | ||
596a855f | 887 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { |
815c2b38 | 888 | AliError(Form("the following detectors were not found: %s", |
889 | detStr.Data())); | |
596a855f | 890 | if (fStopOnError) return kFALSE; |
891 | } | |
892 | ||
5f8272e1 | 893 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", |
894 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
030b532d | 895 | |
596a855f | 896 | return kTRUE; |
897 | } | |
898 | ||
b26c3770 | 899 | //_____________________________________________________________________________ |
900 | Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors) | |
901 | { | |
902 | // run the local reconstruction | |
903 | ||
904 | TStopwatch stopwatch; | |
905 | stopwatch.Start(); | |
906 | ||
907 | TString detStr = detectors; | |
908 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
909 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
910 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
911 | if (!reconstructor) continue; | |
912 | AliLoader* loader = fLoader[iDet]; | |
913 | ||
914 | // conversion of digits | |
915 | if (fRawReader && reconstructor->HasDigitConversion()) { | |
916 | AliInfo(Form("converting raw data digits into root objects for %s", | |
917 | fgkDetectorName[iDet])); | |
918 | TStopwatch stopwatchDet; | |
919 | stopwatchDet.Start(); | |
920 | loader->LoadDigits("update"); | |
921 | loader->CleanDigits(); | |
922 | loader->MakeDigitsContainer(); | |
923 | TTree* digitsTree = loader->TreeD(); | |
924 | reconstructor->ConvertDigits(fRawReader, digitsTree); | |
925 | loader->WriteDigits("OVERWRITE"); | |
926 | loader->UnloadDigits(); | |
5f8272e1 | 927 | AliInfo(Form("Execution time for %s: R:%.2fs C:%.2fs", |
928 | fgkDetectorName[iDet], | |
929 | stopwatchDet.RealTime(),stopwatchDet.CpuTime())); | |
b26c3770 | 930 | } |
931 | ||
932 | // local reconstruction | |
933 | if (!reconstructor->HasLocalReconstruction()) continue; | |
934 | AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet])); | |
935 | TStopwatch stopwatchDet; | |
936 | stopwatchDet.Start(); | |
937 | loader->LoadRecPoints("update"); | |
938 | loader->CleanRecPoints(); | |
939 | loader->MakeRecPointsContainer(); | |
940 | TTree* clustersTree = loader->TreeR(); | |
941 | if (fRawReader && !reconstructor->HasDigitConversion()) { | |
942 | reconstructor->Reconstruct(fRawReader, clustersTree); | |
943 | } else { | |
944 | loader->LoadDigits("read"); | |
945 | TTree* digitsTree = loader->TreeD(); | |
946 | if (!digitsTree) { | |
947 | AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet])); | |
948 | if (fStopOnError) return kFALSE; | |
949 | } else { | |
950 | reconstructor->Reconstruct(digitsTree, clustersTree); | |
951 | } | |
952 | loader->UnloadDigits(); | |
953 | } | |
954 | loader->WriteRecPoints("OVERWRITE"); | |
955 | loader->UnloadRecPoints(); | |
5f8272e1 | 956 | AliDebug(1,Form("Execution time for %s: R:%.2fs C:%.2fs", |
957 | fgkDetectorName[iDet], | |
958 | stopwatchDet.RealTime(),stopwatchDet.CpuTime())); | |
b26c3770 | 959 | } |
960 | ||
961 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
962 | AliError(Form("the following detectors were not found: %s", | |
963 | detStr.Data())); | |
964 | if (fStopOnError) return kFALSE; | |
965 | } | |
5f8272e1 | 966 | |
967 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", | |
968 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
b26c3770 | 969 | |
970 | return kTRUE; | |
971 | } | |
972 | ||
596a855f | 973 | //_____________________________________________________________________________ |
2257f27e | 974 | Bool_t AliReconstruction::RunVertexFinder(AliESD*& esd) |
596a855f | 975 | { |
976 | // run the barrel tracking | |
977 | ||
030b532d | 978 | TStopwatch stopwatch; |
979 | stopwatch.Start(); | |
980 | ||
2257f27e | 981 | AliESDVertex* vertex = NULL; |
982 | Double_t vtxPos[3] = {0, 0, 0}; | |
983 | Double_t vtxErr[3] = {0.07, 0.07, 0.1}; | |
984 | TArrayF mcVertex(3); | |
a6b0b91b | 985 | if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) { |
986 | fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex); | |
987 | for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i]; | |
988 | } | |
2257f27e | 989 | |
b8cd5251 | 990 | if (fVertexer) { |
815c2b38 | 991 | AliInfo("running the ITS vertex finder"); |
b26c3770 | 992 | if (fLoader[0]) fLoader[0]->LoadRecPoints(); |
b8cd5251 | 993 | vertex = fVertexer->FindVertexForCurrentEvent(fRunLoader->GetEventNumber()); |
b26c3770 | 994 | if (fLoader[0]) fLoader[0]->UnloadRecPoints(); |
2257f27e | 995 | if(!vertex){ |
815c2b38 | 996 | AliWarning("Vertex not found"); |
c710f220 | 997 | vertex = new AliESDVertex(); |
d1a50cb5 | 998 | vertex->SetName("default"); |
2257f27e | 999 | } |
1000 | else { | |
1001 | vertex->SetTruePos(vtxPos); // store also the vertex from MC | |
d1a50cb5 | 1002 | vertex->SetName("reconstructed"); |
2257f27e | 1003 | } |
1004 | ||
1005 | } else { | |
815c2b38 | 1006 | AliInfo("getting the primary vertex from MC"); |
2257f27e | 1007 | vertex = new AliESDVertex(vtxPos, vtxErr); |
1008 | } | |
1009 | ||
1010 | if (vertex) { | |
1011 | vertex->GetXYZ(vtxPos); | |
1012 | vertex->GetSigmaXYZ(vtxErr); | |
1013 | } else { | |
815c2b38 | 1014 | AliWarning("no vertex reconstructed"); |
2257f27e | 1015 | vertex = new AliESDVertex(vtxPos, vtxErr); |
1016 | } | |
1017 | esd->SetVertex(vertex); | |
32e449be | 1018 | // if SPD multiplicity has been determined, it is stored in the ESD |
1019 | AliMultiplicity *mult= fVertexer->GetMultiplicity(); | |
1020 | if(mult)esd->SetMultiplicity(mult); | |
1021 | ||
b8cd5251 | 1022 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1023 | if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr); | |
1024 | } | |
2257f27e | 1025 | delete vertex; |
1026 | ||
5f8272e1 | 1027 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", |
1028 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
2257f27e | 1029 | |
1030 | return kTRUE; | |
1031 | } | |
1032 | ||
1f46a9ae | 1033 | //_____________________________________________________________________________ |
1034 | Bool_t AliReconstruction::RunHLTTracking(AliESD*& esd) | |
1035 | { | |
1036 | // run the HLT barrel tracking | |
1037 | ||
1038 | TStopwatch stopwatch; | |
1039 | stopwatch.Start(); | |
1040 | ||
1041 | if (!fRunLoader) { | |
1042 | AliError("Missing runLoader!"); | |
1043 | return kFALSE; | |
1044 | } | |
1045 | ||
1046 | AliInfo("running HLT tracking"); | |
1047 | ||
1048 | // Get a pointer to the HLT reconstructor | |
1049 | AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1); | |
1050 | if (!reconstructor) return kFALSE; | |
1051 | ||
1052 | // TPC + ITS | |
1053 | for (Int_t iDet = 1; iDet >= 0; iDet--) { | |
1054 | TString detName = fgkDetectorName[iDet]; | |
1055 | AliDebug(1, Form("%s HLT tracking", detName.Data())); | |
1056 | reconstructor->SetOption(detName.Data()); | |
1057 | AliTracker *tracker = reconstructor->CreateTracker(fRunLoader); | |
1058 | if (!tracker) { | |
1059 | AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data())); | |
1060 | if (fStopOnError) return kFALSE; | |
9dcc06e1 | 1061 | continue; |
1f46a9ae | 1062 | } |
1063 | Double_t vtxPos[3]; | |
1064 | Double_t vtxErr[3]={0.005,0.005,0.010}; | |
1065 | const AliESDVertex *vertex = esd->GetVertex(); | |
1066 | vertex->GetXYZ(vtxPos); | |
1067 | tracker->SetVertex(vtxPos,vtxErr); | |
1068 | if(iDet != 1) { | |
1069 | fLoader[iDet]->LoadRecPoints("read"); | |
1070 | TTree* tree = fLoader[iDet]->TreeR(); | |
1071 | if (!tree) { | |
1072 | AliError(Form("Can't get the %s cluster tree", detName.Data())); | |
1073 | return kFALSE; | |
1074 | } | |
1075 | tracker->LoadClusters(tree); | |
1076 | } | |
1077 | if (tracker->Clusters2Tracks(esd) != 0) { | |
1078 | AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
1079 | return kFALSE; | |
1080 | } | |
1081 | if(iDet != 1) { | |
1082 | tracker->UnloadClusters(); | |
1083 | } | |
1084 | delete tracker; | |
1085 | } | |
1086 | ||
5f8272e1 | 1087 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", |
1088 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
1f46a9ae | 1089 | |
1090 | return kTRUE; | |
1091 | } | |
1092 | ||
e66fbafb | 1093 | //_____________________________________________________________________________ |
1094 | Bool_t AliReconstruction::RunMuonTracking() | |
1095 | { | |
1096 | // run the muon spectrometer tracking | |
1097 | ||
1098 | TStopwatch stopwatch; | |
1099 | stopwatch.Start(); | |
1100 | ||
1101 | if (!fRunLoader) { | |
1102 | AliError("Missing runLoader!"); | |
1103 | return kFALSE; | |
1104 | } | |
1105 | Int_t iDet = 7; // for MUON | |
1106 | ||
1107 | AliInfo("is running..."); | |
1108 | ||
1109 | // Get a pointer to the MUON reconstructor | |
1110 | AliReconstructor *reconstructor = GetReconstructor(iDet); | |
1111 | if (!reconstructor) return kFALSE; | |
1112 | ||
1113 | ||
1114 | TString detName = fgkDetectorName[iDet]; | |
1115 | AliDebug(1, Form("%s tracking", detName.Data())); | |
1116 | AliTracker *tracker = reconstructor->CreateTracker(fRunLoader); | |
1117 | if (!tracker) { | |
1118 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); | |
1119 | return kFALSE; | |
1120 | } | |
1121 | ||
1122 | // create Tracks | |
1123 | fLoader[iDet]->LoadTracks("update"); | |
1124 | fLoader[iDet]->CleanTracks(); | |
1125 | fLoader[iDet]->MakeTracksContainer(); | |
1126 | ||
1127 | // read RecPoints | |
1128 | fLoader[iDet]->LoadRecPoints("read"); | |
1129 | ||
1130 | if (!tracker->Clusters2Tracks(0x0)) { | |
1131 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
1132 | return kFALSE; | |
1133 | } | |
1134 | fLoader[iDet]->UnloadRecPoints(); | |
1135 | ||
1136 | fLoader[iDet]->WriteTracks("OVERWRITE"); | |
1137 | fLoader[iDet]->UnloadTracks(); | |
1138 | ||
1139 | delete tracker; | |
1140 | ||
1141 | ||
1142 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", | |
1143 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
1144 | ||
1145 | return kTRUE; | |
1146 | } | |
1147 | ||
1148 | ||
2257f27e | 1149 | //_____________________________________________________________________________ |
1150 | Bool_t AliReconstruction::RunTracking(AliESD*& esd) | |
1151 | { | |
1152 | // run the barrel tracking | |
1153 | ||
1154 | TStopwatch stopwatch; | |
1155 | stopwatch.Start(); | |
24f7a148 | 1156 | |
815c2b38 | 1157 | AliInfo("running tracking"); |
596a855f | 1158 | |
b8cd5251 | 1159 | // pass 1: TPC + ITS inwards |
1160 | for (Int_t iDet = 1; iDet >= 0; iDet--) { | |
1161 | if (!fTracker[iDet]) continue; | |
1162 | AliDebug(1, Form("%s tracking", fgkDetectorName[iDet])); | |
24f7a148 | 1163 | |
b8cd5251 | 1164 | // load clusters |
1165 | fLoader[iDet]->LoadRecPoints("read"); | |
1166 | TTree* tree = fLoader[iDet]->TreeR(); | |
1167 | if (!tree) { | |
1168 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); | |
24f7a148 | 1169 | return kFALSE; |
1170 | } | |
b8cd5251 | 1171 | fTracker[iDet]->LoadClusters(tree); |
1172 | ||
1173 | // run tracking | |
1174 | if (fTracker[iDet]->Clusters2Tracks(esd) != 0) { | |
1175 | AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet])); | |
24f7a148 | 1176 | return kFALSE; |
1177 | } | |
b8cd5251 | 1178 | if (fCheckPointLevel > 1) { |
1179 | WriteESD(esd, Form("%s.tracking", fgkDetectorName[iDet])); | |
1180 | } | |
878e1fe1 | 1181 | // preliminary PID in TPC needed by the ITS tracker |
1182 | if (iDet == 1) { | |
1183 | GetReconstructor(1)->FillESD(fRunLoader, esd); | |
b26c3770 | 1184 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); |
878e1fe1 | 1185 | AliESDpid::MakePID(esd); |
1186 | } | |
b8cd5251 | 1187 | } |
596a855f | 1188 | |
b8cd5251 | 1189 | // pass 2: ALL backwards |
1190 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1191 | if (!fTracker[iDet]) continue; | |
1192 | AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet])); | |
1193 | ||
1194 | // load clusters | |
1195 | if (iDet > 1) { // all except ITS, TPC | |
1196 | TTree* tree = NULL; | |
7b61cd9c | 1197 | fLoader[iDet]->LoadRecPoints("read"); |
1198 | tree = fLoader[iDet]->TreeR(); | |
b8cd5251 | 1199 | if (!tree) { |
1200 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet])); | |
24f7a148 | 1201 | return kFALSE; |
1202 | } | |
b8cd5251 | 1203 | fTracker[iDet]->LoadClusters(tree); |
1204 | } | |
24f7a148 | 1205 | |
b8cd5251 | 1206 | // run tracking |
1207 | if (fTracker[iDet]->PropagateBack(esd) != 0) { | |
1208 | AliError(Form("%s backward propagation failed", fgkDetectorName[iDet])); | |
1209 | return kFALSE; | |
1210 | } | |
1211 | if (fCheckPointLevel > 1) { | |
1212 | WriteESD(esd, Form("%s.back", fgkDetectorName[iDet])); | |
1213 | } | |
24f7a148 | 1214 | |
b8cd5251 | 1215 | // unload clusters |
1216 | if (iDet > 2) { // all except ITS, TPC, TRD | |
1217 | fTracker[iDet]->UnloadClusters(); | |
7b61cd9c | 1218 | fLoader[iDet]->UnloadRecPoints(); |
b8cd5251 | 1219 | } |
8f37df88 | 1220 | // updated PID in TPC needed by the ITS tracker -MI |
1221 | if (iDet == 1) { | |
1222 | GetReconstructor(1)->FillESD(fRunLoader, esd); | |
1223 | GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd); | |
1224 | AliESDpid::MakePID(esd); | |
1225 | } | |
b8cd5251 | 1226 | } |
596a855f | 1227 | |
98937d93 | 1228 | // write space-points to the ESD in case alignment data output |
1229 | // is switched on | |
1230 | if (fWriteAlignmentData) | |
1231 | WriteAlignmentData(esd); | |
1232 | ||
b8cd5251 | 1233 | // pass 3: TRD + TPC + ITS refit inwards |
1234 | for (Int_t iDet = 2; iDet >= 0; iDet--) { | |
1235 | if (!fTracker[iDet]) continue; | |
1236 | AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet])); | |
596a855f | 1237 | |
b8cd5251 | 1238 | // run tracking |
1239 | if (fTracker[iDet]->RefitInward(esd) != 0) { | |
1240 | AliError(Form("%s inward refit failed", fgkDetectorName[iDet])); | |
1241 | return kFALSE; | |
1242 | } | |
1243 | if (fCheckPointLevel > 1) { | |
1244 | WriteESD(esd, Form("%s.refit", fgkDetectorName[iDet])); | |
1245 | } | |
596a855f | 1246 | |
b8cd5251 | 1247 | // unload clusters |
1248 | fTracker[iDet]->UnloadClusters(); | |
1249 | fLoader[iDet]->UnloadRecPoints(); | |
1250 | } | |
ff8bb5ae | 1251 | // |
1252 | // Propagate track to the vertex - if not done by ITS | |
1253 | // | |
1254 | Int_t ntracks = esd->GetNumberOfTracks(); | |
1255 | for (Int_t itrack=0; itrack<ntracks; itrack++){ | |
1256 | const Double_t kRadius = 3; // beam pipe radius | |
1257 | const Double_t kMaxStep = 5; // max step | |
1258 | const Double_t kMaxD = 123456; // max distance to prim vertex | |
1259 | Double_t fieldZ = AliTracker::GetBz(); // | |
1260 | AliESDtrack * track = esd->GetTrack(itrack); | |
1261 | if (!track) continue; | |
1262 | if (track->IsOn(AliESDtrack::kITSrefit)) continue; | |
a28195f7 | 1263 | track->PropagateTo(kRadius, fieldZ, track->GetMass(),kMaxStep,kTRUE); |
ff8bb5ae | 1264 | track->RelateToVertex(esd->GetVertex(),fieldZ, kMaxD); |
1265 | } | |
1266 | ||
5f8272e1 | 1267 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", |
1268 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
030b532d | 1269 | |
596a855f | 1270 | return kTRUE; |
1271 | } | |
1272 | ||
1273 | //_____________________________________________________________________________ | |
24f7a148 | 1274 | Bool_t AliReconstruction::FillESD(AliESD*& esd, const TString& detectors) |
596a855f | 1275 | { |
1276 | // fill the event summary data | |
1277 | ||
030b532d | 1278 | TStopwatch stopwatch; |
1279 | stopwatch.Start(); | |
815c2b38 | 1280 | AliInfo("filling ESD"); |
030b532d | 1281 | |
596a855f | 1282 | TString detStr = detectors; |
b8cd5251 | 1283 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1284 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
1285 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
1286 | if (!reconstructor) continue; | |
1287 | ||
1288 | if (!ReadESD(esd, fgkDetectorName[iDet])) { | |
1289 | AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet])); | |
b26c3770 | 1290 | TTree* clustersTree = NULL; |
1291 | if (reconstructor->HasLocalReconstruction() && fLoader[iDet]) { | |
1292 | fLoader[iDet]->LoadRecPoints("read"); | |
1293 | clustersTree = fLoader[iDet]->TreeR(); | |
1294 | if (!clustersTree) { | |
1295 | AliError(Form("Can't get the %s clusters tree", | |
1296 | fgkDetectorName[iDet])); | |
1297 | if (fStopOnError) return kFALSE; | |
1298 | } | |
1299 | } | |
1300 | if (fRawReader && !reconstructor->HasDigitConversion()) { | |
1301 | reconstructor->FillESD(fRawReader, clustersTree, esd); | |
1302 | } else { | |
1303 | TTree* digitsTree = NULL; | |
1304 | if (fLoader[iDet]) { | |
1305 | fLoader[iDet]->LoadDigits("read"); | |
1306 | digitsTree = fLoader[iDet]->TreeD(); | |
1307 | if (!digitsTree) { | |
1308 | AliError(Form("Can't get the %s digits tree", | |
1309 | fgkDetectorName[iDet])); | |
1310 | if (fStopOnError) return kFALSE; | |
1311 | } | |
1312 | } | |
1313 | reconstructor->FillESD(digitsTree, clustersTree, esd); | |
1314 | if (fLoader[iDet]) fLoader[iDet]->UnloadDigits(); | |
1315 | } | |
1316 | if (reconstructor->HasLocalReconstruction() && fLoader[iDet]) { | |
1317 | fLoader[iDet]->UnloadRecPoints(); | |
1318 | } | |
1319 | ||
b8cd5251 | 1320 | if (fRawReader) { |
1321 | reconstructor->FillESD(fRunLoader, fRawReader, esd); | |
1322 | } else { | |
1323 | reconstructor->FillESD(fRunLoader, esd); | |
24f7a148 | 1324 | } |
b8cd5251 | 1325 | if (fCheckPointLevel > 2) WriteESD(esd, fgkDetectorName[iDet]); |
596a855f | 1326 | } |
1327 | } | |
1328 | ||
1329 | if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { | |
815c2b38 | 1330 | AliError(Form("the following detectors were not found: %s", |
1331 | detStr.Data())); | |
596a855f | 1332 | if (fStopOnError) return kFALSE; |
1333 | } | |
1334 | ||
5f8272e1 | 1335 | AliInfo(Form("Execution time: R:%.2fs C:%.2fs", |
1336 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
030b532d | 1337 | |
596a855f | 1338 | return kTRUE; |
1339 | } | |
1340 | ||
b647652d | 1341 | //_____________________________________________________________________________ |
1342 | Bool_t AliReconstruction::FillTriggerESD(AliESD*& esd) | |
1343 | { | |
1344 | // Reads the trigger decision which is | |
1345 | // stored in Trigger.root file and fills | |
1346 | // the corresponding esd entries | |
1347 | ||
1348 | AliInfo("Filling trigger information into the ESD"); | |
1349 | ||
1350 | if (fRawReader) { | |
1351 | AliCTPRawStream input(fRawReader); | |
1352 | if (!input.Next()) { | |
1353 | AliError("No valid CTP (trigger) DDL raw data is found ! The trigger information is not stored in the ESD !"); | |
1354 | return kFALSE; | |
1355 | } | |
1356 | esd->SetTriggerMask(input.GetClassMask()); | |
1357 | esd->SetTriggerCluster(input.GetClusterMask()); | |
1358 | } | |
1359 | else { | |
1360 | AliRunLoader *runloader = AliRunLoader::GetRunLoader(); | |
1361 | if (runloader) { | |
1362 | if (!runloader->LoadTrigger()) { | |
1363 | AliCentralTrigger *aCTP = runloader->GetTrigger(); | |
1364 | esd->SetTriggerMask(aCTP->GetClassMask()); | |
1365 | esd->SetTriggerCluster(aCTP->GetClusterMask()); | |
1366 | } | |
1367 | else { | |
1368 | AliWarning("No trigger can be loaded! The trigger information is not stored in the ESD !"); | |
1369 | return kFALSE; | |
1370 | } | |
1371 | } | |
1372 | else { | |
1373 | AliError("No run loader is available! The trigger information is not stored in the ESD !"); | |
1374 | return kFALSE; | |
1375 | } | |
1376 | } | |
1377 | ||
1378 | return kTRUE; | |
1379 | } | |
596a855f | 1380 | |
001397cd | 1381 | |
1382 | ||
1383 | ||
1384 | ||
1385 | //_____________________________________________________________________________ | |
1386 | Bool_t AliReconstruction::FillRawEventHeaderESD(AliESD*& esd) | |
1387 | { | |
1388 | // | |
1389 | // Filling information from RawReader Header | |
1390 | // | |
1391 | ||
1392 | AliInfo("Filling information from RawReader Header"); | |
31fd97b2 | 1393 | esd->SetBunchCrossNumber(0); |
1394 | esd->SetOrbitNumber(0); | |
001397cd | 1395 | esd->SetTimeStamp(0); |
1396 | esd->SetEventType(0); | |
1397 | const AliRawEventHeaderBase * eventHeader = fRawReader->GetEventHeader(); | |
1398 | if (eventHeader){ | |
31fd97b2 | 1399 | esd->SetBunchCrossNumber((eventHeader->GetP("Id")[0])); |
1400 | esd->SetOrbitNumber((eventHeader->GetP("Id")[1])); | |
001397cd | 1401 | esd->SetTimeStamp((eventHeader->Get("Timestamp"))); |
31fd97b2 | 1402 | esd->SetEventType((eventHeader->Get("Type"))); |
001397cd | 1403 | } |
1404 | ||
1405 | return kTRUE; | |
1406 | } | |
1407 | ||
1408 | ||
596a855f | 1409 | //_____________________________________________________________________________ |
1410 | Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const | |
1411 | { | |
1412 | // check whether detName is contained in detectors | |
1413 | // if yes, it is removed from detectors | |
1414 | ||
1415 | // check if all detectors are selected | |
1416 | if ((detectors.CompareTo("ALL") == 0) || | |
1417 | detectors.BeginsWith("ALL ") || | |
1418 | detectors.EndsWith(" ALL") || | |
1419 | detectors.Contains(" ALL ")) { | |
1420 | detectors = "ALL"; | |
1421 | return kTRUE; | |
1422 | } | |
1423 | ||
1424 | // search for the given detector | |
1425 | Bool_t result = kFALSE; | |
1426 | if ((detectors.CompareTo(detName) == 0) || | |
1427 | detectors.BeginsWith(detName+" ") || | |
1428 | detectors.EndsWith(" "+detName) || | |
1429 | detectors.Contains(" "+detName+" ")) { | |
1430 | detectors.ReplaceAll(detName, ""); | |
1431 | result = kTRUE; | |
1432 | } | |
1433 | ||
1434 | // clean up the detectors string | |
1435 | while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " "); | |
1436 | while (detectors.BeginsWith(" ")) detectors.Remove(0, 1); | |
1437 | while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1); | |
1438 | ||
1439 | return result; | |
1440 | } | |
e583c30d | 1441 | |
f08fc9f5 | 1442 | //_____________________________________________________________________________ |
1443 | Bool_t AliReconstruction::InitRunLoader() | |
1444 | { | |
1445 | // get or create the run loader | |
1446 | ||
1447 | if (gAlice) delete gAlice; | |
1448 | gAlice = NULL; | |
1449 | ||
b26c3770 | 1450 | if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists |
1451 | // load all base libraries to get the loader classes | |
1452 | TString libs = gSystem->GetLibraries(); | |
1453 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1454 | TString detName = fgkDetectorName[iDet]; | |
1455 | if (detName == "HLT") continue; | |
1456 | if (libs.Contains("lib" + detName + "base.so")) continue; | |
1457 | gSystem->Load("lib" + detName + "base.so"); | |
1458 | } | |
f08fc9f5 | 1459 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); |
1460 | if (!fRunLoader) { | |
1461 | AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); | |
1462 | CleanUp(); | |
1463 | return kFALSE; | |
1464 | } | |
b26c3770 | 1465 | fRunLoader->CdGAFile(); |
1466 | if (gFile->GetKey(AliRunLoader::GetGAliceName())) { | |
1467 | if (fRunLoader->LoadgAlice() == 0) { | |
1468 | gAlice = fRunLoader->GetAliRun(); | |
c84a5e9e | 1469 | AliTracker::SetFieldMap(gAlice->Field(),fUniformField); |
b26c3770 | 1470 | } |
f08fc9f5 | 1471 | } |
1472 | if (!gAlice && !fRawReader) { | |
1473 | AliError(Form("no gAlice object found in file %s", | |
1474 | fGAliceFileName.Data())); | |
1475 | CleanUp(); | |
1476 | return kFALSE; | |
1477 | } | |
1478 | ||
1479 | } else { // galice.root does not exist | |
1480 | if (!fRawReader) { | |
1481 | AliError(Form("the file %s does not exist", fGAliceFileName.Data())); | |
1482 | CleanUp(); | |
1483 | return kFALSE; | |
1484 | } | |
1485 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(), | |
1486 | AliConfig::GetDefaultEventFolderName(), | |
1487 | "recreate"); | |
1488 | if (!fRunLoader) { | |
1489 | AliError(Form("could not create run loader in file %s", | |
1490 | fGAliceFileName.Data())); | |
1491 | CleanUp(); | |
1492 | return kFALSE; | |
1493 | } | |
1494 | fRunLoader->MakeTree("E"); | |
1495 | Int_t iEvent = 0; | |
1496 | while (fRawReader->NextEvent()) { | |
1497 | fRunLoader->SetEventNumber(iEvent); | |
1498 | fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(), | |
1499 | iEvent, iEvent); | |
1500 | fRunLoader->MakeTree("H"); | |
1501 | fRunLoader->TreeE()->Fill(); | |
1502 | iEvent++; | |
1503 | } | |
1504 | fRawReader->RewindEvents(); | |
973388c2 | 1505 | if (fNumberOfEventsPerFile > 0) |
1506 | fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile); | |
1507 | else | |
1508 | fRunLoader->SetNumberOfEventsPerFile(iEvent); | |
f08fc9f5 | 1509 | fRunLoader->WriteHeader("OVERWRITE"); |
1510 | fRunLoader->CdGAFile(); | |
1511 | fRunLoader->Write(0, TObject::kOverwrite); | |
1512 | // AliTracker::SetFieldMap(???); | |
1513 | } | |
1514 | ||
1515 | return kTRUE; | |
1516 | } | |
1517 | ||
c757bafd | 1518 | //_____________________________________________________________________________ |
b8cd5251 | 1519 | AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet) |
c757bafd | 1520 | { |
f08fc9f5 | 1521 | // get the reconstructor object and the loader for a detector |
c757bafd | 1522 | |
b8cd5251 | 1523 | if (fReconstructor[iDet]) return fReconstructor[iDet]; |
1524 | ||
1525 | // load the reconstructor object | |
1526 | TPluginManager* pluginManager = gROOT->GetPluginManager(); | |
1527 | TString detName = fgkDetectorName[iDet]; | |
1528 | TString recName = "Ali" + detName + "Reconstructor"; | |
f08fc9f5 | 1529 | if (gAlice && !gAlice->GetDetector(detName) && (detName != "HLT")) return NULL; |
b8cd5251 | 1530 | |
1531 | if (detName == "HLT") { | |
1532 | if (!gROOT->GetClass("AliLevel3")) { | |
4aa41877 | 1533 | gSystem->Load("libAliHLTSrc.so"); |
1534 | gSystem->Load("libAliHLTMisc.so"); | |
1535 | gSystem->Load("libAliHLTHough.so"); | |
1536 | gSystem->Load("libAliHLTComp.so"); | |
b8cd5251 | 1537 | } |
1538 | } | |
1539 | ||
1540 | AliReconstructor* reconstructor = NULL; | |
1541 | // first check if a plugin is defined for the reconstructor | |
1542 | TPluginHandler* pluginHandler = | |
1543 | pluginManager->FindHandler("AliReconstructor", detName); | |
f08fc9f5 | 1544 | // if not, add a plugin for it |
1545 | if (!pluginHandler) { | |
b8cd5251 | 1546 | AliDebug(1, Form("defining plugin for %s", recName.Data())); |
b26c3770 | 1547 | TString libs = gSystem->GetLibraries(); |
1548 | if (libs.Contains("lib" + detName + "base.so") || | |
1549 | (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
b8cd5251 | 1550 | pluginManager->AddHandler("AliReconstructor", detName, |
1551 | recName, detName + "rec", recName + "()"); | |
1552 | } else { | |
1553 | pluginManager->AddHandler("AliReconstructor", detName, | |
1554 | recName, detName, recName + "()"); | |
c757bafd | 1555 | } |
b8cd5251 | 1556 | pluginHandler = pluginManager->FindHandler("AliReconstructor", detName); |
1557 | } | |
1558 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
1559 | reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0); | |
c757bafd | 1560 | } |
b8cd5251 | 1561 | if (reconstructor) { |
1562 | TObject* obj = fOptions.FindObject(detName.Data()); | |
1563 | if (obj) reconstructor->SetOption(obj->GetTitle()); | |
b26c3770 | 1564 | reconstructor->Init(fRunLoader); |
b8cd5251 | 1565 | fReconstructor[iDet] = reconstructor; |
1566 | } | |
1567 | ||
f08fc9f5 | 1568 | // get or create the loader |
1569 | if (detName != "HLT") { | |
1570 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); | |
1571 | if (!fLoader[iDet]) { | |
1572 | AliConfig::Instance() | |
1573 | ->CreateDetectorFolders(fRunLoader->GetEventFolder(), | |
1574 | detName, detName); | |
1575 | // first check if a plugin is defined for the loader | |
bb0901a4 | 1576 | pluginHandler = |
f08fc9f5 | 1577 | pluginManager->FindHandler("AliLoader", detName); |
1578 | // if not, add a plugin for it | |
1579 | if (!pluginHandler) { | |
1580 | TString loaderName = "Ali" + detName + "Loader"; | |
1581 | AliDebug(1, Form("defining plugin for %s", loaderName.Data())); | |
1582 | pluginManager->AddHandler("AliLoader", detName, | |
1583 | loaderName, detName + "base", | |
1584 | loaderName + "(const char*, TFolder*)"); | |
1585 | pluginHandler = pluginManager->FindHandler("AliLoader", detName); | |
1586 | } | |
1587 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
1588 | fLoader[iDet] = | |
1589 | (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(), | |
1590 | fRunLoader->GetEventFolder()); | |
1591 | } | |
1592 | if (!fLoader[iDet]) { // use default loader | |
1593 | fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder()); | |
1594 | } | |
1595 | if (!fLoader[iDet]) { | |
1596 | AliWarning(Form("couldn't get loader for %s", detName.Data())); | |
6667b602 | 1597 | if (fStopOnError) return NULL; |
f08fc9f5 | 1598 | } else { |
1599 | fRunLoader->AddLoader(fLoader[iDet]); | |
1600 | fRunLoader->CdGAFile(); | |
1601 | if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE"); | |
1602 | fRunLoader->Write(0, TObject::kOverwrite); | |
1603 | } | |
1604 | } | |
1605 | } | |
1606 | ||
b8cd5251 | 1607 | return reconstructor; |
c757bafd | 1608 | } |
1609 | ||
2257f27e | 1610 | //_____________________________________________________________________________ |
1611 | Bool_t AliReconstruction::CreateVertexer() | |
1612 | { | |
1613 | // create the vertexer | |
1614 | ||
b8cd5251 | 1615 | fVertexer = NULL; |
1616 | AliReconstructor* itsReconstructor = GetReconstructor(0); | |
59697224 | 1617 | if (itsReconstructor) { |
b8cd5251 | 1618 | fVertexer = itsReconstructor->CreateVertexer(fRunLoader); |
2257f27e | 1619 | } |
b8cd5251 | 1620 | if (!fVertexer) { |
815c2b38 | 1621 | AliWarning("couldn't create a vertexer for ITS"); |
2257f27e | 1622 | if (fStopOnError) return kFALSE; |
1623 | } | |
1624 | ||
1625 | return kTRUE; | |
1626 | } | |
1627 | ||
24f7a148 | 1628 | //_____________________________________________________________________________ |
b8cd5251 | 1629 | Bool_t AliReconstruction::CreateTrackers(const TString& detectors) |
24f7a148 | 1630 | { |
f08fc9f5 | 1631 | // create the trackers |
24f7a148 | 1632 | |
b8cd5251 | 1633 | TString detStr = detectors; |
1634 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
1635 | if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; | |
1636 | AliReconstructor* reconstructor = GetReconstructor(iDet); | |
1637 | if (!reconstructor) continue; | |
1638 | TString detName = fgkDetectorName[iDet]; | |
1f46a9ae | 1639 | if (detName == "HLT") { |
1640 | fRunHLTTracking = kTRUE; | |
1641 | continue; | |
1642 | } | |
e66fbafb | 1643 | if (detName == "MUON") { |
1644 | fRunMuonTracking = kTRUE; | |
1645 | continue; | |
1646 | } | |
1647 | ||
f08fc9f5 | 1648 | |
1649 | fTracker[iDet] = reconstructor->CreateTracker(fRunLoader); | |
1650 | if (!fTracker[iDet] && (iDet < 7)) { | |
1651 | AliWarning(Form("couldn't create a tracker for %s", detName.Data())); | |
8250d5f5 | 1652 | if (fStopOnError) return kFALSE; |
1653 | } | |
1654 | } | |
1655 | ||
24f7a148 | 1656 | return kTRUE; |
1657 | } | |
1658 | ||
e583c30d | 1659 | //_____________________________________________________________________________ |
b26c3770 | 1660 | void AliReconstruction::CleanUp(TFile* file, TFile* fileOld) |
e583c30d | 1661 | { |
1662 | // delete trackers and the run loader and close and delete the file | |
1663 | ||
b8cd5251 | 1664 | for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
1665 | delete fReconstructor[iDet]; | |
1666 | fReconstructor[iDet] = NULL; | |
1667 | fLoader[iDet] = NULL; | |
1668 | delete fTracker[iDet]; | |
1669 | fTracker[iDet] = NULL; | |
1670 | } | |
1671 | delete fVertexer; | |
1672 | fVertexer = NULL; | |
9178838a | 1673 | delete fDiamondProfile; |
1674 | fDiamondProfile = NULL; | |
e583c30d | 1675 | |
1676 | delete fRunLoader; | |
1677 | fRunLoader = NULL; | |
b649205a | 1678 | delete fRawReader; |
1679 | fRawReader = NULL; | |
e583c30d | 1680 | |
1681 | if (file) { | |
1682 | file->Close(); | |
1683 | delete file; | |
1684 | } | |
b26c3770 | 1685 | |
1686 | if (fileOld) { | |
1687 | fileOld->Close(); | |
1688 | delete fileOld; | |
1689 | gSystem->Unlink("AliESDs.old.root"); | |
1690 | } | |
e583c30d | 1691 | } |
24f7a148 | 1692 | |
1693 | ||
1694 | //_____________________________________________________________________________ | |
1695 | Bool_t AliReconstruction::ReadESD(AliESD*& esd, const char* recStep) const | |
1696 | { | |
1697 | // read the ESD event from a file | |
1698 | ||
1699 | if (!esd) return kFALSE; | |
1700 | char fileName[256]; | |
1701 | sprintf(fileName, "ESD_%d.%d_%s.root", | |
31fd97b2 | 1702 | esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep); |
24f7a148 | 1703 | if (gSystem->AccessPathName(fileName)) return kFALSE; |
1704 | ||
f3a97c86 | 1705 | AliInfo(Form("reading ESD from file %s", fileName)); |
815c2b38 | 1706 | AliDebug(1, Form("reading ESD from file %s", fileName)); |
24f7a148 | 1707 | TFile* file = TFile::Open(fileName); |
1708 | if (!file || !file->IsOpen()) { | |
815c2b38 | 1709 | AliError(Form("opening %s failed", fileName)); |
24f7a148 | 1710 | delete file; |
1711 | return kFALSE; | |
1712 | } | |
1713 | ||
1714 | gROOT->cd(); | |
1715 | delete esd; | |
1716 | esd = (AliESD*) file->Get("ESD"); | |
1717 | file->Close(); | |
1718 | delete file; | |
1719 | return kTRUE; | |
1720 | } | |
1721 | ||
1722 | //_____________________________________________________________________________ | |
1723 | void AliReconstruction::WriteESD(AliESD* esd, const char* recStep) const | |
1724 | { | |
1725 | // write the ESD event to a file | |
1726 | ||
1727 | if (!esd) return; | |
1728 | char fileName[256]; | |
1729 | sprintf(fileName, "ESD_%d.%d_%s.root", | |
31fd97b2 | 1730 | esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep); |
24f7a148 | 1731 | |
815c2b38 | 1732 | AliDebug(1, Form("writing ESD to file %s", fileName)); |
24f7a148 | 1733 | TFile* file = TFile::Open(fileName, "recreate"); |
1734 | if (!file || !file->IsOpen()) { | |
815c2b38 | 1735 | AliError(Form("opening %s failed", fileName)); |
24f7a148 | 1736 | } else { |
1737 | esd->Write("ESD"); | |
1738 | file->Close(); | |
1739 | } | |
1740 | delete file; | |
1741 | } | |
f3a97c86 | 1742 | |
1743 | ||
1744 | ||
1745 | ||
1746 | //_____________________________________________________________________________ | |
1747 | void AliReconstruction::CreateTag(TFile* file) | |
1748 | { | |
2bdb9d38 | 1749 | ///////////// |
1750 | //muon code// | |
1751 | //////////// | |
56982dd1 | 1752 | Double_t fMUONMASS = 0.105658369; |
2bdb9d38 | 1753 | //Variables |
56982dd1 | 1754 | Double_t fX,fY,fZ ; |
1755 | Double_t fThetaX, fThetaY, fPyz, fChisquare; | |
1756 | Double_t fPxRec,fPyRec, fPzRec, fEnergy; | |
1757 | Int_t fCharge; | |
1758 | TLorentzVector fEPvector; | |
1759 | ||
1760 | Float_t fZVertexCut = 10.0; | |
1761 | Float_t fRhoVertexCut = 2.0; | |
1762 | ||
1763 | Float_t fLowPtCut = 1.0; | |
1764 | Float_t fHighPtCut = 3.0; | |
1765 | Float_t fVeryHighPtCut = 10.0; | |
2bdb9d38 | 1766 | //////////// |
1767 | ||
1768 | Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05}; | |
1769 | ||
089bf903 | 1770 | // Creates the tags for all the events in a given ESD file |
4302e20f | 1771 | Int_t ntrack; |
089bf903 | 1772 | Int_t nProtons, nKaons, nPions, nMuons, nElectrons; |
1773 | Int_t nPos, nNeg, nNeutr; | |
1774 | Int_t nK0s, nNeutrons, nPi0s, nGamas; | |
1775 | Int_t nCh1GeV, nCh3GeV, nCh10GeV; | |
1776 | Int_t nMu1GeV, nMu3GeV, nMu10GeV; | |
1777 | Int_t nEl1GeV, nEl3GeV, nEl10GeV; | |
1778 | Float_t maxPt = .0, meanPt = .0, totalP = .0; | |
d1a50cb5 | 1779 | Int_t fVertexflag; |
1387d165 | 1780 | Int_t iRunNumber = 0; |
547d75a6 | 1781 | TString fVertexName("default"); |
4302e20f | 1782 | |
f3a97c86 | 1783 | AliRunTag *tag = new AliRunTag(); |
f3a97c86 | 1784 | AliEventTag *evTag = new AliEventTag(); |
1785 | TTree ttag("T","A Tree with event tags"); | |
2bdb9d38 | 1786 | TBranch * btag = ttag.Branch("AliTAG", &tag); |
f3a97c86 | 1787 | btag->SetCompressionLevel(9); |
2bdb9d38 | 1788 | |
f3a97c86 | 1789 | AliInfo(Form("Creating the tags.......")); |
1790 | ||
1791 | if (!file || !file->IsOpen()) { | |
1792 | AliError(Form("opening failed")); | |
1793 | delete file; | |
1794 | return ; | |
2bdb9d38 | 1795 | } |
d71aa170 | 1796 | Int_t lastEvent = 0; |
f3a97c86 | 1797 | TTree *t = (TTree*) file->Get("esdTree"); |
1798 | TBranch * b = t->GetBranch("ESD"); | |
1799 | AliESD *esd = 0; | |
1800 | b->SetAddress(&esd); | |
1387d165 | 1801 | |
d71aa170 | 1802 | b->GetEntry(fFirstEvent); |
1387d165 | 1803 | Int_t iInitRunNumber = esd->GetRunNumber(); |
2bdb9d38 | 1804 | |
bb0901a4 | 1805 | Int_t iNumberOfEvents = (Int_t)b->GetEntries(); |
d71aa170 | 1806 | if(fLastEvent != -1) iNumberOfEvents = fLastEvent + 1; |
1807 | for (Int_t iEventNumber = fFirstEvent; iEventNumber < iNumberOfEvents; iEventNumber++) { | |
2bdb9d38 | 1808 | ntrack = 0; |
1809 | nPos = 0; | |
1810 | nNeg = 0; | |
1811 | nNeutr =0; | |
1812 | nK0s = 0; | |
1813 | nNeutrons = 0; | |
1814 | nPi0s = 0; | |
1815 | nGamas = 0; | |
1816 | nProtons = 0; | |
1817 | nKaons = 0; | |
1818 | nPions = 0; | |
1819 | nMuons = 0; | |
1820 | nElectrons = 0; | |
1821 | nCh1GeV = 0; | |
1822 | nCh3GeV = 0; | |
1823 | nCh10GeV = 0; | |
1824 | nMu1GeV = 0; | |
1825 | nMu3GeV = 0; | |
1826 | nMu10GeV = 0; | |
1827 | nEl1GeV = 0; | |
1828 | nEl3GeV = 0; | |
1829 | nEl10GeV = 0; | |
1830 | maxPt = .0; | |
1831 | meanPt = .0; | |
1832 | totalP = .0; | |
547d75a6 | 1833 | fVertexflag = 0; |
d1a50cb5 | 1834 | |
2bdb9d38 | 1835 | b->GetEntry(iEventNumber); |
1387d165 | 1836 | iRunNumber = esd->GetRunNumber(); |
1837 | if(iRunNumber != iInitRunNumber) AliFatal("Inconsistency of run numbers in the AliESD!!!"); | |
2bdb9d38 | 1838 | const AliESDVertex * vertexIn = esd->GetVertex(); |
547d75a6 | 1839 | if (!vertexIn) AliError("ESD has not defined vertex."); |
1840 | if (vertexIn) fVertexName = vertexIn->GetName(); | |
1841 | if(fVertexName != "default") fVertexflag = 1; | |
2bdb9d38 | 1842 | for (Int_t iTrackNumber = 0; iTrackNumber < esd->GetNumberOfTracks(); iTrackNumber++) { |
1843 | AliESDtrack * esdTrack = esd->GetTrack(iTrackNumber); | |
1844 | UInt_t status = esdTrack->GetStatus(); | |
f3a97c86 | 1845 | |
2bdb9d38 | 1846 | //select only tracks with ITS refit |
1847 | if ((status&AliESDtrack::kITSrefit)==0) continue; | |
1848 | //select only tracks with TPC refit | |
1849 | if ((status&AliESDtrack::kTPCrefit)==0) continue; | |
4302e20f | 1850 | |
2bdb9d38 | 1851 | //select only tracks with the "combined PID" |
1852 | if ((status&AliESDtrack::kESDpid)==0) continue; | |
1853 | Double_t p[3]; | |
1854 | esdTrack->GetPxPyPz(p); | |
1855 | Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2)); | |
1856 | Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2)); | |
1857 | totalP += momentum; | |
1858 | meanPt += fPt; | |
1859 | if(fPt > maxPt) maxPt = fPt; | |
4302e20f | 1860 | |
2bdb9d38 | 1861 | if(esdTrack->GetSign() > 0) { |
1862 | nPos++; | |
56982dd1 | 1863 | if(fPt > fLowPtCut) nCh1GeV++; |
1864 | if(fPt > fHighPtCut) nCh3GeV++; | |
1865 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
2bdb9d38 | 1866 | } |
1867 | if(esdTrack->GetSign() < 0) { | |
1868 | nNeg++; | |
56982dd1 | 1869 | if(fPt > fLowPtCut) nCh1GeV++; |
1870 | if(fPt > fHighPtCut) nCh3GeV++; | |
1871 | if(fPt > fVeryHighPtCut) nCh10GeV++; | |
2bdb9d38 | 1872 | } |
1873 | if(esdTrack->GetSign() == 0) nNeutr++; | |
4302e20f | 1874 | |
2bdb9d38 | 1875 | //PID |
1876 | Double_t prob[5]; | |
1877 | esdTrack->GetESDpid(prob); | |
4302e20f | 1878 | |
2bdb9d38 | 1879 | Double_t rcc = 0.0; |
1880 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) rcc += prob[i]*partFrac[i]; | |
1881 | if(rcc == 0.0) continue; | |
1882 | //Bayes' formula | |
1883 | Double_t w[5]; | |
1884 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) w[i] = prob[i]*partFrac[i]/rcc; | |
4302e20f | 1885 | |
2bdb9d38 | 1886 | //protons |
1887 | if ((w[4]>w[3])&&(w[4]>w[2])&&(w[4]>w[1])&&(w[4]>w[0])) nProtons++; | |
1888 | //kaons | |
1889 | if ((w[3]>w[4])&&(w[3]>w[2])&&(w[3]>w[1])&&(w[3]>w[0])) nKaons++; | |
1890 | //pions | |
1891 | if ((w[2]>w[4])&&(w[2]>w[3])&&(w[2]>w[1])&&(w[2]>w[0])) nPions++; | |
1892 | //electrons | |
1893 | if ((w[0]>w[4])&&(w[0]>w[3])&&(w[0]>w[2])&&(w[0]>w[1])) { | |
1894 | nElectrons++; | |
56982dd1 | 1895 | if(fPt > fLowPtCut) nEl1GeV++; |
1896 | if(fPt > fHighPtCut) nEl3GeV++; | |
1897 | if(fPt > fVeryHighPtCut) nEl10GeV++; | |
2bdb9d38 | 1898 | } |
1899 | ntrack++; | |
1900 | }//track loop | |
1901 | ||
1902 | ///////////// | |
1903 | //muon code// | |
1904 | //////////// | |
1905 | Int_t nMuonTracks = esd->GetNumberOfMuonTracks(); | |
1906 | // loop over all reconstructed tracks (also first track of combination) | |
1907 | for (Int_t iTrack = 0; iTrack < nMuonTracks; iTrack++) { | |
1908 | AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack); | |
1909 | if (muonTrack == 0x0) continue; | |
4302e20f | 1910 | |
2bdb9d38 | 1911 | // Coordinates at vertex |
56982dd1 | 1912 | fZ = muonTrack->GetZ(); |
1913 | fY = muonTrack->GetBendingCoor(); | |
1914 | fX = muonTrack->GetNonBendingCoor(); | |
4302e20f | 1915 | |
56982dd1 | 1916 | fThetaX = muonTrack->GetThetaX(); |
1917 | fThetaY = muonTrack->GetThetaY(); | |
4302e20f | 1918 | |
56982dd1 | 1919 | fPyz = 1./TMath::Abs(muonTrack->GetInverseBendingMomentum()); |
1920 | fPzRec = - fPyz / TMath::Sqrt(1.0 + TMath::Tan(fThetaY)*TMath::Tan(fThetaY)); | |
1921 | fPxRec = fPzRec * TMath::Tan(fThetaX); | |
1922 | fPyRec = fPzRec * TMath::Tan(fThetaY); | |
1923 | fCharge = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum())); | |
f3a97c86 | 1924 | |
2bdb9d38 | 1925 | //ChiSquare of the track if needed |
56982dd1 | 1926 | fChisquare = muonTrack->GetChi2()/(2.0 * muonTrack->GetNHit() - 5); |
1927 | fEnergy = TMath::Sqrt(fMUONMASS * fMUONMASS + fPxRec * fPxRec + fPyRec * fPyRec + fPzRec * fPzRec); | |
1928 | fEPvector.SetPxPyPzE(fPxRec, fPyRec, fPzRec, fEnergy); | |
4302e20f | 1929 | |
2bdb9d38 | 1930 | // total number of muons inside a vertex cut |
56982dd1 | 1931 | if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) { |
2bdb9d38 | 1932 | nMuons++; |
56982dd1 | 1933 | if(fEPvector.Pt() > fLowPtCut) { |
2bdb9d38 | 1934 | nMu1GeV++; |
56982dd1 | 1935 | if(fEPvector.Pt() > fHighPtCut) { |
2bdb9d38 | 1936 | nMu3GeV++; |
56982dd1 | 1937 | if (fEPvector.Pt() > fVeryHighPtCut) { |
2bdb9d38 | 1938 | nMu10GeV++; |
1939 | } | |
1940 | } | |
1941 | } | |
1942 | } | |
1943 | }//muon track loop | |
1944 | ||
1945 | // Fill the event tags | |
1946 | if(ntrack != 0) | |
1947 | meanPt = meanPt/ntrack; | |
1948 | ||
1949 | evTag->SetEventId(iEventNumber+1); | |
547d75a6 | 1950 | if (vertexIn) { |
1951 | evTag->SetVertexX(vertexIn->GetXv()); | |
1952 | evTag->SetVertexY(vertexIn->GetYv()); | |
1953 | evTag->SetVertexZ(vertexIn->GetZv()); | |
1954 | evTag->SetVertexZError(vertexIn->GetZRes()); | |
1955 | } | |
d1a50cb5 | 1956 | evTag->SetVertexFlag(fVertexflag); |
1957 | ||
2bdb9d38 | 1958 | evTag->SetT0VertexZ(esd->GetT0zVertex()); |
1959 | ||
8bd8ac26 | 1960 | evTag->SetTriggerMask(esd->GetTriggerMask()); |
1961 | evTag->SetTriggerCluster(esd->GetTriggerCluster()); | |
2bdb9d38 | 1962 | |
32a5cab4 | 1963 | evTag->SetZDCNeutron1Energy(esd->GetZDCN1Energy()); |
1964 | evTag->SetZDCProton1Energy(esd->GetZDCP1Energy()); | |
1965 | evTag->SetZDCNeutron2Energy(esd->GetZDCN2Energy()); | |
1966 | evTag->SetZDCProton2Energy(esd->GetZDCP2Energy()); | |
2bdb9d38 | 1967 | evTag->SetZDCEMEnergy(esd->GetZDCEMEnergy()); |
1968 | evTag->SetNumOfParticipants(esd->GetZDCParticipants()); | |
1969 | ||
1970 | ||
1971 | evTag->SetNumOfTracks(esd->GetNumberOfTracks()); | |
1972 | evTag->SetNumOfPosTracks(nPos); | |
1973 | evTag->SetNumOfNegTracks(nNeg); | |
1974 | evTag->SetNumOfNeutrTracks(nNeutr); | |
1975 | ||
1976 | evTag->SetNumOfV0s(esd->GetNumberOfV0s()); | |
1977 | evTag->SetNumOfCascades(esd->GetNumberOfCascades()); | |
1978 | evTag->SetNumOfKinks(esd->GetNumberOfKinks()); | |
1979 | evTag->SetNumOfPMDTracks(esd->GetNumberOfPmdTracks()); | |
1980 | ||
1981 | evTag->SetNumOfProtons(nProtons); | |
1982 | evTag->SetNumOfKaons(nKaons); | |
1983 | evTag->SetNumOfPions(nPions); | |
1984 | evTag->SetNumOfMuons(nMuons); | |
1985 | evTag->SetNumOfElectrons(nElectrons); | |
1986 | evTag->SetNumOfPhotons(nGamas); | |
1987 | evTag->SetNumOfPi0s(nPi0s); | |
1988 | evTag->SetNumOfNeutrons(nNeutrons); | |
1989 | evTag->SetNumOfKaon0s(nK0s); | |
1990 | ||
1991 | evTag->SetNumOfChargedAbove1GeV(nCh1GeV); | |
1992 | evTag->SetNumOfChargedAbove3GeV(nCh3GeV); | |
1993 | evTag->SetNumOfChargedAbove10GeV(nCh10GeV); | |
1994 | evTag->SetNumOfMuonsAbove1GeV(nMu1GeV); | |
1995 | evTag->SetNumOfMuonsAbove3GeV(nMu3GeV); | |
1996 | evTag->SetNumOfMuonsAbove10GeV(nMu10GeV); | |
1997 | evTag->SetNumOfElectronsAbove1GeV(nEl1GeV); | |
1998 | evTag->SetNumOfElectronsAbove3GeV(nEl3GeV); | |
1999 | evTag->SetNumOfElectronsAbove10GeV(nEl10GeV); | |
2000 | ||
85c60a8e | 2001 | evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters()); |
2002 | evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters()); | |
2bdb9d38 | 2003 | |
2004 | evTag->SetTotalMomentum(totalP); | |
2005 | evTag->SetMeanPt(meanPt); | |
2006 | evTag->SetMaxPt(maxPt); | |
2007 | ||
1387d165 | 2008 | tag->SetRunId(iInitRunNumber); |
2bdb9d38 | 2009 | tag->AddEventTag(*evTag); |
2010 | } | |
bb0901a4 | 2011 | if(fLastEvent == -1) lastEvent = (Int_t)b->GetEntries(); |
d71aa170 | 2012 | else lastEvent = fLastEvent; |
f3a97c86 | 2013 | |
2014 | ttag.Fill(); | |
2015 | tag->Clear(); | |
2016 | ||
2017 | char fileName[256]; | |
2018 | sprintf(fileName, "Run%d.Event%d_%d.ESD.tag.root", | |
d71aa170 | 2019 | tag->GetRunId(),fFirstEvent,lastEvent ); |
f3a97c86 | 2020 | AliInfo(Form("writing tags to file %s", fileName)); |
2021 | AliDebug(1, Form("writing tags to file %s", fileName)); | |
2022 | ||
2023 | TFile* ftag = TFile::Open(fileName, "recreate"); | |
2024 | ftag->cd(); | |
2025 | ttag.Write(); | |
2026 | ftag->Close(); | |
2027 | file->cd(); | |
2028 | delete tag; | |
f3a97c86 | 2029 | delete evTag; |
2030 | } | |
2031 | ||
a7807689 | 2032 | //_____________________________________________________________________________ |
2033 | void AliReconstruction::CreateAOD(TFile* esdFile) | |
2034 | { | |
2035 | // do nothing for now | |
2036 | ||
2037 | return; | |
2038 | } | |
2039 | ||
2040 | ||
98937d93 | 2041 | void AliReconstruction::WriteAlignmentData(AliESD* esd) |
2042 | { | |
2043 | // Write space-points which are then used in the alignment procedures | |
2044 | // For the moment only ITS, TRD and TPC | |
2045 | ||
2046 | // Load TOF clusters | |
d528ee75 | 2047 | if (fTracker[3]){ |
2048 | fLoader[3]->LoadRecPoints("read"); | |
2049 | TTree* tree = fLoader[3]->TreeR(); | |
2050 | if (!tree) { | |
2051 | AliError(Form("Can't get the %s cluster tree", fgkDetectorName[3])); | |
2052 | return; | |
2053 | } | |
2054 | fTracker[3]->LoadClusters(tree); | |
98937d93 | 2055 | } |
98937d93 | 2056 | Int_t ntracks = esd->GetNumberOfTracks(); |
2057 | for (Int_t itrack = 0; itrack < ntracks; itrack++) | |
2058 | { | |
2059 | AliESDtrack *track = esd->GetTrack(itrack); | |
2060 | Int_t nsp = 0; | |
ef7253ac | 2061 | Int_t idx[200]; |
98937d93 | 2062 | for (Int_t iDet = 3; iDet >= 0; iDet--) |
2063 | nsp += track->GetNcls(iDet); | |
2064 | if (nsp) { | |
2065 | AliTrackPointArray *sp = new AliTrackPointArray(nsp); | |
2066 | track->SetTrackPointArray(sp); | |
2067 | Int_t isptrack = 0; | |
2068 | for (Int_t iDet = 3; iDet >= 0; iDet--) { | |
2069 | AliTracker *tracker = fTracker[iDet]; | |
2070 | if (!tracker) continue; | |
2071 | Int_t nspdet = track->GetNcls(iDet); | |
98937d93 | 2072 | if (nspdet <= 0) continue; |
2073 | track->GetClusters(iDet,idx); | |
2074 | AliTrackPoint p; | |
2075 | Int_t isp = 0; | |
2076 | Int_t isp2 = 0; | |
2077 | while (isp < nspdet) { | |
2078 | Bool_t isvalid = tracker->GetTrackPoint(idx[isp2],p); isp2++; | |
160db090 | 2079 | const Int_t kNTPCmax = 159; |
2080 | if (iDet==1 && isp2>kNTPCmax) break; // to be fixed | |
98937d93 | 2081 | if (!isvalid) continue; |
2082 | sp->AddPoint(isptrack,&p); isptrack++; isp++; | |
2083 | } | |
98937d93 | 2084 | } |
2085 | } | |
2086 | } | |
d528ee75 | 2087 | if (fTracker[3]){ |
2088 | fTracker[3]->UnloadClusters(); | |
2089 | fLoader[3]->UnloadRecPoints(); | |
2090 | } | |
98937d93 | 2091 | } |
2e3550da | 2092 | |
2093 | //_____________________________________________________________________________ | |
2094 | void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESD* esd) | |
2095 | { | |
2096 | // The method reads the raw-data error log | |
2097 | // accumulated within the rawReader. | |
2098 | // It extracts the raw-data errors related to | |
2099 | // the current event and stores them into | |
2100 | // a TClonesArray inside the esd object. | |
2101 | ||
2102 | if (!fRawReader) return; | |
2103 | ||
2104 | for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) { | |
2105 | ||
2106 | AliRawDataErrorLog *log = fRawReader->GetErrorLog(i); | |
2107 | if (!log) continue; | |
2108 | if (iEvent != log->GetEventNumber()) continue; | |
2109 | ||
2110 | esd->AddRawDataErrorLog(log); | |
2111 | } | |
2112 | ||
2113 | } |