]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/PHOS/AliHLTPHOSRcuHistogramProducerComponent.cxx
Updating CMake files
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRcuHistogramProducerComponent.cxx
index 705f3d679c11746b8de8e244ac458d12d8ce3b30..b5210a55911b1e5042641f0c8bee43015cb8ec5b 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-#include <iostream>
-#include "stdio.h"
-#include <cstdlib>
 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
-//#include "AliHLTPHOSModuleCellAccumulatedEnergyDataStruct.h"
 #include "AliHLTPHOSRcuHistogramProducer.h"
 #include "AliHLTPHOSRcuHistogramProducerComponent.h"
+#include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
+#include "AliHLTPHOSSharedMemoryInterface.h"
+#include "AliHLTPHOSValidCellDataStruct.h" 
 
-
-
-const AliHLTComponentDataType  AliHLTPHOSRcuHistogramProducerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
-const AliHLTComponentDataType  AliHLTPHOSRcuHistogramProducerComponent::outputDataType=kAliHLTVoidDataType;
 AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent;
-
-//AliHLTPHOSHistogramProducerComponent gAliHLTPHOSHistogramProducerComponent;
 /*************************************************************************
 * Class AliHLTPHOSRcuHistogramProducerComponent accumulating histograms  *
 * with amplitudes per PHOS channel                                       *
@@ -36,38 +29,29 @@ AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent
 * and it fills the histograms with amplitudes per channel.               * 
 * Usage example see in PHOS/macros/Shuttle/AliPHOSCalibHistoProducer.C   *
 **************************************************************************/
-AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent():AliHLTProcessor(), fEventCount(0), fRcuHistoProducerPtr(0)
-{
-  //  Reset();
+AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent() : AliHLTPHOSRcuProcessor(), 
+                                                                                     fHistoWriteFrequency(100), 
+                                                                                     fRcuHistoProducerPtr(0), 
+                                                                                     fOutPtr(0),
+                                                                                     fShmPtr(0)
+{
+  fShmPtr = new AliHLTPHOSSharedMemoryInterface();
+ //Default constructor
 } 
 
 
-
 AliHLTPHOSRcuHistogramProducerComponent::~ AliHLTPHOSRcuHistogramProducerComponent()
 {
-
-}
-
-
-AliHLTPHOSRcuHistogramProducerComponent::AliHLTPHOSRcuHistogramProducerComponent(const  AliHLTPHOSRcuHistogramProducerComponent & ) : AliHLTProcessor(), fEventCount(0), fRcuHistoProducerPtr(0)
-{
-
+  //Destructor
 }
 
 
 int 
 AliHLTPHOSRcuHistogramProducerComponent::Deinit()
 {
+  //See html documentation of base class
   cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
-  fRcuHistoProducerPtr->WriteEnergyHistograms();
-  return 0;
-}
-
-
-int 
-AliHLTPHOSRcuHistogramProducerComponent::DoDeinit()
-{
-  Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRcuHistogramProducer DoDeinit");
+  fRcuHistoProducerPtr->WriteAllHistograms("recreate");
   return 0;
 }
 
@@ -75,14 +59,16 @@ AliHLTPHOSRcuHistogramProducerComponent::DoDeinit()
 const char* 
 AliHLTPHOSRcuHistogramProducerComponent::GetComponentID()
 {
+  //See html documentation of base class
   return "RcuHistogramProducer";
 }
 
 
 void
- AliHLTPHOSRcuHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
+AliHLTPHOSRcuHistogramProducerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
 {
-  const AliHLTComponentDataType* pType=inputDataTypes;
+  //See html documentation of base class
+  const AliHLTComponentDataType* pType=fgkInputDataTypes;
   while (pType->fID!=0) 
     {
       list.push_back(*pType);
@@ -94,22 +80,38 @@ void
 AliHLTComponentDataType 
 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataType()
 {
-  return AliHLTPHOSDefinitions::gkCellEnergyDataType;
+  //See html documentation of base class  
+  return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
 }
 
 
 void
 AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
 {
+  //See html documentation of base class
   constBase = 30;
   inputMultiplier = 1;
 }
 
 
+
 int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
                                              AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
                                              AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
 {
+  
+  cout <<  "  AliHLTPHOSRcuHistogramProducerComponent::Doevent, entering event loop" << endl;
+
+ //See html documentation of base class
+  // trigData++;
+  // trigData--; //shutting up the compiler, we dont use trigData now but will do in near future
+
+  AliHLTComponentTriggerData &trDta = trigData;  
+  trDta.fDataSize++;
+  trDta.fDataSize--; //shutting up the compiler, we dont use trigData now but will do in near future
+
+  AliHLTPHOSValidCellDataStruct *currentChannel =0;
   unsigned long ndx       = 0;
   UInt_t offset           = 0; 
   UInt_t mysize           = 0;
@@ -117,55 +119,69 @@ int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEven
   const AliHLTComponentBlockData* iter = NULL;   
   AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
   AliHLTUInt8_t* outBPtr;
-  // outBPtr = outputPtr;
-  // fOutPtr =  (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
-  int tmpCnt;
 
   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
+      cout <<  "  AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block" << endl;
       iter = blocks+ndx;
-      cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
-      tmpCnt =  cellDataPtr->fCnt;
+      if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
+       {
+         cout <<  "  AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block of wrong type" << endl;
+         cout << "evtData.fSize ="  << evtData.fStructSize  <<  "evtData.fBlockCnt =" << evtData.fBlockCnt   <<endl ;
 
-      for(int i= 0; i <= tmpCnt; i ++)
+         continue;
+       }
+      
+      cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
+      fShmPtr->SetMemory(cellDataPtr);
+      currentChannel = fShmPtr->NextChannel();
+      
+      Int_t* tmpDataPtr = 0;
+      Int_t nSamples = 0;
+      if(cellDataPtr->fHasRawData == true)
+       {
+         while(currentChannel != 0)
+           {
+             tmpDataPtr = fShmPtr->GetRawData(nSamples);
+             fRcuHistoProducerPtr->FillEnergy(currentChannel->fX, currentChannel->fZ, currentChannel->fGain, currentChannel->fEnergy);
+             fRcuHistoProducerPtr->FillLiveChannels(tmpDataPtr, nSamples, currentChannel->fX, currentChannel->fZ,currentChannel->fGain);
+             currentChannel = fShmPtr->NextChannel();
+           }
+       }
+      else
        {
-         fRcuHistoProducerPtr->FillEnergy(cellDataPtr->fValidData[i].fX,
-                                          cellDataPtr->fValidData[i].fZ, 
-                                          cellDataPtr->fValidData[i].fGain, 
-                                          cellDataPtr->fValidData[i].fEnergy);
+         
+         Logging(kHLTLogFatal, __FILE__ , IntToChar(  __LINE__ ) , "AliHLTPHOSRcuHistogramProducerComponent::We are not pushing raw data, aborting");
+         return -1;
        }
     }
-  
+
   outBPtr = outputPtr;
   fOutPtr =  (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
   const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct  &innPtr = fRcuHistoProducerPtr->GetCellAccumulatedEnergies();
-
   fOutPtr->fModuleID = fModuleID;
   fOutPtr->fRcuX     = fRcuX;
   fOutPtr->fRcuZ     = fRcuZ;
 
-
   for(int x=0; x < N_XCOLUMNS_RCU; x ++)
     {
-      for(int z=0; z < N_XCOLUMNS_RCU; z ++)
+      for(int z=0; z < N_ZROWS_RCU; z ++)
        {
          for(int gain =0;  gain < N_GAINS; gain ++)
            {
              fOutPtr->fAccumulatedEnergies[x][z][gain] = innPtr.fAccumulatedEnergies[x][z][gain];
              fOutPtr->fHits[x][z][gain] = innPtr.fHits[x][z][gain];
+             fOutPtr->fDeadChannelMap[x][z][gain] = innPtr.fDeadChannelMap[x][z][gain];
            }
        }
     }
 
-
-  //pushing data to shared output memory
   mysize += sizeof(AliHLTPHOSRcuCellAccumulatedEnergyDataStruct);
   AliHLTComponentBlockData bd;
   FillBlockData( bd );
   bd.fOffset = offset;
   bd.fSize = mysize;
-  bd.fDataType = AliHLTPHOSDefinitions::gkCellAccumulatedEnergyDataType;
+  bd.fDataType = AliHLTPHOSDefinitions::fgkCellAccumulatedEnergyDataType;
   bd.fSpecification = 0xFFFFFFFF;
   outputBlocks.push_back( bd );
   tSize += mysize;
@@ -179,7 +195,12 @@ int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEven
       return EMSGSIZE;
     }
 
-  fEventCount++; 
+  fPhosEventCount++; 
+
+  if( (fPhosEventCount%fHistoWriteFrequency == 0) &&  ( fPhosEventCount != 0))
+    {
+      fRcuHistoProducerPtr->WriteAllHistograms("recreate");
+    }
   return 0;
 }//end DoEvent
 
@@ -187,132 +208,29 @@ int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEven
 int
 AliHLTPHOSRcuHistogramProducerComponent::DoInit( int argc, const char** argv )
 {
+  //See html documentation of base class
+  fPrintInfo = kFALSE;
   int iResult=0;
   TString argument="";
-  //  fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer();
-  AliHLTUInt8_t tmpRcuX;
-  AliHLTUInt8_t tmpRcuZ; 
-  AliHLTUInt8_t tmpModuleID;
-  Bool_t isSetEquippmentID = kFALSE;
-
-  for(int i=0; i<argc && iResult>=0; i++) 
-    {
-      argument=argv[i];
-      
-      if (argument.IsNull()) 
-       {
-         continue;
-       }
-      if (argument.CompareTo("-equipmentID") == 0) 
-       {
-         if(i+1 <= argc)
-           {
-             fEquippmentID = atoi(argv[i+1]);
-             isSetEquippmentID = kTRUE;
-           }
-         else
-           {
-              iResult= -1;
-              Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
-                       "The argument -equippmentID expects a number");
-              return  iResult;   
-           }
-       }
-
-      int rcuIndex =  (fEquippmentID - 1792)%N_RCUS_PER_MODULE;
-      //     fModuleID = (fEquippmentID  -1792 -rcuIndex)/N_RCUS_PER_MODULE;
-      tmpModuleID = ((fEquippmentID -1792 -rcuIndex)/N_RCUS_PER_MODULE);
-      SetModuleID(tmpModuleID);
-
-      if(rcuIndex == 0)
-       {
-         tmpRcuX = 0; 
-         tmpRcuZ = 0;
-       }
-      
-      if(rcuIndex == 1)
-       {
-        tmpRcuX = 0; 
-        tmpRcuZ = 1;
-       }
-      
-      if(rcuIndex == 2)
-       {
-         tmpRcuX = 1; 
-         tmpRcuZ = 0;
-       }
-      
-      if(rcuIndex == 3)
-       {
-         tmpRcuX = 1; 
-         tmpRcuZ = 1;
-       }
-
-      SetRcuX(tmpRcuX);
-      SetRcuZ(tmpRcuZ); 
-      cout <<"********InitInfo************"<< endl;
-      cout <<"AliHLTPHOSRcuHistogramProducerComponent::SetCoordinate"<< endl;
-      cout <<"Equpippment ID =\t"<< fEquippmentID <<endl;
-      cout <<"Module ID =\t"<<  (int) tmpModuleID<<endl;
-      cout <<"RCUX =\t\t" << (int)tmpRcuX << endl;
-      cout <<"RCUZ =\t\t" << (int)tmpRcuZ << endl;
-     }
-
-  if(isSetEquippmentID == kFALSE)
+  iResult = ScanArguments(argc, argv);
+  if(fIsSetEquippmentID == kFALSE)
     {
-       Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
-                       "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID  <number>");
-       iResult = -2; 
+      Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
+              "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID  <number>");
+      iResult = -2; 
     }
-
+  fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer( fModuleID, fRcuX, fRcuZ);
+  return iResult; 
   
-  fRcuHistoProducerPtr = new AliHLTPHOSRcuHistogramProducer( tmpModuleID, tmpRcuX, tmpRcuZ);
-
-
-  return  iResult;
-}
-
-
-void 
-AliHLTPHOSRcuHistogramProducerComponent::SetRcuX(AliHLTUInt8_t X)
-{
-  fRcuX = X;
-}
-
-
-void 
-AliHLTPHOSRcuHistogramProducerComponent::SetRcuZ(AliHLTUInt8_t Z)
-{
-  fRcuZ = Z;
-}
-
-
-void 
-AliHLTPHOSRcuHistogramProducerComponent::SetModuleID(AliHLTUInt8_t moduleID)
-{
-  fModuleID = moduleID;
-}
-
-
-void 
-AliHLTPHOSRcuHistogramProducerComponent::SetEquippmentId(int id)
-{
-  fEquippmentID = id;
-  fRcuHistoProducerPtr->SetEquippmentId(id);
-}
-
-
-int 
-AliHLTPHOSRcuHistogramProducerComponent::GetEquippmentId()
-{
-  return  fEquippmentID;
 }
 
 
 AliHLTComponent*
 AliHLTPHOSRcuHistogramProducerComponent::Spawn()
 {
+  //See html documentation of base class
   return new AliHLTPHOSRcuHistogramProducerComponent;
 }
 
 
+