]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDptrgParam.cxx
update comments, add some possible TODOs
[u/mrichter/AliRoot.git] / TRD / AliTRDptrgParam.cxx
index 56cd4a06fec5bdb84978e1294b32e762532ef8ab..59675b04586d2925a24cd71e8537008fbc0020dc 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "AliTRDptrgParam.h"
 
+using std::ifstream;
 ClassImp(AliTRDptrgParam)
 
 AliTRDptrgParam *AliTRDptrgParam::fgInstance = 0;
@@ -58,12 +59,6 @@ AliTRDptrgParam::AliTRDptrgParam()
     fFEBV0Multiplicities(0x0),
     fFEBV0LUTs(0x0),
     fCBLUTs(0x0),
-    fCBALUTequX(TString()),
-    fCBALUTequY(TString()),
-    fCBCLUTequX(TString()),
-    fCBCLUTequY(TString()),
-    fCBBLUTequX(TString()),
-    fCBBLUTequY(TString()),
     fPTmasks(AliTRDptrgPTmasks())
 {
   // ctor
@@ -332,6 +327,13 @@ AliTRDptrgParam::~AliTRDptrgParam()
             this->fCBLUTs[iCB][iLUT] = 0x0;
           }
        }
+        if (iCB == kB) {
+          // CB-B has 3 LUTs!
+          if (this->fCBLUTs[iCB][2] != 0x0) {
+            delete[] this->fCBLUTs[iCB][2];
+            this->fCBLUTs[iCB][2] = 0x0;
+          }
+        }
         delete[] this->fCBLUTs[iCB];
        this->fCBLUTs[iCB] = 0x0;
       }
@@ -382,7 +384,7 @@ Int_t AliTRDptrgParam::CheckVariables() const
     return -6;
   }
 
-  // delete T0 FEB thresholds
+  // check T0 FEB thresholds
   if (this->fFEBT0Thresholds != 0x0) {
     if (this->fFEBT0Thresholds[0] == 0x0) {
       return -7;
@@ -395,7 +397,7 @@ Int_t AliTRDptrgParam::CheckVariables() const
     return -9;
   }
 
-  // delete T0 multiplicities
+  // check T0 multiplicities
   if (this->fFEBT0Multiplicities != 0x0) {
     for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
       if (this->fFEBT0Multiplicities[iPosition] != 0x0) {
@@ -415,7 +417,7 @@ Int_t AliTRDptrgParam::CheckVariables() const
   }
   
 
-  // delete T0 LUTs
+  // check T0 LUTs
   if (this->fFEBT0LUTs != 0x0) {
     for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
       if (this->fFEBT0LUTs[iPosition] != 0x0) {
@@ -434,7 +436,7 @@ Int_t AliTRDptrgParam::CheckVariables() const
     return -15;
   }
 
-  // delete V0 FEB thresholds
+  // check V0 FEB thresholds
   if (this->fFEBV0Thresholds != 0x0) {
     for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
       if (this->fFEBV0Thresholds[iPosition] != 0x0) {
@@ -453,7 +455,7 @@ Int_t AliTRDptrgParam::CheckVariables() const
     return -18;
   }
 
-  // delete V0 multiplicities
+  // check V0 multiplicities
   if (this->fFEBV0Multiplicities != 0x0) {
     for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
       if (this->fFEBV0Multiplicities[iPosition] != 0x0) {
@@ -479,7 +481,7 @@ Int_t AliTRDptrgParam::CheckVariables() const
     return -22;
   }
 
-  // delete V0 LUTs
+  // check V0 LUTs
   if (this->fFEBV0LUTs != 0x0) {
     for (UInt_t iPosition = 0; iPosition < 2; iPosition++) {
       if (this->fFEBV0LUTs[iPosition] != 0x0) {
@@ -505,7 +507,7 @@ Int_t AliTRDptrgParam::CheckVariables() const
     return -26;
   }
 
-  // delete CB LUTs
+  // check CB LUTs
   if (this->fCBLUTs != 0x0) {
     for (UInt_t iCB = 0; iCB < 3; iCB++) {
       if (this->fCBLUTs[iCB] != 0x0) {
@@ -514,14 +516,19 @@ Int_t AliTRDptrgParam::CheckVariables() const
             return -27;
           }
        }
+        if (iCB == kB) {
+          if (this->fCBLUTs[iCB][2] == 0x0) {
+            return -28;
+          }
+        }
       }
       else {
-        return -28;
+        return -29;
       }
     }
   }  
   else {
-    return -29;
+    return -30;
   }
   return 0;
 }
@@ -636,7 +643,7 @@ void AliTRDptrgParam::LoadStandardConfiguration() {
   this->fTLMUmultiplicity[6][1] = 400;
   this->fTLMUmultiplicity[7][0] = 400;
   this->fTLMUmultiplicity[7][1] = 576;
-  this->fTLMUmultiplicity[8][0] = 100;
+  this->fTLMUmultiplicity[8][0] = 1;
   this->fTLMUmultiplicity[8][1] = 576;
  
   // TLMU output
@@ -693,23 +700,25 @@ void AliTRDptrgParam::LoadStandardConfiguration() {
   }
 
   // CB-A LUT equations
-  this->fCBALUTequX = "T0_0 || (V0-0_0 || V0-1_0 || V0-2_0 || V0-3_0)";
-  this->fCBALUTequY = "!T0_1 && !V0-0_1 && !V0-1_1 && !V0-2_1 && !V0-3_1";
+  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";
 
   // CB-C LUT equations
-  this->fCBCLUTequX = "T0_0 || ( V0-0_0 || V0-1_0 || V0-2_0 || V0-3_0 )";
-  this->fCBCLUTequY = "!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";
 
   // CB-B LUT equations
-  this->fCBBLUTequX = "( CB-A_1 || CB-C_1 ) && TLMU_7";
-  this->fCBBLUTequY = "( CB-A_1 || CB-C_1 ) && TLMU_7";
+  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";
 
   // PT output mask
   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 < 8; i++) {
+  for (Int_t i = 1; i < 7; i++) {
     this->fPTmasks.fTLMU[i] = kTRUE;
   }
 
@@ -858,40 +867,47 @@ Int_t AliTRDptrgParam::GenerateLUTs() {
   // initialize LUTs
   this->fCBLUTs = new Int_t**[3];
   for (Int_t iCB = 0; iCB < 3; iCB++) {
-    this->fCBLUTs[iCB] = new Int_t*[2];
-    this->fCBLUTs[iCB][0] = 0x0;
-    this->fCBLUTs[iCB][1] = 0x0;
+    if (iCB == kB) { // B
+      fCBLUTs[iCB] = new Int_t*[3];
+      this->fCBLUTs[iCB][0] = 0x0;
+      this->fCBLUTs[iCB][1] = 0x0;
+      this->fCBLUTs[iCB][2] = 0x0;
+    }
+    else { // A + C
+      fCBLUTs[iCB] = new Int_t*[2];
+      this->fCBLUTs[iCB][0] = 0x0;
+      this->fCBLUTs[iCB][1] = 0x0;
+    }
   }
   
   // CB-A (CB = 1 / kA)
-  this->fCBLUTs[1][0] = this->GenerateLUTbasedOnEq(this->fCBALUTequX, 10, 1);
-  for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
-    AliDebug(10, Form("fCBLUTs[@A][0]=%d", this->fCBLUTs[1][0]));
-  }
-  this->fCBLUTs[1][1] = this->GenerateLUTbasedOnEq(this->fCBALUTequY, 10, 1);
-  for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
-    AliDebug(10, Form("fCBLUTs[@A][1]=%d", this->fCBLUTs[1][1]));
+  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]));
+    }
   }
 
   // CB-C (CB = 2 / kC)
-  this->fCBLUTs[2][0] = this->GenerateLUTbasedOnEq(this->fCBCLUTequX, 10, 1);
-  for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
-    AliDebug(6, Form("fCBLUTs[@C][0]=%d", this->fCBLUTs[2][0]));
-  }
-  this->fCBLUTs[2][1] = this->GenerateLUTbasedOnEq(this->fCBCLUTequY, 10, 1);
-  for (Int_t iEntry = 0; iEntry < 1024; iEntry++) {
-    AliDebug(10, Form("fCBLUTs[@C][1]=%d", this->fCBLUTs[2][0]));
-  }
+  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]));
+    }
+  }  
  
   // CB-B (CB = 0 / kB)
-  this->fCBLUTs[0][0] = this->GenerateLUTbasedOnEq(this->fCBALUTequX, 12, 1);
-  for (Int_t iEntry = 0; iEntry < 4096; iEntry++) {
-    AliDebug(10, Form("fCBLUTs[@B][0]=%d", this->fCBLUTs[0][0]));
-  }
-  this->fCBLUTs[0][1] = this->GenerateLUTbasedOnEq(this->fCBALUTequY, 12, 1);
-  
-  for (Int_t iEntry = 0; iEntry < 4096; iEntry++) {
-    AliDebug(10, Form("fCBLUTs[@B][1]=%d", this->fCBLUTs[0][1]));
+  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!");
@@ -1005,7 +1021,7 @@ void AliTRDptrgParam::SplitUpValues(TString value, TObjArray& arr) {
       }
     }
   }
-  if (temp.Length() != 0) { // TODO
+  if (temp.Length() != 0) {
     TObjString* t = new TObjString(temp.Data());
     arr.Add(t);         
   }
@@ -1048,7 +1064,7 @@ Bool_t AliTRDptrgParam::ParseMultiplicityCondition(TString condition,
     maskStr += condition[iLetter++];
   }
   (*mask) = BinaryTStringToInt(maskStr);
-  if ((*mask) == 0) { // TODO find a better method to detected parser errors
+  if ((*mask) == 0) { 
     AliDebug(5, Form("Invalid input mask: %s,[%s]", maskStr.Data(), 
                       condition.Data()));
     return kFALSE;
@@ -1091,8 +1107,10 @@ Bool_t AliTRDptrgParam::ParseFEB(TString identifier, TString value) {
       return kFALSE; 
     }
     for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
-      this->fFEBT0Thresholds[0][iValue] =  
-        (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
+      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])); 
     }
@@ -1112,8 +1130,10 @@ Bool_t AliTRDptrgParam::ParseFEB(TString identifier, TString value) {
       return kFALSE; 
     }
     for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
-      this->fFEBT0Thresholds[1][iValue] =  
-        (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
+      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])); 
     }
@@ -1139,8 +1159,11 @@ Bool_t AliTRDptrgParam::ParseFEB(TString identifier, TString value) {
       return kFALSE; 
     }
     for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
-      this->fFEBV0Thresholds[0][cardID][iValue] =  
-        (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
+      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])); 
     }
@@ -1165,8 +1188,10 @@ Bool_t AliTRDptrgParam::ParseFEB(TString identifier, TString value) {
       return kFALSE; 
     }
     for (Int_t iValue = 0; iValue < arr.GetEntries(); iValue++) {
-      this->fFEBV0Thresholds[1][cardID][iValue] =  
-        (dynamic_cast<TObjString*>(arr[iValue])->GetString()).Atoi();
+      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])); 
     }
@@ -1272,13 +1297,9 @@ Bool_t AliTRDptrgParam::ParseCBAC(TString identifier, TString value) {
     TString eqIDstr = identifier(8, 1);
     Int_t eqID = eqIDstr.Atoi();
    
-    if (eqID == 0) {
-      this->fCBALUTequX = this->CleanTString(value);
-      AliDebug(5, Form("fCBALUTequX=%s", this->fCBALUTequX.Data())); 
-    }
-    else if(eqID == 1) {
-      this->fCBALUTequY= this->CleanTString(value);
-      AliDebug(5, Form("fCBALUTequY=%s", this->fCBALUTequY.Data()));
+    if ((eqID == 0) || (eqID == 1)) {
+      this->fCBALUTequ[eqID] = this->CleanTString(value);
+      AliDebug(5, Form("fCBALUTequ[%d]=%s", eqID, this->fCBALUTequ[eqID].Data())); 
     }
     return kTRUE;    
   }
@@ -1289,14 +1310,11 @@ Bool_t AliTRDptrgParam::ParseCBAC(TString identifier, TString value) {
     TString eqIDstr = identifier(8, 1);
     Int_t eqID = eqIDstr.Atoi();
    
-    if (eqID == 0) {
-      this->fCBCLUTequX = this->CleanTString(value);
-      AliDebug(5, Form("fCBCLUTequX=%s", this->fCBCLUTequX.Data()));
+    if ((eqID == 0) || (eqID == 1)) {
+      this->fCBCLUTequ[eqID] = this->CleanTString(value);
+      AliDebug(5, Form("fCBCLUTequ[%d]=%s", eqID, this->fCBCLUTequ[eqID].Data()));
     }
-    else if(eqID == 1) {
-      this->fCBCLUTequY= this->CleanTString(value);
-      AliDebug(5, Form("fCBCLUTequY=%s", this->fCBCLUTequY.Data()));
-    }    
+    return kTRUE;
   }
 
   return kTRUE;
@@ -1312,14 +1330,10 @@ Bool_t AliTRDptrgParam::ParseCBB(TString identifier, TString value) {
     TString eqIDstr = identifier(8, 1);
     Int_t eqID = eqIDstr.Atoi();
    
-    if (eqID == 0) {
-      this->fCBBLUTequX = this->CleanTString(value);
-      AliDebug(5, Form("fCBBLUTequX=%s", this->fCBBLUTequX.Data()));
-    }
-    else if(eqID == 1) {
-      this->fCBBLUTequY= this->CleanTString(value);
-      AliDebug(5, Form("fCBBLUTequY=%s", this->fCBBLUTequY.Data()));
-    }    
+    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;
   }
   
@@ -1384,6 +1398,16 @@ Bool_t AliTRDptrgParam::ParseCBB(TString identifier, TString value) {
     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) { // CB-B_2
+    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();
@@ -1443,14 +1467,21 @@ Bool_t AliTRDptrgParam::ParseTLMU(TString identifier, TString value) {
 
     SplitUpValues(value, arr);
     
-    TString t0 = (dynamic_cast<TObjString*>(arr[0]))->GetString();
-    TString t1 = (dynamic_cast<TObjString*>(arr[1]))->GetString();
+    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();
+      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]));      
+      AliDebug(5, Form("%d: %d  %d", index, this->fTLMUmultiplicity[index][0], 
+                       this->fTLMUmultiplicity[index][1]));      
+
+    }
 
     return kTRUE;
   }
@@ -1467,15 +1498,22 @@ Bool_t AliTRDptrgParam::ParseTLMU(TString identifier, TString value) {
     } 
   
     for (Int_t iEntry = 0; iEntry < arr.GetEntries(); iEntry++) {
-      TString t = (dynamic_cast<TObjString*>(arr[iEntry]))->GetString(); 
+
+      TObjString *ostrng = dynamic_cast<TObjString*>(arr[iEntry]);
+      if (ostrng) {
+
+        TString t = ostrng->GetString(); 
       
-      TString indexStr = t(2,1);
-      if (t.Index("CM") == 0) { // coincidence matrix
-        this->fTLMUoutput[iEntry][0] = indexStr.Atoi();
-      }
-      else if (t.Index("MC") == 0) { // multiplicity
-        this->fTLMUoutput[iEntry][1] = indexStr.Atoi();
+        TString indexStr = t(2,1);
+        if (t.Index("CM") == 0) { // coincidence matrix
+          this->fTLMUoutput[iEntry][0] = indexStr.Atoi();
+        }
+        else if (t.Index("MC") == 0) { // multiplicity
+          this->fTLMUoutput[iEntry][1] = indexStr.Atoi();
+        }
+
       }
+
       AliDebug(5, Form("TLMU output: cm = %d, mc = %d", 
                        this->fTLMUoutput[iEntry][0], 
                        this->fTLMUoutput[iEntry][1]));
@@ -1540,7 +1578,7 @@ Int_t AliTRDptrgParam::LookUp(TString* const identifier) const {
   else if (identifier->CompareTo("TLMU_6", TString::kIgnoreCase) == 0) 
     return 0x400; 
   else if (identifier->CompareTo("TLMU_7", TString::kIgnoreCase) == 0) 
-    return 0x100; 
+    return 0x800; 
   else return 0x0; // Error
 }
 
@@ -1558,6 +1596,7 @@ void AliTRDptrgParam::MergeResults(TArrayI*& partResult1, TArrayI*& partResult2,
   if ((partResult1 == 0x0) || (partResult2 == 0x0) || 
       (signalsInvolved1 == 0x0) || (signalsInvolved2 == 0x0)) {
     AliError("fatal logical equation processing error!");
+    return;
   }
  
   // allocate results and signalsInvolved 
@@ -1867,29 +1906,36 @@ Int_t* AliTRDptrgParam::GenerateLUTbasedOnEq(TString eq, Int_t inputWidth,
  
   ConvertLogicalEqToBitVectors(eq, results, signalsInvolved);
   // generate bit vectors
+  
+  if ((results != 0x0) && (signalsInvolved != 0x0)) {
 
-  CheckSignalsInvolved(results, signalsInvolved, inputWidth);
-  // add bit vectors for signals which are not taken into account
+    CheckSignalsInvolved(results, signalsInvolved, inputWidth);
+    // add bit vectors for signals which are not taken into account
 
-  Int_t lutSize =  0x1 << inputWidth; // 2^inputwidth elements
-  Int_t* resultingLUT = new Int_t[lutSize]; // create LUT
-  for (Int_t iLUTentry = 0; iLUTentry < lutSize; iLUTentry++) { // init LUT
-    resultingLUT[iLUTentry] = 0;
-  }
-  for (Int_t iEntry = 0; iEntry < results->GetSize(); iEntry++) {
-    resultingLUT[(*results)[iEntry]] = initValue;
-  }
+    Int_t lutSize =  0x1 << inputWidth; // 2^inputwidth elements
+    Int_t* resultingLUT = new Int_t[lutSize]; // create LUT
+    for (Int_t iLUTentry = 0; iLUTentry < lutSize; iLUTentry++) { // init LUT
+      resultingLUT[iLUTentry] = 0;
+    }
+    for (Int_t iEntry = 0; iEntry < results->GetSize(); iEntry++) {
+      resultingLUT[(*results)[iEntry]] = initValue;
+    }
   
-  if (results != 0x0) {
     delete results;
     results = 0x0;
-  }
-  if (signalsInvolved != 0x0) {
+
     delete signalsInvolved;
     signalsInvolved = 0x0;
-  }
   
-  return resultingLUT;
+    return resultingLUT;
+
+  }
+  else {
+
+    return 0x0;
+
+  }
+
 }
 
 //______________________________________________________________________________