Modified files to use constants declared in the
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSModuleMergerComponent.cxx
index 8d170115af9167916786036c9b5ca430efab2246..8db4e3830627fe7cb23da9d10eede897ddc94c95 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+
+
 #include "AliHLTPHOSModuleMergerComponent.h"
-#include <iostream>
-#include "stdio.h"
 #include "AliRawReaderMemory.h"
 #include "AliCaloRawStream.h"
-#include <cstdlib>
-#include "AliHLTPHOSRcuCellEnergyData.h"
-
+#include <cstdio>
+#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
 
-const AliHLTComponentDataType  AliHLTPHOSModuleMergerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
-const AliHLTComponentDataType  AliHLTPHOSModuleMergerComponent::outputDataType=kAliHLTVoidDataType;
 
+const AliHLTComponentDataType  AliHLTPHOSModuleMergerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
+const AliHLTComponentDataType  AliHLTPHOSModuleMergerComponent::fgkOutputDataType=kAliHLTVoidDataType;
 
 AliHLTPHOSModuleMergerComponent gAliHLTPHOSModuleMergerComponent;
-AliHLTPHOSModuleMergerComponent:: AliHLTPHOSModuleMergerComponent():AliHLTProcessor(),  fEventCount(0),  fEquippmentID(0)
+
+//_____________________________________________________________________________________________________
+AliHLTPHOSModuleMergerComponent:: AliHLTPHOSModuleMergerComponent():AliHLTPHOSProcessor(),  fPhosEventCount(0),  fEquippmentID(0)
 {
 
 } 
 
+
+//_____________________________________________________________________________________________________
 AliHLTPHOSModuleMergerComponent::~ AliHLTPHOSModuleMergerComponent()
 {
 
 }
 
-AliHLTPHOSModuleMergerComponent:: AliHLTPHOSModuleMergerComponent(const  AliHLTPHOSModuleMergerComponent & ) : AliHLTProcessor(),  fEventCount(0),  fEquippmentID(0)
+
+//_____________________________________________________________________________________________________
+AliHLTPHOSModuleMergerComponent::AliHLTPHOSModuleMergerComponent(const  AliHLTPHOSModuleMergerComponent & ) : AliHLTPHOSProcessor(),  fPhosEventCount(0),  fEquippmentID(0)
 {
 
 }
 
 
+//_____________________________________________________________________________________________________
 int 
 AliHLTPHOSModuleMergerComponent::Deinit()
 {
   return 0;
 }
 
+
+//_____________________________________________________________________________________________________
 int 
 AliHLTPHOSModuleMergerComponent::DoDeinit()
 {
@@ -57,32 +65,41 @@ AliHLTPHOSModuleMergerComponent::DoDeinit()
 
 }
 
+
+//_____________________________________________________________________________________________________
 const char* 
 AliHLTPHOSModuleMergerComponent::GetComponentID()
 {
   return "ModuleMerger";
 }
 
+
+//_____________________________________________________________________________________________________
 void
- AliHLTPHOSModuleMergerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
+AliHLTPHOSModuleMergerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
 {
-  const AliHLTComponentDataType* pType=inputDataTypes;
-  while (pType->fID!=0) {
-    list.push_back(*pType);
-    pType++;
-  }
+  const AliHLTComponentDataType* pType=fgkInputDataTypes;
+  while (pType->fID!=0) 
+    {
+      list.push_back(*pType);
+      pType++;
+    }
 }
 
+
+//_____________________________________________________________________________________________________
 AliHLTComponentDataType 
 AliHLTPHOSModuleMergerComponent::GetOutputDataType()
 {
-  return AliHLTPHOSDefinitions::gkCellEnergyDataType;
+  return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
 }
 
+
+//_____________________________________________________________________________________________________
 void
 AliHLTPHOSModuleMergerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
-
 {
+  ///
   constBase = 30;
   inputMultiplier = 1;
 }
@@ -92,9 +109,11 @@ int  AliHLTPHOSModuleMergerComponent::DoEvent( const AliHLTComponentEventData& e
                                              AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
                                              AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
 {
+  //Merging of data from 4 RCUS to one module
+  
   unsigned long ndx;
   const AliHLTComponentBlockData* iter = NULL;   
-  AliHLTPHOSRcuCellEnergyData *cellDataPtr;
+  AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
 
   Reset();
 
@@ -103,37 +122,39 @@ int  AliHLTPHOSModuleMergerComponent::DoEvent( const AliHLTComponentEventData& e
       int tmpModuleID = 0;
       int tmpRcuX = 0;
       int tmpRcuZ = 0;
-
+      int tmpCnt =  cellDataPtr->fCnt;
       iter = blocks+ndx;
-      AliHLTPHOSRcuCellEnergyData *cellDataPtr = (AliHLTPHOSRcuCellEnergyData*)( iter->fPtr);
-
+      AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
       tmpModuleID = cellDataPtr->fModuleID;
       tmpRcuX     = cellDataPtr->fRcuX ;
       tmpRcuZ     = cellDataPtr->fRcuZ;
 
-      for(int row = 0; row<32; row ++)
+      for(int i= 0; i< tmpCnt; tmpCnt ++)
        {
-         for(int col = 0; col < 28; col ++)
+         if(cellDataPtr->fValidData[i].fGain == HIGH_GAIN)
            {
-             for(int gain=0; gain <2; gain++)
-               {
-                 fMaxValues[tmpModuleID][row + 32*tmpRcuX][col + 28*tmpRcuZ][gain] =  cellDataPtr->fCellEnergies[row][col][gain];  
-               }         
+             fMaxValues[tmpModuleID][ cellDataPtr->fValidData[i].fZ +  N_ZROWS_RCU*tmpRcuZ][ cellDataPtr->fValidData[i].fX + N_XCOLUMNS_RCU*tmpRcuX][HIGH_GAIN] =  cellDataPtr->fValidData[i].fEnergy;
+           }
+         else if(cellDataPtr->fValidData[i].fGain == LOW_GAIN)
+           {
+             fMaxValues[tmpModuleID][ cellDataPtr->fValidData[i].fZ +  N_ROWS_RCU*tmpRcuZ][ cellDataPtr->fValidData[i].fX +N_COLUMNS_RCU*tmpRcuX][LOW_GAIN] =  cellDataPtr->fValidData[i].fEnergy;
            }
        }
-
+      
     }
 
-  DumpData();
-  fEventCount++; 
+  DumpData(1);
+  fPhosEventCount++; 
   return 0;
+  
 }//end DoEvent
 
 
-
+//_____________________________________________________________________________________________________
 int
 AliHLTPHOSModuleMergerComponent::DoInit( int argc, const char** argv )
 {
+  //See base classs for documenation
   Reset();
 
   if (argc==0 && argv==NULL) {
@@ -142,19 +163,34 @@ AliHLTPHOSModuleMergerComponent::DoInit( int argc, const char** argv )
   return 0;
 }
 
+
+//_____________________________________________________________________________________________________
 void
-AliHLTPHOSModuleMergerComponent::DumpData()
+AliHLTPHOSModuleMergerComponent::DumpData(int gain)
 {
-  for(int mod = 0; mod <5; mod ++)
+  if(gain < 0 || gain >  N_GAINS)
     {
-      printf("\n ***********  MODULE %d ************\n", mod);
-      for(int row = 0; row < 64; row ++)
+      cout <<"AliHLTPHOSModuleMergerComponent::DumpDat: Error, gain must be between " << 0 << "and" << N_GAINS << endl;
+    }
+  
+  for(int mod = 0; mod < N_MODULES; mod ++)
+    {
+      if(gain == HIGH_GAIN)
+       {
+         cout << endl <<" ***********  MODULE" << mod << "****HIGH_GAIN" <<"************" << endl;
+       }
+      else if(gain == LOW_GAIN)
        {
-         for(int col = 0; col < 56; col ++)
+         cout << endl <<" ***********  MODULE" << mod << "****LOW_GAIN" <<"************" << endl;
+       }
+      
+      for(int row = 0; row < N_ROWS_MOD; row ++)
+       {
+         for(int col = 0; col < N_COLUMNS_MOD; col ++)
            {
-             if( fMaxValues[mod][row][col][0] != 0)
+                     if( fMaxValues[mod][row][col][0] != 0)
                { 
-                 cout << fMaxValues[mod][row][col][0] << "\t";
+                                 cout << fMaxValues[mod][row][col][0] << "\t";
                }
            }
        } 
@@ -162,52 +198,61 @@ AliHLTPHOSModuleMergerComponent::DumpData()
 }
 
 
+
+//_____________________________________________________________________________________________________
 void
 AliHLTPHOSModuleMergerComponent::Reset()
 {
-  for(int mod = 0; mod <5; mod ++)
+  for(int mod = 0; mod < N_MODULES; mod ++)
     {
-      for(int row = 0; row < 64; row ++)
+      for(int row = 0; row <  N_ROWS_MOD; row ++)
        {
-         for(int col = 0; col < 56; col ++)
+         for(int col = 0; col < N_COLUMNS_MOD; col ++)
            {
-             for(int gain = 0; gain <2; gain ++ )
-               {
+             for(int gain = 0; gain < N_GAINS; gain ++ )
+               { 
+
                  fMaxValues[mod][row][col][gain] = 0;
                }
            }
        }
     }
 
-  for(int i = 0 ; i< 1008; i++)
+  for(int i = 0 ; i<  ALTRO_MAX_SAMPLES; i++)
     {
       fTmpChannelData[i] = 0;
     }
 } // end Reset
 
+
+//_____________________________________________________________________________________________________
 void
 AliHLTPHOSModuleMergerComponent::ResetDataPtr()
 {
-  for(int i = 0 ; i< 1008; i++)
+  for(int i = 0 ; i<  ALTRO_MAX_SAMPLES; i++)
     {
       fTmpChannelData[i] = 0;
     }
 }
 
 
+//_____________________________________________________________________________________________________
 void 
 AliHLTPHOSModuleMergerComponent::SetEquippmentId(int id)
 {
   fEquippmentID = id;
 }
 
-int 
-AliHLTPHOSModuleMergerComponent::GetEquippmentId()
+
+//_____________________________________________________________________________________________________
+const int 
+AliHLTPHOSModuleMergerComponent::GetEquippmentId() const
 {
   return  fEquippmentID;
 }
 
 
+//_____________________________________________________________________________________________________
 AliHLTComponent*
 AliHLTPHOSModuleMergerComponent::Spawn()
 {