#include "TArrayI.h"
#include "TObjString.h"
#include "TString.h"
#include <fstream>
#include "AliLog.h"
#include "AliTRDptrgParam.h"
using std::ifstream;
ClassImp(AliTRDptrgParam)
AliTRDptrgParam *AliTRDptrgParam::fgInstance = 0;
AliTRDptrgParam::AliTRDptrgParam()
: TObject(),
fTLMUInputStretch(0),
fTLMUcmatrices(0x0),
fTLMUmultiplicity(0x0),
fTLMUoutput(0x0),
fFEBT0Thresholds(0x0),
fFEBT0Multiplicities(0x0),
fFEBT0LUTs(0x0),
fFEBV0Thresholds(0x0),
fFEBV0Multiplicities(0x0),
fFEBV0LUTs(0x0),
fCBLUTs(0x0),
fPTmasks(AliTRDptrgPTmasks())
{
this->fTLMUcmatrices = new UInt_t*[3];
for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
this->fTLMUcmatrices[iMatrix] = new UInt_t[18];
for (UInt_t iSlice = 0; iSlice < 18; iSlice++) {
this->fTLMUcmatrices[iMatrix][iSlice] = 0;
}
}
this->fTLMUmultiplicity = new UInt_t*[9];
for (UInt_t iSlice = 0; iSlice < 9; iSlice++) {
this->fTLMUmultiplicity[iSlice] = new UInt_t[2];
this->fTLMUmultiplicity[iSlice][0] = 577;
this->fTLMUmultiplicity[iSlice][1] = 0;
}
this->fTLMUoutput = new Int_t*[8];
for (UInt_t iBit = 0; iBit < 8; iBit++) {
this->fTLMUoutput[iBit] = new Int_t[2];
this->fTLMUoutput[iBit][0] = -1;
this->fTLMUoutput[iBit][1] = -1;
}
this->fFEBT0Thresholds = new UInt_t*[2];
this->fFEBT0Thresholds[0] = new UInt_t[12];
this->fFEBT0Thresholds[1] = new UInt_t[12];
for (Int_t iChan = 0; iChan < 12; iChan++) {
this->fFEBT0Thresholds[0][iChan] = 4294967295U;
this->fFEBT0Thresholds[1][iChan] = 4294967295U;
}
this->fFEBT0Multiplicities = new UInt_t**[2];
this->fFEBT0Multiplicities[0] = new UInt_t*[2];
this->fFEBT0Multiplicities[1] = new UInt_t*[2];
this->fFEBT0Multiplicities[0][0] = new UInt_t[2];
this->fFEBT0Multiplicities[0][1] = new UInt_t[2];
this->fFEBT0Multiplicities[1][0] = new UInt_t[2];
this->fFEBT0Multiplicities[1][1] = new UInt_t[2];
this->fFEBT0Multiplicities[0][0][0] = 4294967295U;
this->fFEBT0Multiplicities[0][0][1] = 4294967295U;
this->fFEBT0Multiplicities[0][1][0] = 4294967295U;
this->fFEBT0Multiplicities[0][1][1] = 4294967295U;
this->fFEBT0Multiplicities[1][0][0] = 4294967295U;
this->fFEBT0Multiplicities[1][0][1] = 4294967295U;
this->fFEBT0Multiplicities[1][1][0] = 4294967295U;
this->fFEBT0Multiplicities[1][1][1] = 4294967295U;
this->fFEBV0Thresholds = new UInt_t**[2];
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
this->fFEBV0Thresholds[iPosition] = new UInt_t*[4];
for (UInt_t iCard = 0; iCard < 4; iCard++) {
this->fFEBV0Thresholds[iPosition][iCard] = new UInt_t[8];
for (UInt_t iChannel = 0; iChannel < 8; iChannel++) {
this->fFEBV0Thresholds[iPosition][iCard][iChannel] = 4294967295U;
}
}
}
this->fFEBV0Multiplicities = new UInt_t***[2];
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
this->fFEBV0Multiplicities[iPosition] = new UInt_t**[4];
for (UInt_t iCard = 0; iCard < 4; iCard++) {
this->fFEBV0Multiplicities[iPosition][iCard] = new UInt_t*[2];
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
this->fFEBV0Multiplicities[iPosition][iCard][iLUT] = new UInt_t[2];
this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 4294967295U;
this->fFEBV0Multiplicities[iPosition][iCard][iLUT][1] = 0x0;
}
}
}
this->LoadStandardConfiguration();
}
AliTRDptrgParam::~AliTRDptrgParam()
{
if (this->fTLMUcmatrices != 0x0) {
for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
if (this->fTLMUcmatrices[iMatrix] != 0x0) {
delete[] this->fTLMUcmatrices[iMatrix];
this->fTLMUcmatrices[iMatrix] = 0x0;
}
}
delete[] this->fTLMUcmatrices;
this->fTLMUcmatrices = 0x0;
}
if (this->fTLMUmultiplicity != 0x0) {
for (UInt_t iSlice = 0; iSlice < 9; iSlice++) {
if (this->fTLMUmultiplicity[iSlice] != 0x0) {
delete[] this->fTLMUmultiplicity[iSlice];
this->fTLMUmultiplicity[iSlice] = 0x0;
}
}
delete[] this->fTLMUmultiplicity;
this->fTLMUmultiplicity = 0x0;
}
if (this->fTLMUoutput != 0x0) {
for (UInt_t iBit = 0; iBit < 8; iBit++) {
if (this->fTLMUoutput[iBit] != 0x0) {
delete[] this->fTLMUoutput[iBit];
this->fTLMUoutput[iBit] = 0x0;
}
}
delete[] this->fTLMUoutput;
this->fTLMUoutput = 0x0;
}
if (this->fFEBT0Thresholds != 0x0) {
if (this->fFEBT0Thresholds[0] != 0x0) {
delete[] this->fFEBT0Thresholds[0];
this->fFEBT0Thresholds[0] = 0x0;
}
if (this->fFEBT0Thresholds[1] != 0x0) {
delete[] this->fFEBT0Thresholds[1];
this->fFEBT0Thresholds[1] = 0x0;
}
delete[] this->fFEBT0Thresholds;
this->fFEBT0Thresholds = 0x0;
}
if (this->fFEBT0Multiplicities != 0x0) {
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
if (this->fFEBT0Multiplicities[iPosition] != 0x0) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (this->fFEBT0Multiplicities[iPosition][iLUT] != 0x0) {
delete[] this->fFEBT0Multiplicities[iPosition][iLUT];
this->fFEBT0Multiplicities[iPosition][iLUT] = 0x0;
}
}
delete[] this->fFEBT0Multiplicities[iPosition];
this->fFEBT0Multiplicities[iPosition] = 0x0;
}
}
delete[] this->fFEBT0Multiplicities;
this->fFEBT0Multiplicities = 0x0;
}
if (this->fFEBT0LUTs != 0x0) {
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
if (this->fFEBT0LUTs[iPosition] != 0x0) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (this->fFEBT0LUTs[iPosition][iLUT] != 0x0) {
delete[] this->fFEBT0LUTs[iPosition][iLUT];
this->fFEBT0LUTs[iPosition][iLUT] = 0x0;
}
}
delete[] this->fFEBT0LUTs[iPosition];
this->fFEBT0LUTs[iPosition] = 0x0;
}
}
delete[] this->fFEBT0LUTs;
this->fFEBT0LUTs = 0x0;
}
if (this->fFEBV0Thresholds != 0x0) {
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
if (this->fFEBV0Thresholds[iPosition] != 0x0) {
for (UInt_t iCard = 0; iCard < 4; iCard++) {
if (this->fFEBV0Thresholds[iPosition][iCard] != 0x0) {
delete[] this->fFEBV0Thresholds[iPosition][iCard];
this->fFEBV0Thresholds[iPosition][iCard] = 0x0;
}
}
delete[] this->fFEBV0Thresholds[iPosition];
this->fFEBV0Thresholds[iPosition] = 0x0;
}
}
delete[] this->fFEBV0Thresholds;
this->fFEBV0Thresholds = 0x0;
}
if (this->fFEBV0Multiplicities != 0x0) {
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
if (this->fFEBV0Multiplicities[iPosition] != 0x0) {
for (UInt_t iCard = 0; iCard < 4; iCard++) {
if (this->fFEBV0Multiplicities[iPosition][iCard] != 0x0) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (this->fFEBV0Multiplicities[iPosition][iCard][iLUT] != 0x0) {
delete[] this->fFEBV0Multiplicities[iPosition][iCard][iLUT];
this->fFEBV0Multiplicities[iPosition][iCard][iLUT] = 0x0;
}
}
delete[] this->fFEBV0Multiplicities[iPosition][iCard];
this->fFEBV0Multiplicities[iPosition][iCard] = 0x0;
}
}
delete[] this->fFEBV0Multiplicities[iPosition];
this->fFEBV0Multiplicities[iPosition] = 0x0;
}
}
delete[] this->fFEBV0Multiplicities;
this->fFEBV0Multiplicities = 0x0;
}
if (this->fFEBV0LUTs != 0x0) {
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
if (this->fFEBV0LUTs[iPosition] != 0x0) {
for (UInt_t iCard = 0; iCard < 4; iCard++) {
if (this->fFEBV0LUTs[iPosition][iCard] != 0x0) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (this->fFEBV0LUTs[iPosition][iCard][iLUT] != 0x0) {
delete[] this->fFEBV0LUTs[iPosition][iCard][iLUT];
this->fFEBV0LUTs[iPosition][iCard][iLUT] = 0x0;
}
}
delete[] this->fFEBV0LUTs[iPosition][iCard];
this->fFEBV0LUTs[iPosition][iCard] = 0x0;
}
}
delete[] this->fFEBV0LUTs[iPosition];
this->fFEBV0LUTs[iPosition] = 0x0;
}
}
delete[] this->fFEBV0LUTs;
this->fFEBV0LUTs = 0x0;
}
if (this->fCBLUTs != 0x0) {
for (UInt_t iCB = 0; iCB < 3; iCB++) {
if (this->fCBLUTs[iCB] != 0x0) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (this->fCBLUTs[iCB][iLUT] != 0x0) {
delete[] this->fCBLUTs[iCB][iLUT];
this->fCBLUTs[iCB][iLUT] = 0x0;
}
}
if (iCB == kB) {
if (this->fCBLUTs[iCB][2] != 0x0) {
delete[] this->fCBLUTs[iCB][2];
this->fCBLUTs[iCB][2] = 0x0;
}
}
delete[] this->fCBLUTs[iCB];
this->fCBLUTs[iCB] = 0x0;
}
}
delete[] this->fCBLUTs;
this->fCBLUTs = 0x0;
}
}
Int_t AliTRDptrgParam::CheckVariables() const
{
if (this->fTLMUcmatrices != 0x0) {
for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
if (this->fTLMUcmatrices[iMatrix] == 0x0) {
return -1;
}
}
}
else {
return -2;
}
if (this->fTLMUmultiplicity != 0x0) {
for (UInt_t iSlice = 0; iSlice < 9; iSlice++) {
if (this->fTLMUmultiplicity[iSlice] == 0x0) {
return -3;
}
}
}
else {
return -4;
}
if (this->fTLMUoutput != 0x0) {
for (UInt_t iBit = 0; iBit < 8; iBit++) {
if (this->fTLMUoutput[iBit] == 0x0) {
return -5;
}
}
}
else {
return -6;
}
if (this->fFEBT0Thresholds != 0x0) {
if (this->fFEBT0Thresholds[0] == 0x0) {
return -7;
}
if (this->fFEBT0Thresholds[1] == 0x0) {
return -8;
}
}
else {
return -9;
}
if (this->fFEBT0Multiplicities != 0x0) {
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
if (this->fFEBT0Multiplicities[iPosition] != 0x0) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (this->fFEBT0Multiplicities[iPosition][iLUT] == 0x0) {
return -10;
}
}
}
else {
return -11;
}
}
}
else {
return -12;
}
if (this->fFEBT0LUTs != 0x0) {
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
if (this->fFEBT0LUTs[iPosition] != 0x0) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (this->fFEBT0LUTs[iPosition][iLUT] == 0x0) {
return -13;
}
}
}
else {
return -14;
}
}
}
else {
return -15;
}
if (this->fFEBV0Thresholds != 0x0) {
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
if (this->fFEBV0Thresholds[iPosition] != 0x0) {
for (UInt_t iCard = 0; iCard < 4; iCard++) {
if (this->fFEBV0Thresholds[iPosition][iCard] == 0x0) {
return -16;
}
}
}
else {
return -17;
}
}
}
else {
return -18;
}
if (this->fFEBV0Multiplicities != 0x0) {
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
if (this->fFEBV0Multiplicities[iPosition] != 0x0) {
for (UInt_t iCard = 0; iCard < 4; iCard++) {
if (this->fFEBV0Multiplicities[iPosition][iCard] != 0x0) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (this->fFEBV0Multiplicities[iPosition][iCard][iLUT] == 0x0) {
return -19;
}
}
}
else {
return -20;
}
}
}
else {
return -21;
}
}
}
else {
return -22;
}
if (this->fFEBV0LUTs != 0x0) {
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
if (this->fFEBV0LUTs[iPosition] != 0x0) {
for (UInt_t iCard = 0; iCard < 4; iCard++) {
if (this->fFEBV0LUTs[iPosition][iCard] != 0x0) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (this->fFEBV0LUTs[iPosition][iCard][iLUT] == 0x0) {
return -23;
}
}
}
else {
return -24;
}
}
}
else {
return -25;
}
}
}
else {
return -26;
}
if (this->fCBLUTs != 0x0) {
for (UInt_t iCB = 0; iCB < 3; iCB++) {
if (this->fCBLUTs[iCB] != 0x0) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (this->fCBLUTs[iCB][iLUT] == 0x0) {
return -27;
}
}
if (iCB == kB) {
if (this->fCBLUTs[iCB][2] == 0x0) {
return -28;
}
}
}
else {
return -29;
}
}
}
else {
return -30;
}
return 0;
}
AliTRDptrgParam* AliTRDptrgParam::Instance()
{
if (fgInstance == 0)
fgInstance = new AliTRDptrgParam();
return fgInstance;
}
void AliTRDptrgParam::Terminate()
{
if (fgInstance != 0) {
delete fgInstance;
fgInstance = 0x0;
}
}
void AliTRDptrgParam::LoadStandardConfiguration() {
for (UInt_t iSM = 0; iSM < 18; iSM++) {
this->fTLMUInputMask[iSM] = 0xFFFFFFFF;
}
this->fTLMUInputStretch = 0;
for (UInt_t iMatrix = 0; iMatrix < 3; iMatrix++) {
for (UInt_t iSlice = 0; iSlice < 18; iSlice++) {
if (iMatrix == 0) {
if (iSlice < 9) {
this->fTLMUcmatrices[iMatrix][iSlice] = 0x201 << iSlice;
AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
this->fTLMUcmatrices[iMatrix][iSlice]));
}
}
else if (iMatrix == 1) {
if (iSlice < 8) {
this->fTLMUcmatrices[iMatrix][iSlice] = 0x381 << iSlice;
}
else if (iSlice == 8) {
this->fTLMUcmatrices[iMatrix][iSlice] = 0x30101;
}
else if (iSlice == 9) {
this->fTLMUcmatrices[iMatrix][iSlice] = 0x20203;
}
else {
this->fTLMUcmatrices[iMatrix][iSlice] = 0x407 << (iSlice - 10);
}
AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
this->fTLMUcmatrices[iMatrix][iSlice]));
}
else if (iMatrix == 2) {
if (iSlice < 7 ) {
this->fTLMUcmatrices[iMatrix][iSlice] = 0xF81 << iSlice;
}
else if (iSlice == 7) {
this->fTLMUcmatrices[iMatrix][iSlice] = 0x3C081;
}
else if (iSlice == 8) {
this->fTLMUcmatrices[iMatrix][iSlice] = 0x38103;
}
else if (iSlice == 9) {
this->fTLMUcmatrices[iMatrix][iSlice] = 0x30207;
}
else if (iSlice == 10) {
this->fTLMUcmatrices[iMatrix][iSlice] = 0x2040F;
}
else {
this->fTLMUcmatrices[iMatrix][iSlice] = 0x81F << (iSlice - 11);
}
AliDebug(5, Form("fTLMUcmatrices[%d][%d]=0x%x",iMatrix,iSlice,
this->fTLMUcmatrices[iMatrix][iSlice]));
}
}
}
this->fTLMUmultiplicity[0][0] = 0;
this->fTLMUmultiplicity[0][1] = 10;
this->fTLMUmultiplicity[1][0] = 10;
this->fTLMUmultiplicity[1][1] = 25;
this->fTLMUmultiplicity[2][0] = 25;
this->fTLMUmultiplicity[2][1] = 50;
this->fTLMUmultiplicity[3][0] = 50;
this->fTLMUmultiplicity[3][1] = 100;
this->fTLMUmultiplicity[4][0] = 100;
this->fTLMUmultiplicity[4][1] = 200;
this->fTLMUmultiplicity[5][0] = 200;
this->fTLMUmultiplicity[5][1] = 350;
this->fTLMUmultiplicity[6][0] = 350;
this->fTLMUmultiplicity[6][1] = 400;
this->fTLMUmultiplicity[7][0] = 400;
this->fTLMUmultiplicity[7][1] = 576;
this->fTLMUmultiplicity[8][0] = 1;
this->fTLMUmultiplicity[8][1] = 576;
this->fTLMUoutput[0][0] = 0;
this->fTLMUoutput[1][0] = 1;
this->fTLMUoutput[2][0] = 2;
this->fTLMUoutput[3][1] = 0;
this->fTLMUoutput[4][1] = 1;
this->fTLMUoutput[5][1] = 2;
this->fTLMUoutput[6][1] = 3;
this->fTLMUoutput[7][1] = 8;
for (UInt_t iChannel = 0; iChannel < 12; iChannel++) {
this->fFEBT0Thresholds[0][iChannel] = 10;
this->fFEBT0Thresholds[1][iChannel] = 10;
}
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (iLUT == 0) {
this->fFEBT0Multiplicities[iPosition][iLUT][0] = 0;
}
else {
this->fFEBT0Multiplicities[iPosition][iLUT][0] = 5;
}
this->fFEBT0Multiplicities[iPosition][iLUT][1] = 0xFFF;
}
}
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
for (UInt_t iCard = 0; iCard < 4; iCard++) {
for (UInt_t iChannel = 0; iChannel < 8; iChannel++) {
this->fFEBV0Thresholds[iPosition][iCard][iChannel] = 10;
}
}
}
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
for (UInt_t iCard = 0; iCard < 4; iCard++) {
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
if (iLUT == 0) {
this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 0;
}
else {
this->fFEBV0Multiplicities[iPosition][iCard][iLUT][0] = 3;
}
this->fFEBV0Multiplicities[iPosition][iCard][iLUT][1] = 0xFF;
}
}
}
this->fCBALUTequ[0] = "T0_0 || (V0-0_0 || V0-1_0 || V0-2_0 || V0-3_0)";
this->fCBALUTequ[1] = "!T0_1 && !V0-0_1 && !V0-1_1 && !V0-2_1 && !V0-3_1";
this->fCBCLUTequ[0] = "T0_0 || ( V0-0_0 || V0-1_0 || V0-2_0 || V0-3_0 )";
this->fCBCLUTequ[1] = "!T0_1 && !V0-0_1 && !V0-1_1 && !V0-2_1 && !V0-3_1";
this->fCBBLUTequ[0] = "CB-A_1 && !CB-C_1 && TLMU_7";
this->fCBBLUTequ[1] = "!CB-A_1 && CB-C_1 && TLMU_7";
this->fCBBLUTequ[2] = "CB-A_1 && CB-C_1 && TLMU_7";
this->fPTmasks.fLUTs[0] = kTRUE;
this->fPTmasks.fLUTs[1] = kTRUE;
this->fPTmasks.fLUTs[2] = kTRUE;
this->fPTmasks.fCBA[0] = kTRUE;
this->fPTmasks.fCBC[0] = kTRUE;
for (Int_t i = 1; i < 7; i++) {
this->fPTmasks.fTLMU[i] = kTRUE;
}
return;
}
Bool_t AliTRDptrgParam::LoadConfigurationFromFile(TString filename) {
ifstream inputFile;
inputFile.open(filename.Data());
TString line;
TString identifier;
TString value;
std::string str;
if (inputFile.is_open())
{
AliDebug(5, "---- Reading configuration file ----");
while (getline(inputFile, str)) {
line = str;
AliDebug(5, Form("line: %s\n", line.Data()));
if (line.Index("TLMU") == 0) {
this->PrepareLine(line, identifier, value);
if (!this->ParseTLMU(identifier, value)) {
return kFALSE;
}
}
else if (line.Index("FEB") == 0) {
this->PrepareLine(line, identifier, value);
if (!this->ParseFEB(identifier, value)) {
return kFALSE;
}
}
else if (line.Index("CBB") == 0) {
this->PrepareLine(line, identifier, value);
if (!this->ParseCBB(identifier, value)) {
return kFALSE;
}
}
else if ((line.Index("CBA") == 0) ||
(line.Index("CBC") == 0)) {
this->PrepareLine(line, identifier, value);
if (!this->ParseCBAC(identifier, value)) {
return kFALSE;
}
}
}
AliDebug(5, "---- Finished reading configuration file ----");
inputFile.close();
return kTRUE;
}
else
{
AliDebug(5, "Error opening configuration file");
return kFALSE;
}
return kTRUE;
}
Int_t AliTRDptrgParam::GenerateLUTs() {
this->fFEBT0LUTs = new Int_t**[2];
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
this->fFEBT0LUTs[iPosition] = new Int_t*[2];
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
this->fFEBT0LUTs[iPosition][iLUT] = new Int_t[4096];
AliDebug(5, Form("Generate FEBT0LUT[%d][%d]: (0x%x)>%d", iPosition, iLUT,
this->fFEBT0Multiplicities[iPosition][iLUT][1],
this->fFEBT0Multiplicities[iPosition][iLUT][0]));
for (UInt_t iEntry = 0; iEntry < 4096; iEntry++) {
if (this->GetMultiplicity(iEntry &
this->fFEBT0Multiplicities[iPosition][iLUT][1]) >
this->fFEBT0Multiplicities[iPosition][iLUT][0]) {
this->fFEBT0LUTs[iPosition][iLUT][iEntry] = 1;
}
else {
this->fFEBT0LUTs[iPosition][iLUT][iEntry] = 0;
}
AliDebug(10, Form("FEBT0LUTs[%d][%d][0x%x]=%d", iPosition, iLUT, iEntry,
this->fFEBT0LUTs[iPosition][iLUT][iEntry]));
}
AliDebug(5, Form("Generated FEBT0LUTs[%d][%d]", iPosition, iLUT));
}
}
this->fFEBV0LUTs = new Int_t***[2];
for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
this->fFEBV0LUTs[iPosition] = new Int_t**[4];
for (UInt_t iFEB = 0; iFEB < 4; iFEB++) {
this->fFEBV0LUTs[iPosition][iFEB] = new Int_t*[2];
for (UInt_t iLUT = 0; iLUT < 2; iLUT++) {
this->fFEBV0LUTs[iPosition][iFEB][iLUT] = new Int_t[1024];
AliDebug(5, Form("Generate FEBV0LUT[%d][%d][%d]: (0x%x)>%d", iPosition,
iFEB, iLUT,
this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][1],
this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][0]));
for (UInt_t iEntry = 0; iEntry < 1024; iEntry++) {
if (this->GetMultiplicity(iEntry &
this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][1]) >
this->fFEBV0Multiplicities[iPosition][iFEB][iLUT][0]) {
this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry] = 1;
}
else {
this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry] = 0;
}
AliDebug(10, Form("FEBV0LUTs[%d][%d][%d][0x%x]=%d", iPosition, iFEB,
iLUT, iEntry,
this->fFEBV0LUTs[iPosition][iFEB][iLUT][iEntry]));
}
AliDebug(5, Form("Generated FEBV0LUTs[%d][%d][%d]", iPosition, iFEB,
iLUT));
}
}
}
this->fCBLUTs = new Int_t**[3];
for (Int_t iCB = 0; iCB < 3; iCB++) {
if (iCB == kB) {
fCBLUTs[iCB] = new Int_t*[3];
this->fCBLUTs[iCB][0] = 0x0;
this->fCBLUTs[iCB][1] = 0x0;
this->fCBLUTs[iCB][2] = 0x0;
}
else {
fCBLUTs[iCB] = new Int_t*[2];
this->fCBLUTs[iCB][0] = 0x0;
this->fCBLUTs[iCB][1] = 0x0;
}
}
for (Int_t iLUT = 0; iLUT < 2; iLUT++) {
this->fCBLUTs[1][iLUT] = this->GenerateLUTbasedOnEq(this->fCBALUTequ[iLUT],
10,1);
for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
AliDebug(10, Form("fCBLUTs[@A][%d][0x%x]=%d", iLUT, iEntry,
this->fCBLUTs[1][iLUT][iEntry]));
}
}
for (Int_t iLUT = 0; iLUT < 2; iLUT++) {
this->fCBLUTs[2][iLUT] = this->GenerateLUTbasedOnEq(this->fCBCLUTequ[iLUT],
10,1);
for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
AliDebug(6, Form("fCBLUTs[@C][%d][0x%x]=%d", iLUT, iEntry,
this->fCBLUTs[2][iLUT][iEntry]));
}
}
for (Int_t iLUT = 0; iLUT < 3; iLUT++) {
this->fCBLUTs[0][iLUT] = this->GenerateLUTbasedOnEq(this->fCBBLUTequ[iLUT],
12,1);
for (Int_t iEntry = 0; iEntry < 4096; iEntry++) {
AliDebug(10, Form("fCBLUTs[@B][%d][0x%x]=%d", iLUT, iEntry,
this->fCBLUTs[0][iLUT][iEntry]));
}
}
AliDebug(5, "LUTs were generated!");
return 0;
}
UInt_t AliTRDptrgParam::GetMultiplicity(UInt_t BitVector) const {
UInt_t result = 0;
UInt_t temp = 0x01;
for (UInt_t iBit = 0; iBit < 32; iBit++) {
if (BitVector & temp) {
result++;
}
temp <<= 1;
}
return result;
}
UInt_t AliTRDptrgParam::GetMultiplicity(Int_t BitVector) const {
UInt_t result = 0;
UInt_t temp = 0x01;
for (UInt_t iBit = 0; iBit < 32; iBit++) {
if (BitVector & temp) {
result++;
}
temp <<= 1;
}
return result;
}
void AliTRDptrgParam::PrepareLine(TString line, TString& identifier,
TString& value) {
identifier.Clear();
value.Clear();
Int_t iLetter = 0;
while ((line[iLetter] != ' ') && (line[iLetter] != '\t') &&
(line[iLetter] != '#') && (iLetter < line.Length())) {
identifier += line[iLetter];
iLetter++;
}
while (((line[iLetter] == ' ') || (line[iLetter] == '\t')) &&
(iLetter < line.Length()) && (line[iLetter] != '#')) {
iLetter++;
}
while(iLetter < line.Length()) {
if (line[iLetter] != '#') {
value += line[iLetter];
}
iLetter++;
}
}
TString AliTRDptrgParam::CleanTString(TString string) {
TString result;
result.Clear();
for (Int_t iLetter = 0; iLetter < string.Length(); iLetter++) {
if ((string[iLetter] != ' ') && (string[iLetter] != '\t')) {
result += string[iLetter];
}
}
AliDebug(5, Form("Cleaned string: %s", result.Data()));
return result;
}
void AliTRDptrgParam::SplitUpValues(TString value, TObjArray& arr) {
TString temp;
temp.Clear();
temp.Resize(0);
for (Int_t iLetter = 0; iLetter < value.Length(); iLetter++) {
if ((value[iLetter] != ' ') && (value[iLetter] != '\t')) {
temp += value[iLetter];
}
else {
if (temp.Length()) {
TObjString* t = new TObjString(temp.Data());
arr.Add(t);
temp.Clear();
temp.Resize(0);
}
}
}
if (temp.Length() != 0) {
TObjString* t = new TObjString(temp.Data());
arr.Add(t);
}
}
UInt_t AliTRDptrgParam::BinaryTStringToInt(TString number) const {
UInt_t temp = 0x01;
UInt_t result = 0x0;
for (Int_t i = number.Length() - 1; i >= 0; i--) {
if (number[i] == '1') {
result |= temp;
temp <<= 1;
}
else if (number[i] == '0') {
temp <<= 1;
}
}
return result;
}
Bool_t AliTRDptrgParam::ParseMultiplicityCondition(TString condition,
UInt_t* threshold,
UInt_t* mask) {
if ((condition[0] != 'M') || ( condition[1] != '(')) {
return kFALSE;
}
TString maskStr = "";
Int_t iLetter = 0;
while (condition[iLetter] != ')') {
maskStr += condition[iLetter++];
}
(*mask) = BinaryTStringToInt(maskStr);
if ((*mask) == 0) {
AliDebug(5, Form("Invalid input mask: %s,[%s]", maskStr.Data(),
condition.Data()));
return kFALSE;
}
if (condition[++iLetter] != '>') {
AliDebug(5, Form("multiplicity condition is incorrectly formed: %s",
condition.Data()));
return kFALSE;
}
iLetter++;
TString thresholdStr = "";
while (((condition[iLetter] != ' ') || (condition[iLetter] != '\t')) &&
(iLetter < condition.Length())) {
thresholdStr += condition[iLetter++];
}
(*threshold) = thresholdStr.Atoi();
AliDebug(5, Form("mask: 0x%x, multiplicity threshold: %d", (*mask),
(*threshold)));
return kTRUE;
}
Bool_t AliTRDptrgParam::ParseFEB(TString identifier, TString value) {
if (identifier.Index("FEB/T0/A/THR") == 0) {
TObjArray arr;
arr.Clear();
SplitUpValues(value, arr);
if (arr.GetEntries() != 12) {
AliError("Wrong FEB T0 Threshold count, it must be 12 channels!");
return kFALSE;
}
for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
TObjString *ostrng = dynamic_cast<TObjString*>(arr[iValue]);
if (ostrng) {
this->fFEBT0Thresholds[0][iValue] = (ostrng->GetString()).Atoi();
}
AliDebug(5, Form("FEB/T0/A/THR[%d]=%d", iValue,
this->fFEBT0Thresholds[0][iValue]));
}
return kTRUE;
}
else if (identifier.Index("FEB/T0/C/THR") == 0) {
TObjArray arr;
arr.Clear();
SplitUpValues(value, arr);
if (arr.GetEntries() != 12) {
AliError("Wrong FEB T0 Threshold count, it must be 12 channels!");
return kFALSE;
}
for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
TObjString *ostrng = dynamic_cast<TObjString*>(arr[iValue]);
if (ostrng) {
this->fFEBT0Thresholds[1][iValue] = (ostrng->GetString()).Atoi();
}
AliDebug(5, Form("FEB/T0/C/THR[%d]=%d", iValue,
this->fFEBT0Thresholds[1][iValue]));
}
return kTRUE;
}
else if ((identifier.Index("FEB/V0/A0/THR") == 0) ||
(identifier.Index("FEB/V0/A1/THR") == 0) ||
(identifier.Index("FEB/V0/A2/THR") == 0) ||
(identifier.Index("FEB/V0/A3/THR") == 0)) {
TString cardIDstr = identifier(8, 1);
Int_t cardID = cardIDstr.Atoi();
TObjArray arr;
arr.Clear();
SplitUpValues(value, arr);
if (arr.GetEntries() != 8) {
AliError("Wrong FEB V0 Threshold count, it must be 8 channels!");
return kFALSE;
}
for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
TObjString *ostrng = dynamic_cast<TObjString*>(arr[iValue]);
if (ostrng) {
this->fFEBV0Thresholds[0][cardID][iValue] =
(ostrng->GetString()).Atoi();
}
AliDebug(5, Form("FEB/V0/A%d/THR[%d]=%d", cardID, iValue,
this->fFEBV0Thresholds[0][cardID][iValue]));
}
}
else if ((identifier.Index("FEB/V0/C0/THR") == 0) ||
(identifier.Index("FEB/V0/C1/THR") == 0) ||
(identifier.Index("FEB/V0/C2/THR") == 0) ||
(identifier.Index("FEB/V0/C3/THR") == 0)) {
TString cardIDstr = identifier(8, 1);
Int_t cardID = cardIDstr.Atoi();
TObjArray arr;
arr.Clear();
SplitUpValues(value, arr);
if (arr.GetEntries() != 8) {
AliError("Wrong FEB V0 Threshold count, it must be 8 channels!");
return kFALSE;
}
for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
TObjString *ostrng = dynamic_cast<TObjString*>(arr[iValue]);
if (ostrng) {
this->fFEBV0Thresholds[1][cardID][iValue] = (ostrng->GetString()).Atoi();
}
AliDebug(5, Form("FEB/V0/C%d/THR[%d]=%d", cardID, iValue,
this->fFEBV0Thresholds[1][cardID][iValue]));
}
}
else if (identifier.Index("FEB/T0/A/LUT") == 0) {
TString lutIDstr = identifier(13, 1);
Int_t lutID = lutIDstr.Atoi();
UInt_t val = 0;
UInt_t mask = 0;
ParseMultiplicityCondition(value, &val, &mask);
this->fFEBT0Multiplicities[0][lutID][0] = val;
this->fFEBT0Multiplicities[0][lutID][1] = mask;
AliDebug(5, Form("FEBT0Multiplicities[0/A][%d][val] = %d", lutID, val));
AliDebug(5, Form("FEBT0Multiplicities[0/A][%d][mask] = %d", lutID, mask));
return kTRUE;
}
else if (identifier.Index("FEB/T0/C/LUT") == 0) {
TString lutIDstr = identifier(13, 1);
Int_t lutID = lutIDstr.Atoi();
UInt_t val = 0;
UInt_t mask = 0;
ParseMultiplicityCondition(value, &val, &mask);
this->fFEBT0Multiplicities[1][lutID][0] = val;
this->fFEBT0Multiplicities[1][lutID][1] = mask;
AliDebug(5, Form("FEBT0Multiplicities[1/C][%d][val] = %d", lutID, val));
AliDebug(5, Form("FEBT0Multiplicities[1/C][%d][mask] = %d", lutID, mask));
return kTRUE;
}
else if ((identifier.Index("FEB/V0/A0/LUT") == 0) ||
(identifier.Index("FEB/V0/A1/LUT") == 0) ||
(identifier.Index("FEB/V0/A2/LUT") == 0) ||
(identifier.Index("FEB/V0/A3/LUT") == 0)) {
TString cardIDstr = identifier(8, 1);
Int_t cardID = cardIDstr.Atoi();
TString lutIDstr = identifier(14, 1);
Int_t lutID = lutIDstr.Atoi();
UInt_t val = 0;
UInt_t mask = 0;
ParseMultiplicityCondition(value, &val, &mask);
this->fFEBV0Multiplicities[0][cardID][lutID][0] = val;
this->fFEBV0Multiplicities[0][cardID][lutID][1] = mask;
AliDebug(5, Form("FEBV0Multiplicities[0/A][%d][%d][val] = %d", cardID,
lutID, val));
AliDebug(5, Form("FEBV0Multiplicities[0/A][%d][%d][mask] = %d", cardID,
lutID, mask));
return kTRUE;
}
else if ((identifier.Index("FEB/V0/C0/LUT") == 0) ||
(identifier.Index("FEB/V0/C1/LUT") == 0) ||
(identifier.Index("FEB/V0/C2/LUT") == 0) ||
(identifier.Index("FEB/V0/C3/LUT") == 0)) {
TString cardIDstr = identifier(8, 1);
Int_t cardID = cardIDstr.Atoi();
TString lutIDstr = identifier(14, 1);
Int_t lutID = lutIDstr.Atoi();
UInt_t val = 0;
UInt_t mask = 0;
ParseMultiplicityCondition(value, &val, &mask);
this->fFEBV0Multiplicities[1][cardID][lutID][0] = val;
this->fFEBV0Multiplicities[1][cardID][lutID][1] = mask;
AliDebug(5, Form("FEBV0Multiplicities[1/C][%d][%d][val] = %d", cardID,
lutID, val));
AliDebug(5, Form("FEBV0Multiplicities[1/C][%d][%d][mask] = %d", cardID,
lutID, mask));
return kTRUE;
}
return kTRUE;
}
Bool_t AliTRDptrgParam::ParseCBAC(TString identifier, TString value) {
if (identifier.Index("CBA/LUT/") == 0) {
TString eqIDstr = identifier(8, 1);
Int_t eqID = eqIDstr.Atoi();
if ((eqID == 0) || (eqID == 1)) {
this->fCBALUTequ[eqID] = this->CleanTString(value);
AliDebug(5, Form("fCBALUTequ[%d]=%s", eqID, this->fCBALUTequ[eqID].Data()));
}
return kTRUE;
}
else if (identifier.Index("CBC/LUT/") == 0) {
TString eqIDstr = identifier(8, 1);
Int_t eqID = eqIDstr.Atoi();
if ((eqID == 0) || (eqID == 1)) {
this->fCBCLUTequ[eqID] = this->CleanTString(value);
AliDebug(5, Form("fCBCLUTequ[%d]=%s", eqID, this->fCBCLUTequ[eqID].Data()));
}
return kTRUE;
}
return kTRUE;
}
Bool_t AliTRDptrgParam::ParseCBB(TString identifier, TString value) {
if (identifier.Index("CBB/LUT/") == 0) {
TString eqIDstr = identifier(8, 1);
Int_t eqID = eqIDstr.Atoi();
if ((eqID == 0) || (eqID == 1) || (eqID == 2)) {
this->fCBBLUTequ[eqID] = this->CleanTString(value);
AliDebug(5, Form("fCBBLUTequ[%d]=%s", eqID, this->fCBBLUTequ[eqID].Data()));
}
return kTRUE;
}
else if (identifier.Index("CBB/PT/MASK/CB-A_0") == 0) {
if (value.Index("YES") == 0) {
this->fPTmasks.fCBA[0] = kTRUE;
}
else {
this->fPTmasks.fCBA[0] = kFALSE;
}
AliDebug(5, Form("CBB/PT/MASK/CB-A_0=%d", this->fPTmasks.fCBA[0]));
return kTRUE;
}
else if (identifier.Index("CBB/PT/MASK/CB-A_1") == 0) {
if (value.Index("YES") == 0) {
this->fPTmasks.fCBA[1] = kTRUE;
}
else {
this->fPTmasks.fCBA[1] = kFALSE;
}
AliDebug(5, Form("CBB/PT/MASK/CB-A_1=%d", this->fPTmasks.fCBA[1]));
return kTRUE;
}
else if (identifier.Index("CBB/PT/MASK/CB-C_0") == 0) {
if (value.Index("YES") == 0) {
this->fPTmasks.fCBC[0] = kTRUE;
}
else {
this->fPTmasks.fCBC[0] = kFALSE;
}
AliDebug(5, Form("CBB/PT/MASK/CB-C_0=%d",this->fPTmasks.fCBC[0]));
return kTRUE;
}
else if (identifier.Index("CBB/PT/MASK/CB-C_1") == 0) {
if (value.Index("YES") == 0) {
this->fPTmasks.fCBC[1] = kTRUE;
}
else {
this->fPTmasks.fCBC[1] = kFALSE;
}
AliDebug(5, Form("CBB/PT/MASK/CB-C_1=%d", this->fPTmasks.fCBC[1]));
return kTRUE;
}
else if (identifier.Index("CBB/PT/MASK/CB-B_0") == 0) {
if (value.Index("YES") == 0) {
this->fPTmasks.fLUTs[0] = kTRUE;
}
else {
this->fPTmasks.fLUTs[0] = kFALSE;
}
AliDebug(5, Form("CBB/PT/MASK/CB-B_0=%d",this->fPTmasks.fLUTs[0]));
return kTRUE;
}
else if (identifier.Index("CBB/PT/MASK/CB-B_1") == 0) {
if (value.Index("YES") == 0) {
this->fPTmasks.fLUTs[1] = kTRUE;
}
else {
this->fPTmasks.fLUTs[1] = kFALSE;
}
AliDebug(5, Form("CBB/PT/MASK/CB-B_1/=%d", this->fPTmasks.fLUTs[1]));
return kTRUE;
}
else if (identifier.Index("CBB/PT/MASK/CB-B_2") == 0) {
if (value.Index("YES") == 0) {
this->fPTmasks.fLUTs[2] = kTRUE;
}
else {
this->fPTmasks.fLUTs[2] = kFALSE;
}
AliDebug(5, Form("CBB/PT/MASK/CB-B_2/=%d", this->fPTmasks.fLUTs[2]));
return kTRUE;
}
else if (identifier.Index("BB/PT/MASK/TLMU_") == 0) {
TString indexStr = identifier(16, 1);
Int_t index = indexStr.Atoi();
if (value.Index("YES") == 0) {
this->fPTmasks.fTLMU[index] = kTRUE;
}
else {
this->fPTmasks.fTLMU[index] = kFALSE;
}
AliDebug(5, Form("CBB/PT/MASK/TLMU_%d=%d", index,
this->fPTmasks.fTLMU[index]));
return kTRUE;
}
return kTRUE;
}
Bool_t AliTRDptrgParam::ParseTLMU(TString identifier, TString value) {
if (identifier.Index("TLMU/IMASK/SEC") == 0) {
TString indexStr = identifier(14,2);
Int_t index = indexStr.Atoi();
if ((index < 0) || (index > 17)) {
AliDebug(5, "Wrong section index in TLMU input mask");
return kFALSE;
}
this->fTLMUInputMask[index] = BinaryTStringToInt(value);
AliDebug(5, Form("%d %x\n", index, this->fTLMUInputMask[index]));
return kTRUE;
}
else if (identifier.Index("TLMU/CMATRIX") == 0) {
TString matrixIndexStr = identifier(12,1);
Int_t matrixIndex = matrixIndexStr.Atoi();
TString indexStr = identifier(17,2);
Int_t index = indexStr.Atoi();
this->fTLMUcmatrices[matrixIndex][index] = BinaryTStringToInt(value);
AliDebug(5, Form("%d 0x%x\n", matrixIndex,
this->fTLMUcmatrices[matrixIndex][index]));
return kTRUE;
}
else if (identifier.Index("TLMU/MCNTR") == 0) {
TString indexStr = identifier(10,1);
Int_t index = indexStr.Atoi();
TObjArray arr;
SplitUpValues(value, arr);
TObjString *ostrng0 = dynamic_cast<TObjString*>(arr[0]);
TObjString *ostrng1 = dynamic_cast<TObjString*>(arr[1]);
if (ostrng0 && ostrng1) {
TString t0 = ostrng0->GetString();
TString t1 = ostrng1->GetString();
this->fTLMUmultiplicity[index][0] = t0.Atoi();
this->fTLMUmultiplicity[index][1] = t1.Atoi();
AliDebug(5, Form("%d: %d %d", index, this->fTLMUmultiplicity[index][0],
this->fTLMUmultiplicity[index][1]));
}
return kTRUE;
}
else if (identifier.Index("TLMU/OUTMUX") == 0) {
TObjArray arr;
SplitUpValues(value, arr);
if (arr.GetEntries() > 8) {
AliError("Too many TLMU output signals assigned");
return kFALSE;
}
for (Int_t iEntry = 0; iEntry < arr.GetEntries(); iEntry++) {
TObjString *ostrng = dynamic_cast<TObjString*>(arr[iEntry]);
if (ostrng) {
TString t = ostrng->GetString();
TString indexStr = t(2,1);
if (t.Index("CM") == 0) {
this->fTLMUoutput[iEntry][0] = indexStr.Atoi();
}
else if (t.Index("MC") == 0) {
this->fTLMUoutput[iEntry][1] = indexStr.Atoi();
}
}
AliDebug(5, Form("TLMU output: cm = %d, mc = %d",
this->fTLMUoutput[iEntry][0],
this->fTLMUoutput[iEntry][1]));
}
return kTRUE;
}
return kTRUE;
}
Int_t AliTRDptrgParam::LookUp(TString* const identifier) const {
if (identifier->CompareTo("T0_0", TString::kIgnoreCase) == 0)
return 0x001;
else if (identifier->CompareTo("T0_1", TString::kIgnoreCase) == 0)
return 0x002;
else if (identifier->CompareTo("V0-0_0", TString::kIgnoreCase) == 0)
return 0x004;
else if (identifier->CompareTo("V0-0_1", TString::kIgnoreCase) == 0)
return 0x008;
else if (identifier->CompareTo("V0-1_0", TString::kIgnoreCase) == 0)
return 0x010;
else if (identifier->CompareTo("V0-1_1", TString::kIgnoreCase) == 0)
return 0x020;
else if (identifier->CompareTo("V0-2_0", TString::kIgnoreCase) == 0)
return 0x040;
else if (identifier->CompareTo("V0-2_1", TString::kIgnoreCase) == 0)
return 0x080;
else if (identifier->CompareTo("V0-3_0", TString::kIgnoreCase) == 0)
return 0x100;
else if (identifier->CompareTo("V0-3_1", TString::kIgnoreCase) == 0)
return 0x200;
else if (identifier->CompareTo("CB-A_0", TString::kIgnoreCase) == 0)
return 0x001;
else if (identifier->CompareTo("CB-A_1", TString::kIgnoreCase) == 0)
return 0x002;
else if (identifier->CompareTo("CB-C_0", TString::kIgnoreCase) == 0)
return 0x004;
else if (identifier->CompareTo("CB-C_1", TString::kIgnoreCase) == 0)
return 0x008;
else if (identifier->CompareTo("TLMU_0", TString::kIgnoreCase) == 0)
return 0x010;
else if (identifier->CompareTo("TLMU_1", TString::kIgnoreCase) == 0)
return 0x020;
else if (identifier->CompareTo("TLMU_2", TString::kIgnoreCase) == 0)
return 0x040;
else if (identifier->CompareTo("TLMU_3", TString::kIgnoreCase) == 0)
return 0x080;
else if (identifier->CompareTo("TLMU_4", TString::kIgnoreCase) == 0)
return 0x100;
else if (identifier->CompareTo("TLMU_5", TString::kIgnoreCase) == 0)
return 0x200;
else if (identifier->CompareTo("TLMU_6", TString::kIgnoreCase) == 0)
return 0x400;
else if (identifier->CompareTo("TLMU_7", TString::kIgnoreCase) == 0)
return 0x800;
else return 0x0;
}
void AliTRDptrgParam::MergeResults(TArrayI*& partResult1, TArrayI*& partResult2,
TArrayI*& results,
TArrayI*& signalsInvolved1,
TArrayI*& signalsInvolved2,
TArrayI*& signalsInvolved,
Bool_t useOR) {
if ((partResult1 == 0x0) || (partResult2 == 0x0) ||
(signalsInvolved1 == 0x0) || (signalsInvolved2 == 0x0)) {
AliError("fatal logical equation processing error!");
return;
}
results = new TArrayI(0);
signalsInvolved = new TArrayI(0);
for (Int_t i = 0; i < partResult1->GetSize(); i++) {
for (Int_t j = 0; j < partResult2->GetSize(); j++) {
results->Set(results->GetSize() + 1);
(*results)[results->GetSize() - 1] =
(*partResult1)[i] | (*partResult2)[j];
signalsInvolved->Set(signalsInvolved->GetSize() + 1);
(*signalsInvolved)[signalsInvolved->GetSize() - 1] =
(*signalsInvolved1)[i] | (*signalsInvolved2)[j];
}
}
if (useOR) {
for (Int_t i = 0; i < partResult1->GetSize(); i++) {
results->Set(results->GetSize() + 1);
(*results)[results->GetSize() - 1] = (*partResult1)[i];
signalsInvolved->Set(signalsInvolved->GetSize() + 1);
(*signalsInvolved)[signalsInvolved->GetSize()-1] = (*signalsInvolved1)[i];
}
for (Int_t i = 0; i < partResult2->GetSize(); i++) {
results->Set(results->GetSize() + 1);
(*results)[results->GetSize() - 1] = (*partResult2)[i];
signalsInvolved->Set(signalsInvolved->GetSize() + 1);
(*signalsInvolved)[signalsInvolved->GetSize()-1] = (*signalsInvolved2)[i];
}
}
AliDebug(5, "merging results: ");
for (Int_t i = 0; i < results->GetSize(); i++) {
AliDebug(5, Form("0x%x 0x%x", (*results)[i], (*signalsInvolved)[i]));
}
delete partResult1;
partResult1 = 0x0;
delete partResult2;
partResult2 = 0x0;
}
void AliTRDptrgParam::ConvertLogicalEqToBitVectors(TString eq,
TArrayI*& results,
TArrayI*& signalsInvolved) {
AliDebug(5, Form("eq: %s", eq.Data()));
TArrayI* partResult1 = 0x0;
TArrayI* partResult2 = 0x0;
TArrayI* partResult3 = 0x0;
TArrayI* partResult4 = 0x0;
TArrayI* signalsInvolved1 = 0x0;
TArrayI* signalsInvolved2 = 0x0;
TArrayI* signalsInvolved3 = 0x0;
TArrayI* signalsInvolved4 = 0x0;
Int_t iChar = 0;
Int_t foundORbefore = -1;
Int_t foundAND = -1;
Int_t foundORafter = -1;
Int_t enteredBrackets = 0;
Int_t bracketLevelAtZero = -1;
while ((iChar < eq.Length())) {
if ((enteredBrackets == 0 ) && (eq[iChar] != '(') && (eq[iChar] != ')')) {
if (eq[iChar] == '|') {
if (eq[iChar + 1] == '|') {
iChar++;
if (foundAND == -1) {
foundORbefore = iChar;
}
else if ((foundORafter == -1) && (foundAND != -1)) {
foundORafter = iChar;
}
}
else {
AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
AliError("bit-wise AND (&) not supported for now");
return;
}
}
else if (eq[iChar] == '&') {
if (eq[iChar] == '&') {
iChar++;
if (foundAND == -1) {
foundAND = iChar;
}
}
else {
AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
AliError("bit-wise OR (|) not supported for now");
return;
}
}
}
if (eq[iChar] == '(') {
enteredBrackets++;
}
else if (eq[iChar] == ')') {
enteredBrackets--;
if (enteredBrackets < 0) {
AliError(Form("LogicalEquation incorrect: %s", eq.Data()));
AliError("Too many )s");
}
if ((enteredBrackets == 0) && (bracketLevelAtZero == -1) &&
(foundAND == -1) && (foundORbefore == -1)) {
bracketLevelAtZero = iChar;
}
}
iChar++;
}
if (bracketLevelAtZero == (eq.Length() - 1)) {
ConvertLogicalEqToBitVectors(eq(1, eq.Length() -2), results,
signalsInvolved);
return;
}
else if (foundAND == -1) {
if (foundORbefore != -1) {
ConvertLogicalEqToBitVectors(eq(0, foundORbefore-1), partResult1,
signalsInvolved1);
ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
eq.Length()-foundORbefore-1),
partResult2, signalsInvolved2);
MergeResults(partResult1, partResult2, results, signalsInvolved1,
signalsInvolved2, signalsInvolved, kTRUE);
return;
}
else {
results = new TArrayI(1);
signalsInvolved = new TArrayI(1);
if (eq[0] != '!') {
(*results)[0] = LookUp(&eq);
(*signalsInvolved)[0] = (*results)[0];
}
else {
(*results)[0] = 0;
TString eqNegated = eq(1, eq.Length()-1);
(*signalsInvolved)[0] = LookUp(&eqNegated);
}
return;
}
}
else if ((foundORafter != -1) && (foundORbefore != -1)) {
ConvertLogicalEqToBitVectors(eq(0, foundORbefore-1), partResult1,
signalsInvolved1);
ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
foundORafter-foundORbefore-2),
partResult2, signalsInvolved2);
ConvertLogicalEqToBitVectors(eq(foundORafter+1, eq.Length()-foundORafter-1),
partResult3, signalsInvolved3);
MergeResults(partResult1, partResult2, partResult4, signalsInvolved1,
signalsInvolved2, signalsInvolved4, kTRUE);
MergeResults(partResult3, partResult4, results, signalsInvolved3,
signalsInvolved4, signalsInvolved, kTRUE);
return;
}
else if (foundORbefore != -1) {
ConvertLogicalEqToBitVectors(eq(0, foundORbefore - 1), partResult1,
signalsInvolved1);
ConvertLogicalEqToBitVectors(eq(foundORbefore+1,
eq.Length()-foundORbefore-1),
partResult2, signalsInvolved2);
MergeResults(partResult1, partResult2, results, signalsInvolved1,
signalsInvolved2, signalsInvolved, kTRUE);
return;
}
else if (foundORafter != -1) {
ConvertLogicalEqToBitVectors(eq(0, foundORafter - 1), partResult1,
signalsInvolved1);
ConvertLogicalEqToBitVectors(eq(foundORafter+1,
eq.Length()-foundORafter-1),
partResult2, signalsInvolved2);
MergeResults(partResult1, partResult2, results, signalsInvolved1,
signalsInvolved2, signalsInvolved, kTRUE);
return;
}
else {
ConvertLogicalEqToBitVectors(eq(0, foundAND-1), partResult1,
signalsInvolved1);
ConvertLogicalEqToBitVectors(eq(foundAND+1, eq.Length()-foundAND-1),
partResult2, signalsInvolved2);
MergeResults(partResult1, partResult2, results, signalsInvolved1,
signalsInvolved2, signalsInvolved, kFALSE);
return;
}
AliError("Logical equation parser error!");
return;
}
void AliTRDptrgParam::CheckSignalsInvolved(TArrayI*& results,
TArrayI*& signalsInvolved,
Int_t inputWidth) {
Int_t temp = 0x1;
Int_t mask = 0x0;
for (Int_t iSignal = 0; iSignal < inputWidth; iSignal++) {
mask |= temp;
temp <<= 1;
}
for (Int_t iResult = 0; iResult < results->GetSize(); iResult++) {
if (mask != (*signalsInvolved)[iResult]) {
Int_t inputSignal = 0x1;
for (Int_t iSignal = 0; iSignal < inputWidth; iSignal++) {
if (!(inputSignal & (*signalsInvolved)[iResult])) {
Int_t newInvolvedSignalCombination =
(*signalsInvolved)[iResult] | inputSignal;
Int_t newResult = inputSignal | (*results)[iResult];
Bool_t signalCombinationAlreadyEnlisted = kFALSE;
for (Int_t iEntry = 0; iEntry < signalsInvolved->GetSize(); iEntry++){
if ((signalsInvolved->At(iEntry) == newInvolvedSignalCombination) &&
(results->At(iEntry) == newResult)) {
signalCombinationAlreadyEnlisted = kTRUE;
break;
}
}
if (!signalCombinationAlreadyEnlisted) {
results->Set(results->GetSize() + 1);
(*results)[results->GetSize() - 1] = inputSignal |
(*results)[iResult];
signalsInvolved->Set(signalsInvolved->GetSize() + 1);
(*signalsInvolved)[signalsInvolved->GetSize() - 1] =
(*signalsInvolved)[iResult] | inputSignal;
}
}
inputSignal <<= 1;
}
}
}
return;
}
Int_t* AliTRDptrgParam::GenerateLUTbasedOnEq(TString eq, Int_t inputWidth,
Int_t initValue) {
TArrayI* results = 0x0;
TArrayI* signalsInvolved = 0x0;
ConvertLogicalEqToBitVectors(eq, results, signalsInvolved);
if ((results != 0x0) && (signalsInvolved != 0x0)) {
CheckSignalsInvolved(results, signalsInvolved, inputWidth);
Int_t lutSize = 0x1 << inputWidth;
Int_t* resultingLUT = new Int_t[lutSize];
for (Int_t iLUTentry = 0; iLUTentry < lutSize; iLUTentry++) {
resultingLUT[iLUTentry] = 0;
}
for (Int_t iEntry = 0; iEntry < results->GetSize(); iEntry++) {
resultingLUT[(*results)[iEntry]] = initValue;
}
delete results;
results = 0x0;
delete signalsInvolved;
signalsInvolved = 0x0;
return resultingLUT;
}
else {
return 0x0;
}
}
UInt_t* AliTRDptrgParam::GetFEBT0Thresholds(AliTRDptrgFEBPosition_t FEBposition)
const
{
return this->fFEBT0Thresholds[FEBposition - 1];
}
Int_t* AliTRDptrgParam::GetFEBT0LUT(AliTRDptrgFEBPosition_t FEBposition,
Int_t iLUT) {
if (this->fFEBT0LUTs == 0x0) {
this->GenerateLUTs();
}
return this->fFEBT0LUTs[FEBposition - 1][iLUT];
}
UInt_t* AliTRDptrgParam::GetFEBV0Thresholds(AliTRDptrgFEBPosition_t FEBposition,
Int_t iCard) const {
return this->fFEBV0Thresholds[FEBposition - 1][iCard];
}
Int_t* AliTRDptrgParam::GetFEBV0LUT(AliTRDptrgFEBPosition_t FEBposition,
Int_t iCard, Int_t iLUT) {
if (this->fFEBV0LUTs == 0x0) {
this->GenerateLUTs();
}
return this->fFEBV0LUTs[FEBposition - 1][iCard][iLUT];
}
Int_t* AliTRDptrgParam::GetCBLUT(UInt_t iCB, Int_t LUTid) {
if (this->fCBLUTs == 0x0) {
this->GenerateLUTs();
}
return this->fCBLUTs[iCB][LUTid];
}