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