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]=%d", this->fCBLUTs[1][0]));
871 this->fCBLUTs[1][1] = this->GenerateLUTbasedOnEq(this->fCBALUTequY, 10, 1);
872 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
873 AliDebug(10, Form("fCBLUTs[@A][1]=%d", this->fCBLUTs[1][1]));
876 // CB-C (CB = 2 / kC)
877 this->fCBLUTs[2][0] = this->GenerateLUTbasedOnEq(this->fCBCLUTequX, 10, 1);
878 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
879 AliDebug(6, Form("fCBLUTs[@C][0]=%d", this->fCBLUTs[2][0]));
881 this->fCBLUTs[2][1] = this->GenerateLUTbasedOnEq(this->fCBCLUTequY, 10, 1);
882 for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
883 AliDebug(10, Form("fCBLUTs[@C][1]=%d", this->fCBLUTs[2][0]));
886 // CB-B (CB = 0 / kB)
887 this->fCBLUTs[0][0] = this->GenerateLUTbasedOnEq(this->fCBALUTequX, 12, 1);
888 for (Int_t iEntry = 0; iEntry < 4096; iEntry++) {
889 AliDebug(10, Form("fCBLUTs[@B][0]=%d", this->fCBLUTs[0][0]));
891 this->fCBLUTs[0][1] = this->GenerateLUTbasedOnEq(this->fCBALUTequY, 12, 1);
893 for (Int_t iEntry = 0; iEntry < 4096; iEntry++) {
894 AliDebug(10, Form("fCBLUTs[@B][1]=%d", this->fCBLUTs[0][1]));
897 AliDebug(5, "LUTs were generated!");
901 //______________________________________________________________________________
902 UInt_t AliTRDptrgParam::GetMultiplicity(UInt_t BitVector) const {
903 // returns the multiplicity of a given bit vector
907 for (UInt_t iBit = 0; iBit < 32; iBit++) {
908 if (BitVector & temp) {
917 //______________________________________________________________________________
918 UInt_t AliTRDptrgParam::GetMultiplicity(Int_t BitVector) const {
919 // returns the multiplicity of a given bit vector
923 for (UInt_t iBit = 0; iBit < 32; iBit++) {
924 if (BitVector & temp) {
933 //______________________________________________________________________________
935 // Configuration file parsing (helper functions)
936 //______________________________________________________________________________
938 //______________________________________________________________________________
939 void AliTRDptrgParam::PrepareLine(TString line, TString& identifier,
941 // Prepares a line for parsing
942 // divide identifier and value
944 // clear identifier and value
949 while ((line[iLetter] != ' ') && (line[iLetter] != '\t') &&
950 (line[iLetter] != '#') && (iLetter < line.Length())) {
952 identifier += line[iLetter];
955 while (((line[iLetter] == ' ') || (line[iLetter] == '\t')) &&
956 (iLetter < line.Length()) && (line[iLetter] != '#')) {
957 // omit whitespaces and tabs in between
960 while(iLetter < line.Length()) {
961 // read value or equation and remove white spaces and tabs
962 //if ((line[iLetter] != ' ') && (line[iLetter] != '\t') &&
963 // (line[iLetter] != '#')) {
964 if (line[iLetter] != '#') {
965 value += line[iLetter];
971 //______________________________________________________________________________
972 TString AliTRDptrgParam::CleanTString(TString string) {
973 // Removes white spaces and tabs
977 for (Int_t iLetter = 0; iLetter < string.Length(); iLetter++) {
978 if ((string[iLetter] != ' ') && (string[iLetter] != '\t')) {
979 result += string[iLetter];
982 AliDebug(5, Form("Cleaned string: %s", result.Data()));
986 //______________________________________________________________________________
987 void AliTRDptrgParam::SplitUpValues(TString value, TObjArray& arr) {
988 // splits up multiple values into a TObjArray
993 for (Int_t iLetter = 0; iLetter < value.Length(); iLetter++) {
994 if ((value[iLetter] != ' ') && (value[iLetter] != '\t')) {
995 // add another letter
996 temp += value[iLetter];
999 // seperator found: white space or tabs
1000 if (temp.Length()) {
1001 TObjString* t = new TObjString(temp.Data());
1008 if (temp.Length() != 0) { // TODO
1009 TObjString* t = new TObjString(temp.Data());
1014 //______________________________________________________________________________
1015 UInt_t AliTRDptrgParam::BinaryTStringToInt(TString number) const {
1016 // converts a binary TString to an integer
1018 UInt_t result = 0x0;
1019 for (Int_t i = number.Length() - 1; i >= 0; i--) {
1020 if (number[i] == '1') {
1024 else if (number[i] == '0') {
1031 //______________________________________________________________________________
1032 Bool_t AliTRDptrgParam::ParseMultiplicityCondition(TString condition,
1035 // converts a string formed like "M(1111_1111)>4" to a input mask and a
1036 // multiplicity threshold
1038 // check whether condition is starting with "M(
1039 if ((condition[0] != 'M') || ( condition[1] != '(')) {
1043 TString maskStr = "";
1046 // extract input mask
1047 while (condition[iLetter] != ')') {
1048 maskStr += condition[iLetter++];
1050 (*mask) = BinaryTStringToInt(maskStr);
1051 if ((*mask) == 0) { // TODO find a better method to detected parser errors
1052 AliDebug(5, Form("Invalid input mask: %s,[%s]", maskStr.Data(),
1057 // ensure that ')' is followed by a '>'
1058 if (condition[++iLetter] != '>') {
1059 AliDebug(5, Form("multiplicity condition is incorrectly formed: %s",
1063 iLetter++; // move on to the first digit
1065 TString thresholdStr = "";
1066 // gain threshold string
1067 while (((condition[iLetter] != ' ') || (condition[iLetter] != '\t')) &&
1068 (iLetter < condition.Length())) {
1069 thresholdStr += condition[iLetter++];
1071 (*threshold) = thresholdStr.Atoi(); // convert string to integer
1072 AliDebug(5, Form("mask: 0x%x, multiplicity threshold: %d", (*mask),
1077 //______________________________________________________________________________
1078 Bool_t AliTRDptrgParam::ParseFEB(TString identifier, TString value) {
1079 // Parse FEB configuration
1081 //------------------------------------------
1082 if (identifier.Index("FEB/T0/A/THR") == 0) {
1083 // FEB T0 thresholds at A side
1087 SplitUpValues(value, arr);
1089 if (arr.GetEntries() != 12) {
1090 AliError("Wrong FEB T0 Threshold count, it must be 12 channels!");
1093 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1094 this->fFEBT0Thresholds[0][iValue] =
1095 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1096 AliDebug(5, Form("FEB/T0/A/THR[%d]=%d", iValue,
1097 this->fFEBT0Thresholds[0][iValue]));
1102 //-----------------------------------------------
1103 else if (identifier.Index("FEB/T0/C/THR") == 0) {
1104 // FEB T0 thresholds at c side
1108 SplitUpValues(value, arr);
1110 if (arr.GetEntries() != 12) {
1111 AliError("Wrong FEB T0 Threshold count, it must be 12 channels!");
1114 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1115 this->fFEBT0Thresholds[1][iValue] =
1116 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1117 AliDebug(5, Form("FEB/T0/C/THR[%d]=%d", iValue,
1118 this->fFEBT0Thresholds[1][iValue]));
1123 //--------------------------------------------------
1124 else if ((identifier.Index("FEB/V0/A0/THR") == 0) ||
1125 (identifier.Index("FEB/V0/A1/THR") == 0) ||
1126 (identifier.Index("FEB/V0/A2/THR") == 0) ||
1127 (identifier.Index("FEB/V0/A3/THR") == 0)) {
1128 // FEB V0 thresholds at a side (cards 0,1,2,3)
1130 TString cardIDstr = identifier(8, 1);
1131 Int_t cardID = cardIDstr.Atoi();
1135 SplitUpValues(value, arr);
1137 if (arr.GetEntries() != 8) {
1138 AliError("Wrong FEB V0 Threshold count, it must be 8 channels!");
1141 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1142 this->fFEBV0Thresholds[0][cardID][iValue] =
1143 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1144 AliDebug(5, Form("FEB/V0/A%d/THR[%d]=%d", cardID, iValue,
1145 this->fFEBV0Thresholds[0][cardID][iValue]));
1149 //--------------------------------------------------
1150 else if ((identifier.Index("FEB/V0/C0/THR") == 0) ||
1151 (identifier.Index("FEB/V0/C1/THR") == 0) ||
1152 (identifier.Index("FEB/V0/C2/THR") == 0) ||
1153 (identifier.Index("FEB/V0/C3/THR") == 0)) {
1154 // FEB V0 thresholds at c side (cards 0,1,2,3)
1156 TString cardIDstr = identifier(8, 1);
1157 Int_t cardID = cardIDstr.Atoi();
1161 SplitUpValues(value, arr);
1163 if (arr.GetEntries() != 8) {
1164 AliError("Wrong FEB V0 Threshold count, it must be 8 channels!");
1167 for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
1168 this->fFEBV0Thresholds[1][cardID][iValue] =
1169 (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
1170 AliDebug(5, Form("FEB/V0/C%d/THR[%d]=%d", cardID, iValue,
1171 this->fFEBV0Thresholds[1][cardID][iValue]));
1175 //-----------------------------------------------
1176 else if (identifier.Index("FEB/T0/A/LUT") == 0) {
1177 // FEB T0 look up tables at A side
1179 TString lutIDstr = identifier(13, 1);
1180 Int_t lutID = lutIDstr.Atoi();
1184 ParseMultiplicityCondition(value, &val, &mask);
1185 this->fFEBT0Multiplicities[0][lutID][0] = val;
1186 this->fFEBT0Multiplicities[0][lutID][1] = mask;
1187 AliDebug(5, Form("FEBT0Multiplicities[0/A][%d][val] = %d", lutID, val));
1188 AliDebug(5, Form("FEBT0Multiplicities[0/A][%d][mask] = %d", lutID, mask));
1193 //-----------------------------------------------
1194 else if (identifier.Index("FEB/T0/C/LUT") == 0) {
1195 // FEB T0 look up tables at C side
1197 TString lutIDstr = identifier(13, 1);
1198 Int_t lutID = lutIDstr.Atoi();
1202 ParseMultiplicityCondition(value, &val, &mask);
1203 this->fFEBT0Multiplicities[1][lutID][0] = val;
1204 this->fFEBT0Multiplicities[1][lutID][1] = mask;
1205 AliDebug(5, Form("FEBT0Multiplicities[1/C][%d][val] = %d", lutID, val));
1206 AliDebug(5, Form("FEBT0Multiplicities[1/C][%d][mask] = %d", lutID, mask));
1211 //--------------------------------------------------
1212 else if ((identifier.Index("FEB/V0/A0/LUT") == 0) ||
1213 (identifier.Index("FEB/V0/A1/LUT") == 0) ||
1214 (identifier.Index("FEB/V0/A2/LUT") == 0) ||
1215 (identifier.Index("FEB/V0/A3/LUT") == 0)) {
1216 // FEB V0 look up tables at A side
1218 TString cardIDstr = identifier(8, 1);
1219 Int_t cardID = cardIDstr.Atoi();
1221 TString lutIDstr = identifier(14, 1);
1222 Int_t lutID = lutIDstr.Atoi();
1226 ParseMultiplicityCondition(value, &val, &mask);
1227 this->fFEBV0Multiplicities[0][cardID][lutID][0] = val;
1228 this->fFEBV0Multiplicities[0][cardID][lutID][1] = mask;
1229 AliDebug(5, Form("FEBV0Multiplicities[0/A][%d][%d][val] = %d", cardID,
1231 AliDebug(5, Form("FEBV0Multiplicities[0/A][%d][%d][mask] = %d", cardID,
1237 //--------------------------------------------------
1238 else if ((identifier.Index("FEB/V0/C0/LUT") == 0) ||
1239 (identifier.Index("FEB/V0/C1/LUT") == 0) ||
1240 (identifier.Index("FEB/V0/C2/LUT") == 0) ||
1241 (identifier.Index("FEB/V0/C3/LUT") == 0)) {
1242 // FEB V0 look up tables at C side
1244 TString cardIDstr = identifier(8, 1);
1245 Int_t cardID = cardIDstr.Atoi();
1247 TString lutIDstr = identifier(14, 1);
1248 Int_t lutID = lutIDstr.Atoi();
1252 ParseMultiplicityCondition(value, &val, &mask);
1253 this->fFEBV0Multiplicities[1][cardID][lutID][0] = val;
1254 this->fFEBV0Multiplicities[1][cardID][lutID][1] = mask;
1255 AliDebug(5, Form("FEBV0Multiplicities[1/C][%d][%d][val] = %d", cardID,
1257 AliDebug(5, Form("FEBV0Multiplicities[1/C][%d][%d][mask] = %d", cardID,
1265 //______________________________________________________________________________
1266 Bool_t AliTRDptrgParam::ParseCBAC(TString identifier, TString value) {
1267 // Parse CB-A and CB-C configuration
1269 if (identifier.Index("CBA/LUT/") == 0) {
1270 // parse CB-A's logical equations
1272 TString eqIDstr = identifier(8, 1);
1273 Int_t eqID = eqIDstr.Atoi();
1276 this->fCBALUTequX = this->CleanTString(value);
1277 AliDebug(5, Form("fCBALUTequX=%s", this->fCBALUTequX.Data()));
1279 else if(eqID == 1) {
1280 this->fCBALUTequY= this->CleanTString(value);
1281 AliDebug(5, Form("fCBALUTequY=%s", this->fCBALUTequY.Data()));
1286 else if (identifier.Index("CBC/LUT/") == 0) {
1287 // parse CB-C's logical equations
1289 TString eqIDstr = identifier(8, 1);
1290 Int_t eqID = eqIDstr.Atoi();
1293 this->fCBCLUTequX = this->CleanTString(value);
1294 AliDebug(5, Form("fCBCLUTequX=%s", this->fCBCLUTequX.Data()));
1296 else if(eqID == 1) {
1297 this->fCBCLUTequY= this->CleanTString(value);
1298 AliDebug(5, Form("fCBCLUTequY=%s", this->fCBCLUTequY.Data()));
1305 //______________________________________________________________________________
1306 Bool_t AliTRDptrgParam::ParseCBB(TString identifier, TString value) {
1307 // Parse CBB configuration
1309 if (identifier.Index("CBB/LUT/") == 0) {
1310 // parse CB-B's logical equations
1312 TString eqIDstr = identifier(8, 1);
1313 Int_t eqID = eqIDstr.Atoi();
1316 this->fCBBLUTequX = this->CleanTString(value);
1317 AliDebug(5, Form("fCBBLUTequX=%s", this->fCBBLUTequX.Data()));
1319 else if(eqID == 1) {
1320 this->fCBBLUTequY= this->CleanTString(value);
1321 AliDebug(5, Form("fCBBLUTequY=%s", this->fCBBLUTequY.Data()));
1327 else if (identifier.Index("CBB/PT/MASK/CB-A_0") == 0) { // CB-A_0
1328 if (value.Index("YES") == 0) {
1329 this->fPTmasks.fCBA[0] = kTRUE;
1332 this->fPTmasks.fCBA[0] = kFALSE;
1334 AliDebug(5, Form("CBB/PT/MASK/CB-A_0=%d", this->fPTmasks.fCBA[0]));
1337 else if (identifier.Index("CBB/PT/MASK/CB-A_1") == 0) { // CB-A_1
1338 if (value.Index("YES") == 0) {
1339 this->fPTmasks.fCBA[1] = kTRUE;
1342 this->fPTmasks.fCBA[1] = kFALSE;
1344 AliDebug(5, Form("CBB/PT/MASK/CB-A_1=%d", this->fPTmasks.fCBA[1]));
1347 else if (identifier.Index("CBB/PT/MASK/CB-C_0") == 0) { // CB-C_0
1348 if (value.Index("YES") == 0) {
1349 this->fPTmasks.fCBC[0] = kTRUE;
1352 this->fPTmasks.fCBC[0] = kFALSE;
1354 AliDebug(5, Form("CBB/PT/MASK/CB-C_0=%d",this->fPTmasks.fCBC[0]));
1357 else if (identifier.Index("CBB/PT/MASK/CB-C_1") == 0) { // CB-C_1
1358 if (value.Index("YES") == 0) {
1359 this->fPTmasks.fCBC[1] = kTRUE;
1362 this->fPTmasks.fCBC[1] = kFALSE;
1364 AliDebug(5, Form("CBB/PT/MASK/CB-C_1=%d", this->fPTmasks.fCBC[1]));
1367 else if (identifier.Index("CBB/PT/MASK/CB-B_0") == 0) { // CB-B_0
1368 if (value.Index("YES") == 0) {
1369 this->fPTmasks.fLUTs[0] = kTRUE;
1372 this->fPTmasks.fLUTs[0] = kFALSE;
1374 AliDebug(5, Form("CBB/PT/MASK/CB-B_0=%d",this->fPTmasks.fLUTs[0]));
1377 else if (identifier.Index("CBB/PT/MASK/CB-B_1") == 0) { // CB-B_1
1378 if (value.Index("YES") == 0) {
1379 this->fPTmasks.fLUTs[1] = kTRUE;
1382 this->fPTmasks.fLUTs[1] = kFALSE;
1384 AliDebug(5, Form("CBB/PT/MASK/CB-B_1/=%d", this->fPTmasks.fLUTs[1]));
1387 else if (identifier.Index("BB/PT/MASK/TLMU_") == 0) {
1388 TString indexStr = identifier(16, 1);
1389 Int_t index = indexStr.Atoi();
1390 if (value.Index("YES") == 0) {
1391 this->fPTmasks.fTLMU[index] = kTRUE;
1394 this->fPTmasks.fTLMU[index] = kFALSE;
1396 AliDebug(5, Form("CBB/PT/MASK/TLMU_%d=%d", index,
1397 this->fPTmasks.fTLMU[index]));
1403 //______________________________________________________________________________
1404 Bool_t AliTRDptrgParam::ParseTLMU(TString identifier, TString value) {
1405 // Parse TLMU configuration
1407 if (identifier.Index("TLMU/IMASK/SEC") == 0) {
1409 TString indexStr = identifier(14,2);
1410 Int_t index = indexStr.Atoi();
1411 if ((index < 0) || (index > 17)) {
1412 AliDebug(5, "Wrong section index in TLMU input mask");
1415 this->fTLMUInputMask[index] = BinaryTStringToInt(value);
1416 AliDebug(5, Form("%d %x\n", index, this->fTLMUInputMask[index]));
1420 //-----------------------------------------------
1421 else if (identifier.Index("TLMU/CMATRIX") == 0) {
1422 // TLMU coincidence matrices
1425 TString matrixIndexStr = identifier(12,1);
1426 Int_t matrixIndex = matrixIndexStr.Atoi();
1428 TString indexStr = identifier(17,2);
1429 Int_t index = indexStr.Atoi();
1430 this->fTLMUcmatrices[matrixIndex][index] = BinaryTStringToInt(value);
1431 AliDebug(5, Form("%d 0x%x\n", matrixIndex,
1432 this->fTLMUcmatrices[matrixIndex][index]));
1436 //---------------------------------------------
1437 else if (identifier.Index("TLMU/MCNTR") == 0) {
1438 // TLMU multiplicity counter setup
1440 TString indexStr = identifier(10,1);
1441 Int_t index = indexStr.Atoi();
1444 SplitUpValues(value, arr);
1446 TString t0 = (dynamic_cast<TObjString*>(arr[0]))->GetString();
1447 TString t1 = (dynamic_cast<TObjString*>(arr[1]))->GetString();
1449 this->fTLMUmultiplicity[index][0] = t0.Atoi();
1450 this->fTLMUmultiplicity[index][1] = t1.Atoi();
1452 AliDebug(5, Form("%d: %d %d", index, this->fTLMUmultiplicity[index][0],
1453 this->fTLMUmultiplicity[index][1]));
1458 //----------------------------------------------
1459 else if (identifier.Index("TLMU/OUTMUX") == 0) {
1460 // TLMU output signal assignment
1462 SplitUpValues(value, arr);
1464 if (arr.GetEntries() > 8) {
1465 AliError("Too many TLMU output signals assigned");
1469 for (Int_t iEntry = 0; iEntry < arr.GetEntries(); iEntry++) {
1470 TString t = (dynamic_cast<TObjString*>(arr[iEntry]))->GetString();
1472 TString indexStr = t(2,1);
1473 if (t.Index("CM") == 0) { // coincidence matrix
1474 this->fTLMUoutput[iEntry][0] = indexStr.Atoi();
1476 else if (t.Index("MC") == 0) { // multiplicity
1477 this->fTLMUoutput[iEntry][1] = indexStr.Atoi();
1479 AliDebug(5, Form("TLMU output: cm = %d, mc = %d",
1480 this->fTLMUoutput[iEntry][0],
1481 this->fTLMUoutput[iEntry][1]));
1488 //______________________________________________________________________________
1490 // Logical Equation to LUT processing (helper functions)
1491 //______________________________________________________________________________
1493 //______________________________________________________________________________
1494 Int_t AliTRDptrgParam::LookUp(TString* const identifier) const {
1495 // Transforms identifier into look up table address bit
1497 // this function has to be extended/changed when different identifiers for
1498 // other equations and destination LUTs should be used
1500 if (identifier->CompareTo("T0_0", TString::kIgnoreCase) == 0)
1502 else if (identifier->CompareTo("T0_1", TString::kIgnoreCase) == 0)
1504 else if (identifier->CompareTo("V0-0_0", TString::kIgnoreCase) == 0)
1506 else if (identifier->CompareTo("V0-0_1", TString::kIgnoreCase) == 0)
1508 else if (identifier->CompareTo("V0-1_0", TString::kIgnoreCase) == 0)
1510 else if (identifier->CompareTo("V0-1_1", TString::kIgnoreCase) == 0)
1512 else if (identifier->CompareTo("V0-2_0", TString::kIgnoreCase) == 0)
1514 else if (identifier->CompareTo("V0-2_1", TString::kIgnoreCase) == 0)
1516 else if (identifier->CompareTo("V0-3_0", TString::kIgnoreCase) == 0)
1518 else if (identifier->CompareTo("V0-3_1", TString::kIgnoreCase) == 0)
1520 else if (identifier->CompareTo("CB-A_0", TString::kIgnoreCase) == 0)
1522 else if (identifier->CompareTo("CB-A_1", TString::kIgnoreCase) == 0)
1524 else if (identifier->CompareTo("CB-C_0", TString::kIgnoreCase) == 0)
1526 else if (identifier->CompareTo("CB-C_1", TString::kIgnoreCase) == 0)
1528 else if (identifier->CompareTo("TLMU_0", TString::kIgnoreCase) == 0)
1530 else if (identifier->CompareTo("TLMU_1", TString::kIgnoreCase) == 0)
1532 else if (identifier->CompareTo("TLMU_2", TString::kIgnoreCase) == 0)
1534 else if (identifier->CompareTo("TLMU_3", TString::kIgnoreCase) == 0)
1536 else if (identifier->CompareTo("TLMU_4", TString::kIgnoreCase) == 0)
1538 else if (identifier->CompareTo("TLMU_5", TString::kIgnoreCase) == 0)
1540 else if (identifier->CompareTo("TLMU_6", TString::kIgnoreCase) == 0)
1542 else if (identifier->CompareTo("TLMU_7", TString::kIgnoreCase) == 0)
1544 else return 0x0; // Error
1547 //______________________________________________________________________________
1548 void AliTRDptrgParam::MergeResults(TArrayI*& partResult1, TArrayI*& partResult2,
1550 TArrayI*& signalsInvolved1,
1551 TArrayI*& signalsInvolved2,
1552 TArrayI*& signalsInvolved,
1554 // merges result and signal involved arrays
1555 // uses logical OR (or=kTRUE) and AND (or==kFALSE) as merging function
1557 // check whether input data is valid
1558 if ((partResult1 == 0x0) || (partResult2 == 0x0) ||
1559 (signalsInvolved1 == 0x0) || (signalsInvolved2 == 0x0)) {
1560 AliError("fatal logical equation processing error!");
1563 // allocate results and signalsInvolved
1564 results = new TArrayI(0);
1565 signalsInvolved = new TArrayI(0);
1567 // merge arrays (necessary for OR and AND)
1568 for (Int_t i = 0; i < partResult1->GetSize(); i++) {
1569 for (Int_t j = 0; j < partResult2->GetSize(); j++) {
1570 results->Set(results->GetSize() + 1); // increment size
1571 (*results)[results->GetSize() - 1] = // add combination
1572 (*partResult1)[i] | (*partResult2)[j];
1574 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1575 (*signalsInvolved)[signalsInvolved->GetSize() - 1] =
1576 (*signalsInvolved1)[i] | (*signalsInvolved2)[j];
1580 if (useOR) { // only necessary for OR
1582 for (Int_t i = 0; i < partResult1->GetSize(); i++) {
1583 results->Set(results->GetSize() + 1);
1584 (*results)[results->GetSize() - 1] = (*partResult1)[i];
1586 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1587 (*signalsInvolved)[signalsInvolved->GetSize()-1] = (*signalsInvolved1)[i];
1590 for (Int_t i = 0; i < partResult2->GetSize(); i++) {
1591 results->Set(results->GetSize() + 1);
1592 (*results)[results->GetSize() - 1] = (*partResult2)[i];
1594 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1595 (*signalsInvolved)[signalsInvolved->GetSize()-1] = (*signalsInvolved2)[i];
1600 AliDebug(5, "merging results: ");
1601 for (Int_t i = 0; i < results->GetSize(); i++) {
1602 AliDebug(5, Form("0x%x 0x%x", (*results)[i], (*signalsInvolved)[i]));
1612 //______________________________________________________________________________
1613 void AliTRDptrgParam::ConvertLogicalEqToBitVectors(TString eq,
1615 TArrayI*& signalsInvolved) {
1616 // converts a logical equation to a LUT
1618 // input string must not contain white spaces or tabs
1619 // only identifiers, ||, &&, (, ) and ! are allowed
1621 // neglected signals are assumed to be zero in this function
1622 // this problem is solved by "void CheckSignalsInvolved(...)"
1624 AliDebug(5, Form("eq: %s", eq.Data()));
1626 // temporary variables used before/while merging
1627 TArrayI* partResult1 = 0x0;
1628 TArrayI* partResult2 = 0x0;
1629 TArrayI* partResult3 = 0x0;
1630 TArrayI* partResult4 = 0x0;
1631 TArrayI* signalsInvolved1 = 0x0;
1632 TArrayI* signalsInvolved2 = 0x0;
1633 TArrayI* signalsInvolved3 = 0x0;
1634 TArrayI* signalsInvolved4 = 0x0;
1636 Int_t iChar = 0; // counter variable
1638 // variables needed for correct operator order (&& before ||!)
1639 Int_t foundORbefore = -1; // found an || in that string (-1 = not found)
1640 Int_t foundAND = -1; // found an &&
1641 Int_t foundORafter = -1; // found a second OR after &&
1643 // variables needed for correct bracket processing
1644 Int_t enteredBrackets = 0; // indicates in which bracket layer the parser is
1645 Int_t bracketLevelAtZero = -1; // when enteredBrackets = 0 was reached first
1646 // after it ascended
1648 while ((iChar < eq.Length())) { //--------------------------------------------
1649 // walk through string
1651 // operators ---------------------------------------------------------------
1652 if ((enteredBrackets == 0 ) && (eq[iChar] != '(') && (eq[iChar] != ')')) {
1654 if (eq[iChar] == '|') {
1655 if (eq[iChar + 1] == '|') { // ||
1656 iChar++; // jump to the next charakter
1657 if (foundAND == -1) {
1658 foundORbefore = iChar;
1660 else if ((foundORafter == -1) && (foundAND != -1)) {
1661 foundORafter = iChar;
1664 else { // bit-wise and not supported
1665 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1666 AliError("bit-wise AND (&) not supported for now");
1671 else if (eq[iChar] == '&') {
1672 if (eq[iChar] == '&') { // ||
1673 iChar++; // jump to the next charakter
1674 if (foundAND == -1) {
1678 else { // bit-wise or not supported
1679 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1680 AliError("bit-wise OR (|) not supported for now");
1685 // brackets ----------------------------------------------------------------
1687 if (eq[iChar] == '(') {
1691 else if (eq[iChar] == ')') {
1693 if (enteredBrackets < 0) {
1694 AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
1695 AliError("Too many )s");
1697 if ((enteredBrackets == 0) && (bracketLevelAtZero == -1) &&
1698 (foundAND == -1) && (foundORbefore == -1)) {
1699 // needed to detected equations encapsulated in brackets: (...)
1700 bracketLevelAtZero = iChar;
1703 iChar++; // go on to the next letter/char
1704 } //--------------------------------------------------------------------------
1706 if (bracketLevelAtZero == (eq.Length() - 1)) { // strip ( ) and process again
1707 ConvertLogicalEqToBitVectors(eq(1, eq.Length() -2), results,
1711 else if (foundAND == -1) { // no AND
1712 if (foundORbefore != -1) { // only OR / || found and no AND
1713 ConvertLogicalEqToBitVectors(eq(0, foundORbefore-1), partResult1,
1715 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1716 eq.Length()-foundORbefore-1),
1717 partResult2, signalsInvolved2);
1719 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1720 signalsInvolved2, signalsInvolved, kTRUE);
1723 else { // only identifier remained!
1724 results = new TArrayI(1);
1725 signalsInvolved = new TArrayI(1);
1726 if (eq[0] != '!') { // identifier without negation
1727 (*results)[0] = LookUp(&eq);
1728 (*signalsInvolved)[0] = (*results)[0];
1730 else { // identifier with negation
1732 TString eqNegated = eq(1, eq.Length()-1);
1733 (*signalsInvolved)[0] = LookUp(&eqNegated);
1738 // found single or multiple AND / &&
1739 else if ((foundORafter != -1) && (foundORbefore != -1)) {
1740 // found: ...||...&&...||...
1741 ConvertLogicalEqToBitVectors(eq(0, foundORbefore-1), partResult1,
1743 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1744 foundORafter-foundORbefore-2),
1745 partResult2, signalsInvolved2);
1746 ConvertLogicalEqToBitVectors(eq(foundORafter+1, eq.Length()-foundORafter-1),
1747 partResult3, signalsInvolved3);
1749 // merge: 4 = 1 || 2
1750 MergeResults(partResult1, partResult2, partResult4, signalsInvolved1,
1751 signalsInvolved2, signalsInvolved4, kTRUE);
1752 // merge results = 3 || 4
1753 MergeResults(partResult3, partResult4, results, signalsInvolved3,
1754 signalsInvolved4, signalsInvolved, kTRUE);
1757 else if (foundORbefore != -1) {
1758 // found ...||...&&...
1759 ConvertLogicalEqToBitVectors(eq(0, foundORbefore - 1), partResult1,
1761 ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
1762 eq.Length()-foundORbefore-1),
1763 partResult2, signalsInvolved2);
1765 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1766 signalsInvolved2, signalsInvolved, kTRUE);
1769 else if (foundORafter != -1) {
1770 // found ...&&...||...
1771 ConvertLogicalEqToBitVectors(eq(0, foundORafter - 1), partResult1,
1773 ConvertLogicalEqToBitVectors(eq(foundORafter+1,
1774 eq.Length()-foundORafter-1),
1775 partResult2, signalsInvolved2);
1777 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1778 signalsInvolved2, signalsInvolved, kTRUE);
1781 else /* if (foundAND != -1)*/ { // found ...&&...
1782 ConvertLogicalEqToBitVectors(eq(0, foundAND-1), partResult1,
1784 ConvertLogicalEqToBitVectors(eq(foundAND+1, eq.Length()-foundAND-1),
1785 partResult2, signalsInvolved2);
1787 MergeResults(partResult1, partResult2, results, signalsInvolved1,
1788 signalsInvolved2, signalsInvolved, kFALSE);
1792 AliError("Logical equation parser error!");
1796 //______________________________________________________________________________
1797 void AliTRDptrgParam::CheckSignalsInvolved(TArrayI*& results,
1798 TArrayI*& signalsInvolved,
1800 // checks whether all input signals are taken into account
1802 // this function is needed to be able to write equations which contain not all
1803 // possible signals and which are not mentioned in the equation do not effect
1805 // X=B&&C=(A||!A)&&B&&C
1807 // this routine is quite inefficient but working O((2^inputWidth)^3)
1812 for (Int_t iSignal = 0; iSignal < inputWidth; iSignal++) {
1814 temp <<= 1; // move temp to the next bit
1817 for (Int_t iResult = 0; iResult < results->GetSize(); iResult++) {
1818 // tricky: size of results increases while loop is iterating
1819 // that is needed to generate all valid input signal combinations
1820 if (mask != (*signalsInvolved)[iResult]) {
1821 // not all input signals are taken into account
1822 Int_t inputSignal = 0x1;
1823 for (Int_t iSignal = 0; iSignal < inputWidth; iSignal++) {
1824 if (!(inputSignal & (*signalsInvolved)[iResult])) {
1825 Int_t newInvolvedSignalCombination =
1826 (*signalsInvolved)[iResult] | inputSignal;
1827 Int_t newResult = inputSignal | (*results)[iResult];
1828 Bool_t signalCombinationAlreadyEnlisted = kFALSE;
1829 for (Int_t iEntry = 0; iEntry < signalsInvolved->GetSize(); iEntry++){
1830 // this loop is needed to reduce the amount of equal entries in
1832 // maybe a table with all possible input values could reduce the
1833 // computional effort, but this would consume a lot of ram
1834 if ((signalsInvolved->At(iEntry) == newInvolvedSignalCombination) &&
1835 (results->At(iEntry) == newResult)) {
1836 signalCombinationAlreadyEnlisted = kTRUE;
1840 if (!signalCombinationAlreadyEnlisted) {
1841 results->Set(results->GetSize() + 1);
1842 (*results)[results->GetSize() - 1] = inputSignal |
1843 (*results)[iResult];
1844 // add variant with active bit, variant with inactive signal
1845 // is already containt in the results array
1847 // update signalsInvolved:
1848 signalsInvolved->Set(signalsInvolved->GetSize() + 1);
1849 (*signalsInvolved)[signalsInvolved->GetSize() - 1] =
1850 (*signalsInvolved)[iResult] | inputSignal;
1853 inputSignal <<= 1; // move temp to the next input signal
1860 //______________________________________________________________________________
1861 Int_t* AliTRDptrgParam::GenerateLUTbasedOnEq(TString eq, Int_t inputWidth,
1863 // Processes the conversion of a logical equation to a look up table
1865 TArrayI* results = 0x0;
1866 TArrayI* signalsInvolved = 0x0;
1868 ConvertLogicalEqToBitVectors(eq, results, signalsInvolved);
1869 // generate bit vectors
1871 CheckSignalsInvolved(results, signalsInvolved, inputWidth);
1872 // add bit vectors for signals which are not taken into account
1874 Int_t lutSize = 0x1 << inputWidth; // 2^inputwidth elements
1875 Int_t* resultingLUT = new Int_t[lutSize]; // create LUT
1876 for (Int_t iLUTentry = 0; iLUTentry < lutSize; iLUTentry++) { // init LUT
1877 resultingLUT[iLUTentry] = 0;
1879 for (Int_t iEntry = 0; iEntry < results->GetSize(); iEntry++) {
1880 resultingLUT[(*results)[iEntry]] = initValue;
1883 if (results != 0x0) {
1887 if (signalsInvolved != 0x0) {
1888 delete signalsInvolved;
1889 signalsInvolved = 0x0;
1892 return resultingLUT;
1895 //______________________________________________________________________________
1896 //___ GETTER FUNCTIONS__________________________________________________________
1897 //______________________________________________________________________________
1898 UInt_t* AliTRDptrgParam::GetFEBT0Thresholds(AliTRDptrgFEBPosition_t FEBposition)
1901 // get T0 FEB Thresholds
1902 return this->fFEBT0Thresholds[FEBposition - 1];
1903 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1906 //_____________________________________________________________________________
1907 Int_t* AliTRDptrgParam::GetFEBT0LUT(AliTRDptrgFEBPosition_t FEBposition,
1910 if (this->fFEBT0LUTs == 0x0) {
1911 this->GenerateLUTs();
1913 return this->fFEBT0LUTs[FEBposition - 1][iLUT];
1914 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1917 //______________________________________________________________________________
1918 UInt_t* AliTRDptrgParam::GetFEBV0Thresholds(AliTRDptrgFEBPosition_t FEBposition,
1919 Int_t iCard) const {
1920 // get V0 FEB Thresholds
1921 return this->fFEBV0Thresholds[FEBposition - 1][iCard];
1922 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1925 //______________________________________________________________________________
1926 Int_t* AliTRDptrgParam::GetFEBV0LUT(AliTRDptrgFEBPosition_t FEBposition,
1927 Int_t iCard, Int_t iLUT) {
1929 if (this->fFEBV0LUTs == 0x0) {
1930 this->GenerateLUTs();
1932 return this->fFEBV0LUTs[FEBposition - 1][iCard][iLUT];
1933 // 0 kB, 1= kA, 2, kC => -1 because T0FEBs are only in position kA and kC
1936 //______________________________________________________________________________
1937 Int_t* AliTRDptrgParam::GetCBLUT(UInt_t iCB, Int_t LUTid) {
1938 // return control box LUT
1939 // iCB: 0 = B, 1 = A, 2 = C
1940 if (this->fCBLUTs == 0x0) {
1941 this->GenerateLUTs();
1943 return this->fCBLUTs[iCB][LUTid];