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