]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFRoc.cxx
set as default configuration the geometry with PHOS holes
[u/mrichter/AliRoot.git] / TOF / AliTOFRoc.cxx
1 ////////////////////////////////////////////////
2 //  Digitization class for set: TOF           //
3 //  AliTOFRoc  class                          //
4 //  Member variables                          //
5 //   fItems :  number of items                //
6 //   fSize  :  size                           //
7 //   fNRoc  :  Roc number                     //
8 //   fHeader:  Roc header number              //
9 //   fChrgRow[1024]; // adc values            //
10 //   fTimeRow[1024]; // tdc values            //
11 //                                            //
12 //  Member functions implemented here         //
13 //                                            //
14 //*-- Authors: Pierella, Seganti, Vicinanza   //
15 //    (Bologna and Salerno University)        //
16 ////////////////////////////////////////////////
17
18
19 /**************************************************************************
20  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
21  *                                                                        *
22  * Author: The ALICE Off-line Project.                                    *
23  * Contributors are mentioned in the code where appropriate.              *
24  *                                                                        *
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  **************************************************************************/
33
34 #include <Riostream.h>
35 #include <assert.h>
36
37 #include "AliTOFRoc.h"
38
39
40 ClassImp(AliTOFRoc)
41
42 //______________________________________________________________________________
43 AliTOFRoc::AliTOFRoc()
44 {
45 //
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
49   fItems = 0;
50   fSize  = 0;
51   fNRoc  = 0;
52   fHeader= 0;
53 // initialization of fChrgRow[1024] and fTimeRow[1024]
54   for(Int_t i=0; i < 1024; i++){
55      fChrgRow[i] = 0;
56      fTimeRow[i] = 0;
57   } // end loop
58 }
59
60 //______________________________________________________________________________
61 AliTOFRoc::AliTOFRoc(const AliTOFRoc& tofroc)
62 :TObject()
63 // : fItems(tofroc.fItems), fSize(tofroc.fSize), fNRoc(tofroc.fNRoc), fHeader(tofroc.fHeader) 
64
65 //
66 // copy ctor for AliTOFRoc class 
67 //
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
74    } // end loop
75 }
76
77 //______________________________________________________________________________
78 AliTOFRoc& AliTOFRoc::operator=(const AliTOFRoc& tofroc)
79 {
80 //
81 // Assignment operator for AliTOFRoc
82 // (used by copy ctor of AliTOFRawSector)
83 //
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
91      } // end loop
92    }
93    return *this;
94 }
95
96 //______________________________________________________________________________
97 AliTOFRoc::~AliTOFRoc(){}
98
99 //______________________________________________________________________________
100 Int_t AliTOFRoc::AddItem(Int_t Fec, Int_t Tdc, Int_t Error,
101                          Float_t Charge, Float_t Time)
102 {
103 //
104 // Adds an item (i.e. the charge, the TOF and the 
105 // cohordinates of a hit pad) to the ROC class.
106 //
107    fItems++;
108    SetCharge(fItems,Fec,Tdc,Charge);
109    SetTime  (fItems,Error,Time);
110    return fItems; // return the number of current items   
111 }
112
113 //______________________________________________________________________________
114 void AliTOFRoc::SetHeadVar(Int_t items, Int_t size, Int_t nroc, UInt_t header)
115 {
116 //
117 // set header member variables for AliTOFRoc 
118 //
119   fItems = items;
120   fSize  = size ;
121   fNRoc  = nroc ;
122   fHeader= header ;
123 }
124
125 //______________________________________________________________________________
126 void AliTOFRoc::SetHeader()
127 {
128 //
129 // Calculate the header line of the ROC in the raw data file
130 //
131
132    fHeader  = fNRoc<<28;
133    fHeader += fSize;
134 }
135
136
137 //______________________________________________________________________________
138 void AliTOFRoc::SetTime(UInt_t Item, UInt_t Error, Float_t RealTime)
139 {
140 //
141 // Calculate the raw data line relative to the TDC
142 // output of a pad in the current ROC.
143 //
144
145    UInt_t itime;
146    itime = (UInt_t)(RealTime/50.);
147    if (itime >= TMath::Power(2,24)) itime = 2^24-1;
148    Error <<= 24;
149    fTimeRow[Item]= Error+itime;
150 }
151
152 //______________________________________________________________________________
153 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t Fec, UInt_t Tdc, Float_t RealCharge)
154 {
155 //
156 // Calculate the raw data line relative to the ADC 
157 // output of a pad in the current ROC.
158 //
159
160    UInt_t iCharge;
161    if (fNRoc>=TMath::Power(2,4)) fNRoc = 0;
162    fNRoc <<= 28;
163    if (Fec >=TMath::Power(2,6))  Fec = 0;
164    Fec  <<= 22;
165    if (Tdc >=TMath::Power(2,6))  Tdc = 0;
166    Tdc  <<= 16;
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;
170 }
171
172 //______________________________________________________________________________
173 void AliTOFRoc::SetTime(UInt_t Item, UInt_t tir)
174 {
175 //
176 // Writes the raw data line relative to the TDC
177 //
178
179    fChrgRow[Item]=tir;
180 }
181
182 //______________________________________________________________________________
183 void AliTOFRoc::SetCharge(UInt_t Item, UInt_t chr)
184 {
185 //
186 // Writes the raw data line relative to the ADC
187 //
188
189    fChrgRow[Item]=chr;
190 }
191
192 //______________________________________________________________________________
193 Float_t AliTOFRoc::GetCharge(Int_t Item) const
194 {
195 //
196 // Reads the effective value of the charge starting
197 // from the line of the raw data
198 //
199
200    UInt_t  icharge  = fChrgRow[Item]&0x0000ffff;
201    Float_t charge = (Float_t)icharge*50.;
202    return charge;
203 }
204
205 //______________________________________________________________________________
206 Float_t AliTOFRoc::GetTime(Int_t Item, UInt_t& Error) 
207 {
208 //
209 // Reads the effective value of the time of flight starting
210 // from the line of the raw data
211 //
212
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;
216    return time; 
217 }
218
219 //______________________________________________________________________________
220 Int_t AliTOFRoc::GetTotPad(Int_t Item) const
221 {
222 //
223 // Reads the cohordinates of the pad starting
224 // from the line of the raw data
225 //
226
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;
231    return pad; 
232 }
233
234 //______________________________________________________________________________
235 UInt_t AliTOFRoc::GetCheckSum()
236 {
237 //
238 // Calculate the checksum word of the current ROC
239 // 
240
241    UInt_t checkSum=0;
242    for(Int_t i=0; i<fItems; i++){
243       checkSum += BitCount(GetChrgRow(i));
244       checkSum += BitCount(GetTimeRow(i));
245    }
246    return checkSum;
247 }
248
249 //______________________________________________________________________________
250 UInt_t AliTOFRoc::BitCount(UInt_t x) const
251 {
252 //
253 // Count the "1" bit in the current word
254 //
255
256    UInt_t count=0;
257    for (count=0; x!=0; x>>=1){
258       if(x&0x00000001) count++;
259    }
260    return count;
261 }
262
263 //______________________________________________________________________________
264 UInt_t AliTOFRoc::SetSize()
265 {
266 //
267 // Reads the size of data from current ROC starting
268 // from the header line of the raw data
269 //
270
271    fSize = fHeader&0x0000ffff;
272    fItems = (fSize-4)/4;
273    return fSize;
274 }
275
276
277