]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/PHOS/AliHLTPHOSRcuHistogramProducerComponent.cxx
Removing obsolete code + refactoring
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRcuHistogramProducerComponent.cxx
index 605c8252991ff7564be9a921c90f0252d5b7b8b3..c676e684af1440f45659f92429c377394796f9dd 100644 (file)
@@ -1,3 +1,5 @@
+// $Id$
+
 /**************************************************************************
  * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved.      *
  *                                                                        *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-//#include <iostream>
 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
 #include "AliHLTPHOSRcuHistogramProducer.h"
 #include "AliHLTPHOSRcuHistogramProducerComponent.h"
 #include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
-
+#include "AliHLTPHOSSharedMemoryInterface.h"
+#include "AliHLTPHOSValidCellDataStruct.h" 
 
 AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent;
-
-
-
 /*************************************************************************
 * Class AliHLTPHOSRcuHistogramProducerComponent accumulating histograms  *
 * with amplitudes per PHOS channel                                       *
@@ -32,9 +31,14 @@ AliHLTPHOSRcuHistogramProducerComponent gAliHLTPHOSRcuHistogramProducerComponent
 * and it fills the histograms with amplitudes per channel.               * 
 * Usage example see in PHOS/macros/Shuttle/AliPHOSCalibHistoProducer.C   *
 **************************************************************************/
-AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent():AliHLTPHOSRcuProcessor(), fRcuHistoProducerPtr(0)
+AliHLTPHOSRcuHistogramProducerComponent:: AliHLTPHOSRcuHistogramProducerComponent() : AliHLTPHOSRcuProcessor(), 
+                                                                                     fHistoWriteFrequency(100), 
+                                                                                     fRcuHistoProducerPtr(0), 
+                                                                                     fOutPtr(0),
+                                                                                     fShmPtr(0)
 {
-  //Default constructor
+  fShmPtr = new AliHLTPHOSSharedMemoryInterface();
+ //Default constructor
 } 
 
 
@@ -49,7 +53,9 @@ AliHLTPHOSRcuHistogramProducerComponent::Deinit()
 {
   //See html documentation of base class
   cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
-  fRcuHistoProducerPtr->WriteEnergyHistograms();
+  char* arg = new char[9];
+  sprintf(arg, "recreate");
+  fRcuHistoProducerPtr->WriteAllHistograms(arg);
   return 0;
 }
 
@@ -92,11 +98,24 @@ AliHLTPHOSRcuHistogramProducerComponent::GetOutputDataSize(unsigned long& constB
 }
 
 
+
 int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
                                              AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
                                              AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
 {
-  //See html documentation of base class
+  
+  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;
@@ -104,29 +123,43 @@ int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEven
   const AliHLTComponentBlockData* iter = NULL;   
   AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
   AliHLTUInt8_t* 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;
-      for(int i= 0; i <= tmpCnt; i ++)
+      if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
        {
-         fRcuHistoProducerPtr->FillEnergy(cellDataPtr->fValidData[i].fX,
-                                          cellDataPtr->fValidData[i].fZ, 
-                                          cellDataPtr->fValidData[i].fGain, 
-                                          cellDataPtr->fValidData[i].fEnergy);
+         cout <<  "  AliHLTPHOSRcuHistogramProducerComponent::DoEvent, recieved block of wrong type" << endl;
+         cout << "evtData.fSize ="  << evtData.fStructSize  <<  "evtData.fBlockCnt =" << evtData.fBlockCnt   <<endl ;
 
-         if(cellDataPtr->fValidData[i].fEnergy > 1024)
+         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)
            {
-             cout << " AliHLTPHOSRcuHistogramProducerComponent::DoEvent ERROR: cellDataPtr->fValidData[i].fEnergy =" <<  cellDataPtr->fValidData[i].fEnergy << endl;
+             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
+       {
+         
+         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();
@@ -134,21 +167,19 @@ int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEven
   fOutPtr->fRcuX     = fRcuX;
   fOutPtr->fRcuZ     = fRcuZ;
 
-
-  for(int x=0; x < N_XCOLUMNS_RCU; x ++)
+  for(int x=0; x < NXCOLUMNSRCU; x ++)
     {
-      for(int z=0; z < N_ZROWS_RCU; z ++)
+      for(int z=0; z < NZROWSRCU; z ++)
        {
-         for(int gain =0;  gain < N_GAINS; gain ++)
+         for(int gain =0;  gain < NGAINS; 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 );
@@ -169,8 +200,14 @@ int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEven
     }
 
   fPhosEventCount++; 
+
+  if( (fPhosEventCount%fHistoWriteFrequency == 0) &&  ( fPhosEventCount != 0))
+    {
+      char* arg = new char[9];
+      sprintf(arg, "recreate");
+      fRcuHistoProducerPtr->WriteAllHistograms(arg);
+    }
   return 0;
-  
 }//end DoEvent
 
 
@@ -202,3 +239,4 @@ AliHLTPHOSRcuHistogramProducerComponent::Spawn()
 }
 
 
+