1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
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 //
25 // VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS //
26 // ============================================================ //
28 // VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES //
30 // Volume sensibile : FPAD //
35 ///////////////////////////////////////////////////////////////////////////////
38 <img src="picts/AliTOFClass.gif">
47 #include "TVirtualMC.h"
50 #include "AliLoader.h"
55 #include "AliTOFDDLRawData.h"
56 #include "AliTOFDigitizer.h"
57 #include "AliTOFdigit.h"
58 #include "AliTOFhitT0.h"
59 #include "AliTOFhit.h"
60 #include "AliTOFGeometry.h"
61 #include "AliTOFSDigitizer.h"
62 #include "AliTOFSDigit.h"
69 extern TVirtualMC *gMC;
71 extern AliRun *gAlice;
76 //_____________________________________________________________________________
80 // Default constructor
89 fReconParticles = 0x0;
95 //_____________________________________________________________________________
96 AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
97 : AliDetector(name,title)
100 // AliTOF standard constructor
102 // Here are fixed some important parameters
105 // Initialization of hits, sdigits and digits array
106 // added option for time zero analysis
107 fFGeom = 0x0; //skowron
110 fReconParticles= 0x0;
111 fTOFGeometry = new AliTOFGeometry();
113 if (strstr(option,"tzero")){
114 fHits = new TClonesArray("AliTOFhitT0", 1000);
116 AliWarning("tzero option requires AliTOFv4T0/AliTOFv5T0 as TOF version (check Your Config.C)");
118 fHits = new TClonesArray("AliTOFhit", 1000);
122 AliFatal("gAlice==0 !");
125 AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
127 if (mcApplication->GetHitLists())
128 mcApplication->AddHitList(fHits);
129 else AliError("gAlice->GetHitLists()==0");
132 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
133 fDigits = new TClonesArray("AliTOFdigit", 1000);
139 fReconParticles = 0x0;
142 // Digitization parameters
144 // (Transfer Functions to be inserted here)
151 //fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
152 //fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
154 // Physical performances
155 //fTimeRes = 100.;//ps
156 //fChrgRes = 100.;//pC
160 //_____________________________________________________________________________
161 AliTOF::AliTOF(const AliTOF &source)
166 this->fReconParticles=source.fReconParticles;
167 this->fSDigits=source.fSDigits;
168 this->fTOFGeometry=source.fTOFGeometry;
172 //_____________________________________________________________________________
173 AliTOF& AliTOF::operator=(const AliTOF &source)
177 this->fReconParticles=source.fReconParticles;
178 this->fSDigits=source.fSDigits;
179 this->fTOFGeometry=source.fTOFGeometry;
184 //_____________________________________________________________________________
185 void AliTOF::CreateTOFFolders()
187 // create the ALICE TFolder
188 // create the ALICE TTasks
189 // create the ALICE main TFolder
190 // to be done by AliRun
192 TFolder * alice = new TFolder();
193 alice->SetNameTitle("FPAlice", "Alice Folder") ;
194 gROOT->GetListOfBrowsables()->Add(alice) ;
196 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
197 // make it the owner of the objects that it contains
200 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
201 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
202 // make it the owner of the objects that it contains
205 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
206 aliceT->Add(aliceDi);
208 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
209 aliceT->Add(aliceRe);
211 char * tempo = new char[80] ;
213 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
214 sprintf(tempo, "%sDigitizers container",GetName() ) ;
215 fDTask = new TTask(GetName(), tempo);
216 aliceDi->Add(fDTask) ;
218 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
219 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
220 fReTask = new TTask(GetName(), tempo);
221 aliceRe->Add(fReTask) ;
225 // creates the TOF geometry folder
226 geomF->AddFolder("TOF", "Geometry for TOF") ;
229 //_____________________________________________________________________________
233 // it remove also the alice folder
234 // and task that TOF creates instead of AliRun
235 /* PH Temporarily commented because of problems
236 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
261 fReconParticles->Delete ();
262 delete fReconParticles;
268 //_____________________________________________________________________________
269 void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
273 // new with placement used
275 TClonesArray &lhits = *fHits;
276 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
279 //_____________________________________________________________________________
280 void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
284 // new with placement used
286 TClonesArray &lhits = *fHits;
287 new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
290 //_____________________________________________________________________________
291 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
295 // new with placement used
297 TClonesArray &ldigits = *fDigits;
298 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
301 //_____________________________________________________________________________
302 void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
309 TClonesArray &lSDigits = *fSDigits;
310 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
313 //_____________________________________________________________________________
314 void AliTOF::SetTreeAddress ()
316 // Set branch address for the Hits and Digits Tree.
318 if (fLoader->TreeH())
322 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
323 else fHits = new TClonesArray("AliTOFhit", 1000);
326 AliDetector::SetTreeAddress ();
330 if (fLoader->TreeS () )
332 branch = fLoader->TreeS ()->GetBranch ("TOF");
334 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
335 branch->SetAddress (&fSDigits);
339 if (fLoader->TreeR() )
341 branch = fLoader->TreeR()->GetBranch("TOF");
344 if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000);
345 branch->SetAddress(&fReconParticles);
350 if (fLoader->TreeR() && fReconParticles) //I do not know where this array is created - skowron
352 branch = fLoader->TreeR()->GetBranch("TOF");
355 branch->SetAddress(&fReconParticles) ;
361 //_____________________________________________________________________________
362 void AliTOF::CreateGeometry()
365 // Common geometry code
369 <img src="picts/AliTOFv23.gif">
376 if (IsVersion()==7) {
378 xTof = 124.5;//fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm, x-dimension of FTOA volume
379 yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin(); // cm, y-dimension of FTOA volume
380 Float_t zTof = fTOFGeometry->ZlenA(); // cm, z-dimension of FTOA volume
382 // TOF module internal definitions
383 TOFpc(xTof, yTof, zTof, fTOFGeometry->ZlenB());
387 Float_t wall = 4.;//cm // frame inbetween TOF modules
389 // Sizes of TOF module with its support etc..
390 xTof = 2.*(fTOFGeometry->Rmin()*TMath::Tan(10.*kDegrad)-wall/2.-0.5);
391 yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin();
393 // TOF module internal definitions
394 TOFpc(xTof, yTof, fTOFGeometry->ZlenC(), fTOFGeometry->ZlenB(), fTOFGeometry->ZlenA(), fTOFGeometry->MaxhZtof());
399 //_____________________________________________________________________________
400 void AliTOF::DrawModule() const
403 // Draw a shaded view of the common part of the TOF geometry
406 AliInfo(" Drawing of AliTOF");
407 // Set everything unseen
408 gMC->Gsatt("*", "seen", -1);
410 // Set ALIC mother transparent
411 gMC->Gsatt("ALIC","SEEN",0);
413 // Set the volumes visible
414 gMC->Gsatt("FTOA","SEEN",1);
415 gMC->Gsatt("FTOB","SEEN",1);
416 gMC->Gsatt("FTOC","SEEN",1);
417 gMC->Gsatt("FLTA","SEEN",1);
418 gMC->Gsatt("FLTB","SEEN",1);
419 gMC->Gsatt("FLTC","SEEN",1);
420 gMC->Gsatt("FSTR","SEEN",1);
422 gMC->Gdopt("hide", "on");
423 gMC->Gdopt("shad", "on");
424 gMC->Gsatt("*", "fill", 7);
425 gMC->SetClipBox(".");
426 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
428 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
429 gMC->Gdhead(1111, "Time Of Flight");
430 gMC->Gdman(18, 4, "MAN");
431 gMC->Gdopt("hide","off");
434 //_____________________________________________________________________________
435 Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t )
438 // Returns distance from mouse pointer to detector, default version
443 //___________________________________________
444 void AliTOF::ResetHits ()
446 // Reset number of clusters and the cluster array for this detector
447 AliDetector::ResetHits ();
450 //____________________________________________
451 void AliTOF::ResetDigits ()
454 // Reset number of digits and the digits array for this detector
455 AliDetector::ResetDigits ();
458 //____________________________________________
459 void AliTOF::ResetSDigits ()
462 // Reset number of sdigits and the sdigits array for this detector
467 //_____________________________________________________________________________
471 // Initialise TOF detector after it has been built
473 // Set id of TOF sensitive volume
474 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
478 TDirectory* saveDir = gDirectory;
479 gAlice->GetRunLoader()->CdGAFile();
480 fTOFGeometry->Write("TOFGeometry");
485 //____________________________________________________________________________
486 void AliTOF::MakeBranch(Option_t* option)
489 // Initializes the Branches of the TOF inside the
490 // trees written for each event.
491 // AliDetector::MakeBranch initializes just the
492 // Branch inside TreeH. Here we add the branches in
493 // TreeD, TreeS and TreeR.
495 const char *oH = strstr(option,"H");
496 if (fLoader->TreeH() && oH)
500 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
501 else fHits = new TClonesArray("AliTOFhit", 1000);
505 AliDetector::MakeBranch(option);
507 Int_t buffersize = 4000;
508 Char_t branchname[10];
509 sprintf(branchname,"%s",GetName());
511 const char *oD = strstr(option,"D");
512 const char *oS = strstr(option,"S");
513 const char *oR = strstr(option,"R");
515 if (fLoader->TreeD() && oD){
516 if (fDigits == 0x0) fDigits = new TClonesArray("AliTOFdigit", 1000);
517 MakeBranchInTree(fLoader->TreeD(), branchname, &fDigits,buffersize, 0) ;
520 if (fLoader->TreeS() && oS){
521 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
522 MakeBranchInTree(fLoader->TreeS(), branchname, &fSDigits,buffersize, 0) ;
525 if (fLoader->TreeR() && oR){
526 if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000);
527 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
531 if (fReconParticles && fLoader->TreeR() && oR){
532 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
537 //____________________________________________________________________________
538 void AliTOF::Makehits(Bool_t hits)
540 // default argument used, see AliTOF.h
541 // Enable/Disable the writing of the TOF-hits branch
543 // by default : enabled for TOFv1, v2, v3, v4, v5
544 // disabled for TOFv0
546 if (hits && (IsVersion()!=0))
547 fIdSens = gMC->VolId("FPAD");
549 AliInfo("Option for writing the TOF-hits branch on TreeH: disabled");
552 //____________________________________________________________________________
553 void AliTOF::FinishEvent()
558 //____________________________________________________________________________
559 void AliTOF::Hits2SDigits()
562 // Use the TOF SDigitizer to make TOF SDigits
565 // AliInfo("Start...");
567 AliRunLoader * rl = fLoader->GetRunLoader();
568 AliTOFSDigitizer sd((rl->GetFileName()).Data());
569 ToAliDebug(1, sd.Print(""));
575 //____________________________________________________________________________
576 void AliTOF::Hits2SDigits(Int_t evNumber1, Int_t evNumber2)
579 // Use the TOF SDigitizer to make TOF SDigits
582 if ((evNumber2-evNumber1)==1)
583 AliDebug(1, Form("I am making sdigits for the %dth event", evNumber1))
584 else if ((evNumber2-evNumber1)>1)
585 AliDebug(1, Form("I am making sdigits for the events from the "
586 "%dth to the %dth", evNumber1, evNumber2-1));
588 AliRunLoader * rl = fLoader->GetRunLoader();
589 AliTOFSDigitizer sd((rl->GetFileName()).Data(),evNumber1,evNumber2) ;
590 ToAliDebug(1, sd.Print(""));
596 //___________________________________________________________________________
597 AliDigitizer* AliTOF::CreateDigitizer(AliRunDigitizer* manager) const
599 return new AliTOFDigitizer(manager);
602 //___________________________________________________________________________
603 Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
606 // Checks if 2 or more hits belong to the same pad.
607 // In this case the data assigned to the digit object
608 // are the ones of the first hit in order of Time.
609 // 2 hits from the same track on the same pad are collected.
610 // Called only by Hits2SDigits.
611 // This procedure has to be optimized in the next TOF release.
614 Bool_t overlap = kFALSE;
617 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
618 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
619 currentDigit->GetLocation(vol2);
621 // check on digit volume
622 for (Int_t i=0;i<=4;i++){
624 if (vol[i]!=vol2[i]) idem=kFALSE;}
626 if (idem){ // same pad fired
627 Float_t tdc2 = digit[0];
628 Float_t tdc1 = currentDigit->GetTdc();
630 // we separate two digits on the same pad if
631 // they are separated in time by at least 25 ns
632 // remember that tdc time is given in ps
634 if (TMath::Abs(tdc1-tdc2)<25000){
635 // in case of overlap we take the earliest
637 currentDigit->SetTdc(tdc2);
638 currentDigit->SetAdc(digit[1]);
641 currentDigit->SetTdc(tdc1);
642 currentDigit->SetAdc(digit[1]);
644 currentDigit->AddTrack(Track); // add track number in the track array
650 } // close if (idem) -> two digits on the same TOF pad
652 } // end loop on existing sdigits
656 //____________________________________________________________________________
657 void AliTOF::Digits2Raw()
660 // Starting from the TOF digits, writes the Raw Data objects
663 fLoader->LoadDigits();
665 TTree* digits = fLoader->TreeD();
667 AliError("no digits tree");
671 //AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
672 fRunLoader->CdGAFile();
673 TFile *in=(TFile*)gFile;
675 AliTOFGeometry *geometry = (AliTOFGeometry*)in->Get("TOFgeometry");
677 AliTOFDDLRawData rawWriter(geometry);
678 //AliTOFDDLRawData rawWriter;
679 rawWriter.SetVerbose(0);
681 AliInfo("Formatting raw data for TOF");
683 rawWriter.RawDataTOF(digits->GetBranch("TOF"));
685 fLoader->UnloadDigits();
689 //____________________________________________________________________________
690 void AliTOF::RecreateSDigitsArray() {
692 // delete TClonesArray fSDigits and create it again
693 // needed for backward compatability with PPR test production
696 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
698 //____________________________________________________________________________
699 void AliTOF::CreateSDigitsArray() {
701 // create TClonesArray fSDigits
702 // needed for backward compatability with PPR test production
704 fSDigits = new TClonesArray("AliTOFSDigit", 1000);