]>
Commit | Line | Data |
---|---|---|
4c039060 | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
68861244 | 17 | |
fe4da5cc | 18 | /////////////////////////////////////////////////////////////////////////////// |
19 | // // | |
68861244 | 20 | // Time Of Flight // |
fe4da5cc | 21 | // This class contains the basic functions for the Time Of Flight // |
22 | // detector. Functions specific to one particular geometry are // | |
23 | // contained in the derived classes // | |
d3c7bfac | 24 | // // |
25 | // VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS // | |
26 | // ============================================================ // | |
27 | // // | |
28 | // VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES // | |
29 | // // | |
30 | // Volume sensibile : FPAD // | |
31 | // // | |
32 | // // | |
33 | // // | |
34 | // // | |
35 | /////////////////////////////////////////////////////////////////////////////// | |
937fe4a4 | 36 | // Begin_Html |
fe4da5cc | 37 | /* |
1439f98e | 38 | <img src="picts/AliTOFClass.gif"> |
fe4da5cc | 39 | */ |
40 | //End_Html | |
d3c7bfac | 41 | |
7ca4655f | 42 | #include <TClonesArray.h> |
43 | #include <TFile.h> | |
44 | #include <TFolder.h> | |
45 | #include <TROOT.h> | |
46 | #include <TTask.h> | |
47 | #include <TTree.h> | |
48 | #include <TVirtualMC.h> | |
515faf5d | 49 | #include <TStopwatch.h> |
fe4da5cc | 50 | |
88cb7938 | 51 | #include "AliConst.h" |
52 | #include "AliLoader.h" | |
0e46b9ae | 53 | #include "AliLog.h" |
54 | #include "AliMC.h" | |
88cb7938 | 55 | #include "AliRun.h" |
0e46b9ae | 56 | |
57 | #include "AliTOFDDLRawData.h" | |
58 | #include "AliTOFDigitizer.h" | |
88cb7938 | 59 | #include "AliTOFdigit.h" |
88cb7938 | 60 | #include "AliTOFhitT0.h" |
0e46b9ae | 61 | #include "AliTOFhit.h" |
62 | #include "AliTOFGeometry.h" | |
63 | #include "AliTOFSDigitizer.h" | |
64 | #include "AliTOFSDigit.h" | |
65 | #include "AliTOF.h" | |
66 | ||
67 | class AliTOFcluster; | |
68 | ||
69 | extern TFile *gFile; | |
70 | extern TROOT *gROOT; | |
71 | extern TVirtualMC *gMC; | |
72 | ||
73 | extern AliRun *gAlice; | |
74 | ||
fe4da5cc | 75 | |
76 | ClassImp(AliTOF) | |
77 | ||
78 | //_____________________________________________________________________________ | |
655e379f | 79 | AliTOF::AliTOF(): |
80 | fFGeom(0x0), | |
81 | fDTask(0x0), | |
82 | fReTask(0x0), | |
83 | fSDigits(0x0), | |
84 | fNSDigits(0), | |
85 | fReconParticles(0x0), | |
86 | fIdSens(-1), | |
87 | fTZero(kFALSE), | |
88 | fTOFGeometry(0x0) | |
fe4da5cc | 89 | { |
90 | // | |
91 | // Default constructor | |
92 | // | |
0e9dd0cf | 93 | |
94 | //by default all sectors switched on | |
95 | for (Int_t ii=0; ii<18; ii++) fTOFSectors[ii]=0; | |
96 | ||
655e379f | 97 | fDigits = 0; |
fe4da5cc | 98 | fIshunt = 0; |
655e379f | 99 | fName = "TOF"; |
fe4da5cc | 100 | } |
101 | ||
102 | //_____________________________________________________________________________ | |
792995c1 | 103 | AliTOF::AliTOF(const char *name, const char *title, Option_t *option) |
655e379f | 104 | : |
105 | AliDetector(name,title), | |
106 | fFGeom(0x0), | |
107 | fDTask(0x0), | |
108 | fReTask(0x0), | |
109 | fSDigits(0x0), | |
110 | fNSDigits(0), | |
111 | fReconParticles(0x0), | |
112 | fIdSens(-1), | |
113 | fTZero(kFALSE), | |
114 | fTOFGeometry(0x0) | |
fe4da5cc | 115 | { |
116 | // | |
117 | // AliTOF standard constructor | |
118 | // | |
2cef3cb2 | 119 | // Here are fixed some important parameters |
120 | // | |
121 | ||
68861244 | 122 | // Initialization of hits, sdigits and digits array |
d599d913 | 123 | // added option for time zero analysis |
655e379f | 124 | //skowron |
d3c7bfac | 125 | fTOFGeometry = new AliTOFGeometry(); |
88cb7938 | 126 | |
0e9dd0cf | 127 | //by default all sectors switched on |
128 | for (Int_t ii=0; ii<18; ii++) fTOFSectors[ii]=0; | |
129 | ||
d599d913 | 130 | if (strstr(option,"tzero")){ |
131 | fHits = new TClonesArray("AliTOFhitT0", 1000); | |
88cb7938 | 132 | fTZero = kTRUE; |
655e379f | 133 | // AliWarning("tzero option requires AliTOFv4T0/AliTOFv5T0 as TOF version (check Your Config.C)"); |
d599d913 | 134 | }else{ |
135 | fHits = new TClonesArray("AliTOFhit", 1000); | |
88cb7938 | 136 | fTZero = kFALSE; |
d599d913 | 137 | } |
c630aafd | 138 | if (gAlice==0) { |
d076c8d5 | 139 | AliFatal("gAlice==0 !"); |
c630aafd | 140 | } |
0e46b9ae | 141 | |
142 | AliMC *mcApplication = (AliMC*)gAlice->GetMCApp(); | |
143 | ||
144 | if (mcApplication->GetHitLists()) | |
145 | mcApplication->AddHitList(fHits); | |
d076c8d5 | 146 | else AliError("gAlice->GetHitLists()==0"); |
c630aafd | 147 | |
2cef3cb2 | 148 | fIshunt = 0; |
7e6dce66 | 149 | fSDigits = new TClonesArray("AliTOFSDigit", 1000); |
150 | fDigits = new TClonesArray("AliTOFdigit", 1000); | |
00711221 | 151 | |
2cef3cb2 | 152 | // |
153 | // Digitization parameters | |
fe4da5cc | 154 | // |
2cef3cb2 | 155 | // (Transfer Functions to be inserted here) |
fe4da5cc | 156 | // |
e939a978 | 157 | //PH SetMarkerColor(7); |
158 | //PH SetMarkerStyle(2); | |
159 | //PH SetMarkerSize(0.4); | |
2cef3cb2 | 160 | |
2cef3cb2 | 161 | // Strip Parameters |
7e6dce66 | 162 | //fGapA = 4.; //cm Gap beetween tilted strip in A-type plate |
163 | //fGapB = 6.; //cm Gap beetween tilted strip in B-type plate | |
164 | ||
165 | // Physical performances | |
166 | //fTimeRes = 100.;//ps | |
167 | //fChrgRes = 100.;//pC | |
168 | ||
68861244 | 169 | } |
170 | ||
06e24a91 | 171 | //____________________________________________________________________________ |
d0eb8f39 | 172 | void AliTOF::SetTOFSectors(Int_t *sectors) |
173 | { | |
174 | // Setter for partial/full TOF configuration | |
175 | ||
06e24a91 | 176 | for(Int_t isec=0;isec<18;isec++){ |
177 | fTOFSectors[isec]=sectors[isec]; | |
178 | } | |
179 | } | |
180 | //____________________________________________________________________________ | |
d0eb8f39 | 181 | void AliTOF::GetTOFSectors(Int_t *sectors) const |
182 | { | |
183 | // Getter for partial/full TOF configuration | |
06e24a91 | 184 | |
185 | for(Int_t isec=0;isec<18;isec++){ | |
186 | sectors[isec]=fTOFSectors[isec]; | |
187 | } | |
188 | } | |
7aeeaf38 | 189 | //_____________________________________________________________________________ |
190 | AliTOF::AliTOF(const AliTOF &source) | |
655e379f | 191 | :AliDetector(), |
192 | fFGeom(0x0), | |
193 | fDTask(0x0), | |
194 | fReTask(0x0), | |
195 | fSDigits(0x0), | |
196 | fNSDigits(0), | |
197 | fReconParticles(0x0), | |
198 | fIdSens(-1), | |
199 | fTZero(kFALSE), | |
200 | fTOFGeometry(0x0) | |
7aeeaf38 | 201 | { |
202 | // copy constructor | |
203 | ||
204 | this->fReconParticles=source.fReconParticles; | |
205 | this->fSDigits=source.fSDigits; | |
206 | this->fTOFGeometry=source.fTOFGeometry; | |
207 | ||
208 | } | |
209 | ||
210 | //_____________________________________________________________________________ | |
211 | AliTOF& AliTOF::operator=(const AliTOF &source) | |
212 | { | |
213 | // ass. op. | |
214 | ||
215 | this->fReconParticles=source.fReconParticles; | |
216 | this->fSDigits=source.fSDigits; | |
217 | this->fTOFGeometry=source.fTOFGeometry; | |
218 | return *this; | |
219 | ||
220 | } | |
221 | ||
68861244 | 222 | //_____________________________________________________________________________ |
223 | void AliTOF::CreateTOFFolders() | |
224 | { | |
225 | // create the ALICE TFolder | |
226 | // create the ALICE TTasks | |
227 | // create the ALICE main TFolder | |
228 | // to be done by AliRun | |
229 | ||
230 | TFolder * alice = new TFolder(); | |
231 | alice->SetNameTitle("FPAlice", "Alice Folder") ; | |
232 | gROOT->GetListOfBrowsables()->Add(alice) ; | |
233 | ||
234 | TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ; | |
235 | // make it the owner of the objects that it contains | |
236 | aliceF->SetOwner() ; | |
237 | // geometry folder | |
238 | TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ; | |
239 | TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ; | |
240 | // make it the owner of the objects that it contains | |
241 | aliceT->SetOwner() ; | |
242 | ||
243 | TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ; | |
244 | aliceT->Add(aliceDi); | |
245 | ||
246 | TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ; | |
247 | aliceT->Add(aliceRe); | |
248 | ||
249 | char * tempo = new char[80] ; | |
250 | ||
251 | // creates the TOF Digitizer and adds it to alice main (S)Digitizer task | |
252 | sprintf(tempo, "%sDigitizers container",GetName() ) ; | |
253 | fDTask = new TTask(GetName(), tempo); | |
254 | aliceDi->Add(fDTask) ; | |
255 | ||
256 | // creates the TOF reconstructioner and adds it to alice main Reconstructioner task | |
257 | sprintf(tempo, "%sReconstructioner container",GetName() ) ; | |
258 | fReTask = new TTask(GetName(), tempo); | |
259 | aliceRe->Add(fReTask) ; | |
260 | ||
3ff0c331 | 261 | delete [] tempo ; |
68861244 | 262 | |
263 | // creates the TOF geometry folder | |
264 | geomF->AddFolder("TOF", "Geometry for TOF") ; | |
265 | } | |
266 | ||
267 | //_____________________________________________________________________________ | |
268 | AliTOF::~AliTOF() | |
269 | { | |
517b7f8f | 270 | // dtor: |
271 | // it remove also the alice folder | |
68861244 | 272 | // and task that TOF creates instead of AliRun |
5839f074 | 273 | /* PH Temporarily commented because of problems |
68861244 | 274 | TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ; |
275 | delete alice; | |
276 | alice = 0; | |
5839f074 | 277 | */ |
517b7f8f | 278 | if (fHits) |
279 | { | |
280 | fHits->Delete (); | |
281 | delete fHits; | |
282 | fHits = 0; | |
283 | } | |
284 | if (fDigits) | |
285 | { | |
286 | fDigits->Delete (); | |
287 | delete fDigits; | |
288 | fDigits = 0; | |
289 | } | |
290 | if (fSDigits) | |
291 | { | |
88cb7938 | 292 | fSDigits->Delete(); |
517b7f8f | 293 | delete fSDigits; |
294 | fSDigits = 0; | |
295 | } | |
571dda3d | 296 | |
517b7f8f | 297 | if (fReconParticles) |
298 | { | |
299 | fReconParticles->Delete (); | |
300 | delete fReconParticles; | |
301 | fReconParticles = 0; | |
302 | } | |
303 | ||
fe4da5cc | 304 | } |
305 | ||
306 | //_____________________________________________________________________________ | |
2cef3cb2 | 307 | void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits) |
fe4da5cc | 308 | { |
309 | // | |
310 | // Add a TOF hit | |
68861244 | 311 | // new with placement used |
fe4da5cc | 312 | // |
313 | TClonesArray &lhits = *fHits; | |
2cef3cb2 | 314 | new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits); |
fe4da5cc | 315 | } |
d599d913 | 316 | |
317 | //_____________________________________________________________________________ | |
318 | void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits) | |
319 | { | |
320 | // | |
321 | // Add a TOF hit | |
322 | // new with placement used | |
323 | // | |
324 | TClonesArray &lhits = *fHits; | |
325 | new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits); | |
326 | } | |
327 | ||
fe4da5cc | 328 | //_____________________________________________________________________________ |
bf33f8f0 | 329 | void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Int_t *digits) |
fe4da5cc | 330 | { |
331 | // | |
2cef3cb2 | 332 | // Add a TOF digit |
68861244 | 333 | // new with placement used |
2cef3cb2 | 334 | // |
335 | TClonesArray &ldigits = *fDigits; | |
336 | new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits); | |
fe4da5cc | 337 | } |
338 | ||
d3c7bfac | 339 | //_____________________________________________________________________________ |
bf33f8f0 | 340 | void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Int_t *digits) |
517b7f8f | 341 | { |
342 | ||
343 | // | |
344 | // Add a TOF sdigit | |
345 | // | |
346 | ||
347 | TClonesArray &lSDigits = *fSDigits; | |
5919c40c | 348 | new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits); |
517b7f8f | 349 | } |
350 | ||
351 | //_____________________________________________________________________________ | |
352 | void AliTOF::SetTreeAddress () | |
353 | { | |
354 | // Set branch address for the Hits and Digits Tree. | |
88cb7938 | 355 | |
356 | if (fLoader->TreeH()) | |
357 | { | |
358 | if (fHits == 0x0) | |
359 | { | |
360 | if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000); | |
361 | else fHits = new TClonesArray("AliTOFhit", 1000); | |
362 | } | |
363 | } | |
517b7f8f | 364 | AliDetector::SetTreeAddress (); |
365 | ||
366 | TBranch *branch; | |
517b7f8f | 367 | |
88cb7938 | 368 | if (fLoader->TreeS () ) |
517b7f8f | 369 | { |
88cb7938 | 370 | branch = fLoader->TreeS ()->GetBranch ("TOF"); |
371 | if (branch) { | |
372 | if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000); | |
373 | branch->SetAddress (&fSDigits); | |
374 | } | |
517b7f8f | 375 | } |
376 | ||
571dda3d | 377 | if (fLoader->TreeR() ) |
378 | { | |
379 | branch = fLoader->TreeR()->GetBranch("TOF"); | |
380 | if (branch) | |
381 | { | |
382 | if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000); | |
383 | branch->SetAddress(&fReconParticles); | |
384 | } | |
385 | } | |
386 | ||
387 | /* | |
88cb7938 | 388 | if (fLoader->TreeR() && fReconParticles) //I do not know where this array is created - skowron |
517b7f8f | 389 | { |
88cb7938 | 390 | branch = fLoader->TreeR()->GetBranch("TOF"); |
391 | if (branch) | |
392 | { | |
393 | branch->SetAddress(&fReconParticles) ; | |
394 | } | |
571dda3d | 395 | } |
396 | */ | |
517b7f8f | 397 | } |
2cef3cb2 | 398 | |
fe4da5cc | 399 | //_____________________________________________________________________________ |
400 | void AliTOF::CreateGeometry() | |
401 | { | |
402 | // | |
3fe3a833 | 403 | // Common geometry code |
fe4da5cc | 404 | // |
405 | //Begin_Html | |
406 | /* | |
1439f98e | 407 | <img src="picts/AliTOFv23.gif"> |
fe4da5cc | 408 | */ |
409 | //End_Html | |
410 | // | |
937fe4a4 | 411 | |
d3c7bfac | 412 | Float_t xTof, yTof; |
413 | ||
dfef1a15 | 414 | if (IsVersion()==8) { |
415 | ||
416 | xTof = 124.5;//fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm, x-dimension of FTOA volume | |
417 | yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin(); // cm, y-dimension of FTOA volume | |
418 | Float_t zTof = fTOFGeometry->ZlenA(); // cm, z-dimension of FTOA volume | |
419 | ||
420 | // TOF module internal definitions | |
421 | TOFpc(xTof, yTof, zTof); | |
422 | ||
423 | } else if (IsVersion()==7) { | |
d3c7bfac | 424 | |
1ac1b685 | 425 | xTof = 124.5;//fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm, x-dimension of FTOA volume |
d3c7bfac | 426 | yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin(); // cm, y-dimension of FTOA volume |
427 | Float_t zTof = fTOFGeometry->ZlenA(); // cm, z-dimension of FTOA volume | |
428 | ||
429 | // TOF module internal definitions | |
430 | TOFpc(xTof, yTof, zTof, fTOFGeometry->ZlenB()); | |
3fe3a833 | 431 | |
d3c7bfac | 432 | } else { |
433 | ||
434 | Float_t wall = 4.;//cm // frame inbetween TOF modules | |
435 | ||
436 | // Sizes of TOF module with its support etc.. | |
437 | xTof = 2.*(fTOFGeometry->Rmin()*TMath::Tan(10.*kDegrad)-wall/2.-0.5); | |
438 | yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin(); | |
439 | ||
440 | // TOF module internal definitions | |
441 | TOFpc(xTof, yTof, fTOFGeometry->ZlenC(), fTOFGeometry->ZlenB(), fTOFGeometry->ZlenA(), fTOFGeometry->MaxhZtof()); | |
442 | } | |
3fe3a833 | 443 | |
fe4da5cc | 444 | } |
445 | ||
446 | //_____________________________________________________________________________ | |
ba380e33 | 447 | void AliTOF::DrawModule() const |
fe4da5cc | 448 | { |
449 | // | |
450 | // Draw a shaded view of the common part of the TOF geometry | |
fe4da5cc | 451 | // |
452 | ||
d076c8d5 | 453 | AliInfo(" Drawing of AliTOF"); |
fe4da5cc | 454 | // Set everything unseen |
cfce8870 | 455 | gMC->Gsatt("*", "seen", -1); |
fe4da5cc | 456 | // |
457 | // Set ALIC mother transparent | |
cfce8870 | 458 | gMC->Gsatt("ALIC","SEEN",0); |
fe4da5cc | 459 | // |
460 | // Set the volumes visible | |
2cef3cb2 | 461 | gMC->Gsatt("FTOA","SEEN",1); |
462 | gMC->Gsatt("FTOB","SEEN",1); | |
463 | gMC->Gsatt("FTOC","SEEN",1); | |
464 | gMC->Gsatt("FLTA","SEEN",1); | |
465 | gMC->Gsatt("FLTB","SEEN",1); | |
466 | gMC->Gsatt("FLTC","SEEN",1); | |
467 | gMC->Gsatt("FSTR","SEEN",1); | |
cfce8870 | 468 | // |
469 | gMC->Gdopt("hide", "on"); | |
470 | gMC->Gdopt("shad", "on"); | |
471 | gMC->Gsatt("*", "fill", 7); | |
472 | gMC->SetClipBox("."); | |
473 | gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000); | |
474 | gMC->DefaultRange(); | |
475 | gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02); | |
476 | gMC->Gdhead(1111, "Time Of Flight"); | |
477 | gMC->Gdman(18, 4, "MAN"); | |
478 | gMC->Gdopt("hide","off"); | |
fe4da5cc | 479 | } |
480 | ||
fe4da5cc | 481 | //_____________________________________________________________________________ |
0e46b9ae | 482 | Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) |
fe4da5cc | 483 | { |
484 | // | |
485 | // Returns distance from mouse pointer to detector, default version | |
486 | // | |
487 | return 9999; | |
488 | } | |
517b7f8f | 489 | |
490 | //___________________________________________ | |
491 | void AliTOF::ResetHits () | |
492 | { | |
493 | // Reset number of clusters and the cluster array for this detector | |
494 | AliDetector::ResetHits (); | |
495 | } | |
496 | ||
497 | //____________________________________________ | |
498 | void AliTOF::ResetDigits () | |
499 | { | |
500 | // | |
501 | // Reset number of digits and the digits array for this detector | |
502 | AliDetector::ResetDigits (); | |
503 | // | |
504 | } | |
d61f73d9 | 505 | //____________________________________________ |
506 | void AliTOF::ResetSDigits () | |
507 | { | |
508 | // | |
509 | // Reset number of sdigits and the sdigits array for this detector | |
510 | fNSDigits = 0; | |
e615b5b5 | 511 | //fSDigits = 0x0; |
d61f73d9 | 512 | // |
513 | } | |
fe4da5cc | 514 | //_____________________________________________________________________________ |
515 | void AliTOF::Init() | |
516 | { | |
517 | // | |
518 | // Initialise TOF detector after it has been built | |
519 | // | |
fe4da5cc | 520 | // Set id of TOF sensitive volume |
937fe4a4 | 521 | if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD"); |
d3c7bfac | 522 | |
523 | /* | |
d076c8d5 | 524 | // Save the geometry |
525 | TDirectory* saveDir = gDirectory; | |
526 | gAlice->GetRunLoader()->CdGAFile(); | |
527 | fTOFGeometry->Write("TOFGeometry"); | |
528 | saveDir->cd(); | |
d3c7bfac | 529 | */ |
fe4da5cc | 530 | } |
531 | ||
2cef3cb2 | 532 | //____________________________________________________________________________ |
88cb7938 | 533 | void AliTOF::MakeBranch(Option_t* option) |
2cef3cb2 | 534 | { |
b94fa26c | 535 | // |
536 | // Initializes the Branches of the TOF inside the | |
537 | // trees written for each event. | |
517b7f8f | 538 | // AliDetector::MakeBranch initializes just the |
68861244 | 539 | // Branch inside TreeH. Here we add the branches in |
517b7f8f | 540 | // TreeD, TreeS and TreeR. |
b94fa26c | 541 | // |
88cb7938 | 542 | const char *oH = strstr(option,"H"); |
543 | if (fLoader->TreeH() && oH) | |
544 | { | |
545 | if (fHits == 0x0) | |
546 | { | |
547 | if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000); | |
548 | else fHits = new TClonesArray("AliTOFhit", 1000); | |
549 | } | |
550 | } | |
551 | ||
552 | AliDetector::MakeBranch(option); | |
2cef3cb2 | 553 | |
554 | Int_t buffersize = 4000; | |
555 | Char_t branchname[10]; | |
556 | sprintf(branchname,"%s",GetName()); | |
2ab0c725 | 557 | |
68861244 | 558 | const char *oD = strstr(option,"D"); |
559 | const char *oS = strstr(option,"S"); | |
517b7f8f | 560 | const char *oR = strstr(option,"R"); |
68861244 | 561 | |
88cb7938 | 562 | if (fLoader->TreeD() && oD){ |
563 | if (fDigits == 0x0) fDigits = new TClonesArray("AliTOFdigit", 1000); | |
564 | MakeBranchInTree(fLoader->TreeD(), branchname, &fDigits,buffersize, 0) ; | |
2cef3cb2 | 565 | } |
68861244 | 566 | |
88cb7938 | 567 | if (fLoader->TreeS() && oS){ |
568 | if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000); | |
569 | MakeBranchInTree(fLoader->TreeS(), branchname, &fSDigits,buffersize, 0) ; | |
68861244 | 570 | } |
571 | ||
571dda3d | 572 | if (fLoader->TreeR() && oR){ |
573 | if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000); | |
574 | MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ; | |
575 | } | |
576 | ||
577 | /* | |
88cb7938 | 578 | if (fReconParticles && fLoader->TreeR() && oR){ |
579 | MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ; | |
517b7f8f | 580 | } |
571dda3d | 581 | */ |
68861244 | 582 | } |
583 | ||
584 | //____________________________________________________________________________ | |
585 | void AliTOF::Makehits(Bool_t hits) | |
586 | { | |
587 | // default argument used, see AliTOF.h | |
588 | // Enable/Disable the writing of the TOF-hits branch | |
589 | // on TreeH | |
d3c7bfac | 590 | // by default : enabled for TOFv1, v2, v3, v4, v5 |
68861244 | 591 | // disabled for TOFv0 |
592 | // | |
593 | if (hits && (IsVersion()!=0)) | |
594 | fIdSens = gMC->VolId("FPAD"); | |
595 | else | |
d076c8d5 | 596 | AliInfo("Option for writing the TOF-hits branch on TreeH: disabled"); |
2cef3cb2 | 597 | } |
598 | ||
599 | //____________________________________________________________________________ | |
600 | void AliTOF::FinishEvent() | |
601 | { | |
68861244 | 602 | // do nothing |
2cef3cb2 | 603 | } |
604 | ||
d3c7bfac | 605 | //____________________________________________________________________________ |
517b7f8f | 606 | void AliTOF::Hits2SDigits() |
607 | { | |
608 | // | |
609 | // Use the TOF SDigitizer to make TOF SDigits | |
610 | // | |
d61f73d9 | 611 | |
0e46b9ae | 612 | // AliInfo("Start..."); |
68861244 | 613 | |
be385a87 | 614 | AliRunLoader * rl = fLoader->GetRunLoader(); |
615 | AliTOFSDigitizer sd((rl->GetFileName()).Data()); | |
d076c8d5 | 616 | ToAliDebug(1, sd.Print("")); |
68861244 | 617 | |
be385a87 | 618 | sd.Exec("") ; |
d61f73d9 | 619 | |
620 | } | |
621 | ||
d3c7bfac | 622 | //____________________________________________________________________________ |
d61f73d9 | 623 | void AliTOF::Hits2SDigits(Int_t evNumber1, Int_t evNumber2) |
624 | { | |
625 | // | |
626 | // Use the TOF SDigitizer to make TOF SDigits | |
627 | // | |
628 | ||
629 | if ((evNumber2-evNumber1)==1) | |
96f8ea5a | 630 | AliDebug(1, Form("I am making sdigits for the %dth event", evNumber1)); |
631 | if ((evNumber2-evNumber1)>1) | |
632 | AliDebug(1, Form("I am making sdigits for the events from the %dth to the %dth", evNumber1, evNumber2-1)); | |
d61f73d9 | 633 | |
be385a87 | 634 | AliRunLoader * rl = fLoader->GetRunLoader(); |
635 | AliTOFSDigitizer sd((rl->GetFileName()).Data(),evNumber1,evNumber2) ; | |
d076c8d5 | 636 | ToAliDebug(1, sd.Print("")); |
68861244 | 637 | |
be385a87 | 638 | sd.Exec("") ; |
d61f73d9 | 639 | |
2cef3cb2 | 640 | } |
d61f73d9 | 641 | |
2cef3cb2 | 642 | //___________________________________________________________________________ |
c92eb8ad | 643 | AliDigitizer* AliTOF::CreateDigitizer(AliRunDigitizer* manager) const |
85a5290f | 644 | { |
645 | return new AliTOFDigitizer(manager); | |
646 | } | |
647 | ||
648 | //___________________________________________________________________________ | |
bf33f8f0 | 649 | Bool_t AliTOF::CheckOverlap(Int_t* vol, Int_t* digit,Int_t Track) |
b94fa26c | 650 | { |
2cef3cb2 | 651 | // |
652 | // Checks if 2 or more hits belong to the same pad. | |
653 | // In this case the data assigned to the digit object | |
654 | // are the ones of the first hit in order of Time. | |
517b7f8f | 655 | // 2 hits from the same track on the same pad are collected. |
656 | // Called only by Hits2SDigits. | |
657 | // This procedure has to be optimized in the next TOF release. | |
2cef3cb2 | 658 | // |
b94fa26c | 659 | |
d3c7bfac | 660 | Bool_t overlap = kFALSE; |
661 | Int_t vol2[5]; | |
662 | ||
663 | for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){ | |
664 | AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig)); | |
665 | currentDigit->GetLocation(vol2); | |
666 | Bool_t idem= kTRUE; | |
667 | // check on digit volume | |
668 | for (Int_t i=0;i<=4;i++){ | |
669 | if (!idem) break; | |
670 | if (vol[i]!=vol2[i]) idem=kFALSE;} | |
671 | ||
672 | if (idem){ // same pad fired | |
bf33f8f0 | 673 | Int_t tdc2 = digit[0]; |
674 | Int_t tdc1 = currentDigit->GetTdc(); | |
d3c7bfac | 675 | |
676 | // we separate two digits on the same pad if | |
677 | // they are separated in time by at least 25 ns | |
678 | // remember that tdc time is given in ps | |
679 | ||
680 | if (TMath::Abs(tdc1-tdc2)<25000){ | |
681 | // in case of overlap we take the earliest | |
682 | if (tdc1>tdc2){ | |
683 | currentDigit->SetTdc(tdc2); | |
684 | currentDigit->SetAdc(digit[1]); | |
685 | } | |
686 | else { | |
687 | currentDigit->SetTdc(tdc1); | |
688 | currentDigit->SetAdc(digit[1]); | |
689 | } | |
690 | currentDigit->AddTrack(Track); // add track number in the track array | |
691 | overlap = kTRUE; | |
692 | return overlap; | |
693 | } else | |
bf33f8f0 | 694 | overlap= kFALSE; |
517b7f8f | 695 | |
d3c7bfac | 696 | } // close if (idem) -> two digits on the same TOF pad |
517b7f8f | 697 | |
d3c7bfac | 698 | } // end loop on existing sdigits |
517b7f8f | 699 | |
d3c7bfac | 700 | return overlap; |
2cef3cb2 | 701 | } |
2cef3cb2 | 702 | //____________________________________________________________________________ |
7e6dce66 | 703 | void AliTOF::Digits2Raw() |
b94fa26c | 704 | { |
2cef3cb2 | 705 | // |
7e6dce66 | 706 | // Starting from the TOF digits, writes the Raw Data objects |
2cef3cb2 | 707 | // |
708 | ||
515faf5d | 709 | TStopwatch stopwatch; |
710 | stopwatch.Start(); | |
711 | ||
7e6dce66 | 712 | fLoader->LoadDigits(); |
2cef3cb2 | 713 | |
7e6dce66 | 714 | TTree* digits = fLoader->TreeD(); |
715 | if (!digits) { | |
d076c8d5 | 716 | AliError("no digits tree"); |
7e6dce66 | 717 | return; |
718 | } | |
2cef3cb2 | 719 | |
80ecd4d6 | 720 | /* |
d3c7bfac | 721 | fRunLoader->CdGAFile(); |
722 | TFile *in=(TFile*)gFile; | |
723 | in->cd(); | |
724 | AliTOFGeometry *geometry = (AliTOFGeometry*)in->Get("TOFgeometry"); | |
80ecd4d6 | 725 | */ |
726 | AliTOFDDLRawData rawWriter; | |
d3c7bfac | 727 | //AliTOFDDLRawData rawWriter; |
5b8979d4 | 728 | rawWriter.SetVerbose(0); |
515faf5d | 729 | //rawWriter.SetFakeOrphaneProduction(kTRUE); |
730 | //rawWriter.SetPackedAcquisitionMode(kFALSE); | |
731 | if (rawWriter.GetPackedAcquisitionMode()) { | |
732 | if(rawWriter.GetMatchingWindow()>8192) | |
dfef1a15 | 733 | AliWarning(Form("You are running in packing mode and the matching window is %.2f ns, i.e. greater than 199.8848 ns", |
f45f1432 | 734 | rawWriter.GetMatchingWindow()*AliTOFGeometry::TdcBinWidth()*1.e-03)); |
515faf5d | 735 | } |
2cef3cb2 | 736 | |
ba795372 | 737 | AliDebug(1,"Formatting raw data for TOF"); |
7e6dce66 | 738 | digits->GetEvent(0); |
739 | rawWriter.RawDataTOF(digits->GetBranch("TOF")); | |
2cef3cb2 | 740 | |
7e6dce66 | 741 | fLoader->UnloadDigits(); |
742 | ||
515faf5d | 743 | AliDebug(1, Form("Execution time to write TOF raw data : R:%.2fs C:%.2fs", |
744 | stopwatch.RealTime(),stopwatch.CpuTime())); | |
745 | ||
7e6dce66 | 746 | } |
d3c7bfac | 747 | |
748 | //____________________________________________________________________________ | |
55991c8b | 749 | void AliTOF::RecreateSDigitsArray() { |
750 | // | |
751 | // delete TClonesArray fSDigits and create it again | |
752 | // needed for backward compatability with PPR test production | |
753 | // | |
754 | delete fSDigits; | |
755 | fSDigits = new TClonesArray("AliTOFSDigit", 1000); | |
756 | } | |
d3c7bfac | 757 | //____________________________________________________________________________ |
55991c8b | 758 | void AliTOF::CreateSDigitsArray() { |
759 | // | |
760 | // create TClonesArray fSDigits | |
761 | // needed for backward compatability with PPR test production | |
762 | // | |
763 | fSDigits = new TClonesArray("AliTOFSDigit", 1000); | |
764 | } |