New reader for the pedestal run and vdrift (Julian) and some bug fixing (Raphaelle)
[u/mrichter/AliRoot.git] / TRD / AliTRDfeeParam.cxx
CommitLineData
022e76c3 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
acc49af9 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////////////////////////////////////////////////////////////////////////////
022e76c3 34
7cb613c0 35//#include <TMath.h>
022e76c3 36
ecf39416 37#include "AliLog.h"
ba84a3e3 38
022e76c3 39#include "AliTRDfeeParam.h"
7cb613c0 40//#include "AliTRDgeometry.h"
022e76c3 41#include "AliTRDCommonParam.h"
42
43ClassImp(AliTRDfeeParam)
44
45AliTRDfeeParam *AliTRDfeeParam::fgInstance = 0;
46Bool_t AliTRDfeeParam::fgTerminated = kFALSE;
837e440c 47Bool_t AliTRDfeeParam::fgTracklet = kFALSE;
022e76c3 48
49//_____________________________________________________________________________
50AliTRDfeeParam* AliTRDfeeParam::Instance()
51{
acc49af9 52 //
022e76c3 53 // Instance constructor
acc49af9 54 //
55
022e76c3 56 if (fgTerminated != kFALSE) {
57 return 0;
58 }
59
60 if (fgInstance == 0) {
61 fgInstance = new AliTRDfeeParam();
62 }
63
64 return fgInstance;
acc49af9 65
022e76c3 66}
67
68//_____________________________________________________________________________
69void 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 }
acc49af9 81
022e76c3 82}
83
84//_____________________________________________________________________________
85AliTRDfeeParam::AliTRDfeeParam()
86 :TObject()
022e76c3 87 ,fCP(0)
f2979d08 88 ,fTFnExp(1)
dfd03fc3 89 ,fTFr1(0)
90 ,fTFr2(0)
91 ,fTFc1(0)
92 ,fTFc2(0)
2ec0bacc 93 ,fEBsglIndThr(5)
94 ,fEBsumIndThr(5)
95 ,fEBindLUT(0xF0)
96 ,fEBignoreNeighbour(0)
ecf39416 97 ,fRAWversion(3)
98 ,fRAWstoreRaw(kTRUE)
022e76c3 99{
100 //
101 // Default constructor
102 //
103
104 // PASA V.4
f2979d08 105 if (fTFnExp == 1) {
dfd03fc3 106 fTFr1 = 1.1563;
107 fTFr2 = 0.1299;
108 fTFc1 = 0.0657;
109 fTFc2 = 0.0000;
022e76c3 110 }
f2979d08 111 else if (fTFnExp == 2) {
dfd03fc3 112 fTFr1 = 1.1563;
113 fTFr2 = 0.1299;
114 fTFc1 = 0.1141;
115 fTFc2 = 0.6241;
022e76c3 116 }
117
022e76c3 118 fCP = AliTRDCommonParam::Instance();
119
120}
121
122//_____________________________________________________________________________
ba84a3e3 123AliTRDfeeParam::AliTRDfeeParam(TRootIoCtor *)
124 :TObject()
125 ,fCP(0)
f2979d08 126 ,fTFnExp(1)
ba84a3e3 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//_____________________________________________________________________________
022e76c3 145AliTRDfeeParam::AliTRDfeeParam(const AliTRDfeeParam &p)
146 :TObject(p)
022e76c3 147 ,fCP(p.fCP)
f2979d08 148 ,fTFnExp(p.fTFnExp)
dfd03fc3 149 ,fTFr1(p.fTFr1)
150 ,fTFr2(p.fTFr2)
151 ,fTFc1(p.fTFc1)
152 ,fTFc2(p.fTFc2)
2ec0bacc 153 ,fEBsglIndThr(p.fEBsglIndThr)
154 ,fEBsumIndThr(p.fEBsumIndThr)
155 ,fEBindLUT(p.fEBindLUT)
156 ,fEBignoreNeighbour (p.fEBignoreNeighbour)
ecf39416 157 ,fRAWversion(p.fRAWversion)
158 ,fRAWstoreRaw(p.fRAWstoreRaw)
022e76c3 159{
160 //
161 // AliTRDfeeParam copy constructor
162 //
acc49af9 163
022e76c3 164}
165
166//_____________________________________________________________________________
167AliTRDfeeParam::~AliTRDfeeParam()
168{
169 //
170 // AliTRDfeeParam destructor
171 //
acc49af9 172
022e76c3 173}
174
175//_____________________________________________________________________________
176AliTRDfeeParam &AliTRDfeeParam::operator=(const AliTRDfeeParam &p)
177{
178 //
179 // Assignment operator
180 //
181
182 if (this != &p) {
183 ((AliTRDfeeParam &) p).Copy(*this);
184 }
acc49af9 185
022e76c3 186 return *this;
acc49af9 187
022e76c3 188}
189
190//_____________________________________________________________________________
191void AliTRDfeeParam::Copy(TObject &p) const
192{
193 //
194 // Copy function
195 //
196
ecf39416 197 ((AliTRDfeeParam &) p).fCP = fCP;
f2979d08 198 ((AliTRDfeeParam &) p).fTFnExp = fTFnExp;
ecf39416 199 ((AliTRDfeeParam &) p).fTFr1 = fTFr1;
200 ((AliTRDfeeParam &) p).fTFr2 = fTFr2;
201 ((AliTRDfeeParam &) p).fTFc1 = fTFc1;
202 ((AliTRDfeeParam &) p).fTFc2 = fTFc2;
2ec0bacc 203 ((AliTRDfeeParam &) p).fEBsglIndThr = fEBsglIndThr;
204 ((AliTRDfeeParam &) p).fEBsumIndThr = fEBsumIndThr;
205 ((AliTRDfeeParam &) p).fEBindLUT = fEBindLUT;
206 ((AliTRDfeeParam &) p).fEBignoreNeighbour = fEBignoreNeighbour;
ecf39416 207 ((AliTRDfeeParam &) p).fRAWversion = fRAWversion;
208 ((AliTRDfeeParam &) p).fRAWstoreRaw = fRAWstoreRaw;
022e76c3 209
210 TObject::Copy(p);
acc49af9 211
022e76c3 212}
213
214//_____________________________________________________________________________
215Int_t AliTRDfeeParam::GetPadRowFromMCM(Int_t irob, Int_t imcm) const
216{
217 //
acc49af9 218 // Return on which pad row this mcm sits
022e76c3 219 //
220
221 return fgkNmcmRobInRow*(irob/2) + imcm/fgkNmcmRobInCol;
acc49af9 222
022e76c3 223}
224
225//_____________________________________________________________________________
226Int_t AliTRDfeeParam::GetPadColFromADC(Int_t irob, Int_t imcm, Int_t iadc) const
227{
228 //
ecf39416 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 //
022e76c3 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
acc49af9 239 //
022e76c3 240
a6d08b7f 241 if (iadc < 0 || iadc > fgkNadcMcm ) return -100;
022e76c3 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;
38cb2aa7 244 if( padcol < 0 || padcol >= fgkNcol ) return -1; // this is commented because of reason above OK
860f3a82 245
246 return padcol;
247
248}
249
250//_____________________________________________________________________________
251Int_t AliTRDfeeParam::GetExtendedPadColFromADC(Int_t irob, Int_t imcm, Int_t iadc) const
252{
253 //
254 // Return which pad coresponds to the extended digit container pad numbering
255 // Extended digit container is designed to store all pad data including shared pad,
256 // so we have to introduce new virtual pad numbering scheme for this purpose.
257 //
258
259 if (iadc < 0 || iadc > fgkNadcMcm ) return -100;
260 Int_t mcmcol = imcm%fgkNmcmRobInCol + GetRobSide(irob)*fgkNmcmRobInCol; // MCM column number on ROC [0..7]
af0d9e9e 261 Int_t padcol = mcmcol*fgkNadcMcm + fgkNcolMcm + 2 - iadc;
acc49af9 262
022e76c3 263 return padcol;
acc49af9 264
022e76c3 265}
266
267//_____________________________________________________________________________
268Int_t AliTRDfeeParam::GetMCMfromPad(Int_t irow, Int_t icol) const
269{
270 //
271 // Return on which MCM this pad is directry connected.
272 // Return -1 for error.
273 //
274
275 if ( irow < 0 || icol < 0 || irow > fgkNrowC1 || icol > fgkNcol ) return -1;
276
277 return (icol%(fgkNcol/2))/fgkNcolMcm + fgkNmcmRobInCol*(irow%fgkNmcmRobInRow);
acc49af9 278
022e76c3 279}
280
281//_____________________________________________________________________________
1785640c 282Int_t AliTRDfeeParam::GetMCMfromSharedPad(Int_t irow, Int_t icol) const
283{
284 //
285 // Return on which MCM this pad is directry connected.
286 // Return -1 for error.
287 //
288
289 if ( irow < 0 || icol < 0 || irow > fgkNrowC1 || icol > fgkNcol+8*3 ) return -1;
290
291 Int_t adc = 20 - (icol%18) -1;
292 switch(adc) {
293 case 2: icol += 5; break;
294 case 18: icol -= 5; break;
295 case 19: icol -= 5; break;
296 default: icol += 0; break;
297 }
298
299 return (icol%(fgkNcol/2))/fgkNcolMcm + fgkNmcmRobInCol*(irow%fgkNmcmRobInRow);
300
301}
302
303//_____________________________________________________________________________
022e76c3 304Int_t AliTRDfeeParam::GetROBfromPad(Int_t irow, Int_t icol) const
305{
306 //
acc49af9 307 // Return on which rob this pad is
022e76c3 308 //
309
310 return (irow/fgkNmcmRobInRow)*2 + GetColSide(icol);
acc49af9 311
022e76c3 312}
313
314//_____________________________________________________________________________
1785640c 315Int_t AliTRDfeeParam::GetROBfromSharedPad(Int_t irow, Int_t icol) const
316{
317 //
318 // Return on which rob this pad is for shared pads
319 //
320
321 if(icol<72) return (irow/fgkNmcmRobInRow)*2 + GetColSide(icol+5);
322 else return (irow/fgkNmcmRobInRow)*2 + GetColSide(icol-5);
323
324}
325
326//_____________________________________________________________________________
022e76c3 327Int_t AliTRDfeeParam::GetRobSide(Int_t irob) const
328{
329 //
acc49af9 330 // Return on which side this rob sits (A side = 0, B side = 1)
022e76c3 331 //
332
333 if ( irob < 0 || irob >= fgkNrobC1 ) return -1;
acc49af9 334
022e76c3 335 return irob%2;
acc49af9 336
022e76c3 337}
338
339//_____________________________________________________________________________
340Int_t AliTRDfeeParam::GetColSide(Int_t icol) const
341{
342 //
acc49af9 343 // Return on which side this column sits (A side = 0, B side = 1)
022e76c3 344 //
345
346 if ( icol < 0 || icol >= fgkNcol ) return -1;
acc49af9 347
022e76c3 348 return icol/(fgkNcol/2);
acc49af9 349
022e76c3 350}
351
acc49af9 352//_____________________________________________________________________________
353//void AliTRDfeeParam::GetFilterParam( Float_t &r1, Float_t &r2, Float_t &c1
354// , Float_t &c2, Float_t &ped ) const
022e76c3 355//{
356 //
357 // Return current filter parameter
358 //
359
360 // r1 = fR1;
361 //r2 = fR2;
362 //c1 = fC1;
363 //c2 = fC2;
364 //ped = fPedestal;
365//};
ecf39416 366
2ec0bacc 367//_____________________________________________________________________________
368void AliTRDfeeParam::SetEBsglIndThr(Int_t val)
369{
acc49af9 370 //
2ec0bacc 371 // Set Event Buffer Sngle Indicator Threshold (EBIS in TRAP conf).
372 // Timebin is indicated if ADC value >= val.
acc49af9 373 //
2ec0bacc 374
375 if( val >= 0 && val <= 1023 ) {
376 fEBsglIndThr = val;
377 } else {
378 AliError(Form("EBsglIndThr value %d is out of range, keep previously set value (%d).",
379 val, fEBsglIndThr));
380 }
acc49af9 381
2ec0bacc 382}
383
384//_____________________________________________________________________________
385void AliTRDfeeParam::SetEBsumIndThr(Int_t val)
386{
acc49af9 387 //
2ec0bacc 388 // Set Event Buffer Sum Indicator Threshold (EBIT in TRAP conf).
389 // Timebin is indicated if ADC sum value >= val.
acc49af9 390 //
2ec0bacc 391
392 if( val >= 0 && val <= 4095 ) {
393 fEBsumIndThr = val;
acc49af9 394 }
395 else {
2ec0bacc 396 AliError(Form("EBsumIndThr value %d is out of range, keep previously set value (%d).",
397 val, fEBsumIndThr));
398 }
2ec0bacc 399
acc49af9 400}
2ec0bacc 401
402//_____________________________________________________________________________
403void AliTRDfeeParam::SetEBindLUT(Int_t val)
404{
acc49af9 405 //
2ec0bacc 406 // Set Event Buffer Indicator Look-Up Table (EBIL in TRAP conf).
407 // 8 bits value forms lookup table for combination of three criterions.
acc49af9 408 //
2ec0bacc 409
410 if( val >= 0 && val <= 255 ) {
411 fEBindLUT = val;
acc49af9 412 }
413 else {
2ec0bacc 414 AliError(Form("EBindLUT value %d is out of range, keep previously set value (%d).",
415 val, fEBindLUT));
416 }
acc49af9 417
2ec0bacc 418}
419
420//_____________________________________________________________________________
421void AliTRDfeeParam::SetEBignoreNeighbour(Int_t val)
422{
acc49af9 423 //
2ec0bacc 424 // Set Event Buffer Indicator Neighbor Sensitivity. (EBIN in TRAP conf).
425 // If 0, take account of neigbor's values.
acc49af9 426 //
2ec0bacc 427
428 if( val >= 0 && val <= 1 ) {
429 fEBignoreNeighbour = val;
acc49af9 430 }
431 else {
2ec0bacc 432 AliError(Form("EBignoreNeighbour value %d is out of range, keep previously set value (%d).",
433 val, fEBignoreNeighbour));
434 }
435}
ecf39416 436
437//_____________________________________________________________________________
acc49af9 438void AliTRDfeeParam::SetRAWversion( Int_t rawver )
ecf39416 439{
acc49af9 440 //
ecf39416 441 // Set raw data version (major number only)
442 // Maximum available number is preset in fgkMaxRAWversion
acc49af9 443 //
ecf39416 444
445 if( rawver >= 0 && rawver <= fgkMaxRAWversion ) {
acc49af9 446 fRAWversion = rawver;
447 }
448 else {
ecf39416 449 AliError(Form("Raw version is out of range: %d",rawver));
450 }
ecf39416 451
ecf39416 452}
f2979d08 453
454//_____________________________________________________________________________
455void AliTRDfeeParam::SetXenon()
456{
457 //
458 // Sets the filter parameters for the Xenon gas mixture
459 //
460
461 fTFnExp = 1;
462 fTFr1 = 1.1563;
463 fTFr2 = 0.1299;
464 fTFc1 = 0.0657;
465 fTFc2 = 0.0000;
466
467}
468
469//_____________________________________________________________________________
470void AliTRDfeeParam::SetArgon()
471{
472 //
473 // Sets the filter parameters for the Argon gas mixture
474 //
475
476 fTFnExp = 2;
477 fTFr1 = 6.0;
478 fTFr2 = 0.62;
479 fTFc1 = 0.0087;
480 fTFc2 = 0.07;
481
482}
a6d08b7f 483
484