Obsolete classes removed.
[u/mrichter/AliRoot.git] / TRD / AliTRDptrgParam.cxx
CommitLineData
f9720615 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18////////////////////////////////////////////////////////////////////////////
19//
20// Parameters for Pre-Trigger Simulation
21//
22// Author: F. Reidt (Felix.Reidt@cern.ch)
23//
24// This class controls the parameters used by the pretrigger simulation.
25// A configuration file ca be loaded by calling LoadConfigurationFromFile()
26// The generation of look up tables is also done in this class and has to
27// be done only once after a configuration file was loaded.
28// If no configuration file was loaded, the standard
29// configuration in LoadStandardConfiguration() would be used.
30//
31////////////////////////////////////////////////////////////////////////////
32#include "TArrayI.h"
33#include "TObjString.h"
34#include "TString.h"
35
36#include <fstream>
37
38#include "AliLog.h"
39
40#include "AliTRDptrgParam.h"
41
42ClassImp(AliTRDptrgParam)
43
44AliTRDptrgParam *AliTRDptrgParam::fgInstance = 0;
45
46
47//______________________________________________________________________________
48AliTRDptrgParam::AliTRDptrgParam()
49 : TObject(),
50 fTLMUInputStretch(0),
51 fTLMUcmatrices(0x0),
52 fTLMUmultiplicity(0x0),
53 fTLMUoutput(0x0),
54 fFEBT0Thresholds(0x0),
55 fFEBT0Multiplicities(0x0),
56 fFEBT0LUTs(0x0),
57 fFEBV0Thresholds(0x0),
58 fFEBV0Multiplicities(0x0),
59 fFEBV0LUTs(0x0),
60 fCBLUTs(0x0),
61 fCBALUTequX(TString()),
62 fCBALUTequY(TString()),
63 fCBCLUTequX(TString()),
64 fCBCLUTequY(TString()),
65 fCBBLUTequX(TString()),
66 fCBBLUTequY(TString()),
67 fPTmasks(AliTRDptrgPTmasks())
68{
69 // ctor
70
71 // initialize coincidence matrices
72 this->fTLMUcmatrices = new UInt_t*[3];
73 for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
74 this->fTLMUcmatrices[iMatrix] = new UInt_t[18];
75 for (UInt_t iSlice = 0; iSlice < 18; iSlice++) {
76 this->fTLMUcmatrices[iMatrix][iSlice] = 0;
77 }
78 }
79
80 // initialize multiplicity slices
81 this->fTLMUmultiplicity = new UInt_t*[9];
82 for (UInt_t iSlice = 0; iSlice < 9; iSlice++) {
83 this->fTLMUmultiplicity[iSlice] = new UInt_t[2];
84 this->fTLMUmultiplicity[iSlice][0] = 577; // disabled
85 this->fTLMUmultiplicity[iSlice][1] = 0;
86 }
87
88 // initialize output muxer
89 this->fTLMUoutput = new Int_t*[8];
90 for (UInt_t iBit = 0; iBit < 8; iBit++) {
91 this->fTLMUoutput[iBit] = new Int_t[2];
92 this->fTLMUoutput[iBit][0] = -1; // cmatrix disabled
93 this->fTLMUoutput[iBit][1] = -1; // multslice disabled
94 }
95
96 // initialize T0 FEB thresholds
97 this->fFEBT0Thresholds = new UInt_t*[2];
98 this->fFEBT0Thresholds[0] = new UInt_t[12];
99 this->fFEBT0Thresholds[1] = new UInt_t[12];
100 for (Int_t iChan = 0; iChan < 12; iChan++) {
101 this->fFEBT0Thresholds[0][iChan] = 4294967295U;
102 this->fFEBT0Thresholds[1][iChan] = 4294967295U;
103 // writing 2^32-1 disables the input because all used adcs have
104 // less than 32 bits
105 }
106
107 // initialize T0 Multiplicity
108 this->fFEBT0Multiplicities = new UInt_t**[2];
109 this->fFEBT0Multiplicities[0] = new UInt_t*[2];
110 this->fFEBT0Multiplicities[1] = new UInt_t*[2];
111 this->fFEBT0Multiplicities[0][0] = new UInt_t[2];
112 this->fFEBT0Multiplicities[0][1] = new UInt_t[2];
113 this->fFEBT0Multiplicities[1][0] = new UInt_t[2];
114 this->fFEBT0Multiplicities[1][1] = new UInt_t[2];
115 this->fFEBT0Multiplicities[0][0][0] = 4294967295U;
116 this->fFEBT0Multiplicities[0][0][1] = 4294967295U;
117 this->fFEBT0Multiplicities[0][1][0] = 4294967295U;
118 this->fFEBT0Multiplicities[0][1][1] = 4294967295U;
119 this->fFEBT0Multiplicities[1][0][0] = 4294967295U;
120 this->fFEBT0Multiplicities[1][0][1] = 4294967295U;
121 this->fFEBT0Multiplicities[1][1][0] = 4294967295U;
122 this->fFEBT0Multiplicities[1][1][1] = 4294967295U;
123 // writing 2^32-1 disables the input because all used adcs have
124 // less than 32 bits
125
126 // initialize T0 LUTs
127 // this->fFEBT0LUTs = 0x0; (done in member initialization list)
128 // further initialization is done in AliTRDptrgParam::GenerateLUTs()
129
130
131 // initialize V0 FEB Thresholds
132 this->fFEBV0Thresholds = new UInt_t**[2];
133 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
134 this->fFEBV0Thresholds[iPosition] = new UInt_t*[4];
135 for (UInt_t iCard = 0; iCard < 4; iCard++) {
136 this->fFEBV0Thresholds[iPosition][iCard] = new UInt_t[8];
137 for (UInt_t iChannel = 0; iChannel < 8; iChannel++) {
138 this->fFEBV0Thresholds[iPosition][iCard][iChannel] = 4294967295U;
139 }
140 }
141 }
142
143 // initialize V0 Multiplicities
144 this->fFEBV0Multiplicities = new UInt_t***[2];
145 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
146 this->fFEBV0Multiplicities[iPosition] = new UInt_t**[4];
147 for (UInt_t iCard = 0; iCard < 4; iCard++) {
148 this->fFEBV0Multiplicities[iPosition][iCard] = new UInt_t*[2];
149 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
150 this->fFEBV0Multiplicities[iPosition][iCard][iLUT] = new UInt_t[2];
151 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 4294967295U;
152 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][1] = 0x0;
153 }
154 }
155 }
156
157 // initialize V0 LUTs
158 // this->fFEBV0LUTs = 0x0; (done in member initialization list)
159 // further initialization is done in AliTRDptrgParam::GenerateLUTs()
160
161 // initialize CB LUTs
162 // this->fCBLUTs = 0x0; (done in member initialization list)
163 // further initialization is done in AliTRDptrgParam::GenerateLUTs()
164
165 this->LoadStandardConfiguration(); // load standard configuration
166}
167
168//______________________________________________________________________________
169AliTRDptrgParam::~AliTRDptrgParam()
170{
171 // dtor
172
173 // delete coincidence matrices
174 if (this->fTLMUcmatrices != 0x0) {
175 for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
176 if (this->fTLMUcmatrices[iMatrix] != 0x0) {
177 delete[] this->fTLMUcmatrices[iMatrix];
178 this->fTLMUcmatrices[iMatrix] = 0x0;
179 }
180 }
181 delete[] this->fTLMUcmatrices;
182 this->fTLMUcmatrices = 0x0;
183 }
184
185 // delete multiplicity slices
186 if (this->fTLMUmultiplicity != 0x0) {
187 for (UInt_t iSlice = 0; iSlice < 9; iSlice++) {
188 if (this->fTLMUmultiplicity[iSlice] != 0x0) {
189 delete[] this->fTLMUmultiplicity[iSlice];
190 this->fTLMUmultiplicity[iSlice] = 0x0;
191 }
192 }
193 delete[] this->fTLMUmultiplicity;
194 this->fTLMUmultiplicity = 0x0;
195 }
196
197 // delete output mux
198 if (this->fTLMUoutput != 0x0) {
199 for (UInt_t iBit = 0; iBit < 8; iBit++) {
200 if (this->fTLMUoutput[iBit] != 0x0) {
201 delete[] this->fTLMUoutput[iBit];
202 this->fTLMUoutput[iBit] = 0x0;
203 }
204 }
205 delete[] this->fTLMUoutput;
206 this->fTLMUoutput = 0x0;
207 }
208
209 // delete T0 FEB thresholds
210 if (this->fFEBT0Thresholds != 0x0) {
211 if (this->fFEBT0Thresholds[0] != 0x0) {
212 delete[] this->fFEBT0Thresholds[0];
213 this->fFEBT0Thresholds[0] = 0x0;
214 }
215 if (this->fFEBT0Thresholds[1] != 0x0) {
216 delete[] this->fFEBT0Thresholds[1];
217 this->fFEBT0Thresholds[1] = 0x0;
218 }
219 delete[] this->fFEBT0Thresholds;
220 this->fFEBT0Thresholds = 0x0;
221 }
222
223 // delete T0 multiplicities
224 if (this->fFEBT0Multiplicities != 0x0) {
225 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
226 if (this->fFEBT0Multiplicities[iPosition] != 0x0) {
227 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
228 if (this->fFEBT0Multiplicities[iPosition][iLUT] != 0x0) {
229 delete[] this->fFEBT0Multiplicities[iPosition][iLUT];
230 this->fFEBT0Multiplicities[iPosition][iLUT] = 0x0;
231 }
232 }
233 delete[] this->fFEBT0Multiplicities[iPosition];
234 this->fFEBT0Multiplicities[iPosition] = 0x0;
235 }
236 }
237 delete[] this->fFEBT0Multiplicities;
238 this->fFEBT0Multiplicities = 0x0;
239 }
240
241 // delete T0 LUTs
242 if (this->fFEBT0LUTs != 0x0) {
243 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
244 if (this->fFEBT0LUTs[iPosition] != 0x0) {
245 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
246 if (this->fFEBT0LUTs[iPosition][iLUT] != 0x0) {
247 delete[] this->fFEBT0LUTs[iPosition][iLUT];
248 this->fFEBT0LUTs[iPosition][iLUT] = 0x0;
249 }
250 }
251 delete[] this->fFEBT0LUTs[iPosition];
252 this->fFEBT0LUTs[iPosition] = 0x0;
253 }
254 }
255 delete[] this->fFEBT0LUTs;
256 this->fFEBT0LUTs = 0x0;
257 }
258
259 // delete V0 FEB thresholds
260 if (this->fFEBV0Thresholds != 0x0) {
261 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
262 if (this->fFEBV0Thresholds[iPosition] != 0x0) {
263 for (UInt_t iCard = 0; iCard < 4; iCard++) {
264 if (this->fFEBV0Thresholds[iPosition][iCard] != 0x0) {
265 delete[] this->fFEBV0Thresholds[iPosition][iCard];
266 this->fFEBV0Thresholds[iPosition][iCard] = 0x0;
267 }
268 }
269 delete[] this->fFEBV0Thresholds[iPosition];
270 this->fFEBV0Thresholds[iPosition] = 0x0;
271 }
272 }
273 delete[] this->fFEBV0Thresholds;
274 this->fFEBV0Thresholds = 0x0;
275 }
276
277 // delete V0 multiplicities
278 if (this->fFEBV0Multiplicities != 0x0) {
279 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
280 if (this->fFEBV0Multiplicities[iPosition] != 0x0) {
281 for (UInt_t iCard = 0; iCard < 4; iCard++) {
282 if (this->fFEBV0Multiplicities[iPosition][iCard] != 0x0) {
283 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
284 if (this->fFEBV0Multiplicities[iPosition][iCard][iLUT] != 0x0) {
285 delete[] this->fFEBV0Multiplicities[iPosition][iCard][iLUT];
286 this->fFEBV0Multiplicities[iPosition][iCard][iLUT] = 0x0;
287 }
288 }
289 delete[] this->fFEBV0Multiplicities[iPosition][iCard];
290 this->fFEBV0Multiplicities[iPosition][iCard] = 0x0;
291 }
292 }
293 delete[] this->fFEBV0Multiplicities[iPosition];
294 this->fFEBV0Multiplicities[iPosition] = 0x0;
295 }
296 }
297 delete[] this->fFEBV0Multiplicities;
298 this->fFEBV0Multiplicities = 0x0;
299 }
300
301 // delete V0 LUTs
302 if (this->fFEBV0LUTs != 0x0) {
303 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
304 if (this->fFEBV0LUTs[iPosition] != 0x0) {
305 for (UInt_t iCard = 0; iCard < 4; iCard++) {
306 if (this->fFEBV0LUTs[iPosition][iCard] != 0x0) {
307 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
308 if (this->fFEBV0LUTs[iPosition][iCard][iLUT] != 0x0) {
309 delete[] this->fFEBV0LUTs[iPosition][iCard][iLUT];
310 this->fFEBV0LUTs[iPosition][iCard][iLUT] = 0x0;
311 }
312 }
313 delete[] this->fFEBV0LUTs[iPosition][iCard];
314 this->fFEBV0LUTs[iPosition][iCard] = 0x0;
315 }
316 }
317 delete[] this->fFEBV0LUTs[iPosition];
318 this->fFEBV0LUTs[iPosition] = 0x0;
319 }
320 }
321 delete[] this->fFEBV0LUTs;
322 this->fFEBV0LUTs = 0x0;
323 }
324
325 // delete CB LUTs
326 if (this->fCBLUTs != 0x0) {
327 for (UInt_t iCB = 0; iCB < 3; iCB++) {
328 if (this->fCBLUTs[iCB] != 0x0) {
329 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
330 if (this->fCBLUTs[iCB][iLUT] != 0x0) {
331 delete[] this->fCBLUTs[iCB][iLUT];
332 this->fCBLUTs[iCB][iLUT] = 0x0;
333 }
334 }
335 delete[] this->fCBLUTs[iCB];
336 this->fCBLUTs[iCB] = 0x0;
337 }
338 }
339 delete[] this->fCBLUTs;
340 this->fCBLUTs = 0x0;
341 }
342}
343
344//______________________________________________________________________________
345Int_t AliTRDptrgParam::CheckVariables() const
346{
347 // checks whether variables are deleted early enough
348
349 // check coincidence matrices
350 if (this->fTLMUcmatrices != 0x0) {
351 for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
352 if (this->fTLMUcmatrices[iMatrix] == 0x0) {
353 return -1;
354 }
355 }
356 }
357 else {
358 return -2;
359 }
360
361 // check multiplicity slices
362 if (this->fTLMUmultiplicity != 0x0) {
363 for (UInt_t iSlice = 0; iSlice < 9; iSlice++) {
364 if (this->fTLMUmultiplicity[iSlice] == 0x0) {
365 return -3;
366 }
367 }
368 }
369 else {
370 return -4;
371 }
372
373 // check output mux
374 if (this->fTLMUoutput != 0x0) {
375 for (UInt_t iBit = 0; iBit < 8; iBit++) {
376 if (this->fTLMUoutput[iBit] == 0x0) {
377 return -5;
378 }
379 }
380 }
381 else {
382 return -6;
383 }
384
385 // delete T0 FEB thresholds
386 if (this->fFEBT0Thresholds != 0x0) {
387 if (this->fFEBT0Thresholds[0] == 0x0) {
388 return -7;
389 }
390 if (this->fFEBT0Thresholds[1] == 0x0) {
391 return -8;
392 }
393 }
394 else {
395 return -9;
396 }
397
398 // delete T0 multiplicities
399 if (this->fFEBT0Multiplicities != 0x0) {
400 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
401 if (this->fFEBT0Multiplicities[iPosition] != 0x0) {
402 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
403 if (this->fFEBT0Multiplicities[iPosition][iLUT] == 0x0) {
404 return -10;
405 }
406 }
407 }
408 else {
409 return -11;
410 }
411 }
412 }
413 else {
414 return -12;
415 }
416
417
418 // delete T0 LUTs
419 if (this->fFEBT0LUTs != 0x0) {
420 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
421 if (this->fFEBT0LUTs[iPosition] != 0x0) {
422 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
423 if (this->fFEBT0LUTs[iPosition][iLUT] == 0x0) {
424 return -13;
425 }
426 }
427 }
428 else {
429 return -14;
430 }
431 }
432 }
433 else {
434 return -15;
435 }
436
437 // delete V0 FEB thresholds
438 if (this->fFEBV0Thresholds != 0x0) {
439 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
440 if (this->fFEBV0Thresholds[iPosition] != 0x0) {
441 for (UInt_t iCard = 0; iCard < 4; iCard++) {
442 if (this->fFEBV0Thresholds[iPosition][iCard] == 0x0) {
443 return -16;
444 }
445 }
446 }
447 else {
448 return -17;
449 }
450 }
451 }
452 else {
453 return -18;
454 }
455
456 // delete V0 multiplicities
457 if (this->fFEBV0Multiplicities != 0x0) {
458 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
459 if (this->fFEBV0Multiplicities[iPosition] != 0x0) {
460 for (UInt_t iCard = 0; iCard < 4; iCard++) {
461 if (this->fFEBV0Multiplicities[iPosition][iCard] != 0x0) {
462 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
463 if (this->fFEBV0Multiplicities[iPosition][iCard][iLUT] == 0x0) {
464 return -19;
465 }
466 }
467 }
468 else {
469 return -20;
470 }
471 }
472 }
473 else {
474 return -21;
475 }
476 }
477 }
478 else {
479 return -22;
480 }
481
482 // delete V0 LUTs
483 if (this->fFEBV0LUTs != 0x0) {
484 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
485 if (this->fFEBV0LUTs[iPosition] != 0x0) {
486 for (UInt_t iCard = 0; iCard < 4; iCard++) {
487 if (this->fFEBV0LUTs[iPosition][iCard] != 0x0) {
488 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
489 if (this->fFEBV0LUTs[iPosition][iCard][iLUT] == 0x0) {
490 return -23;
491 }
492 }
493 }
494 else {
495 return -24;
496 }
497 }
498 }
499 else {
500 return -25;
501 }
502 }
503 }
504 else {
505 return -26;
506 }
507
508 // delete CB LUTs
509 if (this->fCBLUTs != 0x0) {
510 for (UInt_t iCB = 0; iCB < 3; iCB++) {
511 if (this->fCBLUTs[iCB] != 0x0) {
512 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
513 if (this->fCBLUTs[iCB][iLUT] == 0x0) {
514 return -27;
515 }
516 }
517 }
518 else {
519 return -28;
520 }
521 }
522 }
523 else {
524 return -29;
525 }
526 return 0;
527}
528
529//______________________________________________________________________________
530AliTRDptrgParam* AliTRDptrgParam::Instance()
531{
532 // get (or create) the single instance
533
534 if (fgInstance == 0)
535 fgInstance = new AliTRDptrgParam();
536
537 return fgInstance;
538}
539
540//______________________________________________________________________________
541void AliTRDptrgParam::Terminate()
542{
543 // destruct the instance
544
545 if (fgInstance != 0) {
546 delete fgInstance;
547 fgInstance = 0x0;
548 }
549}
550
551//______________________________________________________________________________
552void AliTRDptrgParam::LoadStandardConfiguration() {
553 // loads a standard configuration parameters for testing
554
555 // TLMU Input Masks
556 for (UInt_t iSM = 0; iSM < 18; iSM++) {
557 this->fTLMUInputMask[iSM] = 0xFFFFFFFF; // enable all input bits
558 }
559
560 // TLMU Input Stretch
561 this->fTLMUInputStretch = 0; // not used in simulation
562
563 // TLMU Coincidence Matrices
564 //
565 // Matrix 0: Back-To-Back
566 // Matrix 1: Back-To-Back +/-1
567 // Matrix 2: Back-To-Back +/-2
568 for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
569 for (UInt_t iSlice = 0; iSlice < 18; iSlice++) {
570 if (iMatrix == 0) {
571 if (iSlice < 9) {
572 this->fTLMUcmatrices[iMatrix][iSlice] = 0x201 << iSlice;
573 // Back-To-Back
574 AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
575 this->fTLMUcmatrices[iMatrix][iSlice]));
576 }
577 // because of symmetrie the other slices are not necessary
578 }
579 else if (iMatrix == 1) {
580 // Back-To-Back +/- 1
581 if (iSlice < 8) {
582 this->fTLMUcmatrices[iMatrix][iSlice] = 0x381 << iSlice;
583 }
584 else if (iSlice == 8) {
585 this->fTLMUcmatrices[iMatrix][iSlice] = 0x30101;
586 }
587 else if (iSlice == 9) {
588 this->fTLMUcmatrices[iMatrix][iSlice] = 0x20203;
589 }
590 else {
591 this->fTLMUcmatrices[iMatrix][iSlice] = 0x407 << (iSlice - 10);
592 }
593 AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
594 this->fTLMUcmatrices[iMatrix][iSlice]));
595 }
596 else if (iMatrix == 2) {
597 // Back-To-Back +/-2
598 if (iSlice < 7 ) {
599 this->fTLMUcmatrices[iMatrix][iSlice] = 0xF81 << iSlice;
600 }
601 else if (iSlice == 7) {
602 this->fTLMUcmatrices[iMatrix][iSlice] = 0x3C081;
603 }
604 else if (iSlice == 8) {
605 this->fTLMUcmatrices[iMatrix][iSlice] = 0x38103;
606 }
607 else if (iSlice == 9) {
608 this->fTLMUcmatrices[iMatrix][iSlice] = 0x30207;
609 }
610 else if (iSlice == 10) {
611 this->fTLMUcmatrices[iMatrix][iSlice] = 0x2040F;
612 }
613 else {
614 this->fTLMUcmatrices[iMatrix][iSlice] = 0x81F << (iSlice - 11);
615 }
616 AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
617 this->fTLMUcmatrices[iMatrix][iSlice]));
618 }
619 }
620 }
621
622 // TLMU Mulitplicity
623 this->fTLMUmultiplicity[0][0] = 0;
624 this->fTLMUmultiplicity[0][1] = 10;
625 this->fTLMUmultiplicity[1][0] = 10;
626 this->fTLMUmultiplicity[1][1] = 25;
627 this->fTLMUmultiplicity[2][0] = 25;
628 this->fTLMUmultiplicity[2][1] = 50;
629 this->fTLMUmultiplicity[3][0] = 50;
630 this->fTLMUmultiplicity[3][1] = 100;
631 this->fTLMUmultiplicity[4][0] = 100;
632 this->fTLMUmultiplicity[4][1] = 200;
633 this->fTLMUmultiplicity[5][0] = 200;
634 this->fTLMUmultiplicity[5][1] = 350;
635 this->fTLMUmultiplicity[6][0] = 350;
636 this->fTLMUmultiplicity[6][1] = 400;
637 this->fTLMUmultiplicity[7][0] = 400;
638 this->fTLMUmultiplicity[7][1] = 576;
639 this->fTLMUmultiplicity[8][0] = 100;
640 this->fTLMUmultiplicity[8][1] = 576;
641
642 // TLMU output
643 this->fTLMUoutput[0][0] = 0;
644 this->fTLMUoutput[1][0] = 1;
645 this->fTLMUoutput[2][0] = 2;
646 this->fTLMUoutput[3][1] = 0;
647 this->fTLMUoutput[4][1] = 1;
648 this->fTLMUoutput[5][1] = 2;
649 this->fTLMUoutput[6][1] = 3;
650 this->fTLMUoutput[7][1] = 8;
651
652 // T0 FEB Thresholds
653 for (UInt_t iChannel = 0; iChannel < 12; iChannel++) {
654 this->fFEBT0Thresholds[0][iChannel] = 10;
655 this->fFEBT0Thresholds[1][iChannel] = 10;
656 }
657
658 // T0 Multiplicities
659 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
660 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
661 if (iLUT == 0) {
662 this->fFEBT0Multiplicities[iPosition][iLUT][0] = 0;
663 }
664 else {
665 this->fFEBT0Multiplicities[iPosition][iLUT][0] = 5;
666 }
667 this->fFEBT0Multiplicities[iPosition][iLUT][1] = 0xFFF;
668 }
669 }
670
671 // V0 FEB Thresholds
672 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
673 for (UInt_t iCard = 0; iCard < 4; iCard++) {
674 for (UInt_t iChannel = 0; iChannel < 8; iChannel++) {
675 this->fFEBV0Thresholds[iPosition][iCard][iChannel] = 10;
676 }
677 }
678 }
679
680 // V0 Multiplicities
681 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
682 for (UInt_t iCard = 0; iCard < 4; iCard++) {
683 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
684 if (iLUT == 0) {
685 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 0;
686 }
687 else {
688 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 3;
689 }
690 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][1] = 0xFF;
691 }
692 }
693 }
694
695 // CB-A LUT equations
696 this->fCBALUTequX = "T0_0 || (V0-0_0 || V0-1_0 || V0-2_0 || V0-3_0)";
697 this->fCBALUTequY = "!T0_1 && !V0-0_1 && !V0-1_1 && !V0-2_1 && !V0-3_1";
698
699 // CB-C LUT equations
700 this->fCBCLUTequX = "T0_0 || ( V0-0_0 || V0-1_0 || V0-2_0 || V0-3_0 )";
701 this->fCBCLUTequY = "!T0_1 && !V0-0_1 && !V0-1_1 && !V0-2_1 && !V0-3_1";
702
703 // CB-B LUT equations
704 this->fCBBLUTequX = "( CB-A_1 || CB-C_1 ) && TLMU_7";
705 this->fCBBLUTequY = "( CB-A_1 || CB-C_1 ) && TLMU_7";
706
707 // PT output mask
708 this->fPTmasks.fLUTs[0] = kTRUE;
709 this->fPTmasks.fLUTs[1] = kTRUE;
710 this->fPTmasks.fCBA[0] = kTRUE;
711 this->fPTmasks.fCBC[0] = kTRUE;
712 for (Int_t i = 1; i < 8; i++) {
713 this->fPTmasks.fTLMU[i] = kTRUE;
714 }
715
716 return;
717}
718
719//______________________________________________________________________________
720Bool_t AliTRDptrgParam::LoadConfigurationFromFile(TString filename) {
721 // Reads pretrigger configuration file and forwards identifiers and values
722 // to the corresponding parser functions
723 // This method is only checking for certain keywords at the beginning of a
724 // line in the config file
725
726 ifstream inputFile;
727 inputFile.open(filename.Data());
728 TString line;
729 TString identifier;
730 TString value;
731 std::string str;
732
733
734 if (inputFile.is_open())
735 {
736 AliDebug(5, "---- Reading configuration file ----");
737 while (getline(inputFile, str)) {
738 line = str;
739
740 AliDebug(5, Form("line: %s\n", line.Data()));
741 if (line.Index("TLMU") == 0) {
742 this->PrepareLine(line, identifier, value);
743 if (!this->ParseTLMU(identifier, value)) {
744 return kFALSE;
745 }
746 }
747 else if (line.Index("FEB") == 0) {
748 this->PrepareLine(line, identifier, value);
749 if (!this->ParseFEB(identifier, value)) {
750 return kFALSE;
751 }
752 }
753 else if (line.Index("CBB") == 0) {
754 this->PrepareLine(line, identifier, value);
755 if (!this->ParseCBB(identifier, value)) {
756 return kFALSE;
757 }
758 }
759 else if ((line.Index("CBA") == 0) ||
760 (line.Index("CBC") == 0)) {
761 this->PrepareLine(line, identifier, value);
762 if (!this->ParseCBAC(identifier, value)) {
763 return kFALSE;
764 }
765 }
766 }
767 AliDebug(5, "---- Finished reading configuration file ----");
768 inputFile.close();
769 return kTRUE;
770 }
771 else
772 {
773 AliDebug(5, "Error opening configuration file");
774 return kFALSE;
775 }
776 return kTRUE;
777}
778
779
780//______________________________________________________________________________
781Int_t AliTRDptrgParam::GenerateLUTs() {
782 // generates all LUTs defined inside this object, this schould called only
783 // once, after configuration is loaded in order to save cpu time
784
785 // generation method:
786 // walk through address space
787 // mask address with input mask => get multiplicity of masked value
788 // if (multiplicity of masked value) > multiplicity condition
789 // write 1 in LUT
790
791 // T0
792 this->fFEBT0LUTs = new Int_t**[2]; // 2 A + C side
793 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
794 // iPosition = 0 -> A, iPosition = 1 -> C
795 this->fFEBT0LUTs[iPosition] = new Int_t*[2]; // 2 LUTs per side
796 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
797 // LUT with 12 input channels 2^12=4096
798 this->fFEBT0LUTs[iPosition][iLUT] = new Int_t[4096];
799 AliDebug(5, Form("Generate FEBT0LUT[%d][%d]: (0x%x)>%d", iPosition, iLUT,
800 this->fFEBT0Multiplicities[iPosition][iLUT][1],
801 this->fFEBT0Multiplicities[iPosition][iLUT][0]));
802 for (UInt_t iEntry = 0; iEntry < 4096; iEntry++) {
803 // Check whether that entry belongs to a multiplicity exceeding the
804 // threshold
805 if (this->GetMultiplicity(iEntry &
806 this->fFEBT0Multiplicities[iPosition][iLUT][1]) >
807 this->fFEBT0Multiplicities[iPosition][iLUT][0]) {
808 this->fFEBT0LUTs[iPosition][iLUT][iEntry] = 1;
809 }
810 else {
811 // initialize LUT (not done before !)
812 this->fFEBT0LUTs[iPosition][iLUT][iEntry] = 0;
813 }
814 AliDebug(10, Form("FEBT0LUTs[%d][%d][0x%x]=%d", iPosition, iLUT, iEntry,
815 this->fFEBT0LUTs[iPosition][iLUT][iEntry]));
816 }
817 AliDebug(5, Form("Generated FEBT0LUTs[%d][%d]", iPosition, iLUT));
818 }
819 }
820
821 // V0
822 this->fFEBV0LUTs = new Int_t***[2]; // 2 A + C side
823 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
824 // iPosition = 0 -> A, iPosition = 1 -> C
825 this->fFEBV0LUTs[iPosition] = new Int_t**[4]; // 4 FEBs per side
826 for (UInt_t iFEB = 0; iFEB < 4; iFEB++) {
827 this->fFEBV0LUTs[iPosition][iFEB] = new Int_t*[2]; // 2 LUTs per FEB
828 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
829 // LUT with 10 input channels 2^10=1024
830 this->fFEBV0LUTs[iPosition][iFEB][iLUT] = new Int_t[1024];
831 AliDebug(5, Form("Generate FEBV0LUT[%d][%d][%d]: (0x%x)>%d", iPosition,
832 iFEB, iLUT,
833 this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][1],
834 this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][0]));
835 for (UInt_t iEntry = 0; iEntry < 1024; iEntry++) {
836 // Check whether that entry belongs to a multiplicity exceeding the
837 // threshold
838 if (this->GetMultiplicity(iEntry &
839 this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][1]) >
840 this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][0]) {
841 this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry] = 1;
842 }
843 else {
844 // initialize LUT (not done before !)
845 this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry] = 0;
846 }
847 AliDebug(10, Form("FEBV0LUTs[%d][%d][%d][0x%x]=%d", iPosition, iFEB,
848 iLUT, iEntry,
849 this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry]));
850 }
851 AliDebug(5, Form("Generated FEBV0LUTs[%d][%d][%d]", iPosition, iFEB,
852 iLUT));
853 }
854 }
855 }
856
857 // ControlBoxes (CB-x)
858 // initialize LUTs
859 this->fCBLUTs = new Int_t**[3];
860 for (Int_t iCB = 0; iCB < 3; iCB++) {
861 this->fCBLUTs[iCB] = new Int_t*[2];
862 this->fCBLUTs[iCB][0] = 0x0;
863 this->fCBLUTs[iCB][1] = 0x0;
864 }
865
866 // CB-A (CB = 1 / kA)
867 this->fCBLUTs[1][0] = this->GenerateLUTbasedOnEq(this->fCBALUTequX, 10, 1);
868 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
869 AliDebug(10, Form("fCBLUTs[@A][0]=%d", this->fCBLUTs[1][0]));
870 }
871 this->fCBLUTs[1][1] = this->GenerateLUTbasedOnEq(this->fCBALUTequY, 10, 1);
872 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
873 AliDebug(10, Form("fCBLUTs[@A][1]=%d", this->fCBLUTs[1][1]));
874 }
875
876 // CB-C (CB = 2 / kC)
877 this->fCBLUTs[2][0] = this->GenerateLUTbasedOnEq(this->fCBCLUTequX, 10, 1);
878 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
879 AliDebug(6, Form("fCBLUTs[@C][0]=%d", this->fCBLUTs[2][0]));
880 }
881 this->fCBLUTs[2][1] = this->GenerateLUTbasedOnEq(this->fCBCLUTequY, 10, 1);
882 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
883 AliDebug(10, Form("fCBLUTs[@C][1]=%d", this->fCBLUTs[2][0]));
884 }
885
886 // CB-B (CB = 0 / kB)
887 this->fCBLUTs[0][0] = this->GenerateLUTbasedOnEq(this->fCBALUTequX, 12, 1);
888 for (Int_t iEntry = 0; iEntry < 4096; iEntry++) {
889 AliDebug(10, Form("fCBLUTs[@B][0]=%d", this->fCBLUTs[0][0]));
890 }
891 this->fCBLUTs[0][1] = this->GenerateLUTbasedOnEq(this->fCBALUTequY, 12, 1);
892
893 for (Int_t iEntry = 0; iEntry < 4096; iEntry++) {
894 AliDebug(10, Form("fCBLUTs[@B][1]=%d", this->fCBLUTs[0][1]));
895 }
896
897 AliDebug(5, "LUTs were generated!");
898 return 0;
899}
900
901//______________________________________________________________________________
902UInt_t AliTRDptrgParam::GetMultiplicity(UInt_t BitVector) const {
903 // returns the multiplicity of a given bit vector
904
905 UInt_t result = 0;
906 UInt_t temp = 0x01;
907 for (UInt_t iBit = 0; iBit < 32; iBit++) {
908 if (BitVector & temp) {
909 result++;
910 }
911 temp <<= 1;
912 }
913
914 return result;
915}
916
917//______________________________________________________________________________
918UInt_t AliTRDptrgParam::GetMultiplicity(Int_t BitVector) const {
919 // returns the multiplicity of a given bit vector
920
921 UInt_t result = 0;
922 UInt_t temp = 0x01;
923 for (UInt_t iBit = 0; iBit < 32; iBit++) {
924 if (BitVector & temp) {
925 result++;
926 }
927 temp <<= 1;
928 }
929
930 return result;
931}
932
933//______________________________________________________________________________
934//
935// Configuration file parsing (helper functions)
936//______________________________________________________________________________
937
938//______________________________________________________________________________
939void AliTRDptrgParam::PrepareLine(TString line, TString& identifier,
940 TString& value) {
941 // Prepares a line for parsing
942 // divide identifier and value
943
944 // clear identifier and value
945 identifier.Clear();
946 value.Clear();
947
948 Int_t iLetter = 0;
949 while ((line[iLetter] != ' ') && (line[iLetter] != '\t') &&
950 (line[iLetter] != '#') && (iLetter < line.Length())) {
951 // read identifier
952 identifier += line[iLetter];
953 iLetter++;
954 }
955 while (((line[iLetter] == ' ') || (line[iLetter] == '\t')) &&
956 (iLetter < line.Length()) && (line[iLetter] != '#')) {
957 // omit whitespaces and tabs in between
958 iLetter++;
959 }
960 while(iLetter < line.Length()) {
961 // read value or equation and remove white spaces and tabs
962 //if ((line[iLetter] != ' ') && (line[iLetter] != '\t') &&
963 // (line[iLetter] != '#')) {
964 if (line[iLetter] != '#') {
965 value += line[iLetter];
966 }
967 iLetter++;
968 }
969}
970
971//______________________________________________________________________________
972TString AliTRDptrgParam::CleanTString(TString string) {
973 // Removes white spaces and tabs
974
975 TString result;
976 result.Clear();
977 for (Int_t iLetter = 0; iLetter < string.Length(); iLetter++) {
978 if ((string[iLetter] != ' ') && (string[iLetter] != '\t')) {
979 result += string[iLetter];
980 }
981 }
982 AliDebug(5, Form("Cleaned string: %s", result.Data()));
983 return result;
984}
985
986//______________________________________________________________________________
987void AliTRDptrgParam::SplitUpValues(TString value, TObjArray& arr) {
988 // splits up multiple values into a TObjArray
989
990 TString temp;
991 temp.Clear();
992 temp.Resize(0);
993 for (Int_t iLetter = 0; iLetter < value.Length(); iLetter++) {
994 if ((value[iLetter] != ' ') && (value[iLetter] != '\t')) {
995 // add another letter
996 temp += value[iLetter];
997 }
998 else {
999 // seperator found: white space or tabs
1000 if (temp.Length()) {
1001 TObjString* t = new TObjString(temp.Data());
1002 arr.Add(t);
1003 temp.Clear();
1004 temp.Resize(0);
1005 }
1006 }
1007 }
1008 if (temp.Length() != 0) { // TODO
1009 TObjString* t = new TObjString(temp.Data());
1010 arr.Add(t);
1011 }
1012}
1013
1014//______________________________________________________________________________
1015UInt_t AliTRDptrgParam::BinaryTStringToInt(TString number) const {
1016 // converts a binary TString to an integer
1017 UInt_t temp = 0x01;
1018 UInt_t result = 0x0;
1019 for (Int_t i = number.Length() - 1; i >= 0; i--) {
1020 if (number[i] == '1') {
1021 result |= temp;
1022 temp <<= 1;
1023 }
1024 else if (number[i] == '0') {
1025 temp <<= 1;
1026 }
1027 }
1028 return result;
1029}
1030
1031//______________________________________________________________________________
1032Bool_t AliTRDptrgParam::ParseMultiplicityCondition(TString condition,
1033 UInt_t* threshold,
1034 UInt_t* mask) {
1035 // converts a string formed like "M(1111_1111)>4" to a input mask and a
1036 // multiplicity threshold
1037
1038 // check whether condition is starting with "M(
1039 if ((condition[0] != 'M') || ( condition[1] != '(')) {
1040 return kFALSE;
1041 }
1042
1043 TString maskStr = "";
1044 Int_t iLetter = 0;
1045
1046 // extract input mask
1047 while (condition[iLetter] != ')') {
1048 maskStr += condition[iLetter++];
1049 }
1050 (*mask) = BinaryTStringToInt(maskStr);
1051 if ((*mask) == 0) { // TODO find a better method to detected parser errors
1052 AliDebug(5, Form("Invalid input mask: %s,[%s]", maskStr.Data(),
1053 condition.Data()));
1054 return kFALSE;
1055 }
1056
1057 // ensure that ')' is followed by a '>'
1058 if (condition[++iLetter] != '>') {
1059 AliDebug(5, Form("multiplicity condition is incorrectly formed: %s",
1060 condition.Data()));
1061 return kFALSE;
1062 }
1063 iLetter++; // move on to the first digit
1064
1065 TString thresholdStr = "";
1066 // gain threshold string
1067 while (((condition[iLetter] != ' ') || (condition[iLetter] != '\t')) &&
1068 (iLetter < condition.Length())) {
1069 thresholdStr += condition[iLetter++];
1070 }
1071 (*threshold) = thresholdStr.Atoi(); // convert string to integer
1072 AliDebug(5, Form("mask: 0x%x, multiplicity threshold: %d", (*mask),
1073 (*threshold)));
1074 return kTRUE;
1075}
1076
1077//______________________________________________________________________________
1078Bool_t AliTRDptrgParam::ParseFEB(TString identifier, TString value) {
1079 // Parse FEB configuration
1080
1081 //------------------------------------------
1082 if (identifier.Index("FEB/T0/A/THR") == 0) {
1083 // FEB T0 thresholds at A side
1084
1085 TObjArray arr;
1086 arr.Clear();
1087 SplitUpValues(value, arr);
1088
1089 if (arr.GetEntries() != 12) {
1090 AliError("Wrong FEB T0 Threshold count, it must be 12 channels!");
1091 return kFALSE;
1092 }
1093 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1094 this->fFEBT0Thresholds[0][iValue] =
1095 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1096 AliDebug(5, Form("FEB/T0/A/THR[%d]=%d", iValue,
1097 this->fFEBT0Thresholds[0][iValue]));
1098 }
1099 return kTRUE;
1100 }
1101
1102 //-----------------------------------------------
1103 else if (identifier.Index("FEB/T0/C/THR") == 0) {
1104 // FEB T0 thresholds at c side
1105
1106 TObjArray arr;
1107 arr.Clear();
1108 SplitUpValues(value, arr);
1109
1110 if (arr.GetEntries() != 12) {
1111 AliError("Wrong FEB T0 Threshold count, it must be 12 channels!");
1112 return kFALSE;
1113 }
1114 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1115 this->fFEBT0Thresholds[1][iValue] =
1116 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1117 AliDebug(5, Form("FEB/T0/C/THR[%d]=%d", iValue,
1118 this->fFEBT0Thresholds[1][iValue]));
1119 }
1120 return kTRUE;
1121 }
1122
1123 //--------------------------------------------------
1124 else if ((identifier.Index("FEB/V0/A0/THR") == 0) ||
1125 (identifier.Index("FEB/V0/A1/THR") == 0) ||
1126 (identifier.Index("FEB/V0/A2/THR") == 0) ||
1127 (identifier.Index("FEB/V0/A3/THR") == 0)) {
1128 // FEB V0 thresholds at a side (cards 0,1,2,3)
1129
1130 TString cardIDstr = identifier(8, 1);
1131 Int_t cardID = cardIDstr.Atoi();
1132
1133 TObjArray arr;
1134 arr.Clear();
1135 SplitUpValues(value, arr);
1136
1137 if (arr.GetEntries() != 8) {
1138 AliError("Wrong FEB V0 Threshold count, it must be 8 channels!");
1139 return kFALSE;
1140 }
1141 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1142 this->fFEBV0Thresholds[0][cardID][iValue] =
1143 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1144 AliDebug(5, Form("FEB/V0/A%d/THR[%d]=%d", cardID, iValue,
1145 this->fFEBV0Thresholds[0][cardID][iValue]));
1146 }
1147 }
1148
1149 //--------------------------------------------------
1150 else if ((identifier.Index("FEB/V0/C0/THR") == 0) ||
1151 (identifier.Index("FEB/V0/C1/THR") == 0) ||
1152 (identifier.Index("FEB/V0/C2/THR") == 0) ||
1153 (identifier.Index("FEB/V0/C3/THR") == 0)) {
1154 // FEB V0 thresholds at c side (cards 0,1,2,3)
1155
1156 TString cardIDstr = identifier(8, 1);
1157 Int_t cardID = cardIDstr.Atoi();
1158
1159 TObjArray arr;
1160 arr.Clear();
1161 SplitUpValues(value, arr);
1162
1163 if (arr.GetEntries() != 8) {
1164 AliError("Wrong FEB V0 Threshold count, it must be 8 channels!");
1165 return kFALSE;
1166 }
1167 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1168 this->fFEBV0Thresholds[1][cardID][iValue] =
1169 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1170 AliDebug(5, Form("FEB/V0/C%d/THR[%d]=%d", cardID, iValue,
1171 this->fFEBV0Thresholds[1][cardID][iValue]));
1172 }
1173 }
1174
1175 //-----------------------------------------------
1176 else if (identifier.Index("FEB/T0/A/LUT") == 0) {
1177 // FEB T0 look up tables at A side
1178
1179 TString lutIDstr = identifier(13, 1);
1180 Int_t lutID = lutIDstr.Atoi();
1181
1182 UInt_t val = 0;
1183 UInt_t mask = 0;
1184 ParseMultiplicityCondition(value, &val, &mask);
1185 this->fFEBT0Multiplicities[0][lutID][0] = val;
1186 this->fFEBT0Multiplicities[0][lutID][1] = mask;
1187 AliDebug(5, Form("FEBT0Multiplicities[0/A][%d][val] = %d", lutID, val));
1188 AliDebug(5, Form("FEBT0Multiplicities[0/A][%d][mask] = %d", lutID, mask));
1189
1190 return kTRUE;
1191 }
1192
1193 //-----------------------------------------------
1194 else if (identifier.Index("FEB/T0/C/LUT") == 0) {
1195 // FEB T0 look up tables at C side
1196
1197 TString lutIDstr = identifier(13, 1);
1198 Int_t lutID = lutIDstr.Atoi();
1199
1200 UInt_t val = 0;
1201 UInt_t mask = 0;
1202 ParseMultiplicityCondition(value, &val, &mask);
1203 this->fFEBT0Multiplicities[1][lutID][0] = val;
1204 this->fFEBT0Multiplicities[1][lutID][1] = mask;
1205 AliDebug(5, Form("FEBT0Multiplicities[1/C][%d][val] = %d", lutID, val));
1206 AliDebug(5, Form("FEBT0Multiplicities[1/C][%d][mask] = %d", lutID, mask));
1207
1208 return kTRUE;
1209 }
1210
1211 //--------------------------------------------------
1212 else if ((identifier.Index("FEB/V0/A0/LUT") == 0) ||
1213 (identifier.Index("FEB/V0/A1/LUT") == 0) ||
1214 (identifier.Index("FEB/V0/A2/LUT") == 0) ||
1215 (identifier.Index("FEB/V0/A3/LUT") == 0)) {
1216 // FEB V0 look up tables at A side
1217
1218 TString cardIDstr = identifier(8, 1);
1219 Int_t cardID = cardIDstr.Atoi();
1220
1221 TString lutIDstr = identifier(14, 1);
1222 Int_t lutID = lutIDstr.Atoi();
1223
1224 UInt_t val = 0;
1225 UInt_t mask = 0;
1226 ParseMultiplicityCondition(value, &val, &mask);
1227 this->fFEBV0Multiplicities[0][cardID][lutID][0] = val;
1228 this->fFEBV0Multiplicities[0][cardID][lutID][1] = mask;
1229 AliDebug(5, Form("FEBV0Multiplicities[0/A][%d][%d][val] = %d", cardID,
1230 lutID, val));
1231 AliDebug(5, Form("FEBV0Multiplicities[0/A][%d][%d][mask] = %d", cardID,
1232 lutID, mask));
1233
1234 return kTRUE;
1235 }
1236
1237 //--------------------------------------------------
1238 else if ((identifier.Index("FEB/V0/C0/LUT") == 0) ||
1239 (identifier.Index("FEB/V0/C1/LUT") == 0) ||
1240 (identifier.Index("FEB/V0/C2/LUT") == 0) ||
1241 (identifier.Index("FEB/V0/C3/LUT") == 0)) {
1242 // FEB V0 look up tables at C side
1243
1244 TString cardIDstr = identifier(8, 1);
1245 Int_t cardID = cardIDstr.Atoi();
1246
1247 TString lutIDstr = identifier(14, 1);
1248 Int_t lutID = lutIDstr.Atoi();
1249
1250 UInt_t val = 0;
1251 UInt_t mask = 0;
1252 ParseMultiplicityCondition(value, &val, &mask);
1253 this->fFEBV0Multiplicities[1][cardID][lutID][0] = val;
1254 this->fFEBV0Multiplicities[1][cardID][lutID][1] = mask;
1255 AliDebug(5, Form("FEBV0Multiplicities[1/C][%d][%d][val] = %d", cardID,
1256 lutID, val));
1257 AliDebug(5, Form("FEBV0Multiplicities[1/C][%d][%d][mask] = %d", cardID,
1258 lutID, mask));
1259
1260 return kTRUE;
1261 }
1262 return kTRUE;
1263}
1264
1265//______________________________________________________________________________
1266Bool_t AliTRDptrgParam::ParseCBAC(TString identifier, TString value) {
1267 // Parse CB-A and CB-C configuration
1268
1269 if (identifier.Index("CBA/LUT/") == 0) {
1270 // parse CB-A's logical equations
1271
1272 TString eqIDstr = identifier(8, 1);
1273 Int_t eqID = eqIDstr.Atoi();
1274
1275 if (eqID == 0) {
1276 this->fCBALUTequX = this->CleanTString(value);
1277 AliDebug(5, Form("fCBALUTequX=%s", this->fCBALUTequX.Data()));
1278 }
1279 else if(eqID == 1) {
1280 this->fCBALUTequY= this->CleanTString(value);
1281 AliDebug(5, Form("fCBALUTequY=%s", this->fCBALUTequY.Data()));
1282 }
1283 return kTRUE;
1284 }
1285
1286 else if (identifier.Index("CBC/LUT/") == 0) {
1287 // parse CB-C's logical equations
1288
1289 TString eqIDstr = identifier(8, 1);
1290 Int_t eqID = eqIDstr.Atoi();
1291
1292 if (eqID == 0) {
1293 this->fCBCLUTequX = this->CleanTString(value);
1294 AliDebug(5, Form("fCBCLUTequX=%s", this->fCBCLUTequX.Data()));
1295 }
1296 else if(eqID == 1) {
1297 this->fCBCLUTequY= this->CleanTString(value);
1298 AliDebug(5, Form("fCBCLUTequY=%s", this->fCBCLUTequY.Data()));
1299 }
1300 }
1301
1302 return kTRUE;
1303}
1304
1305//______________________________________________________________________________
1306Bool_t AliTRDptrgParam::ParseCBB(TString identifier, TString value) {
1307 // Parse CBB configuration
1308
1309 if (identifier.Index("CBB/LUT/") == 0) {
1310 // parse CB-B's logical equations
1311
1312 TString eqIDstr = identifier(8, 1);
1313 Int_t eqID = eqIDstr.Atoi();
1314
1315 if (eqID == 0) {
1316 this->fCBBLUTequX = this->CleanTString(value);
1317 AliDebug(5, Form("fCBBLUTequX=%s", this->fCBBLUTequX.Data()));
1318 }
1319 else if(eqID == 1) {
1320 this->fCBBLUTequY= this->CleanTString(value);
1321 AliDebug(5, Form("fCBBLUTequY=%s", this->fCBBLUTequY.Data()));
1322 }
1323 return kTRUE;
1324 }
1325
1326 // PT masks
1327 else if (identifier.Index("CBB/PT/MASK/CB-A_0") == 0) { // CB-A_0
1328 if (value.Index("YES") == 0) {
1329 this->fPTmasks.fCBA[0] = kTRUE;
1330 }
1331 else {
1332 this->fPTmasks.fCBA[0] = kFALSE;
1333 }
1334 AliDebug(5, Form("CBB/PT/MASK/CB-A_0=%d", this->fPTmasks.fCBA[0]));
1335 return kTRUE;
1336 }
1337 else if (identifier.Index("CBB/PT/MASK/CB-A_1") == 0) { // CB-A_1
1338 if (value.Index("YES") == 0) {
1339 this->fPTmasks.fCBA[1] = kTRUE;
1340 }
1341 else {
1342 this->fPTmasks.fCBA[1] = kFALSE;
1343 }
1344 AliDebug(5, Form("CBB/PT/MASK/CB-A_1=%d", this->fPTmasks.fCBA[1]));
1345 return kTRUE;
1346 }
1347 else if (identifier.Index("CBB/PT/MASK/CB-C_0") == 0) { // CB-C_0
1348 if (value.Index("YES") == 0) {
1349 this->fPTmasks.fCBC[0] = kTRUE;
1350 }
1351 else {
1352 this->fPTmasks.fCBC[0] = kFALSE;
1353 }
1354 AliDebug(5, Form("CBB/PT/MASK/CB-C_0=%d",this->fPTmasks.fCBC[0]));
1355 return kTRUE;
1356 }
1357 else if (identifier.Index("CBB/PT/MASK/CB-C_1") == 0) { // CB-C_1
1358 if (value.Index("YES") == 0) {
1359 this->fPTmasks.fCBC[1] = kTRUE;
1360 }
1361 else {
1362 this->fPTmasks.fCBC[1] = kFALSE;
1363 }
1364 AliDebug(5, Form("CBB/PT/MASK/CB-C_1=%d", this->fPTmasks.fCBC[1]));
1365 return kTRUE;
1366 }
1367 else if (identifier.Index("CBB/PT/MASK/CB-B_0") == 0) { // CB-B_0
1368 if (value.Index("YES") == 0) {
1369 this->fPTmasks.fLUTs[0] = kTRUE;
1370 }
1371 else {
1372 this->fPTmasks.fLUTs[0] = kFALSE;
1373 }
1374 AliDebug(5, Form("CBB/PT/MASK/CB-B_0=%d",this->fPTmasks.fLUTs[0]));
1375 return kTRUE;
1376 }
1377 else if (identifier.Index("CBB/PT/MASK/CB-B_1") == 0) { // CB-B_1
1378 if (value.Index("YES") == 0) {
1379 this->fPTmasks.fLUTs[1] = kTRUE;
1380 }
1381 else {
1382 this->fPTmasks.fLUTs[1] = kFALSE;
1383 }
1384 AliDebug(5, Form("CBB/PT/MASK/CB-B_1/=%d", this->fPTmasks.fLUTs[1]));
1385 return kTRUE;
1386 }
1387 else if (identifier.Index("BB/PT/MASK/TLMU_") == 0) {
1388 TString indexStr = identifier(16, 1);
1389 Int_t index = indexStr.Atoi();
1390 if (value.Index("YES") == 0) {
1391 this->fPTmasks.fTLMU[index] = kTRUE;
1392 }
1393 else {
1394 this->fPTmasks.fTLMU[index] = kFALSE;
1395 }
1396 AliDebug(5, Form("CBB/PT/MASK/TLMU_%d=%d", index,
1397 this->fPTmasks.fTLMU[index]));
1398 return kTRUE;
1399 }
1400 return kTRUE;
1401}
1402
1403//______________________________________________________________________________
1404Bool_t AliTRDptrgParam::ParseTLMU(TString identifier, TString value) {
1405 // Parse TLMU configuration
1406
1407 if (identifier.Index("TLMU/IMASK/SEC") == 0) {
1408 // TLMU input masks
1409 TString indexStr = identifier(14,2);
1410 Int_t index = indexStr.Atoi();
1411 if ((index < 0) || (index > 17)) {
1412 AliDebug(5, "Wrong section index in TLMU input mask");
1413 return kFALSE;
1414 }
1415 this->fTLMUInputMask[index] = BinaryTStringToInt(value);
1416 AliDebug(5, Form("%d %x\n", index, this->fTLMUInputMask[index]));
1417 return kTRUE;
1418 }
1419
1420 //-----------------------------------------------
1421 else if (identifier.Index("TLMU/CMATRIX") == 0) {
1422 // TLMU coincidence matrices
1423
1424 // matrix index
1425 TString matrixIndexStr = identifier(12,1);
1426 Int_t matrixIndex = matrixIndexStr.Atoi();
1427 // entry index
1428 TString indexStr = identifier(17,2);
1429 Int_t index = indexStr.Atoi();
1430 this->fTLMUcmatrices[matrixIndex][index] = BinaryTStringToInt(value);
1431 AliDebug(5, Form("%d 0x%x\n", matrixIndex,
1432 this->fTLMUcmatrices[matrixIndex][index]));
1433 return kTRUE;
1434 }
1435
1436 //---------------------------------------------
1437 else if (identifier.Index("TLMU/MCNTR") == 0) {
1438 // TLMU multiplicity counter setup
1439
1440 TString indexStr = identifier(10,1);
1441 Int_t index = indexStr.Atoi();
1442 TObjArray arr;
1443
1444 SplitUpValues(value, arr);
1445
1446 TString t0 = (dynamic_cast<TObjString*>(arr[0]))->GetString();
1447 TString t1 = (dynamic_cast<TObjString*>(arr[1]))->GetString();
1448
1449 this->fTLMUmultiplicity[index][0] = t0.Atoi();
1450 this->fTLMUmultiplicity[index][1] = t1.Atoi();
1451
1452 AliDebug(5, Form("%d: %d %d", index, this->fTLMUmultiplicity[index][0],
1453 this->fTLMUmultiplicity[index][1]));
1454
1455 return kTRUE;
1456 }
1457
1458 //----------------------------------------------
1459 else if (identifier.Index("TLMU/OUTMUX") == 0) {
1460 // TLMU output signal assignment
1461 TObjArray arr;
1462 SplitUpValues(value, arr);
1463
1464 if (arr.GetEntries() > 8) {
1465 AliError("Too many TLMU output signals assigned");
1466 return kFALSE;
1467 }
1468
1469 for (Int_t iEntry = 0; iEntry < arr.GetEntries(); iEntry++) {
1470 TString t = (dynamic_cast<TObjString*>(arr[iEntry]))->GetString();
1471
1472 TString indexStr = t(2,1);
1473 if (t.Index("CM") == 0) { // coincidence matrix
1474 this->fTLMUoutput[iEntry][0] = indexStr.Atoi();
1475 }
1476 else if (t.Index("MC") == 0) { // multiplicity
1477 this->fTLMUoutput[iEntry][1] = indexStr.Atoi();
1478 }
1479 AliDebug(5, Form("TLMU output: cm = %d, mc = %d",
1480 this->fTLMUoutput[iEntry][0],
1481 this->fTLMUoutput[iEntry][1]));
1482 }
1483 return kTRUE;
1484 }
1485 return kTRUE;
1486}
1487
1488//______________________________________________________________________________
1489//
1490// Logical Equation to LUT processing (helper functions)
1491//______________________________________________________________________________
1492
1493//______________________________________________________________________________
1494Int_t AliTRDptrgParam::LookUp(TString* const identifier) const {
1495 // Transforms identifier into look up table address bit
1496 //
1497 // this function has to be extended/changed when different identifiers for
1498 // other equations and destination LUTs should be used
1499
1500 if (identifier->CompareTo("T0_0", TString::kIgnoreCase) == 0)
1501 return 0x001;
1502 else if (identifier->CompareTo("T0_1", TString::kIgnoreCase) == 0)
1503 return 0x002;
1504 else if (identifier->CompareTo("V0-0_0", TString::kIgnoreCase) == 0)
1505 return 0x004;
1506 else if (identifier->CompareTo("V0-0_1", TString::kIgnoreCase) == 0)
1507 return 0x008;
1508 else if (identifier->CompareTo("V0-1_0", TString::kIgnoreCase) == 0)
1509 return 0x010;
1510 else if (identifier->CompareTo("V0-1_1", TString::kIgnoreCase) == 0)
1511 return 0x020;
1512 else if (identifier->CompareTo("V0-2_0", TString::kIgnoreCase) == 0)
1513 return 0x040;
1514 else if (identifier->CompareTo("V0-2_1", TString::kIgnoreCase) == 0)
1515 return 0x080;
1516 else if (identifier->CompareTo("V0-3_0", TString::kIgnoreCase) == 0)
1517 return 0x100;
1518 else if (identifier->CompareTo("V0-3_1", TString::kIgnoreCase) == 0)
1519 return 0x200;
1520 else if (identifier->CompareTo("CB-A_0", TString::kIgnoreCase) == 0)
1521 return 0x001;
1522 else if (identifier->CompareTo("CB-A_1", TString::kIgnoreCase) == 0)
1523 return 0x002;
1524 else if (identifier->CompareTo("CB-C_0", TString::kIgnoreCase) == 0)
1525 return 0x004;
1526 else if (identifier->CompareTo("CB-C_1", TString::kIgnoreCase) == 0)
1527 return 0x008;
1528 else if (identifier->CompareTo("TLMU_0", TString::kIgnoreCase) == 0)
1529 return 0x010;
1530 else if (identifier->CompareTo("TLMU_1", TString::kIgnoreCase) == 0)
1531 return 0x020;
1532 else if (identifier->CompareTo("TLMU_2", TString::kIgnoreCase) == 0)
1533 return 0x040;
1534 else if (identifier->CompareTo("TLMU_3", TString::kIgnoreCase) == 0)
1535 return 0x080;
1536 else if (identifier->CompareTo("TLMU_4", TString::kIgnoreCase) == 0)
1537 return 0x100;
1538 else if (identifier->CompareTo("TLMU_5", TString::kIgnoreCase) == 0)
1539 return 0x200;
1540 else if (identifier->CompareTo("TLMU_6", TString::kIgnoreCase) == 0)
1541 return 0x400;
1542 else if (identifier->CompareTo("TLMU_7", TString::kIgnoreCase) == 0)
1543 return 0x100;
1544 else return 0x0; // Error
1545}
1546
1547//______________________________________________________________________________
1548void AliTRDptrgParam::MergeResults(TArrayI*& partResult1, TArrayI*& partResult2,
1549 TArrayI*& results,
1550 TArrayI*& signalsInvolved1,
1551 TArrayI*& signalsInvolved2,
1552 TArrayI*& signalsInvolved,
1553 Bool_t useOR) {
1554 // merges result and signal involved arrays
1555 // uses logical OR (or=kTRUE) and AND (or==kFALSE) as merging function
1556
1557 // check whether input data is valid
1558 if ((partResult1 == 0x0) || (partResult2 == 0x0) ||
1559 (signalsInvolved1 == 0x0) || (signalsInvolved2 == 0x0)) {
1560 AliError("fatal logical equation processing error!");
1561 }
1562
1563 // allocate results and signalsInvolved
1564 results = new TArrayI(0);
1565 signalsInvolved = new TArrayI(0);
1566
1567 // merge arrays (necessary for OR and AND)
1568 for (Int_t i = 0; i < partResult1->GetSize(); i++) {
1569 for (Int_t j = 0; j < partResult2->GetSize(); j++) {
1570 results->Set(results->GetSize() + 1); // increment size
1571 (*results)[results->GetSize() - 1] = // add combination
1572 (*partResult1)[i] | (*partResult2)[j];
1573
1574 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1575 (*signalsInvolved)[signalsInvolved->GetSize() - 1] =
1576 (*signalsInvolved1)[i] | (*signalsInvolved2)[j];
1577 }
1578 }
1579
1580 if (useOR) { // only necessary for OR
1581 // add partResult1
1582 for (Int_t i = 0; i < partResult1->GetSize(); i++) {
1583 results->Set(results->GetSize() + 1);
1584 (*results)[results->GetSize() - 1] = (*partResult1)[i];
1585
1586 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1587 (*signalsInvolved)[signalsInvolved->GetSize()-1] = (*signalsInvolved1)[i];
1588 }
1589 // add partResult2
1590 for (Int_t i = 0; i < partResult2->GetSize(); i++) {
1591 results->Set(results->GetSize() + 1);
1592 (*results)[results->GetSize() - 1] = (*partResult2)[i];
1593
1594 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1595 (*signalsInvolved)[signalsInvolved->GetSize()-1] = (*signalsInvolved2)[i];
1596 }
1597 }
1598
1599 // debug output
1600 AliDebug(5, "merging results: ");
1601 for (Int_t i = 0; i < results->GetSize(); i++) {
1602 AliDebug(5, Form("0x%x 0x%x", (*results)[i], (*signalsInvolved)[i]));
1603 }
1604
1605 // free memory
1606 delete partResult1;
1607 partResult1 = 0x0;
1608 delete partResult2;
1609 partResult2 = 0x0;
1610}
1611
1612//______________________________________________________________________________
1613void AliTRDptrgParam::ConvertLogicalEqToBitVectors(TString eq,
1614 TArrayI*& results,
1615 TArrayI*& signalsInvolved) {
1616 // converts a logical equation to a LUT
1617 //
1618 // input string must not contain white spaces or tabs
1619 // only identifiers, ||, &&, (, ) and ! are allowed
1620 //
1621 // neglected signals are assumed to be zero in this function
1622 // this problem is solved by "void CheckSignalsInvolved(...)"
1623
1624 AliDebug(5, Form("eq: %s", eq.Data()));
1625
1626 // temporary variables used before/while merging
1627 TArrayI* partResult1 = 0x0;
1628 TArrayI* partResult2 = 0x0;
1629 TArrayI* partResult3 = 0x0;
1630 TArrayI* partResult4 = 0x0;
1631 TArrayI* signalsInvolved1 = 0x0;
1632 TArrayI* signalsInvolved2 = 0x0;
1633 TArrayI* signalsInvolved3 = 0x0;
1634 TArrayI* signalsInvolved4 = 0x0;
1635
1636 Int_t iChar = 0; // counter variable
1637
1638 // variables needed for correct operator order (&& before ||!)
1639 Int_t foundORbefore = -1; // found an || in that string (-1 = not found)
1640 Int_t foundAND = -1; // found an &&
1641 Int_t foundORafter = -1; // found a second OR after &&
1642
1643 // variables needed for correct bracket processing
1644 Int_t enteredBrackets = 0; // indicates in which bracket layer the parser is
1645 Int_t bracketLevelAtZero = -1; // when enteredBrackets = 0 was reached first
1646 // after it ascended
1647
1648 while ((iChar < eq.Length())) { //--------------------------------------------
1649 // walk through string
1650
1651 // operators ---------------------------------------------------------------
1652 if ((enteredBrackets == 0 ) && (eq[iChar] != '(') && (eq[iChar] != ')')) {
1653 // '|'
1654 if (eq[iChar] == '|') {
1655 if (eq[iChar + 1] == '|') { // ||
1656 iChar++; // jump to the next charakter
1657 if (foundAND == -1) {
1658 foundORbefore = iChar;
1659 }
1660 else if ((foundORafter == -1) && (foundAND != -1)) {
1661 foundORafter = iChar;
1662 }
1663 }
1664 else { // bit-wise and not supported
1665 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1666 AliError("bit-wise AND (&) not supported for now");
1667 return;
1668 }
1669 }
1670 // '&'
1671 else if (eq[iChar] == '&') {
1672 if (eq[iChar] == '&') { // ||
1673 iChar++; // jump to the next charakter
1674 if (foundAND == -1) {
1675 foundAND = iChar;
1676 }
1677 }
1678 else { // bit-wise or not supported
1679 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1680 AliError("bit-wise OR (|) not supported for now");
1681 return;
1682 }
1683 }
1684 }
1685 // brackets ----------------------------------------------------------------
1686 // '('
1687 if (eq[iChar] == '(') {
1688 enteredBrackets++;
1689 }
1690 // ')'
1691 else if (eq[iChar] == ')') {
1692 enteredBrackets--;
1693 if (enteredBrackets < 0) {
1694 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1695 AliError("Too many )s");
1696 }
1697 if ((enteredBrackets == 0) && (bracketLevelAtZero == -1) &&
1698 (foundAND == -1) && (foundORbefore == -1)) {
1699 // needed to detected equations encapsulated in brackets: (...)
1700 bracketLevelAtZero = iChar;
1701 }
1702 }
1703 iChar++; // go on to the next letter/char
1704 } //--------------------------------------------------------------------------
1705
1706 if (bracketLevelAtZero == (eq.Length() - 1)) { // strip ( ) and process again
1707 ConvertLogicalEqToBitVectors(eq(1, eq.Length() -2), results,
1708 signalsInvolved);
1709 return;
1710 }
1711 else if (foundAND == -1) { // no AND
1712 if (foundORbefore != -1) { // only OR / || found and no AND
1713 ConvertLogicalEqToBitVectors(eq(0, foundORbefore-1), partResult1,
1714 signalsInvolved1);
1715 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1716 eq.Length()-foundORbefore-1),
1717 partResult2, signalsInvolved2);
1718
1719 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1720 signalsInvolved2, signalsInvolved, kTRUE);
1721 return;
1722 }
1723 else { // only identifier remained!
1724 results = new TArrayI(1);
1725 signalsInvolved = new TArrayI(1);
1726 if (eq[0] != '!') { // identifier without negation
1727 (*results)[0] = LookUp(&eq);
1728 (*signalsInvolved)[0] = (*results)[0];
1729 }
1730 else { // identifier with negation
1731 (*results)[0] = 0;
1732 TString eqNegated = eq(1, eq.Length()-1);
1733 (*signalsInvolved)[0] = LookUp(&eqNegated);
1734 }
1735 return;
1736 }
1737 }
1738 // found single or multiple AND / &&
1739 else if ((foundORafter != -1) && (foundORbefore != -1)) {
1740 // found: ...||...&&...||...
1741 ConvertLogicalEqToBitVectors(eq(0, foundORbefore-1), partResult1,
1742 signalsInvolved1);
1743 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1744 foundORafter-foundORbefore-2),
1745 partResult2, signalsInvolved2);
1746 ConvertLogicalEqToBitVectors(eq(foundORafter+1, eq.Length()-foundORafter-1),
1747 partResult3, signalsInvolved3);
1748
1749 // merge: 4 = 1 || 2
1750 MergeResults(partResult1, partResult2, partResult4, signalsInvolved1,
1751 signalsInvolved2, signalsInvolved4, kTRUE);
1752 // merge results = 3 || 4
1753 MergeResults(partResult3, partResult4, results, signalsInvolved3,
1754 signalsInvolved4, signalsInvolved, kTRUE);
1755 return;
1756 }
1757 else if (foundORbefore != -1) {
1758 // found ...||...&&...
1759 ConvertLogicalEqToBitVectors(eq(0, foundORbefore - 1), partResult1,
1760 signalsInvolved1);
1761 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1762 eq.Length()-foundORbefore-1),
1763 partResult2, signalsInvolved2);
1764
1765 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1766 signalsInvolved2, signalsInvolved, kTRUE);
1767 return;
1768 }
1769 else if (foundORafter != -1) {
1770 // found ...&&...||...
1771 ConvertLogicalEqToBitVectors(eq(0, foundORafter - 1), partResult1,
1772 signalsInvolved1);
1773 ConvertLogicalEqToBitVectors(eq(foundORafter+1,
1774 eq.Length()-foundORafter-1),
1775 partResult2, signalsInvolved2);
1776
1777 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1778 signalsInvolved2, signalsInvolved, kTRUE);
1779 return;
1780 }
1781 else /* if (foundAND != -1)*/ { // found ...&&...
1782 ConvertLogicalEqToBitVectors(eq(0, foundAND-1), partResult1,
1783 signalsInvolved1);
1784 ConvertLogicalEqToBitVectors(eq(foundAND+1, eq.Length()-foundAND-1),
1785 partResult2, signalsInvolved2);
1786
1787 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1788 signalsInvolved2, signalsInvolved, kFALSE);
1789 return;
1790 }
1791
1792 AliError("Logical equation parser error!");
1793 return;
1794}
1795
1796//______________________________________________________________________________
1797void AliTRDptrgParam::CheckSignalsInvolved(TArrayI*& results,
1798 TArrayI*& signalsInvolved,
1799 Int_t inputWidth) {
1800 // checks whether all input signals are taken into account
1801 //
1802 // this function is needed to be able to write equations which contain not all
1803 // possible signals and which are not mentioned in the equation do not effect
1804 // the result
1805 // X=B&&C=(A||!A)&&B&&C
1806
1807 // this routine is quite inefficient but working O((2^inputWidth)^3)
1808
1809 // generate mask:
1810 Int_t temp = 0x1;
1811 Int_t mask = 0x0;
1812 for (Int_t iSignal = 0; iSignal < inputWidth; iSignal++) {
1813 mask |= temp;
1814 temp <<= 1; // move temp to the next bit
1815 }
1816
1817 for (Int_t iResult = 0; iResult < results->GetSize(); iResult++) {
1818 // tricky: size of results increases while loop is iterating
1819 // that is needed to generate all valid input signal combinations
1820 if (mask != (*signalsInvolved)[iResult]) {
1821 // not all input signals are taken into account
1822 Int_t inputSignal = 0x1;
1823 for (Int_t iSignal = 0; iSignal < inputWidth; iSignal++) {
1824 if (!(inputSignal & (*signalsInvolved)[iResult])) {
1825 Int_t newInvolvedSignalCombination =
1826 (*signalsInvolved)[iResult] | inputSignal;
1827 Int_t newResult = inputSignal | (*results)[iResult];
1828 Bool_t signalCombinationAlreadyEnlisted = kFALSE;
1829 for (Int_t iEntry = 0; iEntry < signalsInvolved->GetSize(); iEntry++){
1830 // this loop is needed to reduce the amount of equal entries in
1831 // signalsInvolved
1832 // maybe a table with all possible input values could reduce the
1833 // computional effort, but this would consume a lot of ram
1834 if ((signalsInvolved->At(iEntry) == newInvolvedSignalCombination) &&
1835 (results->At(iEntry) == newResult)) {
1836 signalCombinationAlreadyEnlisted = kTRUE;
1837 break;
1838 }
1839 }
1840 if (!signalCombinationAlreadyEnlisted) {
1841 results->Set(results->GetSize() + 1);
1842 (*results)[results->GetSize() - 1] = inputSignal |
1843 (*results)[iResult];
1844 // add variant with active bit, variant with inactive signal
1845 // is already containt in the results array
1846
1847 // update signalsInvolved:
1848 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1849 (*signalsInvolved)[signalsInvolved->GetSize() - 1] =
1850 (*signalsInvolved)[iResult] | inputSignal;
1851 }
1852 }
1853 inputSignal <<= 1; // move temp to the next input signal
1854 }
1855 }
1856 }
1857 return;
1858}
1859
1860//______________________________________________________________________________
1861Int_t* AliTRDptrgParam::GenerateLUTbasedOnEq(TString eq, Int_t inputWidth,
1862 Int_t initValue) {
1863 // Processes the conversion of a logical equation to a look up table
1864
1865 TArrayI* results = 0x0;
1866 TArrayI* signalsInvolved = 0x0;
1867
1868 ConvertLogicalEqToBitVectors(eq, results, signalsInvolved);
1869 // generate bit vectors
1870
1871 CheckSignalsInvolved(results, signalsInvolved, inputWidth);
1872 // add bit vectors for signals which are not taken into account
1873
1874 Int_t lutSize = 0x1 << inputWidth; // 2^inputwidth elements
1875 Int_t* resultingLUT = new Int_t[lutSize]; // create LUT
1876 for (Int_t iLUTentry = 0; iLUTentry < lutSize; iLUTentry++) { // init LUT
1877 resultingLUT[iLUTentry] = 0;
1878 }
1879 for (Int_t iEntry = 0; iEntry < results->GetSize(); iEntry++) {
1880 resultingLUT[(*results)[iEntry]] = initValue;
1881 }
1882
1883 if (results != 0x0) {
1884 delete results;
1885 results = 0x0;
1886 }
1887 if (signalsInvolved != 0x0) {
1888 delete signalsInvolved;
1889 signalsInvolved = 0x0;
1890 }
1891
1892 return resultingLUT;
1893}
1894
1895//______________________________________________________________________________
1896//___ GETTER FUNCTIONS__________________________________________________________
1897//______________________________________________________________________________
1898UInt_t* AliTRDptrgParam::GetFEBT0Thresholds(AliTRDptrgFEBPosition_t FEBposition)
1899 const
1900{
1901 // get T0 FEB Thresholds
1902 return this->fFEBT0Thresholds[FEBposition - 1];
1903 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1904}
1905
1906//_____________________________________________________________________________
1907Int_t* AliTRDptrgParam::GetFEBT0LUT(AliTRDptrgFEBPosition_t FEBposition,
1908 Int_t iLUT) {
1909 // get T0 FEB LUTs
1910 if (this->fFEBT0LUTs == 0x0) {
1911 this->GenerateLUTs();
1912 }
1913 return this->fFEBT0LUTs[FEBposition - 1][iLUT];
1914 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1915}
1916
1917//______________________________________________________________________________
1918UInt_t* AliTRDptrgParam::GetFEBV0Thresholds(AliTRDptrgFEBPosition_t FEBposition,
1919 Int_t iCard) const {
1920 // get V0 FEB Thresholds
1921 return this->fFEBV0Thresholds[FEBposition - 1][iCard];
1922 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1923}
1924
1925//______________________________________________________________________________
1926Int_t* AliTRDptrgParam::GetFEBV0LUT(AliTRDptrgFEBPosition_t FEBposition,
1927 Int_t iCard, Int_t iLUT) {
1928 // get V0 FEB LUTs
1929 if (this->fFEBV0LUTs == 0x0) {
1930 this->GenerateLUTs();
1931 }
1932 return this->fFEBV0LUTs[FEBposition - 1][iCard][iLUT];
1933 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1934}
1935
1936//______________________________________________________________________________
1937Int_t* AliTRDptrgParam::GetCBLUT(UInt_t iCB, Int_t LUTid) {
1938 // return control box LUT
1939 // iCB: 0 = B, 1 = A, 2 = C
1940 if (this->fCBLUTs == 0x0) {
1941 this->GenerateLUTs();
1942 }
1943 return this->fCBLUTs[iCB][LUTid];
1944}
1945