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 **************************************************************************/
16 //_________________________________________________________________________
17 // This is a TTask that constructs SDigits out of Hits
18 // A Summable Digits is the sum of all hits in a pad
21 //-- Author: F. Pierella
22 //////////////////////////////////////////////////////////////////////////////
30 #include "AliTOFdigit.h"
31 #include "AliTOFhit.h"
37 #include "AliTOFSDigitizer.h"
39 #include "AliDetector.h"
52 ClassImp(AliTOFSDigitizer)
54 //____________________________________________________________________________
55 AliTOFSDigitizer::AliTOFSDigitizer():TTask("AliTOFSDigitizer","")
64 //____________________________________________________________________________
65 AliTOFSDigitizer::AliTOFSDigitizer(char* HeaderFile,char *SdigitsFile ):TTask("AliTOFSDigitizer","")
67 fNevents = 0 ; // Number of events to digitize, 0 means all evens in current file
68 // add Task to //root/Tasks folder
69 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
70 roottasks->Add(this) ;
73 //____________________________________________________________________________
74 AliTOFSDigitizer::~AliTOFSDigitizer()
79 //____________________________________________________________________________
80 void AliTOFSDigitizer::Exec(Option_t *option) {
83 // Initialise Hit array
84 fHits = new TClonesArray ("AliTOFhit", 1000);
85 fSDigits = new TClonesArray ("AliTOFdigit", 1000);
87 AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF");
90 fNevents = (Int_t) gAlice->TreeE ()->GetEntries ();
92 for (Int_t ievent = 0; ievent < fNevents; ievent++)
94 gAlice->GetEvent (ievent);
95 if (gAlice->TreeH () == 0)
97 if (gAlice->TreeS () == 0)
98 gAlice->MakeTree ("S");
103 sprintf (branchname, "%s", TOF->GetName ());
104 //Make branch for digits
105 TOF->MakeBranch ("S");
107 //Now made SDigits from hits
109 Int_t tracks[3]; // track info
110 Int_t vol[5]; // location for a digit
111 Float_t digit[2]; // TOF digit variables
115 TClonesArray *TOFhits = TOF->Hits();
118 // Event ------------------------- LOOP
123 TOFhits = TOF->Hits ();
124 TTree *TH = gAlice->TreeH ();
125 Stat_t ntracks = TH->GetEntries ();
126 for (Int_t track = 0; track < ntracks; track++)
128 gAlice->ResetHits ();
129 nbytes += TH->GetEvent (track);
130 particle = gAlice->Particle (track);
131 Int_t nhits = TOFhits->GetEntriesFast ();
133 for (hit = 0; hit < nhits; hit++)
135 tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit);
136 vol[0] = tofHit->GetSector();
137 vol[1] = tofHit->GetPlate();
138 vol[2] = tofHit->GetStrip();
139 vol[3] = tofHit->GetPadx();
140 vol[4] = tofHit->GetPadz();
142 // 95% of efficiency to be inserted here
143 // edge effect to be inserted here
144 // cross talk to be inserted here
146 Float_t idealtime = tofHit->GetTof(); // unit s
147 idealtime *= 1.E+12; // conversion from s to ps
148 // fTimeRes is given usually in ps
149 // Float_t tdctime = gRandom->Gaus(idealtime, fTimeRes);
150 Float_t tdctime = gRandom->Gaus(idealtime, TOF->GetTimeRes());
153 // typical Landau Distribution to be inserted here
154 // instead of Gaussian Distribution
155 Float_t idealcharge = tofHit->GetEdep();
156 // Float_t adccharge = gRandom->Gaus(idealcharge, fChrgRes);
157 Float_t adccharge = gRandom->Gaus(idealcharge, TOF->GetChrgRes());
158 digit[1] = adccharge;
159 Int_t tracknum = tofHit->GetTrack();
160 tracks[0] = tracknum;
164 // check if two digit are on the same pad; in that case we sum
165 // the two or more digits
166 // Bool_t overlap = AliTOF::CheckOverlap(vol, digit, tracknum);
167 Bool_t overlap = TOF->CheckOverlap(vol, digit, tracknum);
169 // new ((*fSDigits)[nSdigits++]) AliTOFdigit(tracks, vol, digit);
170 TOF->AddSDigit(tracks, vol, digit);
171 // printf("Sect. %d, Plate %d, PadX %d, PadZ %d, Strip %d, Tdc %f",vol[0],vol[1],vol[2],vol[3],vol[5],digit[0]);
172 } // end loop on hits for the current track
174 } // end loop on ntracks
176 } // close if TOF switched ON
178 gAlice->TreeS()->Reset();
179 gAlice->TreeS()->Fill();
180 gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
186 //__________________________________________________________________
187 void AliTOFSDigitizer::SetSDigitsFile(char * file ){
188 if(!fSDigitsFile.IsNull())
189 cout << "Changing SDigits file from " <<(char *)fSDigitsFile.Data() << " to " << file << endl ;
192 //__________________________________________________________________
193 void AliTOFSDigitizer::Print(Option_t* option)const
195 cout << "------------------- "<< GetName() << " -------------" << endl ;
196 if(fSDigitsFile.IsNull())
197 cout << " Writing SDigitis to file galice.root "<< endl ;
199 cout << " Writing SDigitis to file " << (char*) fSDigitsFile.Data() << endl ;