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