]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALTriggerSTURawStream.cxx
Bug fix in the constructor (thanks to A.Marin)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTriggerSTURawStream.cxx
index b91407b962b28baf640a71ec4a0029090f4a9694..b002e11774d075bfc4f2e0f33acc2808af1634e2 100644 (file)
@@ -1,3 +1,4 @@
+
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
@@ -32,8 +33,8 @@ Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
 
 namespace
 {
-       const Int_t kPayLoadSize            =  944;
-       const Int_t kPayLoadSizeWithRawData = 1772;
+       const Int_t kPayLoadSizeOld     = 236;
+       const Int_t kPayLoadSizeNew     = 245;
 }
 
 ClassImp(AliEMCALTriggerSTURawStream)
@@ -49,7 +50,18 @@ fL1JetPatchIndex(),
 fNL0GammaPatch(0),
 fNL1JetPatch(0),
 fNL1GammaPatch(0),
-fGetRawData(0)
+fGetRawData(0),
+fV0A(0),
+fV0C(0),
+fGA(0),
+fGB(0),
+fGC(0),
+fJA(0),
+fJB(0),
+fJC(0),
+fRegionEnable(0),
+fFrameReceived(0),
+fFwVersion(0)
 {
        //
 }
@@ -65,7 +77,18 @@ fL1JetPatchIndex(),
 fNL0GammaPatch(0),
 fNL1JetPatch(0),
 fNL1GammaPatch(0),
-fGetRawData(0)
+fGetRawData(0),
+fV0A(0),
+fV0C(0),
+fGA(0),
+fGB(0),
+fGC(0),
+fJA(0),
+fJB(0),
+fJC(0),
+fRegionEnable(0),
+fFrameReceived(0),
+fFwVersion(0)
 {
        //
        fRawReader->Reset();
@@ -81,7 +104,8 @@ AliEMCALTriggerSTURawStream::~AliEMCALTriggerSTURawStream()
 //_____________________________________________________________________________
 void AliEMCALTriggerSTURawStream::Reset()
 {
-       //
+       // Reset
+       
        if (fRawReader) fRawReader->Reset();
        
        fNL0GammaPatch = 0;
@@ -93,10 +117,10 @@ void AliEMCALTriggerSTURawStream::Reset()
 Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
 {
        // STU data decoder from Olivier Bourrion LPSC CNRS-IN2P3
-       // bourrion@lpsc.in2p3.fr
+       // bourrion_at_lpsc_dot_in2p3_dot_fr
        
-       UInt_t word32[1772]; // 32b words
-       for (Int_t i=0;i<1772;i++) word32[i] = 0;
+       UInt_t word32[kPayLoadSizeNew + 1536]; // 32b words
+       for (Int_t i = 0;i < kPayLoadSizeNew + 1536; i++) word32[i] = 0;
        
        Int_t iword = 0;
        
@@ -107,6 +131,7 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
        Int_t eqId = -1, eqSize = 0;
        
        UInt_t w32;
+       
        while (fRawReader->ReadNextInt(w32)) 
        {
                if (!iword)
@@ -118,26 +143,69 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                word32[iword++] = w32;
        }
        
-       if (iword != kPayLoadSize && iword != kPayLoadSizeWithRawData)
+       if (iword != kPayLoadSizeOld && iword != kPayLoadSizeNew && iword != (kPayLoadSizeOld + 1536) && iword != (kPayLoadSizeNew + 1536))
        {
-               AliError(Form("ERROR: STU payload (eqId: %d, eqSize: %d) doesn't match expected size! %d word32",
+               AliError(Form("STU payload (eqId: %d, eqSize: %d) doesn't match expected size! %d word32",
                                          eqId, eqSize, iword));
                return kFALSE;
        }
-       else if (AliDebugLevel())
+       
+       if (AliDebugLevel())
        {
                AliInfo(Form("STU (eqId: %d, eqSize: %d) payload size: %d word32",
                                         eqId, eqSize, iword));
        }
        
-         fL1JetThreshold = ((word32[0]>>16) & 0xFFF);
-       fL1GammaThreshold =  (word32[0]      & 0xFFF);
+       int offset = 0, jetSize = 2;
+       
+       switch (iword) 
+       {
+               case kPayLoadSizeOld:
+               case kPayLoadSizeOld + 1536:
+               {
+                       fL1JetThreshold   = ((word32[0]>>16) & 0xFFF);
+                       fL1GammaThreshold =  (word32[0]      & 0xFFF);
+                       
+                       break;
+               }
+               case kPayLoadSizeNew:
+               case kPayLoadSizeNew + 1536:
+               {
+                       fV0A = ((word32[0]>>16) & 0xFFF);
+                       fV0C =  (word32[0]      & 0xFFF);
+                       
+                       UInt_t sV0 = fV0A + fV0C;
+                       
+                       fGA            = word32[1];
+                       fGB            = word32[2];
+                       fGC            = word32[3];
+                       fJA            = word32[4];
+                       fJB            = word32[5];
+                       fJC            = word32[6];             
+                       fRegionEnable  = word32[7];
+                       fFrameReceived = word32[8];
+                       fFwVersion     = word32[9];
+                       
+                       jetSize += (fFwVersion >> 16);
+                       
+                       fL1JetThreshold   = fJA * sV0 * sV0 + fJB * sV0 + fJC;
+                       fL1GammaThreshold = fGA * sV0 * sV0 + fGB * sV0 + fGC;          
+                       
+                       offset = 9;
+                       
+                       break;
+               }
+       }
        
-       for (Int_t jet_row=0; jet_row<11; jet_row++)
+       ///////////
+       // START DECODING
+       //////////
+
+       for (Int_t jet_row = 0; jet_row < 12 - (jetSize - 1); jet_row++)
        {
-               UInt_t currentrow = word32[1+jet_row];
+               UInt_t currentrow = word32[offset + 1 + jet_row];
                
-               for (Int_t jet_col=0; jet_col<15; jet_col++)
+               for (Int_t jet_col = 0; jet_col < 15; jet_col++)
                {
                        if (currentrow & (1 << jet_col))
                        {
@@ -147,21 +215,22 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                        }
                }
        }
+               
        
        //////////////////////////////////////////////////////////
        // index des L0                                         //
        //////////////////////////////////////////////////////////
-       // FIXME: still not interpreted to be done with Jiri
+       // FIXME: sounds like not valid data
        
-       unsigned short TRU_L0_indexes[32][6];
+       unsigned short truL0indexes[32][6];
        
        // extraction from stream
        for (Int_t index=0;index<6;index++)
        {
                for (Int_t tru_num=0;tru_num<16;tru_num++)
                {
-                       TRU_L0_indexes[2*tru_num  ][index] = ( word32[12+index*16+tru_num]      & 0xFFFF);
-                       TRU_L0_indexes[2*tru_num+1][index] = ((word32[12+index*16+tru_num]>>16) & 0xFFFF);
+                       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);
                }
        }
 
@@ -171,7 +240,7 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                {
                        for (Int_t bit_num=0;bit_num<12;bit_num++)
                        {
-                               if ((TRU_L0_indexes[tru_num][index] & (1 << bit_num)))
+                               if ((truL0indexes[tru_num][index] & (1 << bit_num)))
                                {
                                        Int_t idx = 12 * index + bit_num;
                                                                                
@@ -187,15 +256,15 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
        // index des L1 gamma                                   //
        //////////////////////////////////////////////////////////
        
-       unsigned short TRU_L1_indexes[32][8];
+       unsigned short truL1indexes[32][8];
        
        // extraction from stream
        for (Int_t index=0;index<8;index++)
        {
                for (Int_t tru_num=0;tru_num<16;tru_num++)
                {
-                       TRU_L1_indexes[2*tru_num  ][index] = ( word32[108+index*16+tru_num]      & 0xFFFF);
-                       TRU_L1_indexes[2*tru_num+1][index] = ((word32[108+index*16+tru_num]>>16) & 0xFFFF);
+                       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);
                }
        }       
 
@@ -209,7 +278,7 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                {
                        for (Int_t bit_num=0; bit_num<12; bit_num++)
                        {
-                               if ((TRU_L1_indexes[tru_num][index] & (1<<bit_num)) != 0)
+                               if ((truL1indexes[tru_num][index] & (1<<bit_num)) != 0)
                                {
                                        if (index<4) // Even
                                        {
@@ -234,7 +303,7 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
        // raw output                                           //
        //////////////////////////////////////////////////////////
        
-       if ( iword <= kPayLoadSize 
+       if (iword == kPayLoadSizeOld || iword == kPayLoadSizeNew
        {
                fGetRawData = 0;
                return kTRUE;
@@ -247,8 +316,8 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
        {
                for (Int_t tru_num=0;tru_num<16;tru_num++)
                {
-                       fADC[2*tru_num  ][index] = ( word32[236+index*16+tru_num]      & 0xFFFF);
-                       fADC[2*tru_num+1][index] = ((word32[236+index*16+tru_num]>>16) & 0xFFFF);
+                       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);
                }
        }       
 
@@ -266,7 +335,8 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
 //_____________________________________________________________________________
 Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& idx) const
 {
-       //
+       // L0 gamma patches sent to STU (original access to L0 patch indexes)
+       
        if (i > fNL0GammaPatch) return kFALSE;
        
        tru =  fL0GammaPatchIndex[i] & 0x1F;
@@ -278,7 +348,8 @@ 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
 {
-       //
+       // L1 gamma patch indexes
+       
        if (i > fNL1GammaPatch) return kFALSE;
        
        tru =  fL1GammaPatchIndex[i] & 0x1F;
@@ -291,7 +362,8 @@ Bool_t AliEMCALTriggerSTURawStream::GetL1GammaPatch(const Int_t i, Int_t& tru, I
 //_____________________________________________________________________________
 Bool_t AliEMCALTriggerSTURawStream::GetL1JetPatch(const Int_t i, Int_t& col, Int_t& row) const
 {
-       //
+       // L1 jet patch indexes
+       
        if (i > fNL1JetPatch) return kFALSE;
        
        col =  fL1JetPatchIndex[i] & 0xFF;
@@ -303,20 +375,35 @@ Bool_t AliEMCALTriggerSTURawStream::GetL1JetPatch(const Int_t i, Int_t& col, Int
 //_____________________________________________________________________________
 void AliEMCALTriggerSTURawStream::GetADC(Int_t iTRU, UInt_t ADC[])
 {
-       //
+       // Time sums
+       
        for (Int_t i=0; i<96; i++) ADC[i] = fADC[iTRU][i];
 }
 
 //_____________________________________________________________________________
 void AliEMCALTriggerSTURawStream::DumpPayLoad(const Option_t *option) const
 {
-       //
+       // Dump STU payload
+       
        TString op = option;
        
-       cout << "Jet Threshold: " << fL1JetThreshold << " Gamma threshold: " << fL1GammaThreshold << endl;
-       cout << "Number of L0:   " << fNL0GammaPatch << endl;
-       cout << "Number of L1-g: " << fNL1GammaPatch << endl;
-       cout << "Number of L1-j: " << fNL1JetPatch << endl;
+       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);
        
        Int_t itru, col, row;
        
@@ -344,7 +431,7 @@ void AliEMCALTriggerSTURawStream::DumpPayLoad(const Option_t *option) const
                }
        }
        
-       cout << "> RawData: " << fGetRawData << endl;
+       
        
        if ( (op.Contains("ADC") || op.Contains("ALL")) && fGetRawData )
        {