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 Revision 1.3 2000/10/02 21:28:17 fca
19 Removal of useless dependecies via forward declarations
21 Revision 1.2 2000/05/18 14:33:01 vicinanz
22 Modified to be full HP compliant
24 Revision 1.1 2000/05/10 16:52:18 vicinanz
25 New TOF version with holes for PHOS/RICH
33 //******************************************************************************
35 ClassImp(AliTOFRawDigit)
37 //______________________________________________________________________________
38 AliTOFRawDigit::AliTOFRawDigit()
40 // Constructor of AliTOFRawDigit class
47 //******************************************************************************
51 //______________________________________________________________________________
52 AliTOFRoc::AliTOFRoc()
54 // Constructor of AliTOFRoc class
55 // The class represents a ROC in the TARODA system
62 //______________________________________________________________________________
63 AliTOFRoc::~AliTOFRoc(){}
65 //______________________________________________________________________________
66 Int_t AliTOFRoc::AddItem(Int_t Fec, Int_t Tdc, Int_t Error,
67 Float_t Charge, Float_t Time)
70 // Adds an item (i.e. the charge, the TOF and the
71 // cohordinates of a hit pad) to the ROC class.
75 SetCharge(fItems,Fec,Tdc,Charge);
76 SetTime (fItems,Error,Time);
80 //______________________________________________________________________________
81 void AliTOFRoc::SetHeader()
83 // Calculate the header line of the ROC in the raw data file
91 //______________________________________________________________________________
92 void AliTOFRoc::SetTime(UInt_t Item, UInt_t Error, Float_t RealTime)
95 // Calculate the raw data line relative to the TDC
96 // output of a pad in the current ROC.
100 itime = (UInt_t)(RealTime/50.);
101 if (itime >= TMath::Power(2,24)) itime = 2^24-1;
103 fTimeRow[Item]= Error+itime;
106 //______________________________________________________________________________
107 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t Fec, UInt_t Tdc, Float_t RealCharge)
110 // Calculate the raw data line relative to the ADC
111 // output of a pad in the current ROC.
115 if (fNRoc>=TMath::Power(2,4)) fNRoc = 0;
117 if (Fec >=TMath::Power(2,6)) Fec = 0;
119 if (Tdc >=TMath::Power(2,6)) Tdc = 0;
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;
126 //______________________________________________________________________________
127 void AliTOFRoc::SetTime(UInt_t Item, UInt_t tir)
129 // Writes the raw data line relative to the TDC
135 //______________________________________________________________________________
136 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t chr)
138 // Writes the raw data line relative to the ADC
144 //______________________________________________________________________________
145 Float_t AliTOFRoc::GetCharge(Int_t Item)
148 // Reads the effective value of the charge starting
149 // from the line of the raw data
152 UInt_t icharge = fChrgRow[Item]&0x0000ffff;
153 Float_t charge = (Float_t)icharge*50.;
157 //______________________________________________________________________________
158 Float_t AliTOFRoc::GetTime(Int_t Item, UInt_t& Error)
161 // Reads the effective value of the time of flight starting
162 // from the line of the raw data
165 UInt_t itime = fTimeRow[Item]&0x00ffffff;
166 Float_t time = (Float_t)itime*50.;
167 Error = fTimeRow[Item]>>24;
171 //______________________________________________________________________________
172 Int_t AliTOFRoc::GetTotPad(Int_t Item)
175 // Reads the cohordinates of the pad starting
176 // from the line of the raw data
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;
186 //______________________________________________________________________________
187 UInt_t AliTOFRoc::GetCheckSum()
190 // Calculate the checksum word of the current ROC
194 for(Int_t i=0; i<fItems; i++){
195 checkSum += BitCount(GetChrgRow(i));
196 checkSum += BitCount(GetTimeRow(i));
201 //______________________________________________________________________________
202 UInt_t AliTOFRoc::BitCount(UInt_t x)
205 // Count the "1" bit in the current word
209 for (count=0; x!=0; x>>=1){
210 if(x&0x00000001) count++;
215 //______________________________________________________________________________
216 UInt_t AliTOFRoc::SetSize()
219 // Reads the size of data from current ROC starting
220 // from the header line of the raw data
223 fSize = fHeader&0x0000ffff;
224 fItems = (fSize-4)/4;
229 //******************************************************************************
231 ClassImp(AliTOFRawSector)
233 //______________________________________________________________________________
234 AliTOFRawSector::AliTOFRawSector()
237 // Constructor of AliTOFRawSector class
238 // Each sector is in effect a
239 // TClonesArray of 14 AliTOFRoc Objects
241 fRocData = new TClonesArray("AliTOFRoc",14);
244 //______________________________________________________________________________
245 AliTOFRawSector::~AliTOFRawSector()
247 // destructor of the AliTOFRawSector object
248 // Here we delete the 14 AliTOFRoc istances
257 //______________________________________________________________________________
258 void AliTOFRawSector::WriteSector()
261 // Starting from the raw data objects writes a binary file
262 // similar to real raw data.
266 rawfile = fopen("rawdata.dat","w");
268 // fprintf(rawfile,Header);
272 // loop on all AliTOFRoc Headers to set them
273 for(nRoc=1; nRoc<=14; nRoc++){
274 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
275 currentRoc->SetHeader();
276 // UInt_t RocHeader = currentRoc->fHeader;
277 // fprintf(rawfile,RocHeader);
280 for(nRoc=1; nRoc<=14; nRoc++){
281 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
282 Int_t rocItems = currentRoc->GetItems();
284 for(Int_t nItem=1; nItem<=rocItems;nItem++){
285 // UInt_t TimeRow = currentRoc->GetTimeRow(nItem);
286 // fprintf(rawfile,TimeRow);
287 // UInt_t ChrgRow = currentRoc->GetTimeRow(nItem);
288 // fprintf(rawfile,ChrgRow);
292 // UInt_t EndOfSector = GlobalCheckSum;
293 // fprintf(rawfile,EndOfSector);
296 //______________________________________________________________________________
297 void AliTOFRawSector::ReadSector()
300 // Starting from raw data initialize and write the
302 //(i.e. a TClonesArray of 18 AliTOFRawSector)
306 rawfile = fopen("rawdata.dat","r");
308 // fscanf(rawfile,Header);
309 // fscanf(rawfile,Header);
312 for(nRoc=1; nRoc<=14; nRoc++){
313 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
315 fscanf(rawfile,"%u",&rocHeader);
316 currentRoc->SetHeader(rocHeader);
320 // fscanf(rawfile,"%u",SCMWord);
322 for(nRoc=1; nRoc<=14; nRoc++){
323 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
324 // Int_t Size = currentRoc->SetSize();
325 Int_t nItems = currentRoc->GetItems();
326 for(Int_t nrow=0; nrow<=nItems; nrow++){
327 UInt_t charRow,timeRow;
328 fscanf(rawfile,"%u",&charRow);
329 currentRoc->SetTime(nrow, charRow);
330 fscanf(rawfile,"%u",&timeRow);
331 currentRoc->SetTime(nrow, timeRow);
334 fscanf(rawfile,"%d",&FinalWord);
336 // fscanf(rawfile,GlobalCheckSum);