]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDfeeParam.cxx
Add a protection against division by zero
[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 Bool_t          AliTRDfeeParam::fgTracklet = kFALSE;
48
49 //_____________________________________________________________________________
50 AliTRDfeeParam* AliTRDfeeParam::Instance()
51 {
52   //
53   // Instance constructor
54   //
55
56   if (fgTerminated != kFALSE) {
57     return 0;
58   }
59
60   if (fgInstance == 0) {
61     fgInstance = new AliTRDfeeParam();
62   }  
63
64   return fgInstance;
65
66 }
67
68 //_____________________________________________________________________________
69 void AliTRDfeeParam::Terminate()
70 {
71   //
72   // Terminate the class and release memory
73   //
74   
75   fgTerminated = kTRUE;
76
77   if (fgInstance != 0) {
78     delete fgInstance;
79     fgInstance = 0;
80   }
81
82 }
83
84 //_____________________________________________________________________________
85 AliTRDfeeParam::AliTRDfeeParam()
86   :TObject()
87   ,fCP(0)
88   ,fTFnExp(1)
89   ,fTFr1(0)
90   ,fTFr2(0)
91   ,fTFc1(0)
92   ,fTFc2(0)
93   ,fEBsglIndThr(5)
94   ,fEBsumIndThr(5)
95   ,fEBindLUT(0xF0)
96   ,fEBignoreNeighbour(0)
97   ,fRAWversion(3)
98   ,fRAWstoreRaw(kTRUE)
99 {
100   //
101   // Default constructor
102   //
103   
104   // PASA V.4
105   if      (fTFnExp == 1) {
106     fTFr1 = 1.1563;
107     fTFr2 = 0.1299;
108     fTFc1 = 0.0657;
109     fTFc2 = 0.0000;
110   }
111   else if (fTFnExp == 2) {
112     fTFr1 = 1.1563;
113     fTFr2 = 0.1299;
114     fTFc1 = 0.1141;
115     fTFc2 = 0.6241;
116   }
117
118   fCP  = AliTRDCommonParam::Instance();
119
120 }
121
122 //_____________________________________________________________________________
123 AliTRDfeeParam::AliTRDfeeParam(TRootIoCtor *)
124   :TObject()
125   ,fCP(0)
126   ,fTFnExp(1)
127   ,fTFr1(0)
128   ,fTFr2(0)
129   ,fTFc1(0)
130   ,fTFc2(0)
131   ,fEBsglIndThr(0)
132   ,fEBsumIndThr(0)
133   ,fEBindLUT(0)
134   ,fEBignoreNeighbour(0)
135   ,fRAWversion(0)
136   ,fRAWstoreRaw(0)
137 {
138   //
139   // IO constructor
140   //
141
142 }
143
144 //_____________________________________________________________________________
145 AliTRDfeeParam::AliTRDfeeParam(const AliTRDfeeParam &p)
146   :TObject(p)
147   ,fCP(p.fCP)
148   ,fTFnExp(p.fTFnExp)
149   ,fTFr1(p.fTFr1)
150   ,fTFr2(p.fTFr2)
151   ,fTFc1(p.fTFc1)
152   ,fTFc2(p.fTFc2)
153   ,fEBsglIndThr(p.fEBsglIndThr)
154   ,fEBsumIndThr(p.fEBsumIndThr)
155   ,fEBindLUT(p.fEBindLUT)
156   ,fEBignoreNeighbour (p.fEBignoreNeighbour)
157   ,fRAWversion(p.fRAWversion)
158   ,fRAWstoreRaw(p.fRAWstoreRaw)
159 {
160   //
161   // AliTRDfeeParam copy constructor
162   //
163
164 }
165
166 //_____________________________________________________________________________
167 AliTRDfeeParam::~AliTRDfeeParam()
168 {
169   //
170   // AliTRDfeeParam destructor
171   //
172
173 }
174
175 //_____________________________________________________________________________
176 AliTRDfeeParam &AliTRDfeeParam::operator=(const AliTRDfeeParam &p)
177 {
178   //
179   // Assignment operator
180   //
181
182   if (this != &p) {
183     ((AliTRDfeeParam &) p).Copy(*this);
184   }
185
186   return *this;
187
188 }
189
190 //_____________________________________________________________________________
191 void AliTRDfeeParam::Copy(TObject &p) const
192 {
193   //
194   // Copy function
195   //
196
197   ((AliTRDfeeParam &) p).fCP          = fCP;
198   ((AliTRDfeeParam &) p).fTFnExp      = fTFnExp;
199   ((AliTRDfeeParam &) p).fTFr1        = fTFr1;
200   ((AliTRDfeeParam &) p).fTFr2        = fTFr2;
201   ((AliTRDfeeParam &) p).fTFc1        = fTFc1;
202   ((AliTRDfeeParam &) p).fTFc2        = fTFc2;
203   ((AliTRDfeeParam &) p).fEBsglIndThr = fEBsglIndThr;
204   ((AliTRDfeeParam &) p).fEBsumIndThr = fEBsumIndThr;
205   ((AliTRDfeeParam &) p).fEBindLUT    = fEBindLUT;
206   ((AliTRDfeeParam &) p).fEBignoreNeighbour = fEBignoreNeighbour;
207   ((AliTRDfeeParam &) p).fRAWversion  = fRAWversion;
208   ((AliTRDfeeParam &) p).fRAWstoreRaw = fRAWstoreRaw;
209   
210   TObject::Copy(p);
211
212 }
213
214 //_____________________________________________________________________________
215 Int_t AliTRDfeeParam::GetPadRowFromMCM(Int_t irob, Int_t imcm) const
216 {
217   //
218   // Return on which pad row this mcm sits
219   //
220   
221   return fgkNmcmRobInRow*(irob/2) + imcm/fgkNmcmRobInCol;
222
223 }
224
225 //_____________________________________________________________________________
226 Int_t AliTRDfeeParam::GetPadColFromADC(Int_t irob, Int_t imcm, Int_t iadc) const
227 {
228   //
229   // Return which pad is connected to this adc channel.
230   //
231   // Return virtual pad number even if ADC is outside chamber
232   // to keep compatibility of data processing at the edge MCM.
233   // User has to check that this is in the chamber if it is essential.
234   // Return -100 if iadc is invalid.
235   //
236   // Caution: ADC ordering in the online data is opposite to the pad column ordering.
237   // And it is not one-by-one correspondence. Precise drawing can be found in:
238   // http://wiki.kip.uni-heidelberg.de/ti/TRD/index.php/Image:ROB_MCM_numbering.pdf
239   //
240
241   if (iadc < 0 || iadc > fgkNadcMcm ) return -100;
242   Int_t mcmcol = imcm%fgkNmcmRobInCol + GetRobSide(irob)*fgkNmcmRobInCol;  // MCM column number on ROC [0..7]
243   Int_t padcol = mcmcol*fgkNcolMcm + fgkNcolMcm + 1 - iadc;
244   // if( padcol < 0 || padcol >= fgkNcol ) return -1;   // thisi s commented because of reson above KO
245
246   return padcol;
247
248 }
249
250 //_____________________________________________________________________________
251 Int_t AliTRDfeeParam::GetMCMfromPad(Int_t irow, Int_t icol) const
252 {
253   //
254   // Return on which MCM this pad is directry connected.
255   // Return -1 for error.
256   //
257
258   if ( irow < 0 || icol < 0 || irow > fgkNrowC1 || icol > fgkNcol ) return -1;
259
260   return (icol%(fgkNcol/2))/fgkNcolMcm + fgkNmcmRobInCol*(irow%fgkNmcmRobInRow);
261
262 }
263
264 //_____________________________________________________________________________
265 Int_t AliTRDfeeParam::GetROBfromPad(Int_t irow, Int_t icol) const
266 {
267   //
268   // Return on which rob this pad is
269   //
270
271   return (irow/fgkNmcmRobInRow)*2 + GetColSide(icol);
272
273 }
274
275 //_____________________________________________________________________________
276 Int_t AliTRDfeeParam::GetRobSide(Int_t irob) const
277 {
278   //
279   // Return on which side this rob sits (A side = 0, B side = 1)
280   //
281
282   if ( irob < 0 || irob >= fgkNrobC1 ) return -1;
283
284   return irob%2;
285
286 }
287
288 //_____________________________________________________________________________
289 Int_t AliTRDfeeParam::GetColSide(Int_t icol) const
290 {
291   //
292   // Return on which side this column sits (A side = 0, B side = 1)
293   //
294
295   if ( icol < 0 || icol >= fgkNcol ) return -1;
296
297   return icol/(fgkNcol/2);
298
299 }
300
301 //_____________________________________________________________________________
302 //void AliTRDfeeParam::GetFilterParam( Float_t &r1, Float_t &r2, Float_t &c1
303 //                                   , Float_t &c2, Float_t &ped ) const
304 //{
305   //
306   // Return current filter parameter
307   //
308
309   //  r1            = fR1;
310   //r2            = fR2;
311   //c1            = fC1;
312   //c2            = fC2;
313   //ped           = fPedestal;
314 //};
315
316 //_____________________________________________________________________________
317 void AliTRDfeeParam::SetEBsglIndThr(Int_t val)
318 {
319   //
320   // Set Event Buffer Sngle Indicator Threshold (EBIS in TRAP conf).
321   // Timebin is indicated if ADC value >= val.
322   //
323
324   if( val >= 0 && val <= 1023 ) { 
325     fEBsglIndThr = val;
326   } else {
327     AliError(Form("EBsglIndThr value %d is out of range, keep previously set value (%d).",
328                   val, fEBsglIndThr));
329   }
330
331 }
332
333 //_____________________________________________________________________________
334 void AliTRDfeeParam::SetEBsumIndThr(Int_t val)
335 {
336   //
337   // Set Event Buffer Sum Indicator Threshold (EBIT in TRAP conf).
338   // Timebin is indicated if ADC sum value >= val.
339   //
340
341   if( val >= 0 && val <= 4095 ) { 
342     fEBsumIndThr = val;
343   } 
344   else {
345     AliError(Form("EBsumIndThr value %d is out of range, keep previously set value (%d).",
346                   val, fEBsumIndThr));
347   }
348
349 }
350
351 //_____________________________________________________________________________
352 void AliTRDfeeParam::SetEBindLUT(Int_t val)
353 {
354   //
355   // Set Event Buffer Indicator Look-Up Table (EBIL in TRAP conf).
356   // 8 bits value forms lookup table for combination of three criterions.
357   //
358
359   if( val >= 0 && val <= 255 ) {
360     fEBindLUT = val;
361   } 
362   else {
363     AliError(Form("EBindLUT value %d is out of range, keep previously set value (%d).",
364                   val, fEBindLUT));
365   }
366
367 }
368
369 //_____________________________________________________________________________
370 void AliTRDfeeParam::SetEBignoreNeighbour(Int_t val)
371 {
372   //
373   // Set Event Buffer Indicator Neighbor Sensitivity. (EBIN in TRAP conf).
374   // If 0, take account of neigbor's values.
375   //
376
377   if( val >= 0 && val <= 1 ) {
378     fEBignoreNeighbour = val;
379   } 
380   else {
381     AliError(Form("EBignoreNeighbour value %d is out of range, keep previously set value (%d).",
382                   val, fEBignoreNeighbour));
383   }
384 }
385
386 //_____________________________________________________________________________
387 void AliTRDfeeParam::SetRAWversion( Int_t rawver )
388 {
389   //
390   // Set raw data version (major number only)
391   // Maximum available number is preset in fgkMaxRAWversion
392   //
393
394   if( rawver >= 0 && rawver <= fgkMaxRAWversion ) {
395     fRAWversion = rawver;
396   } 
397   else {
398     AliError(Form("Raw version is out of range: %d",rawver));
399   }
400
401 }
402
403 //_____________________________________________________________________________
404 void AliTRDfeeParam::SetXenon()
405 {
406   //
407   // Sets the filter parameters for the Xenon gas mixture
408   //
409
410   fTFnExp = 1;
411   fTFr1   = 1.1563;
412   fTFr2   = 0.1299;
413   fTFc1   = 0.0657;
414   fTFc2   = 0.0000;
415
416 }
417
418 //_____________________________________________________________________________
419 void AliTRDfeeParam::SetArgon()
420 {
421   //
422   // Sets the filter parameters for the Argon gas mixture
423   //
424
425   fTFnExp = 2;
426   fTFr1   = 6.0;
427   fTFr2   = 0.62;
428   fTFc1   = 0.0087;
429   fTFc2   = 0.07;
430
431 }
432
433