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