Changeset 3065 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
02/09/04 10:36:04 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3064 r3065  
    44
    55                                                 -*-*- END OF LINE -*-*-
     6 2004/02/09: Markus Gaug
     7
     8  * MMcCalibrationUpdate.cc
     9  * MCalibrate.cc
     10  * MCalibrationPix.cc
     11  * MCalibrationPix.h
     12    - replace MCalibrationPix->IsChargeFitValid() by IsChargeValid()
     13      because we can calibrate with the histogram mean and RMS even
     14      if the fit is not OK. Thus, there is a question: IsFitted() and
     15      IsChargeValid(), i.e. does the charge make any sense?
     16
     17   * MCalibrationCam.cc
     18     MCalibrationConfig.h
     19     MCalibrationCalc.cc
     20     - found serious bug in calculation of conversion factors for the
     21       outer pixels:
     22       GetMeanConversionBlindPixelMethod and
     23       GetMeanConversionPINDiodeMethod
     24       did not correct for the area of the outer pixel, this did only
     25       MCalibrationCam::GetPixelContent which is not used by MCalibrate
     26
     27
    628 2004/02/06: Markus Gaug
    729
  • trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc

    r3060 r3065  
    222222
    223223        calpix.SetBlindPixelMethodValid();
    224         calpix.SetChargeFitValid();
     224        calpix.SetChargeValid();
    225225
    226226        calpix.SetConversionHiLo(fConversionHiLo);
  • trunk/MagicSoft/Mars/mcalib/MCalibrate.cc

    r3031 r3065  
    169169          MCalibrationPix &pix = (*fCalibrations)[pixidx];       
    170170         
    171           if (!pix.IsChargeFitValid())
     171          if (!pix.IsChargeValid())
    172172            continue;
    173173         
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc

    r3061 r3065  
    279279      return kFALSE;
    280280    }
     281
     282
     283    fCalibrations->SetGeomCam(cam);
    281284
    282285    fNumHiGainSamples =  fSignals->GetNumUsedHiGainFADCSlices();
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc

    r3063 r3065  
    262262    {
    263263     
    264       if (pix->IsChargeFitValid() && !pix->IsExcluded())
     264      if (pix->IsChargeValid() && !pix->IsExcluded())
    265265        {
    266266
     
    284284      {
    285285       
    286         if (!pix->IsChargeFitValid() && !pix->IsExcluded())
     286        if (!pix->IsChargeValid() && !pix->IsExcluded())
    287287          {
    288288
     
    383383  Float_t arearatio = cam.GetPixRatio(idx);
    384384
    385   if (arearatio == 0)
     385 if (arearatio == 0)
    386386    return kFALSE;
    387387
     
    587587      if (!(*this)[idx].IsFitted())
    588588        return kFALSE;
    589       if (!(*this)[idx].IsChargeFitValid())
     589      if (!(*this)[idx].IsChargeValid())
    590590        val = 1;
    591591      else
     
    702702  const Float_t mean = fBlindPixel->GetLambda();
    703703  const Float_t merr = fBlindPixel->GetErrLambda();
     704
     705  //
     706  // Start calculation of number of photons
     707  //
     708  // The blind pixel has exactly one cm^2 area (with negligible error),
     709  // thus we omi division by 1.
     710  //
     711  fMeanPhotInsidePlexiglass    = mean * gkCalibrationInnerPixelArea;
     712
     713  // Start calculation of number of photons relative Variance (!!)
     714  fMeanPhotErrInsidePlexiglass  = merr*merr/mean/mean;
     715  fMeanPhotErrInsidePlexiglass += gkCalibrationInnerPixelAreaError*gkCalibrationInnerPixelAreaError
     716                                / gkCalibrationInnerPixelArea/gkCalibrationInnerPixelArea;
    704717 
    705718  switch (fColor)
    706719    {
    707720    case kECGreen:
    708       fMeanPhotInsidePlexiglass = (mean / gkCalibrationBlindPixelQEGreen)     // real photons
    709                             *TMath::Power(10,gkCalibrationBlindPixelAttGreen) // correct for absorption
    710                             * gkCalibrationInnerPixelArea;                    // correct for area
    711 
    712      
     721      fMeanPhotInsidePlexiglass    /= gkCalibrationBlindPixelQEGreen;   
     722      fMeanPhotErrInsidePlexiglass += gkCalibrationBlindPixelQEGreenError*gkCalibrationBlindPixelQEGreenError
     723                                    / gkCalibrationBlindPixelQEGreen  /   gkCalibrationBlindPixelQEGreen;   
     724
     725      fMeanPhotInsidePlexiglass *= TMath::Power(10,gkCalibrationBlindPixelAttGreen); // correct for absorption
     726      // attenuation has negligible error
    713727      break;
    714728    case kECBlue:
    715       fMeanPhotInsidePlexiglass = (mean / gkCalibrationBlindPixelQEBlue )
    716                             *TMath::Power(10,gkCalibrationBlindPixelAttBlue)
    717                             * gkCalibrationInnerPixelArea;
     729      fMeanPhotInsidePlexiglass    /= gkCalibrationBlindPixelQEBlue;   
     730      fMeanPhotErrInsidePlexiglass += gkCalibrationBlindPixelQEBlueError*gkCalibrationBlindPixelQEBlueError
     731                                    / gkCalibrationBlindPixelQEBlue  /   gkCalibrationBlindPixelQEBlue;   
     732
     733      fMeanPhotInsidePlexiglass *= TMath::Power(10,gkCalibrationBlindPixelAttBlue); // correct for absorption
     734      // attenuation has negligible error
    718735      break;
    719736    case kECUV:
    720       fMeanPhotInsidePlexiglass = (mean / gkCalibrationBlindPixelQEUV )
    721                             *TMath::Power(10,gkCalibrationBlindPixelAttUV)
    722                             * gkCalibrationInnerPixelArea;
     737      fMeanPhotInsidePlexiglass    /= gkCalibrationBlindPixelQEUV;   
     738      fMeanPhotErrInsidePlexiglass += gkCalibrationBlindPixelQEUVError*gkCalibrationBlindPixelQEUVError
     739                                    / gkCalibrationBlindPixelQEUV  /   gkCalibrationBlindPixelQEUV;   
     740
     741      fMeanPhotInsidePlexiglass *= TMath::Power(10,gkCalibrationBlindPixelAttUV); // correct for absorption
     742      // attenuation has negligible error
    723743      break;
    724744    case kECCT1:
    725745    default:
    726       fMeanPhotInsidePlexiglass = (mean / gkCalibrationBlindPixelQECT1 )
    727                             *TMath::Power(10,gkCalibrationBlindPixelAttCT1)
    728                             * gkCalibrationInnerPixelArea;
    729       break;
    730     }
    731 
    732   SETBIT(fFlags,kNumPhotInsidePlexiglassAvailable);
     746      fMeanPhotInsidePlexiglass    /= gkCalibrationBlindPixelQECT1;   
     747      fMeanPhotErrInsidePlexiglass += gkCalibrationBlindPixelQECT1Error*gkCalibrationBlindPixelQECT1Error
     748                                    / gkCalibrationBlindPixelQECT1  /   gkCalibrationBlindPixelQECT1;   
     749
     750      fMeanPhotInsidePlexiglass *= TMath::Power(10,gkCalibrationBlindPixelAttCT1); // correct for absorption
     751      // attenuation has negligible error
     752      break;
     753    }
    733754
    734755  *fLog << inf << endl;
    735   *fLog << inf << "Mean number of Photons for an Inner Pixel (inside Plexiglass): "
     756  *fLog << inf << " Mean number of Photons for an Inner Pixel (inside Plexiglass): "
    736757        << fMeanPhotInsidePlexiglass << endl;
     758
     759  if (fMeanPhotInsidePlexiglass > 0.)
     760    SETBIT(fFlags,kNumPhotInsidePlexiglassAvailable); 
     761  else
     762    {
     763      CLRBIT(fFlags,kNumPhotInsidePlexiglassAvailable);       
     764      return kFALSE;
     765    }
     766
     767  if (fMeanPhotErrInsidePlexiglass < 0.)
     768    {
     769      *fLog << warn << " Relative Variance on number of Photons for an Inner Pixel (inside Plexiglass): "
     770            << fMeanPhotErrInsidePlexiglass << endl;
     771      CLRBIT(fFlags,kNumPhotInsidePlexiglassAvailable);       
     772      return kFALSE;
     773    }
     774
     775  // Finish calculation of errors -> convert from relative variance to absolute error
     776  fMeanPhotErrInsidePlexiglass = TMath::Sqrt(fMeanPhotErrInsidePlexiglass);
     777  fMeanPhotErrInsidePlexiglass *= fMeanPhotInsidePlexiglass;
     778
     779  *fLog << inf << " Error on number of Photons for an Inner Pixel (inside Plexiglass): "
     780        << fMeanPhotErrInsidePlexiglass << endl;
     781  *fLog << inf << endl;
     782
     783
    737784
    738785  TIter Next(fPixels);
     
    740787  while ((pix=(MCalibrationPix*)Next()))
    741788    {
    742       if((pix->GetCharge() > 0.) && (fMeanPhotInsidePlexiglass > 0.))
     789
     790      if(pix->IsChargeValid())
    743791        {
    744792
    745           Float_t conversion      = fMeanPhotInsidePlexiglass/pix->GetCharge();
    746           Float_t conversionerr   = 0.;
    747           Float_t conversionsigma = 0.;
     793          const Float_t charge    = pix->GetCharge();
     794          const Float_t ratio     = fGeomCam->GetPixRatio(pix->GetPixId());
     795          const Float_t chargeerr = pix->GetErrCharge();         
     796
     797          Float_t nphot;
     798          Float_t nphoterr;
     799         
     800          if (ratio == 1.)
     801            {
     802              nphot    = fMeanPhotInsidePlexiglass;
     803              nphoterr = fMeanPhotErrInsidePlexiglass;
     804            }
     805          else
     806            {
     807              nphot = fMeanPhotInsidePlexiglass*gkCalibrationOutervsInnerPixelArea;
     808              nphoterr = fMeanPhotErrInsidePlexiglass*gkCalibrationOutervsInnerPixelArea
     809                        *fMeanPhotErrInsidePlexiglass*gkCalibrationOutervsInnerPixelArea;
     810              nphoterr += fMeanPhotInsidePlexiglass*gkCalibrationOutervsInnerPixelAreaError
     811                         *fMeanPhotInsidePlexiglass*gkCalibrationOutervsInnerPixelAreaError;
     812              nphoterr = TMath::Sqrt(nphoterr);
     813            }
     814
     815         
     816
     817          const Float_t conversion      = nphot/charge;
     818          Float_t conversionerr;
     819         
     820          conversionerr  = nphoterr/charge
     821                         * nphoterr/charge ;
     822          conversionerr += chargeerr/charge
     823                         * chargeerr/charge
     824                         * conversion*conversion;
     825          conversionerr = TMath::Sqrt(conversionerr);
     826
     827          const Float_t conversionsigma = 0.;
     828
    748829          pix->SetConversionBlindPixelMethod(conversion, conversionerr, conversionsigma);
    749830
     
    764845  const Float_t mean = fPINDiode->GetCharge();
    765846  const Float_t merr = fPINDiode->GetErrCharge();
     847
     848  // Start calculation of number of photons
     849  fMeanPhotOutsidePlexiglass = mean * gkCalibrationInnerPixelvsPINDiodeArea;
     850
     851  // Start calculation of number of photons relative Variance (!!)
     852  fMeanPhotErrOutsidePlexiglass  = merr*merr/mean/mean;
     853  fMeanPhotErrOutsidePlexiglass += gkCalibrationInnerPixelvsPINDiodeAreaError*gkCalibrationInnerPixelvsPINDiodeAreaError
     854                                 / gkCalibrationInnerPixelvsPINDiodeArea/gkCalibrationInnerPixelvsPINDiodeArea;
    766855 
    767856  switch (fColor)
    768857    {
    769858    case kECGreen:
    770       fMeanPhotOutsidePlexiglass = (mean / gkCalibrationPINDiodeQEGreen)   // real photons
    771                             * gkCalibrationInnerPixelvsPINDiodeArea;        // correct for area
     859      fMeanPhotOutsidePlexiglass    /= gkCalibrationPINDiodeQEGreen;
     860      fMeanPhotErrOutsidePlexiglass += gkCalibrationPINDiodeQEGreenError*gkCalibrationPINDiodeQEGreenError
     861                                     / gkCalibrationPINDiodeQEGreen/gkCalibrationPINDiodeQEGreen;
    772862      break;
    773863    case kECBlue:
    774       fMeanPhotOutsidePlexiglass = (mean / gkCalibrationPINDiodeQEBlue )
    775                             * gkCalibrationInnerPixelvsPINDiodeArea;
    776       break;
     864      fMeanPhotOutsidePlexiglass    /= gkCalibrationPINDiodeQEBlue;
     865      fMeanPhotErrOutsidePlexiglass += gkCalibrationPINDiodeQEBlueError*gkCalibrationPINDiodeQEBlueError
     866                                     / gkCalibrationPINDiodeQEBlue/gkCalibrationPINDiodeQEBlue;
     867      break;
    777868    case kECUV:
    778       fMeanPhotOutsidePlexiglass = (mean / gkCalibrationPINDiodeQEUV )
    779                             * gkCalibrationInnerPixelvsPINDiodeArea;
     869      fMeanPhotOutsidePlexiglass    /= gkCalibrationPINDiodeQEUV;
     870      fMeanPhotErrOutsidePlexiglass += gkCalibrationPINDiodeQEUVError*gkCalibrationPINDiodeQEUVError
     871                                     / gkCalibrationPINDiodeQEUV/gkCalibrationPINDiodeQEUV;
    780872      break;
    781873    case kECCT1:
    782874    default:
    783       fMeanPhotOutsidePlexiglass = (mean / gkCalibrationPINDiodeQECT1 )
    784                             * gkCalibrationInnerPixelvsPINDiodeArea;
    785       break;
    786     }
    787 
    788   SETBIT(fFlags,kNumPhotOutsidePlexiglassAvailable); 
     875      fMeanPhotOutsidePlexiglass    /= gkCalibrationPINDiodeQECT1;
     876      fMeanPhotErrOutsidePlexiglass += gkCalibrationPINDiodeQECT1Error*gkCalibrationPINDiodeQECT1Error
     877                                     / gkCalibrationPINDiodeQECT1/gkCalibrationPINDiodeQECT1;
     878      break;
     879    }
     880
    789881
    790882  *fLog << inf << endl;
    791   *fLog << inf << mean << " Mean number of Photons for an Inner Pixel (outside Plexiglass): "
     883  *fLog << inf << " Mean number of Photons for an Inner Pixel (outside Plexiglass): "
    792884        << fMeanPhotOutsidePlexiglass << endl;
     885
     886  if (fMeanPhotOutsidePlexiglass > 0.)
     887    SETBIT(fFlags,kNumPhotOutsidePlexiglassAvailable); 
     888  else
     889    {
     890      CLRBIT(fFlags,kNumPhotOutsidePlexiglassAvailable);       
     891      return kFALSE;
     892    }
     893
     894  if (fMeanPhotErrOutsidePlexiglass < 0.)
     895    {
     896      *fLog << warn << "Relative Variance on number of Photons for an Inner Pixel (outside Plexiglass): "
     897            << fMeanPhotErrOutsidePlexiglass << endl;
     898      CLRBIT(fFlags,kNumPhotOutsidePlexiglassAvailable);       
     899      return kFALSE;
     900    }
     901
     902  // Finish calculation of errors -> convert from relative variance to absolute error
     903  fMeanPhotErrOutsidePlexiglass = TMath::Sqrt(fMeanPhotErrOutsidePlexiglass);
     904  fMeanPhotErrOutsidePlexiglass *= fMeanPhotOutsidePlexiglass;
     905
     906  *fLog << inf << " Error on number of Photons for an Inner Pixel (outside Plexiglass): "
     907        << fMeanPhotErrOutsidePlexiglass << endl;
    793908  *fLog << inf << endl;
    794909
     
    797912  while ((pix=(MCalibrationPix*)Next()))
    798913    {
    799      
    800       if((pix->GetCharge() > 0.) && (fMeanPhotInsidePlexiglass > 0.))
    801         pix->SetConversionPINDiodeMethod(fMeanPhotOutsidePlexiglass/pix->GetCharge(), 0., 0.);
     914
     915      if (pix->IsChargeValid())
     916        {
     917
     918          const Float_t charge    = pix->GetCharge();
     919          const Float_t ratio = fGeomCam->GetPixRatio(pix->GetPixId());
     920          const Float_t chargeerr = pix->GetErrCharge();         
     921
     922          Float_t nphot;
     923          Float_t nphoterr;
     924         
     925          if (ratio == 1.)
     926            {
     927              nphot    = fMeanPhotInsidePlexiglass;
     928              nphoterr = fMeanPhotErrInsidePlexiglass;
     929            }
     930          else
     931            {
     932              nphot = fMeanPhotInsidePlexiglass*gkCalibrationOutervsInnerPixelArea;
     933              nphoterr = fMeanPhotErrInsidePlexiglass*gkCalibrationOutervsInnerPixelArea
     934                        *fMeanPhotErrInsidePlexiglass*gkCalibrationOutervsInnerPixelArea;
     935              nphoterr += fMeanPhotInsidePlexiglass*gkCalibrationOutervsInnerPixelAreaError
     936                         *fMeanPhotInsidePlexiglass*gkCalibrationOutervsInnerPixelAreaError;
     937              nphoterr = TMath::Sqrt(nphoterr);
     938            }
     939
     940          const Float_t conversion      = nphot/charge;
     941          Float_t conversionerr;
     942         
     943          conversionerr  = nphoterr/charge
     944                         * nphoterr/charge ;
     945          conversionerr += chargeerr/charge
     946                         * chargeerr/charge
     947                         * conversion*conversion;
     948          if (conversionerr > 0.)
     949            conversionerr = TMath::Sqrt(conversionerr);
     950
     951          const Float_t conversionsigma = 0.;
     952
     953          pix->SetConversionBlindPixelMethod(conversion, conversionerr, conversionsigma);
     954
     955          if (conversionerr/conversion < 0.1)
     956            pix->SetBlindPixelMethodValid();
     957         
     958        }
    802959    }
    803960  return kTRUE;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCam.h

    r3062 r3065  
    3030  MCalibrationPINDiode *fPINDiode;            //-> Pointer to the PIN Diode with fit results
    3131
     32  MGeomCam             *fGeomCam;             //! Need geom cam to know which pixel in inner or outer
     33 
    3234  TH1D* fOffsets;                             //!
    3335  TH1D* fSlopes;                              //!
     
    6971  void SetBlindPixelMethodValid(const Bool_t b = kTRUE);
    7072  void SetPINDiodeMethodValid(const Bool_t b = kTRUE); 
     73
     74  void SetGeomCam(MGeomCam *geom)               {  fGeomCam = geom;     }
    7175 
    7276  // Getters
  • trunk/MagicSoft/Mars/mcalib/MCalibrationConfig.h

    r2957 r3065  
    2323const Float_t gkCalibrationBlindPixelQEUV    = 0.247;
    2424const Float_t gkCalibrationBlindPixelQECT1   = 0.247;
     25
     26// Average QE Error of Blind Pixel (three colours)
     27const Float_t gkCalibrationBlindPixelQEGreenError = 0.015;
     28const Float_t gkCalibrationBlindPixelQEBlueError  = 0.02;
     29const Float_t gkCalibrationBlindPixelQEUVError    = 0.02;
     30const Float_t gkCalibrationBlindPixelQECT1Error   = 0.02;
    2531
    2632// Attenuation factor Blind Pixel (three colours)
     
    8288const Float_t gkCalibrationPINDiodeQECT1   = -1.0;
    8389
     90//
     91// Average QE of the PIN Diode
     92//
     93const Float_t gkCalibrationPINDiodeQEGreenError = -1.0;
     94const Float_t gkCalibrationPINDiodeQEBlueError  = -1.0;
     95const Float_t gkCalibrationPINDiodeQEUVError    = -1.0;
     96const Float_t gkCalibrationPINDiodeQECT1Error   = -1.0;
    8497
    8598#endif /* MARS_MCalibrationConfig */
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc

    r3061 r3065  
    107107  CLRBIT(fFlags, kExcluded);
    108108  CLRBIT(fFlags, kExcludeQualityCheck);
    109   CLRBIT(fFlags, kChargeFitValid);
     109  CLRBIT(fFlags, kChargeValid);
    110110  CLRBIT(fFlags, kFitted);
    111111  CLRBIT(fFlags, kOscillating);
     
    258258// Set the Excluded Bit from outside
    259259//
    260 void MCalibrationPix::SetChargeFitValid(Bool_t b )   
    261 {
    262   b ?  SETBIT(fFlags, kChargeFitValid) : CLRBIT(fFlags, kChargeFitValid);
     260void MCalibrationPix::SetChargeValid(Bool_t b )   
     261{
     262  b ?  SETBIT(fFlags, kChargeValid) : CLRBIT(fFlags, kChargeValid);
    263263}
    264264
     
    443443 }
    444444
    445 Bool_t MCalibrationPix::IsChargeFitValid() const
    446 {
    447   return TESTBIT(fFlags, kChargeFitValid); 
     445Bool_t MCalibrationPix::IsChargeValid() const
     446{
     447  return TESTBIT(fFlags, kChargeValid); 
    448448}
    449449
     
    584584    ApplyLoGainConversion();
    585585
    586   if (CheckChargeFitValidity())
    587     SETBIT(fFlags,kChargeFitValid);
     586  if (CheckChargeValidity())
     587    SETBIT(fFlags,kChargeValid);
    588588  else
    589589    {
    590       CLRBIT(fFlags,kChargeFitValid);
     590      CLRBIT(fFlags,kChargeValid);
    591591      return kFALSE;
    592592    }
     
    751751// 5) Pixel has a charge sigma bigger than its Pedestal RMS
    752752//
    753 Bool_t MCalibrationPix::CheckChargeFitValidity()
     753Bool_t MCalibrationPix::CheckChargeValidity()
    754754{
    755755
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h

    r3062 r3065  
    7878  enum  { kHiGainSaturation,
    7979          kExcluded, kExcludeQualityCheck,
    80           kChargeFitValid, kTimeFitValid,
     80          kChargeValid, kTimeFitValid,
    8181          kFitted, kOscillating,
    8282          kBlindPixelMethodValid, kFFactorMethodValid, kPINDiodeMethodValid };
     
    8484  MHCalibrationPixel *fHist;                // Pointer to the histograms performing the fits, etc. 
    8585
    86   Bool_t CheckChargeFitValidity();
     86  Bool_t CheckChargeValidity();
    8787  Bool_t CheckTimeFitValidity();
    8888  Bool_t CalcFFactorMethod();
     
    148148  Bool_t IsExcludeQualityCheck()   const;
    149149  Bool_t IsHiGainSaturation()      const;
    150   Bool_t IsChargeFitValid()        const;
     150  Bool_t IsChargeValid()        const;
    151151  Bool_t IsFitted()                const;
    152152  Bool_t IsOscillating();
     
    169169  void SetExcluded(Bool_t b = kTRUE);
    170170  void SetExcludeQualityCheck(Bool_t b = kTRUE);
    171   void SetChargeFitValid(Bool_t b = kTRUE);
     171  void SetChargeValid(Bool_t b = kTRUE);
    172172  void SetFitted(Bool_t b = kTRUE);
    173173  void SetOscillating(Bool_t b = kTRUE);
Note: See TracChangeset for help on using the changeset viewer.