1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // Parameters for Pre-Trigger Simulation
22 // Author: F. Reidt (Felix.Reidt@cern.ch)
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.
31 ////////////////////////////////////////////////////////////////////////////
33 #include "TObjString.h"
40 #include "AliTRDptrgParam.h"
42 ClassImp(AliTRDptrgParam)
44 AliTRDptrgParam *AliTRDptrgParam::fgInstance = 0;
47 //______________________________________________________________________________
48 AliTRDptrgParam::AliTRDptrgParam()
52 fTLMUmultiplicity(0x0),
54 fFEBT0Thresholds(0x0),
55 fFEBT0Multiplicities(0x0),
57 fFEBV0Thresholds(0x0),
58 fFEBV0Multiplicities(0x0),
61 fCBALUTequX(TString()),
62 fCBALUTequY(TString()),
63 fCBCLUTequX(TString()),
64 fCBCLUTequY(TString()),
65 fCBBLUTequX(TString()),
66 fCBBLUTequY(TString()),
67 fPTmasks(AliTRDptrgPTmasks())
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;
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;
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
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
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
126 // initialize T0 LUTs
127 // this->fFEBT0LUTs = 0x0; (done in member initialization list)
128 // further initialization is done in AliTRDptrgParam::GenerateLUTs()
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;
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;
157 // initialize V0 LUTs
158 // this->fFEBV0LUTs = 0x0; (done in member initialization list)
159 // further initialization is done in AliTRDptrgParam::GenerateLUTs()
161 // initialize CB LUTs
162 // this->fCBLUTs = 0x0; (done in member initialization list)
163 // further initialization is done in AliTRDptrgParam::GenerateLUTs()
165 this->LoadStandardConfiguration(); // load standard configuration
168 //______________________________________________________________________________
169 AliTRDptrgParam::~AliTRDptrgParam()
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;
181 delete[] this->fTLMUcmatrices;
182 this->fTLMUcmatrices = 0x0;
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;
193 delete[] this->fTLMUmultiplicity;
194 this->fTLMUmultiplicity = 0x0;
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;
205 delete[] this->fTLMUoutput;
206 this->fTLMUoutput = 0x0;
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;
215 if (this->fFEBT0Thresholds[1] != 0x0) {
216 delete[] this->fFEBT0Thresholds[1];
217 this->fFEBT0Thresholds[1] = 0x0;
219 delete[] this->fFEBT0Thresholds;
220 this->fFEBT0Thresholds = 0x0;
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;
233 delete[] this->fFEBT0Multiplicities[iPosition];
234 this->fFEBT0Multiplicities[iPosition] = 0x0;
237 delete[] this->fFEBT0Multiplicities;
238 this->fFEBT0Multiplicities = 0x0;
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;
251 delete[] this->fFEBT0LUTs[iPosition];
252 this->fFEBT0LUTs[iPosition] = 0x0;
255 delete[] this->fFEBT0LUTs;
256 this->fFEBT0LUTs = 0x0;
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;
269 delete[] this->fFEBV0Thresholds[iPosition];
270 this->fFEBV0Thresholds[iPosition] = 0x0;
273 delete[] this->fFEBV0Thresholds;
274 this->fFEBV0Thresholds = 0x0;
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;
289 delete[] this->fFEBV0Multiplicities[iPosition][iCard];
290 this->fFEBV0Multiplicities[iPosition][iCard] = 0x0;
293 delete[] this->fFEBV0Multiplicities[iPosition];
294 this->fFEBV0Multiplicities[iPosition] = 0x0;
297 delete[] this->fFEBV0Multiplicities;
298 this->fFEBV0Multiplicities = 0x0;
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;
313 delete[] this->fFEBV0LUTs[iPosition][iCard];
314 this->fFEBV0LUTs[iPosition][iCard] = 0x0;
317 delete[] this->fFEBV0LUTs[iPosition];
318 this->fFEBV0LUTs[iPosition] = 0x0;
321 delete[] this->fFEBV0LUTs;
322 this->fFEBV0LUTs = 0x0;
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;
335 delete[] this->fCBLUTs[iCB];
336 this->fCBLUTs[iCB] = 0x0;
339 delete[] this->fCBLUTs;
344 //______________________________________________________________________________
345 Int_t AliTRDptrgParam::CheckVariables() const
347 // checks whether variables are deleted early enough
349 // check coincidence matrices
350 if (this->fTLMUcmatrices != 0x0) {
351 for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
352 if (this->fTLMUcmatrices[iMatrix] == 0x0) {
361 // check multiplicity slices
362 if (this->fTLMUmultiplicity != 0x0) {
363 for (UInt_t iSlice = 0; iSlice < 9; iSlice++) {
364 if (this->fTLMUmultiplicity[iSlice] == 0x0) {
374 if (this->fTLMUoutput != 0x0) {
375 for (UInt_t iBit = 0; iBit < 8; iBit++) {
376 if (this->fTLMUoutput[iBit] == 0x0) {
385 // delete T0 FEB thresholds
386 if (this->fFEBT0Thresholds != 0x0) {
387 if (this->fFEBT0Thresholds[0] == 0x0) {
390 if (this->fFEBT0Thresholds[1] == 0x0) {
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) {
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) {
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) {
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) {
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) {
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) {
529 //______________________________________________________________________________
530 AliTRDptrgParam* AliTRDptrgParam::Instance()
532 // get (or create) the single instance
535 fgInstance = new AliTRDptrgParam();
540 //______________________________________________________________________________
541 void AliTRDptrgParam::Terminate()
543 // destruct the instance
545 if (fgInstance != 0) {
551 //______________________________________________________________________________
552 void AliTRDptrgParam::LoadStandardConfiguration() {
553 // loads a standard configuration parameters for testing
556 for (UInt_t iSM = 0; iSM < 18; iSM++) {
557 this->fTLMUInputMask[iSM] = 0xFFFFFFFF; // enable all input bits
560 // TLMU Input Stretch
561 this->fTLMUInputStretch = 0; // not used in simulation
563 // TLMU Coincidence Matrices
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++) {
572 this->fTLMUcmatrices[iMatrix][iSlice] = 0x201 << iSlice;
574 AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
575 this->fTLMUcmatrices[iMatrix][iSlice]));
577 // because of symmetrie the other slices are not necessary
579 else if (iMatrix == 1) {
580 // Back-To-Back +/- 1
582 this->fTLMUcmatrices[iMatrix][iSlice] = 0x381 << iSlice;
584 else if (iSlice == 8) {
585 this->fTLMUcmatrices[iMatrix][iSlice] = 0x30101;
587 else if (iSlice == 9) {
588 this->fTLMUcmatrices[iMatrix][iSlice] = 0x20203;
591 this->fTLMUcmatrices[iMatrix][iSlice] = 0x407 << (iSlice - 10);
593 AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
594 this->fTLMUcmatrices[iMatrix][iSlice]));
596 else if (iMatrix == 2) {
599 this->fTLMUcmatrices[iMatrix][iSlice] = 0xF81 << iSlice;
601 else if (iSlice == 7) {
602 this->fTLMUcmatrices[iMatrix][iSlice] = 0x3C081;
604 else if (iSlice == 8) {
605 this->fTLMUcmatrices[iMatrix][iSlice] = 0x38103;
607 else if (iSlice == 9) {
608 this->fTLMUcmatrices[iMatrix][iSlice] = 0x30207;
610 else if (iSlice == 10) {
611 this->fTLMUcmatrices[iMatrix][iSlice] = 0x2040F;
614 this->fTLMUcmatrices[iMatrix][iSlice] = 0x81F << (iSlice - 11);
616 AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
617 this->fTLMUcmatrices[iMatrix][iSlice]));
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;
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;
653 for (UInt_t iChannel = 0; iChannel < 12; iChannel++) {
654 this->fFEBT0Thresholds[0][iChannel] = 10;
655 this->fFEBT0Thresholds[1][iChannel] = 10;
659 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
660 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
662 this->fFEBT0Multiplicities[iPosition][iLUT][0] = 0;
665 this->fFEBT0Multiplicities[iPosition][iLUT][0] = 5;
667 this->fFEBT0Multiplicities[iPosition][iLUT][1] = 0xFFF;
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;
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++) {
685 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 0;
688 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 3;
690 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][1] = 0xFF;
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";
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";
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";
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;
719 //______________________________________________________________________________
720 Bool_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
727 inputFile.open(filename.Data());
734 if (inputFile.is_open())
736 AliDebug(5, "---- Reading configuration file ----");
737 while (getline(inputFile, str)) {
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)) {
747 else if (line.Index("FEB") == 0) {
748 this->PrepareLine(line, identifier, value);
749 if (!this->ParseFEB(identifier, value)) {
753 else if (line.Index("CBB") == 0) {
754 this->PrepareLine(line, identifier, value);
755 if (!this->ParseCBB(identifier, value)) {
759 else if ((line.Index("CBA") == 0) ||
760 (line.Index("CBC") == 0)) {
761 this->PrepareLine(line, identifier, value);
762 if (!this->ParseCBAC(identifier, value)) {
767 AliDebug(5, "---- Finished reading configuration file ----");
773 AliDebug(5, "Error opening configuration file");
780 //______________________________________________________________________________
781 Int_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
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
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
805 if (this->GetMultiplicity(iEntry &
806 this->fFEBT0Multiplicities[iPosition][iLUT][1]) >
807 this->fFEBT0Multiplicities[iPosition][iLUT][0]) {
808 this->fFEBT0LUTs[iPosition][iLUT][iEntry] = 1;
811 // initialize LUT (not done before !)
812 this->fFEBT0LUTs[iPosition][iLUT][iEntry] = 0;
814 AliDebug(10, Form("FEBT0LUTs[%d][%d][0x%x]=%d", iPosition, iLUT, iEntry,
815 this->fFEBT0LUTs[iPosition][iLUT][iEntry]));
817 AliDebug(5, Form("Generated FEBT0LUTs[%d][%d]", iPosition, iLUT));
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,
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
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;
844 // initialize LUT (not done before !)
845 this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry] = 0;
847 AliDebug(10, Form("FEBV0LUTs[%d][%d][%d][0x%x]=%d", iPosition, iFEB,
849 this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry]));
851 AliDebug(5, Form("Generated FEBV0LUTs[%d][%d][%d]", iPosition, iFEB,
857 // ControlBoxes (CB-x)
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;
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][0x%x]=%d", iEntry,
870 this->fCBLUTs[1][0][iEntry]));
872 this->fCBLUTs[1][1] = this->GenerateLUTbasedOnEq(this->fCBALUTequY, 10, 1);
873 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
874 AliDebug(10, Form("fCBLUTs[@A][1][0x%x]=%d", iEntry,
875 this->fCBLUTs[1][1][iEntry]));
878 // CB-C (CB = 2 / kC)
879 this->fCBLUTs[2][0] = this->GenerateLUTbasedOnEq(this->fCBCLUTequX, 10, 1);
880 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
881 AliDebug(6, Form("fCBLUTs[@C][0][0x%x]=%d", iEntry,
882 this->fCBLUTs[2][0][iEntry]));
884 this->fCBLUTs[2][1] = this->GenerateLUTbasedOnEq(this->fCBCLUTequY, 10, 1);
885 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
886 AliDebug(10, Form("fCBLUTs[@C][1][0x%x]=%d", iEntry,
887 this->fCBLUTs[2][0][iEntry]));
890 // CB-B (CB = 0 / kB)
891 this->fCBLUTs[0][0] = this->GenerateLUTbasedOnEq(this->fCBBLUTequX, 12, 1);
892 for (Int_t iEntry = 0; iEntry < 4096; iEntry++) {
893 AliDebug(10, Form("fCBLUTs[@B][0][0x%x]=%d", iEntry,
894 this->fCBLUTs[0][0][iEntry]));
896 this->fCBLUTs[0][1] = this->GenerateLUTbasedOnEq(this->fCBBLUTequY, 12, 1);
898 for (Int_t iEntry = 0; iEntry < 4096; iEntry++) {
899 AliDebug(10, Form("fCBLUTs[@B][1][0x%x]=%d", iEntry,
900 this->fCBLUTs[0][1][iEntry]));
903 AliDebug(5, "LUTs were generated!");
907 //______________________________________________________________________________
908 UInt_t AliTRDptrgParam::GetMultiplicity(UInt_t BitVector) const {
909 // returns the multiplicity of a given bit vector
913 for (UInt_t iBit = 0; iBit < 32; iBit++) {
914 if (BitVector & temp) {
923 //______________________________________________________________________________
924 UInt_t AliTRDptrgParam::GetMultiplicity(Int_t BitVector) const {
925 // returns the multiplicity of a given bit vector
929 for (UInt_t iBit = 0; iBit < 32; iBit++) {
930 if (BitVector & temp) {
939 //______________________________________________________________________________
941 // Configuration file parsing (helper functions)
942 //______________________________________________________________________________
944 //______________________________________________________________________________
945 void AliTRDptrgParam::PrepareLine(TString line, TString& identifier,
947 // Prepares a line for parsing
948 // divide identifier and value
950 // clear identifier and value
955 while ((line[iLetter] != ' ') && (line[iLetter] != '\t') &&
956 (line[iLetter] != '#') && (iLetter < line.Length())) {
958 identifier += line[iLetter];
961 while (((line[iLetter] == ' ') || (line[iLetter] == '\t')) &&
962 (iLetter < line.Length()) && (line[iLetter] != '#')) {
963 // omit whitespaces and tabs in between
966 while(iLetter < line.Length()) {
967 // read value or equation and remove white spaces and tabs
968 //if ((line[iLetter] != ' ') && (line[iLetter] != '\t') &&
969 // (line[iLetter] != '#')) {
970 if (line[iLetter] != '#') {
971 value += line[iLetter];
977 //______________________________________________________________________________
978 TString AliTRDptrgParam::CleanTString(TString string) {
979 // Removes white spaces and tabs
983 for (Int_t iLetter = 0; iLetter < string.Length(); iLetter++) {
984 if ((string[iLetter] != ' ') && (string[iLetter] != '\t')) {
985 result += string[iLetter];
988 AliDebug(5, Form("Cleaned string: %s", result.Data()));
992 //______________________________________________________________________________
993 void AliTRDptrgParam::SplitUpValues(TString value, TObjArray& arr) {
994 // splits up multiple values into a TObjArray
999 for (Int_t iLetter = 0; iLetter < value.Length(); iLetter++) {
1000 if ((value[iLetter] != ' ') && (value[iLetter] != '\t')) {
1001 // add another letter
1002 temp += value[iLetter];
1005 // seperator found: white space or tabs
1006 if (temp.Length()) {
1007 TObjString* t = new TObjString(temp.Data());
1014 if (temp.Length() != 0) {
1015 TObjString* t = new TObjString(temp.Data());
1020 //______________________________________________________________________________
1021 UInt_t AliTRDptrgParam::BinaryTStringToInt(TString number) const {
1022 // converts a binary TString to an integer
1024 UInt_t result = 0x0;
1025 for (Int_t i = number.Length() - 1; i >= 0; i--) {
1026 if (number[i] == '1') {
1030 else if (number[i] == '0') {
1037 //______________________________________________________________________________
1038 Bool_t AliTRDptrgParam::ParseMultiplicityCondition(TString condition,
1041 // converts a string formed like "M(1111_1111)>4" to a input mask and a
1042 // multiplicity threshold
1044 // check whether condition is starting with "M(
1045 if ((condition[0] != 'M') || ( condition[1] != '(')) {
1049 TString maskStr = "";
1052 // extract input mask
1053 while (condition[iLetter] != ')') {
1054 maskStr += condition[iLetter++];
1056 (*mask) = BinaryTStringToInt(maskStr);
1058 AliDebug(5, Form("Invalid input mask: %s,[%s]", maskStr.Data(),
1063 // ensure that ')' is followed by a '>'
1064 if (condition[++iLetter] != '>') {
1065 AliDebug(5, Form("multiplicity condition is incorrectly formed: %s",
1069 iLetter++; // move on to the first digit
1071 TString thresholdStr = "";
1072 // gain threshold string
1073 while (((condition[iLetter] != ' ') || (condition[iLetter] != '\t')) &&
1074 (iLetter < condition.Length())) {
1075 thresholdStr += condition[iLetter++];
1077 (*threshold) = thresholdStr.Atoi(); // convert string to integer
1078 AliDebug(5, Form("mask: 0x%x, multiplicity threshold: %d", (*mask),
1083 //______________________________________________________________________________
1084 Bool_t AliTRDptrgParam::ParseFEB(TString identifier, TString value) {
1085 // Parse FEB configuration
1087 //------------------------------------------
1088 if (identifier.Index("FEB/T0/A/THR") == 0) {
1089 // FEB T0 thresholds at A side
1093 SplitUpValues(value, arr);
1095 if (arr.GetEntries() != 12) {
1096 AliError("Wrong FEB T0 Threshold count, it must be 12 channels!");
1099 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1100 this->fFEBT0Thresholds[0][iValue] =
1101 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1102 AliDebug(5, Form("FEB/T0/A/THR[%d]=%d", iValue,
1103 this->fFEBT0Thresholds[0][iValue]));
1108 //-----------------------------------------------
1109 else if (identifier.Index("FEB/T0/C/THR") == 0) {
1110 // FEB T0 thresholds at c side
1114 SplitUpValues(value, arr);
1116 if (arr.GetEntries() != 12) {
1117 AliError("Wrong FEB T0 Threshold count, it must be 12 channels!");
1120 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1121 this->fFEBT0Thresholds[1][iValue] =
1122 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1123 AliDebug(5, Form("FEB/T0/C/THR[%d]=%d", iValue,
1124 this->fFEBT0Thresholds[1][iValue]));
1129 //--------------------------------------------------
1130 else if ((identifier.Index("FEB/V0/A0/THR") == 0) ||
1131 (identifier.Index("FEB/V0/A1/THR") == 0) ||
1132 (identifier.Index("FEB/V0/A2/THR") == 0) ||
1133 (identifier.Index("FEB/V0/A3/THR") == 0)) {
1134 // FEB V0 thresholds at a side (cards 0,1,2,3)
1136 TString cardIDstr = identifier(8, 1);
1137 Int_t cardID = cardIDstr.Atoi();
1141 SplitUpValues(value, arr);
1143 if (arr.GetEntries() != 8) {
1144 AliError("Wrong FEB V0 Threshold count, it must be 8 channels!");
1147 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1148 this->fFEBV0Thresholds[0][cardID][iValue] =
1149 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1150 AliDebug(5, Form("FEB/V0/A%d/THR[%d]=%d", cardID, iValue,
1151 this->fFEBV0Thresholds[0][cardID][iValue]));
1155 //--------------------------------------------------
1156 else if ((identifier.Index("FEB/V0/C0/THR") == 0) ||
1157 (identifier.Index("FEB/V0/C1/THR") == 0) ||
1158 (identifier.Index("FEB/V0/C2/THR") == 0) ||
1159 (identifier.Index("FEB/V0/C3/THR") == 0)) {
1160 // FEB V0 thresholds at c side (cards 0,1,2,3)
1162 TString cardIDstr = identifier(8, 1);
1163 Int_t cardID = cardIDstr.Atoi();
1167 SplitUpValues(value, arr);
1169 if (arr.GetEntries() != 8) {
1170 AliError("Wrong FEB V0 Threshold count, it must be 8 channels!");
1173 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1174 this->fFEBV0Thresholds[1][cardID][iValue] =
1175 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1176 AliDebug(5, Form("FEB/V0/C%d/THR[%d]=%d", cardID, iValue,
1177 this->fFEBV0Thresholds[1][cardID][iValue]));
1181 //-----------------------------------------------
1182 else if (identifier.Index("FEB/T0/A/LUT") == 0) {
1183 // FEB T0 look up tables at A side
1185 TString lutIDstr = identifier(13, 1);
1186 Int_t lutID = lutIDstr.Atoi();
1190 ParseMultiplicityCondition(value, &val, &mask);
1191 this->fFEBT0Multiplicities[0][lutID][0] = val;
1192 this->fFEBT0Multiplicities[0][lutID][1] = mask;
1193 AliDebug(5, Form("FEBT0Multiplicities[0/A][%d][val] = %d", lutID, val));
1194 AliDebug(5, Form("FEBT0Multiplicities[0/A][%d][mask] = %d", lutID, mask));
1199 //-----------------------------------------------
1200 else if (identifier.Index("FEB/T0/C/LUT") == 0) {
1201 // FEB T0 look up tables at C side
1203 TString lutIDstr = identifier(13, 1);
1204 Int_t lutID = lutIDstr.Atoi();
1208 ParseMultiplicityCondition(value, &val, &mask);
1209 this->fFEBT0Multiplicities[1][lutID][0] = val;
1210 this->fFEBT0Multiplicities[1][lutID][1] = mask;
1211 AliDebug(5, Form("FEBT0Multiplicities[1/C][%d][val] = %d", lutID, val));
1212 AliDebug(5, Form("FEBT0Multiplicities[1/C][%d][mask] = %d", lutID, mask));
1217 //--------------------------------------------------
1218 else if ((identifier.Index("FEB/V0/A0/LUT") == 0) ||
1219 (identifier.Index("FEB/V0/A1/LUT") == 0) ||
1220 (identifier.Index("FEB/V0/A2/LUT") == 0) ||
1221 (identifier.Index("FEB/V0/A3/LUT") == 0)) {
1222 // FEB V0 look up tables at A side
1224 TString cardIDstr = identifier(8, 1);
1225 Int_t cardID = cardIDstr.Atoi();
1227 TString lutIDstr = identifier(14, 1);
1228 Int_t lutID = lutIDstr.Atoi();
1232 ParseMultiplicityCondition(value, &val, &mask);
1233 this->fFEBV0Multiplicities[0][cardID][lutID][0] = val;
1234 this->fFEBV0Multiplicities[0][cardID][lutID][1] = mask;
1235 AliDebug(5, Form("FEBV0Multiplicities[0/A][%d][%d][val] = %d", cardID,
1237 AliDebug(5, Form("FEBV0Multiplicities[0/A][%d][%d][mask] = %d", cardID,
1243 //--------------------------------------------------
1244 else if ((identifier.Index("FEB/V0/C0/LUT") == 0) ||
1245 (identifier.Index("FEB/V0/C1/LUT") == 0) ||
1246 (identifier.Index("FEB/V0/C2/LUT") == 0) ||
1247 (identifier.Index("FEB/V0/C3/LUT") == 0)) {
1248 // FEB V0 look up tables at C side
1250 TString cardIDstr = identifier(8, 1);
1251 Int_t cardID = cardIDstr.Atoi();
1253 TString lutIDstr = identifier(14, 1);
1254 Int_t lutID = lutIDstr.Atoi();
1258 ParseMultiplicityCondition(value, &val, &mask);
1259 this->fFEBV0Multiplicities[1][cardID][lutID][0] = val;
1260 this->fFEBV0Multiplicities[1][cardID][lutID][1] = mask;
1261 AliDebug(5, Form("FEBV0Multiplicities[1/C][%d][%d][val] = %d", cardID,
1263 AliDebug(5, Form("FEBV0Multiplicities[1/C][%d][%d][mask] = %d", cardID,
1271 //______________________________________________________________________________
1272 Bool_t AliTRDptrgParam::ParseCBAC(TString identifier, TString value) {
1273 // Parse CB-A and CB-C configuration
1275 if (identifier.Index("CBA/LUT/") == 0) {
1276 // parse CB-A's logical equations
1278 TString eqIDstr = identifier(8, 1);
1279 Int_t eqID = eqIDstr.Atoi();
1282 this->fCBALUTequX = this->CleanTString(value);
1283 AliDebug(5, Form("fCBALUTequX=%s", this->fCBALUTequX.Data()));
1285 else if(eqID == 1) {
1286 this->fCBALUTequY= this->CleanTString(value);
1287 AliDebug(5, Form("fCBALUTequY=%s", this->fCBALUTequY.Data()));
1292 else if (identifier.Index("CBC/LUT/") == 0) {
1293 // parse CB-C's logical equations
1295 TString eqIDstr = identifier(8, 1);
1296 Int_t eqID = eqIDstr.Atoi();
1299 this->fCBCLUTequX = this->CleanTString(value);
1300 AliDebug(5, Form("fCBCLUTequX=%s", this->fCBCLUTequX.Data()));
1302 else if(eqID == 1) {
1303 this->fCBCLUTequY= this->CleanTString(value);
1304 AliDebug(5, Form("fCBCLUTequY=%s", this->fCBCLUTequY.Data()));
1311 //______________________________________________________________________________
1312 Bool_t AliTRDptrgParam::ParseCBB(TString identifier, TString value) {
1313 // Parse CBB configuration
1315 if (identifier.Index("CBB/LUT/") == 0) {
1316 // parse CB-B's logical equations
1318 TString eqIDstr = identifier(8, 1);
1319 Int_t eqID = eqIDstr.Atoi();
1322 this->fCBBLUTequX = this->CleanTString(value);
1323 AliDebug(5, Form("fCBBLUTequX=%s", this->fCBBLUTequX.Data()));
1325 else if(eqID == 1) {
1326 this->fCBBLUTequY= this->CleanTString(value);
1327 AliDebug(5, Form("fCBBLUTequY=%s", this->fCBBLUTequY.Data()));
1333 else if (identifier.Index("CBB/PT/MASK/CB-A_0") == 0) { // CB-A_0
1334 if (value.Index("YES") == 0) {
1335 this->fPTmasks.fCBA[0] = kTRUE;
1338 this->fPTmasks.fCBA[0] = kFALSE;
1340 AliDebug(5, Form("CBB/PT/MASK/CB-A_0=%d", this->fPTmasks.fCBA[0]));
1343 else if (identifier.Index("CBB/PT/MASK/CB-A_1") == 0) { // CB-A_1
1344 if (value.Index("YES") == 0) {
1345 this->fPTmasks.fCBA[1] = kTRUE;
1348 this->fPTmasks.fCBA[1] = kFALSE;
1350 AliDebug(5, Form("CBB/PT/MASK/CB-A_1=%d", this->fPTmasks.fCBA[1]));
1353 else if (identifier.Index("CBB/PT/MASK/CB-C_0") == 0) { // CB-C_0
1354 if (value.Index("YES") == 0) {
1355 this->fPTmasks.fCBC[0] = kTRUE;
1358 this->fPTmasks.fCBC[0] = kFALSE;
1360 AliDebug(5, Form("CBB/PT/MASK/CB-C_0=%d",this->fPTmasks.fCBC[0]));
1363 else if (identifier.Index("CBB/PT/MASK/CB-C_1") == 0) { // CB-C_1
1364 if (value.Index("YES") == 0) {
1365 this->fPTmasks.fCBC[1] = kTRUE;
1368 this->fPTmasks.fCBC[1] = kFALSE;
1370 AliDebug(5, Form("CBB/PT/MASK/CB-C_1=%d", this->fPTmasks.fCBC[1]));
1373 else if (identifier.Index("CBB/PT/MASK/CB-B_0") == 0) { // CB-B_0
1374 if (value.Index("YES") == 0) {
1375 this->fPTmasks.fLUTs[0] = kTRUE;
1378 this->fPTmasks.fLUTs[0] = kFALSE;
1380 AliDebug(5, Form("CBB/PT/MASK/CB-B_0=%d",this->fPTmasks.fLUTs[0]));
1383 else if (identifier.Index("CBB/PT/MASK/CB-B_1") == 0) { // CB-B_1
1384 if (value.Index("YES") == 0) {
1385 this->fPTmasks.fLUTs[1] = kTRUE;
1388 this->fPTmasks.fLUTs[1] = kFALSE;
1390 AliDebug(5, Form("CBB/PT/MASK/CB-B_1/=%d", this->fPTmasks.fLUTs[1]));
1393 else if (identifier.Index("BB/PT/MASK/TLMU_") == 0) {
1394 TString indexStr = identifier(16, 1);
1395 Int_t index = indexStr.Atoi();
1396 if (value.Index("YES") == 0) {
1397 this->fPTmasks.fTLMU[index] = kTRUE;
1400 this->fPTmasks.fTLMU[index] = kFALSE;
1402 AliDebug(5, Form("CBB/PT/MASK/TLMU_%d=%d", index,
1403 this->fPTmasks.fTLMU[index]));
1409 //______________________________________________________________________________
1410 Bool_t AliTRDptrgParam::ParseTLMU(TString identifier, TString value) {
1411 // Parse TLMU configuration
1413 if (identifier.Index("TLMU/IMASK/SEC") == 0) {
1415 TString indexStr = identifier(14,2);
1416 Int_t index = indexStr.Atoi();
1417 if ((index < 0) || (index > 17)) {
1418 AliDebug(5, "Wrong section index in TLMU input mask");
1421 this->fTLMUInputMask[index] = BinaryTStringToInt(value);
1422 AliDebug(5, Form("%d %x\n", index, this->fTLMUInputMask[index]));
1426 //-----------------------------------------------
1427 else if (identifier.Index("TLMU/CMATRIX") == 0) {
1428 // TLMU coincidence matrices
1431 TString matrixIndexStr = identifier(12,1);
1432 Int_t matrixIndex = matrixIndexStr.Atoi();
1434 TString indexStr = identifier(17,2);
1435 Int_t index = indexStr.Atoi();
1436 this->fTLMUcmatrices[matrixIndex][index] = BinaryTStringToInt(value);
1437 AliDebug(5, Form("%d 0x%x\n", matrixIndex,
1438 this->fTLMUcmatrices[matrixIndex][index]));
1442 //---------------------------------------------
1443 else if (identifier.Index("TLMU/MCNTR") == 0) {
1444 // TLMU multiplicity counter setup
1446 TString indexStr = identifier(10,1);
1447 Int_t index = indexStr.Atoi();
1450 SplitUpValues(value, arr);
1452 TString t0 = (dynamic_cast<TObjString*>(arr[0]))->GetString();
1453 TString t1 = (dynamic_cast<TObjString*>(arr[1]))->GetString();
1455 this->fTLMUmultiplicity[index][0] = t0.Atoi();
1456 this->fTLMUmultiplicity[index][1] = t1.Atoi();
1458 AliDebug(5, Form("%d: %d %d", index, this->fTLMUmultiplicity[index][0],
1459 this->fTLMUmultiplicity[index][1]));
1464 //----------------------------------------------
1465 else if (identifier.Index("TLMU/OUTMUX") == 0) {
1466 // TLMU output signal assignment
1468 SplitUpValues(value, arr);
1470 if (arr.GetEntries() > 8) {
1471 AliError("Too many TLMU output signals assigned");
1475 for (Int_t iEntry = 0; iEntry < arr.GetEntries(); iEntry++) {
1476 TString t = (dynamic_cast<TObjString*>(arr[iEntry]))->GetString();
1478 TString indexStr = t(2,1);
1479 if (t.Index("CM") == 0) { // coincidence matrix
1480 this->fTLMUoutput[iEntry][0] = indexStr.Atoi();
1482 else if (t.Index("MC") == 0) { // multiplicity
1483 this->fTLMUoutput[iEntry][1] = indexStr.Atoi();
1485 AliDebug(5, Form("TLMU output: cm = %d, mc = %d",
1486 this->fTLMUoutput[iEntry][0],
1487 this->fTLMUoutput[iEntry][1]));
1494 //______________________________________________________________________________
1496 // Logical Equation to LUT processing (helper functions)
1497 //______________________________________________________________________________
1499 //______________________________________________________________________________
1500 Int_t AliTRDptrgParam::LookUp(TString* const identifier) const {
1501 // Transforms identifier into look up table address bit
1503 // this function has to be extended/changed when different identifiers for
1504 // other equations and destination LUTs should be used
1506 if (identifier->CompareTo("T0_0", TString::kIgnoreCase) == 0)
1508 else if (identifier->CompareTo("T0_1", TString::kIgnoreCase) == 0)
1510 else if (identifier->CompareTo("V0-0_0", TString::kIgnoreCase) == 0)
1512 else if (identifier->CompareTo("V0-0_1", TString::kIgnoreCase) == 0)
1514 else if (identifier->CompareTo("V0-1_0", TString::kIgnoreCase) == 0)
1516 else if (identifier->CompareTo("V0-1_1", TString::kIgnoreCase) == 0)
1518 else if (identifier->CompareTo("V0-2_0", TString::kIgnoreCase) == 0)
1520 else if (identifier->CompareTo("V0-2_1", TString::kIgnoreCase) == 0)
1522 else if (identifier->CompareTo("V0-3_0", TString::kIgnoreCase) == 0)
1524 else if (identifier->CompareTo("V0-3_1", TString::kIgnoreCase) == 0)
1526 else if (identifier->CompareTo("CB-A_0", TString::kIgnoreCase) == 0)
1528 else if (identifier->CompareTo("CB-A_1", TString::kIgnoreCase) == 0)
1530 else if (identifier->CompareTo("CB-C_0", TString::kIgnoreCase) == 0)
1532 else if (identifier->CompareTo("CB-C_1", TString::kIgnoreCase) == 0)
1534 else if (identifier->CompareTo("TLMU_0", TString::kIgnoreCase) == 0)
1536 else if (identifier->CompareTo("TLMU_1", TString::kIgnoreCase) == 0)
1538 else if (identifier->CompareTo("TLMU_2", TString::kIgnoreCase) == 0)
1540 else if (identifier->CompareTo("TLMU_3", TString::kIgnoreCase) == 0)
1542 else if (identifier->CompareTo("TLMU_4", TString::kIgnoreCase) == 0)
1544 else if (identifier->CompareTo("TLMU_5", TString::kIgnoreCase) == 0)
1546 else if (identifier->CompareTo("TLMU_6", TString::kIgnoreCase) == 0)
1548 else if (identifier->CompareTo("TLMU_7", TString::kIgnoreCase) == 0)
1550 else return 0x0; // Error
1553 //______________________________________________________________________________
1554 void AliTRDptrgParam::MergeResults(TArrayI*& partResult1, TArrayI*& partResult2,
1556 TArrayI*& signalsInvolved1,
1557 TArrayI*& signalsInvolved2,
1558 TArrayI*& signalsInvolved,
1560 // merges result and signal involved arrays
1561 // uses logical OR (or=kTRUE) and AND (or==kFALSE) as merging function
1563 // check whether input data is valid
1564 if ((partResult1 == 0x0) || (partResult2 == 0x0) ||
1565 (signalsInvolved1 == 0x0) || (signalsInvolved2 == 0x0)) {
1566 AliError("fatal logical equation processing error!");
1569 // allocate results and signalsInvolved
1570 results = new TArrayI(0);
1571 signalsInvolved = new TArrayI(0);
1573 // merge arrays (necessary for OR and AND)
1574 for (Int_t i = 0; i < partResult1->GetSize(); i++) {
1575 for (Int_t j = 0; j < partResult2->GetSize(); j++) {
1576 results->Set(results->GetSize() + 1); // increment size
1577 (*results)[results->GetSize() - 1] = // add combination
1578 (*partResult1)[i] | (*partResult2)[j];
1580 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1581 (*signalsInvolved)[signalsInvolved->GetSize() - 1] =
1582 (*signalsInvolved1)[i] | (*signalsInvolved2)[j];
1586 if (useOR) { // only necessary for OR
1588 for (Int_t i = 0; i < partResult1->GetSize(); i++) {
1589 results->Set(results->GetSize() + 1);
1590 (*results)[results->GetSize() - 1] = (*partResult1)[i];
1592 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1593 (*signalsInvolved)[signalsInvolved->GetSize()-1] = (*signalsInvolved1)[i];
1596 for (Int_t i = 0; i < partResult2->GetSize(); i++) {
1597 results->Set(results->GetSize() + 1);
1598 (*results)[results->GetSize() - 1] = (*partResult2)[i];
1600 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1601 (*signalsInvolved)[signalsInvolved->GetSize()-1] = (*signalsInvolved2)[i];
1606 AliDebug(5, "merging results: ");
1607 for (Int_t i = 0; i < results->GetSize(); i++) {
1608 AliDebug(5, Form("0x%x 0x%x", (*results)[i], (*signalsInvolved)[i]));
1618 //______________________________________________________________________________
1619 void AliTRDptrgParam::ConvertLogicalEqToBitVectors(TString eq,
1621 TArrayI*& signalsInvolved) {
1622 // converts a logical equation to a LUT
1624 // input string must not contain white spaces or tabs
1625 // only identifiers, ||, &&, (, ) and ! are allowed
1627 // neglected signals are assumed to be zero in this function
1628 // this problem is solved by "void CheckSignalsInvolved(...)"
1630 AliDebug(5, Form("eq: %s", eq.Data()));
1632 // temporary variables used before/while merging
1633 TArrayI* partResult1 = 0x0;
1634 TArrayI* partResult2 = 0x0;
1635 TArrayI* partResult3 = 0x0;
1636 TArrayI* partResult4 = 0x0;
1637 TArrayI* signalsInvolved1 = 0x0;
1638 TArrayI* signalsInvolved2 = 0x0;
1639 TArrayI* signalsInvolved3 = 0x0;
1640 TArrayI* signalsInvolved4 = 0x0;
1642 Int_t iChar = 0; // counter variable
1644 // variables needed for correct operator order (&& before ||!)
1645 Int_t foundORbefore = -1; // found an || in that string (-1 = not found)
1646 Int_t foundAND = -1; // found an &&
1647 Int_t foundORafter = -1; // found a second OR after &&
1649 // variables needed for correct bracket processing
1650 Int_t enteredBrackets = 0; // indicates in which bracket layer the parser is
1651 Int_t bracketLevelAtZero = -1; // when enteredBrackets = 0 was reached first
1652 // after it ascended
1654 while ((iChar < eq.Length())) { //--------------------------------------------
1655 // walk through string
1657 // operators ---------------------------------------------------------------
1658 if ((enteredBrackets == 0 ) && (eq[iChar] != '(') && (eq[iChar] != ')')) {
1660 if (eq[iChar] == '|') {
1661 if (eq[iChar + 1] == '|') { // ||
1662 iChar++; // jump to the next charakter
1663 if (foundAND == -1) {
1664 foundORbefore = iChar;
1666 else if ((foundORafter == -1) && (foundAND != -1)) {
1667 foundORafter = iChar;
1670 else { // bit-wise and not supported
1671 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1672 AliError("bit-wise AND (&) not supported for now");
1677 else if (eq[iChar] == '&') {
1678 if (eq[iChar] == '&') { // ||
1679 iChar++; // jump to the next charakter
1680 if (foundAND == -1) {
1684 else { // bit-wise or not supported
1685 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1686 AliError("bit-wise OR (|) not supported for now");
1691 // brackets ----------------------------------------------------------------
1693 if (eq[iChar] == '(') {
1697 else if (eq[iChar] == ')') {
1699 if (enteredBrackets < 0) {
1700 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1701 AliError("Too many )s");
1703 if ((enteredBrackets == 0) && (bracketLevelAtZero == -1) &&
1704 (foundAND == -1) && (foundORbefore == -1)) {
1705 // needed to detected equations encapsulated in brackets: (...)
1706 bracketLevelAtZero = iChar;
1709 iChar++; // go on to the next letter/char
1710 } //--------------------------------------------------------------------------
1712 if (bracketLevelAtZero == (eq.Length() - 1)) { // strip ( ) and process again
1713 ConvertLogicalEqToBitVectors(eq(1, eq.Length() -2), results,
1717 else if (foundAND == -1) { // no AND
1718 if (foundORbefore != -1) { // only OR / || found and no AND
1719 ConvertLogicalEqToBitVectors(eq(0, foundORbefore-1), partResult1,
1721 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1722 eq.Length()-foundORbefore-1),
1723 partResult2, signalsInvolved2);
1725 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1726 signalsInvolved2, signalsInvolved, kTRUE);
1729 else { // only identifier remained!
1730 results = new TArrayI(1);
1731 signalsInvolved = new TArrayI(1);
1732 if (eq[0] != '!') { // identifier without negation
1733 (*results)[0] = LookUp(&eq);
1734 (*signalsInvolved)[0] = (*results)[0];
1736 else { // identifier with negation
1738 TString eqNegated = eq(1, eq.Length()-1);
1739 (*signalsInvolved)[0] = LookUp(&eqNegated);
1744 // found single or multiple AND / &&
1745 else if ((foundORafter != -1) && (foundORbefore != -1)) {
1746 // found: ...||...&&...||...
1747 ConvertLogicalEqToBitVectors(eq(0, foundORbefore-1), partResult1,
1749 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1750 foundORafter-foundORbefore-2),
1751 partResult2, signalsInvolved2);
1752 ConvertLogicalEqToBitVectors(eq(foundORafter+1, eq.Length()-foundORafter-1),
1753 partResult3, signalsInvolved3);
1755 // merge: 4 = 1 || 2
1756 MergeResults(partResult1, partResult2, partResult4, signalsInvolved1,
1757 signalsInvolved2, signalsInvolved4, kTRUE);
1758 // merge results = 3 || 4
1759 MergeResults(partResult3, partResult4, results, signalsInvolved3,
1760 signalsInvolved4, signalsInvolved, kTRUE);
1763 else if (foundORbefore != -1) {
1764 // found ...||...&&...
1765 ConvertLogicalEqToBitVectors(eq(0, foundORbefore - 1), partResult1,
1767 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1768 eq.Length()-foundORbefore-1),
1769 partResult2, signalsInvolved2);
1771 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1772 signalsInvolved2, signalsInvolved, kTRUE);
1775 else if (foundORafter != -1) {
1776 // found ...&&...||...
1777 ConvertLogicalEqToBitVectors(eq(0, foundORafter - 1), partResult1,
1779 ConvertLogicalEqToBitVectors(eq(foundORafter+1,
1780 eq.Length()-foundORafter-1),
1781 partResult2, signalsInvolved2);
1783 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1784 signalsInvolved2, signalsInvolved, kTRUE);
1787 else /* if (foundAND != -1)*/ { // found ...&&...
1788 ConvertLogicalEqToBitVectors(eq(0, foundAND-1), partResult1,
1790 ConvertLogicalEqToBitVectors(eq(foundAND+1, eq.Length()-foundAND-1),
1791 partResult2, signalsInvolved2);
1793 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1794 signalsInvolved2, signalsInvolved, kFALSE);
1798 AliError("Logical equation parser error!");
1802 //______________________________________________________________________________
1803 void AliTRDptrgParam::CheckSignalsInvolved(TArrayI*& results,
1804 TArrayI*& signalsInvolved,
1806 // checks whether all input signals are taken into account
1808 // this function is needed to be able to write equations which contain not all
1809 // possible signals and which are not mentioned in the equation do not effect
1811 // X=B&&C=(A||!A)&&B&&C
1813 // this routine is quite inefficient but working O((2^inputWidth)^3)
1818 for (Int_t iSignal = 0; iSignal < inputWidth; iSignal++) {
1820 temp <<= 1; // move temp to the next bit
1823 for (Int_t iResult = 0; iResult < results->GetSize(); iResult++) {
1824 // tricky: size of results increases while loop is iterating
1825 // that is needed to generate all valid input signal combinations
1826 if (mask != (*signalsInvolved)[iResult]) {
1827 // not all input signals are taken into account
1828 Int_t inputSignal = 0x1;
1829 for (Int_t iSignal = 0; iSignal < inputWidth; iSignal++) {
1830 if (!(inputSignal & (*signalsInvolved)[iResult])) {
1831 Int_t newInvolvedSignalCombination =
1832 (*signalsInvolved)[iResult] | inputSignal;
1833 Int_t newResult = inputSignal | (*results)[iResult];
1834 Bool_t signalCombinationAlreadyEnlisted = kFALSE;
1835 for (Int_t iEntry = 0; iEntry < signalsInvolved->GetSize(); iEntry++){
1836 // this loop is needed to reduce the amount of equal entries in
1838 // maybe a table with all possible input values could reduce the
1839 // computional effort, but this would consume a lot of ram
1840 if ((signalsInvolved->At(iEntry) == newInvolvedSignalCombination) &&
1841 (results->At(iEntry) == newResult)) {
1842 signalCombinationAlreadyEnlisted = kTRUE;
1846 if (!signalCombinationAlreadyEnlisted) {
1847 results->Set(results->GetSize() + 1);
1848 (*results)[results->GetSize() - 1] = inputSignal |
1849 (*results)[iResult];
1850 // add variant with active bit, variant with inactive signal
1851 // is already containt in the results array
1853 // update signalsInvolved:
1854 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1855 (*signalsInvolved)[signalsInvolved->GetSize() - 1] =
1856 (*signalsInvolved)[iResult] | inputSignal;
1859 inputSignal <<= 1; // move temp to the next input signal
1866 //______________________________________________________________________________
1867 Int_t* AliTRDptrgParam::GenerateLUTbasedOnEq(TString eq, Int_t inputWidth,
1869 // Processes the conversion of a logical equation to a look up table
1871 TArrayI* results = 0x0;
1872 TArrayI* signalsInvolved = 0x0;
1874 ConvertLogicalEqToBitVectors(eq, results, signalsInvolved);
1875 // generate bit vectors
1877 CheckSignalsInvolved(results, signalsInvolved, inputWidth);
1878 // add bit vectors for signals which are not taken into account
1880 Int_t lutSize = 0x1 << inputWidth; // 2^inputwidth elements
1881 Int_t* resultingLUT = new Int_t[lutSize]; // create LUT
1882 for (Int_t iLUTentry = 0; iLUTentry < lutSize; iLUTentry++) { // init LUT
1883 resultingLUT[iLUTentry] = 0;
1885 for (Int_t iEntry = 0; iEntry < results->GetSize(); iEntry++) {
1886 resultingLUT[(*results)[iEntry]] = initValue;
1889 if (results != 0x0) {
1893 if (signalsInvolved != 0x0) {
1894 delete signalsInvolved;
1895 signalsInvolved = 0x0;
1898 return resultingLUT;
1901 //______________________________________________________________________________
1902 //___ GETTER FUNCTIONS__________________________________________________________
1903 //______________________________________________________________________________
1904 UInt_t* AliTRDptrgParam::GetFEBT0Thresholds(AliTRDptrgFEBPosition_t FEBposition)
1907 // get T0 FEB Thresholds
1908 return this->fFEBT0Thresholds[FEBposition - 1];
1909 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1912 //_____________________________________________________________________________
1913 Int_t* AliTRDptrgParam::GetFEBT0LUT(AliTRDptrgFEBPosition_t FEBposition,
1916 if (this->fFEBT0LUTs == 0x0) {
1917 this->GenerateLUTs();
1919 return this->fFEBT0LUTs[FEBposition - 1][iLUT];
1920 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1923 //______________________________________________________________________________
1924 UInt_t* AliTRDptrgParam::GetFEBV0Thresholds(AliTRDptrgFEBPosition_t FEBposition,
1925 Int_t iCard) const {
1926 // get V0 FEB Thresholds
1927 return this->fFEBV0Thresholds[FEBposition - 1][iCard];
1928 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1931 //______________________________________________________________________________
1932 Int_t* AliTRDptrgParam::GetFEBV0LUT(AliTRDptrgFEBPosition_t FEBposition,
1933 Int_t iCard, Int_t iLUT) {
1935 if (this->fFEBV0LUTs == 0x0) {
1936 this->GenerateLUTs();
1938 return this->fFEBV0LUTs[FEBposition - 1][iCard][iLUT];
1939 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1942 //______________________________________________________________________________
1943 Int_t* AliTRDptrgParam::GetCBLUT(UInt_t iCB, Int_t LUTid) {
1944 // return control box LUT
1945 // iCB: 0 = B, 1 = A, 2 = C
1946 if (this->fCBLUTs == 0x0) {
1947 this->GenerateLUTs();
1949 return this->fCBLUTs[iCB][LUTid];