]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALTriggerSTURawStream.cxx
composition of the Alluminum alloy that constitutes the ITS-TPC support rings updated...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTriggerSTURawStream.cxx
index b002e11774d075bfc4f2e0f33acc2808af1634e2..a1e04eccae3e594db155d8d851fd2d0ff88dbf01 100644 (file)
@@ -33,59 +33,85 @@ Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
 
 namespace
 {
-       const Int_t kPayLoadSizeOld     = 236;
-       const Int_t kPayLoadSizeNew     = 245;
+       const Int_t kPayLoadSizeV0     = 236;
+       const Int_t kPayLoadSizeV1     = 245;        
+       const Int_t kPayLoadSizeV2     = 390;        
 }
 
+using std::cout;
+using std::setw;
+using std::endl;
 ClassImp(AliEMCALTriggerSTURawStream)
 
 //_____________________________________________________________________________
 AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream() : TObject(),
 fRawReader(0x0),
-fL1JetThreshold(0),
-fL1GammaThreshold(0),
+fL1JetThreshold(),
+fL1GammaThreshold(),
 fL0GammaPatchIndex(),
 fL1GammaPatchIndex(),
 fL1JetPatchIndex(),
 fNL0GammaPatch(0),
-fNL1JetPatch(0),
-fNL1GammaPatch(0),
+fNL1JetPatch(),
+fNL1GammaPatch(),
 fGetRawData(0),
 fV0A(0),
 fV0C(0),
-fGA(0),
-fGB(0),
-fGC(0),
-fJA(0),
-fJB(0),
-fJC(0),
+fG(),
+fJ(),
 fRegionEnable(0),
 fFrameReceived(0),
 fFwVersion(0)
 {
        //
+       for (int i = 0; i < 2; i++) {
+               //
+               fL1JetThreshold[i] = fL1GammaThreshold[i] = 0;
+               
+               fNL1JetPatch[i] = fNL1GammaPatch[i] = 0;
+       }
+       
+       for (int i = 0; i < 3; i++) {
+               for (int j = 0; j < 2; j++) {
+                       //
+                       fG[i][j] = fJ[i][j] = 0;
+               }
+       }
+       
+       for (int i = 0; i < 3100; i++) {
+               //
+               fL0GammaPatchIndex[i] = 0;
+               
+               for (int j = 0; j < 2; j++) {
+                       
+                       fL1GammaPatchIndex[i][j] = 0;
+               }
+       }
+       
+       for (int i = 0; i < 200; i++) {
+               for (int j = 0; j < 2; j++) {
+                       
+                       fL1JetPatchIndex[i][j] = 0;
+               }
+       }
 }
 
 //_____________________________________________________________________________
 AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream(AliRawReader* rawReader) : TObject(),
 fRawReader(rawReader),
-fL1JetThreshold(0),
-fL1GammaThreshold(0),
+fL1JetThreshold(),
+fL1GammaThreshold(),
 fL0GammaPatchIndex(),
 fL1GammaPatchIndex(),
 fL1JetPatchIndex(),
 fNL0GammaPatch(0),
-fNL1JetPatch(0),
-fNL1GammaPatch(0),
+fNL1JetPatch(),
+fNL1GammaPatch(),
 fGetRawData(0),
 fV0A(0),
 fV0C(0),
-fGA(0),
-fGB(0),
-fGC(0),
-fJA(0),
-fJB(0),
-fJC(0),
+fG(),
+fJ(),
 fRegionEnable(0),
 fFrameReceived(0),
 fFwVersion(0)
@@ -93,6 +119,37 @@ fFwVersion(0)
        //
        fRawReader->Reset();
        fRawReader->Select("EMCAL",44);
+       //
+       for (int i = 0; i < 2; i++) {
+               //
+               fL1JetThreshold[i] = fL1GammaThreshold[i] = 0;
+               
+               fNL1JetPatch[i] = fNL1GammaPatch[i] = 0;
+       }
+       
+       for (int i = 0; i < 3; i++) {
+               for (int j = 0; j < 2; j++) {
+                       //
+                       fG[i][j] = fJ[i][j] = 0;
+               }
+       }
+       
+       for (int i = 0; i < 3100; i++) {
+               //
+               fL0GammaPatchIndex[i] = 0;
+               
+               for (int j = 0; j < 2; j++) {
+                       
+                       fL1GammaPatchIndex[i][j] = 0;
+               }
+       }
+       
+       for (int i = 0; i < 200; i++) {
+               for (int j = 0; j < 2; j++) {
+                       
+                       fL1JetPatchIndex[i][j] = 0;
+               }
+       }
 }
 
 //_____________________________________________________________________________
@@ -109,8 +166,8 @@ void AliEMCALTriggerSTURawStream::Reset()
        if (fRawReader) fRawReader->Reset();
        
        fNL0GammaPatch = 0;
-       fNL1GammaPatch = 0;
-       fNL1JetPatch   = 0;     
+       fNL1GammaPatch[0] = fNL1GammaPatch[1] = 0;
+       fNL1JetPatch[0] = fNL1JetPatch[1] = 0;
 }
 
 //_____________________________________________________________________________
@@ -119,14 +176,14 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
        // STU data decoder from Olivier Bourrion LPSC CNRS-IN2P3
        // bourrion_at_lpsc_dot_in2p3_dot_fr
        
-       UInt_t word32[kPayLoadSizeNew + 1536]; // 32b words
-       for (Int_t i = 0;i < kPayLoadSizeNew + 1536; i++) word32[i] = 0;
+       UInt_t word32[kPayLoadSizeV2 + 1536]; // 32b words
+       for (Int_t i = 0;i < kPayLoadSizeV2 + 1536; i++) word32[i] = 0;
        
        Int_t iword = 0;
        
        fNL0GammaPatch = 0;
-       fNL1GammaPatch = 0;
-       fNL1JetPatch   = 0;
+       fNL1GammaPatch[0] = fNL1GammaPatch[1] = 0;
+       fNL1JetPatch[0] = fNL1JetPatch[1] = 0;
        
        Int_t eqId = -1, eqSize = 0;
        
@@ -142,81 +199,131 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                
                word32[iword++] = w32;
        }
-       
-       if (iword != kPayLoadSizeOld && iword != kPayLoadSizeNew && iword != (kPayLoadSizeOld + 1536) && iword != (kPayLoadSizeNew + 1536))
+       if (iword != kPayLoadSizeV0 && iword != kPayLoadSizeV1 && iword != kPayLoadSizeV2 
+               && 
+               iword != (kPayLoadSizeV0 + 1536) && iword != (kPayLoadSizeV1 + 1536) && iword != (kPayLoadSizeV2 + 1536))
        {
                AliError(Form("STU payload (eqId: %d, eqSize: %d) doesn't match expected size! %d word32",
                                          eqId, eqSize, iword));
                return kFALSE;
        }
        
-       if (AliDebugLevel())
-       {
-               AliInfo(Form("STU (eqId: %d, eqSize: %d) payload size: %d word32",
+       AliDebug(1, Form("STU (eqId: %d, eqSize: %d) payload size: %d word32",
                                         eqId, eqSize, iword));
-       }
        
-       int offset = 0, jetSize = 2;
+       int offset = 1;//, jetSize = 2;
+       
+       int nthres = 1;
        
        switch (iword) 
        {
-               case kPayLoadSizeOld:
-               case kPayLoadSizeOld + 1536:
+               case kPayLoadSizeV0:
+               case kPayLoadSizeV0 + 1536:
                {
-                       fL1JetThreshold   = ((word32[0]>>16) & 0xFFF);
-                       fL1GammaThreshold =  (word32[0]      & 0xFFF);
+                       fL1JetThreshold[0]   = ((word32[0]>>16) & 0xFFFF);
+                       fL1GammaThreshold[0] =  (word32[0]      & 0xFFFF);
                        
                        break;
                }
-               case kPayLoadSizeNew:
-               case kPayLoadSizeNew + 1536:
+               case kPayLoadSizeV1:
+               case kPayLoadSizeV1 + 1536:
                {
-                       fV0A = ((word32[0]>>16) & 0xFFF);
-                       fV0C =  (word32[0]      & 0xFFF);
-                       
-                       UInt_t sV0 = fV0A + fV0C;
+                       fV0A = ((word32[0]>>16) & 0xFFFF);
+                       fV0C =  (word32[0]      & 0xFFFF);
                        
-                       fGA            = word32[1];
-                       fGB            = word32[2];
-                       fGC            = word32[3];
-                       fJA            = word32[4];
-                       fJB            = word32[5];
-                       fJC            = word32[6];             
+                       fG[0][0]       = word32[1];
+                       fG[1][0]       = word32[2];
+                       fG[2][0]       = word32[3];
+                       fJ[0][0]       = word32[4];
+                       fJ[1][0]       = word32[5];
+                       fJ[2][0]       = word32[6];             
                        fRegionEnable  = word32[7];
                        fFrameReceived = word32[8];
                        fFwVersion     = word32[9];
                        
-                       jetSize += (fFwVersion >> 16);
+                       fL1JetThreshold[0]   = GetThreshold(fJ[0][0], fJ[1][0], fJ[2][0], fV0A, fV0C);
+                       fL1GammaThreshold[0] = GetThreshold(fG[0][0], fG[1][0], fG[2][0], fV0A, fV0C); 
+                       
+                       offset = 10;
+                       
+                       break;
+               }
+               case kPayLoadSizeV2:
+               case kPayLoadSizeV2 + 1536:
+               {
+                       fV0A = ((word32[0]>>16) & 0xFFFF);
+                       fV0C =  (word32[0]      & 0xFFFF);
                        
-                       fL1JetThreshold   = fJA * sV0 * sV0 + fJB * sV0 + fJC;
-                       fL1GammaThreshold = fGA * sV0 * sV0 + fGB * sV0 + fGC;          
+                       fG[0][0]       = word32[1];
+                       fG[1][0]       = word32[2];
+                       fG[2][0]       = word32[3];
+                       fJ[0][0]       = word32[4];
+                       fJ[1][0]       = word32[5];
+                       fJ[2][0]       = word32[6];             
                        
-                       offset = 9;
+                       fG[0][1]       = word32[7];
+                       fG[1][1]       = word32[8];
+                       fG[2][1]       = word32[9];
+                       fJ[0][1]       = word32[10];
+                       fJ[1][1]       = word32[11];
+                       fJ[2][1]       = word32[12];            
+                       
+                       fRegionEnable  = word32[13];
+                       fFrameReceived = word32[14];
+                       fFwVersion     = word32[15];
+                       
+                       for (int i = 0; i < 2; i++) {
+                               //
+                               fL1JetThreshold[i]   = GetThreshold(fJ[0][i], fJ[1][i], fJ[2][i], fV0A, fV0C);
+                               fL1GammaThreshold[i] = GetThreshold(fG[0][i], fG[1][i], fG[2][i], fV0A, fV0C); 
+                       }
+                       
+                       offset = 16;                    
+                       
+                       nthres = 2;
                        
                        break;
                }
        }
        
+//     jetSize += (fFwVersion >> 16);
+       
        ///////////
        // START DECODING
        //////////
 
-       for (Int_t jet_row = 0; jet_row < 12 - (jetSize - 1); jet_row++)
-       {
-               UInt_t currentrow = word32[offset + 1 + jet_row];
+       for (int i = 0; i < nthres; i++) {
+               DecodeL1JetPatchIndexes(i, word32, offset);
                
-               for (Int_t jet_col = 0; jet_col < 15; jet_col++)
-               {
-                       if (currentrow & (1 << jet_col))
-                       {
-                               fNL1JetPatch++;
-                               
-                               fL1JetPatchIndex[fNL1JetPatch-1] = ((jet_row << 8) & 0xFF00) | (jet_col & 0xFF);
-                       }
-               }
+               offset += 11;
        }
+       
+       DecodeL0GammaPatchIndexes(word32, offset);
+       
+       offset += 96;
+       
+       for (int i = 0; i < nthres; i++) {
+               DecodeL1GammaPatchIndexes(i, word32, offset);   
                
+               offset += 128;
+       }
+       
+       if (iword == kPayLoadSizeV0 || iword == kPayLoadSizeV1 || iword == kPayLoadSizeV2) {
+               fGetRawData = 0;
+               return kTRUE;
+       }
+       
+       fGetRawData = 1;
+       
+       DecodeTRUADC(word32, offset);
        
+       return kTRUE;
+}
+
+//_____________________________________________________________________________
+void AliEMCALTriggerSTURawStream::DecodeL0GammaPatchIndexes(UInt_t *word32, const int offset)
+{
        //////////////////////////////////////////////////////////
        // index des L0                                         //
        //////////////////////////////////////////////////////////
@@ -229,11 +336,11 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
        {
                for (Int_t tru_num=0;tru_num<16;tru_num++)
                {
-                       truL0indexes[2*tru_num  ][index] = ( word32[offset + 12 + index * 16 + tru_num]        & 0xFFFF);
-                       truL0indexes[2*tru_num+1][index] = ((word32[offset + 12 + index * 16 + tru_num] >> 16) & 0xFFFF);
+                       truL0indexes[2*tru_num  ][index] = ( word32[offset + index * 16 + tru_num]        & 0xFFFF);
+                       truL0indexes[2*tru_num+1][index] = ((word32[offset + index * 16 + tru_num] >> 16) & 0xFFFF);
                }
        }
-
+       
        for (Int_t tru_num=0;tru_num<32;tru_num++) 
        {
                for (Int_t index=0;index<6;index++) 
@@ -243,7 +350,7 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                                if ((truL0indexes[tru_num][index] & (1 << bit_num)))
                                {
                                        Int_t idx = 12 * index + bit_num;
-                                                                               
+                                       
                                        fNL0GammaPatch++;
                                        
                                        fL0GammaPatchIndex[fNL0GammaPatch-1] = (((idx << 5) & 0x7E0) | (tru_num & 0x1F));
@@ -251,7 +358,36 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                        }
                }
        }
+}
+
+//_____________________________________________________________________________
+void AliEMCALTriggerSTURawStream::DecodeL1JetPatchIndexes(const int i, UInt_t *word32, const int offset)
+{
+       //////////////////////////////////////////////////////////
+       // index des L1 jet                                     //
+       //////////////////////////////////////////////////////////
+       
+       int jetSize = 2 + (fFwVersion >> 16);
+       
+       for (Int_t jet_row = 0; jet_row < 12 - (jetSize - 1); jet_row++)
+       {
+               UInt_t currentrow = word32[offset + jet_row];
+               
+               for (Int_t jet_col = 0; jet_col < 15; jet_col++)
+               {
+                       if (currentrow & (1 << jet_col))
+                       {
+                               fNL1JetPatch[i] = fNL1JetPatch[i] + 1;
+                               
+                               fL1JetPatchIndex[fNL1JetPatch[i] - 1][i] = ((jet_row << 8) & 0xFF00) | (jet_col & 0xFF);
+                       }
+               }
+       }
+}
 
+//_____________________________________________________________________________
+void AliEMCALTriggerSTURawStream::DecodeL1GammaPatchIndexes(const int i, UInt_t *word32, const int offset)
+{
        //////////////////////////////////////////////////////////
        // index des L1 gamma                                   //
        //////////////////////////////////////////////////////////
@@ -263,11 +399,11 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
        {
                for (Int_t tru_num=0;tru_num<16;tru_num++)
                {
-                       truL1indexes[2*tru_num  ][index] = ( word32[offset + 108 + index * 16 + tru_num]        & 0xFFFF);
-                       truL1indexes[2*tru_num+1][index] = ((word32[offset + 108 + index * 16 + tru_num] >> 16) & 0xFFFF);
+                       truL1indexes[2*tru_num  ][index] = ( word32[offset + index * 16 + tru_num]        & 0xFFFF);
+                       truL1indexes[2*tru_num+1][index] = ((word32[offset + index * 16 + tru_num] >> 16) & 0xFFFF);
                }
        }       
-
+       
        // interpretation
        int gammacolnum;
        short indexcopy;
@@ -291,36 +427,28 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                                                indexcopy   = index-4;
                                        }                                               
                                        
-                                       fNL1GammaPatch++;
+                                       fNL1GammaPatch[i] = fNL1GammaPatch[i] + 1;
                                        
-                                       fL1GammaPatchIndex[fNL1GammaPatch-1] = (((indexcopy << 10) & 0xC00) | ((gammacolnum << 5) & 0x3E0) | (tru_num & 0x1F));
+                                       fL1GammaPatchIndex[fNL1GammaPatch[i] - 1][i] = (((indexcopy << 10) & 0xC00) | ((gammacolnum << 5) & 0x3E0) | (tru_num & 0x1F));
                                }
                        }
                }
        }       
+}
 
-       //////////////////////////////////////////////////////////
-       // raw output                                           //
-       //////////////////////////////////////////////////////////
-       
-       if (iword == kPayLoadSizeOld || iword == kPayLoadSizeNew) 
-       {
-               fGetRawData = 0;
-               return kTRUE;
-       }
-       
-       fGetRawData = 1;
-       
+//_____________________________________________________________________________
+void AliEMCALTriggerSTURawStream::DecodeTRUADC(UInt_t *word32, const int offset)
+{
        // extraction from stream
        for (Int_t index=0;index<96;index++)
        {
                for (Int_t tru_num=0;tru_num<16;tru_num++)
                {
-                       fADC[2*tru_num  ][index] = ( word32[offset + 236 + index * 16 + tru_num]        & 0xFFFF);
-                       fADC[2*tru_num+1][index] = ((word32[offset + 236 + index * 16 + tru_num] >> 16) & 0xFFFF);
+                       fADC[2*tru_num  ][index] = ( word32[offset + index * 16 + tru_num]        & 0xFFFF);
+                       fADC[2*tru_num+1][index] = ((word32[offset + index * 16 + tru_num] >> 16) & 0xFFFF);
                }
        }       
-
+       
        for (Int_t tru_num=16;tru_num<32;tru_num++) // A side
        {
                Int_t v[96];
@@ -328,10 +456,9 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                
                for (Int_t index=0;index<96;index++) fADC[tru_num][index] = v[index];
        }
-       
-       return kTRUE;
 }
 
+
 //_____________________________________________________________________________
 Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& idx) const
 {
@@ -346,28 +473,28 @@ Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, I
 }
 
 //_____________________________________________________________________________
-Bool_t AliEMCALTriggerSTURawStream::GetL1GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const
+Bool_t AliEMCALTriggerSTURawStream::GetL1GammaPatch(const Int_t i, const Int_t j, Int_t& tru, Int_t& col, Int_t& row) const
 {
        // L1 gamma patch indexes
        
-       if (i > fNL1GammaPatch) return kFALSE;
+       if (j >= 2 || i > fNL1GammaPatch[j]) return kFALSE;
        
-       tru =  fL1GammaPatchIndex[i] & 0x1F;
-       col = (fL1GammaPatchIndex[i] & 0x3E0) >> 5;
-       row = (fL1GammaPatchIndex[i] & 0xC00) >> 10;
+       tru =  fL1GammaPatchIndex[i][j] & 0x1F;
+       col = (fL1GammaPatchIndex[i][j] & 0x3E0) >> 5;
+       row = (fL1GammaPatchIndex[i][j] & 0xC00) >> 10;
        
        return kTRUE;
 }
 
 //_____________________________________________________________________________
-Bool_t AliEMCALTriggerSTURawStream::GetL1JetPatch(const Int_t i, Int_t& col, Int_t& row) const
+Bool_t AliEMCALTriggerSTURawStream::GetL1JetPatch(const Int_t i, const Int_t j, Int_t& col, Int_t& row) const
 {
        // L1 jet patch indexes
        
-       if (i > fNL1JetPatch) return kFALSE;
+       if (j >= 2 || i > fNL1JetPatch[j]) return kFALSE;
        
-       col =  fL1JetPatchIndex[i] & 0xFF;
-       row = (fL1JetPatchIndex[i] & 0xFF00) >> 8;
+       col =  fL1JetPatchIndex[i][j] & 0xFF;
+       row = (fL1JetPatchIndex[i][j] & 0xFF00) >> 8;
        
        return kTRUE;
 }
@@ -389,60 +516,56 @@ void AliEMCALTriggerSTURawStream::DumpPayLoad(const Option_t *option) const
        
        printf("V0A:             %d\n", fV0A);
        printf("V0C:             %d\n", fV0C);
-       printf("G_A:             %d\n", fGA);
-       printf("G_B:             %d\n", fGB);
-       printf("G_C:             %d\n", fGC);
-       printf("Gamma threshold: %d\n", fL1GammaThreshold);
-       printf("J_A:             %d\n", fJA);
-       printf("J_B:             %d\n", fJB);
-       printf("J_C:             %d\n", fJC);
-       printf("Jet Threshold:   %d\n", fL1JetThreshold);
+
        printf("RawData:         %d\n", fGetRawData);
        printf("RegionEnable:    %8x\n", fRegionEnable); 
        printf("FrameReceived:   %8x\n", fFrameReceived);
        printf("FwVersion:       %x\n", fFwVersion);
        printf("Number of L0:    %d\n", fNL0GammaPatch);
-       printf("Number of L1-g:  %d\n", fNL1GammaPatch);
-       printf("Number of L1-j:  %d\n", fNL1JetPatch);
+
+       for (int i = 0; i < 2; i++) {
+               for (int j = 0; j < 3; j++) {
+                       printf("G[%d][%d]: %d\n", j, i, fG[j][i]);
+                       printf("J[%d][%d]: %d\n", j, i, fJ[j][i]);
+               }
+               
+               printf("Gamma threshold[%d]: %d\n", i, fL1GammaThreshold[i]);
+               printf("Jet Threshold[%d]:   %d\n", i, fL1JetThreshold[i]);
+
+               printf("Number of L1-g[%d]: %d\n", i, fNL1GammaPatch[i]);
+               printf("Number of L1-j[%d]: %d\n", i, fNL1JetPatch[i]);
+       }
        
        Int_t itru, col, row;
        
        if (op.Contains("L0") || op.Contains("ALL"))
        {
-               for (Int_t i=0;i<fNL0GammaPatch;i++)
-               {
-                       
+               for (Int_t i = 0;i < fNL0GammaPatch; i++) {
                        if (GetL0GammaPatch(i,itru,col)) 
                                cout << "> Found L0 gamma in TRU #" << setw(2) << itru <<  " at idx: " << setw(2) << col << endl;
                }
        }
        
-       if (op.Contains("L1") || op.Contains("ALL"))
-       {
-               for (Int_t i=0;i<fNL1GammaPatch;i++)
-               {
-                       if (GetL1GammaPatch(i,itru,col,row)) 
-                               cout << "> Found L1 gamma in TRU #" << setw(2) << itru <<  " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
-               }
-
-               for (Int_t i=0;i<fNL1JetPatch;i++)
-               {
-                       if (GetL1JetPatch(i,col,row)) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
+       if (op.Contains("L1") || op.Contains("ALL")) {
+               for (int j = 0; j < 2; j++) {
+                       for (Int_t i = 0; i < fNL1GammaPatch[j]; i++) {
+                               if (GetL1GammaPatch(i, j, itru, col, row)) 
+                                       cout << "> Found L1 gamma " << j << " in TRU #" << setw(2) << itru <<  " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
+                       }
+                       
+                       for (Int_t i = 0; i < fNL1JetPatch[j]; i++) {
+                               if (GetL1JetPatch(i, j, col, row)) cout << "> Found L1 jet " << j << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
+                       }
                }
        }
        
-       
-       
-       if ( (op.Contains("ADC") || op.Contains("ALL")) && fGetRawData )
-       {
-               for (Int_t i=0;i<32;i++)
-               {
+       if ((op.Contains("ADC") || op.Contains("ALL")) && fGetRawData) {
+               for (Int_t i = 0; i < 32; i++) {
                        cout << "--------\n";
                        cout << "TRU #" << setw(2) << i << ":";
-                       for (Int_t j=0;j<96;j++) 
-                       { 
-                               TBits xadc(12); xadc.Set(12,&fADC[i][j]); 
-                               if ((j%4)==0) cout << endl;
+                       for (Int_t j = 0;j < 96; j++) { 
+                               //TBits xadc(12); xadc.Set(12,&fADC[i][j]); 
+                               if ((j % 4) == 0) cout << endl;
                                //cout << setw(2) << j << ": " << xadc << " ";
                                printf("%2d: %3x / ",j,fADC[i][j]); 
                        }
@@ -450,3 +573,22 @@ void AliEMCALTriggerSTURawStream::DumpPayLoad(const Option_t *option) const
                }
        }
 }
+
+//_____________________________________________________________________________
+UShort_t AliEMCALTriggerSTURawStream::GetThreshold(Short_t A, Short_t B, Short_t C, UShort_t V0A, UShort_t V0C) const
+{
+       // Get threshold 
+  ULong64_t v0sum = V0A + V0C;
+  
+  ULong64_t sqrV0 = v0sum * v0sum;                                     
+                                       
+  sqrV0 *= A;
+                                       
+  sqrV0 >>= 32;
+                               
+  v0sum *= B;
+                                       
+  v0sum >>= 16;
+                                       
+  return (UShort_t)(sqrV0 + v0sum + C);
+}