Changeset 3479


Ignore:
Timestamp:
03/11/04 18:27:42 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3476 r3479  
    5858     - added Print function
    5959
    60 
     60   * mcalib/MCalibrationChargeCam.[h,cc]
     61   * mcalib/MCalibrationChargePix.h
     62   * mcalib/MCalibrationChargeCalc.cc
     63     - removed pointers to MGeomCam and MBadPixelsCam in MCalibrationChargeCam
     64     - use two loops over pixels in order to determine mean flux of phe;s to
     65       discard pixels far outside the normal distribution
    6166
    6267 2004/03/10: Abelardo Moralejo
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc

    r3477 r3479  
    1717!
    1818!   Author(s): Thomas Bretz 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!              Markus Gaug  3/2004 <mailto:markus@ifae.es>
    1920!
    2021!   Copyright: MAGIC Software Development, 2000-2004
     
    225226
    226227        if (!(count % 25))
    227             *fLog << endl;
    228     }
     228          *fLog << endl;
     229    }
     230
    229231    *fLog << endl;
    230232    *fLog << count << " unreliable pixels :-(" << endl;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r3455 r3479  
    331331    }
    332332
    333   fCam->SetGeomCam(fGeom);
    334   fCam->SetBadPixelsCam(fBadPixels);
    335 
    336333  fNumHiGainSamples  =  fSignals->GetNumUsedHiGainFADCSlices();
    337334  fNumLoGainSamples  =  fSignals->GetNumUsedLoGainFADCSlices();
     
    437434      }
    438435
    439       pix.CheckChargeValidity(&bad);
    440       pix.CheckTimeValidity(&bad);
     436      pix.CheckChargeValidity (&bad);
     437      pix.CheckTimeValidity   (&bad);
    441438     
    442       if (bad.IsUnsuitableRun())
     439      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
    443440        continue;
    444 
     441     
    445442      nvalid++;
    446443
    447444      if (!pix.CalcReducedSigma())
    448445        {
    449           bad.SetUnsuitableRun();
     446          bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
    450447          continue;
    451448        }
    452449     
    453       pix.CalcFFactorMethod();
    454     }
    455 
     450      if (!pix.CalcFFactorMethod())
     451        bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
     452
     453    }
     454 
    456455
    457456
     
    525524  // F-Factor calibration
    526525  //
    527   if (fCam->CalcMeanFluxPhotonsFFactorMethod())
    528   {
    529     fCam->ApplyFFactorCalibration();
     526  if (fCam->CalcMeanFluxPhotonsFFactorMethod(*fGeom, *fBadPixels))
     527  {
     528    fCam->ApplyFFactorCalibration(*fGeom,*fBadPixels);
    530529    fCam->SetFFactorMethodValid(kTRUE);
    531530  }
     
    536535    }
    537536 
    538 
    539 
    540537  //
    541538  // Blind Pixel calibration
     
    558555      {
    559556          fCam->SetBlindPixelMethodValid(kTRUE);
    560           fCam->ApplyBlindPixelCalibration();
     557          fCam->ApplyBlindPixelCalibration(*fGeom,*fBadPixels);
    561558      }
    562559  }
     
    582579      {
    583580          fCam->SetPINDiodeMethodValid(kTRUE);
    584           fCam->ApplyPINDiodeCalibration();
     581          fCam->ApplyPINDiodeCalibration(*fGeom,*fBadPixels);
    585582      }
    586583  }
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc

    r3455 r3479  
    8686// 27: Excluded Pixels
    8787// 28: Pixels where the fit did not succeed --> results obtained only from the histograms
    88 // 29: Pixels with apparently wrong results
    89 // 30: Pixels with un-expected behavior in the Hi Gain fourier spectrum (e.g. oscillations)
    90 // 31: Pixels with un-expected behavior in the Lo Gain fourier spectrum (e.g. oscillations)a
    91 // 32: Number of probable pickup events in the Hi Gain
    92 // 33: Number of probable pickup events in the Lo Gain
     88// 29: Number of probable pickup events in the Hi Gain
     89// 30: Number of probable pickup events in the Lo Gain
    9390//
    9491// Other classifications of pixels:
    9592// ================================
    9693//
    97 // 34: Pixels with saturated Hi-Gain
     94// 31: Pixels with saturated Hi-Gain
    9895//
    9996// Classification of validity of the calibrations:
    10097// ===============================================
    10198//
    102 // 35: Pixels with valid calibration by the F-Factor-Method
    103 // 36: Pixels with valid calibration by the Blind Pixel-Method
    104 // 37: Pixels with valid calibration by the PIN Diode-Method
     99// 32: Pixels with valid calibration by the F-Factor-Method
     100// 33: Pixels with valid calibration by the Blind Pixel-Method
     101// 34: Pixels with valid calibration by the PIN Diode-Method
    105102//
    106103// Used Pedestals:
    107104// ===============
    108105//
    109 // 38: Mean Pedestal over the entire range of signal extraction
    110 // 39: Error on the Mean Pedestal over the entire range of signal extraction
    111 // 40: Pedestal RMS over the entire range of signal extraction
    112 // 41: Error on the Pedestal RMS over the entire range of signal extraction
     106// 35: Mean Pedestal over the entire range of signal extraction
     107// 36: Error on the Mean Pedestal over the entire range of signal extraction
     108// 37: Pedestal RMS over the entire range of signal extraction
     109// 38: Error on the Pedestal RMS over the entire range of signal extraction
    113110//
    114111// Calculated absolute arrival times (very low precision!):
    115112// ========================================================
    116113//
    117 // 42: Absolute Arrival time of the signal
    118 // 43: RMS of the Absolute Arrival time of the signal
     114// 39: Absolute Arrival time of the signal
     115// 40: RMS of the Absolute Arrival time of the signal
    119116//
    120117/////////////////////////////////////////////////////////////////////////////
     
    145142const Float_t MCalibrationChargeCam::gkAverageQEErr             = 0.02; 
    146143const Float_t MCalibrationChargeCam::fgConvFFactorRelErrLimit   = 0.25;
     144const Float_t MCalibrationChargeCam::fgPheFFactorRelLimit       = 5.;
    147145// --------------------------------------------------------------------------
    148146//
     
    155153//
    156154MCalibrationChargeCam::MCalibrationChargeCam(const char *name, const char *title)
    157     : fBlindPixel(NULL),
    158       fPINDiode(NULL),
    159       fGeomCam(NULL),
    160       fBadPixels(NULL),
    161       fOffsets(NULL),
     155    : fOffsets(NULL),
    162156      fSlopes(NULL),
    163157      fOffvsSlope(NULL)
     
    176170    SetAverageQE();
    177171    SetConvFFactorRelErrLimit();
     172    SetPheFFactorRelLimit();
    178173}
    179174
     
    316311  int id = 0;
    317312 
    318   *fLog << all << "Succesfully calibrated pixels:" << endl;
     313  *fLog << all << "Calibrated pixels:" << endl;
    319314  *fLog << all << endl;
    320315
     
    324319    {
    325320     
    326       if ((*fBadPixels)[pix->GetPixId()].IsCalibrationResultOK() && !pix->IsExcluded())
     321      if (!pix->IsExcluded())
    327322        {                           
    328323
    329             *fLog << all << "Pix " << pix->GetPixId()
    330                 << ":  Ped.  Rms: "            << pix->GetPedRms()        << " +- " << pix->GetPedRmsErr()
     324          *fLog << all << "Pix " << pix->GetPixId()
     325                << ":  Ped.  Rms: "            << pix->GetPedRms()        << " +- " << pix->GetPedRmsErr()
    331326                << "   Mean signal: "          << pix->GetMeanCharge()    << " +- " << pix->GetSigmaCharge()
    332327                << "   Reduced Sigma: "        << pix->GetRSigmaCharge()
     
    338333    }
    339334 
    340   *fLog << all << id << " succesful pixels :-))" << endl;
     335  *fLog << all << id << " pixels" << endl;
    341336  id = 0;
    342337 
    343   *fLog << all << endl;
    344   *fLog << all << "Pixels with errors:" << endl;
    345   *fLog << all << endl;
    346  
    347   TIter Next2(fPixels);
    348     while ((pix=(MCalibrationChargePix*)Next2()))
    349       {
    350        
    351         if (!pix->IsExcluded() && !(*fBadPixels)[pix->GetPixId()].IsCalibrationResultOK())
    352           {
    353 
    354 
    355             *fLog << all << "Pix " << pix->GetPixId()
    356                 << ":  Ped.  Rms: "            << pix->GetPedRms()        << " +- " << pix->GetPedRmsErr()
    357                 << "   Mean signal: "          << pix->GetMeanCharge()    << " +- " << pix->GetSigmaCharge()
    358                 << "   Reduced Sigma: "        << pix->GetRSigmaCharge()
    359                 << "   Nr Phe's: "             << pix->GetPheFFactorMethod()
    360                 << " Saturated? :" << pix->IsHiGainSaturation()
    361                 << endl;
    362             id++;
    363           }
    364       }
    365     *fLog << all << id << " pixels with errors :-((" << endl;
    366 
    367   *fLog << all << endl;
    368   *fLog << all << "Pixels with oscillations:" << endl;
    369   *fLog << all << endl;
    370  
    371   id = 0;
    372 
    373   TIter Next3(fPixels);
    374   while ((pix=(MCalibrationChargePix*)Next3()))
    375     {
    376 
    377       if ( (*fBadPixels)[pix->GetPixId()].IsCalibrationOscillating()  && !pix->IsExcluded())
    378         {
    379 
    380             *fLog << all << "Pix " << pix->GetPixId()
    381                 << ":  Ped.  Rms: "            << pix->GetPedRms()        << " +- " << pix->GetPedRmsErr()
    382                 << "   Mean signal: "          << pix->GetMeanCharge()    << " +- " << pix->GetSigmaCharge()
    383                 << "   Reduced Sigma: "        << pix->GetRSigmaCharge()
    384                 << "   Nr Phe's: "             << pix->GetPheFFactorMethod()
    385                 << " Saturated? :" << pix->IsHiGainSaturation()
    386                 << endl;
    387             id++;
    388         }
    389     }
    390   *fLog << all << id << " Oscillating pixels :-((" << endl;
    391  
    392    
     338   
    393339  *fLog << all << endl;
    394340  *fLog << all << "Excluded pixels:" << endl;
     
    408354  *fLog << all << id << " Excluded pixels " << endl;
    409355  *fLog << endl;
     356
    410357  *fLog << all << "Average Inner Pix:"
    411358                << "   Ped.  Rms: "            << fAverageInnerPix->GetPedRms()        << " +- " << fAverageInnerPix->GetPedRmsErr()
     
    474421// 27: Excluded Pixels
    475422// 28: Pixels where the fit did not succeed --> results obtained only from the histograms
    476 // 29: Pixels with apparently wrong results
    477 // 30: Pixels with un-expected behavior in the Hi Gain fourier spectrum (e.g. oscillations)
    478 // 31: Pixels with un-expected behavior in the Lo Gain fourier spectrum (e.g. oscillations)a
    479 // 32: Number of probable pickup events in the Hi Gain
    480 // 33: Number of probable pickup events in the Lo Gain
     423// 29: Number of probable pickup events in the Hi Gain
     424// 30: Number of probable pickup events in the Lo Gain
    481425//
    482426// Other classifications of pixels:
    483427// ================================
    484428//
    485 // 34: Pixels with saturated Hi-Gain
     429// 31: Pixels with saturated Hi-Gain
    486430//
    487431// Classification of validity of the calibrations:
    488432// ===============================================
    489433//
    490 // 35: Pixels with valid calibration by the F-Factor-Method
    491 // 36: Pixels with valid calibration by the Blind Pixel-Method
    492 // 37: Pixels with valid calibration by the PIN Diode-Method
     434// 32: Pixels with valid calibration by the F-Factor-Method
     435// 33: Pixels with valid calibration by the Blind Pixel-Method
     436// 34: Pixels with valid calibration by the PIN Diode-Method
    493437//
    494438// Used Pedestals:
    495439// ===============
    496440//
    497 // 38: Mean Pedestal over the entire range of signal extraction
    498 // 39: Error on the Mean Pedestal over the entire range of signal extraction
    499 // 40: Pedestal RMS over the entire range of signal extraction
    500 // 41: Error on the Pedestal RMS over the entire range of signal extraction
     441// 35: Mean Pedestal over the entire range of signal extraction
     442// 36: Error on the Mean Pedestal over the entire range of signal extraction
     443// 37: Pedestal RMS over the entire range of signal extraction
     444// 38: Error on the Pedestal RMS over the entire range of signal extraction
    501445//
    502446// Calculated absolute arrival times (very low precision!):
    503447// ========================================================
    504448//
    505 // 42: Absolute Arrival time of the signal
    506 // 43: RMS of the Absolute Arrival time of the signal
     449// 39: Absolute Arrival time of the signal
     450// 40: RMS of the Absolute Arrival time of the signal
    507451//
    508452Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
     
    540484      break;
    541485    case 4:
    542       if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK())
     486      if ((*this)[idx].IsExcluded())
    543487        return kFALSE;
    544488      val = (*this)[idx].GetChargeProb();
    545489      break;
    546490    case 5:
    547       if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK())
     491      if ((*this)[idx].IsExcluded())
    548492        return kFALSE;
    549493      if ((*this)[idx].GetRSigmaCharge() == -1.)
     
    552496      break;
    553497    case 6:
    554       if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK())
     498      if ((*this)[idx].IsExcluded())
    555499        return kFALSE;   
    556500      if ((*this)[idx].GetRSigmaCharge() == -1.)
     
    559503      break;
    560504    case 7:
    561       if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK())
     505      if ((*this)[idx].IsExcluded())
    562506        return kFALSE;
    563507      if ((*this)[idx].GetRSigmaCharge() == -1.)
     
    566510      break;
    567511    case 8:
    568       if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK())
     512      if ((*this)[idx].IsExcluded())
    569513        return kFALSE;
    570514      if ((*this)[idx].GetRSigmaCharge() == -1.)
     
    582526      break;
    583527    case 9:
    584       if ((*this)[idx].IsExcluded()
    585           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    586           || !(*this)[idx].IsFFactorMethodValid())
     528      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsFFactorMethodValid())
    587529        return kFALSE;
    588530      val = (*this)[idx].GetPheFFactorMethod();
    589531      break;
    590532    case 10:
    591       if ((*this)[idx].IsExcluded()
    592           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    593           || !(*this)[idx].IsFFactorMethodValid())
     533      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsFFactorMethodValid())
    594534        return kFALSE;
    595535      val = (*this)[idx].GetPheFFactorMethodErr();
    596536      break;
    597537    case 11:
    598       if ((*this)[idx].IsExcluded()
    599           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    600           || !(*this)[idx].IsFFactorMethodValid())
     538      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsFFactorMethodValid())
    601539        return kFALSE;
    602540      val = (*this)[idx].GetMeanConversionFFactorMethod();
    603541      break;
    604542    case 12:
    605       if ((*this)[idx].IsExcluded()
    606           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    607           || !(*this)[idx].IsFFactorMethodValid())
     543      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsFFactorMethodValid())
    608544        return kFALSE;
    609545      val = (*this)[idx].GetConversionFFactorMethodErr();
    610546      break;
    611547    case 13:
    612       if ((*this)[idx].IsExcluded()
    613           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    614           || !(*this)[idx].IsFFactorMethodValid())
     548      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsFFactorMethodValid())
    615549        return kFALSE;
    616550      val = (*this)[idx].GetTotalFFactorFFactorMethod();
    617551      break;
    618552    case 14:
    619       if ((*this)[idx].IsExcluded()
    620           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    621           || !(*this)[idx].IsFFactorMethodValid())
     553      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsFFactorMethodValid())
    622554        return kFALSE;
    623555      val = (*this)[idx].GetTotalFFactorErrFFactorMethod();
    624556      break;
    625557    case 15:
    626       if ((*this)[idx].IsExcluded()
    627           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    628           || !(*this)[idx].IsBlindPixelMethodValid())
     558      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
    629559        return kFALSE;
    630560      val = fBlindPixel->GetMeanFluxInsidePlexiglass()*area;
    631561      break;
    632562    case 16:
    633       if ((*this)[idx].IsExcluded()
    634           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    635           || !(*this)[idx].IsBlindPixelMethodValid())
     563      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
    636564        return kFALSE;
    637565      val = fBlindPixel->GetMeanFluxErrInsidePlexiglass()*area;
    638566      break;
    639567    case 17:
    640       if ((*this)[idx].IsExcluded()
    641           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    642           || !(*this)[idx].IsBlindPixelMethodValid())
     568      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
    643569        return kFALSE;
    644570      val = (*this)[idx].GetMeanConversionBlindPixelMethod();
    645571      break;
    646572    case 18:
    647       if ((*this)[idx].IsExcluded()
    648           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    649           || !(*this)[idx].IsBlindPixelMethodValid())
     573      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
    650574        return kFALSE;
    651575      val = (*this)[idx].GetConversionBlindPixelMethodErr();
    652576      break;
    653577    case 19:
    654       if ((*this)[idx].IsExcluded()
    655           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    656           || !(*this)[idx].IsBlindPixelMethodValid())
     578      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
    657579        return kFALSE;
    658580      val = (*this)[idx].GetTotalFFactorBlindPixelMethod();
    659581      break;
    660582    case 20:
    661       if ((*this)[idx].IsExcluded()
    662           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    663           || !(*this)[idx].IsBlindPixelMethodValid())
     583      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsBlindPixelMethodValid())
    664584        return kFALSE;
    665585      val = (*this)[idx].GetTotalFFactorErrBlindPixelMethod();
    666586      break;
    667587    case 21:
    668       if ((*this)[idx].IsExcluded()
    669           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    670           || !(*this)[idx].IsPINDiodeMethodValid())
     588      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
    671589        return kFALSE;
    672590      val = fPINDiode->GetMeanFluxOutsidePlexiglass()*area;
    673591      break;
    674592    case 22:
    675       if ((*this)[idx].IsExcluded()
    676           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    677           || !(*this)[idx].IsPINDiodeMethodValid())
     593      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
    678594        return kFALSE;
    679595      val = fPINDiode->GetMeanFluxErrOutsidePlexiglass()*area;
    680596      break;
    681597    case 23:
    682       if ((*this)[idx].IsExcluded()
    683           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    684           || !(*this)[idx].IsPINDiodeMethodValid())
     598      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
    685599        return kFALSE;
    686600      val = (*this)[idx].GetMeanConversionPINDiodeMethod();
    687601      break;
    688602    case 24:
    689       if ((*this)[idx].IsExcluded()
    690           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    691           || !(*this)[idx].IsPINDiodeMethodValid())
     603      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
    692604        return kFALSE;
    693605      val = (*this)[idx].GetConversionPINDiodeMethodErr();
    694606      break;
    695607    case 25:
    696       if ((*this)[idx].IsExcluded()
    697           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    698           || !(*this)[idx].IsPINDiodeMethodValid())
     608      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
    699609        return kFALSE;
    700610      val = (*this)[idx].GetTotalFFactorPINDiodeMethod();
    701611      break;
    702612    case 26:
    703       if ((*this)[idx].IsExcluded()
    704           || !(*fBadPixels)[idx].IsCalibrationSignalOK()
    705           || !(*this)[idx].IsPINDiodeMethodValid())
     613      if ((*this)[idx].IsExcluded() || !(*this)[idx].IsPINDiodeMethodValid())
    706614        return kFALSE;
    707615      val = (*this)[idx].GetTotalFFactorErrPINDiodeMethod();
     
    724632      if ((*this)[idx].IsExcluded())
    725633        return kFALSE;
    726       if (!(*fBadPixels)[idx].IsCalibrationSignalOK())
    727         val = 1;
    728       else
    729         return kFALSE;
     634      val = (*this)[idx].GetHiGainNumPickup();
    730635      break;
    731636    case 30:
    732637      if ((*this)[idx].IsExcluded())
    733638        return kFALSE;
    734       if ((*fBadPixels)[idx].IsCalibrationOscillating())
    735         val = 1;
    736       else
    737         return kFALSE;
     639      val = (*this)[idx].GetLoGainNumPickup();
    738640      break;
    739641    case 31:
    740642      if ((*this)[idx].IsExcluded())
    741643        return kFALSE;
    742       if ((*fBadPixels)[idx].IsCalibrationOscillating())
    743         val = 1;
    744       else
    745         return kFALSE;
     644      val = (*this)[idx].IsHiGainSaturation();
    746645      break;
    747646    case 32:
    748       if ((*this)[idx].IsExcluded())
    749         return kFALSE;
    750       val = (*this)[idx].GetHiGainNumPickup();
    751       break;
    752     case 33:
    753       if ((*this)[idx].IsExcluded())
    754         return kFALSE;
    755       val = (*this)[idx].GetLoGainNumPickup();
    756       break;
    757     case 34:
    758       if ((*this)[idx].IsExcluded())
    759         return kFALSE;
    760       val = (*this)[idx].IsHiGainSaturation();
    761       break;
    762     case 35:
    763647      if ((*this)[idx].IsExcluded())
    764648        return kFALSE;
     
    768652        return kFALSE;
    769653      break;
    770     case 36:
     654    case 33:
    771655      if ((*this)[idx].IsExcluded())
    772656        return kFALSE;
     
    776660        return kFALSE;
    777661      break;
    778     case 37:
     662    case 34:
    779663      if ((*this)[idx].IsExcluded())
    780664        return kFALSE;
     
    784668        return kFALSE;
    785669      break;
     670    case 35:
     671      if ((*this)[idx].IsExcluded())
     672        return kFALSE;
     673      val = (*this)[idx].GetPed();
     674      break;
     675    case 36:
     676      if ((*this)[idx].IsExcluded())
     677        return kFALSE;
     678      val = (*this)[idx].GetPedErr();
     679      break;
     680    case 37:
     681      if ((*this)[idx].IsExcluded())
     682        return kFALSE;
     683      val = (*this)[idx].GetPedRms();
     684      break;
    786685    case 38:
    787686      if ((*this)[idx].IsExcluded())
    788687        return kFALSE;
    789       val = (*this)[idx].GetPed();
     688      val = (*this)[idx].GetPedErr()/2.;
    790689      break;
    791690    case 39:
    792691      if ((*this)[idx].IsExcluded())
    793692        return kFALSE;
    794       val = (*this)[idx].GetPedErr();
     693      val = (*this)[idx].GetAbsTimeMean();
    795694      break;
    796695    case 40:
    797696      if ((*this)[idx].IsExcluded())
    798         return kFALSE;
    799       val = (*this)[idx].GetPedRms();
    800       break;
    801     case 41:
    802       if ((*this)[idx].IsExcluded())
    803         return kFALSE;
    804       val = (*this)[idx].GetPedErr()/2.;
    805       break;
    806     case 42:
    807       if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK())
    808         return kFALSE;
    809       val = (*this)[idx].GetAbsTimeMean();
    810       break;
    811     case 43:
    812       if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK())
    813697        return kFALSE;
    814698      val = (*this)[idx].GetAbsTimeRms();
     
    817701      return kFALSE;
    818702    }
     703
    819704  return val!=-1.;
     705
    820706}
    821707
     
    836722//
    837723// Calculate the weighted mean of the phe's of all inner and outer pixels, respectively.
    838 // Bad pixels are excluded from the calculation.
    839 //
    840 Bool_t MCalibrationChargeCam::CalcMeanFluxPhotonsFFactorMethod()
     724// Bad pixels are excluded from the calculation. Two loops are performed to exclude pixels
     725// which are fPheFFactorRelLimit sigmas from the mean.
     726//
     727Bool_t MCalibrationChargeCam::CalcMeanFluxPhotonsFFactorMethod(const MGeomCam &geom, const MBadPixelsCam &bad)
    841728{
    842729
     
    848735  Float_t sumweightsouter = 0.;
    849736  Float_t sumphesouter    = 0.;
     737  Int_t   validinner      = 0;
     738  Int_t   validouter      = 0;
     739 
    850740     
    851741  TIter Next(fPixels);
     
    859749      const Int_t idx = pix->GetPixId();
    860750
    861       if(!(*fBadPixels)[idx].IsCalibrationResultOK())
     751      if(!bad[idx].IsCalibrationResultOK())
    862752        continue;
    863753     
    864754      const Float_t nphe    = pix->GetPheFFactorMethod();
    865755      const Float_t npheerr = pix->GetPheFFactorMethodErr();
    866       const Float_t ratio   = fGeomCam->GetPixRatio(idx);
     756      const Float_t ratio   = geom.GetPixRatio(idx);
    867757
    868758      if (npheerr > 0.)
     
    876766              sumweightsinner += weight;
    877767              sumphesinner    += weight*nphe;
     768              validinner++;
    878769            }
    879770          else
     
    885776              sumweightsouter += weight;
    886777              sumphesouter    += weight*nphe;
     778              validouter++;
    887779            }
    888780        } /* if npheerr != 0 */
    889781    } /* while ((pix=(MCalibrationChargePix*)Next())) */
    890  
     782
    891783  if (sumweightsinner <= 0. || sumphesinner <= 0.)
    892784    {
     
    914806    }
    915807
    916 
    917   const Float_t meanFluxPhotonsRelErrSquare = fMeanFluxPhesInnerPixelErr * fMeanFluxPhesInnerPixelErr
    918                                            / (fMeanFluxPhesInnerPixel    * fMeanFluxPhesInnerPixel);
     808  Float_t meanFluxPhotonsRelErrSquare = fMeanFluxPhesInnerPixelErr * fMeanFluxPhesInnerPixelErr
     809                                     / (fMeanFluxPhesInnerPixel    * fMeanFluxPhesInnerPixel);
     810
     811  fMeanFluxPhotonsInnerPixel    =  fMeanFluxPhesInnerPixel/fAverageQE;
     812  fMeanFluxPhotonsInnerPixelErr =  TMath::Sqrt(meanFluxPhotonsRelErrSquare + avQERelErrSquare)
     813                                             * fMeanFluxPhotonsInnerPixel;
     814
     815  fMeanFluxPhotonsOuterPixel    = 4.*fMeanFluxPhotonsInnerPixel;
     816  fMeanFluxPhotonsOuterPixelErr = 4.*fMeanFluxPhotonsInnerPixelErr; 
     817 
     818  //
     819  // Here starts the second loop discarting pixels out of the range:
     820  //
     821  const Float_t innererr = TMath::Sqrt((Float_t)validinner)*fPheFFactorRelLimit*fMeanFluxPhesInnerPixelErr;
     822  const Float_t outererr = TMath::Sqrt((Float_t)validouter)*fPheFFactorRelLimit*fMeanFluxPhesOuterPixelErr;
     823
     824  const Float_t lowerpheinnerlimit = fMeanFluxPhesInnerPixel - innererr;
     825  const Float_t upperpheinnerlimit = fMeanFluxPhesInnerPixel + innererr;
     826
     827  const Float_t lowerpheouterlimit = fMeanFluxPhesOuterPixel - outererr;
     828  const Float_t upperpheouterlimit = fMeanFluxPhesOuterPixel + outererr;
     829
     830  sumweightsinner = 0.;
     831  sumphesinner    = 0.;
     832  sumweightsouter = 0.;
     833  sumphesouter    = 0.;
     834   
     835  TIter Next2(fPixels);
     836  MCalibrationChargePix *pix2;
     837  while ((pix2=(MCalibrationChargePix*)Next2()))
     838    {
     839
     840      if (!pix2->IsFFactorMethodValid())
     841        continue;
     842
     843      const Int_t idx = pix2->GetPixId();
     844
     845      if(!bad[idx].IsCalibrationResultOK())
     846        continue;
     847     
     848      const Float_t nphe    = pix2->GetPheFFactorMethod();
     849      const Float_t npheerr = pix2->GetPheFFactorMethodErr();
     850      const Float_t ratio   = geom.GetPixRatio(idx);
     851
     852      if (npheerr > 0.)
     853        {
     854          //
     855          // first the inner pixels:
     856          //
     857          if (ratio == 1.)
     858            {
     859
     860              if (nphe < lowerpheinnerlimit || nphe > upperpheinnerlimit)
     861                {
     862                  pix2->SetFFactorMethodValid(kFALSE);
     863                  continue;
     864                }
     865
     866              const Float_t weight = 1./npheerr/npheerr;
     867              sumweightsinner += weight;
     868              sumphesinner    += weight*nphe;
     869            }
     870          else
     871            {
     872              //
     873              // now the outers
     874              //
     875              if (nphe < lowerpheouterlimit || nphe > upperpheouterlimit)
     876                {
     877                  pix2->SetFFactorMethodValid(kFALSE);
     878                  continue;
     879                }
     880
     881              const Float_t weight = 1./npheerr/npheerr;
     882              sumweightsouter += weight;
     883              sumphesouter    += weight*nphe;
     884            }
     885        } /* if npheerr != 0 */
     886    } /* while ((pix2=(MCalibrationChargePix*)Next2())) */
     887
     888  if (sumweightsinner <= 0. || sumphesinner <= 0.)
     889    {
     890      *fLog << warn << " Mean number of phe's from inner pixels cannot be calculated: "
     891            << " Sum of weights: " << sumweightsinner
     892            << " Sum of weighted phes: " << sumphesinner << endl;
     893      return kFALSE;
     894    }
     895  else
     896    {
     897      fMeanFluxPhesInnerPixel    = sumphesinner/sumweightsinner;
     898      fMeanFluxPhesInnerPixelErr = TMath::Sqrt(1./sumweightsinner);
     899
     900    }
     901
     902  if (sumweightsouter <= 0. || sumphesouter <= 0.)
     903    {
     904      *fLog << warn << " Mean number of phe's from outer pixels cannot be calculated: "
     905            << " Sum of weights or sum of weighted phes is 0. " << endl;
     906    }
     907  else
     908    {
     909      fMeanFluxPhesOuterPixel    = sumphesouter/sumweightsouter;
     910      fMeanFluxPhesOuterPixelErr = TMath::Sqrt(1./sumweightsouter);
     911    }
     912
     913  meanFluxPhotonsRelErrSquare = fMeanFluxPhesInnerPixelErr * fMeanFluxPhesInnerPixelErr
     914                             / (fMeanFluxPhesInnerPixel    * fMeanFluxPhesInnerPixel);
    919915
    920916  fMeanFluxPhotonsInnerPixel    =  fMeanFluxPhesInnerPixel/fAverageQE;
     
    931927        << fMeanFluxPhotonsInnerPixel << " +- " << fMeanFluxPhotonsInnerPixelErr << endl;
    932928
    933  
    934 
    935929  return kTRUE;
    936930}
    937931
    938 void MCalibrationChargeCam::ApplyFFactorCalibration()
     932void MCalibrationChargeCam::ApplyFFactorCalibration(const MGeomCam &geom, const MBadPixelsCam &bad)
    939933{
    940934
     
    947941    {
    948942
    949       if (!pix->IsFFactorMethodValid())
     943      const Int_t idx = pix->GetPixId();
     944
     945      if (!(bad[idx].IsCalibrationResultOK()))
     946        {
     947          pix->SetFFactorMethodValid(kFALSE);
     948          continue;
     949        }
     950
     951      if (!(pix->IsFFactorMethodValid()))
    950952        continue;
    951953
    952       const Int_t idx = pix->GetPixId();
    953 
    954       if(!(*fBadPixels)[idx].IsCalibrationResultOK())
    955         continue;
    956 
    957       const Float_t ratio   = fGeomCam->GetPixRatio(idx);
     954      const Float_t ratio   = geom.GetPixRatio(idx);
    958955      //
    959956      // Calculate the conversion factor between PHOTONS and FADC counts
     
    10161013
    10171014
    1018 void MCalibrationChargeCam::ApplyBlindPixelCalibration()
     1015void MCalibrationChargeCam::ApplyBlindPixelCalibration(const MGeomCam &geom, const MBadPixelsCam &bad)
    10191016{
    10201017
     
    10271024    {
    10281025
    1029       if((*fBadPixels)[pix->GetPixId()].IsCalibrationResultOK())
     1026      const Int_t idx = pix->GetPixId();
     1027
     1028      if (!(bad[idx].IsCalibrationResultOK()))
    10301029        {
    1031          
    1032           const Int_t idx = pix->GetPixId();
    1033 
    1034           const Float_t charge    = pix->GetMeanCharge();
    1035           const Float_t area      = (*fGeomCam)[idx].GetA();
    1036           const Float_t chargeerr = pix->GetMeanChargeErr();         
    1037 
    1038           const Float_t nphot      = flux    * area;
    1039           const Float_t nphoterr   = fluxerr * area;
    1040           const Float_t conversion = nphot/charge;
    1041           Float_t conversionerr;
    1042          
    1043           conversionerr  = nphoterr/charge
    1044                          * nphoterr/charge ;
    1045           conversionerr += chargeerr/charge
    1046                          * chargeerr/charge
    1047                          * conversion*conversion;
    1048           conversionerr = TMath::Sqrt(conversionerr);
    1049 
    1050           const Float_t conversionsigma = 0.;
    1051 
    1052           pix->SetConversionBlindPixelMethod(conversion, conversionerr, conversionsigma);
    1053 
    1054           if (conversionerr/conversion < 0.1)
    1055             pix->SetBlindPixelMethodValid();
     1030          pix->SetBlindPixelMethodValid(kFALSE);
     1031          continue;
    10561032        }
    1057     }
    1058 }
    1059 
    1060 
    1061 void MCalibrationChargeCam::ApplyPINDiodeCalibration()
     1033     
     1034      const Float_t charge    = pix->GetMeanCharge();
     1035      const Float_t area      = geom[idx].GetA();
     1036      const Float_t chargeerr = pix->GetMeanChargeErr();         
     1037     
     1038      const Float_t nphot      = flux    * area;
     1039      const Float_t nphoterr   = fluxerr * area;
     1040      const Float_t conversion = nphot/charge;
     1041      Float_t conversionerr;
     1042     
     1043      conversionerr  = nphoterr/charge
     1044                     * nphoterr/charge ;
     1045      conversionerr += chargeerr/charge
     1046                     * chargeerr/charge
     1047                     * conversion*conversion;
     1048      conversionerr = TMath::Sqrt(conversionerr);
     1049
     1050      const Float_t conversionsigma = 0.;
     1051     
     1052      pix->SetConversionBlindPixelMethod(conversion, conversionerr, conversionsigma);
     1053     
     1054      if (conversionerr/conversion < 0.1)
     1055        pix->SetBlindPixelMethodValid();
     1056    }
     1057}
     1058
     1059void MCalibrationChargeCam::ApplyPINDiodeCalibration(const MGeomCam &geom, const MBadPixelsCam &bad)
    10621060{
    10631061
     
    10701068    {
    10711069
    1072       if((*fBadPixels)[pix->GetPixId()].IsCalibrationResultOK())
     1070      const Int_t idx = pix->GetPixId();
     1071     
     1072      if (!(bad[idx].IsCalibrationResultOK()))
    10731073        {
    1074 
    1075           const Int_t idx = pix->GetPixId();
    1076 
    1077           const Float_t charge    = pix->GetMeanCharge();
    1078           const Float_t area      = (*fGeomCam)[idx].GetA();
    1079           const Float_t chargeerr = pix->GetMeanChargeErr();         
    1080 
    1081           const Float_t nphot      = flux    * area;
    1082           const Float_t nphoterr   = fluxerr * area;
    1083           const Float_t conversion = nphot/charge;
    1084 
    1085           Float_t conversionerr;
    1086          
    1087           conversionerr  = nphoterr/charge
    1088                          * nphoterr/charge ;
    1089           conversionerr += chargeerr/charge
    1090                          * chargeerr/charge
    1091                          * conversion*conversion;
    1092           if (conversionerr > 0.)
    1093             conversionerr = TMath::Sqrt(conversionerr);
    1094 
    1095           const Float_t conversionsigma = 0.;
    1096 
    1097           pix->SetConversionPINDiodeMethod(conversion, conversionerr, conversionsigma);
    1098 
    1099           if (conversionerr/conversion < 0.1)
    1100             pix->SetPINDiodeMethodValid();
    1101          
     1074          pix->SetPINDiodeMethodValid(kFALSE);
     1075          continue;
    11021076        }
    1103     }
    1104 }
    1105 
     1077     
     1078      const Float_t charge    = pix->GetMeanCharge();
     1079      const Float_t area      = geom[idx].GetA();
     1080      const Float_t chargeerr = pix->GetMeanChargeErr();         
     1081     
     1082      const Float_t nphot      = flux    * area;
     1083      const Float_t nphoterr   = fluxerr * area;
     1084      const Float_t conversion = nphot/charge;
     1085     
     1086      Float_t conversionerr;
     1087     
     1088      conversionerr  = nphoterr/charge
     1089                     * nphoterr/charge ;
     1090      conversionerr += chargeerr/charge
     1091                     * chargeerr/charge
     1092                     * conversion*conversion;
     1093      if (conversionerr > 0.)
     1094        conversionerr = TMath::Sqrt(conversionerr);
     1095     
     1096      const Float_t conversionsigma = 0.;
     1097     
     1098      pix->SetConversionPINDiodeMethod(conversion, conversionerr, conversionsigma);
     1099     
     1100      if (conversionerr/conversion < 0.1)
     1101        pix->SetPINDiodeMethodValid();
     1102     
     1103    }
     1104}
    11061105
    11071106
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h

    r3455 r3479  
    2626 
    2727  static const Float_t fgConvFFactorRelErrLimit; // The limit for acceptance of the rel. error of the conversion factor with the FFactor method
    28 
    29   Float_t fAverageQE;                       // The average quantum efficieny (see Class description)
    30   Float_t fAverageQEErr;                    // The error of the average quantum efficieny (see Class description)
     28  static const Float_t fgPheFFactorRelLimit;     // The rel. limit for acceptance of a calculated number of phe's w.r.t the mean number (in sigma of the error)
    3129 
    32   Float_t fConvFFactorRelErrLimit;          // The limit for acceptance of the rel. error of the conversion factor with the FFactor method
    33 
     30  Float_t fAverageQE;                // The average quantum efficieny (see Class description)
     31  Float_t fAverageQEErr;             // The error of the average quantum efficieny (see Class description)
     32 
     33  Float_t fConvFFactorRelErrLimit;   // The limit for acceptance of the rel. error of the conversion factor with the FFactor method
     34  Float_t fPheFFactorRelLimit;       // The rel. limit for acceptance of a calculated number of phe's w.r.t the mean number (in sigma of the error).
     35 
    3436  Int_t fNumPixels;
    3537  TClonesArray *fPixels;                         //-> Array of MCalibrationPix with fit results
     38
    3639  MCalibrationChargePix *fAverageInnerPix;       //-> Average Pixel of all events
    3740  MCalibrationChargePix *fAverageOuterPix;       //-> Average Pixel of all events
     
    4245  const MCalibrationChargeBlindPix *fBlindPixel; //! Pointer to the Blind Pixel with fit results
    4346  const MCalibrationChargePINDiode *fPINDiode;   //! Pointer to the PIN Diode with fit results
    44 
    45   const MGeomCam                   *fGeomCam;    //! Need geom cam to know which pixel in inner or outer
    46   const MBadPixelsCam              *fBadPixels;  //! Bad Pixels cam, only for reading
    4747
    4848  TH1D* fOffsets;                                //!
     
    7979                              const Float_t err=gkAverageQEErr)         { fAverageQE    = qe;           
    8080                                                                          fAverageQEErr = err;         }
     81  void SetNumPixelsExcluded(  const UInt_t n )            {  fNumExcludedPixels = n; }
    8182  void SetConvFFactorRelErrLimit( const Float_t f=fgConvFFactorRelErrLimit ) { fConvFFactorRelErrLimit = f; }
    82   void SetNumPixelsExcluded(  const UInt_t n )            {  fNumExcludedPixels = n; }
    83   void SetGeomCam(  const MGeomCam *geom)                 {  fGeomCam = geom;        }
    84   void SetBadPixelsCam(  const MBadPixelsCam *bad)                 {  fBadPixels = bad;        }
     83  void SetPheFFactorRelLimit (  const Float_t f=fgPheFFactorRelLimit )     { fPheFFactorRelLimit = f;    } 
    8584
    8685  void SetPINDiode  ( const MCalibrationChargePINDiode *d ) {  fPINDiode   = d;      }
     
    139138  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
    140139
    141   Bool_t CalcMeanFluxPhotonsFFactorMethod(); 
     140  Bool_t CalcMeanFluxPhotonsFFactorMethod(const MGeomCam &geom, const MBadPixelsCam &bad); 
    142141
    143   void   ApplyPINDiodeCalibration();
    144   void   ApplyBlindPixelCalibration();
    145   void   ApplyFFactorCalibration();
     142  void   ApplyPINDiodeCalibration(const MGeomCam &geom, const MBadPixelsCam &bad);
     143  void   ApplyBlindPixelCalibration(const MGeomCam &geom, const MBadPixelsCam &bad);
     144  void   ApplyFFactorCalibration(const MGeomCam &geom, const MBadPixelsCam &bad);
    146145
    147146  ClassDef(MCalibrationChargeCam, 1)    // Container for calibration information of the camera
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc

    r3476 r3479  
    668668  const Float_t chargeSquareRelErrSquare  = 4.* GetMeanChargeErr() * GetMeanChargeErr() / chargeSquare;
    669669
    670   const Float_t chargeRelErrSquare        =     GetMeanChargeErr() * GetMeanChargeErr()
    671                                              / (GetMeanCharge()    * GetMeanCharge());
    672  
    673670  const Float_t ffactorsquare             =    gkFFactor    * gkFFactor;
    674671  const Float_t ffactorsquareRelErrSquare = 4.*gkFFactorErr * gkFFactorErr / ffactorsquare;
     
    703700  return kTRUE;
    704701}
    705 
    706702
    707703
Note: See TracChangeset for help on using the changeset viewer.