/* ======================================================================== *\
!
! *
! * This file is part of MARS, the MAGIC Analysis and Reconstruction
! * Software. It is distributed to you in the hope that it can be a useful
! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
! * It is distributed WITHOUT ANY WARRANTY.
! *
! * Permission to use, copy, modify and distribute this software and its
! * documentation for any purpose is hereby granted without fee,
! * provided that the above copyright notice appear in all copies and
! * that both that copyright notice and this permission notice appear
! * in supporting documentation. It is provided "as is" without express
! * or implied warranty.
! *
!
!
!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
!
!   Copyright: MAGIC Software Development, 2000-2004
!
\* ======================================================================== */
/////////////////////////////////////////////////////////////////////////////
//                                                                         //
// MCalibrationPix                                                         //
//                                                                         //
// Base Storage container to for a calibration pixel                       //
//                                                                         //
/////////////////////////////////////////////////////////////////////////////
#include "MCalibrationPix.h"

ClassImp(MCalibrationPix);

using namespace std;

// --------------------------------------------------------------------------
//
// Default Constructor: 
//
MCalibrationPix::MCalibrationPix(const char *name, const char *title)
    : fPixId(-1),
      fFlags(0)
{

  fName  = name  ? name  : "MCalibrationPix";
  fTitle = title ? title : "Container of the fit results of MHCalibrationPixs ";

  Clear();

}

// ------------------------------------------------------------------------
//
// Invalidate values
//
void MCalibrationPix::Clear(Option_t *o)
{

  fHiGainNumPickup     =  -1 ;
  fHiGainMean          =  -1.;
  fHiGainMeanVar       =  -1.;
  fHiGainProb          =  -1.;
  fHiGainSigma         =  -1.;
  fHiGainSigmaVar      =  -1.;

  fLoGainNumPickup     =  -1 ;
  fLoGainMean          =  -1.;
  fLoGainMeanVar       =  -1.;
  fLoGainProb          =  -1.;
  fLoGainSigma         =  -1.;
  fLoGainSigmaVar      =  -1.;

  SetHiGainSaturation  ( kFALSE );
  SetExcluded          ( kFALSE );

}

// --------------------------------------------------------------------------
//
// Set the Hi Gain Saturation Bit from outside
//
void MCalibrationPix::SetHiGainSaturation(Bool_t b)
{
    b ?  SETBIT(fFlags, kHiGainSaturation) : CLRBIT(fFlags, kHiGainSaturation); 
}


// --------------------------------------------------------------------------
//
// Set the Excluded Bit from outside 
//
void MCalibrationPix::SetExcluded(Bool_t b )
{ 
    b ?  SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded); 
}


Float_t MCalibrationPix::GetHiGainMeanErr()  const
{
  return TMath::Sqrt(fHiGainMeanVar);
}


Float_t MCalibrationPix::GetHiGainSigmaErr()  const
{
  return TMath::Sqrt(fHiGainSigmaVar);
}

Float_t MCalibrationPix::GetLoGainMeanErr()  const
{
  return TMath::Sqrt(fLoGainMeanVar);
}


Float_t MCalibrationPix::GetLoGainSigmaErr()  const
{
  return TMath::Sqrt(fLoGainSigmaVar);
}


Bool_t MCalibrationPix::IsExcluded()     const
{ 
   return TESTBIT(fFlags,kExcluded);  
}

Bool_t MCalibrationPix::IsHiGainSaturation()    const
{ 
   return TESTBIT(fFlags,kHiGainSaturation);  
}

