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 //_____________________________________________________________________________
89 // Default constructor
96 //_____________________________________________________________________________
97 AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
99 AliDetector(name,title),
105 fReconParticles(0x0),
111 // AliTOF standard constructor
113 // Here are fixed some important parameters
116 // Initialization of hits, sdigits and digits array
117 // added option for time zero analysis
119 fTOFGeometry = new AliTOFGeometry();
121 if (strstr(option,"tzero")){
122 fHits = new TClonesArray("AliTOFhitT0", 1000);
124 // AliWarning("tzero option requires AliTOFv4T0/AliTOFv5T0 as TOF version (check Your Config.C)");
126 fHits = new TClonesArray("AliTOFhit", 1000);
130 AliFatal("gAlice==0 !");
133 AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
135 if (mcApplication->GetHitLists())
136 mcApplication->AddHitList(fHits);
137 else AliError("gAlice->GetHitLists()==0");
140 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
141 fDigits = new TClonesArray("AliTOFdigit", 1000);
144 // Digitization parameters
146 // (Transfer Functions to be inserted here)
148 //PH SetMarkerColor(7);
149 //PH SetMarkerStyle(2);
150 //PH SetMarkerSize(0.4);
153 //fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
154 //fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
156 // Physical performances
157 //fTimeRes = 100.;//ps
158 //fChrgRes = 100.;//pC
162 //____________________________________________________________________________
163 void AliTOF::SetTOFSectors(Int_t *sectors)
165 // Setter for partial/full TOF configuration
167 for(Int_t isec=0;isec<18;isec++){
168 fTOFSectors[isec]=sectors[isec];
171 //____________________________________________________________________________
172 void AliTOF::GetTOFSectors(Int_t *sectors) const
174 // Getter for partial/full TOF configuration
176 for(Int_t isec=0;isec<18;isec++){
177 sectors[isec]=fTOFSectors[isec];
180 //_____________________________________________________________________________
181 AliTOF::AliTOF(const AliTOF &source)
188 fReconParticles(0x0),
195 this->fReconParticles=source.fReconParticles;
196 this->fSDigits=source.fSDigits;
197 this->fTOFGeometry=source.fTOFGeometry;
201 //_____________________________________________________________________________
202 AliTOF& AliTOF::operator=(const AliTOF &source)
206 this->fReconParticles=source.fReconParticles;
207 this->fSDigits=source.fSDigits;
208 this->fTOFGeometry=source.fTOFGeometry;
213 //_____________________________________________________________________________
214 void AliTOF::CreateTOFFolders()
216 // create the ALICE TFolder
217 // create the ALICE TTasks
218 // create the ALICE main TFolder
219 // to be done by AliRun
221 TFolder * alice = new TFolder();
222 alice->SetNameTitle("FPAlice", "Alice Folder") ;
223 gROOT->GetListOfBrowsables()->Add(alice) ;
225 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
226 // make it the owner of the objects that it contains
229 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
230 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
231 // make it the owner of the objects that it contains
234 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
235 aliceT->Add(aliceDi);
237 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
238 aliceT->Add(aliceRe);
240 char * tempo = new char[80] ;
242 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
243 sprintf(tempo, "%sDigitizers container",GetName() ) ;
244 fDTask = new TTask(GetName(), tempo);
245 aliceDi->Add(fDTask) ;
247 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
248 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
249 fReTask = new TTask(GetName(), tempo);
250 aliceRe->Add(fReTask) ;
254 // creates the TOF geometry folder
255 geomF->AddFolder("TOF", "Geometry for TOF") ;
258 //_____________________________________________________________________________
262 // it remove also the alice folder
263 // and task that TOF creates instead of AliRun
264 /* PH Temporarily commented because of problems
265 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
290 fReconParticles->Delete ();
291 delete fReconParticles;
297 //_____________________________________________________________________________
298 void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
302 // new with placement used
304 TClonesArray &lhits = *fHits;
305 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
308 //_____________________________________________________________________________
309 void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
313 // new with placement used
315 TClonesArray &lhits = *fHits;
316 new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
319 //_____________________________________________________________________________
320 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
324 // new with placement used
326 TClonesArray &ldigits = *fDigits;
327 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
330 //_____________________________________________________________________________
331 void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
338 TClonesArray &lSDigits = *fSDigits;
339 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
342 //_____________________________________________________________________________
343 void AliTOF::SetTreeAddress ()
345 // Set branch address for the Hits and Digits Tree.
347 if (fLoader->TreeH())
351 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
352 else fHits = new TClonesArray("AliTOFhit", 1000);
355 AliDetector::SetTreeAddress ();
359 if (fLoader->TreeS () )
361 branch = fLoader->TreeS ()->GetBranch ("TOF");
363 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
364 branch->SetAddress (&fSDigits);
368 if (fLoader->TreeR() )
370 branch = fLoader->TreeR()->GetBranch("TOF");
373 if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000);
374 branch->SetAddress(&fReconParticles);
379 if (fLoader->TreeR() && fReconParticles) //I do not know where this array is created - skowron
381 branch = fLoader->TreeR()->GetBranch("TOF");
384 branch->SetAddress(&fReconParticles) ;
390 //_____________________________________________________________________________
391 void AliTOF::CreateGeometry()
394 // Common geometry code
398 <img src="picts/AliTOFv23.gif">
405 if (IsVersion()==7) {
407 xTof = 124.5;//fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm, x-dimension of FTOA volume
408 yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin(); // cm, y-dimension of FTOA volume
409 Float_t zTof = fTOFGeometry->ZlenA(); // cm, z-dimension of FTOA volume
411 // TOF module internal definitions
412 TOFpc(xTof, yTof, zTof, fTOFGeometry->ZlenB());
416 Float_t wall = 4.;//cm // frame inbetween TOF modules
418 // Sizes of TOF module with its support etc..
419 xTof = 2.*(fTOFGeometry->Rmin()*TMath::Tan(10.*kDegrad)-wall/2.-0.5);
420 yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin();
422 // TOF module internal definitions
423 TOFpc(xTof, yTof, fTOFGeometry->ZlenC(), fTOFGeometry->ZlenB(), fTOFGeometry->ZlenA(), fTOFGeometry->MaxhZtof());
428 //_____________________________________________________________________________
429 void AliTOF::DrawModule() const
432 // Draw a shaded view of the common part of the TOF geometry
435 AliInfo(" Drawing of AliTOF");
436 // Set everything unseen
437 gMC->Gsatt("*", "seen", -1);
439 // Set ALIC mother transparent
440 gMC->Gsatt("ALIC","SEEN",0);
442 // Set the volumes visible
443 gMC->Gsatt("FTOA","SEEN",1);
444 gMC->Gsatt("FTOB","SEEN",1);
445 gMC->Gsatt("FTOC","SEEN",1);
446 gMC->Gsatt("FLTA","SEEN",1);
447 gMC->Gsatt("FLTB","SEEN",1);
448 gMC->Gsatt("FLTC","SEEN",1);
449 gMC->Gsatt("FSTR","SEEN",1);
451 gMC->Gdopt("hide", "on");
452 gMC->Gdopt("shad", "on");
453 gMC->Gsatt("*", "fill", 7);
454 gMC->SetClipBox(".");
455 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
457 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
458 gMC->Gdhead(1111, "Time Of Flight");
459 gMC->Gdman(18, 4, "MAN");
460 gMC->Gdopt("hide","off");
463 //_____________________________________________________________________________
464 Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t )
467 // Returns distance from mouse pointer to detector, default version
472 //___________________________________________
473 void AliTOF::ResetHits ()
475 // Reset number of clusters and the cluster array for this detector
476 AliDetector::ResetHits ();
479 //____________________________________________
480 void AliTOF::ResetDigits ()
483 // Reset number of digits and the digits array for this detector
484 AliDetector::ResetDigits ();
487 //____________________________________________
488 void AliTOF::ResetSDigits ()
491 // Reset number of sdigits and the sdigits array for this detector
496 //_____________________________________________________________________________
500 // Initialise TOF detector after it has been built
502 // Set id of TOF sensitive volume
503 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
507 TDirectory* saveDir = gDirectory;
508 gAlice->GetRunLoader()->CdGAFile();
509 fTOFGeometry->Write("TOFGeometry");
514 //____________________________________________________________________________
515 void AliTOF::MakeBranch(Option_t* option)
518 // Initializes the Branches of the TOF inside the
519 // trees written for each event.
520 // AliDetector::MakeBranch initializes just the
521 // Branch inside TreeH. Here we add the branches in
522 // TreeD, TreeS and TreeR.
524 const char *oH = strstr(option,"H");
525 if (fLoader->TreeH() && oH)
529 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
530 else fHits = new TClonesArray("AliTOFhit", 1000);
534 AliDetector::MakeBranch(option);
536 Int_t buffersize = 4000;
537 Char_t branchname[10];
538 sprintf(branchname,"%s",GetName());
540 const char *oD = strstr(option,"D");
541 const char *oS = strstr(option,"S");
542 const char *oR = strstr(option,"R");
544 if (fLoader->TreeD() && oD){
545 if (fDigits == 0x0) fDigits = new TClonesArray("AliTOFdigit", 1000);
546 MakeBranchInTree(fLoader->TreeD(), branchname, &fDigits,buffersize, 0) ;
549 if (fLoader->TreeS() && oS){
550 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
551 MakeBranchInTree(fLoader->TreeS(), branchname, &fSDigits,buffersize, 0) ;
554 if (fLoader->TreeR() && oR){
555 if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000);
556 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
560 if (fReconParticles && fLoader->TreeR() && oR){
561 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
566 //____________________________________________________________________________
567 void AliTOF::Makehits(Bool_t hits)
569 // default argument used, see AliTOF.h
570 // Enable/Disable the writing of the TOF-hits branch
572 // by default : enabled for TOFv1, v2, v3, v4, v5
573 // disabled for TOFv0
575 if (hits && (IsVersion()!=0))
576 fIdSens = gMC->VolId("FPAD");
578 AliInfo("Option for writing the TOF-hits branch on TreeH: disabled");
581 //____________________________________________________________________________
582 void AliTOF::FinishEvent()
587 //____________________________________________________________________________
588 void AliTOF::Hits2SDigits()
591 // Use the TOF SDigitizer to make TOF SDigits
594 // AliInfo("Start...");
596 AliRunLoader * rl = fLoader->GetRunLoader();
597 AliTOFSDigitizer sd((rl->GetFileName()).Data());
598 ToAliDebug(1, sd.Print(""));
604 //____________________________________________________________________________
605 void AliTOF::Hits2SDigits(Int_t evNumber1, Int_t evNumber2)
608 // Use the TOF SDigitizer to make TOF SDigits
611 if ((evNumber2-evNumber1)==1)
612 AliDebug(1, Form("I am making sdigits for the %dth event", evNumber1))
613 else if ((evNumber2-evNumber1)>1)
614 AliDebug(1, Form("I am making sdigits for the events from the "
615 "%dth to the %dth", evNumber1, evNumber2-1));
617 AliRunLoader * rl = fLoader->GetRunLoader();
618 AliTOFSDigitizer sd((rl->GetFileName()).Data(),evNumber1,evNumber2) ;
619 ToAliDebug(1, sd.Print(""));
625 //___________________________________________________________________________
626 AliDigitizer* AliTOF::CreateDigitizer(AliRunDigitizer* manager) const
628 return new AliTOFDigitizer(manager);
631 //___________________________________________________________________________
632 Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
635 // Checks if 2 or more hits belong to the same pad.
636 // In this case the data assigned to the digit object
637 // are the ones of the first hit in order of Time.
638 // 2 hits from the same track on the same pad are collected.
639 // Called only by Hits2SDigits.
640 // This procedure has to be optimized in the next TOF release.
643 Bool_t overlap = kFALSE;
646 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
647 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
648 currentDigit->GetLocation(vol2);
650 // check on digit volume
651 for (Int_t i=0;i<=4;i++){
653 if (vol[i]!=vol2[i]) idem=kFALSE;}
655 if (idem){ // same pad fired
656 Float_t tdc2 = digit[0];
657 Float_t tdc1 = currentDigit->GetTdc();
659 // we separate two digits on the same pad if
660 // they are separated in time by at least 25 ns
661 // remember that tdc time is given in ps
663 if (TMath::Abs(tdc1-tdc2)<25000){
664 // in case of overlap we take the earliest
666 currentDigit->SetTdc(tdc2);
667 currentDigit->SetAdc(digit[1]);
670 currentDigit->SetTdc(tdc1);
671 currentDigit->SetAdc(digit[1]);
673 currentDigit->AddTrack(Track); // add track number in the track array
679 } // close if (idem) -> two digits on the same TOF pad
681 } // end loop on existing sdigits
685 //____________________________________________________________________________
686 void AliTOF::Digits2Raw()
689 // Starting from the TOF digits, writes the Raw Data objects
692 fLoader->LoadDigits();
694 TTree* digits = fLoader->TreeD();
696 AliError("no digits tree");
700 //AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
701 fRunLoader->CdGAFile();
702 TFile *in=(TFile*)gFile;
704 AliTOFGeometry *geometry = (AliTOFGeometry*)in->Get("TOFgeometry");
706 AliTOFDDLRawData rawWriter(geometry);
707 //AliTOFDDLRawData rawWriter;
708 rawWriter.SetVerbose(0);
710 AliDebug(1,"Formatting raw data for TOF");
712 rawWriter.RawDataTOF(digits->GetBranch("TOF"));
714 fLoader->UnloadDigits();
718 //____________________________________________________________________________
719 void AliTOF::RecreateSDigitsArray() {
721 // delete TClonesArray fSDigits and create it again
722 // needed for backward compatability with PPR test production
725 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
727 //____________________________________________________________________________
728 void AliTOF::CreateSDigitsArray() {
730 // create TClonesArray fSDigits
731 // needed for backward compatability with PPR test production
733 fSDigits = new TClonesArray("AliTOFSDigit", 1000);