1 ////////////////////////////////////////////////
2 // Digitization class for set: TOF //
5 // fItems : number of items //
7 // fNRoc : Roc number //
8 // fHeader: Roc header number //
9 // fChrgRow[1024]; // adc values //
10 // fTimeRow[1024]; // tdc values //
12 // Member functions implemented here //
14 //*-- Authors: Pierella, Seganti, Vicinanza //
15 // (Bologna and Salerno University) //
16 ////////////////////////////////////////////////
19 /**************************************************************************
20 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
22 * Author: The ALICE Off-line Project. *
23 * Contributors are mentioned in the code where appropriate. *
25 * Permission to use, copy, modify and distribute this software and its *
26 * documentation strictly for non-commercial purposes is hereby granted *
27 * without fee, provided that the above copyright notice appears in all *
28 * copies and that both the copyright notice and this permission notice *
29 * appear in the supporting documentation. The authors make no claims *
30 * about the suitability of this software for any purpose. It is *
31 * provided "as is" without express or implied warranty. *
32 **************************************************************************/
34 #include <Riostream.h>
37 #include "AliTOFRoc.h"
42 //______________________________________________________________________________
43 AliTOFRoc::AliTOFRoc()
46 // Constructor of AliTOFRoc class
47 // The class represents a ROC in the TARODA system
48 // here we make the initialization of the member variables
53 // initialization of fChrgRow[1024] and fTimeRow[1024]
54 for(Int_t i=0; i < 1024; i++){
60 //______________________________________________________________________________
61 AliTOFRoc::AliTOFRoc(const AliTOFRoc& tofroc)
63 // : fItems(tofroc.fItems), fSize(tofroc.fSize), fNRoc(tofroc.fNRoc), fHeader(tofroc.fHeader)
66 // copy ctor for AliTOFRoc class
68 assert(tofroc.fItems >= 0); // check for number of items
69 assert(tofroc.fSize >= 0); // check for roc size
70 // making a copy of adc and tdc vectors
71 for(Int_t i=0; i < 1024; i++){
72 fChrgRow[i] = tofroc.fChrgRow[i]; // coping adc values
73 fTimeRow[i] = tofroc.fTimeRow[i]; // coping tdc values
77 //______________________________________________________________________________
78 AliTOFRoc& AliTOFRoc::operator=(const AliTOFRoc& tofroc)
81 // Assignment operator for AliTOFRoc
82 // (used by copy ctor of AliTOFRawSector)
84 if (this !=&tofroc) { // do nothing if assigned to self
85 // setting head member data
86 SetHeadVar(tofroc.fItems,tofroc.fSize,tofroc.fNRoc,tofroc.fHeader);
87 // loop on adc and tdc values
88 for(Int_t i=0; i < 1024; i++){
89 fChrgRow[i] = tofroc.fChrgRow[i]; // coping adc values
90 fTimeRow[i] = tofroc.fTimeRow[i]; // coping tdc values
96 //______________________________________________________________________________
97 AliTOFRoc::~AliTOFRoc(){}
99 //______________________________________________________________________________
100 Int_t AliTOFRoc::AddItem(Int_t Fec, Int_t Tdc, Int_t Error,
101 Float_t Charge, Float_t Time)
104 // Adds an item (i.e. the charge, the TOF and the
105 // cohordinates of a hit pad) to the ROC class.
108 SetCharge(fItems,Fec,Tdc,Charge);
109 SetTime (fItems,Error,Time);
110 return fItems; // return the number of current items
113 //______________________________________________________________________________
114 void AliTOFRoc::SetHeadVar(Int_t items, Int_t size, Int_t nroc, UInt_t header)
117 // set header member variables for AliTOFRoc
125 //______________________________________________________________________________
126 void AliTOFRoc::SetHeader()
129 // Calculate the header line of the ROC in the raw data file
137 //______________________________________________________________________________
138 void AliTOFRoc::SetTime(UInt_t Item, UInt_t Error, Float_t RealTime)
141 // Calculate the raw data line relative to the TDC
142 // output of a pad in the current ROC.
146 itime = (UInt_t)(RealTime/50.);
147 if (itime >= TMath::Power(2,24)) itime = 2^24-1;
149 fTimeRow[Item]= Error+itime;
152 //______________________________________________________________________________
153 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t Fec, UInt_t Tdc, Float_t RealCharge)
156 // Calculate the raw data line relative to the ADC
157 // output of a pad in the current ROC.
161 if (fNRoc>=TMath::Power(2,4)) fNRoc = 0;
163 if (Fec >=TMath::Power(2,6)) Fec = 0;
165 if (Tdc >=TMath::Power(2,6)) Tdc = 0;
167 iCharge = (UInt_t)(RealCharge/50.); // 50 ps (TDC bin value)
168 if(iCharge>=TMath::Power(2,16)) iCharge = (UInt_t)TMath::Power(2,16)-1;
169 fChrgRow[Item] = iCharge+fNRoc+Fec+Tdc;
172 //______________________________________________________________________________
173 void AliTOFRoc::SetTime(UInt_t Item, UInt_t tir)
176 // Writes the raw data line relative to the TDC
182 //______________________________________________________________________________
183 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t chr)
186 // Writes the raw data line relative to the ADC
192 //______________________________________________________________________________
193 Float_t AliTOFRoc::GetCharge(Int_t Item) const
196 // Reads the effective value of the charge starting
197 // from the line of the raw data
200 UInt_t icharge = fChrgRow[Item]&0x0000ffff;
201 Float_t charge = (Float_t)icharge*50.;
205 //______________________________________________________________________________
206 Float_t AliTOFRoc::GetTime(Int_t Item, UInt_t& Error)
209 // Reads the effective value of the time of flight starting
210 // from the line of the raw data
213 UInt_t itime = fTimeRow[Item]&0x00ffffff;
214 Float_t time = (Float_t)itime*50.;
215 Error = fTimeRow[Item]>>24; // the same as Error = fTimeRow[Item] / 24;
219 //______________________________________________________________________________
220 Int_t AliTOFRoc::GetTotPad(Int_t Item) const
223 // Reads the cohordinates of the pad starting
224 // from the line of the raw data
227 UInt_t nRoc = (fChrgRow[Item]&0xf0000000)>>28; // >> the same as / (division by)
228 UInt_t nFec = (fChrgRow[Item]&0x0fc00000)>>22;
229 UInt_t nTdc = (fChrgRow[Item]&0x003f0000)>>16;
230 UInt_t pad = nRoc*32*32+nFec*32+nTdc;
234 //______________________________________________________________________________
235 UInt_t AliTOFRoc::GetCheckSum()
238 // Calculate the checksum word of the current ROC
242 for(Int_t i=0; i<fItems; i++){
243 checkSum += BitCount(GetChrgRow(i));
244 checkSum += BitCount(GetTimeRow(i));
249 //______________________________________________________________________________
250 UInt_t AliTOFRoc::BitCount(UInt_t x) const
253 // Count the "1" bit in the current word
257 for (count=0; x!=0; x>>=1){
258 if(x&0x00000001) count++;
263 //______________________________________________________________________________
264 UInt_t AliTOFRoc::SetSize()
267 // Reads the size of data from current ROC starting
268 // from the header line of the raw data
271 fSize = fHeader&0x0000ffff;
272 fItems = (fSize-4)/4;