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 void AliTOF::SetTOFSectors(Int_t *sectors)
163 // Setter for partial/full TOF configuration
165 for(Int_t isec=0;isec<18;isec++){
166 fTOFSectors[isec]=sectors[isec];
169 //____________________________________________________________________________
170 void AliTOF::GetTOFSectors(Int_t *sectors) const
172 // Getter for partial/full TOF configuration
174 for(Int_t isec=0;isec<18;isec++){
175 sectors[isec]=fTOFSectors[isec];
178 //_____________________________________________________________________________
179 AliTOF::AliTOF(const AliTOF &source)
184 this->fReconParticles=source.fReconParticles;
185 this->fSDigits=source.fSDigits;
186 this->fTOFGeometry=source.fTOFGeometry;
190 //_____________________________________________________________________________
191 AliTOF& AliTOF::operator=(const AliTOF &source)
195 this->fReconParticles=source.fReconParticles;
196 this->fSDigits=source.fSDigits;
197 this->fTOFGeometry=source.fTOFGeometry;
202 //_____________________________________________________________________________
203 void AliTOF::CreateTOFFolders()
205 // create the ALICE TFolder
206 // create the ALICE TTasks
207 // create the ALICE main TFolder
208 // to be done by AliRun
210 TFolder * alice = new TFolder();
211 alice->SetNameTitle("FPAlice", "Alice Folder") ;
212 gROOT->GetListOfBrowsables()->Add(alice) ;
214 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
215 // make it the owner of the objects that it contains
218 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
219 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
220 // make it the owner of the objects that it contains
223 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
224 aliceT->Add(aliceDi);
226 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
227 aliceT->Add(aliceRe);
229 char * tempo = new char[80] ;
231 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
232 sprintf(tempo, "%sDigitizers container",GetName() ) ;
233 fDTask = new TTask(GetName(), tempo);
234 aliceDi->Add(fDTask) ;
236 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
237 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
238 fReTask = new TTask(GetName(), tempo);
239 aliceRe->Add(fReTask) ;
243 // creates the TOF geometry folder
244 geomF->AddFolder("TOF", "Geometry for TOF") ;
247 //_____________________________________________________________________________
251 // it remove also the alice folder
252 // and task that TOF creates instead of AliRun
253 /* PH Temporarily commented because of problems
254 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
279 fReconParticles->Delete ();
280 delete fReconParticles;
286 //_____________________________________________________________________________
287 void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
291 // new with placement used
293 TClonesArray &lhits = *fHits;
294 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
297 //_____________________________________________________________________________
298 void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
302 // new with placement used
304 TClonesArray &lhits = *fHits;
305 new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
308 //_____________________________________________________________________________
309 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
313 // new with placement used
315 TClonesArray &ldigits = *fDigits;
316 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
319 //_____________________________________________________________________________
320 void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
327 TClonesArray &lSDigits = *fSDigits;
328 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
331 //_____________________________________________________________________________
332 void AliTOF::SetTreeAddress ()
334 // Set branch address for the Hits and Digits Tree.
336 if (fLoader->TreeH())
340 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
341 else fHits = new TClonesArray("AliTOFhit", 1000);
344 AliDetector::SetTreeAddress ();
348 if (fLoader->TreeS () )
350 branch = fLoader->TreeS ()->GetBranch ("TOF");
352 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
353 branch->SetAddress (&fSDigits);
357 if (fLoader->TreeR() )
359 branch = fLoader->TreeR()->GetBranch("TOF");
362 if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000);
363 branch->SetAddress(&fReconParticles);
368 if (fLoader->TreeR() && fReconParticles) //I do not know where this array is created - skowron
370 branch = fLoader->TreeR()->GetBranch("TOF");
373 branch->SetAddress(&fReconParticles) ;
379 //_____________________________________________________________________________
380 void AliTOF::CreateGeometry()
383 // Common geometry code
387 <img src="picts/AliTOFv23.gif">
394 if (IsVersion()==7) {
396 xTof = 124.5;//fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm, x-dimension of FTOA volume
397 yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin(); // cm, y-dimension of FTOA volume
398 Float_t zTof = fTOFGeometry->ZlenA(); // cm, z-dimension of FTOA volume
400 // TOF module internal definitions
401 TOFpc(xTof, yTof, zTof, fTOFGeometry->ZlenB());
405 Float_t wall = 4.;//cm // frame inbetween TOF modules
407 // Sizes of TOF module with its support etc..
408 xTof = 2.*(fTOFGeometry->Rmin()*TMath::Tan(10.*kDegrad)-wall/2.-0.5);
409 yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin();
411 // TOF module internal definitions
412 TOFpc(xTof, yTof, fTOFGeometry->ZlenC(), fTOFGeometry->ZlenB(), fTOFGeometry->ZlenA(), fTOFGeometry->MaxhZtof());
417 //_____________________________________________________________________________
418 void AliTOF::DrawModule() const
421 // Draw a shaded view of the common part of the TOF geometry
424 AliInfo(" Drawing of AliTOF");
425 // Set everything unseen
426 gMC->Gsatt("*", "seen", -1);
428 // Set ALIC mother transparent
429 gMC->Gsatt("ALIC","SEEN",0);
431 // Set the volumes visible
432 gMC->Gsatt("FTOA","SEEN",1);
433 gMC->Gsatt("FTOB","SEEN",1);
434 gMC->Gsatt("FTOC","SEEN",1);
435 gMC->Gsatt("FLTA","SEEN",1);
436 gMC->Gsatt("FLTB","SEEN",1);
437 gMC->Gsatt("FLTC","SEEN",1);
438 gMC->Gsatt("FSTR","SEEN",1);
440 gMC->Gdopt("hide", "on");
441 gMC->Gdopt("shad", "on");
442 gMC->Gsatt("*", "fill", 7);
443 gMC->SetClipBox(".");
444 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
446 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
447 gMC->Gdhead(1111, "Time Of Flight");
448 gMC->Gdman(18, 4, "MAN");
449 gMC->Gdopt("hide","off");
452 //_____________________________________________________________________________
453 Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t )
456 // Returns distance from mouse pointer to detector, default version
461 //___________________________________________
462 void AliTOF::ResetHits ()
464 // Reset number of clusters and the cluster array for this detector
465 AliDetector::ResetHits ();
468 //____________________________________________
469 void AliTOF::ResetDigits ()
472 // Reset number of digits and the digits array for this detector
473 AliDetector::ResetDigits ();
476 //____________________________________________
477 void AliTOF::ResetSDigits ()
480 // Reset number of sdigits and the sdigits array for this detector
485 //_____________________________________________________________________________
489 // Initialise TOF detector after it has been built
491 // Set id of TOF sensitive volume
492 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
496 TDirectory* saveDir = gDirectory;
497 gAlice->GetRunLoader()->CdGAFile();
498 fTOFGeometry->Write("TOFGeometry");
503 //____________________________________________________________________________
504 void AliTOF::MakeBranch(Option_t* option)
507 // Initializes the Branches of the TOF inside the
508 // trees written for each event.
509 // AliDetector::MakeBranch initializes just the
510 // Branch inside TreeH. Here we add the branches in
511 // TreeD, TreeS and TreeR.
513 const char *oH = strstr(option,"H");
514 if (fLoader->TreeH() && oH)
518 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
519 else fHits = new TClonesArray("AliTOFhit", 1000);
523 AliDetector::MakeBranch(option);
525 Int_t buffersize = 4000;
526 Char_t branchname[10];
527 sprintf(branchname,"%s",GetName());
529 const char *oD = strstr(option,"D");
530 const char *oS = strstr(option,"S");
531 const char *oR = strstr(option,"R");
533 if (fLoader->TreeD() && oD){
534 if (fDigits == 0x0) fDigits = new TClonesArray("AliTOFdigit", 1000);
535 MakeBranchInTree(fLoader->TreeD(), branchname, &fDigits,buffersize, 0) ;
538 if (fLoader->TreeS() && oS){
539 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
540 MakeBranchInTree(fLoader->TreeS(), branchname, &fSDigits,buffersize, 0) ;
543 if (fLoader->TreeR() && oR){
544 if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000);
545 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
549 if (fReconParticles && fLoader->TreeR() && oR){
550 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
555 //____________________________________________________________________________
556 void AliTOF::Makehits(Bool_t hits)
558 // default argument used, see AliTOF.h
559 // Enable/Disable the writing of the TOF-hits branch
561 // by default : enabled for TOFv1, v2, v3, v4, v5
562 // disabled for TOFv0
564 if (hits && (IsVersion()!=0))
565 fIdSens = gMC->VolId("FPAD");
567 AliInfo("Option for writing the TOF-hits branch on TreeH: disabled");
570 //____________________________________________________________________________
571 void AliTOF::FinishEvent()
576 //____________________________________________________________________________
577 void AliTOF::Hits2SDigits()
580 // Use the TOF SDigitizer to make TOF SDigits
583 // AliInfo("Start...");
585 AliRunLoader * rl = fLoader->GetRunLoader();
586 AliTOFSDigitizer sd((rl->GetFileName()).Data());
587 ToAliDebug(1, sd.Print(""));
593 //____________________________________________________________________________
594 void AliTOF::Hits2SDigits(Int_t evNumber1, Int_t evNumber2)
597 // Use the TOF SDigitizer to make TOF SDigits
600 if ((evNumber2-evNumber1)==1)
601 AliDebug(1, Form("I am making sdigits for the %dth event", evNumber1))
602 else if ((evNumber2-evNumber1)>1)
603 AliDebug(1, Form("I am making sdigits for the events from the "
604 "%dth to the %dth", evNumber1, evNumber2-1));
606 AliRunLoader * rl = fLoader->GetRunLoader();
607 AliTOFSDigitizer sd((rl->GetFileName()).Data(),evNumber1,evNumber2) ;
608 ToAliDebug(1, sd.Print(""));
614 //___________________________________________________________________________
615 AliDigitizer* AliTOF::CreateDigitizer(AliRunDigitizer* manager) const
617 return new AliTOFDigitizer(manager);
620 //___________________________________________________________________________
621 Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
624 // Checks if 2 or more hits belong to the same pad.
625 // In this case the data assigned to the digit object
626 // are the ones of the first hit in order of Time.
627 // 2 hits from the same track on the same pad are collected.
628 // Called only by Hits2SDigits.
629 // This procedure has to be optimized in the next TOF release.
632 Bool_t overlap = kFALSE;
635 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
636 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
637 currentDigit->GetLocation(vol2);
639 // check on digit volume
640 for (Int_t i=0;i<=4;i++){
642 if (vol[i]!=vol2[i]) idem=kFALSE;}
644 if (idem){ // same pad fired
645 Float_t tdc2 = digit[0];
646 Float_t tdc1 = currentDigit->GetTdc();
648 // we separate two digits on the same pad if
649 // they are separated in time by at least 25 ns
650 // remember that tdc time is given in ps
652 if (TMath::Abs(tdc1-tdc2)<25000){
653 // in case of overlap we take the earliest
655 currentDigit->SetTdc(tdc2);
656 currentDigit->SetAdc(digit[1]);
659 currentDigit->SetTdc(tdc1);
660 currentDigit->SetAdc(digit[1]);
662 currentDigit->AddTrack(Track); // add track number in the track array
668 } // close if (idem) -> two digits on the same TOF pad
670 } // end loop on existing sdigits
674 //____________________________________________________________________________
675 void AliTOF::Digits2Raw()
678 // Starting from the TOF digits, writes the Raw Data objects
681 fLoader->LoadDigits();
683 TTree* digits = fLoader->TreeD();
685 AliError("no digits tree");
689 //AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
690 fRunLoader->CdGAFile();
691 TFile *in=(TFile*)gFile;
693 AliTOFGeometry *geometry = (AliTOFGeometry*)in->Get("TOFgeometry");
695 AliTOFDDLRawData rawWriter(geometry);
696 //AliTOFDDLRawData rawWriter;
697 rawWriter.SetVerbose(0);
699 AliInfo("Formatting raw data for TOF");
701 rawWriter.RawDataTOF(digits->GetBranch("TOF"));
703 fLoader->UnloadDigits();
707 //____________________________________________________________________________
708 void AliTOF::RecreateSDigitsArray() {
710 // delete TClonesArray fSDigits and create it again
711 // needed for backward compatability with PPR test production
714 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
716 //____________________________________________________________________________
717 void AliTOF::CreateSDigitsArray() {
719 // create TClonesArray fSDigits
720 // needed for backward compatability with PPR test production
722 fSDigits = new TClonesArray("AliTOFSDigit", 1000);