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 **************************************************************************/
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)
62 : fItems(tofroc.fItems), fSize(tofroc.fSize), fNRoc(tofroc.fNRoc), fHeader(tofroc.fHeader)
65 // copy ctor for AliTOFRoc class
67 assert(tofroc.fItems >= 0); // check for number of items
68 assert(tofroc.fSize >= 0); // check for roc size
69 // making a copy of adc and tdc vectors
70 for(Int_t i=0; i < 1024; i++){
71 fChrgRow[i] = tofroc.fChrgRow[i]; // coping adc values
72 fTimeRow[i] = tofroc.fTimeRow[i]; // coping tdc values
76 //______________________________________________________________________________
77 AliTOFRoc& AliTOFRoc::operator=(const AliTOFRoc& tofroc)
80 // Assignment operator for AliTOFRoc
81 // (used by copy ctor of AliTOFRawSector)
83 if (this !=&tofroc) { // do nothing if assigned to self
84 // setting head member data
85 SetHeadVar(tofroc.fItems,tofroc.fSize,tofroc.fNRoc,tofroc.fHeader);
86 // loop on adc and tdc values
87 for(Int_t i=0; i < 1024; i++){
88 fChrgRow[i] = tofroc.fChrgRow[i]; // coping adc values
89 fTimeRow[i] = tofroc.fTimeRow[i]; // coping tdc values
95 //______________________________________________________________________________
96 AliTOFRoc::~AliTOFRoc(){}
98 //______________________________________________________________________________
99 Int_t AliTOFRoc::AddItem(Int_t Fec, Int_t Tdc, Int_t Error,
100 Float_t Charge, Float_t Time)
103 // Adds an item (i.e. the charge, the TOF and the
104 // cohordinates of a hit pad) to the ROC class.
107 SetCharge(fItems,Fec,Tdc,Charge);
108 SetTime (fItems,Error,Time);
109 return fItems; // return the number of current items
112 //______________________________________________________________________________
113 void AliTOFRoc::SetHeadVar(Int_t items, Int_t size, Int_t nroc, UInt_t header)
116 // set header member variables for AliTOFRoc
124 //______________________________________________________________________________
125 void AliTOFRoc::SetHeader()
128 // Calculate the header line of the ROC in the raw data file
136 //______________________________________________________________________________
137 void AliTOFRoc::SetTime(UInt_t Item, UInt_t Error, Float_t RealTime)
140 // Calculate the raw data line relative to the TDC
141 // output of a pad in the current ROC.
145 itime = (UInt_t)(RealTime/50.);
146 if (itime >= TMath::Power(2,24)) itime = 2^24-1;
148 fTimeRow[Item]= Error+itime;
151 //______________________________________________________________________________
152 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t Fec, UInt_t Tdc, Float_t RealCharge)
155 // Calculate the raw data line relative to the ADC
156 // output of a pad in the current ROC.
160 if (fNRoc>=TMath::Power(2,4)) fNRoc = 0;
162 if (Fec >=TMath::Power(2,6)) Fec = 0;
164 if (Tdc >=TMath::Power(2,6)) Tdc = 0;
166 iCharge = (UInt_t)(RealCharge/50.); // 50 ps (TDC bin value)
167 if(iCharge>=TMath::Power(2,16)) iCharge = (UInt_t)TMath::Power(2,16)-1;
168 fChrgRow[Item] = iCharge+fNRoc+Fec+Tdc;
171 //______________________________________________________________________________
172 void AliTOFRoc::SetTime(UInt_t Item, UInt_t tir)
175 // Writes the raw data line relative to the TDC
181 //______________________________________________________________________________
182 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t chr)
185 // Writes the raw data line relative to the ADC
191 //______________________________________________________________________________
192 Float_t AliTOFRoc::GetCharge(Int_t Item) const
195 // Reads the effective value of the charge starting
196 // from the line of the raw data
199 UInt_t icharge = fChrgRow[Item]&0x0000ffff;
200 Float_t charge = (Float_t)icharge*50.;
204 //______________________________________________________________________________
205 Float_t AliTOFRoc::GetTime(Int_t Item, UInt_t& Error)
208 // Reads the effective value of the time of flight starting
209 // from the line of the raw data
212 UInt_t itime = fTimeRow[Item]&0x00ffffff;
213 Float_t time = (Float_t)itime*50.;
214 Error = fTimeRow[Item]>>24; // the same as Error = fTimeRow[Item] / 24;
218 //______________________________________________________________________________
219 Int_t AliTOFRoc::GetTotPad(Int_t Item) const
222 // Reads the cohordinates of the pad starting
223 // from the line of the raw data
226 UInt_t nRoc = (fChrgRow[Item]&0xf0000000)>>28; // >> the same as / (division by)
227 UInt_t nFec = (fChrgRow[Item]&0x0fc00000)>>22;
228 UInt_t nTdc = (fChrgRow[Item]&0x003f0000)>>16;
229 UInt_t pad = nRoc*32*32+nFec*32+nTdc;
233 //______________________________________________________________________________
234 UInt_t AliTOFRoc::GetCheckSum()
237 // Calculate the checksum word of the current ROC
241 for(Int_t i=0; i<fItems; i++){
242 checkSum += BitCount(GetChrgRow(i));
243 checkSum += BitCount(GetTimeRow(i));
248 //______________________________________________________________________________
249 UInt_t AliTOFRoc::BitCount(UInt_t x) const
252 // Count the "1" bit in the current word
256 for (count=0; x!=0; x>>=1){
257 if(x&0x00000001) count++;
262 //______________________________________________________________________________
263 UInt_t AliTOFRoc::SetSize()
266 // Reads the size of data from current ROC starting
267 // from the header line of the raw data
270 fSize = fHeader&0x0000ffff;
271 fItems = (fSize-4)/4;