Improved online calibration algorithms, Energy and Dead channel histograms updated
authorphille <phille@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Oct 2007 15:54:20 +0000 (15:54 +0000)
committerphille <phille@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Oct 2007 15:54:20 +0000 (15:54 +0000)
to file during run if requested by user

HLT/PHOS/AliHLTPHOSRcuHistogramProducer.cxx
HLT/PHOS/AliHLTPHOSRcuHistogramProducer.h
HLT/PHOS/AliHLTPHOSRcuHistogramProducerComponent.cxx
HLT/PHOS/AliHLTPHOSRcuHistogramProducerComponent.h

index 142828b8069b26f789fb42246da8e168c28d3156..0c25d08f9f59d590d4cc386ba7b288f12aa77e6a 100644 (file)
 
 #include "AliHLTPHOSRcuHistogramProducer.h"
 #include <iostream>
-//#include "stdio.h"
-#//include <cstdlib>
 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
 #include "TFile.h"
+#include "unistd.h"
+#include <time.h>
+
+#define THRESHOLD 30
 
 using  namespace std;
 
@@ -33,8 +35,9 @@ using  namespace std;
 **************************************************************************/
 
 
-AliHLTPHOSRcuHistogramProducer:: AliHLTPHOSRcuHistogramProducer(): fModuleID(0), fRcuX(0), fRcuZ(0)
+AliHLTPHOSRcuHistogramProducer:: AliHLTPHOSRcuHistogramProducer():  AliHLTPHOSBase(), fModuleID(0), fRcuX(0), fRcuZ(0)
 
+//AliHLTPHOSRcuHistogramProducer:: AliHLTPHOSRcuHistogramProducer():  AliHLTPHOSRcuProcessor(), fModuleID(0), fRcuX(0), fRcuZ(0)
 {
   //Default constructor
   cout << "WARNING: You cannot invoke the AliHLTPHOSRcuHistogramProducer without arguments" << endl;
@@ -45,6 +48,22 @@ AliHLTPHOSRcuHistogramProducer:: AliHLTPHOSRcuHistogramProducer(): fModuleID(0),
 AliHLTPHOSRcuHistogramProducer::AliHLTPHOSRcuHistogramProducer(AliHLTUInt8_t moduleID, AliHLTUInt8_t rcuX, AliHLTUInt8_t rcuZ)
 {
   //Se header file for documentation
+  //  char *tmp = getenv("ALIHLT_BASEDIR");
+  char *tmp = getenv("HOME");
+
+  if(tmp == 0)
+    {
+      cout << "ERROR, environment vriable HOME is not set" << endl;
+
+    }
+  
+  else
+    {
+      //  sprintf(fHistoOutDir,"%s/rundir/output/histograms",tmp);
+      sprintf(fHistoOutDir,"%s/rundir/output/histograms/",tmp);
+    }
+  
+
   SetModuleID(moduleID);
   SetRcuX(rcuX); 
   SetRcuZ(rcuZ); 
@@ -57,6 +76,37 @@ AliHLTPHOSRcuHistogramProducer::~ AliHLTPHOSRcuHistogramProducer()
 }
 
 
+void
+AliHLTPHOSRcuHistogramProducer::SetHistoOutDir(char *outDir)
+{
+  sprintf(fHistoOutDir,"%s", outDir);
+}
+
+void 
+AliHLTPHOSRcuHistogramProducer::SetDefaultHistoOutDir()
+{
+  char *tmp = getenv("HOME/rundir"); 
+  sprintf(fHistoOutDir,"%s/rundir/output/histograms", tmp);
+  //testing wether or not directry exist
+  FILE *fp = fopen(fHistoOutDir, "w");
+  
+  if(fp == 0)
+    {
+      cout << "ERROR, directory =" << fHistoOutDir << "  Doesnt exist, or you don have write permissions to the directory" << endl;
+      cout << "WARNING: Histograms will not bew written to files at end of run unless a valid directory is set" << endl;
+      cout << "INFO, You must either" << endl;
+      cout << "1) Create the directory " << fHistoOutDir <<  "Manually" <<endl;
+      cout << "OR "<< endl;
+      cout << "2) Se a valid output directory with the function AliHLTPHOSRcuHistogramProducer::SetHistoOutDir(*char outdir) "<< endl;
+   }
+  else
+    {
+      cout << "INFO: Output ddirectory for Histograms was set tot" << fHistoOutDir << endl;
+      cout << "INFO: if you want another output directory use the AliHLTPHOSRcuHistogramProducer::SetHistoOutDir(*char outdir)" << endl;
+    }
+
+} 
+
 void
 AliHLTPHOSRcuHistogramProducer::Init()
 {
@@ -66,6 +116,23 @@ AliHLTPHOSRcuHistogramProducer::Init()
   int geomz;
     
 
+  for(int gain=0; gain< N_GAINS; gain++)
+    {
+      sprintf(tmpHistoName, "DeadChanneMap_Module%d_rcuz%d_rcux%d_gain%d",(int)fModuleID,  fRcuZ, fRcuX, gain);
+      //    fDeadChannelMapHistogramPtrs[gain] = new TH2D( tmpHistoName, tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
+
+          
+      fDeadChannelMapHistogramPtrs[gain] = new TH2D(tmpHistoName, tmpHistoName,  
+                                     N_XCOLUMNS_RCU , 0, N_XCOLUMNS_RCU , 
+                                     N_ZROWS_RCU,         0, N_ZROWS_RCU);
+      fDeadChannelMapHistogramPtrs[gain]->Reset(); 
+      //     fgCalibHistPtr[gain]->GetXaxis()->SetRange(128, 128 + 64);
+      
+
+    }
+
+
+
   for(int x = 0; x < N_XCOLUMNS_RCU; x ++)
     {
       for(int z = 0; z < N_ZROWS_RCU; z ++)
@@ -79,14 +146,23 @@ AliHLTPHOSRcuHistogramProducer::Init()
              fAccumulatedValues[x][z][gain]   = 0;
              fTimingAverageValues[x][z][gain] = 0; 
              fHits[x][z][gain]                = 0;
+             fDeadChannelMap[x][z][gain]      = 0;
+
              sprintf(tmpHistoName, "Edistribution_%d_%d_%d_%d",(int)fModuleID,  geomx, geomz, gain);
-             fEnergyHistogramPtrs[x][z][gain] = 0;
+             //              fEnergyHistogramPtrs[x][z][gain] = 0;
              fEnergyHistogramPtrs[x][z][gain] = new TH1F( tmpHistoName, tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
-             sprintf(tmpHistoName, "TOFdistribution_%d_%d_%d_%d",(int)fModuleID,  geomx, geomz, gain);
-             fTimingHistogramPtrs[x][z][gain] = 0;
+             sprintf(tmpHistoName, "TOFdistribution_module%d_x%d_z%d_gain%d", (int)fModuleID,  geomx, geomz, gain);
+             
+             //              fTimingHistogramPtrs[x][z][gain] = 0;
+             
+             //              sprintf(tmpHistoName, "DeadChanneMap_%d_%d_%d_%d",(int)fModuleID,  geomx, geomz, gain);
+             //              fDeadChannelMapHistogramPtrs[x][z][gain] = new TH1D( tmpHistoName, tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
+
+
              fTimingHistogramPtrs[x][z][gain] = new TH1F(tmpHistoName , tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
              fCellAccEnergy.fAccumulatedEnergies[x][z][gain] = 0;
              fCellAccEnergy.fHits[x][z][gain] = 0;
+             fCellAccEnergy.fDeadChannelMap[x][z][gain] = 0;
              fCellAccEnergy.fModuleID = 0;
              fCellAccEnergy.fRcuX = 0;
              fCellAccEnergy.fRcuZ = 0; 
@@ -96,6 +172,7 @@ AliHLTPHOSRcuHistogramProducer::Init()
 }
 
 
+
 void 
 AliHLTPHOSRcuHistogramProducer::SetRcuX(AliHLTUInt8_t X)
 {
@@ -128,13 +205,9 @@ AliHLTPHOSRcuHistogramProducer::SetModuleID(AliHLTUInt8_t moduleID)
 void 
 AliHLTPHOSRcuHistogramProducer::FillEnergy(AliHLTUInt8_t x, AliHLTUInt8_t z,  AliHLTUInt8_t gain, float energy)
 {
-  //  cout << "AliHLTPHOSRcuHistogramProducer::FillEnergy x = " << (int)x<< "  z=  " << (int)z;
-  //  cout << " Energy =" <<  energy;
-  //  cout << " Accumulated energy" <<fCellAccEnergy.fAccumulatedEnergies[x][z][gain] << endl; 
-  //See header file for documentation
   fCellAccEnergy.fAccumulatedEnergies[x][z][gain] += energy;
-  fCellAccEnergy.fHits[x][z][gain] ++; 
-  fEnergyHistogramPtrs[x][z][gain]->Fill(energy);
+  fCellAccEnergy.fHits[x][z][gain] ++;
+  fEnergyHistogramPtrs[x][z][gain]->Fill(energy); 
 }
 
 
@@ -152,6 +225,45 @@ AliHLTPHOSRcuHistogramProducer::GetCellAccumulatedEnergies()
   return fCellAccEnergy ;
 }
 
+void 
+AliHLTPHOSRcuHistogramProducer::FillLiveChannels(Int_t data[], int size,  Int_t x, Int_t z, Int_t gain)
+{
+  for(Int_t i = 0; i < size; i++)
+    {
+      if(data[i] > THRESHOLD)
+       {
+         if(data[i+1] > THRESHOLD) 
+           {
+             if(data[i+2] > THRESHOLD)
+               {
+                 if(data[i+3] > THRESHOLD)
+                   {
+                     
+                     fCellAccEnergy.fDeadChannelMap[x][z][gain] = 10;
+                     
+                     return;
+                   }
+               }
+           }
+       }
+    }
+}
+
+void 
+AliHLTPHOSRcuHistogramProducer::FillLiveChannelHistograms()
+{
+  for(int x = 0; x <  N_XCOLUMNS_RCU; x ++)
+    {
+      for(int z = 0; z < N_ZROWS_RCU; z ++)
+       {
+         for(int gain = 0; gain < N_GAINS; gain ++)
+           {
+             fDeadChannelMapHistogramPtrs[gain]->SetBinContent(x ,z , fCellAccEnergy.fDeadChannelMap[x][z][gain]);
+           }
+       } 
+    }
+
+}
 
 void
 AliHLTPHOSRcuHistogramProducer::Reset()
@@ -167,6 +279,7 @@ AliHLTPHOSRcuHistogramProducer::Reset()
              fAccumulatedValues[x][z][gain]   = 0;
              fTimingAverageValues[x][z][gain] = 0; 
              fHits[x][z][gain]                = 0;
+             fDeadChannelMap[x][z][gain]      = 0;
            }
        } 
     }
@@ -179,31 +292,125 @@ AliHLTPHOSRcuHistogramProducer::Reset()
 
 
 void 
-AliHLTPHOSRcuHistogramProducer::WriteEnergyHistograms()
+AliHLTPHOSRcuHistogramProducer::WriteAllHistograms(char *opt)
 {
-  //See header file for documentation
-  char tmpFileName[256];
-  sprintf(tmpFileName,"/home/aliphoshlt/rundir/outdata/calibHisto_%d_%d_%d.root", (int)fModuleID, (int)fRcuX, (int)fRcuZ);
-  TFile *histoFile =  new TFile(tmpFileName,"update");
-  char hname[128];
-  if(!histoFile) return;
-  if(!histoFile->IsOpen()) return;
+  printf("\nAliHLTPHOSRcuHistogramProducer::WriteAllHistogram, opt = %s\n", opt);
+
+  FillLiveChannelHistograms();
+  //  cout <<<< endl;
+
+  int runNumber = 0;
+  char tmpEFileName[256];
+  char tmpDeadFileName_gain0[256];
+  char tmpDeadFileName_gain1[256]; 
+ // char *tmpRundir = getenv("HOME");
+  char runNumberFile[256]; 
+  char timeString[256];
+
+  ResetArray(runNumberFile, 256);
+  ResetArray(tmpEFileName, 256);
+  ResetArray(timeString, 256);
+  
+
+  sprintf(runNumberFile, "%s/rundir/runNumber.txt", getenv("HOME"));
+
+  FILE *fp = fopen(runNumberFile, "r");
+  if(fp == 0)
+    {
+      ScanTimeString(timeString);  
+      cout << "WARNING, could not find file "<< runNumberFile  <<endl;
+      cout <<"Filename will be stamped with data and time instead " << endl;
+      sprintf(tmpEFileName, "%s/Energy/EnergyHistograms_%s_mod%d_rcuZ%d_rcuX%d.root", fHistoOutDir, timeString, (int)fModuleID, (int)fRcuZ, (int)fRcuZ);
+      sprintf(tmpDeadFileName_gain0, "%s/DeadMap/DeadChannelHistograms_%s_mod%d_rcuZ%d_rcuX%d_LG.root", fHistoOutDir, timeString, (int)fModuleID, (int)fRcuZ, (int)fRcuZ); 
+      sprintf(tmpDeadFileName_gain1, "%s/DeadMap/DeadChannelHistograms_%s_mod%d_rcuZ%d_rcuX%d_HG.root", fHistoOutDir, timeString, (int)fModuleID, (int)fRcuZ, (int)fRcuZ); 
+    } 
+  else
+    {
+      fscanf(fp, "%d", &runNumber);
+      sprintf(tmpEFileName, "%s/Energy/EnergyHisttograms_run%d_mod%d_rcuZ%d_rcuX%d.root", fHistoOutDir, runNumber, (int)fModuleID, (int)fRcuZ, (int)fRcuX);
+      sprintf(tmpDeadFileName_gain0, "%s/DeadMap/DeadChannleHistograms_run%d_mod%d_rcuZ%d_rcuX%d_LG.root", fHistoOutDir, runNumber, (int)fModuleID, (int)fRcuZ, (int)fRcuX);
+      sprintf(tmpDeadFileName_gain1, "%s/DeadMap/DeadChannleHistograms_run%d_mod%d_rcuZ%d_rcuX%d_HG.root", fHistoOutDir, runNumber, (int)fModuleID, (int)fRcuZ, (int)fRcuX);
+      fclose(fp);
+    }
+
+  //  cout << "tmpEFileName = "<< tmpEFileName <<endl;
+  //  cout << "tmpDeadFileName_gain0 (low gain)   = " << tmpDeadFileName_gain0 <<endl;
+  //  cout << "tmpDeadFileName_gain1 (high gain)  = " << tmpDeadFileName_gain1 <<endl;
+
+  //  sprintf(tmpEFileName,"/home/aliphoshlt/rundir/outdata/calibHisto_%d_%d_%d.root", (int)fModuleID, (int)fRcuX, (int)fRcuZ);
+
+
+  //  TFile *energyHistoFile =  new TFile(tmpEFileName,"update");
+  //  TFile *energyHistoFile =  new TFile(tmpEFileName,"recreate");
+  //  TFile *energyHistoFile =  new TFile(tmpEFileName,"recreate");
+
+  cout << "tmpEFileName = "<< tmpEFileName  << endl;
+
+  TFile *energyHistoFile =  new TFile(tmpEFileName, opt);
+  if(!energyHistoFile) return;
+  if(!energyHistoFile->IsOpen()) return;
 
   cout <<"printing histograms"<< endl;
-  cout <<"histofile-Getname() =" << histoFile->GetName() << endl;
 
-    for(int x = 0; x <  N_XCOLUMNS_RCU; x ++)
+  for(int x = 0; x <  N_XCOLUMNS_RCU; x ++)
     {
       for(int z = 0; z < N_ZROWS_RCU; z ++)
        {
          for(int gain = 0; gain < N_GAINS; gain ++)
            {
+             //     cout << "the number of entries is " <<fEnergyHistogramPtrs[x][z][gain]->GetEntries()<< endl;
              fEnergyHistogramPtrs[x][z][gain]->Write();
            }
        } 
     }
+  energyHistoFile->Close();
+
 
-    cout << "printing histograms, finished"<< endl;
-    histoFile->Close();
+  //LOW GAIN
+  //TFile *deadHistoFile_gain0 =  new TFile(tmpDeadFileName_gain0,"update");
+  TFile *deadHistoFile_gain0 =  new TFile(tmpDeadFileName_gain0, opt);
 
+  if(!deadHistoFile_gain0) return;
+  if(!deadHistoFile_gain0->IsOpen()) return;
+  fDeadChannelMapHistogramPtrs[0]->Write();
+
+
+  //HIGH GAIN
+  //  TFile *deadHistoFile_gain1 =  new TFile(tmpDeadFileName_gain1,"update");
+  TFile *deadHistoFile_gain1 =  new TFile(tmpDeadFileName_gain1, opt);
+  if(!deadHistoFile_gain1) return;
+  if(!deadHistoFile_gain1->IsOpen()) return;
+  fDeadChannelMapHistogramPtrs[1]->Write();
+
+
+  deadHistoFile_gain0->Close();
+  deadHistoFile_gain1->Close(); 
+
+  cout << "printing histograms, finished"<< endl;
+}
+
+void
+AliHLTPHOSRcuHistogramProducer::ScanTimeString(char *timeString)
+{
+  time_t timePtr;
+  tm *tmPtr;
+  //  char *timeString;
+  time(&timePtr); 
+  tmPtr=localtime(&timePtr);
+  timeString=asctime(tmPtr);
+  char tShort [strlen(timeString)+1];
+  char day[10];
+  char month[10];
+  int date;
+  int hour;
+  int min;
+  int sec;
+  int year;
+  char sDate[5];
+  char sHour[5];
+  char sMin[5];
+  char sSec[5];
+  char sYear[10];
+  sscanf(timeString, "%s %s %d %d:%d:%d %d\n", day, month, &date, &hour, &min, &sec, &year);
+  
 }
index eedfa9e71425dd76dd89d38bef80860aceee07e3..2d5d6b2bf6d1cfb3ab9aff87942e35ce67a5472d 100644 (file)
@@ -5,18 +5,21 @@
  * See cxx source for full Copyright notice  */ 
 
 #include "AliHLTPHOSDefinitions.h"
-#include "AliHLTPHOSCommonDefs.h"
 #include "TH1.h"
+#include "TH2D.h"
 #include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
+//#include "AliHLTPHOSBase.h"
+#include "AliHLTPHOSRcuProcessor.h"
 
 #define XBIN_LOW  0
 #define XBIN_UP   1023
 #define N_BINS    1023
 
-class AliHLTPHOSRcuHistogramProducer
+class AliHLTPHOSRcuHistogramProducer : public AliHLTPHOSBase
+//class AliHLTPHOSRcuHistogramProducer : public AliHLTPHOSRcuProcessor
 {
  public:
-  AliHLTPHOSRcuHistogramProducer();
+  //  AliHLTPHOSRcuHistogramProducer();
   AliHLTPHOSRcuHistogramProducer(AliHLTUInt8_t moduleID, AliHLTUInt8_t rcuX, AliHLTUInt8_t rcuZ);
   virtual ~AliHLTPHOSRcuHistogramProducer();
   const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct& GetCellAccumulatedEnergies(); 
@@ -24,27 +27,36 @@ class AliHLTPHOSRcuHistogramProducer
   void SetRcuX(AliHLTUInt8_t X);
   void SetRcuZ(AliHLTUInt8_t Z);
   void SetModuleID(AliHLTUInt8_t moduleID); 
+  void SetHistoOutDir(char *outDir);
   void FillEnergy(AliHLTUInt8_t x, AliHLTUInt8_t z,  AliHLTUInt8_t gain, float energy);
   void FillTime(AliHLTUInt8_t x,   AliHLTUInt8_t z,  AliHLTUInt8_t gain, float time); 
+
+  void FillLiveChannels(Int_t data[], int size, Int_t x, Int_t z, Int_t gain);
+  void FillLiveChannelHistograms();
+
   void Reset();
-  void WriteEnergyHistograms();
+  void WriteAllHistograms(char opt[] = "update");
 
  protected:
  
  private:
-  AliHLTPHOSRcuHistogramProducer(const AliHLTPHOSRcuHistogramProducer & );
-  AliHLTPHOSRcuHistogramProducer & operator = (const AliHLTPHOSRcuHistogramProducer &)
-   {
-      return *this;
-   };
+  void SetDefaultHistoOutDir(); 
+  void ScanTimeString(char *timeString);
+
+  AliHLTPHOSRcuHistogramProducer();
+  char fHistoOutDir[512];
+
 
   TH1F *fEnergyHistogramPtrs[N_XCOLUMNS_RCU][N_ZROWS_RCU][N_GAINS];    /**<Array to store energy distribution per channel for one rcu*/
   TH1F *fTimingHistogramPtrs[N_XCOLUMNS_RCU][N_ZROWS_RCU][N_GAINS];    /**<Array to store timing distribution per channel for one rcu*/
+  //  TH1D *fDeadChannelMapHistogramPtrs[N_XCOLUMNS_RCU][N_ZROWS_RCU][N_GAINS];
+  TH2D *fDeadChannelMapHistogramPtrs[N_GAINS];
 
   Float_t fEnergyAverageValues[N_XCOLUMNS_RCU][N_ZROWS_RCU][N_GAINS];  /**<Accumulated energy divided by  hits*/
   Double_t fAccumulatedValues[N_XCOLUMNS_RCU][N_ZROWS_RCU][N_GAINS];   /**<Array to store accumulated energy per channel for one rcu during run*/
   Float_t fTimingAverageValues[N_XCOLUMNS_RCU][N_ZROWS_RCU][N_GAINS];  /**<Avereage TOF*/
   AliHLTUInt32_t fHits[N_XCOLUMNS_RCU][N_ZROWS_RCU][N_GAINS];
+  AliHLTUInt32_t fDeadChannelMap[N_XCOLUMNS_RCU][N_ZROWS_RCU][N_GAINS];
   Double_t fTmpChannelData[ALTRO_MAX_SAMPLES];        /**<temporary variable to store raw samples from a single altro channel*/
   AliHLTPHOSRcuCellAccumulatedEnergyDataStruct fCellAccEnergy;
   AliHLTUInt8_t fModuleID; /**<ID of the module this component read data from (0-4)*/
index 605c8252991ff7564be9a921c90f0252d5b7b8b3..5fc970b04a63c81114e766b61ebcc329f5e85a59 100644 (file)
@@ -16,6 +16,8 @@
 
 //#include <iostream>
 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
+//#include "AliHLTPHOSDebugRcuHistogramProducer.h"
+//#include "AliHLTPHOSDebugRcuHistogramProducerComponent.h"
 #include "AliHLTPHOSRcuHistogramProducer.h"
 #include "AliHLTPHOSRcuHistogramProducerComponent.h"
 #include "AliHLTPHOSRcuCellAccumulatedEnergyDataStruct.h"
@@ -32,7 +34,7 @@ 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(), fRcuHistoProducerPtr(0), fHistoWriteFrequency(100)
 {
   //Default constructor
 } 
@@ -49,7 +51,8 @@ AliHLTPHOSRcuHistogramProducerComponent::Deinit()
 {
   //See html documentation of base class
   cout << "AliHLTPHOSRcuHistogramProducerComponent::Deinit()" << endl;
-  fRcuHistoProducerPtr->WriteEnergyHistograms();
+  //  fRcuHistoProducerPtr->WriteAllHistograms("update");
+  fRcuHistoProducerPtr->WriteAllHistograms("recreate");
   return 0;
 }
 
@@ -92,10 +95,13 @@ 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 )
 {
+  //  cout << "AliHLTPHOSRcuHistogramProducerComponent::DoEven TP0"   << endl;
+
   //See html documentation of base class
   unsigned long ndx       = 0;
   UInt_t offset           = 0; 
@@ -105,27 +111,35 @@ int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEven
   AliHLTPHOSRcuCellEnergyDataStruct *cellDataPtr;
   AliHLTUInt8_t* outBPtr;
   int tmpCnt;
-  
-  
+
   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
       iter = blocks+ndx;
-      cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
+      if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
+       {
+         //      cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
+         continue;
+       }
+     cellDataPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)( iter->fPtr);
       tmpCnt =  cellDataPtr->fCnt;
-      for(int i= 0; i <= tmpCnt; i ++)
+
+      for(int i= 0; i <  tmpCnt; i ++)
        {
          fRcuHistoProducerPtr->FillEnergy(cellDataPtr->fValidData[i].fX,
-                                          cellDataPtr->fValidData[i].fZ, 
+                                          cellDataPtr->fValidData[i].fZ, 
                                           cellDataPtr->fValidData[i].fGain, 
                                           cellDataPtr->fValidData[i].fEnergy);
 
-         if(cellDataPtr->fValidData[i].fEnergy > 1024)
-           {
-             cout << " AliHLTPHOSRcuHistogramProducerComponent::DoEvent ERROR: cellDataPtr->fValidData[i].fEnergy =" <<  cellDataPtr->fValidData[i].fEnergy << endl;
-           }
+         fRcuHistoProducerPtr->FillLiveChannels(cellDataPtr->fValidData[i].fData, 
+                                                fNTotalSamples,
+                                                cellDataPtr->fValidData[i].fX,
+                                                cellDataPtr->fValidData[i].fZ,
+                                                cellDataPtr->fValidData[i].fGain);
        }
     }
-  
+  // cout << "Done filling\n";  
   
   outBPtr = outputPtr;
   fOutPtr =  (AliHLTPHOSRcuCellAccumulatedEnergyDataStruct*)outBPtr;
@@ -143,12 +157,15 @@ int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEven
            {
              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];
            }
        }
     }
 
 
+  //    cout << "AliHLTPHOSRcuHistogramProducerComponent::DoEven TP1"   << endl;
   //pushing data to shared output memory
+
   mysize += sizeof(AliHLTPHOSRcuCellAccumulatedEnergyDataStruct);
   AliHLTComponentBlockData bd;
   FillBlockData( bd );
@@ -159,6 +176,9 @@ int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEven
   outputBlocks.push_back( bd );
   tSize += mysize;
   outBPtr += mysize;
+  
+  //   cout << "AliHLTPHOSRcuHistogramProducerComponent::DoEven TP2"   << endl;
+
 
   if( tSize > size )
     {
@@ -169,7 +189,17 @@ int  AliHLTPHOSRcuHistogramProducerComponent::DoEvent( const AliHLTComponentEven
     }
 
   fPhosEventCount++; 
+
+  if( (fPhosEventCount%fHistoWriteFrequency == 0) &&  ( fPhosEventCount != 0))
+  //if( (fPhosEventCount%fHistoWriteFrequency == 0))
+    {
+      cout << "AliHLTPHOSRcuHistogramProducerComponent::DoEvent, updating histograms " << endl;
+      fRcuHistoProducerPtr->WriteAllHistograms("recreate");
+    }
+
   return 0;
+
   
 }//end DoEvent
 
index 3baabf0c43c18cc215dd1b5b2af240ffab221072..561c16d59d45c46be7febeda23be7347c4547483 100644 (file)
@@ -12,6 +12,7 @@
 //#include "Rtypes.h"
 
 
+
 class AliHLTPHOSRcuHistogramProducer;
 class AliHLTPHOSRcuCellAccumulatedEnergyDataStruct;
 
@@ -32,6 +33,8 @@ class AliHLTPHOSRcuHistogramProducerComponent:public AliHLTPHOSRcuProcessor
   virtual const char* GetComponentID();
 
  private:
+  int fHistoWriteFrequency;
+
   /*
   AliHLTPHOSRcuHistogramProducerComponent(const AliHLTPHOSRcuHistogramProducerComponent & );
   AliHLTPHOSRcuHistogramProducerComponent & operator = (const AliHLTPHOSRcuHistogramProducerComponent &)