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.1 2000/05/10 16:52:18 vicinanz
19 New TOF version with holes for PHOS/RICH
27 //******************************************************************************
29 ClassImp(AliTOFRawDigit)
31 //______________________________________________________________________________
32 AliTOFRawDigit::AliTOFRawDigit()
34 // Constructor of AliTOFRawDigit class
41 //******************************************************************************
45 //______________________________________________________________________________
46 AliTOFRoc::AliTOFRoc()
48 // Constructor of AliTOFRoc class
49 // The class represents a ROC in the TARODA system
56 //______________________________________________________________________________
57 AliTOFRoc::~AliTOFRoc(){}
59 //______________________________________________________________________________
60 Int_t AliTOFRoc::AddItem(Int_t Fec, Int_t Tdc, Int_t Error,
61 Float_t Charge, Float_t Time)
63 // Adds an item (i.e. the charge, the TOF and the
64 // cohordinates of a hit pad) to the ROC class.
68 SetCharge(Items,Fec,Tdc,Charge);
69 SetTime (Items,Error,Time);
73 //______________________________________________________________________________
74 void AliTOFRoc::SetHeader()
76 // Calculate the header line of the ROC in the raw data file
84 //______________________________________________________________________________
85 void AliTOFRoc::SetTime(UInt_t Item, UInt_t Error, Float_t RealTime)
87 // Calculate the raw data line relative to the TDC
88 // output of a pad in the current ROC.
92 Itime = (UInt_t)(RealTime/50.);
93 if (Itime >= TMath::Power(2,24)) Itime = 2^24-1;
95 TimeRow[Item]= Error+Itime;
98 //______________________________________________________________________________
99 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t Fec, UInt_t Tdc, Float_t RealCharge)
101 // Calculate the raw data line relative to the ADC
102 // output of a pad in the current ROC.
106 if (NRoc>=TMath::Power(2,4)) NRoc = 0;
108 if (Fec >=TMath::Power(2,6)) Fec = 0;
110 if (Tdc >=TMath::Power(2,6)) Tdc = 0;
112 ICharge = (UInt_t)(RealCharge/50.);
113 if(ICharge>=TMath::Power(2,16)) ICharge = (UInt_t)TMath::Power(2,16)-1;
114 ChrgRow[Item] = ICharge+NRoc+Fec+Tdc;
117 //______________________________________________________________________________
118 void AliTOFRoc::SetTime(UInt_t Item, UInt_t tir)
120 // Writes the raw data line relative to the TDC
126 //______________________________________________________________________________
127 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t chr)
129 // Writes the raw data line relative to the ADC
135 //______________________________________________________________________________
136 Float_t AliTOFRoc::GetCharge(Int_t Item)
138 // Reads the effective value of the charge starting
139 // from the line of the raw data
142 UInt_t Charge = ChrgRow[Item]&0x0000ffff;
143 Float_t ACharge = (Float_t)Charge*50.;
147 //______________________________________________________________________________
148 Float_t AliTOFRoc::GetTime(Int_t Item, UInt_t& Error)
150 // Reads the effective value of the time of flight starting
151 // from the line of the raw data
154 UInt_t Time = TimeRow[Item]&0x00ffffff;
155 Float_t ATime = (Float_t)Time*50.;
156 Error = TimeRow[Item]>>24;
160 //______________________________________________________________________________
161 Int_t AliTOFRoc::GetTotPad(Int_t Item)
163 // Reads the cohordinates of the pad starting
164 // from the line of the raw data
167 UInt_t NRoc = (ChrgRow[Item]&0xf0000000)>>28;
168 UInt_t NFec = (ChrgRow[Item]&0x0fc00000)>>22;
169 UInt_t NTdc = (ChrgRow[Item]&0x003f0000)>>16;
170 UInt_t Pad = NRoc*32*32+NFec*32+NTdc;
174 //______________________________________________________________________________
175 UInt_t AliTOFRoc::GetCheckSum()
177 // Calculate the checksum word of the current ROC
181 for(Int_t i=0; i<Items; i++){
182 CheckSum += BitCount(GetChrgRow(i));
183 CheckSum += BitCount(GetTimeRow(i));
188 //______________________________________________________________________________
189 UInt_t AliTOFRoc::BitCount(UInt_t x)
191 // Count the "1" bit in the current word
195 for (count=0; x!=0; x>>=1){
196 if(x&0x00000001) count++;
201 //______________________________________________________________________________
202 UInt_t AliTOFRoc::SetSize()
204 // Reads the size of data from current ROC starting
205 // from the header line of the raw data
208 Size = Header&0x0000ffff;
214 //******************************************************************************
216 ClassImp(AliTOFRawSector)
218 //______________________________________________________________________________
219 AliTOFRawSector::AliTOFRawSector()
221 // Constructor of AliTOFRawSector class
222 // Each sector is in effect a
223 // TClonesArray of 14 AliTOFRoc Objects
226 fRocData = new TClonesArray("AliTOFRoc",14);
229 //______________________________________________________________________________
230 AliTOFRawSector::~AliTOFRawSector()
235 //______________________________________________________________________________
236 void AliTOFRawSector::WriteSector()
238 // Starting from the raw data objects writes a binary file
239 // similar to real raw data.
243 rawfile = fopen("rawdata.dat","w");
245 // fprintf(rawfile,Header);
249 for(nRoc=1; nRoc<=14; nRoc++){
250 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
251 currentRoc->SetHeader();
252 UInt_t RocHeader = currentRoc->Header;
253 // fprintf(rawfile,RocHeader);
256 for(nRoc=1; nRoc<=14; nRoc++){
257 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
258 Int_t rocItems = currentRoc->Items;
260 for(Int_t nItem=1; nItem<=rocItems;nItem++){
261 UInt_t TimeRow = currentRoc->GetTimeRow(nItem);
262 // fprintf(rawfile,TimeRow);
263 UInt_t ChrgRow = currentRoc->GetTimeRow(nItem);
264 // fprintf(rawfile,ChrgRow);
268 UInt_t EndOfSector = GlobalCheckSum;
269 // fprintf(rawfile,EndOfSector);
272 //______________________________________________________________________________
273 void AliTOFRawSector::ReadSector()
275 // Starting from raw data initialize and write the
277 //(i.e. a TClonesArray of 18 AliTOFRawSector)
281 rawfile = fopen("rawdata.dat","r");
283 // fscanf(rawfile,Header);
286 for(nRoc=1; nRoc<=14; nRoc++){
287 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
289 // fscanf(rawfile,RocHeader);
290 currentRoc->SetHeader(RocHeader);
294 // fscanf(rawfile,SCMWord);
296 for(nRoc=1; nRoc<=14; nRoc++){
297 AliTOFRoc* currentRoc = (AliTOFRoc*)fRocData->UncheckedAt(nRoc);
298 Int_t Size = currentRoc->SetSize();
299 Int_t nItems = currentRoc->Items;
300 for(Int_t nrow=0; nrow<=nItems; nrow++){
301 UInt_t charRow,timeRow;
302 // fscanf(rawfile, charRow);
303 currentRoc->SetTime(nrow, charRow);
304 // fscanf(rawfile, timeRow);
305 currentRoc->SetTime(nrow, timeRow);
308 // fscanf(rawfile,FinalWord);
310 // fscanf(rawfile,GlobalCheckSum);