Ignore:
Timestamp:
07/14/05 16:03:32 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mcalib
Files:
9 edited

Legend:

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

    r7053 r7189  
    3232//   MCalibrationIntensityChargeCam
    3333//   MCalibrationIntensityRelTimeCam
     34//   MCalibrationIntensityConstCam
    3435//   MBadPixelsIntensityCam
    3536//
     
    3738//   MCalibrationIntensityChargeCam
    3839//   MCalibrationIntensityRelTimeCam
    39 //   MBadPixelsIntensityCam
     40//   MBadPixelsIntensityCam
     41//
     42// Class version 2:
     43//  +  UInt_t  fNumPhesDump;         // Number of cams after which the number of phes gets averaged
     44//  +  Float_t fMeanPhes;
     45//  +  Float_t fMeanPhesRelVar;
     46//  +  Bool_t  fUpdateNumPhes;       // Update the number of photo-electrons only after fNumPhesDump number of Cams
     47//  +  TArrayF fPhes;
     48//  +  TArrayF fPhesVar;
    4049//
    4150//////////////////////////////////////////////////////////////////////////////
     
    5564#include "MCalibrationIntensityQECam.h"
    5665#include "MCalibrationIntensityRelTimeCam.h"
     66#include "MCalibrationIntensityConstCam.h"
    5767
    5868#include "MBadPixelsIntensityCam.h"
    5969
     70#include "MCalibrationChargePix.h"
    6071#include "MCalibrationChargeCalc.h"
    6172#include "MCalibrationRelTimeCalc.h"
     
    6778
    6879const UInt_t MCalibCalcFromPast::fgNumEventsDump = 500;
     80const UInt_t MCalibCalcFromPast::fgNumPhesDump   = 10;
    6981
    7082// --------------------------------------------------------------------------
     
    7486// Sets:
    7587// - fNumEventsDump to fgNumEventsDump
     88// - fNumPhesDump to fgNumPhesDump
    7689//
    7790MCalibCalcFromPast::MCalibCalcFromPast(const char *name, const char *title)
    7891    : fGeom(NULL), fParList(NULL), fRunHeader(NULL),
    79     fIntensCharge(NULL), fIntensBlind(NULL), fIntensQE(NULL),
    80     fIntensRelTime(NULL), fIntensBad(NULL), fChargeCalc(NULL),
    81     fRelTimeCalc(NULL), fCalibrate(NULL), fNumEvents(0), fNumCam(0),
    82     fUpdateWithFFactorMethod(kFALSE)
     92      fIntensCharge(NULL), fIntensBlind(NULL), fIntensRelTime(NULL), fIntensConst(NULL),
     93      fIntensBad(NULL),
     94      fChargeCalc(NULL), fRelTimeCalc(NULL), fCalibrate(NULL),
     95      fNumCam(0), fNumEvents(0), fUpdateWithFFactorMethod(kTRUE), fUpdateNumPhes(kTRUE)
    8396{
    8497
     
    87100
    88101  SetNumEventsDump();
     102  SetNumPhesDump  ();
    89103}
    90104
     
    150164    fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
    151165    fIntensQE     = (MCalibrationIntensityQECam*)    pList->FindCreateObj("MCalibrationIntensityQECam");
     166    fIntensConst  = (MCalibrationIntensityConstCam*) pList->FindCreateObj("MCalibrationIntensityConstCam");
     167
     168    MCalibrationChargeCam *chargeinit = (MCalibrationChargeCam*)pList->FindObject("MCalibrationChargeCam");
     169    MCalibrationQECam     *qeinit     = (MCalibrationQECam*)    pList->FindObject("MCalibrationQECam");
     170
     171    if (chargeinit)
     172      fIntensCharge->SetCam(chargeinit,0);
     173    else
     174      *fLog << "Could not find initial MCalibrationChargeCam, cannot initialize intensity cam" << endl;
     175
     176    if (qeinit)
     177      fIntensQE->SetCam(qeinit,0);
     178    else
     179      *fLog << "Could not find initial MCalibrationQECam, cannot initialize intensity cam" << endl;
     180
     181    fIntensConst->GetCam()->Init(*fGeom);
    152182
    153183    if (!fChargeCalc)
     
    212242  fNumCam    = 0;
    213243  fNumEvents = 0;
     244  fNumPhes   = 0;
     245
     246  fChargeCalc->SetUseExternalNumPhes(kFALSE);
     247
     248  if (fUpdateNumPhes)
     249    {
     250      fPhes.Set(fNumPhesDump);
     251      fPhesVar.Set(fNumPhesDump);
     252    }
    214253
    215254  return kTRUE;
     
    231270 
    232271  fNumEvents = 0;
     272  ReInitialize();
     273
    233274  //
    234275  // Finalize Possible calibration histogram classes...
     
    246287  *fLog << inf << "Finalize calibration calculations..." << endl;
    247288  if (fChargeCalc)
    248     fChargeCalc->Finalize();
     289    {
     290      fChargeCalc->Finalize();
     291      if (fUpdateNumPhes)
     292        {
     293          MCalibrationChargePix &avpix =(MCalibrationChargePix&)fIntensCharge->GetCam()->GetAverageArea(0);
     294          fPhes   [fNumPhes] = avpix.GetPheFFactorMethod();
     295          fPhesVar[fNumPhes] = avpix.GetPheFFactorMethodVar();
     296
     297          fNumPhes++;
     298
     299          if (fNumPhes == fNumPhesDump)
     300            {
     301              fNumPhes = 0;
     302              if (!UpdateMeanPhes())
     303                {
     304                  *fLog << warn << "Could not update mean number of photo-electrons. "
     305                        << "Skip it until next update" << endl;
     306                  fChargeCalc->SetUseExternalNumPhes(kFALSE);
     307                }
     308              else
     309                {
     310                  *fLog << inf << "New averaged number photo-electrons: " << fMeanPhes << endl;
     311                  fChargeCalc->SetExternalNumPhes      ( fMeanPhes );
     312                  fChargeCalc->SetExternalNumPhesRelVar( fMeanPhesRelVar );
     313                  fChargeCalc->SetUseExternalNumPhes();
     314                }
     315            }
     316        }
     317    }
     318
    249319  if (fRelTimeCalc)
    250320    fRelTimeCalc->Finalize();
     321
    251322  if (fCalibrate)
    252       fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL :
    253                                           (MCalibrationChargeCam*)fIntensCharge->GetCam());
    254 
    255   ReInitialize();
     323    fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL
     324                                        : (MCalibrationChargeCam*)fIntensCharge->GetCam() );
     325
    256326  return kTRUE;
    257327}
     
    289359  fNumCam++;
    290360
    291   *fLog << inf << "MCalibCalcFromPast::ReInitialize #" << fNumCam << " ";
     361  *fLog << inf << "MCalibCalcFromPast::ReInitialize #" << fNumCam << ": ";
    292362
    293363  const Int_t runnumber = fRunHeader->GetRunNumber();
     
    331401}
    332402
     403
     404Bool_t MCalibCalcFromPast::UpdateMeanPhes()
     405{
     406    Float_t sumw = 0.;
     407    Float_t sum  = 0.;
     408
     409    for (Int_t i=0; i<fPhes.GetSize(); i++)
     410    {
     411        const Float_t weight = 1./fPhesVar[i];
     412        sum  += fPhes[i]*weight;
     413        sumw += weight;
     414    }
     415
     416    if (sumw < 0.000001)
     417        return kFALSE;
     418
     419    if (sum < 0.000001)
     420        return kFALSE;
     421
     422    fMeanPhes       = sum/sumw;
     423    fMeanPhesRelVar = sumw/sum/sum;
     424
     425    return kTRUE;
     426}
     427
    333428// --------------------------------------------------------------------------
    334429//
     
    336431//   MCalibCalcFromPast.UpdateWithFFactorMethod: Off, On
    337432//   MCalibCalcFromPast.NumEventsDump: 500
     433//   MCalibCalcFromPast.UpdateNumPhes: yes/no
     434//   MCalibCalcFromPast.NumPhesDump: 10
    338435//
    339436Int_t MCalibCalcFromPast::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     
    352449    }
    353450
     451    if (IsEnvDefined(env, prefix, "UpdateNumPhes", print))
     452    {
     453        TString s = GetEnvValue(env, prefix, "UpdateNumPhes", "");
     454        s.ToLower();
     455        if (s.BeginsWith("no"))
     456            SetUpdateNumPhes(kFALSE);
     457        if (s.BeginsWith("yes"))
     458            SetUpdateNumPhes(kTRUE);
     459        rc = kTRUE;
     460    }
     461
     462    if (IsEnvDefined(env, prefix, "NumPhesDump", print))
     463    {
     464        SetNumPhesDump(GetEnvValue(env, prefix, "NumPhesDump", (Int_t)fNumPhesDump));
     465        rc = kTRUE;
     466    }
     467
     468
     469
    354470    return rc;
    355471}
  • trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.h

    r7005 r7189  
    44#ifndef MARS_MTask
    55#include "MTask.h"
     6#endif
     7
     8#ifndef ROOT_TArrayF
     9#include <TArrayF.h>
    610#endif
    711
     
    1721class MCalibrationIntensityQECam;
    1822class MCalibrationIntensityRelTimeCam;
     23class MCalibrationIntensityConstCam;
    1924class MBadPixelsIntensityCam;
    2025
     
    2227{
    2328private:
    24 
    2529  static const UInt_t fgNumEventsDump;               //! Default for fNumEventsDump
     30  static const UInt_t fgNumPhesDump;                 //! Default for fNumPhesDump
    2631 
    2732  MGeomCam                        *fGeom;            //! Camera Geometry
     
    3237  MCalibrationIntensityQECam      *fIntensQE;        //! Intensity QE     Cam (to be created)
    3338  MCalibrationIntensityRelTimeCam *fIntensRelTime;   //! Intensity Rel. Time Cam (to be created)
     39  MCalibrationIntensityConstCam   *fIntensConst;     //! Intensity Rel. Time Cam (to be created)
    3440  MBadPixelsIntensityCam          *fIntensBad;       //! Intensity Bad Pixels Cam (to be created)
    3541 
     
    3844  MCalibrateData                  *fCalibrate;       //! Data Calibration Task
    3945                                                     
     46  UInt_t fNumCam;              //! Number of currently used Calibration Cam
    4047  UInt_t fNumEventsDump;       // Number of event after which the MCalibrationCams gets updated
    4148  UInt_t fNumEvents;           //! Event counter only for calibration events
    42   UInt_t fNumCam;              //! Number of currently used Calibration Cam
     49  UInt_t fNumPhesDump;         // Number of cams after which the number of phes gets averaged
     50  UInt_t fNumPhes;             //! Event counter for photo-electron updates
     51
     52  Float_t fMeanPhes;
     53  Float_t fMeanPhesRelVar;
    4354
    4455  Bool_t fUpdateWithFFactorMethod; // Update the interlaced calib events with the full F-Factor method
     56  Bool_t fUpdateNumPhes;           // Update the number of photo-electrons only after fNumPhesDump number of Cams
    4557
     58  TArrayF fPhes;
     59  TArrayF fPhesVar;
     60
     61  // MTask
    4662  Int_t  PreProcess(MParList *pList);
    4763  Int_t  Process();
    4864  Int_t  PostProcess(); 
    4965
     66  // MCalibCalcFromPast
    5067  Bool_t ReInitialize();
    5168  Bool_t Finalize(const char* name);
    5269
     70  Bool_t UpdateMeanPhes();
     71
     72  // MParContainer
    5373  Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
    5474
    5575public:
     76  MCalibCalcFromPast(const char *name=NULL, const char *title=NULL);
    5677
    57   MCalibCalcFromPast(const char *name=NULL, const char *title=NULL);
    58   ~MCalibCalcFromPast() {}
    59  
     78  // Getter
    6079  UInt_t GetNumEventsDump() const   {  return fNumEventsDump;   }
    61  
     80
     81  // Setter
    6282  void SetNumEventsDump( const UInt_t i=fgNumEventsDump )   { fNumEventsDump = i; }
     83  void SetNumPhesDump  ( const UInt_t i=fgNumPhesDump   )   { fNumPhesDump   = i; }
    6384 
    6485  void SetCalibrate    ( MCalibrateData          *c )  { fCalibrate   = c; }
    6586  void SetChargeCalc   ( MCalibrationChargeCalc  *c )  { fChargeCalc  = c; }
    6687  void SetRelTimeCalc  ( MCalibrationRelTimeCalc *c )  { fRelTimeCalc = c; }
     88  void SetUpdateNumPhes      ( const Bool_t b=kTRUE )  { fUpdateNumPhes           = b;  }
    6789
    6890  void SetUpdateWithFFactorMethod(const Bool_t b=kTRUE){ fUpdateWithFFactorMethod = b; }
    6991 
    70   ClassDef(MCalibCalcFromPast, 1) // Task to steer the processing of interlace calibration events
     92  ClassDef(MCalibCalcFromPast, 2) // Task to steer the processing of interlace calibration events
    7193};
    7294
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc

    r7122 r7189  
    9292//
    9393// See also: MJCalibration, MJPedestal, MJExtractSignal, MJExtractCalibTest
    94 // 
     94//
    9595//////////////////////////////////////////////////////////////////////////////
    9696#include "MCalibrateData.h"
     
    112112#include "MPedestalPix.h"
    113113
     114#include "MCalibrationIntensityChargeCam.h"
    114115#include "MCalibrationChargeCam.h"
    115116#include "MCalibrationChargePix.h"
    116 
     117 
     118#include "MCalibrationIntensityQECam.h"
    117119#include "MCalibrationQECam.h"
    118120#include "MCalibrationQEPix.h"
    119 
     121 
     122#include "MCalibrationIntensityConstCam.h"
    120123#include "MCalibConstCam.h"
    121124#include "MCalibConstPix.h"
     
    152155//
    153156MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title)
    154     : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL),
    155       fQEs(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL),
    156       fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.), fScaleFactor(1.)
     157    : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL), fIntensCalib(NULL),
     158      fQEs(NULL), fIntensQE(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL),
     159      fIntensConst(NULL), fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.),
     160      fScaleFactor(1.)
    157161{
    158162
     
    226230            return kFALSE;
    227231
    228         fCalibConstCam = (MCalibConstCam*)pList->FindCreateObj(AddSerialNumber("MCalibConstCam"));
    229         if (!fCalibConstCam)
    230             return kFALSE;
     232        fIntensConst = (MCalibrationIntensityConstCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityConstCam"));
     233        if (fIntensConst)
     234            *fLog << inf << "Found MCalibrationIntensityConstCam ... " << endl;
     235        else
     236        {
     237            fCalibConstCam = (MCalibConstCam*)pList->FindCreateObj(AddSerialNumber("MCalibConstCam"));
     238            if (!fCalibConstCam)
     239                return kFALSE;
     240        }
    231241    }
    232242
     
    235245    if (fCalibrationMode>kNone)
    236246    {
     247        fIntensCalib = (MCalibrationIntensityChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityChargeCam"));
     248        if (fIntensCalib)
     249          *fLog << inf << "Found MCalibrationIntensityChargeCam ... " << endl;
     250
    237251        fCalibrations = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
    238252        if (!fCalibrations)
     
    241255            return kFALSE;
    242256        }
     257
     258        fIntensQE = (MCalibrationIntensityQECam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityQECam"));
     259        if (fIntensQE)
     260          *fLog << inf << "Found MCalibrationIntensityQECam ... " << endl;
    243261
    244262        fQEs = (MCalibrationQECam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
     
    290308      {
    291309      case kPhe:
    292         fRenormFactor = MCalibrationQEPix::gkDefaultAverageQE;
    293         break;
     310          //
     311          // Average QE for C-photons, for pixels in the inner pixel region ("area 0"),
     312          // used later to convert from C-photons into "equivalent phes":
     313          //
     314          if (fQEs->GetAverageAreas() > 0)
     315          {
     316              MCalibrationQEPix& avqepix = (MCalibrationQEPix&)(fQEs->GetAverageArea(0));
     317              fRenormFactor = avqepix.GetAverageQE();
     318          }
     319          else // Average areas not yet initialized, use default value
     320              fRenormFactor = MCalibrationQEPix::gkDefaultAverageQE;
     321
     322          fRenormFactor = MCalibrationQEPix::gkDefaultAverageQE;
     323          break;
    294324      case kPhot:
    295         fRenormFactor = 1.;
    296         break;
     325          fRenormFactor = 1.;
     326          break;
    297327      }
    298328
     
    346376    }
    347377
    348     if(fCalibrationMode == kBlindPixel && !fQEs->IsBlindPixelMethodValid())
     378    const MCalibrationQECam *qecam = fIntensQE ? (MCalibrationQECam*)fIntensQE->GetCam() : fQEs;
     379    if(fCalibrationMode == kBlindPixel && !qecam->IsBlindPixelMethodValid())
    349380    {
    350381        *fLog << warn << "Blind pixel calibration method not valid, switching to F-factor method" << endl;
     
    352383    }
    353384
    354     if(fCalibrationMode == kPinDiode && !fQEs->IsPINDiodeMethodValid())
     385    if(fCalibrationMode == kPinDiode && !qecam->IsPINDiodeMethodValid())
    355386    {
    356387        *fLog << warn << "PIN diode calibration method not valid, switching to F-factor method" << endl;
     
    358389    }
    359390
    360     if(fCalibrationMode == kCombined && !fQEs->IsCombinedMethodValid())
     391    if(fCalibrationMode == kCombined && !qecam->IsCombinedMethodValid())
    361392    {
    362393        *fLog << warn << "Combined calibration method not valid, switching to F-factor method" << endl;
     
    419450
    420451    if (fCalibrationMode > kNone)
    421       {
    422        
    423         if (fCalibrations->GetSize() != npixels)
    424           {
     452    {
     453
     454        const MCalibrationCam *chargecam = fIntensCalib ? fIntensCalib->GetCam() : fCalibrations;
     455        if (chargecam->GetSize() != npixels)
     456        {
    425457            *fLog << "Size mismatch between MGeomCam and MCalibrationChargeCam... abort!" << endl;
    426458            return kFALSE;
    427           }
    428        
     459        }
     460
    429461        if (fBadPixels->GetSize() != npixels)
    430           {
     462        {
    431463            *fLog << "Size mismatch between MGeomCam and MBadPixelsCam... abort!" << endl;
    432464            return kFALSE;
    433           }
     465        }
    434466      }
    435467   
     
    466498    fHiLoConv.Reset();
    467499    fHiLoConvErr.Reset();
    468    
     500
     501    MCalibConstCam *constcam = fIntensConst ? fIntensConst->GetCam() : fCalibConstCam;
     502
     503    MCalibrationChargeCam *chargecam = NULL;
     504    MCalibrationQECam     *qecam     = NULL;
     505    if (updatecam)
     506    {
     507        chargecam = fCalibrations;
     508        qecam     = fQEs;
     509    }
     510    else
     511    {
     512        chargecam = fIntensCalib ? (MCalibrationChargeCam*)fIntensCalib->GetCam() : fCalibrations;
     513        qecam     = fIntensQE    ? (MCalibrationQECam*)    fIntensQE->GetCam()    : fQEs;
     514    }
     515
    469516    //
    470517    // For the moment, we use only a dummy zenith for the calibration:
     
    488535        Float_t calibUpdate   = 1.;
    489536
    490         MCalibConstPix &cpix  = (*fCalibConstCam)[pixidx];
     537        MCalibConstPix &cpix  = (*constcam)[pixidx];
    491538           
    492539        if(fCalibrationMode!=kNone)
     
    499546             }
    500547           
    501             MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*fCalibrations)[pixidx];
    502             MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCalibrations->GetAverageArea(0);
    503            
    504             hiloconv   = pix.GetConversionHiLo   ();
    505             hiloconverr= pix.GetConversionHiLoErr();
     548            const MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*chargecam)[pixidx];
     549            const MCalibrationChargePix &avpix = (MCalibrationChargePix&)chargecam->GetAverageArea(0);
     550
     551            hiloconv   = pix.GetConversionHiLo     ();
     552            hiloconverr= pix.GetConversionHiLoSigma();
    506553           
    507554            calibConv    = pix.GetMeanConvFADC2Phe();
     
    509556            calibFFactor = pix.GetMeanFFactorFADC2Phot();
    510557           
    511             MCalibrationQEPix &qe = (MCalibrationQEPix&) (*fQEs)[pixidx];
     558            const MCalibrationQEPix &qe = (MCalibrationQEPix&)(*qecam)[pixidx];
    512559
    513560            if (updatecam)
     
    613660        calibConv /= calibQE;
    614661
    615         if (calibConv != 0. && calibQE != 0.)
     662        if (calibConv > 0.00001 && calibQE > 0.00001)
    616663          {
    617664            calibConvVar  = calibConvVar/(calibConv*calibConv) + calibQEVar/(calibQE*calibQE);
     
    632679            calibConv    = -1.;
    633680            calibFFactor = -1.;
     681            *fLog << warn << "Conversion factor of Pixel " << pixidx << " out of range " << endl;
    634682          }
    635683        cpix.SetCalibConst(calibConv);
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.h

    r7122 r7189  
    1313class MBadPixelsCam;
    1414class MPedestalCam;
    15 class MCalibrationChargeCam;
    16 class MCalibrationQECam;
    17 class MExtractedSignalCam;
    18 
    1915class MPedPhotCam;
    2016class MSignalCam;
    2117class MCalibConstCam;
     18class MExtractedSignalCam;
     19
     20class MCalibrationChargeCam;
     21class MCalibrationQECam;
     22
     23class MCalibrationIntensityChargeCam;
     24class MCalibrationIntensityQECam;
     25class MCalibrationIntensityConstCam;
    2226
    2327class MCalibrateData : public MTask
     
    5862  Float_t  fCalibConvMaxLimit;           // Maximum limit for conv. factor
    5963   
    60   MGeomCam              *fGeomCam;       //! Camera geometry container
    61   MBadPixelsCam         *fBadPixels;     //! Bad Pixels information
    62   MCalibrationChargeCam *fCalibrations;  //! Calibration constants
    63   MCalibrationQECam     *fQEs;           //! Quantum efficiencies
    64   MExtractedSignalCam   *fSignals;       //! Integrated charge in FADCs counts
    65   MSignalCam            *fCerPhotEvt;    //! Cerenkov Photon Event used for calculation
    66   MCalibConstCam        *fCalibConstCam; //! Temporary calib consts storage
     64  MGeomCam                       *fGeomCam;       //! Camera geometry container
     65  MBadPixelsCam                  *fBadPixels;     //! Bad Pixels information
     66  MCalibrationChargeCam          *fCalibrations;  //! Calibration constants
     67  MCalibrationIntensityChargeCam *fIntensCalib;   //! Calibration constants from interlaced calib.
     68  MCalibrationQECam              *fQEs;           //! Quantum efficiencies
     69  MCalibrationIntensityQECam     *fIntensQE;      //! Quantum efficiencies  from interlaced calib.
     70  MExtractedSignalCam            *fSignals;       //! Integrated charge in FADCs counts
     71  MSignalCam                     *fCerPhotEvt;    //! Cerenkov Photon Event used for calculation
     72  MCalibConstCam                 *fCalibConstCam; //! Temporary calib consts storage
     73  MCalibrationIntensityConstCam  *fIntensConst;   //! Temporary calib consts storage
    6774 
    6875  CalibrationMode_t fCalibrationMode;    // Flag defining the calibration mode (CalibrationMode_t)
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r7126 r7189  
    184184//   + Float_t fPheErrUpperLimit; // Upper limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
    185185//
     186//
    186187//  ClassVersion 3:
    187188//   + Bool_t  fUseExtractorRes;  // Include extractor resolution in F-Factor method
     189//
     190//  ClassVersion 3:
     191//   +  Float_t fUnsuitablesLimit;                   // Limit for relative number of unsuitable pixels
     192//   +  Float_t fUnreliablesLimit;                   // Limit for relative number of unreliable pixels
     193//   +  Float_t fExternalNumPhes;                    // External mean number of photo-electrons set from outside
     194//   +  Float_t fExternalNumPhesRelVar;              // External rel. var. number of photo-electrons set from outside 
    188195//
    189196//////////////////////////////////////////////////////////////////////////////
     
    198205
    199206#include "MParList.h"
    200 
    201 #include "MStatusDisplay.h"
    202207
    203208#include "MCalibrationPattern.h"
     
    247252const Float_t MCalibrationChargeCalc::fgFFactorErrLimit        = 4.5;
    248253const Float_t MCalibrationChargeCalc::fgArrTimeRmsLimit        = 3.5;
     254const Float_t MCalibrationChargeCalc::fgUnsuitablesLimit       = 0.1;
     255const Float_t MCalibrationChargeCalc::fgUnreliablesLimit       = 0.3;
    249256const TString MCalibrationChargeCalc::fgNamePedestalCam = "MPedestalCam";
    250257
     
    263270//
    264271// Initializes:
    265 // - fArrTimeRmsLimit   to fgArrTimeRmsLimit
    266 // - fChargeLimit       to fgChargeLimit
    267 // - fChargeErrLimit    to fgChargeErrLimit   
    268 // - fChargeRelErrLimit to fgChargeRelErrLimit
    269 // - fFFactorErrLimit   to fgFFactorErrLimit
    270 // - fLambdaCheckLimit  to fgLambdaCheckLimit
    271 // - fLambdaErrLimit    to fgLambdaErrLimit
    272 // - fNamePedestalCam   to fgNamePedestalCam
    273 // - fPheErrLowerLimit  to fgPheErrLowerLimit
    274 // - fPheErrUpperLimit  to fgPheErrUpperLimit
    275 // - fPulserColor       to MCalibrationCam::kCT1
    276 // - fOutputPath        to "."
    277 // - fOutputFile        to "ChargeCalibStat.txt"
    278 // - flag debug         to kFALSE
     272// - fArrTimeRmsLimit     to fgArrTimeRmsLimit
     273// - fChargeLimit         to fgChargeLimit
     274// - fChargeErrLimit      to fgChargeErrLimit
     275// - fChargeRelErrLimit   to fgChargeRelErrLimit
     276// - fFFactorErrLimit     to fgFFactorErrLimit
     277// - fLambdaCheckLimit    to fgLambdaCheckLimit
     278// - fLambdaErrLimit      to fgLambdaErrLimit
     279// - fNamePedestalCam     to fgNamePedestalCam
     280// - fPheErrLowerLimit    to fgPheErrLowerLimit
     281// - fPheErrUpperLimit    to fgPheErrUpperLimit
     282// - fPulserColor         to MCalibrationCam::kCT1
     283// - fOutputPath          to "."
     284// - fOutputFile          to "ChargeCalibStat.txt"
     285// - flag debug           to kFALSE
     286// - IsUseExtractorRes    to kFALSE
     287// - IsUseExternalNumPhes to kFALSE
     288// - fExternalNumPhes     to 0.
     289// - fExternalNumPhesRelVar to 0.
    279290//
    280291// Sets all checks
     
    284295//
    285296MCalibrationChargeCalc::MCalibrationChargeCalc(const char *name, const char *title)
    286     : fUseExtractorRes(kFALSE),
    287     fGeom(NULL), fSignal(NULL), fCalibPattern(NULL), fExtractor(NULL)
     297    : fGeom(NULL), fSignal(NULL), fCalibPattern(NULL), fExtractor(NULL)
    288298{
    289299       
     
    309319  SetPheErrLowerLimit  ();
    310320  SetPheErrUpperLimit  ();
     321  SetUnsuitablesLimit  ();
     322  SetUnreliablesLimit  ();
     323  SetUseExtractorRes   ();
     324  SetUseUnreliables    ();
     325  SetUseExternalNumPhes(kFALSE);
     326 
     327  SetExternalNumPhes      ();
     328  SetExternalNumPhesRelVar();
    311329
    312330  SetCheckArrivalTimes     ();
     
    560578    }
    561579
     580  fResultFlags.Set(fGeom->GetNumAreas());
     581
    562582  return kTRUE;
    563583}
     
    777797    {
    778798
    779       const MPedestalPix     &ped = fPedestals->GetAverageArea(aidx);
     799      const MPedestalPix    &ped = fPedestals->GetAverageArea(aidx);
    780800      MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageArea(aidx);
     801      const MArrayI &arr         = fHCam->GetAverageAreaNum();
    781802
    782803      FinalizePedestals(ped,pix,aidx);
     804
     805      //
     806      // Correct for sqrt(number of valid pixels) in the pedestal RMS
     807      // (already done for calibration sigma in MHCalibrationCam::CalcAverageSigma()
     808      //
     809      pix.SetPedRMS(pix.GetPedRms()*TMath::Sqrt((Float_t)arr[aidx]),
     810                    pix.GetPedRmsErr()*TMath::Sqrt((Float_t)arr[aidx]));
     811      pix.SetSigma (pix.GetSigma()/pix.GetFFactorFADC2Phe());
     812
    783813      FinalizeCharges(pix, chargecam->GetAverageBadArea(aidx),"area id");
    784814      FinalizeArrivalTimes(pix, chargecam->GetAverageBadArea(aidx), "area id");
     
    847877  }
    848878
    849   //
    850   // Finalize calibration statistics
    851   //
    852   FinalizeUnsuitablePixels();
    853 
    854   chargecam->SetReadyToSave();
    855   qecam    ->SetReadyToSave();
    856   badcam   ->SetReadyToSave();
    857  
    858   if (blindcam)
    859     blindcam->SetReadyToSave();
    860   if (fPINDiode)
    861     fPINDiode->SetReadyToSave();
    862  
    863879  *fLog << inf << endl;
    864880  *fLog << GetDescriptor() << ": Fatal errors statistics:" << endl; 
     
    884900  PrintUncalibrated(MBadPixelsPix::kDeviatingNumPhes,
    885901                    "Deviating number of phes:                         ");
     902  PrintUncalibrated(MBadPixelsPix::kLoGainBlackout,
     903                    "Too many blackout events in low gain:             ");
    886904  PrintUncalibrated(MBadPixelsPix::kPreviouslyExcluded,
    887905                    "Previously excluded:                              ");
     
    906924      SetLogStream(oldlog);
    907925
    908   return kTRUE;
     926  chargecam->SetReadyToSave();
     927  qecam    ->SetReadyToSave();
     928  badcam   ->SetReadyToSave();
     929
     930  if (blindcam)
     931    blindcam->SetReadyToSave();
     932  if (fPINDiode)
     933    fPINDiode->SetReadyToSave();
     934
     935  //
     936  // Finalize calibration statistics
     937  //
     938  return FinalizeUnsuitablePixels();
    909939}
    910940
     
    10421072    }
    10431073
    1044   if (!fUseExtractorRes)
     1074  if (!IsUseExtractorRes())
    10451075    return kTRUE;
    10461076
     
    10591089    : resinphes/cal.GetMeanConvFADC2Phe();
    10601090
    1061   if (resinfadc > 1.5*cal.GetPedRms() )
    1062     {
    1063       *fLog << warn << " Extractor Resolution: " << resinfadc << " bigger than Pedestal RMS " << cal.GetPedRms() << endl;
    1064       resinfadc = cal.GetPedRms();
     1091  if (resinfadc > 3.0*cal.GetPedRms() )
     1092    {
     1093      *fLog << warn << " Extractor Resolution: " << resinfadc << " bigger than 3 Pedestal RMS "
     1094            << cal.GetPedRms() << endl;
     1095      resinfadc = 3.0*cal.GetPedRms();
    10651096    }
    10661097
     
    11521183          if (bad.IsUncalibrated( MBadPixelsPix::kChargeIsPedestal))
    11531184            bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun   );
    1154  
    1155           if (bad.IsUncalibrated( MBadPixelsPix::kChargeErrNotValid ))
    1156             bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
    1157 
    1158           if (bad.IsUncalibrated( MBadPixelsPix::kChargeRelErrNotValid ))
    1159             bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
    11601185        }
    11611186     
     
    12681293      if (bad.IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid))
    12691294        continue;
    1270      
     1295
     1296      if (!IsUseUnreliables())
     1297        if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
     1298          continue;
     1299
    12711300      const Float_t nphe  = pix.GetPheFFactorMethod();
    12721301      const Int_t   aidx  = (*fGeom)[i].GetAidx();
     
    13221351      if (ndf < 5)
    13231352        {
    1324           *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons "
    1325                 << "in the camera with area index: " << i << endl;
    1326           *fLog << warn << GetDescriptor() << ": Number of dof.: " << ndf << " is smaller than 5 " << endl;
    1327           *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
    1328           delete hist;
    1329           continue;
     1353            *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " << endl;
     1354            *fLog << " in the camera with area index: " << i << endl;
     1355            *fLog << " Number of dof.: " << ndf << " is smaller than 5 " << endl;
     1356            *fLog << " Will use the simple mean and rms " << endl;
     1357            delete hist;
     1358            SetPheFitOK(i,kFALSE);
     1359            continue;
    13301360        }
    13311361     
     
    13341364      if (prob < 0.001)
    13351365        {
    1336           *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons "
    1337                 << "in the camera with area index: " << i << endl;
    1338           *fLog << warn << GetDescriptor() << ": Fit probability " << prob
    1339                 << " is smaller than 0.001 " << endl;
    1340           *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
    1341           delete hist;
    1342           continue;
     1366            *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " << endl;
     1367            *fLog << " in the camera with area index: " << i << endl;
     1368            *fLog << " Fit probability " << prob << " is smaller than 0.001 " << endl;
     1369            *fLog << " Will use the simple mean and rms " << endl;
     1370            delete hist;
     1371            SetPheFitOK(i,kFALSE);
     1372            continue;
    13431373        }
    13441374     
    13451375      if (mean < 0.)
    13461376        {
    1347           *fLog << inf << GetDescriptor() << ": Fitted mean number of photo-electrons "
    1348                 << "with area idx " << i << ": " << mean << " is smaller than 0. " << endl;
    1349           *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;         
    1350           delete hist;
    1351           continue;
     1377            *fLog << inf << GetDescriptor() << ": Fitted mean number of photo-electrons " << endl;
     1378            *fLog << " with area idx " << i << ": " << mean << " is smaller than 0. " << endl;
     1379            *fLog << warn << " Will use the simple mean and rms " << endl;
     1380            SetPheFitOK(i,kFALSE);
     1381            delete hist;
     1382            continue;
    13521383        }
    13531384     
     
    13591390
    13601391      delete hist;
     1392
     1393      SetPheFitOK(i,kTRUE);
    13611394    }
    13621395
     
    13831416      if (bad.IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid))
    13841417        continue;
     1418
     1419      if (!IsUseUnreliables())
     1420        if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
     1421          continue;
    13851422
    13861423      const Float_t nvar  = pix.GetPheFFactorMethodVar();
     
    17301767  MCalibrationQEPix     &qepix = (MCalibrationQEPix&)    qecam->GetAverageArea(0);
    17311768
    1732   const Float_t avphotons   = avpix.GetPheFFactorMethod()       
     1769  if (IsDebug())
     1770    *fLog << dbginf << "External Phes: " << fExternalNumPhes
     1771          << " Internal Phes: " << avpix.GetPheFFactorMethod() << endl;
     1772
     1773  const Float_t avphotons   = ( IsUseExternalNumPhes()
     1774                                ? fExternalNumPhes
     1775                                : avpix.GetPheFFactorMethod() )
    17331776                           / qepix.GetDefaultQE(fPulserColor)
    17341777                           / qepix.GetPMTCollectionEff()
     
    17361779                           / qecam->GetPlexiglassQE();
    17371780
    1738   const Float_t avphotrelvar = avpix.GetPheFFactorMethodRelVar()
     1781  const Float_t avphotrelvar = ( IsUseExternalNumPhes()
     1782                                 ? fExternalNumPhesRelVar
     1783                                 : avpix.GetPheFFactorMethodRelVar() )
    17391784                            + qepix.GetDefaultQERelVar(fPulserColor) / fNumInnerFFactorMethodUsed
    17401785                            + qepix.GetPMTCollectionEffRelVar()
     
    18461891      if (ndf < 2)
    18471892        {
    1848           *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor "
    1849                 << "in the camera with area index: " << i << endl;
    1850           *fLog << "Number of dof.: " << ndf << " is smaller than 2 " << endl;
    1851           *fLog << "Will use the simple mean and rms." << endl;
     1893          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " << endl;
     1894          *fLog << " in the camera with area index: " << i << endl;
     1895          *fLog << " Number of dof.: " << ndf << " is smaller than 2 " << endl;
     1896          *fLog << " Will use the simple mean and rms." << endl;
    18521897          delete hist;
     1898          SetFFactorFitOK(i,kFALSE);
    18531899          continue;
    18541900        }
     
    18581904      if (prob < 0.001)
    18591905        {
    1860           *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor "
    1861                 << "in the camera with area index: " << i << endl;
    1862           *fLog << "Fit probability " << prob
    1863                 << " is smaller than 0.001 " << endl;
    1864           *fLog << "Will use the simple mean and rms." << endl;
     1906          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " << endl;
     1907          *fLog << " in the camera with area index: " << i << endl;
     1908          *fLog << " Fit probability " << prob << " is smaller than 0.001 " << endl;
     1909          *fLog << " Will use the simple mean and rms." << endl;
    18651910          delete hist;
    1866           continue;
     1911          SetFFactorFitOK(i,kFALSE);
     1912         continue;
    18671913        }
    18681914
    18691915      *fLog << inf << GetDescriptor() << ": Mean F-Factor "
    1870           << "with area index #" << i << ": "
    1871             << Form("%4.2f+-%4.2f",mean,sigma) << endl;
     1916          << "with area index #" << i << ": " << Form("%4.2f+-%4.2f",mean,sigma) << endl;
    18721917
    18731918      lowlim  [i] = 1.;
     
    18751920
    18761921      delete hist;
     1922
     1923      SetFFactorFitOK(i,kTRUE);
    18771924    }
    18781925 
     
    21342181// - store numbers of bad pixels of each type in fCam or fIntensCam
    21352182//
    2136 void MCalibrationChargeCalc::FinalizeUnsuitablePixels()
     2183Bool_t MCalibrationChargeCalc::FinalizeUnsuitablePixels()
    21372184{
    21382185 
     
    21432190  const Int_t nareas = fGeom->GetNumAreas();
    21442191
     2192  TArrayI suit(nareas);
     2193  TArrayI unsuit(nareas);
     2194  TArrayI unrel(nareas);
     2195
     2196  const MBadPixelsCam *badcam = fIntensBad ? (MBadPixelsCam*)fIntensBad->GetCam() : fBadPixels;
     2197  MCalibrationChargeCam *chargecam = fIntensCam ? (MCalibrationChargeCam*)fIntensCam->GetCam() : fCam;
     2198
     2199  Int_t unsuitcnt=0;
     2200  Int_t unrelcnt =0;
     2201
     2202  // Count number of succesfully calibrated pixels
     2203  for (Int_t aidx=0; aidx<nareas; aidx++)
     2204  {
     2205      suit[aidx]   = badcam->GetNumSuitable(MBadPixelsPix::kUnsuitableRun,   fGeom, aidx);
     2206      unsuit[aidx] = badcam->GetNumUnsuitable(MBadPixelsPix::kUnsuitableRun, fGeom, aidx);
     2207      unrel[aidx]  = badcam->GetNumUnsuitable(MBadPixelsPix::kUnreliableRun, fGeom, aidx);
     2208
     2209      unsuitcnt   += unsuit[aidx];
     2210      unrelcnt    += unrel[aidx];
     2211
     2212      chargecam->SetNumUnsuitable(unsuit[aidx], aidx);
     2213      chargecam->SetNumUnreliable(unrel[aidx],  aidx);
     2214  }
     2215
    21452216  TArrayI counts(nareas);
    2146 
    2147   MBadPixelsCam         *badcam    = fIntensBad
    2148     ? (MBadPixelsCam*)fIntensBad->GetCam()  : fBadPixels;
    2149   MCalibrationChargeCam *chargecam = fIntensCam
    2150     ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
    2151 
    2152   for (Int_t i=0; i<badcam->GetSize(); i++)
    2153     {
    2154       MBadPixelsPix &bad = (*badcam)[i];
    2155       if (!bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
    2156         {
     2217  for (Int_t i=0; i<chargecam->GetSize(); i++)
     2218  {
     2219      MCalibrationPix &pix = (*chargecam)[i];
     2220      if (pix.IsHiGainSaturation())
     2221      {
    21572222          const Int_t aidx = (*fGeom)[i].GetAidx();
    21582223          counts[aidx]++;
    2159         }
    2160     }
     2224      }
     2225  }
    21612226
    21622227  if (fGeom->InheritsFrom("MGeomCamMagic"))
    2163     *fLog << " " << setw(7) << "Successfully calibrated Pixels: "
    2164           << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
    2165  
    2166   counts.Reset();
    2167 
    2168   for (Int_t i=0; i<badcam->GetSize(); i++)
    2169     {
    2170       MBadPixelsPix &bad =  (*badcam)[i];
    2171 
    2172       if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
    2173         {
    2174           const Int_t aidx = (*fGeom)[i].GetAidx();
    2175           counts[aidx]++;
    2176         }
    2177     }
    2178 
    2179   for (Int_t aidx=0; aidx<nareas; aidx++)
    2180     chargecam->SetNumUnsuitable(counts[aidx], aidx);
    2181 
    2182   if (fGeom->InheritsFrom("MGeomCamMagic"))
    2183     *fLog << " " << setw(7) << "Uncalibrated Pixels:            "
    2184           << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
    2185 
    2186   counts.Reset();
    2187 
    2188   for (Int_t i=0; i<badcam->GetSize(); i++)
    2189     {
    2190 
    2191       MBadPixelsPix &bad = (*badcam)[i];
    2192 
    2193       if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
    2194         {
    2195           const Int_t aidx = (*fGeom)[i].GetAidx();
    2196           counts[aidx]++;
    2197         }
    2198     }
    2199 
    2200   for (Int_t aidx=0; aidx<nareas; aidx++)
    2201     chargecam->SetNumUnreliable(counts[aidx], aidx);
    2202 
    2203   *fLog << " " << setw(7) << "Unreliable Pixels:              "
    2204         << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
    2205 
     2228  {
     2229      *fLog << " Successfully calibrated Pixels: Inner: "
     2230          << Form("%3i",suit[0])   << " Outer: " << Form("%3i",suit[1])   << endl;
     2231      *fLog << " Uncalibrated Pixels:            Inner: "
     2232          << Form("%3i",unsuit[0]) << " Outer: " << Form("%3i",unsuit[1]) << endl;
     2233      *fLog << " Unreliable Pixels:              Inner: "
     2234          << Form("%3i",unrel[0])  << " Outer: " << Form("%3i",unrel[1])  << endl;
     2235      *fLog << " High-gain saturated Pixels:     Inner: "
     2236          << Form("%3i",counts[0]) << " Outer: " << Form("%3i",counts[1]) << endl;
     2237      *fLog << endl;
     2238  }
     2239
     2240  return kTRUE;
     2241
     2242  if (unsuitcnt > fUnsuitablesLimit*fGeom->GetNumPixels())
     2243  {
     2244      *fLog << err << "Number of unsuitable pixels: " << 100.*unsuitcnt/fGeom->GetNumPixels()
     2245          << "% exceeds limit of " << fUnsuitablesLimit*100 << "%" <<  endl;
     2246      return kFALSE;
     2247  }
     2248
     2249  if (unrelcnt > fUnreliablesLimit*fGeom->GetNumPixels())
     2250  {
     2251      *fLog << err << "Relative number of unreliable pixels: " << 100.*unrelcnt/fGeom->GetNumPixels()
     2252          << "% exceeds limit of " << fUnreliablesLimit*100 << "%" << endl;
     2253      return kFALSE;
     2254  }
     2255  return kTRUE;
    22062256}
    22072257
     
    22322282    }
    22332283
    2234   *fLog << " " << setw(7) << text  
    2235         << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
     2284  *fLog << " " << setw(7) << text << "Inner: " << Form("%3i",countinner)
     2285      << " Outer: " << Form("%3i", countouter) << endl;
    22362286}
    22372287
     
    23612411      rc = kTRUE;
    23622412    }
    2363   if (IsEnvDefined(env, prefix, "UseExtractorRes", print))
    2364     {
    2365       SetUseExtractorRes(GetEnvValue(env, prefix, "UseExtractorRes", fUseExtractorRes));
     2413   if (IsEnvDefined(env, prefix, "UseExtractorRes", print))
     2414     {
     2415       SetUseExtractorRes(GetEnvValue(env, prefix, "UseExtractorRes", IsUseExtractorRes()));
    23662416      rc = kTRUE;
    23672417    }
     2418  if (IsEnvDefined(env, prefix, "UseUnreliables", print))
     2419    {
     2420      SetUseUnreliables(GetEnvValue(env, prefix, "UseUnreliables", IsUseUnreliables()));
     2421      rc = kTRUE;
     2422    }
     2423
     2424  if (IsEnvDefined(env, prefix, "UseExternalNumPhes", print))
     2425    {
     2426      SetUseExternalNumPhes(GetEnvValue(env, prefix, "UseExternalNumPhes", IsUseExternalNumPhes()));
     2427      rc = kTRUE;
     2428    }
     2429
     2430  if (IsEnvDefined(env, prefix, "UnsuitablesLimit", print))
     2431    {
     2432      SetUnsuitablesLimit(GetEnvValue(env, prefix, "UnsuitablesLimit", fUnsuitablesLimit));
     2433      rc = kTRUE;
     2434    }
     2435
     2436  if (IsEnvDefined(env, prefix, "UnreliablesLimit", print))
     2437    {
     2438       SetUnreliablesLimit(GetEnvValue(env, prefix, "UnreliablesLimit", fUnreliablesLimit));
     2439       rc = kTRUE;
     2440     }
     2441 
    23682442
    23692443  return rc;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h

    r7099 r7189  
    5050  static const Float_t fgFFactorErrLimit;      //! Default for fFFactorErrLimit    (now set to: 4.5)
    5151  static const Float_t fgArrTimeRmsLimit;      //! Default for fArrTimeRmsLimit    (now set to: 3.5)
     52  static const Float_t fgUnsuitablesLimit;     //! Default for fUnsuitableLimit    (now set to: 0.1)
     53  static const Float_t fgUnreliablesLimit;     //! Default for fUnreliableLimit    (now set to: 0.3)
    5254 
    5355  static const TString fgNamePedestalCam;      //! "MPedestalCam"
    5456 
    5557  // Variables
     58  Float_t fArrTimeRmsLimit;                    // Limit acceptance RMS of absolute arrival times
    5659  Float_t fChargeLimit;                        // Limit acceptance mean charge  (in units of PedRMS)
    5760  Float_t fChargeErrLimit;                     // Limit acceptance charge error (in abs. numbers)
    5861  Float_t fChargeRelErrLimit;                  // Limit acceptance rel. error mean (in abs. numbers)
     62  Float_t fFFactorErrLimit;                    // Limit acceptance F-Factor w.r.t. area idx mean
    5963  Float_t fLambdaCheckLimit;                   // Limit rel. diff. lambda and lambdacheck in Blind Pixel
    6064  Float_t fLambdaErrLimit;                     // Limit acceptance lambda error in Blind Pixel
     
    6367  Float_t fPheErrLowerLimit;                   // Lower limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
    6468  Float_t fPheErrUpperLimit;                   // Upper limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
    65   Float_t fFFactorErrLimit;                    // Limit acceptance F-Factor w.r.t. area idx mean
    66   Float_t fArrTimeRmsLimit;                    // Limit acceptance RMS of absolute arrival times
    6769  Float_t fSqrtHiGainSamples;                  // Square root nr. High-Gain FADC slices used by extractor
    6870  Float_t fSqrtLoGainSamples;                  // Square root nr. Low -Gain FADC slices used by extractor
     71  Float_t fUnsuitablesLimit;                   // Limit for relative number of unsuitable pixels
     72  Float_t fUnreliablesLimit;                   // Limit for relative number of unreliable pixels
     73
     74  Float_t fExternalNumPhes;                    // External mean number of photo-electrons set from outside
     75  Float_t fExternalNumPhesRelVar;              // External rel. var. number of photo-electrons set from outside 
    6976
    7077  MCalibrationCam::PulserColor_t fPulserColor; // Calibration LEDs colour
     
    7380  Int_t   fNumInnerFFactorMethodUsed;          // Number of inner pixels used for F-Factor Method calibration
    7481
    75   Byte_t  fFlags;                              // Bit-field for the general flags
    76   TArrayC fResultFlags;                        // Bit-fields for the fitting results   (one field per area index)
    77   TArrayC fBlindPixelFlags;                    // Bit-fields for the blind pixel flags (one field per blind pixel)
    78   TArrayC fPINDiodeFlags;                      // Bit-fields for the PIN Diode flags   (one field per PIN Diode  )
    79  
    8082  TString fOutputPath;                         // Path to the output file
    8183  TString fOutputFile;                         // Name of the output file 
     
    8385
    8486  Int_t   fNumProcessed;                       // Number of processed events (for Intensity calibration)
    85   Bool_t  fUseExtractorRes;                    // Include extractor resolution in F-Factor method
    8687 
    8788  // Pointers
     
    115116
    116117  Byte_t fCheckFlags;                          // Bit-field to hold the possible check flags
    117  
     118
     119  enum  FitResult_t { kPheFitOK,
     120                      kFFactorFitOK,
     121                      kBlindPixelFitOK,
     122                      kBlindPixelPedFitOK,
     123                      kPINDiodeFitOK };        // Possible Fit Result flags
     124
     125  TArrayC fResultFlags;                        // Bit-fields for the fitting results   (one field per area index)
     126  TArrayC fBlindPixelFlags;                    // Bit-fields for the blind pixel flags (one field per blind pixel)
     127  TArrayC fPINDiodeFlags;                      // Bit-fields for the PIN Diode flags   (one field per PIN Diode  )
     128
    118129  enum  { kDebug,
    119           kPheFitOK, kFFactorFitOK, kBlindPixelFitOK, kBlindPixelPedFitOK, kPINDiodeFitOK };
     130          kUseExtractorRes,
     131          kUseUnreliables,
     132          kUseExternalNumPhes };               // Possible general flags
     133
     134  Byte_t fFlags;                               // Bit-field to hold the general flags
    120135
    121136  // functions
     137  void   FinalizeArrivalTimes    ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
     138  void   FinalizeBadPixels       ();
     139  Bool_t FinalizeBlindCam        (); 
     140  void   FinalizeBlindPixelQECam ();
     141  Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
     142  void   FinalizeCombinedQECam   ();
     143  void   FinalizeFFactorQECam    (); 
     144  Bool_t FinalizeFFactorMethod   ();
    122145  void   FinalizePedestals       ( const MPedestalPix    &ped, MCalibrationChargePix &cal, const Int_t aidx );
    123   void   FinalizeArrivalTimes    ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
    124   Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
    125146  Bool_t FinalizePINDiode        ();
    126   Bool_t FinalizeBlindCam        (); 
    127   Bool_t FinalizeFFactorMethod   ();
    128   void   FinalizeBadPixels       ();
    129   void   FinalizeFFactorQECam    (); 
    130   void   FinalizeBlindPixelQECam ();
    131147  void   FinalizePINDiodeQECam   ();
    132   void   FinalizeCombinedQECam   ();
    133   void   FinalizeUnsuitablePixels();
     148  Bool_t FinalizeUnsuitablePixels();
    134149
    135150  const char* GetOutputFile();
     
    143158  Bool_t IsCheckArrivalTimes     () const { return TESTBIT(fCheckFlags,kCheckArrivalTimes);      }
    144159
     160  Bool_t IsDebug                 () const { return TESTBIT(fFlags,kDebug);                       }
     161  Bool_t IsUseExtractorRes       () const { return TESTBIT(fFlags,kUseExtractorRes);             }
     162  Bool_t IsUseUnreliables        () const { return TESTBIT(fFlags,kUseUnreliables);              }
     163  Bool_t IsUseExternalNumPhes    () const { return TESTBIT(fFlags,kUseExternalNumPhes);          }
     164
    145165  void   PrintUncalibrated( MBadPixelsPix::UncalibratedType_t typ, const char *text) const;
    146166
    147167  // Global fit results
    148   void   SetPheFitOK          ( const Int_t aidx, const Bool_t b=kTRUE ) {
    149     b ? SETBIT(fResultFlags[aidx], kPheFitOK)
    150       : CLRBIT(fResultFlags[aidx], kPheFitOK);      }
    151   void   SetFFactorFitOK      ( const Int_t aidx, const Bool_t b=kTRUE ) {
    152     b ? SETBIT(fResultFlags[aidx], kFFactorFitOK)
    153       : CLRBIT(fResultFlags[aidx], kFFactorFitOK);  }
    154   void   SetBlindPixelFitOK   ( const Int_t  idx, const Bool_t b=kTRUE ) {
    155     b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelFitOK)
    156       : CLRBIT(fBlindPixelFlags[idx], kBlindPixelFitOK); }
    157   void   SetBlindPixelPedFitOK( const Int_t  idx, const Bool_t b=kTRUE ) {
    158     b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK)
    159       : CLRBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK); }
    160   void   SetPINDiodeFitOK     ( const Int_t  idx, const Bool_t b=kTRUE ) {
    161     b ? SETBIT(fPINDiodeFlags[idx], kPINDiodeFitOK)
    162       : CLRBIT(fPINDiodeFlags[idx], kPINDiodeFitOK); }
     168  void   SetPheFitOK          (const Int_t aidx, const Bool_t b=kTRUE) { b ? SETBIT(fResultFlags[aidx], kPheFitOK) : CLRBIT(fResultFlags[aidx], kPheFitOK);      }
     169  void   SetFFactorFitOK      (const Int_t aidx, const Bool_t b=kTRUE) { b ? SETBIT(fResultFlags[aidx], kFFactorFitOK) : CLRBIT(fResultFlags[aidx], kFFactorFitOK);  }
     170  void   SetBlindPixelFitOK   (const Int_t  idx, const Bool_t b=kTRUE) { b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelFitOK) : CLRBIT(fBlindPixelFlags[idx], kBlindPixelFitOK); }
     171  void   SetBlindPixelPedFitOK(const Int_t  idx, const Bool_t b=kTRUE) { b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK): CLRBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK); }
     172  void   SetPINDiodeFitOK     (const Int_t  idx, const Bool_t b=kTRUE) { b ? SETBIT(fPINDiodeFlags[idx], kPINDiodeFitOK): CLRBIT(fPINDiodeFlags[idx], kPINDiodeFitOK); }
    163173
    164174  Int_t  PreProcess (MParList *pList);
     
    169179
    170180public:
    171 
    172181  MCalibrationChargeCalc(const char *name=NULL, const char *title=NULL);
    173182
     
    176185  Int_t Finalize();
    177186
    178   Bool_t IsDebug() const   {  return TESTBIT(fFlags,kDebug); }
     187  void SetChargeLimit      (const Float_t f=fgChargeLimit      ) { fChargeLimit       = f; }
     188  void SetChargeErrLimit   (const Float_t f=fgChargeErrLimit   ) { fChargeErrLimit    = f; }
     189  void SetChargeRelErrLimit(const Float_t f=fgChargeRelErrLimit) { fChargeRelErrLimit = f; }
     190
     191  // Checks
     192  void SetCheckArrivalTimes(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckArrivalTimes)      : CLRBIT(fCheckFlags,kCheckArrivalTimes); }
     193  void SetCheckDeadPixels(const Bool_t b=kTRUE)        { b ? SETBIT(fCheckFlags,kCheckDeadPixels)        : CLRBIT(fCheckFlags,kCheckDeadPixels); }
     194  void SetCheckDeviatingBehavior(const Bool_t b=kTRUE) { b ? SETBIT(fCheckFlags,kCheckDeviatingBehavior) : CLRBIT(fCheckFlags,kCheckDeviatingBehavior); }
     195  void SetCheckExtractionWindow(const Bool_t b=kTRUE)  { b ? SETBIT(fCheckFlags,kCheckExtractionWindow)  : CLRBIT(fCheckFlags,kCheckExtractionWindow); }
     196  void SetCheckHistOverflow(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckHistOverflow)      : CLRBIT(fCheckFlags,kCheckHistOverflow); }
     197  void SetCheckOscillations(const Bool_t b=kTRUE)      { b ? SETBIT(fCheckFlags,kCheckOscillations)      : CLRBIT(fCheckFlags,kCheckOscillations); }
     198  void SetDebug(const Bool_t b=kTRUE)                  { b ? SETBIT(fFlags, kDebug)                      : CLRBIT(fFlags, kDebug); }
     199  void SetUseExtractorRes(const Bool_t b=kTRUE)        { b ? SETBIT(fFlags, kUseExtractorRes)            : CLRBIT(fFlags, kUseExtractorRes); }
     200  void SetUseUnreliables(const Bool_t b=kTRUE)         { b ? SETBIT(fFlags, kUseUnreliables)             : CLRBIT(fFlags, kUseUnreliables); }
     201  void SetUseExternalNumPhes(const Bool_t b=kTRUE)     { b ? SETBIT(fFlags, kUseExternalNumPhes)         : CLRBIT(fFlags, kUseExternalNumPhes); }
     202
     203  // pointers
     204  void SetPedestals(MPedestalCam *cam) { fPedestals=cam; }
     205  void SetExtractor(MExtractor   *ext) { fExtractor=ext; }
     206
     207  // limits
     208  void SetArrTimeRmsLimit (const Float_t f=fgArrTimeRmsLimit ) { fArrTimeRmsLimit   = f; }
     209  void SetFFactorErrLimit (const Float_t f=fgFFactorErrLimit ) { fFFactorErrLimit   = f; }
     210  void SetLambdaErrLimit  (const Float_t f=fgLambdaErrLimit  ) { fLambdaErrLimit    = f; }
     211  void SetLambdaCheckLimit(const Float_t f=fgLambdaCheckLimit) { fLambdaCheckLimit  = f; }
     212  void SetUnsuitablesLimit(const Float_t f=fgUnsuitablesLimit) { fUnsuitablesLimit  = f; }
     213  void SetUnreliablesLimit(const Float_t f=fgUnreliablesLimit) { fUnreliablesLimit  = f; }
     214
     215  // others
     216  void SetExternalNumPhes      ( const Float_t f=0.                       ) { fExternalNumPhes       = f; }
     217  void SetExternalNumPhesRelVar( const Float_t f=0.                       ) { fExternalNumPhesRelVar = f; } 
     218  void SetNamePedestalCam      ( const char *name=fgNamePedestalCam.Data()) { fNamePedestalCam    = name; }
     219  void SetOutputPath           ( const TString path="."                   );
     220  void SetOutputFile           ( const TString file="ChargeCalibStat.txt" );
     221  void SetPheErrLowerLimit     ( const Float_t f=fgPheErrLowerLimit       ) { fPheErrLowerLimit  = f;    }
     222  void SetPheErrUpperLimit     ( const Float_t f=fgPheErrUpperLimit       ) { fPheErrUpperLimit  = f;    }   
     223  void SetPulserColor          ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;  }
    179224 
    180   void SetChargeLimit       ( const Float_t f=fgChargeLimit            ) { fChargeLimit       = f;     }
    181   void SetChargeErrLimit    ( const Float_t f=fgChargeErrLimit         ) { fChargeErrLimit    = f;     }
    182   void SetChargeRelErrLimit ( const Float_t f=fgChargeRelErrLimit      ) { fChargeRelErrLimit = f;     }
    183 
    184   // Checks
    185   void SetCheckArrivalTimes( const Bool_t b=kTRUE ) {
    186     b ? SETBIT(fCheckFlags,kCheckArrivalTimes)
    187       : CLRBIT(fCheckFlags,kCheckArrivalTimes); }
    188   void SetCheckDeadPixels( const Bool_t b=kTRUE ) {
    189     b ? SETBIT(fCheckFlags,kCheckDeadPixels)
    190       : CLRBIT(fCheckFlags,kCheckDeadPixels); }
    191   void SetCheckDeviatingBehavior( const Bool_t b=kTRUE ) {
    192     b ? SETBIT(fCheckFlags,kCheckDeviatingBehavior)
    193       : CLRBIT(fCheckFlags,kCheckDeviatingBehavior); }
    194   void SetCheckExtractionWindow( const Bool_t b=kTRUE ) {
    195     b ? SETBIT(fCheckFlags,kCheckExtractionWindow)
    196       : CLRBIT(fCheckFlags,kCheckExtractionWindow); }
    197   void SetCheckHistOverflow( const Bool_t b=kTRUE ) {
    198     b ? SETBIT(fCheckFlags,kCheckHistOverflow)
    199       : CLRBIT(fCheckFlags,kCheckHistOverflow); }
    200   void SetCheckOscillations( const Bool_t b=kTRUE ) {
    201     b ? SETBIT(fCheckFlags,kCheckOscillations)
    202       : CLRBIT(fCheckFlags,kCheckOscillations); }
    203   void SetDebug            ( const Bool_t b=kTRUE ) {
    204     b ? SETBIT(fFlags, kDebug)
    205       : CLRBIT(fFlags, kDebug); }
    206 
    207   void SetExtractor(MExtractor   *ext) { fExtractor=ext; }
    208   void SetPedestals(MPedestalCam *cam) { fPedestals=cam; }
    209                                                                          
    210   void SetArrTimeRmsLimit   ( const Float_t f=fgArrTimeRmsLimit        ) { fArrTimeRmsLimit   = f;     }
    211   void SetFFactorErrLimit   ( const Float_t f=fgFFactorErrLimit        ) { fFFactorErrLimit   = f;     }
    212   void SetLambdaErrLimit    ( const Float_t f=fgLambdaErrLimit         ) { fLambdaErrLimit    = f;     }
    213   void SetLambdaCheckLimit  ( const Float_t f=fgLambdaCheckLimit       ) { fLambdaCheckLimit  = f;     }
    214   void SetNamePedestalCam   ( const char *name=fgNamePedestalCam.Data()) { fNamePedestalCam   = name;  }
    215   void SetOutputPath        ( TString path="."                   );
    216   void SetOutputFile        ( TString file="ChargeCalibStat.txt" );
    217   void SetPheErrLowerLimit  ( const Float_t f=fgPheErrLowerLimit       ) { fPheErrLowerLimit  = f;     }
    218   void SetPheErrUpperLimit  ( const Float_t f=fgPheErrUpperLimit       ) { fPheErrUpperLimit  = f;     }
    219   void SetPulserColor       ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;   }
    220   void SetUseExtractorRes(Bool_t b=kTRUE) { fUseExtractorRes = b; }
    221 
    222   ClassDef(MCalibrationChargeCalc, 3)   // Task calculating Calibration Containers and Quantum Efficiencies
     225  ClassDef(MCalibrationChargeCalc, 4)   // Task calculating Calibration Containers and Quantum Efficiencies
    223226};
    224227
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h

    r7188 r7189  
    188188  Bool_t CalcMeanFFactor(const Float_t nphotons, const Float_t nphotonsrelvar);
    189189 
    190   ClassDef(MCalibrationChargePix, 3)    // Container Charge Calibration Results Pixel
     190  ClassDef(MCalibrationChargePix, 4)    // Container Charge Calibration Results Pixel
    191191};
    192192
  • trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc

    r7005 r7189  
    4141//           MCalibrationChargeBlindPix, MCalibrationChargePINDiode
    4242//
     43// Inline Functions:
     44// -----------------
     45//
     46// GetSize(): Returns the current size of the TOrdCollection fCams
     47//  independently if the MCalibrationCam is filled with values or not.
     48//
     49// GetAverageAreas(): Returns the current size of the TOrdCollection
     50//  fAverageAreas of the current camera.
     51//
     52// GetAverageArea(UInt_t i): Get i-th High Gain pixel Area from the
     53//  current camera
     54//
     55// GetAverageArea(UInt_t i): Get i-th High Gain pixel Area from the
     56//  current camera
     57//
     58// GetAverageBadArea(UInt_t i): Get i-th High Gain pixel Area from the
     59//  current camera
     60//
     61// GetAverageBadArea(UInt_t i): Get i-th High Gain pixel Area from the
     62//  current camera
     63//
     64// GetAverageSectors(): Returns the current size of the TOrdCollection
     65//  fAverageSectors or the current camera
     66//
     67// GetAverageSector(UInt_t i): Get i-th High Gain Sector from the
     68//  current camera
     69//
     70// GetAverageSector(UInt_t i): Get i-th High Gain Sector from the current
     71//  camera
     72//
     73// GetAverageBadSector(UInt_t i): Get i-th High Gain Sector from the
     74//  current camera
     75//
     76// GetAverageBadSector(UInt_t i): Get i-th High Gain Sector from the
     77//  current camera
     78//
     79//
    4380// ClassVersion 2:
    4481//  + fHists
     82//
     83// ClassVersion 3:
     84//  - MArrayD fOffsets;           //! Arrays of Higain-vs-LoGain fit result Offsets
     85//  - MArrayD fSlopes;            //! Arrays of Higain-vs-LoGain fit result Slopes
    4586//
    4687/////////////////////////////////////////////////////////////////////////////
     
    127168
    128169    MParContainer::Copy(calib);
    129 
    130     calib.fOffsets = fOffsets;
    131     calib.fSlopes  = fSlopes;
    132170
    133171    const UInt_t n = GetSize();
     
    163201}
    164202
    165 // -----------------------------------------------------
    166 //
    167 // Not yet installed...
    168 //
    169 void MCalibrationIntensityCam::DrawHiLoFits()
    170 {
    171 
    172   /*
    173   if (!fOffsets)
    174     fOffsets = new TH1D("pp","Offsets of the HiGain LoGain Fit",100,-600.,400.);
    175   if (!fSlopes)
    176     fSlopes  = new TH1D("mm","Slopes of the HiGain LoGain Fit",100,-2.,2.);
    177   if (!fOffvsSlope)
    178     fOffvsSlope = new TH2D("aa","Slopes vs Offsets of the HiGain LoGain Fit",100,-600.,400.,100,-2.,2.);
    179  
    180   TIter Next(fPixels);
    181   MCalibrationPix *pix;
    182   MHCalibrationPixel *hist;
    183   while ((pix=(MCalibrationPix*)Next()))
    184     {
    185       hist = pix->GetHist();
    186       hist->FitHiGainvsLoGain();
    187       fOffsets->Fill(hist->GetOffset(),1.);
    188       fSlopes->Fill(hist->GetSlope(),1.);
    189       fOffvsSlope->Fill(hist->GetOffset(),hist->GetSlope(),1.);
    190     }
    191 
    192    TCanvas *c1 = new TCanvas();
    193 
    194    c1->Divide(1,3);
    195    c1->cd(1);
    196    fOffsets->Draw();
    197    gPad->Modified();
    198    gPad->Update();
    199 
    200    c1->cd(2);
    201   fSlopes->Draw();
    202   gPad->Modified();
    203   gPad->Update();
    204 
    205   c1->cd(3);
    206   fOffvsSlope->Draw("col1");
    207   gPad->Modified();
    208   gPad->Update();
    209   */
    210 }
    211 
    212203// -------------------------------------------------------------------
    213204//
     
    256247}
    257248
    258 
    259 // --------------------------------------------------------------------------
    260 //
    261 // Returns the current size of the TOrdCollection fCams
    262 // independently if the MCalibrationCam is filled with values or not.
    263 //
    264 const Int_t MCalibrationIntensityCam::GetSize() const
    265 {
    266   return fCams->GetSize();
    267 }
    268 
    269 // --------------------------------------------------------------------------
    270 //
    271 // Get i-th pixel from current camera
    272 //
    273 MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
    274 {
    275   return (*GetCam())[i];
    276 }
    277 
    278 // --------------------------------------------------------------------------
    279 //
    280 // Get i-th pixel from current camera
    281 //
    282 const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const
    283 {
    284   return (*GetCam())[i];
    285 }
    286 
    287 
    288 // --------------------------------------------------------------------------
    289 //
    290 // Returns the current size of the TOrdCollection fAverageAreas of the current camera.
    291 //
    292 const Int_t MCalibrationIntensityCam::GetAverageAreas() const
    293 {
    294   return GetCam()->GetAverageAreas();
    295 }
    296 
    297 // --------------------------------------------------------------------------
    298 //
    299 // Get i-th High Gain pixel Area from the current camera
    300 //
    301 MCalibrationPix  &MCalibrationIntensityCam::GetAverageArea(UInt_t i)
    302 {
    303   return GetCam()->GetAverageArea(i);
    304 }
    305 
    306 // --------------------------------------------------------------------------
    307 //
    308 // Get i-th High Gain pixel Area from the current camera
    309 //
    310 const MCalibrationPix  &MCalibrationIntensityCam::GetAverageArea(UInt_t i) const
    311 {
    312   return GetCam()->GetAverageArea(i);
    313 }
    314 
    315 // --------------------------------------------------------------------------
    316 //
    317 // Get i-th High Gain pixel Area from the current camera
    318 //
    319 MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i)
    320 {
    321   return GetCam()->GetAverageBadArea(i);
    322 }
    323 
    324 // --------------------------------------------------------------------------
    325 //
    326 // Get i-th High Gain pixel Area from the current camera
    327 //
    328 const MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i) const
    329 {
    330   return GetCam()->GetAverageBadArea(i);
    331 }
    332 
    333 // --------------------------------------------------------------------------
    334 //
    335 // Returns the current size of the TOrdCollection fAverageSectors or the current camera
    336 //
    337 const Int_t MCalibrationIntensityCam::GetAverageSectors() const
    338 {
    339   return GetCam()->GetAverageSectors();
    340 }
    341 
    342 // --------------------------------------------------------------------------
    343 //
    344 // Get i-th High Gain Sector from the current camera
    345 //
    346 MCalibrationPix  &MCalibrationIntensityCam::GetAverageSector(UInt_t i)
    347 {
    348   return GetCam()->GetAverageSector(i);
    349 }
    350 
    351 // --------------------------------------------------------------------------
    352 //
    353 // Get i-th High Gain Sector from the current camera
    354 //
    355 const MCalibrationPix  &MCalibrationIntensityCam::GetAverageSector(UInt_t i) const
    356 {
    357   return GetCam()->GetAverageSector(i);
    358 }
    359 
    360 // --------------------------------------------------------------------------
    361 //
    362 // Get i-th High Gain Sector from the current camera
    363 //
    364 MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i)
    365 {
    366   return GetCam()->GetAverageBadSector(i);
    367 }
    368 
    369 // --------------------------------------------------------------------------
    370 //
    371 // Get i-th High Gain Sector from the current camera
    372 //
    373 const MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i) const
    374 {
    375   return GetCam()->GetAverageBadSector(i);
    376 }
    377 
    378 
    379 // --------------------------------------------------------------------------
    380 //
    381 // Get i-th camera
    382 //
    383 MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i)
    384 {
    385   return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
    386 }
    387 
    388 // --------------------------------------------------------------------------
    389 //
    390 // Get i-th camera
    391 //
    392 const MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i) const
    393 {
    394   return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
    395 }
    396 
    397 // --------------------------------------------------------------------------
    398 //
    399 // Get camera with name 'name'
    400 //
    401 MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name )
    402 {
    403   return static_cast<MCalibrationCam*>(fCams->FindObject(name));
    404 }
    405 
    406 // --------------------------------------------------------------------------
    407 //
    408 // Get camera with name 'name'
    409 //
    410 const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name ) const
    411 {
    412   return static_cast<MCalibrationCam*>(fCams->FindObject(name));
    413 }
    414 
    415 // --------------------------------------------------------------------------
    416 //
    417 // Calls GetPixelContent for the current entry in fCams
    418 //
    419 Bool_t MCalibrationIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
    420 {
    421   return GetCam()->GetPixelContent(val,idx,cam,type);
    422 }
    423 
    424 // --------------------------------------------------------------------------
    425 //
    426 // Calls DrawPixelContent for the current entry in fCams
    427 //
    428 void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
    429 {
    430   return GetCam()->DrawPixelContent(num);
    431 }
    432 
    433 Int_t MCalibrationIntensityCam::CountNumEntries(const MCalibrationCam::PulserColor_t col) const
     249// --------------------------------------------------------------------------
     250//
     251Int_t MCalibrationIntensityCam::CountNumEntries(const MCalibrationCam::PulserColor_t col) const
    434252{
    435253 
     
    451269// --------------------------------------------------------------------------
    452270//
     271// Get i-th pixel from current camera
     272//
     273MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
     274{
     275  return (*GetCam())[i];
     276}
     277
     278// --------------------------------------------------------------------------
     279//
     280// Get i-th pixel from current camera
     281//
     282const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const
     283{
     284  return (*GetCam())[i];
     285}
     286
     287// --------------------------------------------------------------------------
     288//
     289// Get camera with name 'name'
     290//
     291MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name)
     292{
     293  return static_cast<MCalibrationCam*>(fCams->FindObject(name));
     294}
     295
     296// --------------------------------------------------------------------------
     297//
     298// Get camera with name 'name'
     299//
     300const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name) const
     301{
     302  return static_cast<MCalibrationCam*>(fCams->FindObject(name));
     303}
     304
     305// --------------------------------------------------------------------------
     306//
    453307// Get i-th histogram class
    454308//
    455309MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i)
    456310{
    457     return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
    458 }
    459 
    460 // --------------------------------------------------------------------------
    461 //
    462 // Get i-th histogram class
    463 //
    464 const MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i) const
    465 {
    466     return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
    467 }
    468 
    469 // --------------------------------------------------------------------------
    470 //
    471 // Get histogram class with name 'name'
     311  return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
     312}
     313
     314// --------------------------------------------------------------------------
     315//
     316// Get i-th histogram class 
     317//
     318const MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i) const 
     319{
     320  return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
     321}
     322
     323// --------------------------------------------------------------------------
     324//
     325// Get histogram class with name 'name' 
    472326//
    473327MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name )
     
    478332// --------------------------------------------------------------------------
    479333//
    480 // Get histogram class with name 'name'
    481 //
    482 const MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name ) const
    483 {
    484     return static_cast<MHCalibrationCam*>(fHists->FindObject(name));
    485 }
     334// Get histogram class with name 'name'
     335//
     336const MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name ) const
     337{
     338  return static_cast<MHCalibrationCam*>(fHists->FindObject(name));
     339}
     340
     341// --------------------------------------------------------------------------
     342//
     343// Calls DrawPixelContent for the current entry in fCams
     344//
     345void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
     346{
     347  return GetCam()->DrawPixelContent(num);
     348}
  • trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h

    r7005 r7189  
    1414#endif
    1515
    16 class TOrdCollection;
     16#ifndef ROOT_TOrdCollection
     17#include <TOrdCollection.h>
     18#endif
     19
    1720class MCalibrationPix;
    1821class MBadPixelsPix;
     
    2225class MCalibrationIntensityCam : public MParContainer, public MCamEvent
    2326{
    24 private:
    25   MArrayD fOffsets;        //! Arrays of Higain-vs-LoGain fit result Offsets
    26   MArrayD fSlopes;         //! Arrays of Higain-vs-LoGain fit result Slopes
    27 
    2827protected: 
    2928  TOrdCollection *fCams;   // Array of MCalibrationCams, one per pulse colour and intensity
     
    4544  Int_t CountNumEntries(const MCalibrationCam::PulserColor_t col) const; 
    4645
    47   // Draws
    48   void DrawHiLoFits();
    49   void DrawPixelContent( Int_t num) const;
    50  
    51   // Getters
    52   Bool_t GetPixelContent( Double_t &val, Int_t idx, const MGeomCam &cam,Int_t type=0) const;
    53   const Int_t GetSize() const;
     46  const Int_t GetSize() const  { return fCams->GetSize();  }
    5447
    55   const Int_t            GetAverageAreas     ()            const;       
    56         MCalibrationPix &GetAverageArea      ( UInt_t i );
    57   const MCalibrationPix &GetAverageArea      ( UInt_t i )  const;
    58         MBadPixelsPix   &GetAverageBadArea   ( UInt_t i );
    59   const MBadPixelsPix   &GetAverageBadArea   ( UInt_t i )  const;
    60   const Int_t            GetAverageSectors   ()            const;
    61         MCalibrationPix &GetAverageSector    ( UInt_t i );
    62   const MCalibrationPix &GetAverageSector    ( UInt_t i )  const;
    63         MBadPixelsPix   &GetAverageBadSector ( UInt_t i );
    64   const MBadPixelsPix   &GetAverageBadSector ( UInt_t i )  const;
     48  const Int_t            GetAverageAreas     ()            const   { return GetCam()->GetAverageAreas(); }
     49        MCalibrationPix &GetAverageArea      ( UInt_t i )          { return GetCam()->GetAverageArea(i);  }
     50  const MCalibrationPix &GetAverageArea      ( UInt_t i )  const   { return GetCam()->GetAverageArea(i);  }
     51        MBadPixelsPix   &GetAverageBadArea   ( UInt_t i )          { return GetCam()->GetAverageBadArea(i); } 
     52  const MBadPixelsPix   &GetAverageBadArea   ( UInt_t i )  const   { return GetCam()->GetAverageBadArea(i); }
     53  const Int_t            GetAverageSectors   ()            const   { return GetCam()->GetAverageSectors();  }
     54        MCalibrationPix &GetAverageSector    ( UInt_t i )          { return GetCam()->GetAverageSector(i);  }
     55  const MCalibrationPix &GetAverageSector    ( UInt_t i )  const   { return GetCam()->GetAverageSector(i);  }
     56        MBadPixelsPix   &GetAverageBadSector ( UInt_t i )          { return GetCam()->GetAverageBadSector(i); }
     57  const MBadPixelsPix   &GetAverageBadSector ( UInt_t i )  const   { return GetCam()->GetAverageBadSector(i); }
    6558
    66         MCalibrationCam *GetCam              ( Int_t i=-1);
    67   const MCalibrationCam *GetCam              ( Int_t i=-1) const;
     59        MCalibrationCam *GetCam              ( Int_t i=-1)       {
     60        return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i)); }
     61  const MCalibrationCam *GetCam              ( Int_t i=-1) const {
     62        return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i)); }
    6863
    6964        MCalibrationCam *GetCam              ( const char *name );
    7065  const MCalibrationCam *GetCam              ( const char *name ) const;
    7166
    72         MHCalibrationCam *GetHist            ( Int_t i=-1);
     67        MHCalibrationCam *GetHist            ( Int_t i=-1);     
    7368  const MHCalibrationCam *GetHist            ( Int_t i=-1) const;
    7469
    75         MHCalibrationCam *GetHist            ( const char *name );
     70        MHCalibrationCam *GetHist            ( const char *name );     
    7671  const MHCalibrationCam *GetHist            ( const char *name ) const;
    7772
     
    8782  void  Init   ( const MGeomCam &geom );
    8883 
    89   // Prints
     84   // Prints
    9085  void   Print(Option_t *o="")         const;
    9186
     
    9691  void  SetNumUnreliable      ( const UInt_t i,  const Int_t aidx  ) { GetCam()->SetNumUnreliable(i,aidx);       }
    9792  void  SetPulserColor        ( const MCalibrationCam::PulserColor_t col=MCalibrationCam::kCT1) {
    98                                                                 GetCam()->SetPulserColor(col);            }
     93                                                                       GetCam()->SetPulserColor(col);            }
     94  void  SetCam( MCalibrationCam *cam, const Int_t i)                 {  fCams->PutAt(cam,i);  }
     95 
     96  // MCamEvent
     97  Bool_t GetPixelContent( Double_t &val, Int_t idx, const MGeomCam &cam,Int_t type=0) const
     98        { return GetCam()->GetPixelContent(val,idx,cam,type);  }
     99  void DrawPixelContent( Int_t num) const;
    99100
    100   ClassDef(MCalibrationIntensityCam, 2) // Base Container Intensity Calibration Results
     101  ClassDef(MCalibrationIntensityCam, 3) // Base Container Intensity Calibration Results
    101102};
    102103
Note: See TracChangeset for help on using the changeset viewer.