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