]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSRawDecoder.cxx
Initialisations in constructor.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRawDecoder.cxx
index 6f376cc4dfe8ba9e2a6ec967a15cb3e77b626a34..7e80e640b0101f31ce4217fbba8bfe99222efb1c 100644 (file)
 // --- AliRoot header files ---
 #include "AliPHOSRawDecoder.h"
 #include "AliRawReader.h"
+#include "AliPHOSCalibData.h"
+#include "AliLog.h"
 
 ClassImp(AliPHOSRawDecoder)
 
 //-----------------------------------------------------------------------------
 AliPHOSRawDecoder::AliPHOSRawDecoder():
-  fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fQuality(0.),fPedestalRMS(0.),
-  fModule(-1),fColumn(-1),fRow(-1),fNewModule(-1),fNewColumn(-1),fNewRow(-1),fNewAmp(0),fNewTime(0), 
-  fLowGainFlag(kFALSE),fNewLowGainFlag(kFALSE),fOverflow(kFALSE),fSamples(0),fTimes(0)
+  TObject(),
+  fRawReader(0),
+  fCaloStream(0),
+  fPedSubtract(kFALSE),
+  fEnergy(-111),
+  fTime(-111),
+  fQuality(0.),
+  fPedestalRMS(0.),
+  fAmpOffset(0),
+  fAmpThreshold(0),
+  fModule(-1),
+  fColumn(-1),
+  fRow(-1),
+  fNewModule(-1),
+  fNewColumn(-1),
+  fNewRow(-1),
+  fNewAmp(0),
+  fNewTime(0), 
+  fLowGainFlag(kFALSE),
+  fNewLowGainFlag(kFALSE),
+  fOverflow(kFALSE),
+  fSamples(0),
+  fTimes(0),
+  fCalibData(0)
 {
   //Default constructor.
 }
 
 //-----------------------------------------------------------------------------
 AliPHOSRawDecoder::AliPHOSRawDecoder(AliRawReader* rawReader,  AliAltroMapping **mapping):
-  fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fQuality(0.),fPedestalRMS(0.),
-  fModule(-1),fColumn(-1),fRow(-1),fNewModule(-1),fNewColumn(-1),fNewRow(-1),fNewAmp(0),fNewTime(0),
-  fLowGainFlag(kFALSE),fNewLowGainFlag(kFALSE),fOverflow(kFALSE),fSamples(0),fTimes(0)
+  TObject(),
+  fRawReader(0),
+  fCaloStream(0),
+  fPedSubtract(kFALSE),
+  fEnergy(-111),
+  fTime(-111),
+  fQuality(0.),
+  fPedestalRMS(0.),
+  fAmpOffset(0),
+  fAmpThreshold(0),
+  fModule(-1),
+  fColumn(-1),
+  fRow(-1),
+  fNewModule(-1),
+  fNewColumn(-1),
+  fNewRow(-1),
+  fNewAmp(0),
+  fNewTime(0), 
+  fLowGainFlag(kFALSE),
+  fNewLowGainFlag(kFALSE),
+  fOverflow(kFALSE),
+  fSamples(0),
+  fTimes(0),
+  fCalibData(0)
 {
   //Construct a decoder object.
   //Is is user responsibility to provide next raw event 
@@ -83,15 +127,30 @@ AliPHOSRawDecoder::~AliPHOSRawDecoder()
 
 //-----------------------------------------------------------------------------
 AliPHOSRawDecoder::AliPHOSRawDecoder(const AliPHOSRawDecoder &phosDecoder ):
-  fRawReader(phosDecoder.fRawReader),fCaloStream(phosDecoder.fCaloStream),
+  TObject(),
+  fRawReader(phosDecoder.fRawReader),
+  fCaloStream(phosDecoder.fCaloStream),
   fPedSubtract(phosDecoder.fPedSubtract),
-  fEnergy(phosDecoder.fEnergy),fTime(phosDecoder.fTime),fQuality(phosDecoder.fQuality),fPedestalRMS(phosDecoder.fPedestalRMS),
-  fModule(phosDecoder.fModule),fColumn(phosDecoder.fColumn),
-  fRow(phosDecoder.fRow),fNewModule(phosDecoder.fNewModule),fNewColumn(phosDecoder.fNewColumn),
-  fNewRow(phosDecoder.fNewRow),fNewAmp(phosDecoder.fNewAmp),fNewTime(phosDecoder.fNewTime),
-  fLowGainFlag(phosDecoder.fLowGainFlag),fNewLowGainFlag(phosDecoder.fNewLowGainFlag),
-  fOverflow(phosDecoder.fOverflow),fSamples(phosDecoder.fSamples),
-  fTimes(phosDecoder.fTimes)
+  fEnergy(phosDecoder.fEnergy),
+  fTime(phosDecoder.fTime),
+  fQuality(phosDecoder.fQuality),
+  fPedestalRMS(phosDecoder.fPedestalRMS),
+  fAmpOffset(phosDecoder.fAmpOffset),
+  fAmpThreshold(phosDecoder.fAmpThreshold),
+  fModule(phosDecoder.fModule),
+  fColumn(phosDecoder.fColumn),
+  fRow(phosDecoder.fRow),
+  fNewModule(phosDecoder.fNewModule),
+  fNewColumn(phosDecoder.fNewColumn),
+  fNewRow(phosDecoder.fNewRow),
+  fNewAmp(phosDecoder.fNewAmp),
+  fNewTime(phosDecoder.fNewTime),
+  fLowGainFlag(phosDecoder.fLowGainFlag),
+  fNewLowGainFlag(phosDecoder.fNewLowGainFlag),
+  fOverflow(phosDecoder.fOverflow),
+  fSamples(phosDecoder.fSamples),
+  fTimes(phosDecoder.fTimes),
+  fCalibData(phosDecoder.fCalibData) 
 {
   //Copy constructor.
 }
@@ -110,6 +169,8 @@ AliPHOSRawDecoder& AliPHOSRawDecoder::operator = (const AliPHOSRawDecoder &phosD
     fEnergy = phosDecode.fEnergy;
     fTime = phosDecode.fTime;
     fQuality = phosDecode.fQuality ;
+    fPedestalRMS = phosDecode.fPedestalRMS ;
+    fAmpOffset = phosDecode.fAmpOffset ;
     fModule = phosDecode.fModule;
     fColumn = phosDecode.fColumn;
     fRow = phosDecode.fRow;
@@ -127,6 +188,7 @@ AliPHOSRawDecoder& AliPHOSRawDecoder::operator = (const AliPHOSRawDecoder &phosD
 
     if(fTimes) delete fTimes;
     fTimes = phosDecode.fTimes;
+    fCalibData = phosDecode.fCalibData; 
   }
 
   return *this;
@@ -142,9 +204,6 @@ Bool_t AliPHOSRawDecoder::NextDigit()
   
   AliCaloRawStream* in = fCaloStream;
   
-  Int_t    iBin     = 0;
-  Int_t    mxSmps   = fSamples->GetSize();
-  Int_t    tLength  = 0;
   fEnergy = -111;
   Float_t pedMean = 0;
   Float_t pedRMS = 0;
@@ -152,20 +211,10 @@ Bool_t AliPHOSRawDecoder::NextDigit()
   Float_t baseLine = 1.0;
   const Int_t kPreSamples = 10;
   
-  fSamples->Reset();
   while ( in->Next() ) { 
-
-     if(!tLength) {
-       tLength = in->GetTimeLength();
-       if(tLength>mxSmps) {
-        fSamples->Set(tLength);
-       }
-     }
-     
-     // Fit the full sample
-     if(in->IsNewHWAddress() && iBin>0) {
+    // Evaluate previous sample
+    if(in->IsNewHWAddress() && fEnergy!=-111){ //Do not return at first sample
        
-       iBin=0;
        //First remember new sample
        fNewLowGainFlag = in->IsLowGain();
        fNewModule = in->GetModule()+1;
@@ -173,13 +222,12 @@ Bool_t AliPHOSRawDecoder::NextDigit()
        fNewColumn = in->GetColumn()+1;
        fNewAmp = in->GetSignal() ;
        fNewTime=in->GetTime() ;                                                                                                                               
-       
-       // Temporarily we take the energy as a maximum amplitude
+       // We take the energy as a maximum amplitude
        // and the pedestal from the 0th point (30 Aug 2006).
-       // Time is not evaluated for the moment (12.01.2007). 
-       // Take is as a first time bin multiplied by the sample tick time
+       // Time is not evaluated 
+       // Take it as a first time bin multiplied by the sample tick time
        
-       if(fPedSubtract) 
+       if(fPedSubtract) {
         if (nPed > 0){
            fPedestalRMS=(pedRMS-pedMean*pedMean/nPed)/nPed ;
            if(fPedestalRMS > 0.) 
@@ -188,13 +236,26 @@ Bool_t AliPHOSRawDecoder::NextDigit()
          }
         else
           return kFALSE;
+       }
+       else{
+         //take pedestals from DB
+         Double_t pedestal = (Double_t) fAmpOffset ;
+         if(fCalibData){
+           Float_t truePed = fCalibData->GetADCpedestalEmc(fModule, fColumn, fRow) ;
+           Int_t   altroSettings = fCalibData->GetAltroOffsetEmc(fModule, fColumn, fRow) ;
+           pedestal += truePed - altroSettings ;
+         }
+         else{
+           printf("AliPHOSRawDecoder::NextDigit() Can not read data from OCDB \n") ;
+         }
+         fEnergy-=pedestal ;
+       }
        if (fEnergy < baseLine) fEnergy = 0;
 
        return kTRUE;
      }
 
      fLowGainFlag = in->IsLowGain();
-//     fTime =   in->GetTime();
      fTime = 1;
      fModule = in->GetModule()+1;
      fRow    = in->GetRow()   +1;
@@ -203,17 +264,17 @@ Bool_t AliPHOSRawDecoder::NextDigit()
     if(fLowGainFlag==fNewLowGainFlag && fModule==fNewModule &&
        fRow==fNewRow && fColumn==fNewColumn ){
        if(fNewAmp>fEnergy)  fEnergy = (Double_t)fNewAmp ;
-       fNewModule=-1 ;
+       fNewModule=-1 ;  //copyed, do not copy more
     } 
 
      //Calculate pedestal if necessary
-     if(fPedSubtract && in->GetTime() < kPreSamples) {
+     if(fPedSubtract && (in->GetTime() < kPreSamples)) {
        pedMean += in->GetSignal();
        pedRMS+=in->GetSignal()*in->GetSignal() ;
        nPed++;
      }
-     if((Double_t)in->GetSignal() > fEnergy) fEnergy = (Double_t)in->GetSignal();
-     iBin++ ;
+     if((Double_t)in->GetSignal() > fEnergy)
+       fEnergy = (Double_t)in->GetSignal();
      
    } // in.Next()