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 fPTmasks(AliTRDptrgPTmasks())
65 // initialize coincidence matrices
66 this->fTLMUcmatrices = new UInt_t*[3];
67 for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
68 this->fTLMUcmatrices[iMatrix] = new UInt_t[18];
69 for (UInt_t iSlice = 0; iSlice < 18; iSlice++) {
70 this->fTLMUcmatrices[iMatrix][iSlice] = 0;
74 // initialize multiplicity slices
75 this->fTLMUmultiplicity = new UInt_t*[9];
76 for (UInt_t iSlice = 0; iSlice < 9; iSlice++) {
77 this->fTLMUmultiplicity[iSlice] = new UInt_t[2];
78 this->fTLMUmultiplicity[iSlice][0] = 577; // disabled
79 this->fTLMUmultiplicity[iSlice][1] = 0;
82 // initialize output muxer
83 this->fTLMUoutput = new Int_t*[8];
84 for (UInt_t iBit = 0; iBit < 8; iBit++) {
85 this->fTLMUoutput[iBit] = new Int_t[2];
86 this->fTLMUoutput[iBit][0] = -1; // cmatrix disabled
87 this->fTLMUoutput[iBit][1] = -1; // multslice disabled
90 // initialize T0 FEB thresholds
91 this->fFEBT0Thresholds = new UInt_t*[2];
92 this->fFEBT0Thresholds[0] = new UInt_t[12];
93 this->fFEBT0Thresholds[1] = new UInt_t[12];
94 for (Int_t iChan = 0; iChan < 12; iChan++) {
95 this->fFEBT0Thresholds[0][iChan] = 4294967295U;
96 this->fFEBT0Thresholds[1][iChan] = 4294967295U;
97 // writing 2^32-1 disables the input because all used adcs have
101 // initialize T0 Multiplicity
102 this->fFEBT0Multiplicities = new UInt_t**[2];
103 this->fFEBT0Multiplicities[0] = new UInt_t*[2];
104 this->fFEBT0Multiplicities[1] = new UInt_t*[2];
105 this->fFEBT0Multiplicities[0][0] = new UInt_t[2];
106 this->fFEBT0Multiplicities[0][1] = new UInt_t[2];
107 this->fFEBT0Multiplicities[1][0] = new UInt_t[2];
108 this->fFEBT0Multiplicities[1][1] = new UInt_t[2];
109 this->fFEBT0Multiplicities[0][0][0] = 4294967295U;
110 this->fFEBT0Multiplicities[0][0][1] = 4294967295U;
111 this->fFEBT0Multiplicities[0][1][0] = 4294967295U;
112 this->fFEBT0Multiplicities[0][1][1] = 4294967295U;
113 this->fFEBT0Multiplicities[1][0][0] = 4294967295U;
114 this->fFEBT0Multiplicities[1][0][1] = 4294967295U;
115 this->fFEBT0Multiplicities[1][1][0] = 4294967295U;
116 this->fFEBT0Multiplicities[1][1][1] = 4294967295U;
117 // writing 2^32-1 disables the input because all used adcs have
120 // initialize T0 LUTs
121 // this->fFEBT0LUTs = 0x0; (done in member initialization list)
122 // further initialization is done in AliTRDptrgParam::GenerateLUTs()
125 // initialize V0 FEB Thresholds
126 this->fFEBV0Thresholds = new UInt_t**[2];
127 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
128 this->fFEBV0Thresholds[iPosition] = new UInt_t*[4];
129 for (UInt_t iCard = 0; iCard < 4; iCard++) {
130 this->fFEBV0Thresholds[iPosition][iCard] = new UInt_t[8];
131 for (UInt_t iChannel = 0; iChannel < 8; iChannel++) {
132 this->fFEBV0Thresholds[iPosition][iCard][iChannel] = 4294967295U;
137 // initialize V0 Multiplicities
138 this->fFEBV0Multiplicities = new UInt_t***[2];
139 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
140 this->fFEBV0Multiplicities[iPosition] = new UInt_t**[4];
141 for (UInt_t iCard = 0; iCard < 4; iCard++) {
142 this->fFEBV0Multiplicities[iPosition][iCard] = new UInt_t*[2];
143 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
144 this->fFEBV0Multiplicities[iPosition][iCard][iLUT] = new UInt_t[2];
145 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 4294967295U;
146 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][1] = 0x0;
151 // initialize V0 LUTs
152 // this->fFEBV0LUTs = 0x0; (done in member initialization list)
153 // further initialization is done in AliTRDptrgParam::GenerateLUTs()
155 // initialize CB LUTs
156 // this->fCBLUTs = 0x0; (done in member initialization list)
157 // further initialization is done in AliTRDptrgParam::GenerateLUTs()
159 this->LoadStandardConfiguration(); // load standard configuration
162 //______________________________________________________________________________
163 AliTRDptrgParam::~AliTRDptrgParam()
167 // delete coincidence matrices
168 if (this->fTLMUcmatrices != 0x0) {
169 for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
170 if (this->fTLMUcmatrices[iMatrix] != 0x0) {
171 delete[] this->fTLMUcmatrices[iMatrix];
172 this->fTLMUcmatrices[iMatrix] = 0x0;
175 delete[] this->fTLMUcmatrices;
176 this->fTLMUcmatrices = 0x0;
179 // delete multiplicity slices
180 if (this->fTLMUmultiplicity != 0x0) {
181 for (UInt_t iSlice = 0; iSlice < 9; iSlice++) {
182 if (this->fTLMUmultiplicity[iSlice] != 0x0) {
183 delete[] this->fTLMUmultiplicity[iSlice];
184 this->fTLMUmultiplicity[iSlice] = 0x0;
187 delete[] this->fTLMUmultiplicity;
188 this->fTLMUmultiplicity = 0x0;
192 if (this->fTLMUoutput != 0x0) {
193 for (UInt_t iBit = 0; iBit < 8; iBit++) {
194 if (this->fTLMUoutput[iBit] != 0x0) {
195 delete[] this->fTLMUoutput[iBit];
196 this->fTLMUoutput[iBit] = 0x0;
199 delete[] this->fTLMUoutput;
200 this->fTLMUoutput = 0x0;
203 // delete T0 FEB thresholds
204 if (this->fFEBT0Thresholds != 0x0) {
205 if (this->fFEBT0Thresholds[0] != 0x0) {
206 delete[] this->fFEBT0Thresholds[0];
207 this->fFEBT0Thresholds[0] = 0x0;
209 if (this->fFEBT0Thresholds[1] != 0x0) {
210 delete[] this->fFEBT0Thresholds[1];
211 this->fFEBT0Thresholds[1] = 0x0;
213 delete[] this->fFEBT0Thresholds;
214 this->fFEBT0Thresholds = 0x0;
217 // delete T0 multiplicities
218 if (this->fFEBT0Multiplicities != 0x0) {
219 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
220 if (this->fFEBT0Multiplicities[iPosition] != 0x0) {
221 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
222 if (this->fFEBT0Multiplicities[iPosition][iLUT] != 0x0) {
223 delete[] this->fFEBT0Multiplicities[iPosition][iLUT];
224 this->fFEBT0Multiplicities[iPosition][iLUT] = 0x0;
227 delete[] this->fFEBT0Multiplicities[iPosition];
228 this->fFEBT0Multiplicities[iPosition] = 0x0;
231 delete[] this->fFEBT0Multiplicities;
232 this->fFEBT0Multiplicities = 0x0;
236 if (this->fFEBT0LUTs != 0x0) {
237 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
238 if (this->fFEBT0LUTs[iPosition] != 0x0) {
239 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
240 if (this->fFEBT0LUTs[iPosition][iLUT] != 0x0) {
241 delete[] this->fFEBT0LUTs[iPosition][iLUT];
242 this->fFEBT0LUTs[iPosition][iLUT] = 0x0;
245 delete[] this->fFEBT0LUTs[iPosition];
246 this->fFEBT0LUTs[iPosition] = 0x0;
249 delete[] this->fFEBT0LUTs;
250 this->fFEBT0LUTs = 0x0;
253 // delete V0 FEB thresholds
254 if (this->fFEBV0Thresholds != 0x0) {
255 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
256 if (this->fFEBV0Thresholds[iPosition] != 0x0) {
257 for (UInt_t iCard = 0; iCard < 4; iCard++) {
258 if (this->fFEBV0Thresholds[iPosition][iCard] != 0x0) {
259 delete[] this->fFEBV0Thresholds[iPosition][iCard];
260 this->fFEBV0Thresholds[iPosition][iCard] = 0x0;
263 delete[] this->fFEBV0Thresholds[iPosition];
264 this->fFEBV0Thresholds[iPosition] = 0x0;
267 delete[] this->fFEBV0Thresholds;
268 this->fFEBV0Thresholds = 0x0;
271 // delete V0 multiplicities
272 if (this->fFEBV0Multiplicities != 0x0) {
273 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
274 if (this->fFEBV0Multiplicities[iPosition] != 0x0) {
275 for (UInt_t iCard = 0; iCard < 4; iCard++) {
276 if (this->fFEBV0Multiplicities[iPosition][iCard] != 0x0) {
277 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
278 if (this->fFEBV0Multiplicities[iPosition][iCard][iLUT] != 0x0) {
279 delete[] this->fFEBV0Multiplicities[iPosition][iCard][iLUT];
280 this->fFEBV0Multiplicities[iPosition][iCard][iLUT] = 0x0;
283 delete[] this->fFEBV0Multiplicities[iPosition][iCard];
284 this->fFEBV0Multiplicities[iPosition][iCard] = 0x0;
287 delete[] this->fFEBV0Multiplicities[iPosition];
288 this->fFEBV0Multiplicities[iPosition] = 0x0;
291 delete[] this->fFEBV0Multiplicities;
292 this->fFEBV0Multiplicities = 0x0;
296 if (this->fFEBV0LUTs != 0x0) {
297 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
298 if (this->fFEBV0LUTs[iPosition] != 0x0) {
299 for (UInt_t iCard = 0; iCard < 4; iCard++) {
300 if (this->fFEBV0LUTs[iPosition][iCard] != 0x0) {
301 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
302 if (this->fFEBV0LUTs[iPosition][iCard][iLUT] != 0x0) {
303 delete[] this->fFEBV0LUTs[iPosition][iCard][iLUT];
304 this->fFEBV0LUTs[iPosition][iCard][iLUT] = 0x0;
307 delete[] this->fFEBV0LUTs[iPosition][iCard];
308 this->fFEBV0LUTs[iPosition][iCard] = 0x0;
311 delete[] this->fFEBV0LUTs[iPosition];
312 this->fFEBV0LUTs[iPosition] = 0x0;
315 delete[] this->fFEBV0LUTs;
316 this->fFEBV0LUTs = 0x0;
320 if (this->fCBLUTs != 0x0) {
321 for (UInt_t iCB = 0; iCB < 3; iCB++) {
322 if (this->fCBLUTs[iCB] != 0x0) {
323 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
324 if (this->fCBLUTs[iCB][iLUT] != 0x0) {
325 delete[] this->fCBLUTs[iCB][iLUT];
326 this->fCBLUTs[iCB][iLUT] = 0x0;
331 if (this->fCBLUTs[iCB][2] != 0x0) {
332 delete[] this->fCBLUTs[iCB][2];
333 this->fCBLUTs[iCB][2] = 0x0;
336 delete[] this->fCBLUTs[iCB];
337 this->fCBLUTs[iCB] = 0x0;
340 delete[] this->fCBLUTs;
345 //______________________________________________________________________________
346 Int_t AliTRDptrgParam::CheckVariables() const
348 // checks whether variables are deleted early enough
350 // check coincidence matrices
351 if (this->fTLMUcmatrices != 0x0) {
352 for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
353 if (this->fTLMUcmatrices[iMatrix] == 0x0) {
362 // check multiplicity slices
363 if (this->fTLMUmultiplicity != 0x0) {
364 for (UInt_t iSlice = 0; iSlice < 9; iSlice++) {
365 if (this->fTLMUmultiplicity[iSlice] == 0x0) {
375 if (this->fTLMUoutput != 0x0) {
376 for (UInt_t iBit = 0; iBit < 8; iBit++) {
377 if (this->fTLMUoutput[iBit] == 0x0) {
386 // check T0 FEB thresholds
387 if (this->fFEBT0Thresholds != 0x0) {
388 if (this->fFEBT0Thresholds[0] == 0x0) {
391 if (this->fFEBT0Thresholds[1] == 0x0) {
399 // check T0 multiplicities
400 if (this->fFEBT0Multiplicities != 0x0) {
401 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
402 if (this->fFEBT0Multiplicities[iPosition] != 0x0) {
403 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
404 if (this->fFEBT0Multiplicities[iPosition][iLUT] == 0x0) {
420 if (this->fFEBT0LUTs != 0x0) {
421 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
422 if (this->fFEBT0LUTs[iPosition] != 0x0) {
423 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
424 if (this->fFEBT0LUTs[iPosition][iLUT] == 0x0) {
438 // check V0 FEB thresholds
439 if (this->fFEBV0Thresholds != 0x0) {
440 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
441 if (this->fFEBV0Thresholds[iPosition] != 0x0) {
442 for (UInt_t iCard = 0; iCard < 4; iCard++) {
443 if (this->fFEBV0Thresholds[iPosition][iCard] == 0x0) {
457 // check V0 multiplicities
458 if (this->fFEBV0Multiplicities != 0x0) {
459 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
460 if (this->fFEBV0Multiplicities[iPosition] != 0x0) {
461 for (UInt_t iCard = 0; iCard < 4; iCard++) {
462 if (this->fFEBV0Multiplicities[iPosition][iCard] != 0x0) {
463 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
464 if (this->fFEBV0Multiplicities[iPosition][iCard][iLUT] == 0x0) {
484 if (this->fFEBV0LUTs != 0x0) {
485 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
486 if (this->fFEBV0LUTs[iPosition] != 0x0) {
487 for (UInt_t iCard = 0; iCard < 4; iCard++) {
488 if (this->fFEBV0LUTs[iPosition][iCard] != 0x0) {
489 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
490 if (this->fFEBV0LUTs[iPosition][iCard][iLUT] == 0x0) {
510 if (this->fCBLUTs != 0x0) {
511 for (UInt_t iCB = 0; iCB < 3; iCB++) {
512 if (this->fCBLUTs[iCB] != 0x0) {
513 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
514 if (this->fCBLUTs[iCB][iLUT] == 0x0) {
519 if (this->fCBLUTs[iCB][2] == 0x0) {
535 //______________________________________________________________________________
536 AliTRDptrgParam* AliTRDptrgParam::Instance()
538 // get (or create) the single instance
541 fgInstance = new AliTRDptrgParam();
546 //______________________________________________________________________________
547 void AliTRDptrgParam::Terminate()
549 // destruct the instance
551 if (fgInstance != 0) {
557 //______________________________________________________________________________
558 void AliTRDptrgParam::LoadStandardConfiguration() {
559 // loads a standard configuration parameters for testing
562 for (UInt_t iSM = 0; iSM < 18; iSM++) {
563 this->fTLMUInputMask[iSM] = 0xFFFFFFFF; // enable all input bits
566 // TLMU Input Stretch
567 this->fTLMUInputStretch = 0; // not used in simulation
569 // TLMU Coincidence Matrices
571 // Matrix 0: Back-To-Back
572 // Matrix 1: Back-To-Back +/-1
573 // Matrix 2: Back-To-Back +/-2
574 for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
575 for (UInt_t iSlice = 0; iSlice < 18; iSlice++) {
578 this->fTLMUcmatrices[iMatrix][iSlice] = 0x201 << iSlice;
580 AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
581 this->fTLMUcmatrices[iMatrix][iSlice]));
583 // because of symmetrie the other slices are not necessary
585 else if (iMatrix == 1) {
586 // Back-To-Back +/- 1
588 this->fTLMUcmatrices[iMatrix][iSlice] = 0x381 << iSlice;
590 else if (iSlice == 8) {
591 this->fTLMUcmatrices[iMatrix][iSlice] = 0x30101;
593 else if (iSlice == 9) {
594 this->fTLMUcmatrices[iMatrix][iSlice] = 0x20203;
597 this->fTLMUcmatrices[iMatrix][iSlice] = 0x407 << (iSlice - 10);
599 AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
600 this->fTLMUcmatrices[iMatrix][iSlice]));
602 else if (iMatrix == 2) {
605 this->fTLMUcmatrices[iMatrix][iSlice] = 0xF81 << iSlice;
607 else if (iSlice == 7) {
608 this->fTLMUcmatrices[iMatrix][iSlice] = 0x3C081;
610 else if (iSlice == 8) {
611 this->fTLMUcmatrices[iMatrix][iSlice] = 0x38103;
613 else if (iSlice == 9) {
614 this->fTLMUcmatrices[iMatrix][iSlice] = 0x30207;
616 else if (iSlice == 10) {
617 this->fTLMUcmatrices[iMatrix][iSlice] = 0x2040F;
620 this->fTLMUcmatrices[iMatrix][iSlice] = 0x81F << (iSlice - 11);
622 AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
623 this->fTLMUcmatrices[iMatrix][iSlice]));
629 this->fTLMUmultiplicity[0][0] = 0;
630 this->fTLMUmultiplicity[0][1] = 10;
631 this->fTLMUmultiplicity[1][0] = 10;
632 this->fTLMUmultiplicity[1][1] = 25;
633 this->fTLMUmultiplicity[2][0] = 25;
634 this->fTLMUmultiplicity[2][1] = 50;
635 this->fTLMUmultiplicity[3][0] = 50;
636 this->fTLMUmultiplicity[3][1] = 100;
637 this->fTLMUmultiplicity[4][0] = 100;
638 this->fTLMUmultiplicity[4][1] = 200;
639 this->fTLMUmultiplicity[5][0] = 200;
640 this->fTLMUmultiplicity[5][1] = 350;
641 this->fTLMUmultiplicity[6][0] = 350;
642 this->fTLMUmultiplicity[6][1] = 400;
643 this->fTLMUmultiplicity[7][0] = 400;
644 this->fTLMUmultiplicity[7][1] = 576;
645 this->fTLMUmultiplicity[8][0] = 1;
646 this->fTLMUmultiplicity[8][1] = 576;
649 this->fTLMUoutput[0][0] = 0;
650 this->fTLMUoutput[1][0] = 1;
651 this->fTLMUoutput[2][0] = 2;
652 this->fTLMUoutput[3][1] = 0;
653 this->fTLMUoutput[4][1] = 1;
654 this->fTLMUoutput[5][1] = 2;
655 this->fTLMUoutput[6][1] = 3;
656 this->fTLMUoutput[7][1] = 8;
659 for (UInt_t iChannel = 0; iChannel < 12; iChannel++) {
660 this->fFEBT0Thresholds[0][iChannel] = 10;
661 this->fFEBT0Thresholds[1][iChannel] = 10;
665 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
666 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
668 this->fFEBT0Multiplicities[iPosition][iLUT][0] = 0;
671 this->fFEBT0Multiplicities[iPosition][iLUT][0] = 5;
673 this->fFEBT0Multiplicities[iPosition][iLUT][1] = 0xFFF;
678 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
679 for (UInt_t iCard = 0; iCard < 4; iCard++) {
680 for (UInt_t iChannel = 0; iChannel < 8; iChannel++) {
681 this->fFEBV0Thresholds[iPosition][iCard][iChannel] = 10;
687 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
688 for (UInt_t iCard = 0; iCard < 4; iCard++) {
689 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
691 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 0;
694 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 3;
696 this->fFEBV0Multiplicities[iPosition][iCard][iLUT][1] = 0xFF;
701 // CB-A LUT equations
702 this->fCBALUTequ[0] = "T0_0 || (V0-0_0 || V0-1_0 || V0-2_0 || V0-3_0)";
703 this->fCBALUTequ[1] = "!T0_1 && !V0-0_1 && !V0-1_1 && !V0-2_1 && !V0-3_1";
705 // CB-C LUT equations
706 this->fCBCLUTequ[0] = "T0_0 || ( V0-0_0 || V0-1_0 || V0-2_0 || V0-3_0 )";
707 this->fCBCLUTequ[1] = "!T0_1 && !V0-0_1 && !V0-1_1 && !V0-2_1 && !V0-3_1";
709 // CB-B LUT equations
710 this->fCBBLUTequ[0] = "CB-A_1 && !CB-C_1 && TLMU_7";
711 this->fCBBLUTequ[1] = "!CB-A_1 && CB-C_1 && TLMU_7";
712 this->fCBBLUTequ[2] = "CB-A_1 && CB-C_1 && TLMU_7";
715 this->fPTmasks.fLUTs[0] = kTRUE;
716 this->fPTmasks.fLUTs[1] = kTRUE;
717 this->fPTmasks.fLUTs[2] = kTRUE;
718 this->fPTmasks.fCBA[0] = kTRUE;
719 this->fPTmasks.fCBC[0] = kTRUE;
720 for (Int_t i = 1; i < 7; i++) {
721 this->fPTmasks.fTLMU[i] = kTRUE;
727 //______________________________________________________________________________
728 Bool_t AliTRDptrgParam::LoadConfigurationFromFile(TString filename) {
729 // Reads pretrigger configuration file and forwards identifiers and values
730 // to the corresponding parser functions
731 // This method is only checking for certain keywords at the beginning of a
732 // line in the config file
735 inputFile.open(filename.Data());
742 if (inputFile.is_open())
744 AliDebug(5, "---- Reading configuration file ----");
745 while (getline(inputFile, str)) {
748 AliDebug(5, Form("line: %s\n", line.Data()));
749 if (line.Index("TLMU") == 0) {
750 this->PrepareLine(line, identifier, value);
751 if (!this->ParseTLMU(identifier, value)) {
755 else if (line.Index("FEB") == 0) {
756 this->PrepareLine(line, identifier, value);
757 if (!this->ParseFEB(identifier, value)) {
761 else if (line.Index("CBB") == 0) {
762 this->PrepareLine(line, identifier, value);
763 if (!this->ParseCBB(identifier, value)) {
767 else if ((line.Index("CBA") == 0) ||
768 (line.Index("CBC") == 0)) {
769 this->PrepareLine(line, identifier, value);
770 if (!this->ParseCBAC(identifier, value)) {
775 AliDebug(5, "---- Finished reading configuration file ----");
781 AliDebug(5, "Error opening configuration file");
788 //______________________________________________________________________________
789 Int_t AliTRDptrgParam::GenerateLUTs() {
790 // generates all LUTs defined inside this object, this schould called only
791 // once, after configuration is loaded in order to save cpu time
793 // generation method:
794 // walk through address space
795 // mask address with input mask => get multiplicity of masked value
796 // if (multiplicity of masked value) > multiplicity condition
800 this->fFEBT0LUTs = new Int_t**[2]; // 2 A + C side
801 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
802 // iPosition = 0 -> A, iPosition = 1 -> C
803 this->fFEBT0LUTs[iPosition] = new Int_t*[2]; // 2 LUTs per side
804 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
805 // LUT with 12 input channels 2^12=4096
806 this->fFEBT0LUTs[iPosition][iLUT] = new Int_t[4096];
807 AliDebug(5, Form("Generate FEBT0LUT[%d][%d]: (0x%x)>%d", iPosition, iLUT,
808 this->fFEBT0Multiplicities[iPosition][iLUT][1],
809 this->fFEBT0Multiplicities[iPosition][iLUT][0]));
810 for (UInt_t iEntry = 0; iEntry < 4096; iEntry++) {
811 // Check whether that entry belongs to a multiplicity exceeding the
813 if (this->GetMultiplicity(iEntry &
814 this->fFEBT0Multiplicities[iPosition][iLUT][1]) >
815 this->fFEBT0Multiplicities[iPosition][iLUT][0]) {
816 this->fFEBT0LUTs[iPosition][iLUT][iEntry] = 1;
819 // initialize LUT (not done before !)
820 this->fFEBT0LUTs[iPosition][iLUT][iEntry] = 0;
822 AliDebug(10, Form("FEBT0LUTs[%d][%d][0x%x]=%d", iPosition, iLUT, iEntry,
823 this->fFEBT0LUTs[iPosition][iLUT][iEntry]));
825 AliDebug(5, Form("Generated FEBT0LUTs[%d][%d]", iPosition, iLUT));
830 this->fFEBV0LUTs = new Int_t***[2]; // 2 A + C side
831 for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
832 // iPosition = 0 -> A, iPosition = 1 -> C
833 this->fFEBV0LUTs[iPosition] = new Int_t**[4]; // 4 FEBs per side
834 for (UInt_t iFEB = 0; iFEB < 4; iFEB++) {
835 this->fFEBV0LUTs[iPosition][iFEB] = new Int_t*[2]; // 2 LUTs per FEB
836 for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
837 // LUT with 10 input channels 2^10=1024
838 this->fFEBV0LUTs[iPosition][iFEB][iLUT] = new Int_t[1024];
839 AliDebug(5, Form("Generate FEBV0LUT[%d][%d][%d]: (0x%x)>%d", iPosition,
841 this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][1],
842 this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][0]));
843 for (UInt_t iEntry = 0; iEntry < 1024; iEntry++) {
844 // Check whether that entry belongs to a multiplicity exceeding the
846 if (this->GetMultiplicity(iEntry &
847 this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][1]) >
848 this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][0]) {
849 this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry] = 1;
852 // initialize LUT (not done before !)
853 this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry] = 0;
855 AliDebug(10, Form("FEBV0LUTs[%d][%d][%d][0x%x]=%d", iPosition, iFEB,
857 this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry]));
859 AliDebug(5, Form("Generated FEBV0LUTs[%d][%d][%d]", iPosition, iFEB,
865 // ControlBoxes (CB-x)
867 this->fCBLUTs = new Int_t**[3];
868 for (Int_t iCB = 0; iCB < 3; iCB++) {
869 if (iCB == kB) { // B
870 fCBLUTs[iCB] = new Int_t*[3];
871 this->fCBLUTs[iCB][0] = 0x0;
872 this->fCBLUTs[iCB][1] = 0x0;
873 this->fCBLUTs[iCB][2] = 0x0;
876 fCBLUTs[iCB] = new Int_t*[2];
877 this->fCBLUTs[iCB][0] = 0x0;
878 this->fCBLUTs[iCB][1] = 0x0;
882 // CB-A (CB = 1 / kA)
883 for (Int_t iLUT = 0; iLUT < 2; iLUT++) {
884 this->fCBLUTs[1][iLUT] = this->GenerateLUTbasedOnEq(this->fCBALUTequ[iLUT],
886 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
887 AliDebug(10, Form("fCBLUTs[@A][%d][0x%x]=%d", iLUT, iEntry,
888 this->fCBLUTs[1][iLUT][iEntry]));
892 // CB-C (CB = 2 / kC)
893 for (Int_t iLUT = 0; iLUT < 2; iLUT++) {
894 this->fCBLUTs[2][iLUT] = this->GenerateLUTbasedOnEq(this->fCBCLUTequ[iLUT],
896 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
897 AliDebug(6, Form("fCBLUTs[@C][%d][0x%x]=%d", iLUT, iEntry,
898 this->fCBLUTs[2][iLUT][iEntry]));
902 // CB-B (CB = 0 / kB)
903 for (Int_t iLUT = 0; iLUT < 3; iLUT++) {
904 this->fCBLUTs[0][iLUT] = this->GenerateLUTbasedOnEq(this->fCBBLUTequ[iLUT],
906 for (Int_t iEntry = 0; iEntry < 4096; iEntry++) {
907 AliDebug(10, Form("fCBLUTs[@B][%d][0x%x]=%d", iLUT, iEntry,
908 this->fCBLUTs[0][iLUT][iEntry]));
912 AliDebug(5, "LUTs were generated!");
916 //______________________________________________________________________________
917 UInt_t AliTRDptrgParam::GetMultiplicity(UInt_t BitVector) const {
918 // returns the multiplicity of a given bit vector
922 for (UInt_t iBit = 0; iBit < 32; iBit++) {
923 if (BitVector & temp) {
932 //______________________________________________________________________________
933 UInt_t AliTRDptrgParam::GetMultiplicity(Int_t BitVector) const {
934 // returns the multiplicity of a given bit vector
938 for (UInt_t iBit = 0; iBit < 32; iBit++) {
939 if (BitVector & temp) {
948 //______________________________________________________________________________
950 // Configuration file parsing (helper functions)
951 //______________________________________________________________________________
953 //______________________________________________________________________________
954 void AliTRDptrgParam::PrepareLine(TString line, TString& identifier,
956 // Prepares a line for parsing
957 // divide identifier and value
959 // clear identifier and value
964 while ((line[iLetter] != ' ') && (line[iLetter] != '\t') &&
965 (line[iLetter] != '#') && (iLetter < line.Length())) {
967 identifier += line[iLetter];
970 while (((line[iLetter] == ' ') || (line[iLetter] == '\t')) &&
971 (iLetter < line.Length()) && (line[iLetter] != '#')) {
972 // omit whitespaces and tabs in between
975 while(iLetter < line.Length()) {
976 // read value or equation and remove white spaces and tabs
977 //if ((line[iLetter] != ' ') && (line[iLetter] != '\t') &&
978 // (line[iLetter] != '#')) {
979 if (line[iLetter] != '#') {
980 value += line[iLetter];
986 //______________________________________________________________________________
987 TString AliTRDptrgParam::CleanTString(TString string) {
988 // Removes white spaces and tabs
992 for (Int_t iLetter = 0; iLetter < string.Length(); iLetter++) {
993 if ((string[iLetter] != ' ') && (string[iLetter] != '\t')) {
994 result += string[iLetter];
997 AliDebug(5, Form("Cleaned string: %s", result.Data()));
1001 //______________________________________________________________________________
1002 void AliTRDptrgParam::SplitUpValues(TString value, TObjArray& arr) {
1003 // splits up multiple values into a TObjArray
1008 for (Int_t iLetter = 0; iLetter < value.Length(); iLetter++) {
1009 if ((value[iLetter] != ' ') && (value[iLetter] != '\t')) {
1010 // add another letter
1011 temp += value[iLetter];
1014 // seperator found: white space or tabs
1015 if (temp.Length()) {
1016 TObjString* t = new TObjString(temp.Data());
1023 if (temp.Length() != 0) {
1024 TObjString* t = new TObjString(temp.Data());
1029 //______________________________________________________________________________
1030 UInt_t AliTRDptrgParam::BinaryTStringToInt(TString number) const {
1031 // converts a binary TString to an integer
1033 UInt_t result = 0x0;
1034 for (Int_t i = number.Length() - 1; i >= 0; i--) {
1035 if (number[i] == '1') {
1039 else if (number[i] == '0') {
1046 //______________________________________________________________________________
1047 Bool_t AliTRDptrgParam::ParseMultiplicityCondition(TString condition,
1050 // converts a string formed like "M(1111_1111)>4" to a input mask and a
1051 // multiplicity threshold
1053 // check whether condition is starting with "M(
1054 if ((condition[0] != 'M') || ( condition[1] != '(')) {
1058 TString maskStr = "";
1061 // extract input mask
1062 while (condition[iLetter] != ')') {
1063 maskStr += condition[iLetter++];
1065 (*mask) = BinaryTStringToInt(maskStr);
1067 AliDebug(5, Form("Invalid input mask: %s,[%s]", maskStr.Data(),
1072 // ensure that ')' is followed by a '>'
1073 if (condition[++iLetter] != '>') {
1074 AliDebug(5, Form("multiplicity condition is incorrectly formed: %s",
1078 iLetter++; // move on to the first digit
1080 TString thresholdStr = "";
1081 // gain threshold string
1082 while (((condition[iLetter] != ' ') || (condition[iLetter] != '\t')) &&
1083 (iLetter < condition.Length())) {
1084 thresholdStr += condition[iLetter++];
1086 (*threshold) = thresholdStr.Atoi(); // convert string to integer
1087 AliDebug(5, Form("mask: 0x%x, multiplicity threshold: %d", (*mask),
1092 //______________________________________________________________________________
1093 Bool_t AliTRDptrgParam::ParseFEB(TString identifier, TString value) {
1094 // Parse FEB configuration
1096 //------------------------------------------
1097 if (identifier.Index("FEB/T0/A/THR") == 0) {
1098 // FEB T0 thresholds at A side
1102 SplitUpValues(value, arr);
1104 if (arr.GetEntries() != 12) {
1105 AliError("Wrong FEB T0 Threshold count, it must be 12 channels!");
1108 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1109 TObjString *ostrng = dynamic_cast<TObjString*>(arr[iValue]);
1111 this->fFEBT0Thresholds[0][iValue] = (ostrng->GetString()).Atoi();
1113 AliDebug(5, Form("FEB/T0/A/THR[%d]=%d", iValue,
1114 this->fFEBT0Thresholds[0][iValue]));
1119 //-----------------------------------------------
1120 else if (identifier.Index("FEB/T0/C/THR") == 0) {
1121 // FEB T0 thresholds at c side
1125 SplitUpValues(value, arr);
1127 if (arr.GetEntries() != 12) {
1128 AliError("Wrong FEB T0 Threshold count, it must be 12 channels!");
1131 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1132 TObjString *ostrng = dynamic_cast<TObjString*>(arr[iValue]);
1134 this->fFEBT0Thresholds[1][iValue] = (ostrng->GetString()).Atoi();
1136 AliDebug(5, Form("FEB/T0/C/THR[%d]=%d", iValue,
1137 this->fFEBT0Thresholds[1][iValue]));
1142 //--------------------------------------------------
1143 else if ((identifier.Index("FEB/V0/A0/THR") == 0) ||
1144 (identifier.Index("FEB/V0/A1/THR") == 0) ||
1145 (identifier.Index("FEB/V0/A2/THR") == 0) ||
1146 (identifier.Index("FEB/V0/A3/THR") == 0)) {
1147 // FEB V0 thresholds at a side (cards 0,1,2,3)
1149 TString cardIDstr = identifier(8, 1);
1150 Int_t cardID = cardIDstr.Atoi();
1154 SplitUpValues(value, arr);
1156 if (arr.GetEntries() != 8) {
1157 AliError("Wrong FEB V0 Threshold count, it must be 8 channels!");
1160 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1161 TObjString *ostrng = dynamic_cast<TObjString*>(arr[iValue]);
1163 this->fFEBV0Thresholds[0][cardID][iValue] =
1164 (ostrng->GetString()).Atoi();
1166 AliDebug(5, Form("FEB/V0/A%d/THR[%d]=%d", cardID, iValue,
1167 this->fFEBV0Thresholds[0][cardID][iValue]));
1171 //--------------------------------------------------
1172 else if ((identifier.Index("FEB/V0/C0/THR") == 0) ||
1173 (identifier.Index("FEB/V0/C1/THR") == 0) ||
1174 (identifier.Index("FEB/V0/C2/THR") == 0) ||
1175 (identifier.Index("FEB/V0/C3/THR") == 0)) {
1176 // FEB V0 thresholds at c side (cards 0,1,2,3)
1178 TString cardIDstr = identifier(8, 1);
1179 Int_t cardID = cardIDstr.Atoi();
1183 SplitUpValues(value, arr);
1185 if (arr.GetEntries() != 8) {
1186 AliError("Wrong FEB V0 Threshold count, it must be 8 channels!");
1189 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1190 TObjString *ostrng = dynamic_cast<TObjString*>(arr[iValue]);
1192 this->fFEBV0Thresholds[1][cardID][iValue] = (ostrng->GetString()).Atoi();
1194 AliDebug(5, Form("FEB/V0/C%d/THR[%d]=%d", cardID, iValue,
1195 this->fFEBV0Thresholds[1][cardID][iValue]));
1199 //-----------------------------------------------
1200 else if (identifier.Index("FEB/T0/A/LUT") == 0) {
1201 // FEB T0 look up tables at A side
1203 TString lutIDstr = identifier(13, 1);
1204 Int_t lutID = lutIDstr.Atoi();
1208 ParseMultiplicityCondition(value, &val, &mask);
1209 this->fFEBT0Multiplicities[0][lutID][0] = val;
1210 this->fFEBT0Multiplicities[0][lutID][1] = mask;
1211 AliDebug(5, Form("FEBT0Multiplicities[0/A][%d][val] = %d", lutID, val));
1212 AliDebug(5, Form("FEBT0Multiplicities[0/A][%d][mask] = %d", lutID, mask));
1217 //-----------------------------------------------
1218 else if (identifier.Index("FEB/T0/C/LUT") == 0) {
1219 // FEB T0 look up tables at C side
1221 TString lutIDstr = identifier(13, 1);
1222 Int_t lutID = lutIDstr.Atoi();
1226 ParseMultiplicityCondition(value, &val, &mask);
1227 this->fFEBT0Multiplicities[1][lutID][0] = val;
1228 this->fFEBT0Multiplicities[1][lutID][1] = mask;
1229 AliDebug(5, Form("FEBT0Multiplicities[1/C][%d][val] = %d", lutID, val));
1230 AliDebug(5, Form("FEBT0Multiplicities[1/C][%d][mask] = %d", lutID, mask));
1235 //--------------------------------------------------
1236 else if ((identifier.Index("FEB/V0/A0/LUT") == 0) ||
1237 (identifier.Index("FEB/V0/A1/LUT") == 0) ||
1238 (identifier.Index("FEB/V0/A2/LUT") == 0) ||
1239 (identifier.Index("FEB/V0/A3/LUT") == 0)) {
1240 // FEB V0 look up tables at A side
1242 TString cardIDstr = identifier(8, 1);
1243 Int_t cardID = cardIDstr.Atoi();
1245 TString lutIDstr = identifier(14, 1);
1246 Int_t lutID = lutIDstr.Atoi();
1250 ParseMultiplicityCondition(value, &val, &mask);
1251 this->fFEBV0Multiplicities[0][cardID][lutID][0] = val;
1252 this->fFEBV0Multiplicities[0][cardID][lutID][1] = mask;
1253 AliDebug(5, Form("FEBV0Multiplicities[0/A][%d][%d][val] = %d", cardID,
1255 AliDebug(5, Form("FEBV0Multiplicities[0/A][%d][%d][mask] = %d", cardID,
1261 //--------------------------------------------------
1262 else if ((identifier.Index("FEB/V0/C0/LUT") == 0) ||
1263 (identifier.Index("FEB/V0/C1/LUT") == 0) ||
1264 (identifier.Index("FEB/V0/C2/LUT") == 0) ||
1265 (identifier.Index("FEB/V0/C3/LUT") == 0)) {
1266 // FEB V0 look up tables at C side
1268 TString cardIDstr = identifier(8, 1);
1269 Int_t cardID = cardIDstr.Atoi();
1271 TString lutIDstr = identifier(14, 1);
1272 Int_t lutID = lutIDstr.Atoi();
1276 ParseMultiplicityCondition(value, &val, &mask);
1277 this->fFEBV0Multiplicities[1][cardID][lutID][0] = val;
1278 this->fFEBV0Multiplicities[1][cardID][lutID][1] = mask;
1279 AliDebug(5, Form("FEBV0Multiplicities[1/C][%d][%d][val] = %d", cardID,
1281 AliDebug(5, Form("FEBV0Multiplicities[1/C][%d][%d][mask] = %d", cardID,
1289 //______________________________________________________________________________
1290 Bool_t AliTRDptrgParam::ParseCBAC(TString identifier, TString value) {
1291 // Parse CB-A and CB-C configuration
1293 if (identifier.Index("CBA/LUT/") == 0) {
1294 // parse CB-A's logical equations
1296 TString eqIDstr = identifier(8, 1);
1297 Int_t eqID = eqIDstr.Atoi();
1299 if ((eqID == 0) || (eqID == 1)) {
1300 this->fCBALUTequ[eqID] = this->CleanTString(value);
1301 AliDebug(5, Form("fCBALUTequ[%d]=%s", eqID, this->fCBALUTequ[eqID].Data()));
1306 else if (identifier.Index("CBC/LUT/") == 0) {
1307 // parse CB-C's logical equations
1309 TString eqIDstr = identifier(8, 1);
1310 Int_t eqID = eqIDstr.Atoi();
1312 if ((eqID == 0) || (eqID == 1)) {
1313 this->fCBCLUTequ[eqID] = this->CleanTString(value);
1314 AliDebug(5, Form("fCBCLUTequ[%d]=%s", eqID, this->fCBCLUTequ[eqID].Data()));
1322 //______________________________________________________________________________
1323 Bool_t AliTRDptrgParam::ParseCBB(TString identifier, TString value) {
1324 // Parse CBB configuration
1326 if (identifier.Index("CBB/LUT/") == 0) {
1327 // parse CB-B's logical equations
1329 TString eqIDstr = identifier(8, 1);
1330 Int_t eqID = eqIDstr.Atoi();
1332 if ((eqID == 0) || (eqID == 1) || (eqID == 2)) {
1333 this->fCBBLUTequ[eqID] = this->CleanTString(value);
1334 AliDebug(5, Form("fCBBLUTequ[%d]=%s", eqID, this->fCBBLUTequ[eqID].Data()));
1340 else if (identifier.Index("CBB/PT/MASK/CB-A_0") == 0) { // CB-A_0
1341 if (value.Index("YES") == 0) {
1342 this->fPTmasks.fCBA[0] = kTRUE;
1345 this->fPTmasks.fCBA[0] = kFALSE;
1347 AliDebug(5, Form("CBB/PT/MASK/CB-A_0=%d", this->fPTmasks.fCBA[0]));
1350 else if (identifier.Index("CBB/PT/MASK/CB-A_1") == 0) { // CB-A_1
1351 if (value.Index("YES") == 0) {
1352 this->fPTmasks.fCBA[1] = kTRUE;
1355 this->fPTmasks.fCBA[1] = kFALSE;
1357 AliDebug(5, Form("CBB/PT/MASK/CB-A_1=%d", this->fPTmasks.fCBA[1]));
1360 else if (identifier.Index("CBB/PT/MASK/CB-C_0") == 0) { // CB-C_0
1361 if (value.Index("YES") == 0) {
1362 this->fPTmasks.fCBC[0] = kTRUE;
1365 this->fPTmasks.fCBC[0] = kFALSE;
1367 AliDebug(5, Form("CBB/PT/MASK/CB-C_0=%d",this->fPTmasks.fCBC[0]));
1370 else if (identifier.Index("CBB/PT/MASK/CB-C_1") == 0) { // CB-C_1
1371 if (value.Index("YES") == 0) {
1372 this->fPTmasks.fCBC[1] = kTRUE;
1375 this->fPTmasks.fCBC[1] = kFALSE;
1377 AliDebug(5, Form("CBB/PT/MASK/CB-C_1=%d", this->fPTmasks.fCBC[1]));
1380 else if (identifier.Index("CBB/PT/MASK/CB-B_0") == 0) { // CB-B_0
1381 if (value.Index("YES") == 0) {
1382 this->fPTmasks.fLUTs[0] = kTRUE;
1385 this->fPTmasks.fLUTs[0] = kFALSE;
1387 AliDebug(5, Form("CBB/PT/MASK/CB-B_0=%d",this->fPTmasks.fLUTs[0]));
1390 else if (identifier.Index("CBB/PT/MASK/CB-B_1") == 0) { // CB-B_1
1391 if (value.Index("YES") == 0) {
1392 this->fPTmasks.fLUTs[1] = kTRUE;
1395 this->fPTmasks.fLUTs[1] = kFALSE;
1397 AliDebug(5, Form("CBB/PT/MASK/CB-B_1/=%d", this->fPTmasks.fLUTs[1]));
1400 else if (identifier.Index("CBB/PT/MASK/CB-B_2") == 0) { // CB-B_2
1401 if (value.Index("YES") == 0) {
1402 this->fPTmasks.fLUTs[2] = kTRUE;
1405 this->fPTmasks.fLUTs[2] = kFALSE;
1407 AliDebug(5, Form("CBB/PT/MASK/CB-B_2/=%d", this->fPTmasks.fLUTs[2]));
1410 else if (identifier.Index("BB/PT/MASK/TLMU_") == 0) {
1411 TString indexStr = identifier(16, 1);
1412 Int_t index = indexStr.Atoi();
1413 if (value.Index("YES") == 0) {
1414 this->fPTmasks.fTLMU[index] = kTRUE;
1417 this->fPTmasks.fTLMU[index] = kFALSE;
1419 AliDebug(5, Form("CBB/PT/MASK/TLMU_%d=%d", index,
1420 this->fPTmasks.fTLMU[index]));
1426 //______________________________________________________________________________
1427 Bool_t AliTRDptrgParam::ParseTLMU(TString identifier, TString value) {
1428 // Parse TLMU configuration
1430 if (identifier.Index("TLMU/IMASK/SEC") == 0) {
1432 TString indexStr = identifier(14,2);
1433 Int_t index = indexStr.Atoi();
1434 if ((index < 0) || (index > 17)) {
1435 AliDebug(5, "Wrong section index in TLMU input mask");
1438 this->fTLMUInputMask[index] = BinaryTStringToInt(value);
1439 AliDebug(5, Form("%d %x\n", index, this->fTLMUInputMask[index]));
1443 //-----------------------------------------------
1444 else if (identifier.Index("TLMU/CMATRIX") == 0) {
1445 // TLMU coincidence matrices
1448 TString matrixIndexStr = identifier(12,1);
1449 Int_t matrixIndex = matrixIndexStr.Atoi();
1451 TString indexStr = identifier(17,2);
1452 Int_t index = indexStr.Atoi();
1453 this->fTLMUcmatrices[matrixIndex][index] = BinaryTStringToInt(value);
1454 AliDebug(5, Form("%d 0x%x\n", matrixIndex,
1455 this->fTLMUcmatrices[matrixIndex][index]));
1459 //---------------------------------------------
1460 else if (identifier.Index("TLMU/MCNTR") == 0) {
1461 // TLMU multiplicity counter setup
1463 TString indexStr = identifier(10,1);
1464 Int_t index = indexStr.Atoi();
1467 SplitUpValues(value, arr);
1469 TObjString *ostrng0 = dynamic_cast<TObjString*>(arr[0]);
1470 TObjString *ostrng1 = dynamic_cast<TObjString*>(arr[1]);
1472 if (ostrng0 && ostrng1) {
1474 TString t0 = ostrng0->GetString();
1475 TString t1 = ostrng1->GetString();
1477 this->fTLMUmultiplicity[index][0] = t0.Atoi();
1478 this->fTLMUmultiplicity[index][1] = t1.Atoi();
1480 AliDebug(5, Form("%d: %d %d", index, this->fTLMUmultiplicity[index][0],
1481 this->fTLMUmultiplicity[index][1]));
1488 //----------------------------------------------
1489 else if (identifier.Index("TLMU/OUTMUX") == 0) {
1490 // TLMU output signal assignment
1492 SplitUpValues(value, arr);
1494 if (arr.GetEntries() > 8) {
1495 AliError("Too many TLMU output signals assigned");
1499 for (Int_t iEntry = 0; iEntry < arr.GetEntries(); iEntry++) {
1501 TObjString *ostrng = dynamic_cast<TObjString*>(arr[iEntry]);
1504 TString t = ostrng->GetString();
1506 TString indexStr = t(2,1);
1507 if (t.Index("CM") == 0) { // coincidence matrix
1508 this->fTLMUoutput[iEntry][0] = indexStr.Atoi();
1510 else if (t.Index("MC") == 0) { // multiplicity
1511 this->fTLMUoutput[iEntry][1] = indexStr.Atoi();
1516 AliDebug(5, Form("TLMU output: cm = %d, mc = %d",
1517 this->fTLMUoutput[iEntry][0],
1518 this->fTLMUoutput[iEntry][1]));
1525 //______________________________________________________________________________
1527 // Logical Equation to LUT processing (helper functions)
1528 //______________________________________________________________________________
1530 //______________________________________________________________________________
1531 Int_t AliTRDptrgParam::LookUp(TString* const identifier) const {
1532 // Transforms identifier into look up table address bit
1534 // this function has to be extended/changed when different identifiers for
1535 // other equations and destination LUTs should be used
1537 if (identifier->CompareTo("T0_0", TString::kIgnoreCase) == 0)
1539 else if (identifier->CompareTo("T0_1", TString::kIgnoreCase) == 0)
1541 else if (identifier->CompareTo("V0-0_0", TString::kIgnoreCase) == 0)
1543 else if (identifier->CompareTo("V0-0_1", TString::kIgnoreCase) == 0)
1545 else if (identifier->CompareTo("V0-1_0", TString::kIgnoreCase) == 0)
1547 else if (identifier->CompareTo("V0-1_1", TString::kIgnoreCase) == 0)
1549 else if (identifier->CompareTo("V0-2_0", TString::kIgnoreCase) == 0)
1551 else if (identifier->CompareTo("V0-2_1", TString::kIgnoreCase) == 0)
1553 else if (identifier->CompareTo("V0-3_0", TString::kIgnoreCase) == 0)
1555 else if (identifier->CompareTo("V0-3_1", TString::kIgnoreCase) == 0)
1557 else if (identifier->CompareTo("CB-A_0", TString::kIgnoreCase) == 0)
1559 else if (identifier->CompareTo("CB-A_1", TString::kIgnoreCase) == 0)
1561 else if (identifier->CompareTo("CB-C_0", TString::kIgnoreCase) == 0)
1563 else if (identifier->CompareTo("CB-C_1", TString::kIgnoreCase) == 0)
1565 else if (identifier->CompareTo("TLMU_0", TString::kIgnoreCase) == 0)
1567 else if (identifier->CompareTo("TLMU_1", TString::kIgnoreCase) == 0)
1569 else if (identifier->CompareTo("TLMU_2", TString::kIgnoreCase) == 0)
1571 else if (identifier->CompareTo("TLMU_3", TString::kIgnoreCase) == 0)
1573 else if (identifier->CompareTo("TLMU_4", TString::kIgnoreCase) == 0)
1575 else if (identifier->CompareTo("TLMU_5", TString::kIgnoreCase) == 0)
1577 else if (identifier->CompareTo("TLMU_6", TString::kIgnoreCase) == 0)
1579 else if (identifier->CompareTo("TLMU_7", TString::kIgnoreCase) == 0)
1581 else return 0x0; // Error
1584 //______________________________________________________________________________
1585 void AliTRDptrgParam::MergeResults(TArrayI*& partResult1, TArrayI*& partResult2,
1587 TArrayI*& signalsInvolved1,
1588 TArrayI*& signalsInvolved2,
1589 TArrayI*& signalsInvolved,
1591 // merges result and signal involved arrays
1592 // uses logical OR (or=kTRUE) and AND (or==kFALSE) as merging function
1594 // check whether input data is valid
1595 if ((partResult1 == 0x0) || (partResult2 == 0x0) ||
1596 (signalsInvolved1 == 0x0) || (signalsInvolved2 == 0x0)) {
1597 AliError("fatal logical equation processing error!");
1601 // allocate results and signalsInvolved
1602 results = new TArrayI(0);
1603 signalsInvolved = new TArrayI(0);
1605 // merge arrays (necessary for OR and AND)
1606 for (Int_t i = 0; i < partResult1->GetSize(); i++) {
1607 for (Int_t j = 0; j < partResult2->GetSize(); j++) {
1608 results->Set(results->GetSize() + 1); // increment size
1609 (*results)[results->GetSize() - 1] = // add combination
1610 (*partResult1)[i] | (*partResult2)[j];
1612 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1613 (*signalsInvolved)[signalsInvolved->GetSize() - 1] =
1614 (*signalsInvolved1)[i] | (*signalsInvolved2)[j];
1618 if (useOR) { // only necessary for OR
1620 for (Int_t i = 0; i < partResult1->GetSize(); i++) {
1621 results->Set(results->GetSize() + 1);
1622 (*results)[results->GetSize() - 1] = (*partResult1)[i];
1624 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1625 (*signalsInvolved)[signalsInvolved->GetSize()-1] = (*signalsInvolved1)[i];
1628 for (Int_t i = 0; i < partResult2->GetSize(); i++) {
1629 results->Set(results->GetSize() + 1);
1630 (*results)[results->GetSize() - 1] = (*partResult2)[i];
1632 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1633 (*signalsInvolved)[signalsInvolved->GetSize()-1] = (*signalsInvolved2)[i];
1638 AliDebug(5, "merging results: ");
1639 for (Int_t i = 0; i < results->GetSize(); i++) {
1640 AliDebug(5, Form("0x%x 0x%x", (*results)[i], (*signalsInvolved)[i]));
1650 //______________________________________________________________________________
1651 void AliTRDptrgParam::ConvertLogicalEqToBitVectors(TString eq,
1653 TArrayI*& signalsInvolved) {
1654 // converts a logical equation to a LUT
1656 // input string must not contain white spaces or tabs
1657 // only identifiers, ||, &&, (, ) and ! are allowed
1659 // neglected signals are assumed to be zero in this function
1660 // this problem is solved by "void CheckSignalsInvolved(...)"
1662 AliDebug(5, Form("eq: %s", eq.Data()));
1664 // temporary variables used before/while merging
1665 TArrayI* partResult1 = 0x0;
1666 TArrayI* partResult2 = 0x0;
1667 TArrayI* partResult3 = 0x0;
1668 TArrayI* partResult4 = 0x0;
1669 TArrayI* signalsInvolved1 = 0x0;
1670 TArrayI* signalsInvolved2 = 0x0;
1671 TArrayI* signalsInvolved3 = 0x0;
1672 TArrayI* signalsInvolved4 = 0x0;
1674 Int_t iChar = 0; // counter variable
1676 // variables needed for correct operator order (&& before ||!)
1677 Int_t foundORbefore = -1; // found an || in that string (-1 = not found)
1678 Int_t foundAND = -1; // found an &&
1679 Int_t foundORafter = -1; // found a second OR after &&
1681 // variables needed for correct bracket processing
1682 Int_t enteredBrackets = 0; // indicates in which bracket layer the parser is
1683 Int_t bracketLevelAtZero = -1; // when enteredBrackets = 0 was reached first
1684 // after it ascended
1686 while ((iChar < eq.Length())) { //--------------------------------------------
1687 // walk through string
1689 // operators ---------------------------------------------------------------
1690 if ((enteredBrackets == 0 ) && (eq[iChar] != '(') && (eq[iChar] != ')')) {
1692 if (eq[iChar] == '|') {
1693 if (eq[iChar + 1] == '|') { // ||
1694 iChar++; // jump to the next charakter
1695 if (foundAND == -1) {
1696 foundORbefore = iChar;
1698 else if ((foundORafter == -1) && (foundAND != -1)) {
1699 foundORafter = iChar;
1702 else { // bit-wise and not supported
1703 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1704 AliError("bit-wise AND (&) not supported for now");
1709 else if (eq[iChar] == '&') {
1710 if (eq[iChar] == '&') { // ||
1711 iChar++; // jump to the next charakter
1712 if (foundAND == -1) {
1716 else { // bit-wise or not supported
1717 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1718 AliError("bit-wise OR (|) not supported for now");
1723 // brackets ----------------------------------------------------------------
1725 if (eq[iChar] == '(') {
1729 else if (eq[iChar] == ')') {
1731 if (enteredBrackets < 0) {
1732 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1733 AliError("Too many )s");
1735 if ((enteredBrackets == 0) && (bracketLevelAtZero == -1) &&
1736 (foundAND == -1) && (foundORbefore == -1)) {
1737 // needed to detected equations encapsulated in brackets: (...)
1738 bracketLevelAtZero = iChar;
1741 iChar++; // go on to the next letter/char
1742 } //--------------------------------------------------------------------------
1744 if (bracketLevelAtZero == (eq.Length() - 1)) { // strip ( ) and process again
1745 ConvertLogicalEqToBitVectors(eq(1, eq.Length() -2), results,
1749 else if (foundAND == -1) { // no AND
1750 if (foundORbefore != -1) { // only OR / || found and no AND
1751 ConvertLogicalEqToBitVectors(eq(0, foundORbefore-1), partResult1,
1753 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1754 eq.Length()-foundORbefore-1),
1755 partResult2, signalsInvolved2);
1757 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1758 signalsInvolved2, signalsInvolved, kTRUE);
1761 else { // only identifier remained!
1762 results = new TArrayI(1);
1763 signalsInvolved = new TArrayI(1);
1764 if (eq[0] != '!') { // identifier without negation
1765 (*results)[0] = LookUp(&eq);
1766 (*signalsInvolved)[0] = (*results)[0];
1768 else { // identifier with negation
1770 TString eqNegated = eq(1, eq.Length()-1);
1771 (*signalsInvolved)[0] = LookUp(&eqNegated);
1776 // found single or multiple AND / &&
1777 else if ((foundORafter != -1) && (foundORbefore != -1)) {
1778 // found: ...||...&&...||...
1779 ConvertLogicalEqToBitVectors(eq(0, foundORbefore-1), partResult1,
1781 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1782 foundORafter-foundORbefore-2),
1783 partResult2, signalsInvolved2);
1784 ConvertLogicalEqToBitVectors(eq(foundORafter+1, eq.Length()-foundORafter-1),
1785 partResult3, signalsInvolved3);
1787 // merge: 4 = 1 || 2
1788 MergeResults(partResult1, partResult2, partResult4, signalsInvolved1,
1789 signalsInvolved2, signalsInvolved4, kTRUE);
1790 // merge results = 3 || 4
1791 MergeResults(partResult3, partResult4, results, signalsInvolved3,
1792 signalsInvolved4, signalsInvolved, kTRUE);
1795 else if (foundORbefore != -1) {
1796 // found ...||...&&...
1797 ConvertLogicalEqToBitVectors(eq(0, foundORbefore - 1), partResult1,
1799 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1800 eq.Length()-foundORbefore-1),
1801 partResult2, signalsInvolved2);
1803 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1804 signalsInvolved2, signalsInvolved, kTRUE);
1807 else if (foundORafter != -1) {
1808 // found ...&&...||...
1809 ConvertLogicalEqToBitVectors(eq(0, foundORafter - 1), partResult1,
1811 ConvertLogicalEqToBitVectors(eq(foundORafter+1,
1812 eq.Length()-foundORafter-1),
1813 partResult2, signalsInvolved2);
1815 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1816 signalsInvolved2, signalsInvolved, kTRUE);
1819 else /* if (foundAND != -1)*/ { // found ...&&...
1820 ConvertLogicalEqToBitVectors(eq(0, foundAND-1), partResult1,
1822 ConvertLogicalEqToBitVectors(eq(foundAND+1, eq.Length()-foundAND-1),
1823 partResult2, signalsInvolved2);
1825 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1826 signalsInvolved2, signalsInvolved, kFALSE);
1830 AliError("Logical equation parser error!");
1834 //______________________________________________________________________________
1835 void AliTRDptrgParam::CheckSignalsInvolved(TArrayI*& results,
1836 TArrayI*& signalsInvolved,
1838 // checks whether all input signals are taken into account
1840 // this function is needed to be able to write equations which contain not all
1841 // possible signals and which are not mentioned in the equation do not effect
1843 // X=B&&C=(A||!A)&&B&&C
1845 // this routine is quite inefficient but working O((2^inputWidth)^3)
1850 for (Int_t iSignal = 0; iSignal < inputWidth; iSignal++) {
1852 temp <<= 1; // move temp to the next bit
1855 for (Int_t iResult = 0; iResult < results->GetSize(); iResult++) {
1856 // tricky: size of results increases while loop is iterating
1857 // that is needed to generate all valid input signal combinations
1858 if (mask != (*signalsInvolved)[iResult]) {
1859 // not all input signals are taken into account
1860 Int_t inputSignal = 0x1;
1861 for (Int_t iSignal = 0; iSignal < inputWidth; iSignal++) {
1862 if (!(inputSignal & (*signalsInvolved)[iResult])) {
1863 Int_t newInvolvedSignalCombination =
1864 (*signalsInvolved)[iResult] | inputSignal;
1865 Int_t newResult = inputSignal | (*results)[iResult];
1866 Bool_t signalCombinationAlreadyEnlisted = kFALSE;
1867 for (Int_t iEntry = 0; iEntry < signalsInvolved->GetSize(); iEntry++){
1868 // this loop is needed to reduce the amount of equal entries in
1870 // maybe a table with all possible input values could reduce the
1871 // computional effort, but this would consume a lot of ram
1872 if ((signalsInvolved->At(iEntry) == newInvolvedSignalCombination) &&
1873 (results->At(iEntry) == newResult)) {
1874 signalCombinationAlreadyEnlisted = kTRUE;
1878 if (!signalCombinationAlreadyEnlisted) {
1879 results->Set(results->GetSize() + 1);
1880 (*results)[results->GetSize() - 1] = inputSignal |
1881 (*results)[iResult];
1882 // add variant with active bit, variant with inactive signal
1883 // is already containt in the results array
1885 // update signalsInvolved:
1886 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1887 (*signalsInvolved)[signalsInvolved->GetSize() - 1] =
1888 (*signalsInvolved)[iResult] | inputSignal;
1891 inputSignal <<= 1; // move temp to the next input signal
1898 //______________________________________________________________________________
1899 Int_t* AliTRDptrgParam::GenerateLUTbasedOnEq(TString eq, Int_t inputWidth,
1901 // Processes the conversion of a logical equation to a look up table
1903 TArrayI* results = 0x0;
1904 TArrayI* signalsInvolved = 0x0;
1906 ConvertLogicalEqToBitVectors(eq, results, signalsInvolved);
1907 // generate bit vectors
1909 if ((results != 0x0) && (signalsInvolved != 0x0)) {
1911 CheckSignalsInvolved(results, signalsInvolved, inputWidth);
1912 // add bit vectors for signals which are not taken into account
1914 Int_t lutSize = 0x1 << inputWidth; // 2^inputwidth elements
1915 Int_t* resultingLUT = new Int_t[lutSize]; // create LUT
1916 for (Int_t iLUTentry = 0; iLUTentry < lutSize; iLUTentry++) { // init LUT
1917 resultingLUT[iLUTentry] = 0;
1919 for (Int_t iEntry = 0; iEntry < results->GetSize(); iEntry++) {
1920 resultingLUT[(*results)[iEntry]] = initValue;
1926 delete signalsInvolved;
1927 signalsInvolved = 0x0;
1929 return resultingLUT;
1940 //______________________________________________________________________________
1941 //___ GETTER FUNCTIONS__________________________________________________________
1942 //______________________________________________________________________________
1943 UInt_t* AliTRDptrgParam::GetFEBT0Thresholds(AliTRDptrgFEBPosition_t FEBposition)
1946 // get T0 FEB Thresholds
1947 return this->fFEBT0Thresholds[FEBposition - 1];
1948 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1951 //_____________________________________________________________________________
1952 Int_t* AliTRDptrgParam::GetFEBT0LUT(AliTRDptrgFEBPosition_t FEBposition,
1955 if (this->fFEBT0LUTs == 0x0) {
1956 this->GenerateLUTs();
1958 return this->fFEBT0LUTs[FEBposition - 1][iLUT];
1959 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1962 //______________________________________________________________________________
1963 UInt_t* AliTRDptrgParam::GetFEBV0Thresholds(AliTRDptrgFEBPosition_t FEBposition,
1964 Int_t iCard) const {
1965 // get V0 FEB Thresholds
1966 return this->fFEBV0Thresholds[FEBposition - 1][iCard];
1967 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1970 //______________________________________________________________________________
1971 Int_t* AliTRDptrgParam::GetFEBV0LUT(AliTRDptrgFEBPosition_t FEBposition,
1972 Int_t iCard, Int_t iLUT) {
1974 if (this->fFEBV0LUTs == 0x0) {
1975 this->GenerateLUTs();
1977 return this->fFEBV0LUTs[FEBposition - 1][iCard][iLUT];
1978 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1981 //______________________________________________________________________________
1982 Int_t* AliTRDptrgParam::GetCBLUT(UInt_t iCB, Int_t LUTid) {
1983 // return control box LUT
1984 // iCB: 0 = B, 1 = A, 2 = C
1985 if (this->fCBLUTs == 0x0) {
1986 this->GenerateLUTs();
1988 return this->fCBLUTs[iCB][LUTid];