]>
Commit | Line | Data |
---|---|---|
2cef3cb2 | 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 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
b94fa26c | 18 | Revision 1.3 2000/10/02 21:28:17 fca |
19 | Removal of useless dependecies via forward declarations | |
20 | ||
94de3818 | 21 | Revision 1.2 2000/05/18 14:33:01 vicinanz |
22 | Modified to be full HP compliant | |
23 | ||
f5489efc | 24 | Revision 1.1 2000/05/10 16:52:18 vicinanz |
25 | New TOF version with holes for PHOS/RICH | |
26 | ||
2cef3cb2 | 27 | */ |
28 | ||
29 | #include "AliTOF.h" | |
30 | #include "AliTOFD.h" | |
31 | #include "TObject.h" | |
32 | ||
33 | //****************************************************************************** | |
34 | ||
35 | ClassImp(AliTOFRawDigit) | |
36 | ||
37 | //______________________________________________________________________________ | |
38 | AliTOFRawDigit::AliTOFRawDigit() | |
39 | // | |
40 | // Constructor of AliTOFRawDigit class | |
41 | // | |
42 | { | |
43 | fTreeD = 0; | |
44 | fRawDigits = 0; | |
45 | } | |
46 | ||
47 | //****************************************************************************** | |
48 | ||
49 | ClassImp(AliTOFRoc) | |
50 | ||
51 | //______________________________________________________________________________ | |
52 | AliTOFRoc::AliTOFRoc() | |
53 | // | |
54 | // Constructor of AliTOFRoc class | |
55 | // The class represents a ROC in the TARODA system | |
56 | // | |
57 | { | |
b94fa26c | 58 | fItems = 0; |
59 | fSize = 0; | |
2cef3cb2 | 60 | } |
61 | ||
62 | //______________________________________________________________________________ | |
63 | AliTOFRoc::~AliTOFRoc(){} | |
64 | ||
65 | //______________________________________________________________________________ | |
66 | Int_t AliTOFRoc::AddItem(Int_t Fec, Int_t Tdc, Int_t Error, | |
67 | Float_t Charge, Float_t Time) | |
b94fa26c | 68 | { |
2cef3cb2 | 69 | // |
70 | // Adds an item (i.e. the charge, the TOF and the | |
71 | // cohordinates of a hit pad) to the ROC class. | |
72 | // | |
b94fa26c | 73 | |
74 | fItems++; | |
75 | SetCharge(fItems,Fec,Tdc,Charge); | |
76 | SetTime (fItems,Error,Time); | |
77 | return fItems; | |
2cef3cb2 | 78 | } |
79 | ||
80 | //______________________________________________________________________________ | |
81 | void AliTOFRoc::SetHeader() | |
82 | // | |
83 | // Calculate the header line of the ROC in the raw data file | |
84 | // | |
85 | { | |
b94fa26c | 86 | fHeader = fNRoc<<28; |
87 | fHeader += fSize; | |
2cef3cb2 | 88 | } |
89 | ||
90 | ||
91 | //______________________________________________________________________________ | |
92 | void AliTOFRoc::SetTime(UInt_t Item, UInt_t Error, Float_t RealTime) | |
b94fa26c | 93 | { |
2cef3cb2 | 94 | // |
95 | // Calculate the raw data line relative to the TDC | |
96 | // output of a pad in the current ROC. | |
97 | // | |
b94fa26c | 98 | |
99 | UInt_t itime; | |
100 | itime = (UInt_t)(RealTime/50.); | |
101 | if (itime >= TMath::Power(2,24)) itime = 2^24-1; | |
2cef3cb2 | 102 | Error <<= 24; |
b94fa26c | 103 | fTimeRow[Item]= Error+itime; |
2cef3cb2 | 104 | } |
105 | ||
106 | //______________________________________________________________________________ | |
107 | void AliTOFRoc::SetCharge(UInt_t Item, UInt_t Fec, UInt_t Tdc, Float_t RealCharge) | |
b94fa26c | 108 | { |
2cef3cb2 | 109 | // |
110 | // Calculate the raw data line relative to the ADC | |
111 | // output of a pad in the current ROC. | |
112 | // | |
b94fa26c | 113 | |
114 | UInt_t iCharge; | |
115 | if (fNRoc>=TMath::Power(2,4)) fNRoc = 0; | |
116 | fNRoc <<= 28; | |
f5489efc | 117 | if (Fec >=TMath::Power(2,6)) Fec = 0; |
2cef3cb2 | 118 | Fec <<= 22; |
f5489efc | 119 | if (Tdc >=TMath::Power(2,6)) Tdc = 0; |
2cef3cb2 | 120 | Tdc <<= 16; |
b94fa26c | 121 | iCharge = (UInt_t)(RealCharge/50.); |
122 | if(iCharge>=TMath::Power(2,16)) iCharge = (UInt_t)TMath::Power(2,16)-1; | |
123 | fChrgRow[Item] = iCharge+fNRoc+Fec+Tdc; | |
2cef3cb2 | 124 | } |
125 | ||
126 | //______________________________________________________________________________ | |
127 | void AliTOFRoc::SetTime(UInt_t Item, UInt_t tir) | |
128 | // | |
129 | // Writes the raw data line relative to the TDC | |
130 | // | |
131 | { | |
b94fa26c | 132 | fChrgRow[Item]=tir; |
2cef3cb2 | 133 | } |
134 | ||
135 | //______________________________________________________________________________ | |
136 | void AliTOFRoc::SetCharge(UInt_t Item, UInt_t chr) | |
137 | // | |
138 | // Writes the raw data line relative to the ADC | |
139 | // | |
140 | { | |
b94fa26c | 141 | fChrgRow[Item]=chr; |
2cef3cb2 | 142 | } |
143 | ||
144 | //______________________________________________________________________________ | |
145 | Float_t AliTOFRoc::GetCharge(Int_t Item) | |
b94fa26c | 146 | { |
2cef3cb2 | 147 | // |
148 | // Reads the effective value of the charge starting | |
149 | // from the line of the raw data | |
150 | // | |
b94fa26c | 151 | |
152 | UInt_t icharge = fChrgRow[Item]&0x0000ffff; | |
153 | Float_t charge = (Float_t)icharge*50.; | |
154 | return charge; | |
2cef3cb2 | 155 | } |
156 | ||
157 | //______________________________________________________________________________ | |
158 | Float_t AliTOFRoc::GetTime(Int_t Item, UInt_t& Error) | |
b94fa26c | 159 | { |
2cef3cb2 | 160 | // |
161 | // Reads the effective value of the time of flight starting | |
162 | // from the line of the raw data | |
163 | // | |
b94fa26c | 164 | |
165 | UInt_t itime = fTimeRow[Item]&0x00ffffff; | |
166 | Float_t time = (Float_t)itime*50.; | |
167 | Error = fTimeRow[Item]>>24; | |
168 | return time; | |
2cef3cb2 | 169 | } |
170 | ||
171 | //______________________________________________________________________________ | |
172 | Int_t AliTOFRoc::GetTotPad(Int_t Item) | |
b94fa26c | 173 | { |
2cef3cb2 | 174 | // |
175 | // Reads the cohordinates of the pad starting | |
176 | // from the line of the raw data | |
177 | // | |
b94fa26c | 178 | |
179 | UInt_t nRoc = (fChrgRow[Item]&0xf0000000)>>28; | |
180 | UInt_t nFec = (fChrgRow[Item]&0x0fc00000)>>22; | |
181 | UInt_t nTdc = (fChrgRow[Item]&0x003f0000)>>16; | |
182 | UInt_t pad = nRoc*32*32+nFec*32+nTdc; | |
183 | return pad; | |
2cef3cb2 | 184 | } |
185 | ||
186 | //______________________________________________________________________________ | |
187 | UInt_t AliTOFRoc::GetCheckSum() | |
b94fa26c | 188 | { |
2cef3cb2 | 189 | // |
190 | // Calculate the checksum word of the current ROC | |
191 | // | |
b94fa26c | 192 | |
193 | UInt_t checkSum=0; | |
194 | for(Int_t i=0; i<fItems; i++){ | |
195 | checkSum += BitCount(GetChrgRow(i)); | |
196 | checkSum += BitCount(GetTimeRow(i)); | |
2cef3cb2 | 197 | } |
b94fa26c | 198 | return checkSum; |
2cef3cb2 | 199 | } |
200 | ||
201 | //______________________________________________________________________________ | |
202 | UInt_t AliTOFRoc::BitCount(UInt_t x) | |
b94fa26c | 203 | { |
2cef3cb2 | 204 | // |
205 | // Count the "1" bit in the current word | |
206 | // | |
b94fa26c | 207 | |
2cef3cb2 | 208 | UInt_t count=0; |
209 | for (count=0; x!=0; x>>=1){ | |
210 | if(x&0x00000001) count++; | |
211 | } | |
212 | return count; | |
213 | } | |
214 | ||
215 | //______________________________________________________________________________ | |
216 | UInt_t AliTOFRoc::SetSize() | |
b94fa26c | 217 | { |
2cef3cb2 | 218 | // |
219 | // Reads the size of data from current ROC starting | |
220 | // from the header line of the raw data | |
221 | // | |
b94fa26c | 222 | |
223 | fSize = fHeader&0x0000ffff; | |
224 | fItems = (fSize-4)/4; | |
225 | return fSize; | |
2cef3cb2 | 226 | } |
227 | ||
228 | ||
229 | //****************************************************************************** | |
230 | ||
231 | ClassImp(AliTOFRawSector) | |
232 | ||
233 | //______________________________________________________________________________ | |
234 | AliTOFRawSector::AliTOFRawSector() | |
b94fa26c | 235 | { |
2cef3cb2 | 236 | // |
237 | // Constructor of AliTOFRawSector class | |
238 | // Each sector is in effect a | |
239 | // TClonesArray of 14 AliTOFRoc Objects | |
240 | // | |
2cef3cb2 | 241 | fRocData = new TClonesArray("AliTOFRoc",14); |
242 | } | |
243 | ||
244 | //______________________________________________________________________________ | |
245 | AliTOFRawSector::~AliTOFRawSector() | |
246 | { | |
b94fa26c | 247 | // destructor of the AliTOFRawSector object |
248 | // Here we delete the 14 AliTOFRoc istances | |
249 | // | |
250 | if (fRocData) { | |
251 | fRocData->Delete() ; | |
252 | delete fRocData; | |
253 | fRocData = 0; | |
254 | } | |
2cef3cb2 | 255 | } |
256 | ||
257 | //______________________________________________________________________________ | |
258 | void AliTOFRawSector::WriteSector() | |
b94fa26c | 259 | { |
2cef3cb2 | 260 | // |
261 | // Starting from the raw data objects writes a binary file | |
262 | // similar to real raw data. | |
263 | // | |
b94fa26c | 264 | |
2cef3cb2 | 265 | FILE *rawfile; |
266 | rawfile = fopen("rawdata.dat","w"); | |
267 | ||
268 | // fprintf(rawfile,Header); | |
269 | ||
270 | Int_t nRoc; | |
b94fa26c | 271 | |
272 | // loop on all AliTOFRoc Headers to set them | |
2cef3cb2 | 273 | for(nRoc=1; nRoc<=14; nRoc++){ |
274 | AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc); | |
f5489efc | 275 | currentRoc->SetHeader(); |
b94fa26c | 276 | // UInt_t RocHeader = currentRoc->fHeader; |
2cef3cb2 | 277 | // fprintf(rawfile,RocHeader); |
278 | } | |
279 | ||
280 | for(nRoc=1; nRoc<=14; nRoc++){ | |
281 | AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc); | |
b94fa26c | 282 | Int_t rocItems = currentRoc->GetItems(); |
2cef3cb2 | 283 | |
284 | for(Int_t nItem=1; nItem<=rocItems;nItem++){ | |
94de3818 | 285 | // UInt_t TimeRow = currentRoc->GetTimeRow(nItem); |
2cef3cb2 | 286 | // fprintf(rawfile,TimeRow); |
94de3818 | 287 | // UInt_t ChrgRow = currentRoc->GetTimeRow(nItem); |
2cef3cb2 | 288 | // fprintf(rawfile,ChrgRow); |
289 | } | |
290 | } | |
291 | ||
94de3818 | 292 | // UInt_t EndOfSector = GlobalCheckSum; |
2cef3cb2 | 293 | // fprintf(rawfile,EndOfSector); |
294 | } | |
295 | ||
296 | //______________________________________________________________________________ | |
297 | void AliTOFRawSector::ReadSector() | |
b94fa26c | 298 | { |
2cef3cb2 | 299 | // |
300 | // Starting from raw data initialize and write the | |
301 | // Raw Data objects | |
302 | //(i.e. a TClonesArray of 18 AliTOFRawSector) | |
303 | // | |
b94fa26c | 304 | |
2cef3cb2 | 305 | FILE *rawfile; |
306 | rawfile = fopen("rawdata.dat","r"); | |
307 | ||
b94fa26c | 308 | // fscanf(rawfile,Header); |
2cef3cb2 | 309 | // fscanf(rawfile,Header); |
310 | Int_t nRoc; | |
311 | ||
312 | for(nRoc=1; nRoc<=14; nRoc++){ | |
313 | AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc); | |
b94fa26c | 314 | UInt_t rocHeader; |
315 | fscanf(rawfile,"%u",&rocHeader); | |
316 | currentRoc->SetHeader(rocHeader); | |
2cef3cb2 | 317 | } |
318 | ||
b94fa26c | 319 | // UInt_t SCMWord; |
320 | // fscanf(rawfile,"%u",SCMWord); | |
2cef3cb2 | 321 | |
322 | for(nRoc=1; nRoc<=14; nRoc++){ | |
323 | AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc); | |
94de3818 | 324 | // Int_t Size = currentRoc->SetSize(); |
b94fa26c | 325 | Int_t nItems = currentRoc->GetItems(); |
2cef3cb2 | 326 | for(Int_t nrow=0; nrow<=nItems; nrow++){ |
327 | UInt_t charRow,timeRow; | |
b94fa26c | 328 | fscanf(rawfile,"%u",&charRow); |
2cef3cb2 | 329 | currentRoc->SetTime(nrow, charRow); |
b94fa26c | 330 | fscanf(rawfile,"%u",&timeRow); |
2cef3cb2 | 331 | currentRoc->SetTime(nrow, timeRow); |
332 | } | |
b94fa26c | 333 | Int_t FinalWord; |
334 | fscanf(rawfile,"%d",&FinalWord); | |
2cef3cb2 | 335 | } |
336 | // fscanf(rawfile,GlobalCheckSum); | |
337 | } | |
338 |