Ignore:
Timestamp:
04/08/04 17:58:54 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mcalib
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc

    r3673 r3678  
    6464using namespace std;
    6565
     66const Int_t MCalibrationCam::gkNumPulserColors = 4;
    6667// --------------------------------------------------------------------------
    6768//
     
    7374// - fAverageSectors
    7475//
     76// Initializes:
     77// - fPulserColor to kCT1
     78//
    7579// Creates a TClonesArray of MBadPixelsPix containers for the TClonesArray's:
    7680// - fAverageBadAreas
     
    8286//
    8387MCalibrationCam::MCalibrationCam(const char *name, const char *title)
    84     : fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL)
     88    : fPulserColor(kCT1), fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL)
    8589{
    8690    fName  = name  ? name  : "MCalibrationCam";
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCam.h

    r3667 r3678  
    1919{
    2020
     21public:
     22
     23  enum PulserColor_t { kCT1=0, kGREEN=1, kBLUE=2, kUV=3 }; // Possible Pulser colours
     24  static const Int_t gkNumPulserColors;                     // Number of Pulser colours (now set to: 4)
     25 
    2126protected:
    2227 
     28  PulserColor_t fPulserColor;        // Colour of the pulsed LEDs
     29
    2330  TClonesArray *fPixels;             //-> Array of MCalibrationPix, one per pixel
    2431  TClonesArray *fAverageAreas;       //-> Array of MCalibrationPix, one per pixel area
    2532  TClonesArray *fAverageSectors;     //-> Array of MCalibrationPix, one per camera sector
    26   TClonesArray *fAverageBadAreas;    //-> Array of MBadPixelsPix, one per pixel area
    27   TClonesArray *fAverageBadSectors;  //-> Array of MBadPixelsPix, one per camera sector
     33  TClonesArray *fAverageBadAreas;    //-> Array of MBadPixelsPix,   one per pixel area
     34  TClonesArray *fAverageBadSectors;  //-> Array of MBadPixelsPix,   one per camera sector
    2835 
    2936public:
     
    3239  ~MCalibrationCam();
    3340 
    34   virtual void Clear(    Option_t *o="" );
    35   void Init(const MGeomCam &geom);
    36   void InitSize( const UInt_t i );
    37   void InitAverageAreas(  const UInt_t i );
    38   void InitAverageSectors( const UInt_t i );
     41  virtual void Clear      ( Option_t *o=""               );
    3942
     43  void Init               ( const MGeomCam &geom         );
     44  void InitSize           ( const UInt_t i               );
     45  void InitAverageAreas   ( const UInt_t i               );
     46  void InitAverageSectors ( const UInt_t i               );
     47
     48  void SetPulserColor     ( const PulserColor_t col=kCT1)  { fPulserColor = col; }
     49 
    4050  // Getters
    4151  Int_t   GetSize()               const;
     
    4353  Int_t   GetAverageSectors()     const; 
    4454
    45   // Others
    46   MCalibrationPix &operator[](UInt_t i);
    47   const MCalibrationPix &operator[](UInt_t i) const;
     55        MCalibrationPix &GetAverageArea      ( UInt_t i );
     56  const MCalibrationPix &GetAverageArea      ( UInt_t i ) const;
     57        MBadPixelsPix   &GetAverageBadArea   ( UInt_t i );
     58  const MBadPixelsPix   &GetAverageBadArea   ( UInt_t i ) const;
     59        MBadPixelsPix   &GetAverageBadSector ( UInt_t i );
     60  const MBadPixelsPix   &GetAverageBadSector ( UInt_t i ) const;
     61        MCalibrationPix &GetAverageSector    ( UInt_t i );
     62  const MCalibrationPix &GetAverageSector    ( UInt_t i ) const;
     63        MCalibrationPix &operator[]          ( UInt_t i );
     64  const MCalibrationPix &operator[]          ( UInt_t i ) const;
    4865
    49   MCalibrationPix &GetAverageArea(UInt_t i);
    50   const MCalibrationPix &GetAverageArea(UInt_t i) const;
     66  const PulserColor_t    GetPulserColor()                 const { return fPulserColor; }
    5167
    52   MBadPixelsPix &GetAverageBadArea(UInt_t i);
    53   const MBadPixelsPix &GetAverageBadArea(UInt_t i) const;
    54 
    55   MCalibrationPix &GetAverageSector(UInt_t i);
    56   const MCalibrationPix &GetAverageSector(UInt_t i) const;
    57 
    58   MBadPixelsPix &GetAverageBadSector(UInt_t i);
    59   const MBadPixelsPix &GetAverageBadSector(UInt_t i) const;
    60 
    61   // Draws
     68  virtual Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
    6269  virtual void DrawPixelContent(Int_t num) const;   
    63  
    64   // Others
    65   virtual Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
    6670
    6771  ClassDef(MCalibrationCam, 1)  // Base class Container for Calibration Results Camera
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeBlindPix.cc

    r3672 r3678  
    5353/////////////////////////////////////////////////////////////////////////////
    5454#include "MCalibrationChargeBlindPix.h"
     55#include "MCalibrationCam.h"
    5556
    5657#include <TH1.h>
     
    184185// --------------------------------------------------------------------------
    185186//
     187// Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
     188// Return -1 if fFluxInsidePlexiglass    is 0.
     189// Return fFluxInsidePlexiglassVar / fFluxInsidePlexiglass^2
     190//
     191Float_t MCalibrationChargeBlindPix::GetFluxInsidePlexiglassRelVar() const
     192{
     193  if (fFluxInsidePlexiglassVar < 0.)
     194    return -1.;
     195
     196  if (fFluxInsidePlexiglass == 0.)
     197    return -1.;
     198 
     199  return fFluxInsidePlexiglassVar / (fFluxInsidePlexiglass * fFluxInsidePlexiglass) ;
     200}
     201
     202// --------------------------------------------------------------------------
     203//
    186204// Return -1 if fLambdaVar is smaller than 0.
    187205// Return square root of fLambdaVar
     
    279297  return gkBlindPixelQECT1Err * gkBlindPixelQECT1Err / gkBlindPixelQECT1 / gkBlindPixelQECT1 ;
    280298}
    281 
    282299
    283300// --------------------------------------------------------------------------
     
    355372  switch (fColor)
    356373    {
    357     case kGREEN:
     374    case MCalibrationCam::kGREEN:
    358375      fFluxInsidePlexiglass    = fLambda * gkBlindPixelQEGreen * TMath::Power(10,gkBlindPixelAttGreen);   
    359376      // attenuation has negligible error
    360377      fFluxInsidePlexiglassVar = GetLambdaRelVar() + GetBlindPixelQEGreenRelVar();
    361378      break;
    362     case kBLUE:
     379    case MCalibrationCam::kBLUE:
    363380      fFluxInsidePlexiglass    = fLambda * gkBlindPixelQEBlue * TMath::Power(10,gkBlindPixelAttBlue);   
    364381      // attenuation has negligible error
    365382      fFluxInsidePlexiglassVar = GetLambdaRelVar() + GetBlindPixelQEBlueRelVar();
    366383      break;
    367     case kUV:
     384    case MCalibrationCam::kUV:
    368385      fFluxInsidePlexiglass    = fLambda * gkBlindPixelQEUV * TMath::Power(10,gkBlindPixelAttUV);   
    369386      // attenuation has negligible error
    370387      fFluxInsidePlexiglassVar = GetLambdaRelVar() + GetBlindPixelQEUVRelVar();
    371388      break;
    372     case kCT1:
     389    case MCalibrationCam::kCT1:
    373390    default:
    374391      fFluxInsidePlexiglass    = fLambda * gkBlindPixelQECT1 * TMath::Power(10,gkBlindPixelAttCT1);   
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeBlindPix.h

    r3672 r3678  
    11#ifndef MARS_MCalibrationChargeBlindPix
    22#define MARS_MCalibrationChargeBlindPix
     3
     4#ifndef MARS_MCalibrationChargeCam
     5#include "MCalibrationChargeCam.h"
     6#endif
    37
    48#ifndef MARS_MCalibrationChargePix
     
    4246         kFluxInsidePlexiglassAvailable };
    4347
    44   PulserColor_t fColor; 
     48  MCalibrationCam::PulserColor_t fColor; 
    4549
    4650  const Float_t GetBlindPixelQEGreenRelVar() const;
     
    5761
    5862  // Setters
    59   void SetColor            ( const PulserColor_t color )          { fColor          = color; }
     63  void SetColor            ( const MCalibrationCam::PulserColor_t color ) { fColor  = color; }
    6064  void SetLambda           ( const Float_t f )                    { fLambda         = f;   }
    6165  void SetLambdaVar        ( const Float_t f )                    { fLambdaVar      = f;   }
     
    7882 
    7983  // Getters
    80   Float_t GetLambda()                  const { return fLambda;               }
    81   Float_t GetLambdaErr()               const;
    82   Float_t GetLambdaRelVar()            const; 
    83   Float_t GetLambdaCheck()             const { return fLambdaCheck;          }
    84   Float_t GetLambdaCheckErr()          const { return fLambdaCheckErr;       }
    85   Float_t GetFluxInsidePlexiglass()    const { return fFluxInsidePlexiglass; }
    86   Float_t GetFluxInsidePlexiglassErr() const;
    87   Float_t GetMu0()                     const { return fMu0;                  }
    88   Float_t GetMu0Err()                  const { return fMu0Err;               }
    89   Float_t GetMu1()                     const { return fMu1;                  }
    90   Float_t GetMu1Err()                  const { return fMu1Err;               }
    91   Float_t GetSigma0()                  const { return fSigma0;               }
    92   Float_t GetSigma0Err()               const { return fSigma0Err;            }
    93   Float_t GetSigma1()                  const { return fSigma1;               }
    94   Float_t GetSigma1Err()               const { return fSigma1Err;            }
     84  Float_t GetLambda()                     const { return fLambda;               }
     85  Float_t GetLambdaErr()                  const;
     86  Float_t GetLambdaRelVar()               const; 
     87  Float_t GetLambdaCheck()                const { return fLambdaCheck;          }
     88  Float_t GetLambdaCheckErr()             const { return fLambdaCheckErr;       }
     89  Float_t GetFluxInsidePlexiglass()       const { return fFluxInsidePlexiglass; }
     90  Float_t GetFluxInsidePlexiglassErr()    const;
     91  Float_t GetFluxInsidePlexiglassRelVar() const; 
     92  Float_t GetMu0()                        const { return fMu0;                  }
     93  Float_t GetMu0Err()                     const { return fMu0Err;               }
     94  Float_t GetMu1()                        const { return fMu1;                  }
     95  Float_t GetMu1Err()                     const { return fMu1Err;               }
     96  Float_t GetSigma0()                     const { return fSigma0;               }
     97  Float_t GetSigma0Err()                  const { return fSigma0Err;            }
     98  Float_t GetSigma1()                     const { return fSigma1;               }
     99  Float_t GetSigma1Err()                  const { return fSigma1Err;            }
    95100
    96101  Bool_t  IsOscillating()                    const;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r3664 r3678  
    185185#include "MParList.h"
    186186
    187 #include "MGeomCam.h"
    188187#include "MRawRunHeader.h"
    189188#include "MRawEvtPixelIter.h"
     189
     190#include "MGeomCam.h"
     191#include "MGeomPix.h"
    190192
    191193#include "MPedestalCam.h"
     
    208210#include "MCalibrationQEPix.h"
    209211
     212#include "MCalibrationCam.h"
    210213
    211214ClassImp(MCalibrationChargeCalc);
     
    213216using namespace std;
    214217
    215 const Float_t MCalibrationChargeCalc::fgChargeLimit        = 3.;
    216 const Float_t MCalibrationChargeCalc::fgChargeErrLimit     = 0.;
    217 const Float_t MCalibrationChargeCalc::fgChargeRelErrLimit  = 1.;
    218 const Float_t MCalibrationChargeCalc::fgLambdaCheckLimit   = 0.2;
    219 const Float_t MCalibrationChargeCalc::fgLambdaErrLimit     = 0.2;
    220 const Float_t MCalibrationChargeCalc::fgTimeLowerLimit     = 1.;
    221 const Float_t MCalibrationChargeCalc::fgTimeUpperLimit     = 2.;
     218const Float_t MCalibrationChargeCalc::fgChargeLimit            = 3.;
     219const Float_t MCalibrationChargeCalc::fgChargeErrLimit         = 0.;
     220const Float_t MCalibrationChargeCalc::fgChargeRelErrLimit      = 1.;
     221const Float_t MCalibrationChargeCalc::fgLambdaErrLimit         = 0.2;
     222const Float_t MCalibrationChargeCalc::fgLambdaCheckLimit       = 0.2;
     223const Float_t MCalibrationChargeCalc::fgPheErrLimit            = 5.;
     224const Float_t MCalibrationChargeCalc::fgTimeLowerLimit         = 1.;
     225const Float_t MCalibrationChargeCalc::fgTimeUpperLimit         = 2.;
    222226// --------------------------------------------------------------------------
    223227//
     
    240244// - fTimeLowerLimit    to fgTimeLowerLimit
    241245// - fTimeUpperLimit    to fgTimeUpperLimit
     246// - fPheErrLimit       to fgPheErrLimit 
     247// - fPulserColor       to MCalibrationCam::kCT1
    242248//
    243249// Calls:
     
    265271  SetLambdaCheckLimit();
    266272  SetLambdaErrLimit();
     273  SetPheErrLimit();
     274  SetPulserColor(MCalibrationCam::kCT1);
    267275  SetTimeLowerLimit();
    268276  SetTimeUpperLimit();
     
    300308// they were not found:
    301309//
    302 //  - MCalibrationCam
     310//  - MCalibrationChargeCam
    303311//  - MCalibrationQECam
    304312//
     
    306314//
    307315//  - MTime
     316//
     317// Sets the pulser colour in MCalibrationChargeCam
    308318//
    309319Int_t MCalibrationChargeCalc::PreProcess(MParList *pList)
     
    342352          return kFALSE;
    343353        }
     354      fBlindPixel->SetColor( fPulserColor );
    344355    }
    345356 
     
    355366          return kFALSE;
    356367        }
     368      fPINDiode->SetColor( fPulserColor );
    357369    }
    358370 
     
    363375      return kFALSE;
    364376    }
    365  
     377
     378  fCam->SetPulserColor( fPulserColor );
     379
    366380  fQECam = (MCalibrationQECam*)pList->FindCreateObj("MCalibrationQECam");
    367381  if (!fQECam)
     
    451465
    452466
     467// ----------------------------------------------------------------------------------
     468// 
     469// Nothing to be done in Process, but have a look at MHCalibrationChargeCam, instead
     470//
    453471Int_t MCalibrationChargeCalc::Process()
    454472{
     
    456474}
    457475
    458 // --------------------------------------------------------------------------
     476// ----------------------------------------------------------------------------------
    459477// 
    460478// Finalize pedestals:
     
    535553Bool_t MCalibrationChargeCalc::FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad)
    536554{
    537  
     555
    538556  //
    539557  // The check return kTRUE if:
     
    546564  if (cal.GetMean() < fChargeLimit*cal.GetPedRms())
    547565    {
    548       *fLog << warn << "WARNING: Fitted Charge: " << cal.GetMean() << " is smaller than "
     566      *fLog << warn << GetDescriptor() << ": Fitted Charge: " << cal.GetMean() << " is smaller than "
    549567            << fChargeLimit << " Pedestal RMS: " <<  cal.GetPedRms() << " in Pixel  " << cal.GetPixId() << endl;
    550568      bad.SetUncalibrated( MBadPixelsPix::kChargeIsPedestal);
    551       bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun   );
    552569    }
    553570 
    554571  if (cal.GetMeanErr() < fChargeErrLimit)
    555572    {
    556       *fLog << warn << "WARNING: Sigma of Fitted Charge: " << cal.GetMeanErr() << " is smaller than "
     573      *fLog << warn << GetDesriptor() << ": Sigma of Fitted Charge: " << cal.GetMeanErr() << " is smaller than "
    557574            << fChargeErrLimit << " in Pixel  " << cal.GetPixId() << endl;
    558575      bad.SetUncalibrated( MBadPixelsPix::kChargeErrNotValid );
    559       bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun     );
    560576    }
    561577     
    562578   if (cal.GetMean() < fChargeRelErrLimit*cal.GetMeanErr())
    563579    {
    564       *fLog << warn << "WARNING: Fitted Charge: " << cal.GetMean() << " is smaller than "
    565             << fChargeRelErrLimit << "* its error: " << cal.GetMeanErr() << " in Pixel  " << cal.GetPixId() << endl;
     580      *fLog << warn << GetDesriptor() << ": Fitted Charge: " << cal.GetMean() << " is smaller than "
     581            << fChargeRelErrLimit << "* its error: " << cal.GetMeanErr()
     582            << " in Pixel  " << cal.GetPixId() << endl;
    566583      bad.SetUncalibrated( MBadPixelsPix::kChargeRelErrNotValid );
    567       bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun        );
    568584    }
    569585
    570586  if (cal.GetSigma() < cal.GetPedRms())
    571587    {
    572       *fLog << warn << "WARNING: Sigma of Fitted Charge: " << cal.GetSigma()
     588      *fLog << warn << GetDesriptor() << ": Sigma of Fitted Charge: " << cal.GetSigma()
    573589            << " smaller than Pedestal RMS: " << cal.GetPedRms() << " in Pixel  " << cal.GetPixId() << endl;
    574590      bad.SetUncalibrated( MBadPixelsPix::kChargeSigmaNotValid );
    575       bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun       );
    576591    }
    577592
     
    592607  if ( cal.GetAbsTimeMean() < lowerlimit)
    593608    {
    594       *fLog << warn << "WARNING: Mean ArrivalTime in first " << fTimeLowerLimit
     609      *fLog << warn << GetDesriptor() << ": Mean ArrivalTime in first " << fTimeLowerLimit
    595610            << " extraction bin of the Pixel " << cal.GetPixId() << endl;
    596611      *fLog << cal.GetAbsTimeMean() << "   " << lowerlimit << endl;
    597612      bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
    598       bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun      );
    599613    }
    600614 
    601615  if ( cal.GetAbsTimeMean() > upperlimit )
    602616    {
    603       *fLog << warn << "WARNING: Mean ArrivalTime in last " << fTimeUpperLimit
     617      *fLog << warn << GetDesriptor() << ": Mean ArrivalTime in last " << fTimeUpperLimit
    604618            << " two extraction bins of the Pixel " << cal.GetPixId() << endl;
    605619      *fLog << cal.GetAbsTimeMean() << "   " << upperlimit << endl;
    606620      bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
    607       bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun       );
    608621    }
    609622     
     
    615628      *fLog << warn << GetDescriptor()
    616629            << ": Could not calculate reduced sigmas of pixel: " << cal.GetPixId() << endl;
    617       bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
     630      bad.SetUncalibrated(MBadPixelsPix::kChargeIsPedestal);
    618631      return kFALSE;
    619632    }
     
    623636      *fLog << warn << GetDescriptor()
    624637            << ": Could not calculate F-Factor of pixel: " << cal.GetPixId() << endl;
    625       bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
     638      bad.SetUncalibrated(MBadPixelsPix::kDeviatingNumPhes);
    626639      return kFALSE;
    627640    }
     
    657670  if (fPINDiode->GetMean() < fChargeLimit*fPINDiode->GetPedRms())
    658671    {
    659       *fLog << warn << "WARNING: Fitted Charge is smaller than "
     672      *fLog << warn << GetDesriptor() << ": Fitted Charge is smaller than "
    660673            << fChargeLimit << " Pedestal RMS in PINDiode " << endl;
    661674      return kFALSE;
     
    664677  if (fPINDiode->GetMeanErr() < fChargeErrLimit)
    665678    {
    666       *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
     679      *fLog << warn << GetDesriptor() << ": Error of Fitted Charge is smaller than "
    667680            << fChargeErrLimit << " in PINDiode " << endl;
    668681      return kFALSE;
     
    671684  if (fPINDiode->GetMean() < fChargeRelErrLimit*fPINDiode->GetMeanErr())
    672685    {
    673       *fLog << warn << "WARNING: Fitted Charge is smaller than "
     686      *fLog << warn << GetDesriptor() << ": Fitted Charge is smaller than "
    674687            << fChargeRelErrLimit << "* its error in PINDiode " << endl;
    675688      return kFALSE;
     
    678691  if (fPINDiode->GetSigma() < fPINDiode->GetPedRms())
    679692    {
    680       *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl;
     693      *fLog << warn << GetDesriptor() << ": Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl;
    681694      return kFALSE;
    682695    }
     
    689702  if (fPINDiode->GetAbsTimeMean() < lowerlimit)
    690703    {
    691       *fLog << warn << "WARNING: Mean ArrivalTime in first " << fTimeLowerLimit
     704      *fLog << warn << GetDesriptor() << ": Mean ArrivalTime in first " << fTimeLowerLimit
    692705            << " extraction bin in PIN Diode " << endl;
    693706      *fLog << fPINDiode->GetAbsTimeMean() << "   " << lowerlimit << endl;
     
    697710  if ( fPINDiode->GetAbsTimeMean() > upperlimit )
    698711    {
    699       *fLog << warn << "WARNING: Mean ArrivalTime in last " << fTimeUpperLimit
     712      *fLog << warn << GetDesriptor() << ": Mean ArrivalTime in last " << fTimeUpperLimit
    700713            << " two extraction bins in PIN Diode " << endl;
    701714      *fLog << fPINDiode->GetAbsTimeMean() << "   " << upperlimit << endl;
     
    741754  if (2.*(lambdacheck-lambda)/(lambdacheck+lambda) < fLambdaCheckLimit)
    742755    {
    743       *fLog << warn << "WARNING: Lambda and Lambda-Check differ by more than "
     756      *fLog << warn << GetDesriptor() << ": Lambda and Lambda-Check differ by more than "
    744757            << fLambdaCheckLimit << " in the Blind Pixel " << endl;
    745758      return kFALSE;
     
    748761  if (lambdaerr < fLambdaErrLimit)
    749762    {
    750       *fLog << warn << "WARNING: Error of Fitted Lambda is greater than "
     763      *fLog << warn << GetDesriptor() << ": Error of Fitted Lambda is greater than "
    751764            << fLambdaErrLimit << " in Blind Pixel " << endl;
    752765      return kFALSE;
     
    763776}
    764777
     778// ------------------------------------------------------------------------
     779//
     780//
     781Bool_t MCalibrationChargeCalc::FinalizeFFactorMethod()
     782{
     783
     784  const UInt_t npixels  = fGeom->GetNumPixels();
     785  const UInt_t nareas   = fGeom->GetNumAreas();
     786  const UInt_t nsectors = fGeom->GetNumSectors();
     787
     788  Float_t lowlim      [nareas];
     789  Float_t upplim      [nareas];
     790  Float_t areavars    [nareas];
     791  Float_t areaweights [nareas], sectorweights [nsectors];
     792  Float_t areaphes    [nareas], sectorphes    [nsectors];
     793  Int_t   numareavalid[nareas], numsectorvalid[nsectors];
     794
     795  memset(lowlim        ,0, nareas   * sizeof(Float_t));
     796  memset(upplim        ,0, nareas   * sizeof(Float_t));
     797  memset(areaphes      ,0, nareas   * sizeof(Float_t));
     798  memset(areavars      ,0, nareas   * sizeof(Float_t));
     799  memset(areaweights   ,0, nareas   * sizeof(Float_t));
     800  memset(numareavalid  ,0, nareas   * sizeof(Int_t  ));
     801  memset(sectorweights ,0, nsectors * sizeof(Float_t));
     802  memset(sectorphes    ,0, nsectors * sizeof(Float_t));
     803  memset(numsectorvalid,0, nsectors * sizeof(Int_t  ));
     804 
     805  //
     806  // First loop: Get mean number of photo-electrons and the RMS
     807  //             The loop is only to recognize later pixels with very deviating numbers
     808  //
     809  for (UInt_t i=0; i<npixels; i++)
     810    {
     811     
     812      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)  [i];
     813      MBadPixelsPix         &bad = (*fBadPixels)[i];
     814     
     815      if (!pix.IsFFactorMethodValid())
     816        continue;
     817
     818      if (!bad.IsCalibrationResultOK())
     819        {
     820          pix.SetFFactorMethodValid(kFALSE);
     821          continue;
     822        }
     823     
     824      const Float_t nphe  = pix.GetPheFFactorMethod();
     825      const Float_t nvar  = pix.GetPheFFactorMethodVar();
     826      const Int_t   aidx  = (*fGeom)[i].GetAidx();
     827
     828      if (nvar > 0.)
     829        {
     830          areaphes    [aidx] += nphe;
     831          areavars    [aidx] += nvar;
     832          numareavalid[aidx] ++;
     833        }
     834    }
     835
     836  for (UInt_t i=0; i<nareas; i++)
     837    {
     838      if (numareavalid[i] == 0)
     839        {
     840          *fLog << warn << GetDescriptor() << ": No pixels with valid number of photo-electrons found "
     841                << "in area index: " << i << endl;
     842          continue;
     843        }
     844
     845      areaphes[i] = areaphes[i] / numareavalid[i];
     846      areavars[i] = areavars[i] / numareavalid[i];
     847      lowlim  [i] = areaphes[i] - fPheErrLimit*TMath::Sqrt(areavars[i]);
     848      upplim  [i] = areaphes[i] + fPheErrLimit*TMath::Sqrt(areavars[i]);
     849    }
     850
     851  memset(numareavalid,0,nareas*sizeof(Int_t));
     852  memset(areaphes    ,0,nareas*sizeof(Int_t));
     853  memset(areavars    ,0,nareas*sizeof(Int_t));
     854
     855  //
     856  // Second loop: Get weighted mean number of photo-electrons and its RMS excluding
     857  //              pixels deviating by more than fPheErrLimit sigma.
     858  //              Set the conversion factor FADC counts to photo-electrons
     859  //
     860  for (UInt_t i=0; i<npixels; i++)
     861    {
     862     
     863      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
     864
     865      if (!pix.IsFFactorMethodValid())
     866        continue;
     867
     868      const Float_t nvar  = pix.GetPheFFactorMethodVar();
     869
     870      if (nvar <= 0.)
     871        {
     872          pix.SetFFactorMethodValid(kFALSE);
     873          continue;
     874        }
     875     
     876      MBadPixelsPix         &bad = (*fBadPixels)[i];
     877
     878      const Int_t   aidx   = (*fGeom)[i].GetAidx();
     879      const Int_t   sector = (*fGeom)[i].GetSector();
     880      const Float_t nphe   = pix.GetPheFFactorMethod();
     881
     882      if ( nphe < lowlim[aidx] || nphe > upplim[aidx] )
     883        {
     884          *fLog << warn << GetDescriptor() << ": Deviating number of photo-electrons: "
     885                << Form("%4.2f",nphe) << " out of accepted limits: ["
     886                << Form("%4.2f%s%4.2f",lowlim[aidx],",",upplim[aidx]) << "] in pixel " << i << endl;
     887          bad.SetUncalibrated( MBadPixelsPix::kDeviatingNumPhes );
     888          bad.SetUnsuitable  ( MBadPixelsPix::kUnreliableRun    );
     889          continue;
     890        }
     891     
     892      const Float_t weight = 1./nvar;
     893     
     894      areaweights   [aidx]   += weight;
     895      areaphes      [aidx]   += weight*nphe;
     896      numareavalid  [aidx]   ++;
     897      sectorweights [sector] += weight;
     898      sectorphes    [sector] += weight*nphe;
     899      numsectorvalid[sector] ++;
     900    }
     901
     902  for (UInt_t aidx=0; aidx<nareas; aidx++)
     903    {
     904
     905      MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
     906
     907      if (areaweights[aidx] <= 0. || areaphes[aidx] <= 0.)
     908        {
     909          *fLog << warn << " Mean number of phe's from area index " << aidx << " cannot be calculated: "
     910                << " Sum of weights: "       << areaweights[aidx]
     911                << " Sum of weighted phes: " << areaphes[aidx]    << endl;
     912          apix.SetFFactorMethodValid(kFALSE);
     913          continue;
     914        }
     915
     916      *fLog << inf << "Replacing number photo-electrons of average area idx " << aidx << ": "
     917            << Form("%5.3f%s%5.3f",apix.GetPheFFactorMethod()," +- ",apix.GetPheFFactorMethodErr()) << endl;
     918      *fLog << inf << "  by average number of photo-electrons from area idx " << aidx <<  ": "
     919            << Form("%5.3f%s%5.3f",areaphes[aidx] / areaweights[aidx]," +- ",
     920                    TMath::Sqrt(1./areaweights[aidx])) << endl;
     921
     922      apix.SetPheFFactorMethod   ( areaphes[aidx]/ areaweights[aidx] );
     923      apix.SetPheFFactorMethodVar(    1.         / areaweights[aidx] );     
     924      apix.SetFFactorMethodValid ( kTRUE );
     925
     926    }
     927
     928  for (UInt_t sector=0; sector<nsectors; sector++)
     929    {
     930
     931      MCalibrationChargePix &spix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
     932
     933      if (sectorweights[sector] <= 0. || sectorphes[sector] <= 0.)
     934        {
     935          *fLog << warn << " Mean number of phe's from sector " << sector << " cannot be calculated: "
     936                << " Sum of weights: "       << sectorweights[sector]
     937                << " Sum of weighted phes: " << sectorphes[sector]    << endl;
     938          spix.SetFFactorMethodValid(kFALSE);
     939          continue;
     940        }
     941
     942      *fLog << inf << "Replacing number photo-electrons of average sector " << sector << ": "
     943            << Form("%5.3f%s%5.3f",spix.GetPheFFactorMethod()," +- ",spix.GetPheFFactorMethodErr()) << endl;
     944      *fLog << inf << "   by average number photo-electrons from sector " << sector <<  ": "
     945            << Form("%5.3f%s%5.3f",sectorphes[sector]/ sectorweights[sector]," +- ",
     946                    TMath::Sqrt(1./sectorweights[sector])) << endl;
     947
     948      spix.SetPheFFactorMethod   ( sectorphes[sector]/ sectorweights[sector] );
     949      spix.SetPheFFactorMethodVar(    1.        / sectorweights[sector] );     
     950      spix.SetFFactorMethodValid ( kTRUE );
     951
     952    }
     953
     954  MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCam->GetAverageArea(0);
     955  MCalibrationQEPix     &qepix = (MCalibrationQEPix&)  fQECam->GetAverageArea(0); 
     956
     957  const Float_t avphotonflux = avpix.GetPheFFactorMethod()       
     958                             / qepix.GetQEFFactor(fPulserColor)
     959                             / fQECam->GetPlexiglassQE();
     960
     961  const Float_t avfluxrelvar = avpix.GetPheFFactorMethodRelVar()
     962                             + qepix.GetQEFFactorRelVar(fPulserColor)
     963                             + fQECam->GetPlexiglassQERelVar();
     964  //
     965  // Third loop: With the knowledge of the overall photon flux, calculate the total
     966  //             F-Factor of the whole readout per pixel and set the quantum efficiencies
     967  //             after the F-Factor method.
     968  //
     969  for (UInt_t i=0; i<npixels; i++)
     970    {
     971     
     972      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
     973      MCalibrationQEPix   &qepix = (MCalibrationQEPix&)  (*fQECam)[i];
     974
     975      if (!pix.IsFFactorMethodValid())
     976        {
     977          qepix.SetFFactorMethodValid(kFALSE,fPulserColor);
     978          continue;
     979        }
     980     
     981      const Float_t photons    = avphotonflux / fGeom->GetPixRatio(i);
     982      const Float_t conv       = photons      / pix.GetPheFFactorMethod();
     983
     984      if (!pix.CalcMeanFFactor( photons , avfluxrelvar ))
     985        {
     986          pix.SetFFactorMethodValid(kFALSE);
     987          qepix.SetFFactorMethodValid(kFALSE, fPulserColor);
     988          (*fBadPixels)[i].SetUncalibrated( MBadPixelsPix::kDeviatingNumPhes );
     989        }
     990
     991      const Float_t convrelvar = avfluxrelvar +  pix.GetPheFFactorMethodRelVar();
     992
     993      qepix.SetQEFFactor    ( conv                    , fPulserColor );
     994      qepix.SetQEFFactorVar ( convrelvar * conv * conv, fPulserColor );     
     995    }
     996 
     997
     998  return kTRUE;
     999}
     1000
     1001// ----------------------------------------------------------------------
     1002//
     1003// Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
     1004// - MBadPixelsPix::kChargeIsPedestal
     1005// - MBadPixelsPix::kChargeErrNotValid
     1006// - MBadPixelsPix::kChargeRelErrNotValid
     1007// - MBadPixelsPix::kChargeSigmaNotValid
     1008// - MBadPixelsPix::kMeanTimeInFirstBin
     1009// - MBadPixelsPix::kMeanTimeInLast2Bins
     1010//
     1011// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
     1012// - MBadPixelsPix::kDeviatingNumPhes
     1013//
     1014void MCalibrationChargeCalc::FinalizeBadPixels()
     1015{
     1016 
     1017  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
     1018    {
     1019     
     1020      MBadPixelsPix    &bad    = (*fBadPixels)[i];
     1021
     1022      if (bad.IsUncalibrated( MBadPixelsPix::kChargeIsPedestal))
     1023        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun   );
     1024 
     1025      if (bad.IsUncalibrated( MBadPixelsPix::kChargeErrNotValid ))
     1026        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
     1027
     1028      if (bad.IsUncalibrated( MBadPixelsPix::kChargeRelErrNotValid ))
     1029        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
     1030 
     1031      if (bad.IsUncalibrated( MBadPixelsPix::kChargeSigmaNotValid ))
     1032        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
     1033
     1034      if (bad.IsUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin ))
     1035        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
     1036
     1037      if (bad.IsUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins ))
     1038        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
     1039
     1040      if (bad.IsUncalibrated( MBadPixelsPix::kDeviatingNumPhes ))
     1041        bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
     1042    }
     1043}
     1044
     1045// ------------------------------------------------------------------------
     1046//
     1047//
     1048void MCalibrationChargeCalc::FinalizeBlindPixelQECam()
     1049{
     1050
     1051  const UInt_t npixels  = fGeom->GetNumPixels();
     1052 
     1053  //
     1054  //  With the knowledge of the overall photon flux, calculate the
     1055  //  quantum efficiencies after the Blind Pixel and PIN Diode method
     1056  //
     1057  for (UInt_t i=0; i<npixels; i++)
     1058    {
     1059     
     1060      MCalibrationQEPix   &qepix = (MCalibrationQEPix&)  (*fQECam)[i];
     1061
     1062      if (!fBlindPixel)
     1063        {
     1064          qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
     1065          continue;
     1066        }
     1067     
     1068      if (!fBlindPixel->IsFluxInsidePlexiglassAvailable())
     1069        {
     1070          qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
     1071          continue;
     1072        }
     1073     
     1074      MBadPixelsPix       &bad   =                   (*fBadPixels)[i];
     1075
     1076      if (!bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
     1077        {
     1078          qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
     1079          continue;
     1080        }
     1081     
     1082      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
     1083      MGeomPix              &geo =                        (*fGeom)[i];
     1084     
     1085      const Float_t conv       = fBlindPixel->GetFluxInsidePlexiglass()
     1086                              * geo.GetA()
     1087                              / fQECam->GetPlexiglassQE()
     1088                              / pix.GetPheFFactorMethod();
     1089
     1090      const Float_t convrelvar = fBlindPixel->GetFluxInsidePlexiglassRelVar()
     1091                               + fQECam->GetPlexiglassQERelVar()
     1092                               + pix.GetPheFFactorMethodRelVar();
     1093
     1094      qepix.SetQEBlindPixel    ( conv                    , fPulserColor );
     1095      qepix.SetQEBlindPixelVar ( convrelvar * conv * conv, fPulserColor );     
     1096    }
     1097}
     1098
     1099// ------------------------------------------------------------------------
     1100//
     1101//
     1102void MCalibrationChargeCalc::FinalizePINDiodeQECam()
     1103{
     1104 
     1105  const UInt_t npixels  = fGeom->GetNumPixels();
     1106
     1107  //
     1108  //  With the knowledge of the overall photon flux, calculate the
     1109  //  quantum efficiencies after the PIN Diode method
     1110  //
     1111  for (UInt_t i=0; i<npixels; i++)
     1112    {
     1113     
     1114      MCalibrationQEPix   &qepix = (MCalibrationQEPix&)  (*fQECam)[i];
     1115
     1116      if (!fPINDiode)
     1117        {
     1118          qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
     1119          continue;
     1120        }
     1121     
     1122      if (!fPINDiode->IsFluxOutsidePlexiglassAvailable())
     1123        {
     1124          qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
     1125          continue;
     1126        }
     1127
     1128      MBadPixelsPix &bad  =  (*fBadPixels)[i];
     1129
     1130      if (!bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
     1131        {
     1132          qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
     1133          continue;
     1134        }
     1135     
     1136      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
     1137      MGeomPix              &geo =                        (*fGeom)[i];
     1138     
     1139      const Float_t conv       = fPINDiode->GetFluxOutsidePlexiglass() * geo.GetA() / pix.GetPheFFactorMethod();
     1140      const Float_t convrelvar = fPINDiode->GetFluxOutsidePlexiglassRelVar() + pix.GetPheFFactorMethodRelVar();
     1141
     1142      qepix.SetQEPINDiode    ( conv                    , fPulserColor );
     1143      qepix.SetQEPINDiodeVar ( convrelvar * conv * conv, fPulserColor );     
     1144    }
     1145}
    7651146
    7661147
     
    8481229    }
    8491230 
     1231  //
     1232  // Finalize Bad Pixels
    8501233  //
    851   // F-Factor calibration
    852   //
    853   if (fCam->CalcFluxPhotonsFFactorMethod(*fGeom, *fBadPixels))
    854   {
    855     fCam->ApplyFFactorCalibration(*fGeom,*fBadPixels);
     1234  FinalizeBadPixels();
     1235
     1236  //
     1237  // Finalize F-Factor method
     1238  //
     1239  if (!FinalizeFFactorMethod())
     1240    {
     1241      *fLog << warn << "Could not calculate the photons flux from the F-Factor method " << endl;
     1242      fCam->SetFFactorMethodValid(kFALSE);
     1243      return kFALSE;
     1244    }
     1245  else
    8561246    fCam->SetFFactorMethodValid(kTRUE);
    857   }
     1247 
     1248  //
     1249  // Finalize Blind Pixel
     1250  //
     1251  if (FinalizeBlindPixel())
     1252    fQECam->SetBlindPixelMethodValid(kTRUE);
    8581253  else
    859     {
    860       *fLog << warn << "Could not calculate the flux of photo-electrons from the F-Factor method, " << endl;
    861       fCam->SetFFactorMethodValid(kFALSE);
    862     }
    863  
     1254    fQECam->SetBlindPixelMethodValid(kFALSE);
     1255
    8641256  //
    865   // Blind Pixel calibration
    866   //
    867   if (!FinalizeBlindPixel())
    868     fCam->SetBlindPixelMethodValid(kFALSE);
     1257  // Finalize PIN Diode
     1258  //
     1259  if (FinalizePINDiode())
     1260    fQECam->SetPINDiodeMethodValid(kTRUE);
    8691261  else
    870     {
    871       fCam->SetBlindPixelMethodValid(kTRUE);
    872       fCam->ApplyBlindPixelCalibration(*fGeom,*fBadPixels, *fBlindPixel);
    873     }
    874 
    875   //
    876   // PIN Diode calibration
    877   //
    878   if (!FinalizePINDiode())
    879     fCam->SetPINDiodeMethodValid(kFALSE);
    880   else
    881     {
    882       fCam->SetPINDiodeMethodValid(kTRUE);
    883       fCam->ApplyPINDiodeCalibration(*fGeom,*fBadPixels, *fPINDiode);
    884     }
    885 
    886   fCam->SetReadyToSave();
     1262    fQECam->SetPINDiodeMethodValid(kFALSE);
     1263
     1264  //
     1265  // Finalize QE Cam
     1266  //
     1267  FinalizeBlindPixelQECam();
     1268  FinalizePINDiodeQECam();
     1269
     1270  fCam      ->SetReadyToSave();
     1271  fQECam    ->SetReadyToSave();
     1272  fBadPixels->SetReadyToSave();
    8871273 
    8881274  *fLog << inf << endl;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h

    r3662 r3678  
    1717#ifndef MARS_MBadPixelsPix
    1818#include "MBadPixelsPix.h"
     19#endif
     20
     21#ifndef MARS_MCalibrationCam
     22#include "MCalibrationCam.h"
    1923#endif
    2024
     
    3943private:
    4044
    41   static const Float_t fgChargeLimit;       //! Default for fChargeLimit       (now set to: 3.)
    42   static const Float_t fgChargeErrLimit;    //! Default for fChargeErrLimit    (now set to: 0.)
    43   static const Float_t fgChargeRelErrLimit; //! Default for fChargeRelErrLimit (now set to: 1.)
    44   static const Float_t fgLambdaCheckLimit;  //! Default for fLambdaCheckLimit  (now set to: 0.2)
    45   static const Float_t fgLambdaErrLimit;    //! Default for fLabmdaErrLimit    (now set to: 0.2)
    46   static const Float_t fgTimeLowerLimit;    //! Default for fTimeLowerLimit    (now set to: 1.)
    47   static const Float_t fgTimeUpperLimit;    //! Default for fTimeUpperLimit    (now set to: 2.)
     45  static const Float_t fgChargeLimit;            //! Default for fChargeLimit            (now set to: 3.)
     46  static const Float_t fgChargeErrLimit;         //! Default for fChargeErrLimit         (now set to: 0.)
     47  static const Float_t fgChargeRelErrLimit;      //! Default for fChargeRelErrLimit      (now set to: 1.)
     48  static const Float_t fgLambdaCheckLimit;       //! Default for fLambdaCheckLimit       (now set to: 0.2)
     49  static const Float_t fgLambdaErrLimit;         //! Default for fLabmdaErrLimit         (now set to: 0.2)
     50  static const Float_t fgPheErrLimit;            //! Default for fPheErrLimit            (now set to: 5.)
     51  static const Float_t fgTimeLowerLimit;         //! Default for fTimeLowerLimit         (now set to: 1.)
     52  static const Float_t fgTimeUpperLimit;         //! Default for fTimeUpperLimit         (now set to: 2.)
    4853 
    49   Float_t fChargeLimit;          // Limit (in units of PedRMS) for acceptance of mean charge
    50   Float_t fChargeErrLimit;       // Limit (in units of PedRMS) for acceptance of charge sigma square
    51   Float_t fChargeRelErrLimit;    // Limit (in units of Sigma of fitted charge) for acceptance of mean 
    52   Float_t fLambdaCheckLimit;     // Limit for rel. diff. lambda and lambdacheck blind pixel
    53   Float_t fLambdaErrLimit;       // Limit for acceptance of lambda error blind pixel
    54   Float_t fTimeLowerLimit;       // Limit (in units of FADC slices) for dist. to first signal slice
    55   Float_t fTimeUpperLimit;       // Limit (in units of FADC slices) for dist. to last signal slice
     54  Float_t fChargeLimit;            // Limit (in units of PedRMS) for acceptance of mean charge
     55  Float_t fChargeErrLimit;         // Limit (in units of PedRMS) for acceptance of charge sigma square
     56  Float_t fChargeRelErrLimit;      // Limit (in units of Sigma of fitted charge) for acceptance of mean 
     57  Float_t fLambdaCheckLimit;       // Limit for rel. diff. lambda and lambdacheck blind pixel
     58  Float_t fLambdaErrLimit;         // Limit for acceptance of lambda error blind pixel
     59  Float_t fPheErrLimit;            // Limit for acceptance number phe's w.r.t area index mean (in sigmas)
     60  Float_t fTimeLowerLimit;         // Limit (in units of FADC slices) for dist. to first signal slice
     61  Float_t fTimeUpperLimit;         // Limit (in units of FADC slices) for dist. to last signal slice
    5662
    5763  MPedestalCam               *fPedestals;     //! Pedestals of all pixels in the camera
     
    8086  Int_t   fFlags;                              // Flag for the fits used
    8187
    82   enum  { kUseQualityChecks,
    83           kHiLoGainCalibration };
     88  enum  { kUseQualityChecks, kHiLoGainCalibration };
     89
     90  MCalibrationCam::PulserColor_t fPulserColor;
    8491 
    8592  Int_t  PreProcess(MParList *pList);
     
    8895  Int_t  PostProcess();
    8996
    90   void FinalizePedestals(const MPedestalPix &ped, MCalibrationChargePix &cal,
    91                          Float_t &avped, Float_t &avrms);
    92   void FinalizeAvPedestals(MCalibrationChargePix &cal, Float_t avped, Float_t avrms, Int_t avnum);
    93   Bool_t FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad);
     97  void   FinalizePedestals   ( const MPedestalPix &ped, MCalibrationChargePix &cal,
     98                               Float_t &avped, Float_t &avrms);
     99  void   FinalizeAvPedestals ( MCalibrationChargePix &cal, Float_t avped, Float_t avrms, Int_t avnum);
     100  Bool_t FinalizeCharges     ( MCalibrationChargePix &cal, MBadPixelsPix &bad );
    94101  Bool_t FinalizePINDiode();
    95102  Bool_t FinalizeBlindPixel();
     103  Bool_t FinalizeFFactorMethod();
     104  void   FinalizeBadPixels(); 
     105  void   FinalizeBlindPixelQECam();
     106  void   FinalizePINDiodeQECam();
    96107 
    97108  void PrintUnsuitable(MBadPixelsPix::UnsuitableType_t typ, const char *text) const;   
     
    104115  void Clear(const Option_t *o="");
    105116 
    106   void SetChargeLimit    (   const Float_t f=fgChargeLimit       ) { fChargeLimit       = f; }
    107   void SetChargeErrLimit (   const Float_t f=fgChargeErrLimit    ) { fChargeErrLimit    = f; }
    108   void SetChargeRelErrLimit( const Float_t f=fgChargeRelErrLimit ) { fChargeRelErrLimit = f; }
    109   void SetLambdaErrLimit   ( const Float_t f=fgLambdaErrLimit   ) { fLambdaErrLimit   = f; }
    110   void SetLambdaCheckLimit ( const Float_t f=fgLambdaCheckLimit ) { fLambdaCheckLimit = f; }
    111 
    112   void SetTimeLowerLimit (   const Float_t f=fgTimeLowerLimit    ) { fTimeLowerLimit  = f;   }
    113   void SetTimeUpperLimit (   const Float_t f=fgTimeUpperLimit    ) { fTimeUpperLimit  = f;   }
     117  void SetChargeLimit      ( const Float_t f=fgChargeLimit       ) { fChargeLimit       = f;   }
     118  void SetChargeErrLimit   ( const Float_t f=fgChargeErrLimit    ) { fChargeErrLimit    = f;   }
     119  void SetChargeRelErrLimit( const Float_t f=fgChargeRelErrLimit ) { fChargeRelErrLimit = f;   }
     120  void SetPheErrLimit      ( const Float_t f=fgPheErrLimit       ) { fPheErrLimit       = f;   } 
     121  void SetLambdaErrLimit   ( const Float_t f=fgLambdaErrLimit    ) { fLambdaErrLimit    = f;   }
     122  void SetLambdaCheckLimit ( const Float_t f=fgLambdaCheckLimit  ) { fLambdaCheckLimit  = f;   }
     123  void SetPulserColor      ( MCalibrationCam::PulserColor_t col  ) { fPulserColor       = col; }
     124  void SetTimeLowerLimit   ( const Float_t f=fgTimeLowerLimit    ) { fTimeLowerLimit    = f;   }
     125  void SetTimeUpperLimit   ( const Float_t f=fgTimeUpperLimit    ) { fTimeUpperLimit    = f;   }
    114126
    115127  void SkipQualityChecks(Bool_t b=kTRUE)
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc

    r3664 r3678  
    2222!
    2323\* ======================================================================== */
    24 
    2524/////////////////////////////////////////////////////////////////////////////
    2625//                                                               
    2726// MCalibrationChargeCam                                               
    2827//                                                               
    29 // Hold the whole Calibration results of the camera:
    30 //                                                               
    31 // 1) MCalibrationChargeCam initializes a TClonesArray whose elements are
    32 //    pointers to MCalibrationChargePix Containers
    33 // 2) It initializes a pointer to an MCalibrationBlindPix container
    34 // 3) It initializes a pointer to an MCalibrationPINDiode container
    35 //
    36 //
    37 // The calculated values (types of GetPixelContent) are:
     28// Storage container for charge calibration results of the whole camera.
     29//
     30// Individual pixels have to be cast when retrieved e.g.:
     31// MCalibrationChargePix &avpix = (MCalibrationChargePix&)(*fChargeCam)[i]
    3832//
    39 // --------------------------------------------------------------------------
    40 //
    41 // The types are as follows:
     33// The following calibration constants can be retrieved from each pixel:
     34//
     35// - GetConversionFactorFFactor    ( Int_t idx, Float_t &mean, Float_t &err, Float_t &sigma );
     36// - GetConversionFactorBlindPixel ( Int_t idx, Float_t &mean, Float_t &err, Float_t &sigma );
     37// - GetConversionFactorPINDiode   ( Int_t idx, Float_t &mean, Float_t &err, Float_t &sigma );
     38// - GetConversionFactorCombined   ( Int_t idx, Float_t &mean, Float_t &err, Float_t &sigma );
     39//
     40// where:
     41// - idx is the pixel software ID
     42// - "mean" is the mean conversion constant, to be multiplied with the retrieved signal
     43//   in order to get a calibrated number of PHOTONS.
     44// - "err" is the pure statistical uncertainty about the MEAN
     45// - "sigma", if mulitplied with the square root of signal, gives the approximate sigma of the
     46//   retrieved mean number of incident Cherenkov photons.
     47//
     48// Note, Conversion is ALWAYS (included the F-Factor method!) from summed FADC slices to PHOTONS.
     49//
     50// Averaged values over one whole area index (e.g. inner or outer pixels for
     51// the MAGIC camera), can be retrieved via:
     52// MCalibrationChargePix &avpix = (MCalibrationChargePix&)fChargeCam->GetAverageArea(i)
     53//
     54// Averaged values over one whole camera sector can be retrieved via:
     55// MCalibrationChargePix &avpix = (MCalibrationChargePix&)fChargeCam->GetAverageSector(i)
     56//
     57// Note the averageing has been done on an event-by-event basis. Resulting
     58// Sigma's of the Gauss fit have been multiplied with the square root of the number
     59// of involved pixels in order to make a direct comparison possible with the mean of
     60// sigmas.
     61//
     62// See also: MCalibrationChargePix, MCalibrationChargeCalc
     63//           MHCalibrationChargePix, MHCalibrationChargeCam             
     64//
     65// The types of GetPixelContent() are as follows:
    4266//
    4367// Fitted values:
    4468// ==============
    4569//
    46 // 0: Fitted Charge
    47 // 1: Error of fitted Charge
    48 // 2: Sigma of fitted Charge
    49 // 3: Error of Sigma of fitted Charge
     70// 0: Fitted Charge                              (see MCalibrationPix::GetMean())
     71// 1: Error of fitted Charge                     (see MCalibrationPix::GetMeanErr())
     72// 2: Sigma of fitted Charge                     (see MCalibrationPix::GetSigma())
     73// 3: Error of Sigma of fitted Charge            (see MCalibrationPix::GetSigmaErr())
    5074//
    5175// Useful variables derived from the fit results:
    5276// =============================================
    5377//
    54 // 4: Returned probability of Gauss fit to Charge distribution
    55 // 5: Reduced Sigma of fitted Charge --> sqrt(sigma_Q^2 - PedRMS^2)
    56 // 6: Error Reduced Sigma of fitted Charge
    57 // 7: Reduced Sigma per Charge
     78// 4: Probability Gauss fit Charge distribution  (see MCalibrationPix::GetProb())
     79// 5: Reduced Sigma of fitted Charge             (see MCalibrationChargePix::GetRSigma())
     80// 6: Error Reduced Sigma of fitted Charge       (see MCalibrationChargePix::GetRSigmaErr())
     81// 7: Reduced Sigma per Charge                
    5882// 8: Error of Reduced Sigma per Charge
    5983//
     
    6185// =============================================
    6286//
    63 //  9: Number of Photo-electrons obtained with the F-Factor method
    64 // 10: Error on Number of Photo-electrons obtained with the F-Factor method
    65 // 11: Mean conversion factor obtained with the F-Factor method
    66 // 12: Error on the mean conversion factor obtained with the F-Factor method
    67 // 13: Overall F-Factor of the readout obtained with the F-Factor method
    68 // 14: Error on Overall F-Factor of the readout obtained with the F-Factor method
    69 // 15: Pixels with valid calibration by the F-Factor-Method
    70 // 16: Mean conversion factor obtained with the Blind Pixel method
    71 // 17: Error on the mean conversion factor obtained with the Blind Pixel method
    72 // 18: Overall F-Factor of the readout obtained with the Blind Pixel method
    73 // 19: Error on Overall F-Factor of the readout obtained with the Blind Pixel method
    74 // 20: Pixels with valid calibration by the Blind Pixel-Method
    75 // 21: Mean conversion factor obtained with the PIN Diode method
    76 // 22: Error on the mean conversion factor obtained with the PIN Diode method
    77 // 23: Overall F-Factor of the readout obtained with the PIN Diode method
    78 // 24: Error on Overall F-Factor of the readout obtained with the PIN Diode method
    79 // 25: Pixels with valid calibration by the PIN Diode-Method
    80 //
    81 // Localized defects:
     87//  9: Nr. Photo-electrons from F-Factor Method   (see MCalibrationChargePix::GetPheFFactorMethod())
     88// 10: Error Nr. Photo-el. from F-Factor Method   (see MCalibrationChargePix::GetPheFFactorMethodErr())
     89// 11: Conversion factor   from F-Factor Method   (see MCalibrationChargePix::GetMeanConversionFFactorMethod())
     90// 12: Error conv. factor  from F-Factor Method   (see MCalibrationChargePix::GetConversionFFactorMethodErr())
     91// 13: Overall F-Factor    from F-Factor Method   (see MCalibrationChargePix::GetTotalFFactorFFactorMethod())
     92// 14: Error F-Factor      from F-Factor Method   (see MCalibrationChargePix::GetTotalFFactorFFactorMethodErr())
     93// 15: Pixels valid calibration F-Factor-Method   (see MCalibrationChargePix::IsFFactorMethodValid())           
     94// 16: Conversion factor   from BlindPixel Method (see MCalibrationChargePix::GetMeanConversionBlindPixelMethod())
     95// 17: Error conv. factor  from BlindPixel Method (see MCalibrationChargePix::GetConversionBlindPixelMethodErr()) 
     96// 18: Overall F-Factor    from BlindPixel Method (see MCalibrationChargePix::GetTotalFFactorBlindPixelMethod())   
     97// 19: Error F-Factor      from BlindPixel Method (see MCalibrationChargePix::GetTotalFFactorBlindPixelMethodErr())
     98// 20: Pixels valid calibration BlindPixel-Method (see MCalibrationChargePix::IsBlindPixelMethodValid())           
     99// 21: Conversion factor   from PINDiode Method   (see MCalibrationChargePix::GetMeanConversionPINDiodeMethod())
     100// 22: Error conv. factor  from PINDiode Method   (see MCalibrationChargePix::GetConversionPINDiodeMethodErr()) 
     101// 23: Overall F-Factor    from PINDiode Method   (see MCalibrationChargePix::GetTotalFFactorPINDiodeMethod())   
     102// 24: Error F-Factor      from PINDiode Method   (see MCalibrationChargePix::GetTotalFFactorPINDiodeMethodErr())
     103// 25: Pixels valid calibration PINDiode-Method   (see MCalibrationChargePix::IsPINDiodeMethodValid())           
     104//                                               
     105// Localized defects:                             
    82106// ==================
    83107//
    84108// 26: Excluded Pixels
    85 // 27: Number of probable pickup events in the Hi Gain
    86 // 28: Number of probable pickup events in the Lo Gain
     109// 27: Number of pickup events in the Hi Gain     (see MCalibrationPix::GetHiGainNumPickup())
     110// 28: Number of pickup events in the Lo Gain     (see MCalibrationPix::GetLoGainNumPickup())
    87111//
    88112// Other classifications of pixels:
    89113// ================================
    90114//
    91 // 29: Pixels with saturated Hi-Gain
     115// 29: Pixels with saturated Hi-Gain              (see MCalibrationPix::IsHighGainSaturation())
    92116//
    93117// Used Pedestals:
    94118// ===============
    95119//
    96 // 30: Mean Pedestal over the entire range of signal extraction
    97 // 31: Error on the Mean Pedestal over the entire range of signal extraction
    98 // 32: Pedestal RMS over the entire range of signal extraction
    99 // 33: Error on the Pedestal RMS over the entire range of signal extraction
     120// 30: Pedestal for entire signal extr. range     (see MCalibrationChargePix::Ped())
     121// 31: Error Pedestal entire signal extr. range   (see MCalibrationChargePix::PedErr())
     122// 32: Ped. RMS entire signal extraction range    (see MCalibrationChargePix::PedRms())
     123// 33: Error Ped. RMS entire signal extr. range   (see MCalibrationChargePix::PedRmsErr())
    100124//
    101125// Calculated absolute arrival times (very low precision!):
    102126// ========================================================
    103127//
    104 // 34: Absolute Arrival time of the signal
    105 // 35: RMS of the Absolute Arrival time of the signal
     128// 34: Absolute Arrival time of the signal        (see MCalibrationChargePix::GetAbsTimeMean())
     129// 35: RMS Ab.  Arrival time of the signal        (see MCalibrationChargePix::GetAbsTimeRms())
    106130//
    107131/////////////////////////////////////////////////////////////////////////////
     
    129153
    130154using namespace std;
    131 
    132 const Float_t MCalibrationChargeCam::fgAverageQE                = 0.18;     
    133 const Float_t MCalibrationChargeCam::fgAverageQEErr             = 0.02; 
    134 const Float_t MCalibrationChargeCam::fgConvFFactorRelErrLimit   = 0.35;
    135 const Float_t MCalibrationChargeCam::fgPheFFactorRelErrLimit    = 5.;
    136155// --------------------------------------------------------------------------
    137156//
    138157// Default constructor.
    139158//
    140 // Creates a TClonesArray of MCalibrationPix containers, initialized to 1 entry
    141 // Later, a call to MCalibrationChargeCam::InitSize(Int_t size) has to be performed
    142 //
    143 // Creates an MCalibrationBlindPix container
     159// Sets all pointers to 0
     160//
     161// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated
     162// to hold one container per pixel. Later, a call to MCalibrationChargeCam::InitSize()
     163// has to be performed (in MGeomApply).
     164//
     165// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated
     166// to hold one container per pixel AREA. Later, a call to MCalibrationChargeCam::InitAreas()
     167// has to be performed (in MGeomApply).
     168//
     169// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated
     170// to hold one container per camera SECTOR. Later, a call to MCalibrationChargeCam::InitSectors()
     171// has to be performed (in MGeomApply).
     172//
     173// Calls:
     174// - Clear()
    144175//
    145176MCalibrationChargeCam::MCalibrationChargeCam(const char *name, const char *title)
     
    148179      fOffvsSlope(NULL)
    149180{
    150     fName  = name  ? name  : "MCalibrationChargeCam";
    151     fTitle = title ? title : "Storage container for the Calibration Information in the camera";
    152 
    153     fPixels           = new TClonesArray("MCalibrationChargePix",1);
    154     fAverageAreas     = new TClonesArray("MCalibrationChargePix",1);
    155     fAverageSectors   = new TClonesArray("MCalibrationChargePix",1);
    156 
    157     fFluxPhesInnerPixel       = 0.;
    158     fFluxPhesInnerPixelVar    = 0.;
    159     fFluxPhesOuterPixel       = 0.;
    160     fFluxPhesOuterPixelVar    = 0.;
    161    
    162     CLRBIT(fFlags,kBlindPixelMethodValid);
    163     CLRBIT(fFlags,kFFactorMethodValid);
    164     CLRBIT(fFlags,kPINDiodeMethodValid);
     181  fName  = name  ? name  : "MCalibrationChargeCam";
     182  fTitle = title ? title : "Storage container for the Calibration Information in the camera";
    165183 
    166     SetAverageQE();
    167     SetConvFFactorRelErrLimit();
    168     SetPheFFactorRelErrLimit();
     184  fPixels           = new TClonesArray("MCalibrationChargePix",1);
     185  fAverageAreas     = new TClonesArray("MCalibrationChargePix",1);
     186  fAverageSectors   = new TClonesArray("MCalibrationChargePix",1);
     187 
     188  Clear();
    169189}
    170190
    171191// --------------------------------------------------------------------------
    172192//
    173 // Delete the TClonesArray of MCalibrationPix containers
    174 // Delete the MCalibrationPINDiode and the MCalibrationBlindPix
    175 //
    176 // Delete the histograms if they exist
     193// Deletes the histograms if they exist
    177194//
    178195MCalibrationChargeCam::~MCalibrationChargeCam()
    179196{
    180197
    181  
    182198  if (fOffsets)
    183199    delete fOffsets;
     
    186202  if (fOffvsSlope)
    187203    delete fOffvsSlope;
    188 
    189204}
    190205
     
    192207// --------------------------------------
    193208//
     209// Sets all variable to 0.
     210// Sets all flags to kFALSE
     211// Calls MCalibrationCam::Clear()
     212//
    194213void MCalibrationChargeCam::Clear(Option_t *o)
    195214{
    196215
    197   fFluxPhesInnerPixel       = 0.;
    198   fFluxPhesInnerPixelVar    = 0.;
    199   fFluxPhesOuterPixel       = 0.;
    200   fFluxPhesOuterPixelVar    = 0.;
    201 
    202   CLRBIT(fFlags,kBlindPixelMethodValid);
    203   CLRBIT(fFlags,kFFactorMethodValid);
    204   CLRBIT(fFlags,kPINDiodeMethodValid);
     216  SetFFactorMethodValid    ( kFALSE );
    205217
    206218  MCalibrationCam::Clear();
     
    209221}
    210222
     223
     224// -----------------------------------------------
     225//
     226// Sets the kFFactorMethodValid bit from outside
     227//
    211228void MCalibrationChargeCam::SetFFactorMethodValid(const Bool_t b)
    212229{
     
    214231}
    215232
    216 void MCalibrationChargeCam::SetBlindPixelMethodValid(const Bool_t b)
    217 {
    218     b ? SETBIT(fFlags, kBlindPixelMethodValid) : CLRBIT(fFlags, kBlindPixelMethodValid);
    219 }
    220 
    221 void MCalibrationChargeCam::SetPINDiodeMethodValid(const Bool_t b)
    222 {
    223     b ? SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid);
    224 }
    225 
    226 Float_t MCalibrationChargeCam::GetFluxPhesInnerPixelErr()   const
    227 {
    228   if (fFluxPhesInnerPixelVar <= 0.)
    229     return -1.;
    230   return TMath::Sqrt(fFluxPhesInnerPixelVar);
    231 }
    232 
    233 Float_t MCalibrationChargeCam::GetFluxPhesOuterPixelErr()   const
    234 {
    235   if (fFluxPhesOuterPixelVar <= 0.)
    236     return -1.;
    237   return TMath::Sqrt(fFluxPhesOuterPixelVar);
    238 }
    239 
    240 Float_t MCalibrationChargeCam::GetFluxPhotonsInnerPixelErr()   const
    241 {
    242   if (fFluxPhotonsInnerPixelVar <= 0.)
    243     return -1.;
    244   return TMath::Sqrt(fFluxPhotonsInnerPixelVar);
    245 }
    246 
    247 Float_t MCalibrationChargeCam::GetFluxPhotonsOuterPixelErr()   const
    248 {
    249   if (fFluxPhotonsOuterPixelVar <= 0.)
    250     return -1.;
    251   return TMath::Sqrt(fFluxPhotonsOuterPixelVar);
    252 }
    253 
    254 Bool_t  MCalibrationChargeCam::IsBlindPixelMethodValid()   const
    255 {
    256   return TESTBIT(fFlags,kBlindPixelMethodValid);
    257 }
    258 
    259 Bool_t  MCalibrationChargeCam::IsPINDiodeMethodValid() const
    260 {
    261   return TESTBIT(fFlags,kPINDiodeMethodValid); 
    262 }
    263 
     233
     234// --------------------------------------------------------------------------
     235//
     236// Test bit kFFactorMethodValid
     237//
     238Bool_t  MCalibrationChargeCam::IsFFactorMethodValid()   const
     239{
     240  return TESTBIT(fFlags,kFFactorMethodValid);
     241}
    264242
    265243// --------------------------------------------------------------------------
     
    352330// ==============
    353331//
    354 // 0: Fitted Charge
    355 // 1: Error of fitted Charge
    356 // 2: Sigma of fitted Charge
    357 // 3: Error of Sigma of fitted Charge
     332// 0: Fitted Charge                              (see MCalibrationPix::GetMean())
     333// 1: Error of fitted Charge                     (see MCalibrationPix::GetMeanErr())
     334// 2: Sigma of fitted Charge                     (see MCalibrationPix::GetSigma())
     335// 3: Error of Sigma of fitted Charge            (see MCalibrationPix::GetSigmaErr())
    358336//
    359337// Useful variables derived from the fit results:
    360338// =============================================
    361339//
    362 // 4: Returned probability of Gauss fit to Charge distribution
    363 // 5: Reduced Sigma of fitted Charge --> sqrt(sigma_Q^2 - PedRMS^2)
    364 // 6: Error Reduced Sigma of fitted Charge
    365 // 7: Reduced Sigma per Charge
    366 // 8: Error of Reduced Sigma per Charge
    367 //
    368 // Useful variables derived from the fit results:
    369 // =============================================
    370 //
    371 // 4: Returned probability of Gauss fit to Charge distribution
    372 // 5: Reduced Sigma of fitted Charge --> sqrt(sigma_Q^2 - PedRMS^2)
    373 // 6: Error Reduced Sigma of fitted Charge
    374 // 7: Reduced Sigma per Charge
     340// 4: Probability Gauss fit Charge distribution  (see MCalibrationPix::GetProb())
     341// 5: Reduced Sigma of fitted Charge             (see MCalibrationChargePix::GetRSigma())
     342// 6: Error Reduced Sigma of fitted Charge       (see MCalibrationChargePix::GetRSigmaErr())
     343// 7: Reduced Sigma per Charge                 
    375344// 8: Error of Reduced Sigma per Charge
    376345//
     
    378347// =============================================
    379348//
    380 //  9: Number of Photo-electrons obtained with the F-Factor method
    381 // 10: Error on Number of Photo-electrons obtained with the F-Factor method
    382 // 11: Mean conversion factor obtained with the F-Factor method
    383 // 12: Error on the mean conversion factor obtained with the F-Factor method
    384 // 13: Overall F-Factor of the readout obtained with the F-Factor method
    385 // 14: Error on Overall F-Factor of the readout obtained with the F-Factor method
    386 // 15: Pixels with valid calibration by the F-Factor-Method
    387 // 16: Mean conversion factor obtained with the Blind Pixel method
    388 // 17: Error on the mean conversion factor obtained with the Blind Pixel method
    389 // 18: Overall F-Factor of the readout obtained with the Blind Pixel method
    390 // 19: Error on Overall F-Factor of the readout obtained with the Blind Pixel method
    391 // 20: Pixels with valid calibration by the Blind Pixel-Method
    392 // 21: Mean conversion factor obtained with the PIN Diode method
    393 // 22: Error on the mean conversion factor obtained with the PIN Diode method
    394 // 23: Overall F-Factor of the readout obtained with the PIN Diode method
    395 // 24: Error on Overall F-Factor of the readout obtained with the PIN Diode method
    396 // 25: Pixels with valid calibration by the PIN Diode-Method
    397 //
    398 // Localized defects:
     349//  9: Nr. Photo-electrons from F-Factor Method   (see MCalibrationChargePix::GetPheFFactorMethod())
     350// 10: Error Nr. Photo-el. from F-Factor Method   (see MCalibrationChargePix::GetPheFFactorMethodErr())
     351// 11: Conversion factor   from F-Factor Method   (see MCalibrationChargePix::GetMeanConversionFFactorMethod())
     352// 12: Error conv. factor  from F-Factor Method   (see MCalibrationChargePix::GetConversionFFactorMethodErr())
     353// 13: Overall F-Factor    from F-Factor Method   (see MCalibrationChargePix::GetTotalFFactorFFactorMethod())
     354// 14: Error F-Factor      from F-Factor Method   (see MCalibrationChargePix::GetTotalFFactorFFactorMethodErr())
     355// 15: Pixels valid calibration F-Factor-Method   (see MCalibrationChargePix::IsFFactorMethodValid())           
     356// 16: Conversion factor   from BlindPixel Method (see MCalibrationChargePix::GetMeanConversionBlindPixelMethod())
     357// 17: Error conv. factor  from BlindPixel Method (see MCalibrationChargePix::GetConversionBlindPixelMethodErr()) 
     358// 18: Overall F-Factor    from BlindPixel Method (see MCalibrationChargePix::GetTotalFFactorBlindPixelMethod())   
     359// 19: Error F-Factor      from BlindPixel Method (see MCalibrationChargePix::GetTotalFFactorBlindPixelMethodErr())
     360// 20: Pixels valid calibration BlindPixel-Method (see MCalibrationChargePix::IsBlindPixelMethodValid())           
     361// 21: Conversion factor   from PINDiode Method   (see MCalibrationChargePix::GetMeanConversionPINDiodeMethod())
     362// 22: Error conv. factor  from PINDiode Method   (see MCalibrationChargePix::GetConversionPINDiodeMethodErr()) 
     363// 23: Overall F-Factor    from PINDiode Method   (see MCalibrationChargePix::GetTotalFFactorPINDiodeMethod())   
     364// 24: Error F-Factor      from PINDiode Method   (see MCalibrationChargePix::GetTotalFFactorPINDiodeMethodErr())
     365// 25: Pixels valid calibration PINDiode-Method   (see MCalibrationChargePix::IsPINDiodeMethodValid())           
     366//                                               
     367// Localized defects:                             
    399368// ==================
    400369//
    401370// 26: Excluded Pixels
    402 // 27: Number of probable pickup events in the Hi Gain
    403 // 28: Number of probable pickup events in the Lo Gain
     371// 27: Number of pickup events in the Hi Gain     (see MCalibrationPix::GetHiGainNumPickup())
     372// 28: Number of pickup events in the Lo Gain     (see MCalibrationPix::GetLoGainNumPickup())
    404373//
    405374// Other classifications of pixels:
    406375// ================================
    407376//
    408 // 29: Pixels with saturated Hi-Gain
     377// 29: Pixels with saturated Hi-Gain              (see MCalibrationPix::IsHighGainSaturation())
    409378//
    410379// Used Pedestals:
    411380// ===============
    412381//
    413 // 30: Mean Pedestal over the entire range of signal extraction
    414 // 31: Error on the Mean Pedestal over the entire range of signal extraction
    415 // 32: Pedestal RMS over the entire range of signal extraction
    416 // 33: Error on the Pedestal RMS over the entire range of signal extraction
     382// 30: Pedestal for entire signal extr. range     (see MCalibrationChargePix::Ped())
     383// 31: Error Pedestal entire signal extr. range   (see MCalibrationChargePix::PedErr())
     384// 32: Ped. RMS entire signal extraction range    (see MCalibrationChargePix::PedRms())
     385// 33: Error Ped. RMS entire signal extr. range   (see MCalibrationChargePix::PedRmsErr())
    417386//
    418387// Calculated absolute arrival times (very low precision!):
    419388// ========================================================
    420389//
    421 // 34: Absolute Arrival time of the signal
    422 // 35: RMS of the Absolute Arrival time of the signal
     390// 34: Absolute Arrival time of the signal        (see MCalibrationChargePix::GetAbsTimeMean())
     391// 35: RMS Ab.  Arrival time of the signal        (see MCalibrationChargePix::GetAbsTimeRms())
    423392//
    424393Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
     
    488457      if (pix.IsExcluded())
    489458        return kFALSE;
    490       if (pix.GetRSigma() <= 0.)
    491           return kFALSE;
    492       if (pix.GetMean() <= 0.)
    493         return kFALSE;
    494       if (pix.GetRSigmaErr() <= 0.)
    495           return kFALSE;
    496       if (pix.GetMeanErr() <= 0.)
     459      if (pix.GetRSigmaRelVar() <= 0.)
     460        return kFALSE;
     461      if (pix.GetMeanRelVar() <= 0.)
    497462        return kFALSE;
    498463      // relative error Rsigma square
    499       val =    pix.GetRSigmaErr()* pix.GetRSigmaErr()
    500             / (pix.GetRSigma()   * pix.GetRSigma()   );
    501       // relative error  square
    502       val +=   pix.GetMeanErr() * pix.GetMeanErr()
    503             / (pix.GetMean()    * pix.GetMean()   );
    504       // calculate relative error out of squares
    505       val  =   TMath::Sqrt(val) ;
    506       // multiply with value to get absolute error
    507       val  *=  pix.GetRSigma() / pix.GetMean();
     464      val =  pix.GetRSigmaRelVar() + pix.GetMeanRelVar();
     465      //a calculate relative error out of squares
     466      if (val < 0)
     467        val = -1.;
     468      else
     469        val  =   TMath::Sqrt(val) * pix.GetRSigma() / pix.GetMean();
    508470      break;
    509471    case 9:
     
    520482      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
    521483        return kFALSE;
    522       val = pix.GetMeanConversionFFactorMethod();
     484      val = pix.GetMeanConvFADC2Phe();
    523485      break;
    524486    case 12:
    525487      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
    526488        return kFALSE;
    527       val = pix.GetConversionFFactorMethodErr();
     489      val = pix.GetMeanConvFADC2PheErr();
    528490      break;
    529491    case 13:
    530492      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
    531493        return kFALSE;
    532       val = pix.GetTotalFFactorFFactorMethod();
     494      val = pix.GetMeanFFactorFADC2Phot();
    533495      break;
    534496    case 14:
    535497      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
    536498        return kFALSE;
    537       val = pix.GetTotalFFactorFFactorMethodErr();
     499      val = pix.GetMeanFFactorFADC2Phot();
    538500      break;
    539501    case 15:
     
    546508      break;
    547509    case 16:
    548       if (pix.IsExcluded() || !pix.IsBlindPixelMethodValid())
    549         return kFALSE;
    550       val = pix.GetMeanConversionBlindPixelMethod();
     510      return kFALSE;
    551511      break;
    552512    case 17:
    553       if (pix.IsExcluded() || !pix.IsBlindPixelMethodValid())
    554         return kFALSE;
    555       val = pix.GetConversionBlindPixelMethodErr();
     513      return kFALSE;
    556514      break;
    557515    case 18:
    558       if (pix.IsExcluded() || !pix.IsBlindPixelMethodValid())
    559         return kFALSE;
    560       val = pix.GetTotalFFactorBlindPixelMethod();
     516      return kFALSE;
    561517      break;
    562518    case 19:
    563       if (pix.IsExcluded() || !pix.IsBlindPixelMethodValid())
    564         return kFALSE;
    565       val = pix.GetTotalFFactorBlindPixelMethodErr();
     519      return kFALSE;
    566520      break;
    567521    case 20:
    568       if (pix.IsExcluded())
    569         return kFALSE;
    570       if (pix.IsBlindPixelMethodValid())
    571         val = 1;
    572       else
    573         return kFALSE;
     522      return kFALSE;
    574523      break;
    575524    case 21:
    576       if (pix.IsExcluded() || !pix.IsPINDiodeMethodValid())
    577         return kFALSE;
    578       val = pix.GetMeanConversionPINDiodeMethod();
     525      return kFALSE;
    579526      break;
    580527    case 22:
    581       if (pix.IsExcluded() || !pix.IsPINDiodeMethodValid())
    582         return kFALSE;
    583       val = pix.GetConversionPINDiodeMethodErr();
     528      return kFALSE;
    584529      break;
    585530    case 23:
    586       if (pix.IsExcluded() || !pix.IsPINDiodeMethodValid())
    587         return kFALSE;
    588       val = pix.GetTotalFFactorPINDiodeMethod();
     531      return kFALSE;
    589532      break;
    590533    case 24:
    591       if (pix.IsExcluded() || !pix.IsPINDiodeMethodValid())
    592         return kFALSE;
    593       val = pix.GetTotalFFactorPINDiodeMethodErr();
     534      return kFALSE;
    594535      break;
    595536    case 25:
    596       if (pix.IsExcluded())
    597         return kFALSE;
    598       if (pix.IsPINDiodeMethodValid())
    599         val = 1;
    600       else
    601         return kFALSE;
     537      return kFALSE;
    602538      break;
    603539    case 26:
     
    662598// --------------------------------------------------------------------------
    663599//
    664 // What MHCamera needs in order to draw an individual pixel in the camera
     600// Calls MCalibrationChargePix::DrawClone()
    665601//
    666602void MCalibrationChargeCam::DrawPixelContent(Int_t idx) const
     
    670606}
    671607
    672 //
    673 // Calculate the weighted mean of the phe's of all inner and outer pixels, respectively.
    674 // Bad pixels are excluded from the calculation. Two loops are performed to exclude pixels
    675 // which are fPheFFactorRelLimit sigmas from the mean.
    676 //
    677 Bool_t MCalibrationChargeCam::CalcFluxPhotonsFFactorMethod(const MGeomCam &geom, MBadPixelsCam &bad)
    678 {
    679 
    680   const Float_t avQERelVar = fAverageQEVar / (fAverageQE * fAverageQE );
    681 
    682   Float_t sumweightsinner = 0.;
    683   Float_t sumphesinner    = 0.;
    684   Float_t sumweightsouter = 0.;
    685   Float_t sumphesouter    = 0.;
    686   Int_t   validinner      = 0;
    687   Int_t   validouter      = 0;
    688 
    689   TIter Next(fPixels);
    690   MCalibrationChargePix *pix;
    691   while ((pix=(MCalibrationChargePix*)Next()))
    692     {
    693 
    694       if (!pix->IsFFactorMethodValid())
    695         continue;
    696 
    697       const Int_t idx = pix->GetPixId();
    698 
    699       if(!bad[idx].IsCalibrationResultOK())
    700         continue;
    701      
    702       const Float_t nphe    = pix->GetPheFFactorMethod();
    703       const Float_t npheerr = pix->GetPheFFactorMethodErr();
    704       const Float_t ratio   = geom.GetPixRatio(idx);
    705 
    706       if (npheerr > 0.)
    707         {
    708           const Float_t weight = nphe*nphe/npheerr/npheerr;
    709           //
    710           // first the inner pixels:
    711           //
    712           if (ratio == 1.)
    713             {
    714               sumweightsinner += weight;
    715               sumphesinner    += weight*nphe;
    716               validinner++;
    717             }
    718           else
    719             {
    720               //
    721               // now the outers
    722               //
    723               sumweightsouter += weight;
    724               sumphesouter    += weight*nphe;
    725               validouter++;
    726             }
    727         } /* if npheerr != 0 */
    728     } /* while ((pix=(MCalibrationChargePix*)Next())) */
    729 
    730   if (sumweightsinner <= 0. || sumphesinner <= 0.)
    731     {
    732       *fLog << warn << " Mean number of phe's from inner pixels cannot be calculated: "
    733             << " Sum of weights: " << sumweightsinner
    734             << " Sum of weighted phes: " << sumphesinner << endl;
    735       return kFALSE;
    736     }
    737   else
    738     {
    739       fFluxPhesInnerPixel    = sumphesinner/sumweightsinner;
    740       fFluxPhesInnerPixelVar = (1./sumweightsinner)*fFluxPhesInnerPixel*fFluxPhesInnerPixel;
    741     }
    742 
    743   if (sumweightsouter <= 0. || sumphesouter <= 0.)
    744     {
    745       *fLog << warn << " Mean number of phe's from outer pixels cannot be calculated: "
    746             << " Sum of weights or sum of weighted phes is 0. " << endl;
    747     }
    748   else
    749     {
    750       fFluxPhesOuterPixel    = sumphesouter/sumweightsouter;
    751       fFluxPhesOuterPixelVar = (1./sumweightsouter)*fFluxPhesOuterPixel*fFluxPhesOuterPixel;
    752     }
    753 
    754   Float_t meanFluxPhotonsRelVar  = fFluxPhesInnerPixelVar
    755                                 / (fFluxPhesInnerPixel * fFluxPhesInnerPixel);
    756 
    757   fFluxPhotonsInnerPixel    =  fFluxPhesInnerPixel/fAverageQE;
    758   fFluxPhotonsInnerPixelVar =  (meanFluxPhotonsRelVar + avQERelVar)
    759                                  * fFluxPhotonsInnerPixel * fFluxPhotonsInnerPixel;
    760 
    761   fFluxPhotonsOuterPixel    = 4. *fFluxPhotonsInnerPixel;
    762   fFluxPhotonsOuterPixelVar = 16.*fFluxPhotonsInnerPixelVar; 
    763  
    764   *fLog << inf << " Mean number of photo-electrons from inner pixels (F-Factor Method): "
    765         << fFluxPhesInnerPixel << " +- " << GetFluxPhesInnerPixelErr() << endl;
    766 
    767   *fLog << inf << " Mean number of photons from inner pixels (F-Factor Method): "
    768         << fFluxPhotonsInnerPixel << " +- " << GetFluxPhotonsInnerPixelErr() << endl;
    769 
    770   //
    771   // Here starts the second loop discarting pixels out of the range:
    772   //
    773   const Float_t innervar = (Float_t)validinner*fPheFFactorRelVarLimit*fFluxPhesInnerPixelVar;
    774   const Float_t outervar = (Float_t)validouter*fPheFFactorRelVarLimit*fFluxPhesOuterPixelVar;
    775  
    776   Float_t innererr;
    777   Float_t outererr;
    778 
    779   if (innervar > 0.)
    780     innererr = TMath::Sqrt(innervar);
    781   else
    782     {
    783       *fLog << warn << GetDescriptor() << ": Variance of mean number of photo-electrons for inner pixels "
    784             << " is smaller than 0. " << endl;
    785       SetFFactorMethodValid(kFALSE);
    786       return kFALSE;
    787     }
    788  
    789   if (outervar > 0.)
    790     outererr = TMath::Sqrt(outervar);
    791   else
    792     {
    793       *fLog << warn << GetDescriptor() << ": Variance of mean number of photo-electrons for outer pixels "
    794             << " is smaller than 0. " << endl;
    795       SetFFactorMethodValid(kFALSE);
    796       return kFALSE;
    797     }
    798 
    799   const Float_t lowerpheinnerlimit = fFluxPhesInnerPixel - innererr;
    800   const Float_t upperpheinnerlimit = fFluxPhesInnerPixel + innererr;
    801 
    802   const Float_t lowerpheouterlimit = fFluxPhesOuterPixel - outererr;
    803   const Float_t upperpheouterlimit = fFluxPhesOuterPixel + outererr;
    804 
    805   sumweightsinner = 0.;
    806   sumphesinner    = 0.;
    807   sumweightsouter = 0.;
    808   sumphesouter    = 0.;
    809    
    810   TIter Next2(fPixels);
    811   MCalibrationChargePix *pix2;
    812   while ((pix2=(MCalibrationChargePix*)Next2()))
    813     {
    814 
    815       if (!pix2->IsFFactorMethodValid())
    816         continue;
    817 
    818       const Int_t idx = pix2->GetPixId();
    819 
    820       if(!bad[idx].IsCalibrationResultOK())
    821         continue;
    822 
    823       const Float_t nphe    = pix2->GetPheFFactorMethod();
    824       const Float_t npheerr = pix2->GetPheFFactorMethodErr();
    825       const Float_t ratio   = geom.GetPixRatio(idx);
    826 
    827       if (npheerr > 0.)
    828         {
    829           const Float_t weight = nphe*nphe/npheerr/npheerr;
    830           //
    831           // first the inner pixels:
    832           //
    833           if (ratio == 1.)
    834             {
    835              
    836               if (nphe < lowerpheinnerlimit || nphe > upperpheinnerlimit)
    837                 {
    838                   bad[idx].SetUncalibrated(MBadPixelsPix::kDeviatingNumPhes);
    839                   bad[idx].SetUnsuitable(  MBadPixelsPix::kUnreliableRun);
    840                   continue;
    841                 }
    842 
    843               sumweightsinner += weight;
    844               sumphesinner    += weight*nphe;
    845             }
    846           else
    847             {
    848               //
    849               // now the outers
    850               //
    851               if (nphe < lowerpheouterlimit || nphe > upperpheouterlimit)
    852                 {
    853                   bad[idx].SetUncalibrated(MBadPixelsPix::kDeviatingNumPhes);
    854                   bad[idx].SetUnsuitable(  MBadPixelsPix::kUnreliableRun);
    855                   continue;
    856                 }
    857 
    858               sumweightsouter += weight;
    859               sumphesouter    += weight*nphe;
    860             }
    861         } /* if npheerr != 0 */
    862     } /* while ((pix2=(MCalibrationChargePix*)Next2())) */
    863 
    864   if (sumweightsinner <= 0. || sumphesinner <= 0.)
    865     {
    866       *fLog << warn << " Mean number of phe's from inner pixels cannot be calculated: "
    867             << " Sum of weights: " << sumweightsinner
    868             << " Sum of weighted phes: " << sumphesinner << endl;
    869       return kFALSE;
    870     }
    871   else
    872     {
    873       fFluxPhesInnerPixel    = sumphesinner/sumweightsinner;
    874       fFluxPhesInnerPixelVar = (1./sumweightsinner)*fFluxPhesInnerPixel*fFluxPhesInnerPixel;
    875 
    876     }
    877 
    878   if (sumweightsouter <= 0. || sumphesouter <= 0.)
    879     {
    880       *fLog << warn << " Mean number of phe's from outer pixels cannot be calculated: "
    881             << " Sum of weights or sum of weighted phes is 0. " << endl;
    882     }
    883   else
    884     {
    885       fFluxPhesOuterPixel    = sumphesouter/sumweightsouter;
    886       fFluxPhesOuterPixelVar = (1./sumweightsouter)*fFluxPhesOuterPixel*fFluxPhesOuterPixel;
    887     }
    888 
    889   meanFluxPhotonsRelVar = fFluxPhesInnerPixelVar
    890                        / (fFluxPhesInnerPixel    * fFluxPhesInnerPixel);
    891 
    892   fFluxPhotonsInnerPixel    =  fFluxPhesInnerPixel/fAverageQE;
    893   fFluxPhotonsInnerPixelVar =  (meanFluxPhotonsRelVar + avQERelVar)
    894                                  * fFluxPhotonsInnerPixel * fFluxPhotonsInnerPixel;
    895 
    896   fFluxPhotonsOuterPixel    = 4. *fFluxPhotonsInnerPixel;
    897   fFluxPhotonsOuterPixelVar = 16.*fFluxPhotonsInnerPixelVar; 
    898 
    899   *fLog << inf << " Mean number of photo-electrons from inner pixels (F-Factor Method): "
    900         << fFluxPhesInnerPixel << " +- " << GetFluxPhesInnerPixelErr() << endl;
    901 
    902   *fLog << inf << " Mean number of photons from inner pixels (F-Factor Method): "
    903         << fFluxPhotonsInnerPixel << " +- " << GetFluxPhotonsInnerPixelErr() << endl;
    904 
    905   return kTRUE;
    906 }
    907 
    908 void MCalibrationChargeCam::ApplyFFactorCalibration(const MGeomCam &geom, const MBadPixelsCam &bad)
    909 {
    910 
    911   const Float_t meanphotRelVar  = fFluxPhotonsInnerPixelVar
    912                                /( fFluxPhotonsInnerPixel    * fFluxPhotonsInnerPixel );
    913 
    914   TIter Next(fPixels);
    915   MCalibrationChargePix *pix;
    916   while ((pix=(MCalibrationChargePix*)Next()))
    917     {
    918 
    919       const Int_t idx = pix->GetPixId();
    920 
    921       if (!(bad[idx].IsCalibrationResultOK()))
    922         {
    923           pix->SetFFactorMethodValid(kFALSE);
    924           continue;
    925         }
    926 
    927       if (!(pix->IsFFactorMethodValid()))
    928         continue;
    929 
    930       const Float_t ratio   = geom.GetPixRatio(idx);
    931       //
    932       // Calculate the conversion factor between PHOTONS and FADC counts
    933       //
    934       // Nphot = Nphe / avQE
    935       // conv  = Nphot / FADC counts
    936       //
    937       Float_t conv;
    938      
    939       if (ratio == 1.)
    940         conv               = fFluxPhotonsInnerPixel / pix->GetMean();
    941       else
    942         conv               = fFluxPhotonsOuterPixel / pix->GetMean();
    943 
    944       if (conv <= 0.)
    945         {
    946           pix->SetFFactorMethodValid(kFALSE);
    947           continue;
    948         }
    949      
    950       const Float_t chargeRelVar       =   pix->GetMeanErr() * pix->GetMeanErr()
    951                                        / ( pix->GetMean()    * pix->GetMean());
    952       const Float_t rsigmaRelVar =   pix->GetRSigmaErr() *  pix->GetRSigmaErr()
    953                                         / (pix->GetRSigma()    * pix->GetRSigma()) ;
    954 
    955       const Float_t convrelvar = meanphotRelVar + chargeRelVar;
    956 
    957       if (convrelvar > fConvFFactorRelVarLimit)
    958         {
    959           *fLog << warn << GetDescriptor() << ": Conversion Factor F-Factor Method Rel. Variance: "
    960                 << convrelvar << " above limit of: " << fConvFFactorRelVarLimit
    961                 << " in pixel: " << idx << endl;
    962           pix->SetFFactorMethodValid(kFALSE);
    963           continue;
    964         }
    965      
    966       //
    967       // Calculate the Total F-Factor of the camera (in photons)
    968       //
    969       const Float_t totalFFactor  =  (pix->GetRSigma()/pix->GetMean())
    970                                     *TMath::Sqrt(fFluxPhotonsInnerPixel);
    971      
    972       //
    973       // Calculate the error of the Total F-Factor of the camera ( in photons )
    974       //
    975       const Float_t totalFFactorVar = rsigmaRelVar + chargeRelVar + meanphotRelVar;
    976 
    977       if (convrelvar > 0. && conv > 0.)
    978         pix->SetConversionFFactorMethod(conv,
    979                                         TMath::Sqrt(convrelvar)*conv,
    980                                         totalFFactor*TMath::Sqrt(conv));
    981 
    982       pix->SetTotalFFactorFFactorMethod(   totalFFactor   );
    983 
    984       if (totalFFactorVar > 0.)
    985         pix->SetTotalFFactorFFactorMethodErr(TMath::Sqrt(totalFFactorVar));     
    986 
    987       pix->SetFFactorMethodValid();
    988     }
    989 }
    990 
    991 
    992 
    993 void MCalibrationChargeCam::ApplyBlindPixelCalibration(const MGeomCam &geom, const MBadPixelsCam &bad, const MCalibrationChargeBlindPix &blindpix)
    994 {
    995 
    996   Float_t flux    = blindpix.GetFluxInsidePlexiglass();
    997   Float_t fluxerr = blindpix.GetFluxInsidePlexiglassErr();
    998 
    999   TIter Next(fPixels);
    1000   MCalibrationChargePix *pix;
    1001   while ((pix=(MCalibrationChargePix*)Next()))
    1002     {
    1003 
    1004       const Int_t idx = pix->GetPixId();
    1005 
    1006       if (!(bad[idx].IsCalibrationResultOK()))
    1007         {
    1008           pix->SetBlindPixelMethodValid(kFALSE);
    1009           continue;
    1010         }
    1011      
    1012       const Float_t charge    = pix->GetMean();
    1013       const Float_t area      = geom[idx].GetA();
    1014       const Float_t chargeerr = pix->GetMeanErr();         
    1015      
    1016       const Float_t nphot      = flux    * area;
    1017       const Float_t nphoterr   = fluxerr * area;
    1018       const Float_t conversion = nphot/charge;
    1019       Float_t conversionerr;
    1020      
    1021       conversionerr  = nphoterr/charge
    1022                      * nphoterr/charge ;
    1023       conversionerr += chargeerr/charge
    1024                      * chargeerr/charge
    1025                      * conversion*conversion;
    1026       conversionerr = TMath::Sqrt(conversionerr);
    1027 
    1028       const Float_t conversionsigma = 0.;
    1029      
    1030       pix->SetConversionBlindPixelMethod(conversion, conversionerr, conversionsigma);
    1031      
    1032       if (conversionerr/conversion < 0.1)
    1033         pix->SetBlindPixelMethodValid();
    1034     }
    1035 }
    1036 
    1037 void MCalibrationChargeCam::ApplyPINDiodeCalibration(const MGeomCam &geom, const MBadPixelsCam &bad, const MCalibrationChargePINDiode &pindiode)
    1038 {
    1039 
    1040   Float_t flux    = pindiode.GetFluxOutsidePlexiglass();
    1041   Float_t fluxerr = pindiode.GetFluxOutsidePlexiglassErr();
    1042 
    1043   TIter Next(fPixels);
    1044   MCalibrationChargePix *pix;
    1045   while ((pix=(MCalibrationChargePix*)Next()))
    1046     {
    1047 
    1048       const Int_t idx = pix->GetPixId();
    1049      
    1050       if (!(bad[idx].IsCalibrationResultOK()))
    1051         {
    1052           pix->SetPINDiodeMethodValid(kFALSE);
    1053           continue;
    1054         }
    1055      
    1056       const Float_t charge    = pix->GetMean();
    1057       const Float_t area      = geom[idx].GetA();
    1058       const Float_t chargeerr = pix->GetMeanErr();         
    1059      
    1060       const Float_t nphot      = flux    * area;
    1061       const Float_t nphoterr   = fluxerr * area;
    1062       const Float_t conversion = nphot/charge;
    1063      
    1064       Float_t conversionerr;
    1065      
    1066       conversionerr  = nphoterr/charge
    1067                      * nphoterr/charge ;
    1068       conversionerr += chargeerr/charge
    1069                      * chargeerr/charge
    1070                      * conversion*conversion;
    1071       if (conversionerr > 0.)
    1072         conversionerr = TMath::Sqrt(conversionerr);
    1073      
    1074       const Float_t conversionsigma = 0.;
    1075      
    1076       pix->SetConversionPINDiodeMethod(conversion, conversionerr, conversionsigma);
    1077      
    1078       if (conversionerr/conversion < 0.1)
    1079         pix->SetPINDiodeMethodValid();
    1080      
    1081     }
    1082 }
    1083 
    1084 
    1085 Bool_t MCalibrationChargeCam::GetConversionFactorBlindPixel(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
     608
     609
     610Bool_t MCalibrationChargeCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &ffactor)
    1086611{
    1087612
    1088613  MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[ipx];
    1089614
    1090   mean  = pix.GetMeanConversionBlindPixelMethod();
    1091   err   = pix.GetConversionBlindPixelMethodErr();
    1092   sigma = pix.GetSigmaConversionBlindPixelMethod();
    1093 
    1094   return kTRUE;
    1095 }
    1096 
    1097 
    1098 Bool_t MCalibrationChargeCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
    1099 {
    1100 
    1101   MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[ipx];
    1102 
    1103   Float_t conv = pix.GetMeanConversionFFactorMethod();
     615  Float_t conv = pix.GetMeanConvFADC2Phe();
    1104616
    1105617  if (conv < 0.)
    1106618    return kFALSE;
    1107619
    1108   mean  = conv;
    1109   err   = pix.GetConversionFFactorMethodErr();
    1110   sigma = pix.GetSigmaConversionFFactorMethod();
     620  mean    = conv;
     621  err     = pix.GetMeanConvFADC2PheErr();
     622  ffactor = pix.GetMeanFFactorFADC2Phot();
    1111623
    1112624  return kTRUE;
    1113625}
    1114626
    1115 
    1116 //-----------------------------------------------------------------------------------
    1117 //
    1118 // Calculates the conversion factor between the integral of FADCs slices
    1119 // (as defined in the signal extractor MExtractSignal.cc)
    1120 // and the number of photons reaching the plexiglass for one Inner Pixel
    1121 //
    1122 Bool_t MCalibrationChargeCam::GetConversionFactorPINDiode(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
    1123 {
    1124 
    1125   MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[ipx];
    1126 
    1127   mean  = pix.GetMeanConversionPINDiodeMethod();
    1128   err   = pix.GetConversionPINDiodeMethodErr();
    1129   sigma = pix.GetSigmaConversionPINDiodeMethod();
    1130 
    1131   return kFALSE;
    1132 
    1133 }
    1134 
    1135 //-----------------------------------------------------------------------------------
    1136 //
    1137 // Calculates the best combination of the three used methods possible
    1138 // between the integral of FADCs slices
    1139 // (as defined in the signal extractor MExtractSignal.cc)
    1140 // and the number of photons reaching one Inner Pixel.
    1141 // The procedure is not yet defined.
    1142 //
    1143 Bool_t MCalibrationChargeCam::GetConversionFactorCombined(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
    1144 {
    1145   return kFALSE;
    1146 
    1147 }
    1148627
    1149628/*
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h

    r3664 r3678  
    99class TH2D;
    1010
    11 class MCalibrationChargeBlindPix;
    12 class MCalibrationChargePINDiode;
    13 class MCalibrationChargePix;
    1411class MCalibrationChargeCam : public MCalibrationCam
    1512{
    1613private:
    17  
    18   static const Float_t fgAverageQE;              //! Default for fAverageQE              (now set to: 0.18)
    19   static const Float_t fgAverageQEErr;           //! Default for fAverageQEErr           (now set to: 0.02)
    20   static const Float_t fgConvFFactorRelErrLimit; //! Default for fConvFFactorRelErrLimit (now set to: 0.35)
    21   static const Float_t fgPheFFactorRelErrLimit;  //! Default for fPheFFactorRelErrLimit  (now set to: 5.)
    22  
    23   Float_t fAverageQE;                // Average quantum efficieny (see Class description)
    24   Float_t fAverageQEVar;             // Error av. quantum eff.    (see Class description)
    25   Float_t fConvFFactorRelVarLimit;   // Acceptance limit rel. error conv. factor (F-Factor method)
    26   Float_t fPheFFactorRelVarLimit;    // Acceptance limit number phe's w.r.t its mean (in variances)
    2714 
    2815  TH1D* fOffsets;                    //! Histogram with Higain-vs-LoGain fit result Offsets
     
    3017  TH2D* fOffvsSlope;                 //! Histogram with Higain-vs-LoGain fit result Offsets vs. Slopes
    3118
    32   enum  { kFFactorMethodValid, kBlindPixelMethodValid, kPINDiodeMethodValid, kCombinedMethodValid };
     19  enum  { kFFactorMethodValid };
    3320
    34   Float_t fFluxPhesInnerPixel;       // Mean nr.  photo-electrons in INNER PIXEL
    35   Float_t fFluxPhesInnerPixelVar;    // Variance nr. photo-electrons INNER PIXEL 
    36   Float_t fFluxPhesOuterPixel;       // Mean nr. photo-electrons in an OUTER PIXEL
    37   Float_t fFluxPhesOuterPixelVar;    // Variance nr, photo-electrons OUTER PIXEL 
    38   Float_t fFluxPhotonsInnerPixel;    // Mean nr. photo-electrons in INNER PIXEL
    39   Float_t fFluxPhotonsInnerPixelVar; // Variance nr. photo-electrons INNER PIXEL 
    40   Float_t fFluxPhotonsOuterPixel;    // Mean nr. photo-electrons in OUTER PIXEL
    41   Float_t fFluxPhotonsOuterPixelVar; // Variance nr. photo-electrons OUTER PIXEL 
    42   Byte_t fFlags;                     // Bit-fieldto hold the flags
     21  Byte_t  fFlags;                    // Bit-field to hold the flags
    4322 
    4423public:
     
    4726  ~MCalibrationChargeCam();
    4827 
    49   void Clear(    Option_t *o="" );
     28  void   Clear ( Option_t *o="" );
    5029
    5130  // Setters   
    52   void SetAverageQE             ( const Float_t q=fgAverageQE,
    53                                   const Float_t e=fgAverageQEErr)      { fAverageQE = q; fAverageQEVar = e*e; }
    54   void SetBlindPixelMethodValid ( const Bool_t  b=kTRUE                    );
    55   void SetConvFFactorRelErrLimit( const Float_t f=fgConvFFactorRelErrLimit ) { fConvFFactorRelVarLimit = f*f; }
    56   void SetFFactorMethodValid    ( const Bool_t  b=kTRUE                    );
    57   void SetPheFFactorRelErrLimit ( const Float_t f=fgPheFFactorRelErrLimit  ) { fPheFFactorRelVarLimit  = f*f; } 
    58   void SetPINDiodeMethodValid   ( const Bool_t  b=kTRUE                    ); 
     31  void   SetFFactorMethodValid     ( const Bool_t  b=kTRUE );
    5932
    6033  // Getters
    61   Bool_t  GetConversionFactorFFactor    ( Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
    62   Bool_t  GetConversionFactorBlindPixel ( Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
    63   Bool_t  GetConversionFactorPINDiode   ( Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
    64   Bool_t  GetConversionFactorCombined   ( Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
     34  Bool_t GetConversionFactorFFactor( Int_t ipx, Float_t &mean, Float_t &err, Float_t &ffactor );
    6535
    66   Float_t GetFluxPhesInnerPixel()        const { return fFluxPhesInnerPixel;    }
    67   Float_t GetFluxPhesInnerPixelErr()     const;
    68   Float_t GetFluxPhesOuterPixel()        const { return fFluxPhesOuterPixel;    }
    69   Float_t GetFluxPhesOuterPixelErr()     const;
    70   Float_t GetFluxPhotonsInnerPixel()     const { return fFluxPhotonsInnerPixel; }
    71   Float_t GetFluxPhotonsInnerPixelErr()  const;
    72   Float_t GetFluxPhotonsOuterPixel()     const { return fFluxPhotonsOuterPixel; }
    73   Float_t GetFluxPhotonsOuterPixelErr()  const;
    74 
    75   Bool_t IsBlindPixelMethodValid()       const;
    76   Bool_t IsPINDiodeMethodValid()         const; 
     36  Bool_t IsFFactorMethodValid()      const;
    7737
    7838  // Prints
    79   void Print(Option_t *o="")             const;
     39  void Print(Option_t *o="")         const;
    8040 
    8141  // Draws
    82   void DrawPixelContent(Int_t num)       const;   
    8342//  void DrawHiLoFits();
    8443 
    8544  // Others
    8645  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
     46  void DrawPixelContent(Int_t num)   const;   
    8747
    88   Bool_t CalcFluxPhotonsFFactorMethod(const MGeomCam &geom, MBadPixelsCam &bad); 
    89 
    90   void   ApplyPINDiodeCalibration   ( const MGeomCam &geom,
    91                                       const MBadPixelsCam &bad,
    92                                       const MCalibrationChargePINDiode &pindiode );
    93   void   ApplyBlindPixelCalibration ( const MGeomCam &geom,
    94                                       const MBadPixelsCam &bad,
    95                                       const MCalibrationChargeBlindPix &blindpix );
    96   void   ApplyFFactorCalibration    ( const MGeomCam &geom,
    97                                       const MBadPixelsCam &bad                   );
    98 
    99   ClassDef(MCalibrationChargeCam, 1)    // Container Charge Calibration Results Camera
     48  ClassDef(MCalibrationChargeCam, 1) // Container Charge Calibration Results Camera
    10049};
    10150
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.cc

    r3672 r3678  
    5151#include "MCalibrationChargePINDiode.h"
    5252#include "MCalibrationChargePix.h"
     53
     54#include "MCalibrationCam.h"
    5355
    5456#include "MLog.h"
     
    195197// --------------------------------------------------------------------------
    196198//
     199// Return -1 if fFluxOutsidePlexiglassVar is smaller than 0.
     200// Return -1 if fFluxOutsidePlexiglass is 0.
     201// Return  fFluxOutsidePlexiglassVar / fFluxOutsidePlexiglass^2
     202//
     203Float_t MCalibrationChargePINDiode::GetFluxOutsidePlexiglassRelVar() const
     204{
     205  if (fFluxOutsidePlexiglassVar < 0.)
     206    return -1.;
     207 
     208  if (fFluxOutsidePlexiglass == 0.)
     209    return -1.;
     210 
     211  return fFluxOutsidePlexiglassVar / (fFluxOutsidePlexiglass * fFluxOutsidePlexiglass );
     212}
     213
     214// --------------------------------------------------------------------------
     215//
    197216// Return -1 if fNumPhotonsVar is smaller than 0.
    198217// Return square root of fNumPhotonsVar
     
    375394  switch (fColor)
    376395    {
    377     case kGREEN:
     396    case MCalibrationCam::kGREEN:
    378397      fFluxOutsidePlexiglass    = fNumPhotons           * gkSolidAngleRatio           * gkPINDiodeQEGreen;
    379398      fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar()  + GetPINDiodeQEGreenRelVar();
    380399      break;
    381     case kBLUE:
     400    case MCalibrationCam::kBLUE:
    382401      fFluxOutsidePlexiglass    = fNumPhotons           * gkSolidAngleRatio           * gkPINDiodeQEBlue;
    383402      fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar()  + GetPINDiodeQEBlueRelVar();
    384403      break;
    385     case kUV:
     404    case MCalibrationCam::kUV:
    386405      fFluxOutsidePlexiglass    = fNumPhotons           * gkSolidAngleRatio          * gkPINDiodeQEUV;
    387406      fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar() + GetPINDiodeQEUVRelVar();
    388407      break;
    389     case kCT1:
     408    case MCalibrationCam::kCT1:
    390409    default:
    391410      fFluxOutsidePlexiglass    = fNumPhotons           * gkSolidAngleRatio          * gkPINDiodeQECT1;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.h

    r3672 r3678  
    11#ifndef MARS_MCalibrationChargePINDiode
    22#define MARS_MCalibrationChargePINDiode
     3
     4#ifndef MARS_MCalibrationCam
     5#include "MCalibrationCam.h"
     6#endif
    37
    48#ifndef MARS_MCalibrationPix
     
    4145  Float_t fRmsChargeSigma;            // Sigma of RMS of summed FADC slices distribution   
    4246  Float_t fRmsChargeSigmaErr;         // Error on Sigma RMS summed FADC slices distribution
    43   PulserColor_t fColor;              // Colour of the pulsed LEDs
     47  MCalibrationCam::PulserColor_t fColor; // Colour of the pulsed LEDs
    4448
    4549  enum  { kOscillating,
     
    6569  void SetChargeToPhotons    ( const Float_t f=fgChargeToPhotons    ) { fChargeToPhotons    = f;   } 
    6670  void SetChargeToPhotonsErr ( const Float_t f=fgChargeToPhotonsErr ) { fChargeToPhotonsVar = f*f; } 
    67   void SetColor              ( const PulserColor_t color            ) { fColor = color;            }
     71  void SetColor              ( const MCalibrationCam::PulserColor_t color) { fColor = color;   }
    6872  void SetPedestal           (       Float_t ped, Float_t pedrms    );
    6973  void SetRmsChargeMean      ( const Float_t f )                      { fRmsChargeMean      = f;   }
     
    7781
    7882  // Getters
    79   Float_t GetFluxOutsidePlexiglass()    const { return fFluxOutsidePlexiglass; }
    80   Float_t GetFluxOutsidePlexiglassErr() const;
     83  Float_t GetFluxOutsidePlexiglass      () const { return fFluxOutsidePlexiglass; }
     84  Float_t GetFluxOutsidePlexiglassErr   () const;
     85  Float_t GetFluxOutsidePlexiglassRelVar() const; 
    8186
    8287  // Pedestals
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc

    r3672 r3678  
    4848// The following variables are set by MCalibrationChargeCalc:
    4949// - fPed, fPedVar and fPedRms                         
    50 // - fMeanConversionFFactorMethod, fMeanConversionBlindPixelMethod,
    51 //   fMeanConversionPINDiodeMethod and fMeanConversionCombinedMethod   
    52 // - fConversionFFactorMethodVar, fConversionBlindPixelMethodVar
    53 //   fConversionPINDiodeMethodVar and fConversionCombinedMethodVar
    54 // - fSigmaConversionFFactorMethod, fSigmaConversionBlindPixelMethod
    55 //   fSigmaConversionPINDiodeMethod and fSigmaConversionCombinedMethod 
    56 // - fTotalFFactorFFactorMethod, fTotalFFactorBlindPixelMethod   
    57 //   fTotalFFactorPINDiodeMethod and fTotalFFactorCombinedMethod     
    58 // - fTotalFFactorFFactorMethodVar, fTotalFFactorBlindPixelMethodVar,
    59 //   fTotalFFactorPINDiodeMethodVar and fTotalFFactorCombinedMethodVar 
     50// - fMeanConvFADC2Phe
     51// - fConvFADC2PheVar
     52// - fSigmaConvFADC2Phe
     53// - fTotalFFactorFFactorMethod
     54// - fTotalFFactorFFactorMethodVar
    6055//
    6156// The following variables are not yet implemented:
     
    9287const Float_t MCalibrationChargePix::fgConversionHiLoErr        = 2.5;
    9388const Float_t MCalibrationChargePix::fgPheFFactorMethodLimit    = 5.;
     89const Float_t MCalibrationChargePix::fgConvFFactorRelErrLimit   = 0.35;
    9490// --------------------------------------------------------------------------
    9591//
     
    10096// - fConversionHiLo to fgConversionHiLo
    10197// - fConversionHiLoVar to square of fgConversionHiLoErr
    102 // - fPheFFactorMethodLimit to fgPheFFactorMethodLimit
     98// - fConvFFactorRelErrLimit to fgConvFFactorRelErrLimit*fgConvFFactorRelErrLimit
     99// - fPheFFactorLimit to fgPheFFactorLimit
    103100//
    104101// Calls:
     
    120117
    121118  SetPheFFactorMethodLimit();
     119  SetConvFFactorRelErrLimit();
    122120 
    123121  Clear();
     
    136134{
    137135
    138   SetBlindPixelMethodValid  ( kFALSE );
    139136  SetFFactorMethodValid     ( kFALSE );
    140   SetPINDiodeMethodValid    ( kFALSE );
    141   SetCombinedMethodValid    ( kFALSE );
    142137
    143138  fRSigmaSquare                     =  -1.;
     
    157152  fPheFFactorMethodVar              =  -1.;
    158153
    159   fMeanConversionFFactorMethod      =  -1.;
    160   fMeanConversionBlindPixelMethod   =  -1.;
    161   fMeanConversionPINDiodeMethod     =  -1.;
    162   fMeanConversionCombinedMethod     =  -1.;
    163 
    164   fConversionFFactorMethodVar       =  -1.;
    165   fConversionBlindPixelMethodVar    =  -1.;
    166   fConversionPINDiodeMethodVar      =  -1.;
    167   fConversionCombinedMethodVar      =  -1.;
    168 
    169   fSigmaConversionFFactorMethod     =  -1.;
    170   fSigmaConversionBlindPixelMethod  =  -1.;
    171   fSigmaConversionPINDiodeMethod    =  -1.;
    172   fSigmaConversionCombinedMethod    =  -1.;
    173 
    174   fTotalFFactorFFactorMethod        =  -1.;
    175   fTotalFFactorBlindPixelMethod     =  -1.;
    176   fTotalFFactorPINDiodeMethod       =  -1.;
    177   fTotalFFactorCombinedMethod       =  -1.;
     154  fMeanConvFADC2Phe                 =  -1.;
     155  fMeanConvFADC2PheVar              =  -1.;
     156  fMeanFFactorFADC2Phot             =  -1.;
     157  fMeanFFactorFADC2PhotVar          =  -1.; 
    178158
    179159  MCalibrationPix::Clear();
    180160}
    181161
    182 
    183 // --------------------------------------------------------------------------
    184 //
    185 // Set conversion factors Blind Pixel Method from outside (only for MC)
    186 //
    187 void MCalibrationChargePix::SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig)
    188 {
    189   fMeanConversionBlindPixelMethod  = c;
    190   fConversionBlindPixelMethodVar   = err*err;
    191   fSigmaConversionBlindPixelMethod = sig;
    192 }
    193 
    194 
    195 // --------------------------------------------------------------------------
    196 //
    197 // Set conversion factors Combined Method from outside (only for MC)
    198 //
    199 void MCalibrationChargePix::SetConversionCombinedMethod(Float_t c, Float_t err, Float_t sig)
    200 {
    201   fMeanConversionCombinedMethod  = c;
    202   fConversionCombinedMethodVar   = err*err;
    203   fSigmaConversionCombinedMethod = sig;
    204 }
    205 
    206 
    207 // --------------------------------------------------------------------------
    208 //
    209 // Set conversion factors F-Factor Method from outside (only for MC)
    210 //
    211 void MCalibrationChargePix::SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)
    212 {
    213   fMeanConversionFFactorMethod  = c;
    214   fConversionFFactorMethodVar   = err*err;
    215   fSigmaConversionFFactorMethod = sig;
    216 }
    217 
    218 // --------------------------------------------------------------------------
    219 //
    220 // Set conversion factors PIN Diode Method from outside (only for MC)
    221 //
    222 void MCalibrationChargePix::SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig)
    223 {
    224   fMeanConversionPINDiodeMethod  = c ;
    225   fConversionPINDiodeMethodVar   = err*err;
    226   fSigmaConversionPINDiodeMethod = sig;
    227 }
    228 
    229 // --------------------------------------------------------------------------
    230 //
    231 // Set Blind Pixel Method Validity Bit from outside
    232 //
    233 void MCalibrationChargePix::SetBlindPixelMethodValid(const Bool_t b )
    234 {
    235   b ?  SETBIT(fCalibFlags, kBlindPixelMethodValid) : CLRBIT(fCalibFlags, kBlindPixelMethodValid);
    236 }   
    237 
    238 // --------------------------------------------------------------------------
    239 //
    240 // Set Combined Method Validity Bit from outside
    241 //
    242 void MCalibrationChargePix::SetCombinedMethodValid(const Bool_t b ) 
    243 {
    244   b ?  SETBIT(fCalibFlags, kCombinedMethodValid) : CLRBIT(fCalibFlags, kCombinedMethodValid);
    245 }
    246162
    247163// --------------------------------------------------------------------------
     
    253169  b ?  SETBIT(fCalibFlags, kFFactorMethodValid) : CLRBIT(fCalibFlags, kFFactorMethodValid);
    254170}   
    255 
    256 // --------------------------------------------------------------------------
    257 //
    258 // Set PIN Diode Method Validity Bit from outside
    259 //
    260 void MCalibrationChargePix::SetPINDiodeMethodValid(const Bool_t b ) 
    261 {
    262   b ?  SETBIT(fCalibFlags, kPINDiodeMethodValid) : CLRBIT(fCalibFlags, kPINDiodeMethodValid);
    263 }
    264171
    265172// --------------------------------------------------------------------------
     
    485392  if (IsHiGainSaturation())
    486393    return TMath::Sqrt(rsigmaVar/fRSigmaSquare + GetConversionHiLoRelVar()) * GetRSigma();
    487  else
    488    return TMath::Sqrt(rsigmaVar);
    489 
    490 }
     394  else
     395    return TMath::Sqrt(rsigmaVar);
     396
     397}
     398
     399// --------------------------------------------------------------------------
     400//
     401// Get the reduced Sigma Square:
     402// - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
     403// - Test bit kHiGainSaturation:
     404//   If yes, return fRSigmaSquare, multiplied with fConversionHiLo^2,
     405//   If no , return fRSigmaSquare
     406//
     407Float_t MCalibrationChargePix::GetRSigmaSquare()  const
     408{
     409  if (fRSigmaSquare < 0)
     410    return -1;
     411
     412  return IsHiGainSaturation() ? fRSigmaSquare*fConversionHiLo*fConversionHiLo : fRSigmaSquare ;
     413}
    491414
    492415// --------------------------------------------------------------------------
     
    533456// --------------------------------------------------------------------------
    534457//
    535 // Get the error on the mean conversion factor (Combined Method):
    536 // - If fConversionCombinedMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
    537 // - Else returns the square root of fConversionCombinedMethodVar
    538 //
    539 Float_t MCalibrationChargePix::GetConversionCombinedMethodErr()  const
    540 {
    541   if (fConversionCombinedMethodVar < 0.)
    542     return -1.;
    543   return TMath::Sqrt(fConversionCombinedMethodVar);
    544 }
    545 
    546 // --------------------------------------------------------------------------
    547 //
    548 // Get the error on the mean conversion factor (PINDiode Method):
    549 // - If fConversionPINDiodeMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
    550 // - Else returns the square root of fConversionPINDiodeMethodVar
    551 //
    552 Float_t MCalibrationChargePix::GetConversionPINDiodeMethodErr()  const
    553 {
    554   if (fConversionPINDiodeMethodVar < 0.)
    555     return -1.;
    556   return TMath::Sqrt(fConversionPINDiodeMethodVar);
    557 }
    558 
    559 // --------------------------------------------------------------------------
    560 //
    561 // Get the error on the mean conversion factor (BlindPixel  Method):
    562 // - If fConversionBlindPixelMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
    563 // - Else returns the square root of fConversionBlindPixelMethodVar
    564 //
    565 Float_t MCalibrationChargePix::GetConversionBlindPixelMethodErr()  const
    566 {
    567   if (fConversionBlindPixelMethodVar < 0.)
    568     return -1.;
    569   return TMath::Sqrt(fConversionBlindPixelMethodVar);
    570 }
     458// Get the error on the mean total F-Factor of the signal readout (F-Factor Method):
     459// - If fMeanFFactorFADC2PhotVar is smaller than 0 (i.e. has not yet been set), return -1.
     460// - Else returns the square root of fMeanFFactorFADC2PhotVar
     461//
     462Float_t MCalibrationChargePix::GetMeanFFactorFADC2PhotErr()  const
     463{
     464  if (fMeanFFactorFADC2PhotVar < 0.)
     465    return -1.;
     466  return TMath::Sqrt(fMeanFFactorFADC2PhotVar);
     467}
     468
     469// --------------------------------------------------------------------------
     470//
     471// Get the relative variance on the number of photo-electrons (F-Factor Method):
     472// - If fPheFFactorMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
     473// - If fPheFFactorMethod    is 0, return -1.
     474// - Else returns fPheFFactorMethodVar / fPheFFactorMethod^2
     475//
     476Float_t MCalibrationChargePix::GetPheFFactorMethodRelVar()  const
     477{
     478  if (fPheFFactorMethodVar < 0.)
     479    return -1.;
     480  if (fPheFFactorMethod  == 0.)
     481    return -1.;
     482
     483  return fPheFFactorMethodVar / (fPheFFactorMethod * fPheFFactorMethod);
     484}
     485
    571486
    572487// --------------------------------------------------------------------------
    573488//
    574489// Get the error on the mean conversion factor (FFactor  Method):
    575 // - If fConversionFFactorMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
    576 // - Else returns the square root of fConversionFFactorMethodVar
    577 //
    578 Float_t MCalibrationChargePix::GetConversionFFactorMethodErr()  const
    579 {
    580   if (fConversionFFactorMethodVar < 0.)
    581     return -1.;
    582   return TMath::Sqrt(fConversionFFactorMethodVar);
    583 }
    584 
    585 // --------------------------------------------------------------------------
    586 //
    587 // Get the error on the total F-Factor (Combined  Method):
    588 // - If fTotalFFactorCombinedMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
    589 // - Else returns the square root of fTotalFFactorCombinedMethodVar
    590 //
    591 Float_t MCalibrationChargePix::GetTotalFFactorCombinedMethodErr()  const
    592 {
    593   if (fTotalFFactorCombinedMethodVar < 0.)
    594     return -1.;
    595   return TMath::Sqrt(fTotalFFactorCombinedMethodVar);
    596 }
    597 
    598 // --------------------------------------------------------------------------
    599 //
    600 // Get the error on the total F-Factor (PIN Diode  Method):
    601 // - If fTotalPINDiodeCombinedMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
    602 // - Else returns the square root of fTotalPINDiodeCombinedMethodVar
    603 //
    604 Float_t MCalibrationChargePix::GetTotalFFactorPINDiodeMethodErr()  const
    605 {
    606   if (fTotalFFactorPINDiodeMethodVar < 0.)
    607     return -1.;
    608   return TMath::Sqrt(fTotalFFactorPINDiodeMethodVar);
    609 }
    610 
    611 // --------------------------------------------------------------------------
    612 //
    613 // Get the error on the total F-Factor (Blind Pixel  Method):
    614 // - If fTotalBlindPixelCombinedMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
    615 // - Else returns the square root of fTotalBlindPixelCombinedMethodVar
    616 //
    617 Float_t MCalibrationChargePix::GetTotalFFactorBlindPixelMethodErr()  const
    618 {
    619   if (fTotalFFactorBlindPixelMethodVar < 0.)
    620     return -1.;
    621   return TMath::Sqrt(fTotalFFactorBlindPixelMethodVar);
    622 }
    623 
    624 // --------------------------------------------------------------------------
    625 //
    626 // Get the error on the total F-Factor (F-Factor  Method):
    627 // - If fTotalFFactorCombinedMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
    628 // - Else returns the square root of fTotalFFactorCombinedMethodVar
    629 //
    630 Float_t MCalibrationChargePix::GetTotalFFactorFFactorMethodErr()  const
    631 {
    632   if (fTotalFFactorFFactorMethodVar < 0.)
    633     return -1.;
    634   return TMath::Sqrt(fTotalFFactorFFactorMethodVar);
    635 }
    636 
    637 // --------------------------------------------------------------------------
    638 //
    639 // Test bit kBlindPixelMethodValid
    640 //
    641 Bool_t MCalibrationChargePix::IsBlindPixelMethodValid() const
    642 {
    643   return TESTBIT(fCalibFlags, kBlindPixelMethodValid);
     490// - If fMeanConvFADC2PheVar is smaller than 0 (i.e. has not yet been set), return -1.
     491// - Else returns the square root of fMeanConvFADC2PheVar
     492//
     493Float_t MCalibrationChargePix::GetMeanConvFADC2PheErr()  const
     494{
     495  if (fMeanConvFADC2PheVar < 0.)
     496    return -1.;
     497  return TMath::Sqrt(fMeanConvFADC2PheVar);
    644498}
    645499
     
    653507}
    654508
    655 // --------------------------------------------------------------------------
    656 //
    657 // Test bit kPINDiodeMethodValid
    658 //
    659 Bool_t MCalibrationChargePix::IsPINDiodeMethodValid()  const
    660 {
    661   return TESTBIT(fCalibFlags, kPINDiodeMethodValid);   
    662 }
    663 
    664 // --------------------------------------------------------------------------
    665 //
    666 // Test bit kCombinedMethodValid
    667 //
    668 Bool_t MCalibrationChargePix::IsCombinedMethodValid()  const
    669 {
    670   return TESTBIT(fCalibFlags, kCombinedMethodValid);   
    671 }
    672509
    673510// ----------------------------------------------------------------------------
     
    710547  const Float_t pedRmsSquareVar = IsHiGainSaturation() ? fLoGainPedRmsSquareVar : 0.25*fPedVar*pedRmsSquare;
    711548
    712   const Float_t sigmaSquare    = sigma     * sigma;
    713   const Float_t sigmaSquareVar = sigmavar  * sigmaSquare;
     549  const Float_t sigmaSquare    =      sigma     * sigma;
     550  const Float_t sigmaSquareVar = 4. * sigmavar  * sigmaSquare;
    714551
    715552  //
     
    761598
    762599  if (fRSigmaSquare < 0.)
     600    return kFALSE;
     601 
     602  //
     603  // Square all variables in order to avoid applications of square root
     604  //
     605  const Float_t meanSquare          =     GetMean()    * GetMean();
     606  const Float_t meanSquareRelVar    = 4.* GetMeanRelVar();
     607
     608  const Float_t ffactorsquare       =     gkFFactor    * gkFFactor;
     609  const Float_t ffactorsquareRelVar = 4.* GetFFactorRelVar();
     610
     611  const Float_t rsigmaSquareRelVar  =     fRSigmaSquareVar / fRSigmaSquare / fRSigmaSquare;
     612  //
     613  // Calculate the number of phe's from the F-Factor method
     614  // (independent on Hi Gain or Lo Gain)
     615  //
     616  fPheFFactorMethod = ffactorsquare * meanSquare / fRSigmaSquare;
     617
     618  if (fPheFFactorMethod < fPheFFactorMethodLimit)
     619    return kFALSE;
     620 
     621  //
     622  // Calculate the Error of Nphe
     623  //
     624  const Float_t pheRelVar = ffactorsquareRelVar + meanSquareRelVar + rsigmaSquareRelVar;
     625  fPheFFactorMethodVar =  pheRelVar * fPheFFactorMethod * fPheFFactorMethod;
     626
     627  if (fPheFFactorMethodVar < 0. )
     628    return kFALSE;
     629
     630  fMeanConvFADC2Phe    =  fPheFFactorMethod / GetMean();
     631 
     632  if (fMeanConvFADC2Phe < 0. )
     633    return kFALSE;
     634 
     635  //
     636  // In the calculation of the number of phe's one mean square has already been used.
     637  // Now, we divide by another mean, so one mean calcels out, we cannot directly propagate
     638  // the errors, but have to take account of this cancellation:
     639  //
     640  const Float_t convrelvar = ffactorsquareRelVar + GetMeanRelVar() + rsigmaSquareRelVar;
     641
     642  if (convrelvar > fConvFFactorRelVarLimit || convrelvar < 0.)
    763643    {
    764       SetFFactorMethodValid(kFALSE);
     644      *fLog << warn << GetDescriptor() << ": Conversion F-Factor Method Rel. Variance: "
     645            << convrelvar << " above limits of: [0," << Form("%3.2f",fConvFFactorRelVarLimit)
     646            << "] in pixel: " << fPixId << endl;
    765647      return kFALSE;
    766648    }
    767649 
    768   //
    769   // Square all variables in order to avoid applications of square root
    770   //
    771   const Float_t meanSquare          =     GetMean()    * GetMean();
    772   const Float_t meanSquareRelVar    = 4.* GetMeanRelVar();
    773 
    774   const Float_t ffactorsquare       =     gkFFactor    * gkFFactor;
    775   const Float_t ffactorsquareRelVar = 4.* GetFFactorRelVar();
    776 
    777   const Float_t rsigmaSquareRelVar  =     fRSigmaSquareVar / fRSigmaSquare;
    778 
    779   //
    780   // Calculate the number of phe's from the F-Factor method
    781   // (independent on Hi Gain or Lo Gain)
    782   //
    783   fPheFFactorMethod = ffactorsquare * meanSquare / fRSigmaSquare;
    784 
    785   if (fPheFFactorMethod < fPheFFactorMethodLimit)
     650  fMeanConvFADC2PheVar =  convrelvar * fMeanConvFADC2Phe * fMeanConvFADC2Phe;
     651 
     652  SetFFactorMethodValid(kTRUE);
     653  return kTRUE;
     654}
     655
     656// ----------------------------------------------------------------------------------
     657//
     658// If photflux is smaller or equal 0, return kFALSE
     659//
     660// Calculate the total F-Factor with the formula:
     661//   fMeanFFactorFADC2Phot = fRSigmaSquare / GetMeanSquare() * sqrt(photflux)
     662//
     663// Calculate the error of the total F-Factor
     664//
     665Bool_t MCalibrationChargePix::CalcMeanFFactor( const Float_t photflux, const Float_t photfluxrelvar )
     666{
     667
     668  if (photflux <= 0.)
    786669    {
    787       SetFFactorMethodValid(kFALSE);
     670      *fLog << warn << GetDescriptor() << ": Assumed photon flux is smaller or equal 0." << endl;
    788671      return kFALSE;
    789672    }
    790  
    791   //
    792   // Calculate the Error of Nphe
    793   //
    794   fPheFFactorMethodVar =  (ffactorsquareRelVar + meanSquareRelVar + rsigmaSquareRelVar)
    795                          * fPheFFactorMethod * fPheFFactorMethod;
    796 
    797   SetFFactorMethodValid(kTRUE);
     673
     674  if (photfluxrelvar < 0.)
     675    {
     676      *fLog << warn << GetDescriptor() << ": Assumed photon flux variance is smaller than 0." << endl;
     677      return kFALSE;
     678    }
     679
     680  fMeanFFactorFADC2Phot =  fRSigmaSquare / GetMeanSquare() * TMath::Sqrt(photflux);
     681 
     682  if (fMeanFFactorFADC2Phot < 0.)
     683    {
     684      *fLog << warn << GetDescriptor() << ": F-Factor photons to FADC counts smaller than 0." << endl;
     685      return kFALSE;
     686    }
     687 
     688  const Float_t ffactorrelvar = fRSigmaSquareVar / ( fRSigmaSquare * fRSigmaSquare)
     689                              + 4.   * GetMeanRelVar()
     690                              + 0.25 * photfluxrelvar;
     691 
     692  fMeanFFactorFADC2PhotVar    = ffactorrelvar * fMeanFFactorFADC2Phot * fMeanFFactorFADC2Phot;
     693
    798694  return kTRUE;
    799695}
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h

    r3674 r3678  
    1212  static const Float_t gkElectronicPedRms;       //! Electronic component of ped. RMS (now set to: 1.5)
    1313  static const Float_t gkElectronicPedRmsErr;    //! Error Electr. component ped. RMS (now set to: 0.3)
    14   static const Float_t gkFFactor;                //! Laboratory F-factor PMTs       (now set to: 1.15)
    15   static const Float_t gkFFactorErr;             //! Laboratory F-factor Error PMTs (now set to: 0.02)
     14  static const Float_t gkFFactor;                //! Laboratory F-factor PMTs         (now set to: 1.15)
     15  static const Float_t gkFFactorErr;             //! Laboratory F-factor Error PMTs   (now set to: 0.02)
    1616
    17   static const Float_t fgConversionHiLo;         //! Default fConversionHiLo        (now set to: 10.)
    18   static const Float_t fgConversionHiLoErr;      //! Default fConversionHiLoVar     (now set to: 2.5)
    19   static const Float_t fgPheFFactorMethodLimit;  //! Default fPheFFactorMethodLimit (now set to: 5.)
     17  static const Float_t fgConversionHiLo;         //! Default fConversionHiLo          (now set to: 10.)
     18  static const Float_t fgConversionHiLoErr;      //! Default fConversionHiLoVar       (now set to: 2.5)
     19  static const Float_t fgPheFFactorMethodLimit;  //! Default fPheFFactorMethodLimit   (now set to: 5.)
     20  static const Float_t fgConvFFactorRelErrLimit; //! Default fConvFFactorRelErrLimit  (now set to: 0.35) 
    2021 
    2122  Float_t fAbsTimeMean;                     // Mean Absolute Arrival Time
    2223  Float_t fAbsTimeRms;                      // RMS Mean Absolute Arrival Time
    2324  Byte_t  fCalibFlags;                      // Bit-field for the class-own bits
    24   Float_t fConversionFFactorMethodVar;      // Variance conversion factor (F-factor method)
    25   Float_t fConversionBlindPixelMethodVar;   // Variance conversion factor (Blind Pixel method)
    26   Float_t fConversionPINDiodeMethodVar;     // Variance conversion factor (PIN Diode method)
    27   Float_t fConversionCombinedMethodVar;     // Variance conversion factor (all methods combined)
    2825  Float_t fConversionHiLo;                  // Conversion factor betw. Hi Gain and Lo Gain 
    2926  Float_t fConversionHiLoVar;               // Variance Conversion factor betw. Hi and Lo Gain
     27  Float_t fConvFFactorRelVarLimit;          // Limit for acceptance rel. variance Conversion FADC2Phe
    3028  Float_t fLoGainPedRmsSquare;              // Pedestal RMS square of Low Gain
    3129  Float_t fLoGainPedRmsSquareVar;           // Pedestal RMS square Variance of Low Gain
    32   Float_t fMeanConversionFFactorMethod;     // Conversion factor (F-factor method)
    33   Float_t fMeanConversionBlindPixelMethod;  // Conversion factor (Blind Pixel method)
    34   Float_t fMeanConversionPINDiodeMethod;    // Conversion factor (PIN Diode method)
    35   Float_t fMeanConversionCombinedMethod;    // Conversion factor (all methods combined)
     30  Float_t fMeanConvFADC2Phe;                // Conversion factor (F-factor method)
     31  Float_t fMeanConvFADC2PheVar;             // Variance conversion factor (F-factor method)
     32  Float_t fMeanFFactorFADC2Phot;            // Total mean F-Factor to photons (F-factor method)
     33  Float_t fMeanFFactorFADC2PhotVar;         // Variance mean F-Factor photons (F-factor method) 
    3634  Float_t fPed;                             // Pedestal (from MPedestalPix) times number FADC slices
    3735  Float_t fPedVar;                          // Variance of pedestal
     
    4240  Float_t fRSigmaSquare;                    // Square of Reduced sigma
    4341  Float_t fRSigmaSquareVar;                 // Variance Reduced sigma
    44   Float_t fSigmaConversionFFactorMethod;    // Sigma Conversion factor (F-factor method)
    45   Float_t fSigmaConversionBlindPixelMethod; // Sigma Conversion factor (Blind Pixel method)
    46   Float_t fSigmaConversionPINDiodeMethod;   // Sigma Conversion factor (PIN Diode method)
    47   Float_t fSigmaConversionCombinedMethod;   // Sigma Conversion factor (all methods combined)
    48   Float_t fTotalFFactorFFactorMethod;       // Total F-Factor to Ph's (F-factor method)
    49   Float_t fTotalFFactorBlindPixelMethod;    // Total F-Factor to Ph's (Blind Pixel method)
    50   Float_t fTotalFFactorPINDiodeMethod;      // Total F-Factor to Ph's (PIN Diode method)
    51   Float_t fTotalFFactorCombinedMethod;      // Total F-Factor to Ph's (all methods combined)
    52   Float_t fTotalFFactorFFactorMethodVar;    // Variance total F-Factor (F-factor method)
    53   Float_t fTotalFFactorBlindPixelMethodVar; // Variance total F-Factor (Blind Pixel method)
    54   Float_t fTotalFFactorPINDiodeMethodVar;   // Variance total F-Factor (PIN Diode method)
    55   Float_t fTotalFFactorCombinedMethodVar;   // Variance total F-Factor (all methods combined)
    5642 
    57   enum  { kBlindPixelMethodValid, kFFactorMethodValid,
    58           kPINDiodeMethodValid, kCombinedMethodValid }; // Possible bits to be set
     43  enum  { kFFactorMethodValid   };          // Possible bits to be set
    5944
    6045  const Float_t GetConversionHiLoRelVar()  const;
     
    7156  void SetAbsTimeMean ( const Float_t f ) { fAbsTimeMean = f; }
    7257  void SetAbsTimeRms  ( const Float_t f ) { fAbsTimeRms  = f; }
    73   void SetConversionHiLo    ( const Float_t c=fgConversionHiLo    ) { fConversionHiLo    = c;   }
    74   void SetConversionHiLoErr ( const Float_t e=fgConversionHiLoErr ) { fConversionHiLoVar = e*e; }
    75   void SetConversionFFactorMethod   ( Float_t c, Float_t err, Float_t sig );
    76   void SetConversionBlindPixelMethod( Float_t c, Float_t err, Float_t sig );
    77   void SetConversionPINDiodeMethod  ( Float_t c, Float_t err, Float_t sig );
    78   void SetConversionCombinedMethod  ( Float_t c, Float_t err, Float_t sig );
    79 
    80   void SetBlindPixelMethodValid( const Bool_t b = kTRUE );
     58  void SetConversionHiLo    ( const Float_t c=fgConversionHiLo    )        { fConversionHiLo    = c;       }
     59  void SetConversionHiLoErr ( const Float_t e=fgConversionHiLoErr )        { fConversionHiLoVar = e*e;     }
     60  void SetConvFFactorRelErrLimit   ( const Float_t f=fgConvFFactorRelErrLimit) { fConvFFactorRelVarLimit = f*f;}
    8161  void SetFFactorMethodValid   ( const Bool_t b = kTRUE );
    82   void SetPINDiodeMethodValid  ( const Bool_t b = kTRUE );
    83   void SetCombinedMethodValid  ( const Bool_t b = kTRUE );
    84 
     62  void SetMeanConvFADC2Phe      ( const Float_t f)                          { fMeanConvFADC2Phe       = f; }
     63  void SetMeanConvFADC2PheVar   ( const Float_t f)                          { fMeanConvFADC2PheVar    = f; }
     64  void SetMeanFFactorFADC2Phot  ( const Float_t f)                          { fMeanFFactorFADC2Phot   = f; }
    8565  void SetPedestal              ( const Float_t ped, const Float_t pedrms, const Float_t pederr);
    8666  void SetPheFFactorMethod      ( const Float_t f)                          { fPheFFactorMethod       = f; }
    8767  void SetPheFFactorMethodVar   ( const Float_t f)                          { fPheFFactorMethodVar    = f; } 
    8868  void SetPheFFactorMethodLimit ( const Float_t f=fgPheFFactorMethodLimit ) { fPheFFactorMethodLimit  = f; }
    89   void SetTotalFFactorFFactorMethod       ( const Float_t f)  { fTotalFFactorFFactorMethod       = f; }
    90   void SetTotalFFactorBlindPixelMethod    ( const Float_t f)  { fTotalFFactorBlindPixelMethod    = f; }
    91   void SetTotalFFactorPINDiodeMethod      ( const Float_t f)  { fTotalFFactorPINDiodeMethod      = f; }
    92   void SetTotalFFactorFFactorMethodErr    ( const Float_t f)  { fTotalFFactorFFactorMethodVar    = f*f; }
    93   void SetTotalFFactorBlindPixelMethodErr ( const Float_t f)  { fTotalFFactorBlindPixelMethodVar = f*f; }
    94   void SetTotalFFactorPINDiodeMethodErr   ( const Float_t f)  { fTotalFFactorPINDiodeMethodVar   = f*f; }
    9569 
    9670  // Getters
    97   Float_t GetAbsTimeMean                ()     const { return fAbsTimeMean;     }
    98   Float_t GetAbsTimeRms                 ()     const { return fAbsTimeRms;      }
    99   Float_t GetConversionHiLo             ()     const { return fConversionHiLo;  }
    100   Float_t GetConversionHiLoErr          ()     const;
    101   Float_t GetConversionBlindPixelMethodErr()   const;
    102   Float_t GetConversionFFactorMethodErr ()     const;
    103   Float_t GetConversionPINDiodeMethodErr()     const;
    104   Float_t GetConversionCombinedMethodErr()     const;
    105   Float_t GetConvertedLoGainMean        ()     const;
    106   Float_t GetConvertedLoGainMeanErr     ()     const;
    107   Float_t GetConvertedLoGainSigma       ()     const;
    108   Float_t GetConvertedLoGainSigmaErr    ()     const;
    109   Float_t GetMeanConversionBlindPixelMethod()  const { return fMeanConversionBlindPixelMethod  ; }
    110   Float_t GetMeanConversionCombinedMethod()    const { return fMeanConversionCombinedMethod ;    }
    111   Float_t GetMeanConversionFFactorMethod()     const { return fMeanConversionFFactorMethod;      }
    112   Float_t GetMeanConversionPINDiodeMethod()    const { return fMeanConversionPINDiodeMethod ;    }
    113   Float_t GetSigmaConversionBlindPixelMethod() const { return fSigmaConversionBlindPixelMethod ; }
    114   Float_t GetSigmaConversionCombinedMethod()   const { return fSigmaConversionCombinedMethod ;   }
    115   Float_t GetSigmaConversionFFactorMethod()    const { return fSigmaConversionFFactorMethod;     }
    116   Float_t GetSigmaConversionPINDiodeMethod()   const { return fSigmaConversionPINDiodeMethod ;   }
    117   Float_t GetPed                ()             const { return fPed;                              }
    118   Float_t GetPedErr             ()             const;
    119   Float_t GetPedRms             ()             const;
    120   Float_t GetPedRmsErr          ()             const;
    121   Float_t GetPheFFactorMethod   ()             const { return fPheFFactorMethod;                 }   
    122   Float_t GetPheFFactorMethodErr()             const;
    123   Float_t GetPheFFactorMethodVar()             const { return fPheFFactorMethodVar;              }
    124   Float_t GetRSigma             ()             const;
    125   Float_t GetRSigmaErr          ()             const;
    126   Float_t GetRSigmaRelVar       ()             const;
    127   Float_t GetTotalFFactorBlindPixelMethod()    const { return fTotalFFactorBlindPixelMethod;     }
    128   Float_t GetTotalFFactorBlindPixelMethodErr() const;
    129   Float_t GetTotalFFactorCombinedMethod()      const { return fTotalFFactorCombinedMethod;       }
    130   Float_t GetTotalFFactorCombinedMethodErr()   const;
    131   Float_t GetTotalFFactorFFactorMethod()       const { return fTotalFFactorFFactorMethod;        }
    132   Float_t GetTotalFFactorFFactorMethodErr()    const;
    133   Float_t GetTotalFFactorPINDiodeMethod()      const { return fTotalFFactorPINDiodeMethod;       }
    134   Float_t GetTotalFFactorPINDiodeMethodErr()   const;
     71  Float_t GetAbsTimeMean             () const { return fAbsTimeMean;             }
     72  Float_t GetAbsTimeRms              () const { return fAbsTimeRms;              }
     73  Float_t GetConversionHiLo          () const { return fConversionHiLo;          }
     74  Float_t GetConversionHiLoErr       () const;
     75  Float_t GetConvertedLoGainMean     () const;
     76  Float_t GetConvertedLoGainMeanErr  () const;
     77  Float_t GetConvertedLoGainSigma    () const;
     78  Float_t GetConvertedLoGainSigmaErr () const;
     79  Float_t GetMeanConvFADC2Phe        () const { return fMeanConvFADC2Phe;        }
     80  Float_t GetMeanConvFADC2PheErr     () const;
     81  Float_t GetMeanConvFADC2PheVar     () const { return fMeanConvFADC2PheVar;     }
     82  Float_t GetMeanFFactorFADC2Phot    () const { return fMeanFFactorFADC2Phot;    }
     83  Float_t GetMeanFFactorFADC2PhotErr () const;
     84  Float_t GetMeanFFactorFADC2PhotVar () const { return fMeanFFactorFADC2PhotVar; }   
     85  Float_t GetPed                     () const { return fPed;                     }
     86  Float_t GetPedErr                  () const;
     87  Float_t GetPedRms                  () const;
     88  Float_t GetPedRmsErr               () const;
     89  Float_t GetPheFFactorMethod        () const { return fPheFFactorMethod;        }   
     90  Float_t GetPheFFactorMethodErr     () const;
     91  Float_t GetPheFFactorMethodVar     () const { return fPheFFactorMethodVar;     }
     92  Float_t GetPheFFactorMethodRelVar  () const;
     93  Float_t GetRSigma                  () const;
     94  Float_t GetRSigmaErr               () const;
     95  Float_t GetRSigmaSquare            () const; 
     96  Float_t GetRSigmaRelVar            () const;
    13597
    136   Bool_t IsBlindPixelMethodValid()             const;
    137   Bool_t IsPINDiodeMethodValid()               const;
    138   Bool_t IsFFactorMethodValid()                const;
    139   Bool_t IsCombinedMethodValid()               const;
     98  Bool_t IsFFactorMethodValid        () const;
    14099
    141   // Miscellaneous
    142   void   CalcLoGainPedestal(const Float_t logainsamples);
    143   Bool_t CalcReducedSigma();
    144   Bool_t CalcFFactorMethod();
    145 
     100  // Calculations
     101  void   CalcLoGainPedestal       ( const Float_t logainsamples  );
     102  Bool_t CalcReducedSigma  ();
     103  Bool_t CalcFFactorMethod ();
     104  Bool_t CalcMeanFFactor   ( const Float_t photflux, const Float_t phtfluxrelvar );
     105 
    146106  ClassDef(MCalibrationChargePix, 1)    // Container Charge Calibration Results Pixel
    147107};
  • trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.cc

    r3644 r3678  
    6464/////////////////////////////////////////////////////////////////////////////
    6565#include "MCalibrationQECam.h"
     66#include "MCalibrationCam.h"
    6667
    6768#include <TClonesArray.h>
     
    7677using namespace std;
    7778
     79const Float_t MCalibrationQECam::gkPlexiglassQE         = 0.96;
     80const Float_t MCalibrationQECam::gkPlexiglassQEErr      = 0.01;
    7881// --------------------------------------------------------------------------
    7982//
     
    8588//
    8689MCalibrationQECam::MCalibrationQECam(const char *name, const char *title)
     90    : fFlags(MCalibrationCam::gkNumPulserColors)
    8791{
    8892    fName  = name  ? name  : "MCalibrationQECam";
     
    9397    fAverageSectors   = new TClonesArray("MCalibrationQEPix",1);
    9498
    95 }
    96 
     99    Clear();
     100}
     101
     102// ------------------------------------------------------------------------
     103//
     104// Sets all bits to kFALSE
     105//
     106// Calls:
     107// - MCalibrationCam::Clear()
     108//
     109void MCalibrationQECam::Clear(Option_t *o)
     110{
     111
     112  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kGREEN);
     113  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kGREEN);
     114  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kGREEN);
     115  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kGREEN);
     116  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kBLUE);
     117  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kBLUE);
     118  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kBLUE);
     119  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kBLUE);
     120  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kUV);
     121  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kUV);
     122  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kUV);
     123  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kUV);
     124  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kCT1);
     125  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kCT1);
     126  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kCT1);
     127  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kCT1);
     128
     129  MCalibrationCam::Clear();
     130}
     131
     132// --------------------------------------------------------------------------
     133//
     134// Return -1 if gkPlexiglassQEErr is smaller than 0.
     135// Return -1 if gkPlexiglassQE    is 0.
     136// Return gkPlexiglassQEErr^2 / (gkPlexiglassQE^2 )
     137//
     138Float_t MCalibrationQECam::GetPlexiglassQERelVar() const
     139{
     140  if (gkPlexiglassQEErr < 0.)
     141    return -1.;
     142 
     143  if (gkPlexiglassQE  == 0.)
     144    return -1.;
     145 
     146  return gkPlexiglassQEErr * gkPlexiglassQEErr / gkPlexiglassQE / gkPlexiglassQE ;
     147}
     148
     149
     150void MCalibrationQECam::SetBlindPixelMethodValid ( Bool_t b )
     151{
     152  SetBlindPixelMethodValid ( b, MCalibrationCam::kGREEN);
     153  SetBlindPixelMethodValid ( b, MCalibrationCam::kBLUE );
     154  SetBlindPixelMethodValid ( b, MCalibrationCam::kUV   );
     155  SetBlindPixelMethodValid ( b, MCalibrationCam::kCT1  );
     156}
     157
     158void MCalibrationQECam::SetCombinedMethodValid ( Bool_t b )
     159{
     160  SetCombinedMethodValid ( b, MCalibrationCam::kGREEN);
     161  SetCombinedMethodValid ( b, MCalibrationCam::kBLUE );
     162  SetCombinedMethodValid ( b, MCalibrationCam::kUV   );
     163  SetCombinedMethodValid ( b, MCalibrationCam::kCT1  );
     164}
     165
     166void MCalibrationQECam::SetFFactorMethodValid ( Bool_t b )
     167{
     168  SetFFactorMethodValid ( b, MCalibrationCam::kGREEN);
     169  SetFFactorMethodValid ( b, MCalibrationCam::kBLUE );
     170  SetFFactorMethodValid ( b, MCalibrationCam::kUV   );
     171  SetFFactorMethodValid ( b, MCalibrationCam::kCT1  );
     172}
     173
     174void MCalibrationQECam::SetPINDiodeMethodValid ( Bool_t b )
     175{
     176  SetPINDiodeMethodValid ( b, MCalibrationCam::kGREEN);
     177  SetPINDiodeMethodValid ( b, MCalibrationCam::kBLUE );
     178  SetPINDiodeMethodValid ( b, MCalibrationCam::kUV   );
     179  SetPINDiodeMethodValid ( b, MCalibrationCam::kCT1  );
     180}
     181
     182void MCalibrationQECam::SetBlindPixelMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col )
     183{
     184  if (b)
     185    SETBIT(fFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);
     186  else
     187    CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);   
     188}
     189
     190void MCalibrationQECam::SetPINDiodeMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col )
     191{
     192  if (b)
     193    SETBIT(fFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);
     194  else
     195    CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);   
     196}
     197
     198void MCalibrationQECam::SetFFactorMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col )
     199{
     200  if (b)
     201    SETBIT(fFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);
     202  else
     203    CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);   
     204}
     205
     206void MCalibrationQECam::SetCombinedMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col )
     207{
     208  if (b)
     209    SETBIT(fFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);
     210  else
     211    CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);   
     212}
     213
     214Bool_t MCalibrationQECam::IsBlindPixelMethodValid () const 
     215{
     216  if (IsBlindPixelMethodValid (MCalibrationCam::kGREEN))
     217    return kTRUE;
     218  if (IsBlindPixelMethodValid (MCalibrationCam::kBLUE ))
     219    return kTRUE;
     220  if (IsBlindPixelMethodValid (MCalibrationCam::kUV   ))
     221    return kTRUE;
     222  if (IsBlindPixelMethodValid (MCalibrationCam::kCT1  ))
     223    return kTRUE;
     224
     225  return kFALSE;
     226}
     227
     228Bool_t MCalibrationQECam::IsCombinedMethodValid () const
     229{
     230  if (IsCombinedMethodValid (MCalibrationCam::kGREEN))
     231    return kTRUE;
     232  if (IsCombinedMethodValid (MCalibrationCam::kBLUE ))
     233    return kTRUE;
     234  if (IsCombinedMethodValid (MCalibrationCam::kUV   ))
     235    return kTRUE;
     236  if (IsCombinedMethodValid (MCalibrationCam::kCT1  ))
     237    return kTRUE;
     238
     239  return kFALSE;
     240}
     241
     242Bool_t MCalibrationQECam::IsFFactorMethodValid () const
     243{
     244  if (IsFFactorMethodValid (MCalibrationCam::kGREEN))
     245    return kTRUE;
     246  if (IsFFactorMethodValid (MCalibrationCam::kBLUE ))
     247    return kTRUE;
     248  if (IsFFactorMethodValid (MCalibrationCam::kUV   ))
     249    return kTRUE;
     250  if (IsFFactorMethodValid (MCalibrationCam::kCT1  ))
     251    return kTRUE;
     252
     253  return kFALSE;
     254}
     255
     256
     257Bool_t MCalibrationQECam::IsPINDiodeMethodValid () const
     258{
     259  if (IsPINDiodeMethodValid (MCalibrationCam::kGREEN))
     260    return kTRUE;
     261  if (IsPINDiodeMethodValid (MCalibrationCam::kBLUE ))
     262    return kTRUE;
     263  if (IsPINDiodeMethodValid (MCalibrationCam::kUV   ))
     264    return kTRUE;
     265  if (IsPINDiodeMethodValid (MCalibrationCam::kCT1  ))
     266    return kTRUE;
     267
     268  return kFALSE;
     269}
     270
     271Bool_t MCalibrationQECam::IsBlindPixelMethodValid (MCalibrationCam::PulserColor_t col)  const
     272{
     273  return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);
     274}
     275
     276Bool_t MCalibrationQECam::IsCombinedMethodValid (MCalibrationCam::PulserColor_t col)  const
     277{
     278  return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);
     279}
     280
     281Bool_t MCalibrationQECam::IsFFactorMethodValid (MCalibrationCam::PulserColor_t col)  const
     282{
     283  return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);
     284}
     285
     286Bool_t MCalibrationQECam::IsPINDiodeMethodValid (MCalibrationCam::PulserColor_t col)  const
     287{
     288  return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);
     289}
    97290
    98291// --------------------------------------------------------------------------
     
    114307      if (!pix->IsExcluded() && pix->IsValid())
    115308        {
    116             *fLog << all << "Pix " << pix->GetPixId()
    117                 << ":  QE: "                   << pix->GetQE(kCT1)        << " +- " << pix->GetQEErr(kCT1)
    118                 << endl;
    119309          id++;
    120310        }
     
    134324        if (!pix->IsExcluded() && !pix->IsValid())
    135325          {
    136             *fLog << all << "Pix " << pix->GetPixId()
    137                 << ":  QE: "                   << pix->GetQE(kCT1)        << " +- " << pix->GetQEErr(kCT1)
    138                 << endl;
    139326            id++;
    140327          }
     
    188375    {
    189376    case 0:
    190       val = pix.GetQE(kCT1);
     377      val = pix.GetQEBlindPixel(kCT1);
    191378      break;
    192379    case 1:
    193       val = pix.GetQEErr(kCT1);
     380      val = pix.GetQEBlindPixelErr(kCT1);
    194381      break;
    195382    case 2:
    196       val = pix.GetQE(kGREEN);
     383      val = pix.GetQEBlindPixel(kGREEN);
    197384      break;
    198385    case 3:
    199       val = pix.GetQEErr(kGREEN);
     386      val = pix.GetQEBlindPixelErr(kGREEN);
    200387      break;
    201388    case 4:
    202       val = pix.GetQE(kBLUE);
     389      val = pix.GetQEBlindPixel(kBLUE);
    203390      break;
    204391    case 5:
    205       val = pix.GetQEErr(kBLUE);
     392      val = pix.GetQEBlindPixelErr(kBLUE);
    206393      break;
    207394    case 6:
    208       val = pix.GetQE(kUV);
     395      val = pix.GetQEBlindPixel(kUV);
    209396      break;
    210397    case 7:
    211       val = pix.GetQEErr(kUV);
     398      val = pix.GetQEBlindPixelErr(kUV);
    212399      break;
    213400    default:
  • trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.h

    r3647 r3678  
    66#endif
    77
     8#ifndef ROOT_TArrayC
     9#include "TArrayC.h"
     10#endif
     11
    812class MCalibrationQECam : public MCalibrationCam
    913{
    1014private:
    11  
     15
     16  static const Float_t gkPlexiglassQE   ;  //! Quantum Efficiency Plexiglass
     17  static const Float_t gkPlexiglassQEErr;  //! Uncertainty QE Plexiglass
     18
     19  TArrayC fFlags;
     20
     21  enum { kBlindPixelMethodValid, kFFactorMethodValid,
     22         kPINDiodeMethodValid, kCombinedMethodValid };
     23
    1224public:
    1325
    1426  MCalibrationQECam(const char *name=NULL, const char *title=NULL);
    1527  ~MCalibrationQECam() {}
     28
     29  void Clear( Option_t *o="");
    1630 
     31  Float_t GetPlexiglassQE       () const { return gkPlexiglassQE; }
     32  Float_t GetPlexiglassQERelVar () const;
     33
     34  // Only for MC (Ciao Abelardo!!)
     35  void SetBlindPixelMethodValid ( Bool_t  b=kTRUE );
     36  void SetFFactorMethodValid    ( Bool_t  b=kTRUE ); 
     37  void SetCombinedMethodValid   ( Bool_t  b=kTRUE );
     38  void SetPINDiodeMethodValid   ( Bool_t  b=kTRUE ); 
     39
     40  void SetBlindPixelMethodValid ( Bool_t  b, MCalibrationCam::PulserColor_t col);
     41  void SetFFactorMethodValid    ( Bool_t  b, MCalibrationCam::PulserColor_t col); 
     42  void SetCombinedMethodValid   ( Bool_t  b, MCalibrationCam::PulserColor_t col);
     43  void SetPINDiodeMethodValid   ( Bool_t  b, MCalibrationCam::PulserColor_t col); 
     44
     45  Bool_t IsBlindPixelMethodValid() const;
     46  Bool_t IsFFactorMethodValid   () const; 
     47  Bool_t IsCombinedMethodValid  () const; 
     48  Bool_t IsPINDiodeMethodValid  () const; 
     49
     50  Bool_t IsBlindPixelMethodValid(MCalibrationCam::PulserColor_t col) const;
     51  Bool_t IsFFactorMethodValid   (MCalibrationCam::PulserColor_t col) const; 
     52  Bool_t IsCombinedMethodValid  (MCalibrationCam::PulserColor_t col) const; 
     53  Bool_t IsPINDiodeMethodValid  (MCalibrationCam::PulserColor_t col) const; 
     54
    1755  // Prints
    1856  void Print(Option_t *o="") const;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationQEPix.cc

    r3644 r3678  
    2424
    2525/////////////////////////////////////////////////////////////////////////////
    26 //                                                                         //
    27 // MCalibrationQEPix                                                       //
    28 //                                                                         //
    29 // Storage container of the calibrated Quantrum Efficiency of one pixel
    30 // For the moment, only a fixed average QE is stored:
    31 //
    32 // - Average QE: (email David Paneque, 14.2.04):
    33 //
    34 //  The conversion factor that comes purely from QE folded to a Cherenkov
    35 //  spectrum has to be multiplied by:
    36 //  * Plexiglass window -->> 0.96 X 0.96
    37 //  * PMT photoelectron collection efficiency -->> 0.9
    38 //  * Light guides efficiency -->> 0.94
    39 //
    40 //  Concerning the light guides effiency estimation... Daniel Ferenc
     26//                                                                     
     27// MCalibrationQEPix                                                   
     28//                                                                     
     29// Storage container of the calibrated Quantrum Efficiency of one pixel.
     30// This container (like MCalibrationQECam) is designed to persist during
     31// several eventloops over different calibration files, especially those
     32// with different colour LEDs. It is the class calibration the Quantum
     33// efficiency for each individual pixel.
     34//
     35// At the moment, this calibration works in the following steps:
     36//
     37// 1)  MHCalibrationChargeCam extracts mean and sigma (and its errors) of
     38//     the summed FADC slices distribution and stores them in MCalibrationCam
     39//     
     40// 2)  MHCalibrationChargeBlindPix extracts the mean of a Poisson fit to the
     41//     single photo-electron spectrum and stores it in MCalibrationChargeBlindPix
     42//     
     43// 3)  MHCalibrationChargePINDiode extracts the mean of a charge distribution
     44//     of the signals collected by the PIN Diode and stores it in MCalibrationChargePINDiode
     45//     
     46// 4)  MCalibrationCalc calculates for every pixel the number of photo-electrons
     47//     with the F-Factor method (see MCalibrationCalc)
     48//
     49// 5)  MCalibrationCalc calculates the (weighted) average number of photo-electrons
     50//     from the pixels with the area index 0 (Inner pixels for the MAGIC camera)
     51//     and divides this number by gkDefaultQEGreen, gkDefaultQEBlue, gkDefaultQEUV
     52//     or gkDefaultQECT1, depending on the implied pulser LED colour, and further
     53//     by MCalibratinoQECam::gkPlexiglassQE. The obtained number gives the NUMBER
     54//     OF PHOTONS incident on a pixel with area index 0 (INNER pixel) OUTSIDE THE
     55//     PLEXIGLASS of the camera, obtained with the F-Factor method.
     56//
     57// 6)  MCalibrationCalc calculates the mean photon flux per mm^2 in the camera
     58//     from the MCalibrationChargeBlindPix, multiplies it with the area of
     59//     one pixel with area index 0 (Inner pixel) and divides it by the quantum
     60//     efficiency of the plexi-glass (MCalibratinoQECam::gkPlexiglassQE). The obtained
     61//     number gives the NUMBER OF PHOTONS incident on a pixel with area index 0
     62//     (INNER pixel) OUTSIDE THE PLEXIGLASS of the camera, obtained with the
     63//     Blind Pixel method.
     64//
     65// 7)  MCalibrationCalc calculates the mean photon flux per mm^2 in the camera
     66//     from the MCalibrationChargePINDiode and multiplies it with the area of
     67//     one pixel with area index 0 (Inner pixel). The obtained number gives the
     68//     NUMBER OF PHOTONS incident on a pixel with area index 0 (INNER pixel)
     69//     OUTSIDE THE PLEXIGLASS of the camera, obtained with the PIN Diode method.
     70//
     71// 8)  Each of the three photons numbers is divided by the mean sum of FADC counts
     72//     and defined as MEASURED QUANTUM EFFICIENCY AT A GIVEN COLOUR. They are stored
     73//     in the variables SetQE*Method ( qe, colour ).
     74//
     75// 9)  Errors are propagated and corresponding variances get stored in: SetQE*Var( qe, colour).
     76//
     77// 10) After every eventloop, MCalibrationChargeCalc calls the function: Update*Method().
     78//     which calculates the ratio measured QE / gkDefaultQE* of every colour implied so far
     79//     and calculates an weighted average of these quantum-efficiency normalizations obtained
     80//     by one of the three methods.
     81//
     82// 11) A call to GetQECascades* returns then the normalization multiplied with an average QE
     83//     folded into a cascades spectrum. This number should be dependent on zenith angle, but
     84//     this feature is not yet implemented, instead a fixed number gkDefaultAverageQE is used.
     85//
     86// The number gkDefaultAverageQE = 0.20 +- 0.02 can be obtained in the following way:
     87//                             
     88// * Averaged QE coated PMTs: zenith     value
     89//                              0.       0.237
     90//                             20.       0.237
     91//                             40.       0.236
     92//                             60.       0.234
     93// (from D.Paneque et al., NIM A 504, 2003, 109-115
     94//
     95// * PMT photoelectron collection efficiency: 0.9
     96// (from D.Paneque, email 14.2.2004)
     97//
     98// * Light guides efficiency: 0.94
     99// (from D.Paneque, email 14.2.2004)
     100//
     101// "Concerning the light guides effiency estimation... Daniel Ferenc
    41102//  is preparing some work (simulations) to estimate it. Yet so far, he has
    42103//  been busy with other stuff, and this work is still UNfinished.
     
    58119//  which is the variation of teh entrance window cross section. So, in
    59120//  first approximation, no loses when increasing light incidence angle;
    60 //  and therefore, the factor 0.94.
    61 //
    62 //  So, summarizing... I would propose the following conversion factors
    63 //  (while working with CT1 cal box) in order to get the final number of photons
    64 //  from the detected measured size in ADC counts.
    65 //
    66 //  Nph = ADC * FmethodConversionFactor / ConvPhe-PhFactor
    67 //
    68 //  FmethodConversionFactor ; measured for individual pmts
    69 //
    70 //  ConvPhe-PhFactor = 0.98 * 0.23 * 0.90 * 0.94 * 0.96 * 0.96 = 0.18
    71 //
    72 //  I would not apply any smearing of this factor (which we have in nature),
    73 //  since we might be applying it to PMTs in the totally wrong direction.
    74 //
    75 //
     121//  and therefore, the factor 0.94."
     122//
    76123/////////////////////////////////////////////////////////////////////////////
    77124#include "MCalibrationQEPix.h"
     125#include "MCalibrationCam.h"
    78126
    79127#include "MLog.h"
    80128#include "MLogManip.h"
    81129
     130#include "TArrayF.h"
     131#include "TArrayC.h"
     132
    82133ClassImp(MCalibrationQEPix);
    83134
    84135using namespace std;
    85136
     137const Float_t MCalibrationQEPix::gkDefaultQEGreen      = 0.192;
     138const Float_t MCalibrationQEPix::gkDefaultQEBlue       = 0.27;
     139const Float_t MCalibrationQEPix::gkDefaultQEUV         = 0.285;
     140const Float_t MCalibrationQEPix::gkDefaultQECT1        = 0.285;
     141const Float_t MCalibrationQEPix::gkDefaultQEGreenErr   = 0.05 ;
     142const Float_t MCalibrationQEPix::gkDefaultQEBlueErr    = 0.07 ;
     143const Float_t MCalibrationQEPix::gkDefaultQEUVErr      = 0.07 ;
     144const Float_t MCalibrationQEPix::gkDefaultQECT1Err     = 0.07 ;
     145const Float_t MCalibrationQEPix::gkDefaultAverageQE    = 0.20;     
     146const Float_t MCalibrationQEPix::gkDefaultAverageQEErr = 0.02; 
    86147// --------------------------------------------------------------------------
    87148//
    88149// Default Constructor:
    89150//
     151// Initializes all TArrays to MCalibrationCam::gkNumPulserColors
     152//
     153// Calls:
     154// - Clear()
     155//
    90156MCalibrationQEPix::MCalibrationQEPix(const char *name, const char *title)
     157    :  fQEBlindPixel    ( MCalibrationCam::gkNumPulserColors),
     158       fQEBlindPixelVar ( MCalibrationCam::gkNumPulserColors ),
     159       fQECombined      ( MCalibrationCam::gkNumPulserColors ),   
     160       fQECombinedVar   ( MCalibrationCam::gkNumPulserColors ),
     161       fQEFFactor       ( MCalibrationCam::gkNumPulserColors ),     
     162       fQEFFactorVar    ( MCalibrationCam::gkNumPulserColors ), 
     163       fQEPINDiode      ( MCalibrationCam::gkNumPulserColors ),   
     164       fQEPINDiodeVar   ( MCalibrationCam::gkNumPulserColors ),
     165       fValidFlags      ( MCalibrationCam::gkNumPulserColors )
    91166{
    92167
     
    98173}
    99174
     175// ----------------------------------------------------------------------------------------------
     176//
     177// Search all available QE's of a certain colour after the blind pixel method,
     178// compare them to the default QE of that colour and
     179// add up a weighted average (wav) and a sum of weights (sumw)
     180//
     181// FIXME: This has to be replaced by a decent fit the QE-spectrum!
     182//
     183void MCalibrationQEPix::AddAverageBlindPixelQEs(const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw )
     184{
     185
     186  if (IsBlindPixelMethodValid (col))
     187  {
     188    const Float_t newavqe    =   GetQEBlindPixel(col)       / GetDefaultQE (col) ;
     189    const Float_t newavqevar = ( GetQEBlindPixelRelVar(col) + GetDefaultQERelVar(col) ) * newavqe * newavqe;
     190    wav  += newavqe / newavqevar;
     191    sumw += 1. / newavqevar ;
     192  }
     193}
     194
     195// ----------------------------------------------------------------------------------------------
     196//
     197// Search all available QE's of a certain colour after the combination of the three methods
     198// compare them to the default QE of that colour and
     199// add up a weighted average (wav) and a sum of weights (sumw)
     200//
     201// FIXME: This has to be replaced by a decent fit the QE-spectrum!
     202//
     203void MCalibrationQEPix::AddAverageCombinedQEs(const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw )
     204{
     205
     206  if (IsCombinedMethodValid (col))
     207  {
     208    const Float_t newavqe    =   GetQECombined(col)       / GetDefaultQE (col) ;
     209    const Float_t newavqevar = ( GetQECombinedRelVar(col) + GetDefaultQERelVar(col) ) * newavqe * newavqe;
     210    wav  += newavqe / newavqevar;
     211    sumw += 1./ newavqevar;
     212  }
     213}
     214
     215// ----------------------------------------------------------------------------------------------
     216//
     217// Search all available QE's of a certain colour after the F-Factor method,
     218// compare them to the default QE of that colour and
     219// add up a weighted average (wav) and a sum of weights (sumw)
     220//
     221// FIXME: This has to be replaced by a decent fit the QE-spectrum!
     222//
     223void MCalibrationQEPix::AddAverageFFactorQEs(const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw )
     224{
     225
     226  if (IsFFactorMethodValid (col))
     227  {
     228    const Float_t newavqe    =   GetQEFFactor(col)       / GetDefaultQE (col) ;
     229    const Float_t newavqevar = ( GetQEFFactorRelVar(col) + GetDefaultQERelVar(col) ) * newavqe * newavqe;
     230    wav  += newavqe / newavqevar;
     231    sumw += 1./ newavqevar;
     232  }
     233}
     234
     235// ----------------------------------------------------------------------------------------------
     236//
     237// Search all available QE's of a certain colour after the PIN Diode method,
     238// compare them to the default QE of that colour and
     239// add up a weighted average (wav) and a sum of weights (sumw)
     240//
     241// FIXME: This has to be replaced by a decent fit the QE-spectrum!
     242//
     243void MCalibrationQEPix::AddAveragePINDiodeQEs(const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw )
     244{
     245
     246  if (IsPINDiodeMethodValid (col))
     247  {
     248    const Float_t newavqe    =   GetQEPINDiode(col)       / GetDefaultQE (col) ;
     249    const Float_t newavqevar = ( GetQEPINDiodeRelVar(col) + GetDefaultQERelVar(col) ) * newavqe * newavqe;
     250    wav  += newavqe / newavqevar;
     251    sumw += 1./ newavqevar;
     252  }
     253}
     254
     255
     256
    100257// ------------------------------------------------------------------------
    101258//
    102 // Invalidate values
     259// Sets all quantum efficiencies to the gkDefaultQE*
     260// Sets all Variances to the square root of gkDefaultQE*Err
     261// Sets all flags to kFALSE
     262//
     263// Calls:
     264// - MCalibrationPix::Clear()
    103265//
    104266void MCalibrationQEPix::Clear(Option_t *o)
    105267{
    106268
    107   fQEGreen      =  -1.;
    108   fQEBlue       =  -1.;
    109   fQEUV         =  -1.;
    110   fQECT1        =  -1.;
     269  SetAverageQEBlindPixelAvailable ( kFALSE );
     270  SetAverageQEFFactorAvailable    ( kFALSE );
     271  SetAverageQECombinedAvailable   ( kFALSE );
     272  SetAverageQEPINDiodeAvailable   ( kFALSE );
     273
     274  fQEBlindPixel    [ MCalibrationCam::kGREEN ] = gkDefaultQEGreen; 
     275  fQEBlindPixelVar [ MCalibrationCam::kGREEN ] = gkDefaultQEGreenErr*gkDefaultQEGreenErr;
     276  fQEFFactor       [ MCalibrationCam::kGREEN ] = gkDefaultQEGreen;     
     277  fQEFFactorVar    [ MCalibrationCam::kGREEN ] = gkDefaultQEGreenErr*gkDefaultQEGreenErr;
     278  fQECombined      [ MCalibrationCam::kGREEN ] = gkDefaultQEGreen;   
     279  fQECombinedVar   [ MCalibrationCam::kGREEN ] = gkDefaultQEGreenErr*gkDefaultQEGreenErr;
     280  fQEPINDiode      [ MCalibrationCam::kGREEN ] = gkDefaultQEGreen;   
     281  fQEPINDiodeVar   [ MCalibrationCam::kGREEN ] = gkDefaultQEGreenErr*gkDefaultQEGreenErr;
     282
     283  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kGREEN);
     284  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kGREEN);
     285  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kGREEN);
     286  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kGREEN);
     287
     288  fQEBlindPixel    [ MCalibrationCam::kBLUE ] = gkDefaultQEBlue; 
     289  fQEBlindPixelVar [ MCalibrationCam::kBLUE ] = gkDefaultQEBlueErr*gkDefaultQEBlueErr;
     290  fQEFFactor       [ MCalibrationCam::kBLUE ] = gkDefaultQEBlue;     
     291  fQEFFactorVar    [ MCalibrationCam::kBLUE ] = gkDefaultQEBlueErr*gkDefaultQEBlueErr;
     292  fQECombined      [ MCalibrationCam::kBLUE ] = gkDefaultQEBlue;   
     293  fQECombinedVar   [ MCalibrationCam::kBLUE ] = gkDefaultQEBlueErr*gkDefaultQEBlueErr;
     294  fQEPINDiode      [ MCalibrationCam::kBLUE ] = gkDefaultQEBlue;   
     295  fQEPINDiodeVar   [ MCalibrationCam::kBLUE ] = gkDefaultQEBlueErr*gkDefaultQEBlueErr;
     296
     297  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kBLUE);
     298  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kBLUE);
     299  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kBLUE);
     300  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kBLUE);
     301
     302  fQEBlindPixel    [ MCalibrationCam::kUV ] = gkDefaultQEUV; 
     303  fQEBlindPixelVar [ MCalibrationCam::kUV ] = gkDefaultQEUVErr*gkDefaultQEUVErr;
     304  fQEFFactor       [ MCalibrationCam::kUV ] = gkDefaultQEUV;     
     305  fQEFFactorVar    [ MCalibrationCam::kUV ] = gkDefaultQEUVErr*gkDefaultQEUVErr;
     306  fQECombined      [ MCalibrationCam::kUV ] = gkDefaultQEUV;   
     307  fQECombinedVar   [ MCalibrationCam::kUV ] = gkDefaultQEUVErr*gkDefaultQEUVErr;
     308  fQEPINDiode      [ MCalibrationCam::kUV ] = gkDefaultQEUV;   
     309  fQEPINDiodeVar   [ MCalibrationCam::kUV ] = gkDefaultQEUVErr*gkDefaultQEUVErr;
     310
     311  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kUV);
     312  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kUV);
     313  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kUV);
     314  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kUV);
     315
     316  fQEBlindPixel    [ MCalibrationCam::kCT1 ] = gkDefaultQECT1; 
     317  fQEBlindPixelVar [ MCalibrationCam::kCT1 ] = gkDefaultQECT1Err*gkDefaultQECT1Err;
     318  fQEFFactor       [ MCalibrationCam::kCT1 ] = gkDefaultQECT1;     
     319  fQEFFactorVar    [ MCalibrationCam::kCT1 ] = gkDefaultQECT1Err*gkDefaultQECT1Err;
     320  fQECombined      [ MCalibrationCam::kCT1 ] = gkDefaultQECT1;   
     321  fQECombinedVar   [ MCalibrationCam::kCT1 ] = gkDefaultQECT1Err*gkDefaultQECT1Err;
     322  fQEPINDiode      [ MCalibrationCam::kCT1 ] = gkDefaultQECT1;   
     323  fQEPINDiodeVar   [ MCalibrationCam::kCT1 ] = gkDefaultQECT1Err*gkDefaultQECT1Err;
     324
     325  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kCT1);
     326  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kCT1);
     327  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kCT1);
     328  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kCT1);
     329
     330  MCalibrationPix::Clear();
     331}
     332
     333
     334// -----------------------------------------------------------------
     335//
     336// Return the average Default QE (depending on zenith angle)
     337//
     338const Float_t MCalibrationQEPix::GetAverageQE( const Float_t zenith ) const
     339{
     340  return gkDefaultAverageQE ;
     341}
     342
     343// -----------------------------------------------------------------
     344//
     345// Return the relative variance of the average Default QE (depending on zenith angle)
     346//
     347const Float_t MCalibrationQEPix::GetAverageQERelVar( const Float_t zenith ) const
     348{
     349  return gkDefaultAverageQEErr * gkDefaultAverageQEErr / (gkDefaultAverageQE * gkDefaultAverageQE );
     350}
     351
     352// -----------------------------------------------------------------
     353//
     354// Return the relative variance of the average normalization (Blind Pixel Method)
     355//
     356const Float_t MCalibrationQEPix::GetAvNormBlindPixelRelVar( ) const
     357{
     358  return fAvNormBlindPixelVar / (fAvNormBlindPixel * fAvNormBlindPixel );
     359}
     360
     361// -----------------------------------------------------------------
     362//
     363// Return the relative variance of the average normalization (Combined Method)
     364//
     365const Float_t MCalibrationQEPix::GetAvNormCombinedRelVar( ) const
     366{
     367  return fAvNormCombinedVar / (fAvNormCombined * fAvNormCombined );
     368}
     369
     370// -----------------------------------------------------------------
     371//
     372// Return the relative variance of the average normalization (F-Factor Method)
     373//
     374const Float_t MCalibrationQEPix::GetAvNormFFactorRelVar( ) const
     375{
     376  return fAvNormFFactorVar / (fAvNormFFactor * fAvNormFFactor );
     377}
     378
     379// -----------------------------------------------------------------
     380//
     381// Return the relative variance of the average normalization (PIN Diode Method)
     382//
     383const Float_t MCalibrationQEPix::GetAvNormPINDiodeRelVar( ) const
     384{
     385  return fAvNormPINDiodeVar / (fAvNormPINDiode * fAvNormPINDiode );
     386}
     387
     388// ------------------------------------------------------------------------------
     389//
     390// Get the default Quantum efficiency for pulser colour "col"
     391//
     392Float_t MCalibrationQEPix::GetDefaultQE( const MCalibrationCam::PulserColor_t col )  const
     393{
     394  switch (col)
     395    {
     396    case MCalibrationCam::kGREEN:
     397      return gkDefaultQEGreen;
     398      break;
     399    case MCalibrationCam::kBLUE:
     400      return gkDefaultQEBlue;
     401      break;
     402    case MCalibrationCam::kUV:
     403      return gkDefaultQEUV;
     404      break;
     405    case MCalibrationCam::kCT1:
     406      return gkDefaultQECT1;
     407      break;
     408    default:
     409      return gkDefaultQECT1;
     410      break;
     411    }
     412  return -1.;
     413}
     414
     415// ------------------------------------------------------------------------------
     416//
     417// Get the relative variance of the default Quantum efficiency for pulser colour "col"
     418//
     419Float_t MCalibrationQEPix::GetDefaultQERelVar( const MCalibrationCam::PulserColor_t col )  const
     420{
     421  switch (col)
     422    {
     423    case MCalibrationCam::kGREEN:
     424      return gkDefaultQEGreenErr * gkDefaultQEGreenErr / (gkDefaultQEGreen * gkDefaultQEGreen );
     425      break;
     426    case MCalibrationCam::kBLUE:
     427      return gkDefaultQEBlueErr  * gkDefaultQEBlueErr  / (gkDefaultQEBlue  * gkDefaultQEBlue  );
     428      break;
     429    case MCalibrationCam::kUV:
     430      return gkDefaultQEUVErr    * gkDefaultQEUVErr    / (gkDefaultQEUV    * gkDefaultQEUV    );
     431      break;
     432    case MCalibrationCam::kCT1:
     433      return gkDefaultQECT1Err   * gkDefaultQECT1Err   / (gkDefaultQECT1   * gkDefaultQECT1   );
     434      break;
     435    default:
     436      return gkDefaultQECT1Err   * gkDefaultQECT1Err   / (gkDefaultQECT1   * gkDefaultQECT1   );
     437      break;
     438    }
     439  return -1.;
     440}
     441
     442// ------------------------------------------------------------------------------
     443//
     444// Get the calculated Quantum efficiency with the blind pixel method,
     445// obtained with pulser colour "col"
     446//
     447Float_t MCalibrationQEPix::GetQEBlindPixel( const MCalibrationCam::PulserColor_t col )  const
     448{
     449  return fQEBlindPixel[col];
     450}
     451
     452// ------------------------------------------------------------------------------
     453//
     454// Get the error on the calculated Quantum efficiency with the blind pixel method,
     455// obtained with pulser colour "col"
     456// Tests for variances smaller than 0. (e.g. if it has not yet been set)
     457// and returns -1. in that case
     458//
     459Float_t MCalibrationQEPix::GetQEBlindPixelErr( const MCalibrationCam::PulserColor_t col )  const
     460{
     461
     462  if (fQEBlindPixelVar[col] < 0.)
     463    return -1.;
     464
     465  return TMath::Sqrt(fQEBlindPixelVar[col]);
     466
     467}
     468
     469// ------------------------------------------------------------------------------
     470//
     471// Get the relative variance of the calculated Quantum efficiency with the blind pixel method,
     472// obtained with pulser colour "col"
     473// Tests for variances smaller than 0. (e.g. if it has not yet been set)
     474// and returns -1. in that case
     475// Tests for quantum efficiency equal to  0. and returns -1. in that case
     476//
     477Float_t MCalibrationQEPix::GetQEBlindPixelRelVar( const MCalibrationCam::PulserColor_t col )  const
     478{
     479
     480  if (fQEBlindPixelVar[col] < 0.)
     481    return -1.;
     482  if (fQEBlindPixel[col] < 0.)
     483      return -1.;
     484  return fQEBlindPixelVar[col] / ( fQEBlindPixel[col] * fQEBlindPixel[col] );
     485
     486}
     487
     488// ------------------------------------------------------------------------------
     489//
     490// Get the calculated Quantum efficiency with the combination of the three methods
     491// obtained with pulser colour "col"
     492//
     493Float_t MCalibrationQEPix::GetQECombined( const MCalibrationCam::PulserColor_t col )  const
     494{
     495  return fQECombined[col];
     496}
     497
     498
     499// ------------------------------------------------------------------------------
     500//
     501// Get the error on the calculated Quantum efficiency with the combination of the three methods
     502// obtained with pulser colour "col"
     503// Tests for variances smaller than 0. (e.g. if it has not yet been set)
     504// and returns -1. in that case
     505//
     506Float_t MCalibrationQEPix::GetQECombinedErr( const MCalibrationCam::PulserColor_t col )  const
     507{
     508
     509  if (fQECombinedVar[col] < 0.)
     510    return -1.;
     511
     512  return TMath::Sqrt(fQECombinedVar[col]);
     513
     514}
     515
     516
     517// ----------------------------------------------------------------------------------------
     518//
     519// Get the relative variance of the calculated Quantum efficiency with the combination of
     520// the three methods,
     521// obtained with pulser colour "col"
     522// Tests for variances smaller than 0. (e.g. if it has not yet been set)
     523// and returns -1. in that case
     524// Tests for quantum efficiency equal to  0. and returns -1. in that case
     525//
     526Float_t MCalibrationQEPix::GetQECombinedRelVar( const MCalibrationCam::PulserColor_t col )  const
     527{
     528
     529  if (fQECombinedVar[col] < 0.)
     530    return -1.;
     531  if (fQECombined[col] < 0.)
     532      return -1.;
     533  return fQECombinedVar[col] / ( fQECombined[col] * fQECombined[col] );
     534
     535}
     536
     537// ------------------------------------------------------------------------------
     538//
     539// Get the calculated Quantum efficiency with the F-Factor method
     540// obtained with pulser colour "col"
     541//
     542Float_t MCalibrationQEPix::GetQEFFactor( const MCalibrationCam::PulserColor_t col )  const
     543{
     544  return fQEFFactor[col];
     545}
     546
     547
     548// ------------------------------------------------------------------------------
     549//
     550// Get the error on the calculated Quantum efficiency with the F-Factor method,
     551// obtained with pulser colour "col"
     552// Tests for variances smaller than 0. (e.g. if it has not yet been set)
     553// and returns -1. in that case
     554//
     555Float_t MCalibrationQEPix::GetQEFFactorErr( const MCalibrationCam::PulserColor_t col )  const
     556{
     557
     558  if (fQEFFactorVar[col] < 0.)
     559    return -1.;
     560
     561  return TMath::Sqrt(fQEFFactorVar[col]);
     562
     563}
     564
     565
     566// ----------------------------------------------------------------------------------------
     567//
     568// Get the relative variance of the calculated Quantum efficiency with the F-Factor method,
     569// obtained with pulser colour "col"
     570// Tests for variances smaller than 0. (e.g. if it has not yet been set)
     571// and returns -1. in that case
     572// Tests for quantum efficiency equal to  0. and returns -1. in that case
     573//
     574Float_t MCalibrationQEPix::GetQEFFactorRelVar( const MCalibrationCam::PulserColor_t col )  const
     575{
     576
     577  if (fQEFFactorVar[col] < 0.)
     578    return -1.;
     579  if (fQEFFactor[col] < 0.)
     580      return -1.;
     581  return fQEFFactorVar[col] / ( fQEFFactor[col] * fQEFFactor[col] );
     582
     583}
     584
     585// ------------------------------------------------------------------------------
     586//
     587// Get the calculated Quantum efficiency with the PIN-Diode method
     588// obtained with pulser colour "col"
     589//
     590Float_t MCalibrationQEPix::GetQEPINDiode( const MCalibrationCam::PulserColor_t col )  const
     591{
     592  return fQEPINDiode[col];
     593}
     594
     595
     596// ------------------------------------------------------------------------------
     597//
     598// Get the error on the calculated Quantum efficiency with the PIN Diode method,
     599// obtained with pulser colour "col"
     600// Tests for variances smaller than 0. (e.g. if it has not yet been set)
     601// and returns -1. in that case
     602//
     603Float_t MCalibrationQEPix::GetQEPINDiodeErr( const MCalibrationCam::PulserColor_t col )  const
     604{
     605
     606  if (fQEPINDiodeVar[col] < 0.)
     607    return -1.;
     608
     609  return TMath::Sqrt(fQEPINDiodeVar[col]);
     610
     611}
     612
     613// ----------------------------------------------------------------------------------------
     614//
     615// Get the relative variance of the calculated Quantum efficiency with the PIN Diode method,
     616// obtained with pulser colour "col"
     617// Tests for variances smaller than 0. (e.g. if it has not yet been set)
     618// and returns -1. in that case
     619// Tests for quantum efficiency equal to  0. and returns -1. in that case
     620//
     621Float_t MCalibrationQEPix::GetQEPINDiodeRelVar( const MCalibrationCam::PulserColor_t col )  const
     622{
     623
     624  if (fQEPINDiodeVar[col] < 0.)
     625    return -1.;
     626  if (fQEPINDiode[col] < 0.)
     627      return -1.;
     628  return fQEPINDiodeVar[col] / ( fQEPINDiode[col] * fQEPINDiode[col] );
     629
     630}
     631
     632// ------------------------------------------------------------------------------
     633//
     634// Get the averaged Quantum efficiency folded over the cascade spectrum, obtained
     635// with the blind pixel method and averaged over the results from the different colours.
     636//
     637Float_t MCalibrationQEPix::GetQECascadesBlindPixel( const Float_t zenith  )  const
     638{
     639  return fAvNormBlindPixel * GetAverageQE ( zenith );
     640}
     641
     642// ------------------------------------------------------------------------------
     643//
     644// Get the variance of the averaged Quantum efficiency folded over the cascade spectrum,
     645// obtained with the blind pixel method and averaged over the results from the
     646// different colours.
     647//
     648Float_t MCalibrationQEPix::GetQECascadesBlindPixelVar( const Float_t zenith  )  const
     649{
     650  return ( GetAvNormBlindPixelRelVar()  + GetAverageQERelVar(zenith))
     651    * GetQECascadesBlindPixel(zenith) * GetQECascadesBlindPixel(zenith);
     652}
     653
     654// ------------------------------------------------------------------------------
     655//
     656// Get the averaged Quantum efficiency folded over the cascade spectrum, obtained
     657// with the combination of the three methods and averaged over the results
     658// from the different colours.
     659//
     660Float_t MCalibrationQEPix::GetQECascadesCombined( const Float_t zenith  )  const
     661{
     662  return fAvNormCombined * GetAverageQE ( zenith );
     663}
     664
     665// ------------------------------------------------------------------------------
     666//
     667// Get the variance of the averaged Quantum efficiency folded over the cascade spectrum,
     668// obtained with the combination of the three methods and averaged over the results from the
     669// different colours.
     670//
     671Float_t MCalibrationQEPix::GetQECascadesCombinedVar( const Float_t zenith  )  const
     672{
     673  return ( GetAvNormCombinedRelVar()  + GetAverageQERelVar(zenith))
     674    * GetQECascadesCombined(zenith) * GetQECascadesCombined(zenith);
     675}
     676
     677// ------------------------------------------------------------------------------
     678//
     679// Get the averaged Quantum efficiency folded over the cascade spectrum, obtained
     680// with the F-Factor method and averaged over the results from the different colours.
     681//
     682Float_t MCalibrationQEPix::GetQECascadesFFactor( const Float_t zenith  )  const
     683{
     684  return fAvNormFFactor * GetAverageQE ( zenith );
     685}
     686
     687// ------------------------------------------------------------------------------
     688//
     689// Get the variance of the averaged Quantum efficiency folded over the cascade spectrum,
     690// obtained with the F-Factor method and averaged over the results from the
     691// different colours.
     692//
     693Float_t MCalibrationQEPix::GetQECascadesFFactorVar( const Float_t zenith  )  const
     694{
     695  return ( GetAvNormFFactorRelVar()  + GetAverageQERelVar(zenith))
     696    * GetQECascadesFFactor(zenith) * GetQECascadesFFactor(zenith);
     697}
     698
     699// ------------------------------------------------------------------------------
     700//
     701// Get the averaged Quantum efficiency folded over the cascade spectrum, obtained
     702// with the PIN Diode method and averaged over the results from the different colours.
     703//
     704Float_t MCalibrationQEPix::GetQECascadesPINDiode( const Float_t zenith  )  const
     705{
     706  return fAvNormPINDiode * GetAverageQE ( zenith );
     707}
     708
     709// ------------------------------------------------------------------------------
     710//
     711// Get the variance of the averaged Quantum efficiency folded over the cascade spectrum,
     712// obtained with the PIN Diode method and averaged over the results from the
     713// different colours.
     714//
     715Float_t MCalibrationQEPix::GetQECascadesPINDiodeVar( const Float_t zenith  )  const
     716{
     717  return ( GetAvNormPINDiodeRelVar()  + GetAverageQERelVar(zenith))
     718    * GetQECascadesPINDiode(zenith) * GetQECascadesPINDiode(zenith);
     719}
     720
     721// ------------------------------------------------------------------------------
     722//
     723// Test if the average QE can be obtained from the blind pixel method
     724//
     725Bool_t MCalibrationQEPix::IsAverageQEBlindPixelAvailable() const
     726{
     727  return TESTBIT(fAvailableFlags,kAverageQEBlindPixelAvailable);
     728}
     729
     730// ------------------------------------------------------------------------------
     731//
     732// Test if the average QE can be obtained from the combination of the three methods
     733//
     734Bool_t MCalibrationQEPix::IsAverageQECombinedAvailable() const
     735{
     736  return TESTBIT(fAvailableFlags,kAverageQECombinedAvailable);
     737}
     738
     739// ------------------------------------------------------------------------------
     740//
     741// Test if the average QE can be obtained from the F-Factor method
     742//
     743Bool_t MCalibrationQEPix::IsAverageQEFFactorAvailable() const
     744{
     745  return TESTBIT(fAvailableFlags,kAverageQEFFactorAvailable);
     746}
     747
     748// ------------------------------------------------------------------------------
     749//
     750// Test if the average QE can be obtained from the PIN Diode method
     751//
     752Bool_t MCalibrationQEPix::IsAverageQEPINDiodeAvailable() const
     753{
     754  return TESTBIT(fAvailableFlags,kAverageQEPINDiodeAvailable);
     755}
     756
     757// ------------------------------------------------------------------------------
     758//
     759// Test if any of the three colours has already been calibrated with the blind pixel method
     760//
     761Bool_t MCalibrationQEPix::IsBlindPixelMethodValid () const
     762{
     763
     764  if (IsBlindPixelMethodValid (MCalibrationCam::kGREEN))
     765    return kTRUE;
     766  if (IsBlindPixelMethodValid (MCalibrationCam::kBLUE ))
     767    return kTRUE;
     768  if (IsBlindPixelMethodValid (MCalibrationCam::kUV   ))
     769    return kTRUE;
     770  if (IsBlindPixelMethodValid (MCalibrationCam::kCT1  ))
     771    return kTRUE;
     772
     773  return kFALSE;
     774}
     775
     776// ------------------------------------------------------------------------------
     777//
     778// Test if any of the three colours has already been calibrated with the combination
     779// of the three methods
     780//
     781Bool_t MCalibrationQEPix::IsCombinedMethodValid () const
     782{
     783  if (IsCombinedMethodValid (MCalibrationCam::kGREEN))
     784    return kTRUE;
     785  if (IsCombinedMethodValid (MCalibrationCam::kBLUE ))
     786    return kTRUE;
     787  if (IsCombinedMethodValid (MCalibrationCam::kUV   ))
     788    return kTRUE;
     789  if (IsCombinedMethodValid (MCalibrationCam::kCT1  ))
     790    return kTRUE;
     791
     792  return kFALSE;
     793}
     794
     795// ------------------------------------------------------------------------------
     796//
     797// Test if any of the three colours has already been calibrated with the F-Factor method
     798//
     799Bool_t MCalibrationQEPix::IsFFactorMethodValid () const
     800{
     801  if (IsFFactorMethodValid (MCalibrationCam::kGREEN))
     802    return kTRUE;
     803  if (IsFFactorMethodValid (MCalibrationCam::kBLUE ))
     804    return kTRUE;
     805  if (IsFFactorMethodValid (MCalibrationCam::kUV   ))
     806    return kTRUE;
     807  if (IsFFactorMethodValid (MCalibrationCam::kCT1  ))
     808    return kTRUE;
     809
     810  return kFALSE;
     811}
     812
     813
     814// ------------------------------------------------------------------------------
     815//
     816// Test if any of the three colours has already been calibrated with the PIN Diode method
     817//
     818Bool_t MCalibrationQEPix::IsPINDiodeMethodValid () const
     819{
     820  if (IsPINDiodeMethodValid (MCalibrationCam::kGREEN))
     821    return kTRUE;
     822  if (IsPINDiodeMethodValid (MCalibrationCam::kBLUE ))
     823    return kTRUE;
     824  if (IsPINDiodeMethodValid (MCalibrationCam::kUV   ))
     825    return kTRUE;
     826  if (IsPINDiodeMethodValid (MCalibrationCam::kCT1  ))
     827    return kTRUE;
     828
     829  return kFALSE;
     830}
     831
     832// ------------------------------------------------------------------------------
     833//
     834// Test if the colour "col" has already been calibrated with the Blind Pixel method
     835//
     836Bool_t MCalibrationQEPix::IsBlindPixelMethodValid (MCalibrationCam::PulserColor_t col)  const
     837{
     838  return TESTBIT(fValidFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);
     839}
     840
     841// ------------------------------------------------------------------------------
     842//
     843// Test if the colour "col" has already been calibrated with the combination of
     844// the three methods
     845//
     846Bool_t MCalibrationQEPix::IsCombinedMethodValid (MCalibrationCam::PulserColor_t col)  const
     847{
     848  return TESTBIT(fValidFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);
     849}
     850
     851// ------------------------------------------------------------------------------
     852//
     853// Test if the colour "col" has already been calibrated with the F-Factor method
     854//
     855Bool_t MCalibrationQEPix::IsFFactorMethodValid (MCalibrationCam::PulserColor_t col)  const
     856{
     857  return TESTBIT(fValidFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);
     858}
     859
     860// ------------------------------------------------------------------------------
     861//
     862// Test if the colour "col" has already been calibrated with the PIN Diode method
     863//
     864Bool_t MCalibrationQEPix::IsPINDiodeMethodValid (MCalibrationCam::PulserColor_t col)  const
     865{
     866  return TESTBIT(fValidFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);
     867}
     868
     869// ------------------------------------------------------------------------------
     870//
     871// Set the bit Average QE Blind Pixel method available from outside (only for MC!)
     872//
     873void MCalibrationQEPix::SetAverageQEBlindPixelAvailable ( Bool_t b )
     874{
     875  if (b)
     876    SETBIT(fAvailableFlags,kAverageQEBlindPixelAvailable);
     877  else
     878    CLRBIT(fAvailableFlags,kAverageQEBlindPixelAvailable);   
     879}
     880
     881// ------------------------------------------------------------------------------
     882//
     883// Set the bit Average QE combination of three methods available from outside (only for MC!)
     884//
     885void MCalibrationQEPix::SetAverageQECombinedAvailable ( Bool_t b )
     886{
     887  if (b)
     888    SETBIT(fAvailableFlags,kAverageQECombinedAvailable);
     889  else
     890    CLRBIT(fAvailableFlags,kAverageQECombinedAvailable);   
     891}
     892
     893// ------------------------------------------------------------------------------
     894//
     895// Set the bit Average QE F-Factor method available from outside (only for MC!)
     896//
     897void MCalibrationQEPix::SetAverageQEFFactorAvailable ( Bool_t b )
     898{
     899  if (b)
     900    SETBIT(fAvailableFlags,kAverageQEFFactorAvailable);
     901  else
     902    CLRBIT(fAvailableFlags,kAverageQEFFactorAvailable);   
     903}
     904
     905// ------------------------------------------------------------------------------
     906//
     907// Set the bit Average QE PIN Diode method available from outside (only for MC!)
     908//
     909void MCalibrationQEPix::SetAverageQEPINDiodeAvailable ( Bool_t b )
     910{
     911  if (b)
     912    SETBIT(fAvailableFlags,kAverageQEPINDiodeAvailable);
     913  else
     914    CLRBIT(fAvailableFlags,kAverageQEPINDiodeAvailable);   
     915}
     916
     917// ------------------------------------------------------------------------------
     918//
     919// Set the bit QE Blind Pixel method available from colour "col"
     920//
     921void MCalibrationQEPix::SetBlindPixelMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col )
     922{
     923  if (b)
     924    SETBIT(fValidFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);
     925  else
     926    CLRBIT(fValidFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);   
     927}
     928
     929// ------------------------------------------------------------------------------
     930//
     931// Set the bit QE Combination of three methods available from colour "col"
     932//
     933void MCalibrationQEPix::SetCombinedMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col )
     934{
     935  if (b)
     936    SETBIT(fValidFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);
     937  else
     938    CLRBIT(fValidFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);   
     939}
     940
     941// ------------------------------------------------------------------------------
     942//
     943// Set the bit QE F-Factor method available from colour "col"
     944//
     945void MCalibrationQEPix::SetFFactorMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col )
     946{
     947  if (b)
     948    SETBIT(fValidFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);
     949  else
     950    CLRBIT(fValidFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);   
     951}
     952
     953// ------------------------------------------------------------------------------
     954//
     955// Set the bit QE PIN Diode method available from colour "col"
     956//
     957void MCalibrationQEPix::SetPINDiodeMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col )
     958{
     959  if (b)
     960    SETBIT(fValidFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);
     961  else
     962    CLRBIT(fValidFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);   
     963}
     964
     965// ------------------------------------------------------------------------------
     966//
     967// Update the Blind Pixel Method: Calculate new average QE's
     968//
     969Bool_t  MCalibrationQEPix::UpdateBlindPixelMethod()
     970{
     971
     972  Float_t weightedav = 0.;
     973  Float_t sumweights = 0.;
     974
     975  AddAverageBlindPixelQEs(MCalibrationCam::kGREEN, weightedav, sumweights);
     976  AddAverageBlindPixelQEs(MCalibrationCam::kBLUE , weightedav, sumweights);
     977  AddAverageBlindPixelQEs(MCalibrationCam::kUV   , weightedav, sumweights);
     978  AddAverageBlindPixelQEs(MCalibrationCam::kCT1  , weightedav, sumweights);
     979
     980  if (weightedav == 0. || sumweights == 0.)
     981    return kFALSE;
     982
     983  weightedav /= sumweights;
     984
     985  fAvNormBlindPixel     = gkDefaultAverageQE   *  weightedav;
     986  fAvNormBlindPixelVar  = GetAverageQERelVar() + (sumweights / weightedav / weightedav ); 
     987  fAvNormBlindPixelVar *= fAvNormBlindPixel * fAvNormBlindPixel;
     988
     989  return kTRUE;
     990}
     991
     992// ------------------------------------------------------------------------------
     993//
     994// Update the Combination of the three Methods: Calculate new average QE's
     995//
     996Bool_t  MCalibrationQEPix::UpdateCombinedMethod()
     997{
    111998 
    112   fQEGreenErr   =  -1.;
    113   fQEBlueErr    =  -1.;
    114   fQEUVErr      =  -1.;
    115   fQECT1Err     =  -1.;
    116  
    117   MCalibrationPix::Clear();
    118 
    119 }
    120 
    121 
    122 void MCalibrationQEPix::SetQE( const Float_t qe, const PulserColor_t col )
    123 {
    124 
    125   switch (col)
    126   {
    127       case kGREEN:
    128           fQEGreen = qe;
    129           break;
    130       case kBLUE:
    131           fQEBlue = qe;
    132           break;
    133       case kUV:
    134           fQEUV = qe;
    135           break;
    136       case kCT1:
    137           fQECT1 = qe;
    138           break;
    139       default:
    140           fQECT1 = qe;
    141           break;
    142   }
    143 }
    144 
    145 void MCalibrationQEPix::SetQEErr( const Float_t qeerr, const PulserColor_t col )
    146 {
    147 
    148   switch (col)
    149   {
    150       case kGREEN:
    151           fQEGreenErr = qeerr;
    152           break;
    153       case kBLUE:
    154           fQEBlueErr  = qeerr;
    155           break;
    156       case kUV:
    157           fQEUVErr    = qeerr;
    158           break;
    159       case kCT1:
    160           fQECT1Err   = qeerr;
    161           break;
    162       default:
    163           fQECT1Err  = qeerr;
    164           break;
    165   }
    166 }
    167 
    168 
    169 Float_t MCalibrationQEPix::GetQE(const PulserColor_t col )  const
    170 {
    171 
    172   switch (col)
    173   {
    174       case kGREEN:
    175           return fQEGreen;
    176           break;
    177       case kBLUE:
    178           return fQEBlue;
    179           break;
    180       case kUV:
    181           return fQEUV;
    182           break;
    183       case kCT1:
    184           return fQECT1;
    185           break;
    186       default:
    187           return fQECT1;
    188           break;
    189   }
    190 }
    191 
    192 Float_t MCalibrationQEPix::GetQEErr(const PulserColor_t col )  const
    193 {
    194 
    195   switch (col)
    196   {
    197       case kGREEN:
    198           return fQEGreenErr;
    199           break;
    200       case kBLUE:
    201           return fQEBlueErr;
    202           break;
    203       case kUV:
    204           return fQEUVErr;
    205           break;
    206       case kCT1:
    207           return fQECT1Err;
    208           break;
    209       default:
    210           return fQECT1Err;
    211           break;
    212   }
    213 }
    214 
    215 // --------------------------------------------------------------
    216 //
    217 // The check return kTRUE if:
    218 //
    219 // Not yet implemented!
    220 //
    221 Bool_t MCalibrationQEPix::CheckQEValidity()
    222 {
    223  
    224   SetValid();
     999  Float_t weightedav = 0.;
     1000  Float_t sumweights = 0.;
     1001
     1002  AddAverageCombinedQEs(MCalibrationCam::kGREEN, weightedav, sumweights);
     1003  AddAverageCombinedQEs(MCalibrationCam::kBLUE , weightedav, sumweights);
     1004  AddAverageCombinedQEs(MCalibrationCam::kUV   , weightedav, sumweights);
     1005  AddAverageCombinedQEs(MCalibrationCam::kCT1  , weightedav, sumweights);
     1006
     1007  if (weightedav == 0. || sumweights == 0.)
     1008    return kFALSE;
     1009
     1010  weightedav /= sumweights;
     1011
     1012  fAvNormCombined     = gkDefaultAverageQE   *  weightedav;
     1013  fAvNormCombinedVar  = GetAverageQERelVar() + (sumweights / weightedav / weightedav ); 
     1014  fAvNormCombinedVar *= fAvNormCombined * fAvNormCombined;
     1015
    2251016  return kTRUE;
    226 }
     1017 
     1018}
     1019
     1020// ------------------------------------------------------------------------------
     1021//
     1022// Update the F-Factor Method: Calculate new average QE's
     1023//
     1024Bool_t  MCalibrationQEPix::UpdateFFactorMethod()
     1025{
     1026
     1027  Float_t weightedav = 0.;
     1028  Float_t sumweights = 0.;
     1029
     1030  AddAverageFFactorQEs(MCalibrationCam::kGREEN, weightedav, sumweights);
     1031  AddAverageFFactorQEs(MCalibrationCam::kBLUE , weightedav, sumweights);
     1032  AddAverageFFactorQEs(MCalibrationCam::kUV   , weightedav, sumweights);
     1033  AddAverageFFactorQEs(MCalibrationCam::kCT1  , weightedav, sumweights);
     1034
     1035  if (weightedav == 0. || sumweights == 0.)
     1036    return kFALSE;
     1037
     1038  weightedav /= sumweights;
     1039
     1040  fAvNormFFactor     = gkDefaultAverageQE   *  weightedav;
     1041  fAvNormFFactorVar  = GetAverageQERelVar() + (sumweights / weightedav / weightedav ); 
     1042  fAvNormFFactorVar *= fAvNormFFactor * fAvNormFFactor;
     1043
     1044  return kTRUE;
     1045 
     1046 
     1047}
     1048
     1049// ------------------------------------------------------------------------------
     1050//
     1051// Update the PIN Diode Method: Calculate new average QE's
     1052//
     1053Bool_t  MCalibrationQEPix::UpdatePINDiodeMethod()
     1054{
     1055 
     1056  Float_t weightedav = 0.;
     1057  Float_t sumweights = 0.;
     1058
     1059  AddAveragePINDiodeQEs(MCalibrationCam::kGREEN, weightedav, sumweights);
     1060  AddAveragePINDiodeQEs(MCalibrationCam::kBLUE , weightedav, sumweights);
     1061  AddAveragePINDiodeQEs(MCalibrationCam::kUV   , weightedav, sumweights);
     1062  AddAveragePINDiodeQEs(MCalibrationCam::kCT1  , weightedav, sumweights);
     1063
     1064  if (weightedav == 0. || sumweights == 0.)
     1065    return kFALSE;
     1066
     1067  weightedav /= sumweights;
     1068
     1069  fAvNormPINDiode     = gkDefaultAverageQE   *  weightedav;
     1070  fAvNormPINDiodeVar  = GetAverageQERelVar() + (sumweights / weightedav / weightedav ); 
     1071  fAvNormPINDiodeVar *= fAvNormPINDiode * fAvNormPINDiode;
     1072
     1073  return kTRUE;
     1074
     1075 
     1076}
     1077
  • trunk/MagicSoft/Mars/mcalib/MCalibrationQEPix.h

    r3655 r3678  
    66#endif
    77
     8#ifndef ROOT_TArrayF
     9#include "TArrayF.h"
     10#endif
     11
     12#ifndef ROOT_TArrayC
     13#include "TArrayC.h"
     14#endif
     15
     16#ifndef MARS_MCalibrationCam
     17#include "MCalibrationCam.h"
     18#endif
     19
    820class MCalibrationQEPix : public MCalibrationPix
    921{
    1022private:
    1123
    12   Float_t fQEGreen;          // Calibrated quantum efficiency at 520 nm
    13   Float_t fQEBlue;           // Calibrated quantum efficiency at 460 nm
    14   Float_t fQEUV;             // Calibrated quantum efficiency at 370 nm
    15   Float_t fQECT1;            // Calibrated quantum efficiency at 370 nm
    16   Float_t fQEGreenErr;       // Uncertainty calibrated QE at 520 nm
    17   Float_t fQEBlueErr;        // Uncertainty calibrated QE at 460 nm
    18   Float_t fQEUVErr;          // Uncertainty calibrated QE at 370 nm
    19   Float_t fQECT1Err;         // Uncertainty calibrated QE at 370 nm
     24  static const Float_t gkDefaultQEGreen;      //! Default QE at 520 nm (now set to: 0.192)
     25  static const Float_t gkDefaultQEBlue;       //! Default QE at 460 nm (now set to: 0.27 )
     26  static const Float_t gkDefaultQEUV;         //! Default QE at 370 nm (now set to: 0.285)
     27  static const Float_t gkDefaultQECT1;        //! Default QE at 370 nm (now set to: 0.285)
     28  static const Float_t gkDefaultQEGreenErr;   //! Uncertainty Def. QE  at 520 nm (now set to: 0.05)
     29  static const Float_t gkDefaultQEBlueErr;    //! Uncertainty Def. QE  at 460 nm (now set to: 0.07)
     30  static const Float_t gkDefaultQEUVErr;      //! Uncertainty Def. QE  at 370 nm (now set to: 0.07)
     31  static const Float_t gkDefaultQECT1Err;     //! Uncertainty Def. QE  at 370 nm (now set to: 0.07)
     32  static const Float_t gkDefaultAverageQE;    //! Default QE folded into Cascade spectrum (now set to: 0.18)
     33  static const Float_t gkDefaultAverageQEErr; //! Uncertainty Def. QE Cascade spectrum    (now set to: 0.02)
     34 
     35  TArrayF fQEBlindPixel;                     // Calibrated QEs    (Blind Pixel Method)
     36  TArrayF fQEBlindPixelVar;                  // Variance cal. QEs (Blind Pixel Method)
     37  TArrayF fQECombined;                       // Calibrated QEs    (Combined Method)
     38  TArrayF fQECombinedVar;                    // Variance cal. QEs (Combined Method)
     39  TArrayF fQEFFactor;                        // Calibrated QEs    (F-Factor Method)
     40  TArrayF fQEFFactorVar;                     // Variance cal. QEs (F-Factor Method)
     41  TArrayF fQEPINDiode;                       // Calibrated QEs    (PIN Diode Method)
     42  TArrayF fQEPINDiodeVar;                    // Variance cal. QEs (PIN Diode Method)
     43                                             
     44  Float_t fAvNormBlindPixel;                 // Normalization w.r.t. default QE (Blind Pixel Method)
     45  Float_t fAvNormBlindPixelVar;              // Variance norm. w.r.t. def. QE (Blind Pixel Method)
     46  Float_t fAvNormCombined;                   // Normalization w.r.t. default QE (Combined Method)
     47  Float_t fAvNormCombinedVar;                // Variance norm. w.r.t. def. QE (Combined Method)
     48  Float_t fAvNormFFactor;                    // Normalization w.r.t. default QE (F-Factor Method)
     49  Float_t fAvNormFFactorVar;                 // Variance norm. w.r.t. def. QE (F-Factor Method)
     50  Float_t fAvNormPINDiode;                   // Normalization w.r.t. default QE (PIN Diode Method)
     51  Float_t fAvNormPINDiodeVar;                // Variance norm. w.r.t. def. QE (PIN Diode Method)
     52                                             
     53  TArrayC fValidFlags;                       // Bit-field for valid flags, one array entry for each color
     54  Byte_t  fAvailableFlags;                   // Bit-field for available flags
     55 
     56  enum { kBlindPixelMethodValid, kFFactorMethodValid,
     57         kPINDiodeMethodValid, kCombinedMethodValid,
     58         kAverageQEBlindPixelAvailable, kAverageQEFFactorAvailable,
     59         kAverageQEPINDiodeAvailable, kAverageQECombinedAvailable  };
     60
     61  void  AddAverageBlindPixelQEs( const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw );
     62  void  AddAverageCombinedQEs  ( const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw );
     63  void  AddAverageFFactorQEs  ( const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw );
     64  void  AddAveragePINDiodeQEs  ( const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw );
     65
     66  const Float_t GetAverageQE     ( const Float_t zenith=0. ) const; 
     67  const Float_t GetAverageQERelVar( const Float_t zenith=0. ) const;
     68 
     69  const Float_t GetAvNormBlindPixelRelVar()  const;
     70  const Float_t GetAvNormCombinedRelVar()  const;
     71  const Float_t GetAvNormFFactorRelVar()  const;
     72  const Float_t GetAvNormPINDiodeRelVar()  const; 
    2073 
    2174public:
     
    2477  ~MCalibrationQEPix() {}
    2578 
    26   void Clear(Option_t *o="");
     79  void    Clear(Option_t *o="");
     80 
     81  // Getters
     82  Float_t GetDefaultQE                   ( const MCalibrationCam::PulserColor_t col ) const;
     83  Float_t GetDefaultQERelVar             ( const MCalibrationCam::PulserColor_t col ) const; 
     84  Float_t GetQEBlindPixel                ( const MCalibrationCam::PulserColor_t col ) const; 
     85  Float_t GetQEBlindPixelErr             ( const MCalibrationCam::PulserColor_t col ) const;
     86  Float_t GetQEBlindPixelRelVar          ( const MCalibrationCam::PulserColor_t col ) const; 
     87  Float_t GetQECascadesBlindPixel        ( const Float_t zenith=0.)                   const;
     88  Float_t GetQECascadesBlindPixelVar     ( const Float_t zenith=0.)                   const;
     89  Float_t GetQECascadesCombined          ( const Float_t zenith=0.)                   const; 
     90  Float_t GetQECascadesCombinedVar       ( const Float_t zenith=0.)                   const; 
     91  Float_t GetQECascadesFFactor           ( const Float_t zenith=0.)                   const; 
     92  Float_t GetQECascadesFFactorVar        ( const Float_t zenith=0 )                   const; 
     93  Float_t GetQECascadesPINDiode          ( const Float_t zenith=0.)                   const;
     94  Float_t GetQECascadesPINDiodeVar       ( const Float_t zenith=0.)                   const;
     95  Float_t GetQECombined                  ( const MCalibrationCam::PulserColor_t col ) const;       
     96  Float_t GetQECombinedErr               ( const MCalibrationCam::PulserColor_t col ) const;
     97  Float_t GetQECombinedRelVar            ( const MCalibrationCam::PulserColor_t col ) const; 
     98  Float_t GetQEFFactor                   ( const MCalibrationCam::PulserColor_t col ) const; 
     99  Float_t GetQEFFactorErr                ( const MCalibrationCam::PulserColor_t col ) const;
     100  Float_t GetQEFFactorRelVar             ( const MCalibrationCam::PulserColor_t col ) const; 
     101  Float_t GetQEPINDiode                  ( const MCalibrationCam::PulserColor_t col ) const;       
     102  Float_t GetQEPINDiodeErr               ( const MCalibrationCam::PulserColor_t col ) const;
     103  Float_t GetQEPINDiodeRelVar            ( const MCalibrationCam::PulserColor_t col ) const; 
    27104
    28   // Setters
    29   void SetQE   ( const Float_t qe   , const PulserColor_t col );
    30   void SetQEErr( const Float_t qeerr, const PulserColor_t col );
     105  Bool_t  IsAverageQEBlindPixelAvailable ()                                           const;
     106  Bool_t  IsAverageQECombinedAvailable   ()                                           const; 
     107  Bool_t  IsAverageQEFFactorAvailable    ()                                           const; 
     108  Bool_t  IsAverageQEPINDiodeAvailable   ()                                           const; 
     109  Bool_t  IsBlindPixelMethodValid        ()                                           const;
     110  Bool_t  IsBlindPixelMethodValid        ( const MCalibrationCam::PulserColor_t col ) const;
     111  Bool_t  IsCombinedMethodValid          ()                                           const; 
     112  Bool_t  IsCombinedMethodValid          ( const MCalibrationCam::PulserColor_t col ) const; 
     113  Bool_t  IsFFactorMethodValid           ()                                           const; 
     114  Bool_t  IsFFactorMethodValid           ( const MCalibrationCam::PulserColor_t col ) const; 
     115  Bool_t  IsPINDiodeMethodValid          ()                                           const; 
     116  Bool_t  IsPINDiodeMethodValid          ( const MCalibrationCam::PulserColor_t col ) const; 
    31117
    32   // Getters
    33   Float_t GetQE   ( const PulserColor_t col )  const;
    34   Float_t GetQEErr( const PulserColor_t col )  const;
     118  // Setters
     119  void SetAverageQEBlindPixelAvailable   ( const Bool_t b );
     120  void SetAverageQECombinedAvailable     ( const Bool_t b );
     121  void SetAverageQEFFactorAvailable      ( const Bool_t b );
     122  void SetAverageQEPINDiodeAvailable     ( const Bool_t b );
     123  void SetBlindPixelMethodValid          ( const Bool_t b, const MCalibrationCam::PulserColor_t col);
     124  void SetCombinedMethodValid            ( const Bool_t b, const MCalibrationCam::PulserColor_t col);
     125  void SetFFactorMethodValid             ( const Bool_t b, const MCalibrationCam::PulserColor_t col); 
     126  void SetPINDiodeMethodValid            ( const Bool_t b, const MCalibrationCam::PulserColor_t col); 
     127  void SetQEBlindPixel    ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEBlindPixel   [col] = f; }
     128  void SetQEBlindPixelVar ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEBlindPixelVar[col] = f; }
     129  void SetQECombined      ( Float_t f, MCalibrationCam::PulserColor_t col) { fQECombined     [col] = f; }
     130  void SetQECombinedVar   ( Float_t f, MCalibrationCam::PulserColor_t col) { fQECombinedVar  [col] = f; }
     131  void SetQEFFactor       ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEFFactor      [col] = f; }
     132  void SetQEFFactorVar    ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEFFactorVar   [col] = f; }
     133  void SetQEPINDiode      ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEPINDiode     [col] = f; }
     134  void SetQEPINDiodeVar   ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEPINDiodeVar  [col] = f; }
    35135
    36   // Miscellaneous
    37   Bool_t CheckQEValidity();
     136  // Updates
     137  Bool_t  UpdateBlindPixelMethod();
     138  Bool_t  UpdateCombinedMethod  ();
     139  Bool_t  UpdateFFactorMethod   ();
     140  Bool_t  UpdatePINDiodeMethod  ();
    38141
    39   ClassDef(MCalibrationQEPix, 1)        // Container Quantum Efficieny Calibration Results Pixel
     142  ClassDef(MCalibrationQEPix, 1)     // Container Quantum Efficieny Calibration Results Pixel
    40143};
    41144
Note: See TracChangeset for help on using the changeset viewer.