]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDfeeParam.cxx
Changing fabs into TMath::Abs
[u/mrichter/AliRoot.git] / TRD / AliTRDfeeParam.cxx
1
2 /**************************************************************************
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  *                                                                        *
5  * Author: The ALICE Off-line Project.                                    *
6  * Contributors are mentioned in the code where appropriate.              *
7  *                                                                        *
8  * Permission to use, copy, modify and distribute this software and its   *
9  * documentation strictly for non-commercial purposes is hereby granted   *
10  * without fee, provided that the above copyright notice appears in all   *
11  * copies and that both the copyright notice and this permission notice   *
12  * appear in the supporting documentation. The authors make no claims     *
13  * about the suitability of this software for any purpose. It is          *
14  * provided "as is" without express or implied warranty.                  *
15  **************************************************************************/
16
17 /* $Id$ */
18
19 ////////////////////////////////////////////////////////////////////////////
20 //                                                                        //
21 //  TRD front end electronics parameters class                            //
22 //  Contains all FEE (MCM, TRAP, PASA) related                            //
23 //  parameters, constants, and mapping.                                   //
24 //                                                                        //
25 //  New release on 2007/08/17:                                            //
26 //   The default raw data version (now fRAWversion ) is set to 3          //
27 //   in the constructor because version 3 raw data read and write         //
28 //   are fully debugged.                                                  //
29 //                                                                        //
30 //  Author:                                                               //
31 //    Ken Oyama (oyama@physi.uni-heidelberg.de)                           //
32 //                                                                        //
33 ////////////////////////////////////////////////////////////////////////////
34
35 #include <TMath.h>
36
37 #include "AliLog.h"
38
39 #include "AliTRDfeeParam.h"
40 #include "AliTRDgeometry.h"
41 #include "AliTRDCommonParam.h"
42
43 ClassImp(AliTRDfeeParam)
44
45 AliTRDfeeParam *AliTRDfeeParam::fgInstance   = 0;
46 Bool_t          AliTRDfeeParam::fgTerminated = kFALSE;
47
48 //_____________________________________________________________________________
49 AliTRDfeeParam* AliTRDfeeParam::Instance()
50 {
51   //
52   // Instance constructor
53   //
54
55   if (fgTerminated != kFALSE) {
56     return 0;
57   }
58
59   if (fgInstance == 0) {
60     fgInstance = new AliTRDfeeParam();
61   }  
62
63   return fgInstance;
64
65 }
66
67 //_____________________________________________________________________________
68 void AliTRDfeeParam::Terminate()
69 {
70   //
71   // Terminate the class and release memory
72   //
73   
74   fgTerminated = kTRUE;
75
76   if (fgInstance != 0) {
77     delete fgInstance;
78     fgInstance = 0;
79   }
80
81 }
82
83 //_____________________________________________________________________________
84 AliTRDfeeParam::AliTRDfeeParam()
85   :TObject()
86   ,fCP(0)
87   ,fTFr1(0)
88   ,fTFr2(0)
89   ,fTFc1(0)
90   ,fTFc2(0)
91   ,fEBsglIndThr(5)
92   ,fEBsumIndThr(5)
93   ,fEBindLUT(0xF0)
94   ,fEBignoreNeighbour(0)
95   ,fRAWversion(3)
96   ,fRAWstoreRaw(kTRUE)
97 {
98   //
99   // Default constructor
100   //
101   
102   // PASA V.4
103   if      (fgkTFnExp == 1) {
104     fTFr1 = 1.1563;
105     fTFr2 = 0.1299;
106     fTFc1 = 0.0657;
107     fTFc2 = 0.0000;
108   }
109   else if (fgkTFnExp == 2) {
110     fTFr1 = 1.1563;
111     fTFr2 = 0.1299;
112     fTFc1 = 0.1141;
113     fTFc2 = 0.6241;
114   }
115
116   fCP  = AliTRDCommonParam::Instance();
117
118 }
119
120 //_____________________________________________________________________________
121 AliTRDfeeParam::AliTRDfeeParam(TRootIoCtor *)
122   :TObject()
123   ,fCP(0)
124   ,fTFr1(0)
125   ,fTFr2(0)
126   ,fTFc1(0)
127   ,fTFc2(0)
128   ,fEBsglIndThr(0)
129   ,fEBsumIndThr(0)
130   ,fEBindLUT(0)
131   ,fEBignoreNeighbour(0)
132   ,fRAWversion(0)
133   ,fRAWstoreRaw(0)
134 {
135   //
136   // IO constructor
137   //
138
139 }
140
141 //_____________________________________________________________________________
142 AliTRDfeeParam::AliTRDfeeParam(const AliTRDfeeParam &p)
143   :TObject(p)
144   ,fCP(p.fCP)
145   ,fTFr1(p.fTFr1)
146   ,fTFr2(p.fTFr2)
147   ,fTFc1(p.fTFc1)
148   ,fTFc2(p.fTFc2)
149   ,fEBsglIndThr(p.fEBsglIndThr)
150   ,fEBsumIndThr(p.fEBsumIndThr)
151   ,fEBindLUT(p.fEBindLUT)
152   ,fEBignoreNeighbour (p.fEBignoreNeighbour)
153   ,fRAWversion(p.fRAWversion)
154   ,fRAWstoreRaw(p.fRAWstoreRaw)
155 {
156   //
157   // AliTRDfeeParam copy constructor
158   //
159
160 }
161
162 //_____________________________________________________________________________
163 AliTRDfeeParam::~AliTRDfeeParam()
164 {
165   //
166   // AliTRDfeeParam destructor
167   //
168
169 }
170
171 //_____________________________________________________________________________
172 AliTRDfeeParam &AliTRDfeeParam::operator=(const AliTRDfeeParam &p)
173 {
174   //
175   // Assignment operator
176   //
177
178   if (this != &p) {
179     ((AliTRDfeeParam &) p).Copy(*this);
180   }
181
182   return *this;
183
184 }
185
186 //_____________________________________________________________________________
187 void AliTRDfeeParam::Copy(TObject &p) const
188 {
189   //
190   // Copy function
191   //
192
193   ((AliTRDfeeParam &) p).fCP          = fCP;
194   ((AliTRDfeeParam &) p).fTFr1        = fTFr1;
195   ((AliTRDfeeParam &) p).fTFr2        = fTFr2;
196   ((AliTRDfeeParam &) p).fTFc1        = fTFc1;
197   ((AliTRDfeeParam &) p).fTFc2        = fTFc2;
198   ((AliTRDfeeParam &) p).fEBsglIndThr = fEBsglIndThr;
199   ((AliTRDfeeParam &) p).fEBsumIndThr = fEBsumIndThr;
200   ((AliTRDfeeParam &) p).fEBindLUT    = fEBindLUT;
201   ((AliTRDfeeParam &) p).fEBignoreNeighbour = fEBignoreNeighbour;
202   ((AliTRDfeeParam &) p).fRAWversion  = fRAWversion;
203   ((AliTRDfeeParam &) p).fRAWstoreRaw = fRAWstoreRaw;
204   
205   TObject::Copy(p);
206
207 }
208
209 //_____________________________________________________________________________
210 Int_t AliTRDfeeParam::GetPadRowFromMCM(Int_t irob, Int_t imcm) const
211 {
212   //
213   // Return on which pad row this mcm sits
214   //
215   
216   return fgkNmcmRobInRow*(irob/2) + imcm/fgkNmcmRobInCol;
217
218 }
219
220 //_____________________________________________________________________________
221 Int_t AliTRDfeeParam::GetPadColFromADC(Int_t irob, Int_t imcm, Int_t iadc) const
222 {
223   //
224   // Return which pad is connected to this adc channel.
225   //
226   // Return virtual pad number even if ADC is outside chamber
227   // to keep compatibility of data processing at the edge MCM.
228   // User has to check that this is in the chamber if it is essential.
229   // Return -100 if iadc is invalid.
230   //
231   // Caution: ADC ordering in the online data is opposite to the pad column ordering.
232   // And it is not one-by-one correspondence. Precise drawing can be found in:
233   // http://wiki.kip.uni-heidelberg.de/ti/TRD/index.php/Image:ROB_MCM_numbering.pdf
234   //
235
236   if (iadc < 0 || iadc > 19 ) return -100;
237   Int_t mcmcol = imcm%fgkNmcmRobInCol + GetRobSide(irob)*fgkNmcmRobInCol;  // MCM column number on ROC [0..7]
238   Int_t padcol = mcmcol*fgkNcolMcm + fgkNcolMcm + 1 - iadc;
239   // if( padcol < 0 || padcol >= fgkNcol ) return -1;   // thisi s commented because of reson above KO
240
241   return padcol;
242
243 }
244
245 //_____________________________________________________________________________
246 Int_t AliTRDfeeParam::GetMCMfromPad(Int_t irow, Int_t icol) const
247 {
248   //
249   // Return on which MCM this pad is directry connected.
250   // Return -1 for error.
251   //
252
253   if ( irow < 0 || icol < 0 || irow > fgkNrowC1 || icol > fgkNcol ) return -1;
254
255   return (icol%(fgkNcol/2))/fgkNcolMcm + fgkNmcmRobInCol*(irow%fgkNmcmRobInRow);
256
257 }
258
259 //_____________________________________________________________________________
260 Int_t AliTRDfeeParam::GetROBfromPad(Int_t irow, Int_t icol) const
261 {
262   //
263   // Return on which rob this pad is
264   //
265
266   return (irow/fgkNmcmRobInRow)*2 + GetColSide(icol);
267
268 }
269
270 //_____________________________________________________________________________
271 Int_t AliTRDfeeParam::GetRobSide(Int_t irob) const
272 {
273   //
274   // Return on which side this rob sits (A side = 0, B side = 1)
275   //
276
277   if ( irob < 0 || irob >= fgkNrobC1 ) return -1;
278
279   return irob%2;
280
281 }
282
283 //_____________________________________________________________________________
284 Int_t AliTRDfeeParam::GetColSide(Int_t icol) const
285 {
286   //
287   // Return on which side this column sits (A side = 0, B side = 1)
288   //
289
290   if ( icol < 0 || icol >= fgkNcol ) return -1;
291
292   return icol/(fgkNcol/2);
293
294 }
295
296 //_____________________________________________________________________________
297 //void AliTRDfeeParam::GetFilterParam( Float_t &r1, Float_t &r2, Float_t &c1
298 //                                   , Float_t &c2, Float_t &ped ) const
299 //{
300   //
301   // Return current filter parameter
302   //
303
304   //  r1            = fR1;
305   //r2            = fR2;
306   //c1            = fC1;
307   //c2            = fC2;
308   //ped           = fPedestal;
309 //};
310
311 //_____________________________________________________________________________
312 void AliTRDfeeParam::SetEBsglIndThr(Int_t val)
313 {
314   //
315   // Set Event Buffer Sngle Indicator Threshold (EBIS in TRAP conf).
316   // Timebin is indicated if ADC value >= val.
317   //
318
319   if( val >= 0 && val <= 1023 ) { 
320     fEBsglIndThr = val;
321   } else {
322     AliError(Form("EBsglIndThr value %d is out of range, keep previously set value (%d).",
323                   val, fEBsglIndThr));
324   }
325
326 }
327
328 //_____________________________________________________________________________
329 void AliTRDfeeParam::SetEBsumIndThr(Int_t val)
330 {
331   //
332   // Set Event Buffer Sum Indicator Threshold (EBIT in TRAP conf).
333   // Timebin is indicated if ADC sum value >= val.
334   //
335
336   if( val >= 0 && val <= 4095 ) { 
337     fEBsumIndThr = val;
338   } 
339   else {
340     AliError(Form("EBsumIndThr value %d is out of range, keep previously set value (%d).",
341                   val, fEBsumIndThr));
342   }
343
344 }
345
346 //_____________________________________________________________________________
347 void AliTRDfeeParam::SetEBindLUT(Int_t val)
348 {
349   //
350   // Set Event Buffer Indicator Look-Up Table (EBIL in TRAP conf).
351   // 8 bits value forms lookup table for combination of three criterions.
352   //
353
354   if( val >= 0 && val <= 255 ) {
355     fEBindLUT = val;
356   } 
357   else {
358     AliError(Form("EBindLUT value %d is out of range, keep previously set value (%d).",
359                   val, fEBindLUT));
360   }
361
362 }
363
364 //_____________________________________________________________________________
365 void AliTRDfeeParam::SetEBignoreNeighbour(Int_t val)
366 {
367   //
368   // Set Event Buffer Indicator Neighbor Sensitivity. (EBIN in TRAP conf).
369   // If 0, take account of neigbor's values.
370   //
371
372   if( val >= 0 && val <= 1 ) {
373     fEBignoreNeighbour = val;
374   } 
375   else {
376     AliError(Form("EBignoreNeighbour value %d is out of range, keep previously set value (%d).",
377                   val, fEBignoreNeighbour));
378   }
379 }
380
381 //_____________________________________________________________________________
382 void AliTRDfeeParam::SetRAWversion( Int_t rawver )
383 {
384   //
385   // Set raw data version (major number only)
386   // Maximum available number is preset in fgkMaxRAWversion
387   //
388
389   if( rawver >= 0 && rawver <= fgkMaxRAWversion ) {
390     fRAWversion = rawver;
391   } 
392   else {
393     AliError(Form("Raw version is out of range: %d",rawver));
394   }
395
396 }