Modified files to use constants declared in the
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSModuleMergerComponent.cxx
index 93fe1e051adeb9d8046946359c80c3021d2cf30c..8db4e3830627fe7cb23da9d10eede897ddc94c95 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-//#include "AliHLTPHOSModuleMergerComponent.h"
 
-#include "AliHLTPHOSModuleMergerComponent.h"
-#include <iostream>
-#include "stdio.h"
 
+#include "AliHLTPHOSModuleMergerComponent.h"
 #include "AliRawReaderMemory.h"
 #include "AliCaloRawStream.h"
-#include <cstdlib>
-//#include "TH2.h"
+#include <cstdio>
+#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
 
-//#include "AliHLTTPCDefinitions.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 g AliHLTPHOSModuleMergerComponent;
-//ClassImp( AliHLTPHOSModuleMergerComponent) 
-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()
 {
@@ -62,34 +65,43 @@ AliHLTPHOSModuleMergerComponent::DoDeinit()
 
 }
 
+
+//_____________________________________________________________________________________________________
 const char* 
- AliHLTPHOSModuleMergerComponent::GetComponentID()
+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()
+AliHLTPHOSModuleMergerComponent::GetOutputDataType()
 {
-  return outputDataType;
+  return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
 }
 
-void
- AliHLTPHOSModuleMergerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
 
+//_____________________________________________________________________________________________________
+void
+AliHLTPHOSModuleMergerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
 {
+  ///
   constBase = 30;
-  inputMultiplier = 0.1;
+  inputMultiplier = 1;
 }
 
 
@@ -97,54 +109,88 @@ 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;   
+  AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
+
+  Reset();
 
+  for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+    {
+      int tmpModuleID = 0;
+      int tmpRcuX = 0;
+      int tmpRcuZ = 0;
+      int tmpCnt =  cellDataPtr->fCnt;
+      iter = blocks+ndx;
+      AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
+      tmpModuleID = cellDataPtr->fModuleID;
+      tmpRcuX     = cellDataPtr->fRcuX ;
+      tmpRcuZ     = cellDataPtr->fRcuZ;
+
+      for(int i= 0; i< tmpCnt; tmpCnt ++)
+       {
+         if(cellDataPtr->fValidData[i].fGain == HIGH_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;
+           }
+       }
+      
+    }
 
-  fEventCount++; 
+  DumpData(1);
+  fPhosEventCount++; 
   return 0;
+  
 }//end DoEvent
 
 
-
+//_____________________________________________________________________________________________________
 int
- AliHLTPHOSModuleMergerComponent::DoInit( int argc, const char** argv )
-{
-  cout << "DOINIT argc =" << argc << endl;
-  cout << "DOINIT argv[0] =" << argv[0] << endl;
-  cout << "DOINIT argv[1] =" << argv[1] << endl;
-  cout << "DOINIT argv[2] =" << argv[2] << endl;
-  cout << "DOINIT argv[3] =" << argv[3] << endl;
-  cout << "DOINIT argv[4] =" << argv[4] << endl;
-  cout << "DOINIT argv[5] =" << argv[5] << endl;
-  cout << "DOINIT argv[6] =" << argv[6] << endl;
-  int equippmentId = atoi(argv[6]);
-  cout << "The equipment ID was set to " <<equippmentId << endl;
-  
-
+AliHLTPHOSModuleMergerComponent::DoInit( int argc, const char** argv )
+{
+  //See base classs for documenation
   Reset();
-  cout << " AliHLTPHOSModuleMergerComponent::DoInit Creating new  AliRawReaderMemory()" << endl; 
 
-
-  cout <<" AliHLTPHOSModuleMergerComponent::DoIni  DONE!" << endl;
   if (argc==0 && argv==NULL) {
     // this is currently just to get rid of the warning "unused parameter"
   }
   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)
+       {
+         cout << endl <<" ***********  MODULE" << mod << "****LOW_GAIN" <<"************" << endl;
+       }
+      
+      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 ++)
            {
-             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";
                }
            }
        } 
@@ -152,47 +198,65 @@ void
 }
 
 
+
+//_____________________________________________________________________________________________________
 void
- AliHLTPHOSModuleMergerComponent::Reset()
+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()
+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)
+AliHLTPHOSModuleMergerComponent::SetEquippmentId(int id)
 {
-  fEquippmentId = id;
+  fEquippmentID = id;
 }
 
-int 
-AliHLTPHOSModuleMergerComponent::GetEquippmentId()
+
+//_____________________________________________________________________________________________________
+const int 
+AliHLTPHOSModuleMergerComponent::GetEquippmentId() const
 {
-  return  fEquippmentId;
+  return  fEquippmentID;
 }
+
+
+//_____________________________________________________________________________________________________
+AliHLTComponent*
+AliHLTPHOSModuleMergerComponent::Spawn()
+{
+  return new AliHLTPHOSModuleMergerComponent;
+}
+
+