Ignore:
Timestamp:
02/09/04 10:36:04 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.