]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALCalibHistoProducer.cxx
Coverity corrections
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALCalibHistoProducer.cxx
index 43add41ee11371557f0db94bebe686d8133cb986..58c02b5fadf304010f6b70d9f916732e98d6a8ee 100644 (file)
 /* $Id$ */
 /* History of cvs commits:
  *
- * $Log$ 
+ * $Log$
+ * Revision 1.1  2006/12/07 16:32:16  gustavo
+ * First shuttle code, online calibration histograms producer, EMCAL preprocessor
+ * 
  *
 */
 ///////////////////////////////////////////////////////////////////////////////
 // Adapted for EMCAL by Gustavo Conesa Balbastre, October 2006
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "AliLog.h"
-#include "AliEMCALCalibHistoProducer.h"
 #include "TH1.h"
 #include "TFile.h"
 #include "TProfile.h"
+
+
+#include "AliLog.h"
 #include "AliRawReader.h"
-#include "AliCaloRawStream.h"
+#include "AliCaloRawStreamV3.h"
+#include "AliEMCALCalibHistoProducer.h"
 
 ClassImp(AliEMCALCalibHistoProducer)
 
 //-----------------------------------------------------------------------------
 AliEMCALCalibHistoProducer::AliEMCALCalibHistoProducer(AliRawReader* rawReader) : 
-  fRawReader(rawReader),fHistoFile(0),fHistoFileName("calibHisto.root"),
-  fUpdatingRate(100),fIsOldRCUFormat(kFALSE), fNSuperModules(12),  fNCellsEta (48),   
+  TObject(),fRawReader(rawReader),fHistoFile(0),fHistoFileName("calibEmcHisto.root"),
+  fUpdatingRate(100), fNSuperModules(12),  fNCellsEta (48),   
   fNCellsPhi(24),  fNCellsPhiHalfSM(12)
 {
   // Constructor
@@ -56,14 +61,43 @@ AliEMCALCalibHistoProducer::AliEMCALCalibHistoProducer(AliRawReader* rawReader)
          fAmpHisto[ism][icol][irow]=0;
   }
 
+}
+//-----------------------------------------------------------------------------
+AliEMCALCalibHistoProducer::AliEMCALCalibHistoProducer() : 
+  fRawReader(0x0),fHistoFile(0),fHistoFileName(""),
+  fUpdatingRate(0), fNSuperModules(12),  fNCellsEta (48),   
+  fNCellsPhi(24),  fNCellsPhiHalfSM(12)
+{
+  // default Constructor
+
+  for(Int_t ism=0; ism<fNSuperModules; ism++) {
+    fAmpProf[ism] = 0;
+    fSMInstalled[ism]=kTRUE;
+    for(Int_t icol=0; icol<fNCellsEta; icol++) 
+      for(Int_t irow=0; irow<fNCellsPhi; irow++) 
+         fAmpHisto[ism][icol][irow]=0;
+  }
+
 }
 
 //-----------------------------------------------------------------------------
-AliEMCALCalibHistoProducer::AliEMCALCalibHistoProducer() :
-  fRawReader(0),fHistoFile(0),fUpdatingRate(0),fIsOldRCUFormat(kFALSE),
-  fNSuperModules(12), fNCellsEta (48), fNCellsPhi(24), fNCellsPhiHalfSM(12)
+AliEMCALCalibHistoProducer::AliEMCALCalibHistoProducer(const AliEMCALCalibHistoProducer & copy) :
+  TObject(copy),fRawReader((AliRawReader*)copy. fRawReader->Clone()),
+  fHistoFile((TFile*)copy.fHistoFile->Clone()),fHistoFileName(copy.fHistoFileName),
+  fUpdatingRate(copy.fUpdatingRate),
+  fNSuperModules(copy.fNSuperModules), fNCellsEta (copy.fNCellsEta), 
+  fNCellsPhi(copy.fNCellsPhi), fNCellsPhiHalfSM(copy.fNCellsPhiHalfSM)
 {
-  // Default constructor
+  //copy constructor
+
+ for(Int_t ism=0; ism<fNSuperModules; ism++) {
+    fAmpProf[ism] = copy. fAmpProf[ism];
+    fSMInstalled[ism]= copy.fSMInstalled[ism];
+    for(Int_t icol=0; icol<fNCellsEta; icol++) 
+      for(Int_t irow=0; irow<fNCellsPhi; irow++) 
+         fAmpHisto[ism][icol][irow]= copy.fAmpHisto[ism][icol][irow];
+  }
+
 }
 
 //-----------------------------------------------------------------------------
@@ -75,6 +109,37 @@ AliEMCALCalibHistoProducer::~AliEMCALCalibHistoProducer()
     delete fHistoFile;
   }
 }
+
+//------------------------------------------------------------------------------
+//
+AliEMCALCalibHistoProducer& AliEMCALCalibHistoProducer::operator=(const AliEMCALCalibHistoProducer& copy)
+{
+       //
+       // Assignment operator.
+       // Besides copying all parameters, duplicates all collections.  
+       //
+                if (&copy == this) return *this;
+       TObject::operator=(copy);
+       fHistoFileName = copy.fHistoFileName;
+       fUpdatingRate = copy.fUpdatingRate;
+       fNSuperModules = copy.fNSuperModules;
+       fNCellsEta = copy.fNCellsEta;
+       fNCellsPhi = copy.fNCellsPhi;
+       fNCellsPhiHalfSM = copy.fNCellsPhiHalfSM;
+       
+       fRawReader  = (AliRawReader*)copy. fRawReader->Clone();
+       fHistoFile      = (TFile*)copy.fHistoFile->Clone();
+
+       for(Int_t ism=0; ism<fNSuperModules; ism++) {
+         fAmpProf[ism] = copy. fAmpProf[ism];
+         fSMInstalled[ism]= copy.fSMInstalled[ism];
+         for(Int_t icol=0; icol<fNCellsEta; icol++) 
+           for(Int_t irow=0; irow<fNCellsPhi; irow++) 
+             fAmpHisto[ism][icol][irow]= copy.fAmpHisto[ism][icol][irow];
+       }
+
+       return (*this);
+}
 //-----------------------------------------------------------------------------
 void AliEMCALCalibHistoProducer::Init()
 {
@@ -82,14 +147,15 @@ void AliEMCALCalibHistoProducer::Init()
   // Checks existence of histograms which might have been left
   // from the previous runs to continue their filling
   fHistoFile =  new TFile(fHistoFileName,"update");
-  char hname[128];
+  const Int_t buffersize = 128;
+  char hname[buffersize];
   Int_t nRow =  fNCellsPhi ;
 
   for(Int_t supermodule=0; supermodule<fNSuperModules; supermodule++) {
     //Check installed supermodules
     if(fSMInstalled[supermodule]==kFALSE) continue;
     //Check created profiles
-    sprintf(hname,"mod%d",supermodule);
+    snprintf(hname,buffersize,"mod%d",supermodule);
     TProfile* prof = (TProfile*)fHistoFile->Get(hname);
     if(prof)
       fAmpProf[supermodule]=prof;
@@ -98,10 +164,10 @@ void AliEMCALCalibHistoProducer::Init()
     if(supermodule > 10) nRow = fNCellsPhiHalfSM ; //Supermodules 11 and 12 are half supermodules
     for(Int_t column=0; column<fNCellsEta; column++) {
       for(Int_t row=0; row<nRow; row++) {
-       sprintf(hname,"mod%dcol%drow%d",supermodule,column,row);
-       TH1F* hist = (TH1F*)fHistoFile->Get(hname);
-       if(hist) 
-         fAmpHisto[supermodule][column][row]=hist;
+        snprintf(hname,buffersize,"mod%dcol%drow%d",supermodule,column,row);
+        TH1F* hist = (TH1F*)fHistoFile->Get(hname);
+        if(hist) 
+          fAmpHisto[supermodule][column][row]=hist;
       }
     }
   }
@@ -118,57 +184,65 @@ void AliEMCALCalibHistoProducer::Run()
   
 //   TH1F* gHighGain = 0;
 //   TH1F* gLowGain = 0;
-  Int_t iBin = 0;
+  const Int_t buffersize=128;
+  char hname[buffersize];
   Int_t iEvent = 0;
   Int_t runNum = 0;
   Int_t nProfFreq = 1000; //Number of events with which a bin of the TProfile if filled
   Int_t nEvtBins = 1000; //Total number of the profile survey bins.
 
-  AliCaloRawStream in(fRawReader,"EMCAL");
-  if(fIsOldRCUFormat)
-    in.SetOldRCUFormat(kTRUE);
+  AliCaloRawStreamV3 in(fRawReader,"EMCAL");
 
   // Read raw data event by event
 
   while (fRawReader->NextEvent()) {
     runNum = fRawReader->GetRunNumber();
-    Float_t energy = 0;
-     while ( in.Next() ) { 
 
-      if(fSMInstalled[in.GetModule()]==kFALSE) continue;
-       
-      if (in.GetSignal() > energy) {
-       energy = (Double_t) in.GetSignal();
-      }    
+    while (in.NextDDL()) {
+      while (in.NextChannel()) {
+
+       if(fSMInstalled[in.GetModule()]==kFALSE) continue;
 
-      iBin++;
+       // loop over samples
+       int nsamples = 0;
+       Int_t maxSample = 0;
+       while (in.NextBunch()) {
+         const UShort_t *sig = in.GetSignals();
+         nsamples += in.GetBunchLength();
+         for (Int_t i = 0; i < in.GetBunchLength(); i++) {
+           if (sig[i] > maxSample) maxSample = sig[i];
+         }
+       } // bunches
 
-      if(iBin==in.GetTimeLength()) {
-       iBin=0;
-           
+       if (nsamples > 0) { // this check is needed for when we have zero-supp. on, but not sparse readout
+
+       // indices
        Int_t mod = in.GetModule();
        Int_t col = in.GetColumn();
        Int_t row = in.GetRow();
        Int_t evtbin = iEvent/nProfFreq;
-       char hname[128];
-
+       Bool_t HighGainFlag = in.IsHighGain();
+       
        //Check if histogram/profile already exist, if not create it.
        if(!fAmpHisto[mod][col][row]) {
-         sprintf(hname,"mod%dcol%drow%d",mod,col,row);
+         snprintf(hname,buffersize,"mod%dcol%drow%d",mod,col,row);
          fAmpHisto[mod][col][row] = new TH1F(hname,hname,1024,-0.5,1023.);
        }
        if(!fAmpProf[mod]) {
-         sprintf(hname,"mod%d",mod);
+         snprintf(hname,buffersize,"mod%d",mod);
          fAmpProf[mod] = new TProfile(hname,hname,nEvtBins,0.,nEvtBins);
        }
+               
        //Fill histogram/profile 
-       Bool_t lowGainFlag = in.IsLowGain();
-       if(!lowGainFlag) {
-         fAmpHisto[mod][col][row]->Fill(energy);
-         fAmpProf[mod]->Fill(evtbin, energy);
+       if(HighGainFlag) {
+         fAmpHisto[mod][col][row]->Fill(maxSample);
+         fAmpProf[mod]->Fill(evtbin, maxSample);
        }
-      }
-    }
+
+      } // nsamples>0 check, some data found for this channel; not only trailer/header
+
+      } // channels
+    } // DDL's
 
     // update histograms in local file every 100th event
     if(iEvent%fUpdatingRate == 0) {