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.2 2000/05/18 14:33:01 vicinanz
19 Modified to be full HP compliant
21 Revision 1.1 2000/05/10 16:52:18 vicinanz
22 New TOF version with holes for PHOS/RICH
30 //******************************************************************************
32 ClassImp(AliTOFRawDigit)
34 //______________________________________________________________________________
35 AliTOFRawDigit::AliTOFRawDigit()
37 // Constructor of AliTOFRawDigit class
44 //******************************************************************************
48 //______________________________________________________________________________
49 AliTOFRoc::AliTOFRoc()
51 // Constructor of AliTOFRoc class
52 // The class represents a ROC in the TARODA system
59 //______________________________________________________________________________
60 AliTOFRoc::~AliTOFRoc(){}
62 //______________________________________________________________________________
63 Int_t AliTOFRoc::AddItem(Int_t Fec, Int_t Tdc, Int_t Error,
64 Float_t Charge, Float_t Time)
66 // Adds an item (i.e. the charge, the TOF and the
67 // cohordinates of a hit pad) to the ROC class.
71 SetCharge(Items,Fec,Tdc,Charge);
72 SetTime (Items,Error,Time);
76 //______________________________________________________________________________
77 void AliTOFRoc::SetHeader()
79 // Calculate the header line of the ROC in the raw data file
87 //______________________________________________________________________________
88 void AliTOFRoc::SetTime(UInt_t Item, UInt_t Error, Float_t RealTime)
90 // Calculate the raw data line relative to the TDC
91 // output of a pad in the current ROC.
95 Itime = (UInt_t)(RealTime/50.);
96 if (Itime >= TMath::Power(2,24)) Itime = 2^24-1;
98 TimeRow[Item]= Error+Itime;
101 //______________________________________________________________________________
102 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t Fec, UInt_t Tdc, Float_t RealCharge)
104 // Calculate the raw data line relative to the ADC
105 // output of a pad in the current ROC.
109 if (NRoc>=TMath::Power(2,4)) NRoc = 0;
111 if (Fec >=TMath::Power(2,6)) Fec = 0;
113 if (Tdc >=TMath::Power(2,6)) Tdc = 0;
115 ICharge = (UInt_t)(RealCharge/50.);
116 if(ICharge>=TMath::Power(2,16)) ICharge = (UInt_t)TMath::Power(2,16)-1;
117 ChrgRow[Item] = ICharge+NRoc+Fec+Tdc;
120 //______________________________________________________________________________
121 void AliTOFRoc::SetTime(UInt_t Item, UInt_t tir)
123 // Writes the raw data line relative to the TDC
129 //______________________________________________________________________________
130 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t chr)
132 // Writes the raw data line relative to the ADC
138 //______________________________________________________________________________
139 Float_t AliTOFRoc::GetCharge(Int_t Item)
141 // Reads the effective value of the charge starting
142 // from the line of the raw data
145 UInt_t Charge = ChrgRow[Item]&0x0000ffff;
146 Float_t ACharge = (Float_t)Charge*50.;
150 //______________________________________________________________________________
151 Float_t AliTOFRoc::GetTime(Int_t Item, UInt_t& Error)
153 // Reads the effective value of the time of flight starting
154 // from the line of the raw data
157 UInt_t Time = TimeRow[Item]&0x00ffffff;
158 Float_t ATime = (Float_t)Time*50.;
159 Error = TimeRow[Item]>>24;
163 //______________________________________________________________________________
164 Int_t AliTOFRoc::GetTotPad(Int_t Item)
166 // Reads the cohordinates of the pad starting
167 // from the line of the raw data
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;
177 //______________________________________________________________________________
178 UInt_t AliTOFRoc::GetCheckSum()
180 // Calculate the checksum word of the current ROC
184 for(Int_t i=0; i<Items; i++){
185 CheckSum += BitCount(GetChrgRow(i));
186 CheckSum += BitCount(GetTimeRow(i));
191 //______________________________________________________________________________
192 UInt_t AliTOFRoc::BitCount(UInt_t x)
194 // Count the "1" bit in the current word
198 for (count=0; x!=0; x>>=1){
199 if(x&0x00000001) count++;
204 //______________________________________________________________________________
205 UInt_t AliTOFRoc::SetSize()
207 // Reads the size of data from current ROC starting
208 // from the header line of the raw data
211 Size = Header&0x0000ffff;
217 //******************************************************************************
219 ClassImp(AliTOFRawSector)
221 //______________________________________________________________________________
222 AliTOFRawSector::AliTOFRawSector()
224 // Constructor of AliTOFRawSector class
225 // Each sector is in effect a
226 // TClonesArray of 14 AliTOFRoc Objects
229 fRocData = new TClonesArray("AliTOFRoc",14);
232 //______________________________________________________________________________
233 AliTOFRawSector::~AliTOFRawSector()
238 //______________________________________________________________________________
239 void AliTOFRawSector::WriteSector()
241 // Starting from the raw data objects writes a binary file
242 // similar to real raw data.
246 rawfile = fopen("rawdata.dat","w");
248 // fprintf(rawfile,Header);
252 for(nRoc=1; nRoc<=14; nRoc++){
253 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
254 currentRoc->SetHeader();
255 // UInt_t RocHeader = currentRoc->Header;
256 // fprintf(rawfile,RocHeader);
259 for(nRoc=1; nRoc<=14; nRoc++){
260 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
261 Int_t rocItems = currentRoc->Items;
263 for(Int_t nItem=1; nItem<=rocItems;nItem++){
264 // UInt_t TimeRow = currentRoc->GetTimeRow(nItem);
265 // fprintf(rawfile,TimeRow);
266 // UInt_t ChrgRow = currentRoc->GetTimeRow(nItem);
267 // fprintf(rawfile,ChrgRow);
271 // UInt_t EndOfSector = GlobalCheckSum;
272 // fprintf(rawfile,EndOfSector);
275 //______________________________________________________________________________
276 void AliTOFRawSector::ReadSector()
278 // Starting from raw data initialize and write the
280 //(i.e. a TClonesArray of 18 AliTOFRawSector)
284 rawfile = fopen("rawdata.dat","r");
286 // fscanf(rawfile,Header);
289 for(nRoc=1; nRoc<=14; nRoc++){
290 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
292 // fscanf(rawfile,RocHeader);
293 currentRoc->SetHeader(RocHeader);
297 // fscanf(rawfile,SCMWord);
299 for(nRoc=1; nRoc<=14; nRoc++){
300 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
301 // Int_t Size = currentRoc->SetSize();
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);
311 // fscanf(rawfile,FinalWord);
313 // fscanf(rawfile,GlobalCheckSum);