]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALTriggerSTURawStream.cxx
Fixes for the creation of PAR files on Mac (Chiara, Gerri)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTriggerSTURawStream.cxx
index 9546dde578b45539f466ff81b5919d973920e7c2..048528b70e483d61965712d4fe0106495c368c29 100644 (file)
@@ -1,3 +1,4 @@
+
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
@@ -28,9 +29,12 @@ Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
 #include "Riostream.h"
 #include "TBits.h"
 
+#include <cstdlib>
+
 namespace
 {
-       const Int_t kPayLoadSize = 944;
+       const Int_t kPayLoadSize            =  944;
+       const Int_t kPayLoadSizeWithRawData = 1772;
 }
 
 ClassImp(AliEMCALTriggerSTURawStream)
@@ -40,13 +44,13 @@ AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream() : TObject(),
 fRawReader(0x0),
 fL1JetThreshold(0),
 fL1GammaThreshold(0),
-fL0GammaPatchIndex(0x0),
-fL1GammaPatchIndex(0x0),
-fL1JetPatchIndex(0x0),
+fL0GammaPatchIndex(),
+fL1GammaPatchIndex(),
+fL1JetPatchIndex(),
 fNL0GammaPatch(0),
 fNL1JetPatch(0),
 fNL1GammaPatch(0),
-fL0(0)
+fGetRawData(0)
 {
        //
 }
@@ -56,13 +60,13 @@ AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream(AliRawReader* rawReader
 fRawReader(rawReader),
 fL1JetThreshold(0),
 fL1GammaThreshold(0),
-fL0GammaPatchIndex(0x0),
-fL1GammaPatchIndex(0x0),
-fL1JetPatchIndex(0x0),
+fL0GammaPatchIndex(),
+fL1GammaPatchIndex(),
+fL1JetPatchIndex(),
 fNL0GammaPatch(0),
 fNL1JetPatch(0),
 fNL1GammaPatch(0),
-fL0(0)
+fGetRawData(0)
 {
        //
        fRawReader->Reset();
@@ -80,32 +84,52 @@ void AliEMCALTriggerSTURawStream::Reset()
 {
        //
        if (fRawReader) fRawReader->Reset();
+       
+       fNL0GammaPatch = 0;
+       fNL1GammaPatch = 0;
+       fNL1JetPatch   = 0;     
 }
 
 //_____________________________________________________________________________
 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;
+       
        Int_t iword = 0;
        
+       fNL0GammaPatch = 0;
+       fNL1GammaPatch = 0;
+       fNL1JetPatch   = 0;
+       
+       Int_t eqId = -1, eqSize = 0;
+       
        UInt_t w32;
-       while (fRawReader->ReadNextInt(w32)) word32[iword++] = w32;
+       while (fRawReader->ReadNextInt(w32)) 
+       {
+               if (!iword)
+               {
+                       eqId   = fRawReader->GetEquipmentId();
+                       eqSize = fRawReader->GetEquipmentSize();
+               }
+               
+               word32[iword++] = w32;
+       }
        
-       if (iword < kPayLoadSize) 
+       if (iword != kPayLoadSize && iword != kPayLoadSizeWithRawData)
        {
-               AliError(Form("STU raw data size is too small: %d word32 only!", iword));
+               AliError(Form("ERROR: STU payload (eqId: %d, eqSize: %d) doesn't match expected size! %d word32",
+                                         eqId, eqSize, iword));
                return kFALSE;
-       } 
-       else if (iword > kPayLoadSize )
+       }
+       else if (AliDebugLevel())
        {
-               AliLog::Message(AliLog::kInfo, "TRU raw data in the STU payload enabled","EMCAL","AliEMCALTriggerSTURawStream","ReadPayLoad()","AliEMCALTriggerSTURawStream.cxx",104);
+               AliInfo(Form("STU (eqId: %d, eqSize: %d) payload size: %d word32",
+                                        eqId, eqSize, iword));
        }
-
-       fL0 = 0;
        
          fL1JetThreshold = ((word32[0]>>16) & 0xFFF);
        fL1GammaThreshold =  (word32[0]      & 0xFFF);
@@ -119,8 +143,6 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                        if (currentrow & (1 << jet_col))
                        {
                                fNL1JetPatch++;
-                               fL1JetPatchIndex = (UShort_t*)realloc(fL1JetPatchIndex, fNL1JetPatch * sizeof(UShort_t));
-                               if (fL1JetPatchIndex == NULL) {AliError("Error (re)allocating L1 jet patch memory");}
                                
                                fL1JetPatchIndex[fNL1JetPatch-1] = ((jet_row << 8) & 0xFF00) | (jet_col & 0xFF);
                        }
@@ -152,19 +174,11 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                        {
                                if ((TRU_L0_indexes[tru_num][index] & (1 << bit_num)))
                                {
-                                       fL0 = 1;
-
                                        Int_t idx = 12 * index + bit_num;
-                                       
-                                       Int_t col = idx / 3;
-                                       Int_t row = idx % 3;
-                                       
+                                                                               
                                        fNL0GammaPatch++;
-                                       fL0GammaPatchIndex = (UShort_t*)realloc(fL0GammaPatchIndex, fNL0GammaPatch * sizeof(UShort_t));
-                                       
-                                       if (fL0GammaPatchIndex == NULL) {AliError("Error (re)allocating L0 gamma patch memory");}
                                        
-                                       fL0GammaPatchIndex[fNL0GammaPatch-1] = (((row << 10) & 0xC00) | ((col << 5) & 0x3E0) | (tru_num & 0x1F));
+                                       fL0GammaPatchIndex[fNL0GammaPatch-1] = (((idx << 5) & 0x7E0) | (tru_num & 0x1F));
                                }
                        }
                }
@@ -210,9 +224,6 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                                        }                                               
                                        
                                        fNL1GammaPatch++;
-                                       fL1GammaPatchIndex = (UShort_t*)realloc(fL1GammaPatchIndex, fNL1GammaPatch * sizeof(UShort_t));
-
-                                       if (fL1GammaPatchIndex == NULL) {AliError("Error (re)allocating L1 gamma patch memory");}
                                        
                                        fL1GammaPatchIndex[fNL1GammaPatch-1] = (((indexcopy << 10) & 0xC00) | ((gammacolnum << 5) & 0x3E0) | (tru_num & 0x1F));
                                }
@@ -224,7 +235,13 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
        // raw output                                           //
        //////////////////////////////////////////////////////////
        
-       if ( iword <= kPayLoadSize ) return kFALSE;
+       if ( iword <= kPayLoadSize ) 
+       {
+               fGetRawData = 0;
+               return kTRUE;
+       }
+       
+       fGetRawData = 1;
        
        // extraction from stream
        for (Int_t index=0;index<96;index++)
@@ -238,24 +255,23 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
 
        for (Int_t tru_num=16;tru_num<32;tru_num++) // A side
        {
-               for (Int_t index=0;index<96;index++)
-               {
-                       fADC[tru_num][index] = fADC[tru_num][95-index];
-               }
+               Int_t v[96];
+               for (Int_t index=0;index<96;index++) v[index] = fADC[tru_num][95-index];
+               
+               for (Int_t index=0;index<96;index++) fADC[tru_num][index] = v[index];
        }
        
-       return kFALSE;
+       return kTRUE;
 }
 
 //_____________________________________________________________________________
-Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const
+Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& idx) const
 {
        //
        if (i > fNL0GammaPatch) return kFALSE;
        
        tru =  fL0GammaPatchIndex[i] & 0x1F;
-       col = (fL0GammaPatchIndex[i] & 0x3E0) >> 5;
-       row = (fL0GammaPatchIndex[i] & 0xC00) >> 10;
+       idx = (fL0GammaPatchIndex[i] & 0x7E0) >> 5;
        
        return kTRUE;
 }
@@ -293,24 +309,25 @@ void AliEMCALTriggerSTURawStream::GetADC(Int_t iTRU, UInt_t ADC[])
 }
 
 //_____________________________________________________________________________
-void AliEMCALTriggerSTURawStream::Dump(const Option_t *option) const
+void AliEMCALTriggerSTURawStream::DumpPayLoad(const Option_t *option) const
 {
        //
        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;
        
        Int_t itru, col, row;
-
-       Bool_t isOK;
        
        if (op.Contains("L0") || op.Contains("ALL"))
        {
                for (Int_t i=0;i<fNL0GammaPatch;i++)
                {
-                       isOK = GetL0GammaPatch(i,itru,col,row);
-                       if (isOK) cout << "> Found L0 gamma in TRU #" << setw(2) << itru
-                                               <<  " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
+                       
+                       if (GetL0GammaPatch(i,itru,col)) 
+                               cout << "> Found L0 gamma in TRU #" << setw(2) << itru <<  " at idx: " << setw(2) << col << endl;
                }
        }
        
@@ -318,19 +335,19 @@ void AliEMCALTriggerSTURawStream::Dump(const Option_t *option) const
        {
                for (Int_t i=0;i<fNL1GammaPatch;i++)
                {
-                       isOK = GetL1GammaPatch(i,itru,col,row);
-                       if (isOK) cout << "> Found L1 gamma in TRU #" << setw(2) << itru
-                                               <<  " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
+                       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++)
                {
-                       isOK = GetL1JetPatch(i,col,row);
-                       if (isOK) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
+                       if (GetL1JetPatch(i,col,row)) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
                }
        }
        
-       if (op.Contains("ADC") || op.Contains("ALL"))
+       cout << "> RawData: " << fGetRawData << endl;
+       
+       if ( (op.Contains("ADC") || op.Contains("ALL")) && fGetRawData )
        {
                for (Int_t i=0;i<32;i++)
                {