Changeset 2716 for trunk


Ignore:
Timestamp:
12/18/03 17:26:36 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2715 r2716  
    1212   * manalysis/MCalibrationPix.cc
    1313     - introduced error calculation for the F-Factor method
    14 
     14 
     15   * macros/calibration.C
     16     - display now the errors in the F-Factor method correctly 
    1517
    1618 2003/12/18: Abelardo Moralejo
  • trunk/MagicSoft/Mars/manalysis/MCalibrationCam.h

    r2679 r2716  
    9999  UInt_t GetNumPixels() const { return fNumPixels; }
    100100
    101   Bool_t IsPixelUsed(Int_t idx) const;
    102   Bool_t IsPixelFitted(Int_t idx) const;
     101  Bool_t IsPixelUsed(Int_t idx)      const;
     102  Bool_t IsPixelFitted(Int_t idx)    const;
     103  Bool_t IsPixelFitValid(Int_t idx)  const; 
    103104 
    104105  MCalibrationPix &operator[](Int_t i);
     
    114115  void   DrawPixelContent(Int_t num) const;   
    115116 
    116   MCalibrationPix      *GetCalibrationPix(Int_t idx) const;
    117   MCalibrationBlindPix *GetBlindPixel() const { return fBlindPixel; }
    118   MCalibrationPINDiode *GetPINDiode()   const { return fPINDiode; }
     117  MCalibrationBlindPix *GetBlindPixel()              const { return fBlindPixel;  }
     118  MCalibrationPINDiode *GetPINDiode()                const { return fPINDiode;    }
    119119
    120120  void SetColor(CalibrationColor_t color)    { fColor = color; }
  • trunk/MagicSoft/Mars/manalysis/MCalibrationConfig.h

    r2679 r2716  
    1717
    1818// The conversion factor between High Gain and Low Gain
    19 const Float_t gkConversionHiLo = 10.;
     19const Float_t gkConversionHiLo      = 10.;
     20const Float_t gkConversionHiLoError = 2.5;
    2021
    2122// The penalty constant to produce overflow in the histogram
     
    4041
    4142//
    42 // Area of Inner Pixel w.r.t. Blind Pixel (which is 1 cm²)
     43// Area of Inner Pixel w.r.t. Blind Pixel (which is 1 sq. cm)
    4344//
    4445// Hexagone of diagonal axis b = 3.5 cm
    4546//             straight axis a = 3.0 cm +- 2%
    46 // Area =  sqrt(3)*a²/2 = 7.79 cm² +- 4% = 7.8 +- 0.3 cm²
     47// Area =  sqrt(3)*a*a/2 = 7.79 sq.cm +- 4% = 7.8 +- 0.3 sq.cm
    4748//
    4849const Float_t gkCalibrationInnerPixelArea      = 7.8;
     
    5354// Hexagone of diagonal axis b = 7.0 cm
    5455//             straight axis a = 6.0 cm +- 1%
    55 // Area = sqrt(3)*a²/2 =
     56// Area = sqrt(3)*a*a/2 =
    5657//
    5758const Float_t gkCalibrationOutervsInnerPixelArea      = 4.00;
     
    6869// Hexagone of diagonal axis b = 3.5 cm
    6970//             straight axis a = 3.0 cm +- 2%
    70 // Area =  sqrt(3)*a²/2 = 7.79 cm² +- 4% = 7.8 +- 0.3 cm²
     71// Area =  sqrt(3)*a*a/2 = 7.79 sq.cm +- 4% = 7.8 +- 0.3 sq.cm
    7172//
    7273// Distance of PIN Diode to pulser D1:   1.5  +- 0.3 m
     
    7475//
    7576//
    76 //                A(Inner Pixel)    D1²
    77 // conversion C = -------------- * ----- = 0.054
    78 //                A(PIN Diode)      D2²
     77//                A(Inner Pixel)    D1*D1
     78// conversion C = -------------- * ------ = 0.054
     79//                A(PIN Diode)      D2*D2
    7980//
    8081// Delta C / C  = sqrt((Delta A(IP)/A(IP))² + 4 * ( (Delta D1/D1)² + (Delta D2/D2)² )
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc

    r2699 r2716  
    3232/////////////////////////////////////////////////////////////////////////////
    3333#include "MCalibrationPix.h"
     34#include "MCalibrationConfig.h"
    3435
    3536#include "MLog.h"
     
    5455      fPed(-1.),
    5556      fPedRms(-1.),
     57      fErrPedRms(0.),
     58      fElectronicPedRms(1.5),
     59      fErrElectronicPedRms(0.3),
    5660      fTime(-1.),
    5761      fSigmaTime(-1.),
     
    6872      fConversionSigmaBlindPixelMethod(-1.),
    6973      fConversionSigmaPINDiodeMethod(-1.),
    70       fHiGainSaturation(kFALSE),
    71       fElectronicPedRms(1.5)
     74      fHiGainSaturation(kFALSE)
    7275{
    7376
     
    103106}
    104107
     108
     109Bool_t MCalibrationPix::IsFitted()
     110{
     111  return (fCharge > 0.) && (fErrCharge > 0.) ;
     112}
     113
     114// --------------------------------------------------------------------------
     115//
     116// Return TRUE if:
     117//
     118// 1) Pixel has a fitted charge greater than 3*PedRMS
     119// 2) Pixel has a fit error greater than 0.
     120// 3) Pixel has a fit Probability greater than 0.0001
     121// 4) Pixel has a charge sigma bigger than its Pedestal RMS
     122// 5) If FitTimes is used,
     123//    the mean arrival time is at least 1.5 slices from the edge
     124//
     125Bool_t MCalibrationPix::IsFitValid()
     126{
     127   
     128  if (fCharge < 3.*GetPedRms())
     129    return kFALSE;
     130 
     131  if (fErrCharge <= 0.)
     132    return kFALSE;
     133 
     134  if (!fHist->IsFitOK())
     135    return kFALSE;
     136 
     137  if (fSigmaCharge <= fPedRms)
     138    return kFALSE;
     139
     140  if (fHist->GetTimeLowerFitRange() < fTime < fHist->GetTimeLowerFitRange()+1.)
     141    return kFALSE;
     142
     143  if (fHist->GetTimeUpperFitRange()-1. < fTime < fHist->GetTimeUpperFitRange())
     144    return kFALSE;
     145
     146  return kTRUE;
     147 
     148}
     149
     150// --------------------------------------------------------------------------
     151//
     152// Return TRUE if:
     153//
     154// 1) Pixel is FitValid
     155// 2) Conversion Factor is bigger than 0.
     156// 3) The error of the conversion factor is smaller than 10%
     157//
     158Bool_t MCalibrationPix::IsBlindPixelMethodValid()
     159{
     160 
     161  if (!IsFitValid())
     162    return kFALSE;
     163
     164  if (fConversionBlindPixelMethod <= 0.)
     165    return kFALSE;
     166 
     167  if (fConversionErrorBlindPixelMethod/fConversionBlindPixelMethod > 0.1)
     168    return kFALSE;
     169 
     170  return kTRUE;
     171}
     172
     173// --------------------------------------------------------------------------
     174//
     175// Return TRUE if:
     176//
     177// 1) Pixel is FitValid
     178// 2) Conversion Factor is bigger than 0.
     179// 3) The error of the conversion factor is smaller than 10%
     180//
     181Bool_t MCalibrationPix::IsFFactorMethodValid()
     182{
     183 
     184  if (!IsFitValid())
     185    return kFALSE;
     186
     187  if (fConversionFFactorMethod <= 0.)
     188    return kFALSE;
     189 
     190  if (fConversionErrorFFactorMethod/fConversionFFactorMethod > 0.1)
     191    return kFALSE;
     192
     193  return kTRUE;
     194}
     195
     196// --------------------------------------------------------------------------
     197//
     198// Return TRUE if:
     199//
     200// 1) Pixel is FitValid
     201// 2) Conversion Factor is bigger than 0.
     202// 3) The error of the conversion factor is smaller than 10%
     203//
     204Bool_t MCalibrationPix::IsPINDiodeMethodValid()
     205{
     206 
     207  if (!IsFitValid())
     208    return kFALSE;
     209
     210  if (fConversionPINDiodeMethod <= 0.)
     211    return kFALSE;
     212 
     213  if (fConversionErrorPINDiodeMethod/fConversionPINDiodeMethod > 0.1)
     214    return kFALSE;
     215
     216  return kTRUE;
     217}
     218
     219// --------------------------------------------------------------------------
     220//
     221// 1) Return if the charge distribution is already succesfully fitted 
     222// 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
     223//    possible remaining cosmics to spoil the fit.
     224// 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
     225// 4) Fit the histograms with a Gaussian
     226// 5) In case of failure print out the fit results
     227// 6) Retrieve the results and store them in this class
     228// 7) Calculate the number of photo-electrons after the F-Factor method
     229// 8) Calculate the errors of the F-Factor method
     230//
    105231Bool_t MCalibrationPix::FitCharge()
    106232{
     
    123249          *fLog << warn << "Could not fit Lo Gain charges of pixel " << fPixId << endl;
    124250          fHist->PrintChargeFitResult();
    125           //      return kFALSE;
    126251        }
    127252    }
     
    132257          *fLog << warn << "Could not fit Hi Gain charges of pixel " << fPixId << endl;
    133258          fHist->PrintChargeFitResult();
    134           //      return kFALSE;
    135259        }
    136260    }
     
    143267  fChargeProb     = fHist->GetChargeProb();
    144268
     269  if (fCharge <= 0.)
     270    {
     271      *fLog << warn << "Cannot apply calibration: Mean Fitted Charges are smaller than 0 in pixel "
     272            << fPixId << endl;
     273      return kFALSE;
     274    }
     275 
     276
     277  //
     278  // Apply the F-Factor Method
     279  //
    145280  if ((fPed > 0.)  && (fPedRms > 0.))
    146281    {
    147282     
    148       Float_t pedrmssquare = fPedRms*fPedRms;
    149       Float_t sigmasquare  = fSigmaCharge*fSigmaCharge;
     283      //
     284      // Square all variables in order to avoid applications of square root
     285      //
     286      const Float_t chargesquare              =       fCharge*fCharge;
     287      const Float_t chargessquarerelerrsquare = 4.*fErrCharge*fErrCharge/chargesquare;
     288
     289      const Float_t sigmasquare         =       fSigmaCharge*fSigmaCharge;
     290      const Float_t sigmasquareerr      = 2.*fErrSigmaCharge*fSigmaCharge;
     291
     292      const Float_t pedrmssquare        =       fPedRms*fPedRms;
     293      const Float_t pedrmssquareerr     = 2.*fErrPedRms*fPedRms;
     294
     295      const Float_t elecrmssquare       =       fElectronicPedRms*fElectronicPedRms;
     296      const Float_t elecrmssquareerr    = 2.*fErrElectronicPedRms*fElectronicPedRms;
     297
     298      const Float_t conversionsquare    =    gkConversionHiLo     *gkConversionHiLo;
     299      const Float_t conversionsquareerr = 2.*gkConversionHiLoError*gkConversionHiLo;
     300
     301      const Float_t ffactorrelerrsquare = fFactorError * fFactorError / fFactor / fFactor;
     302
     303      Float_t rsigmasquarerelerrsquare  = 0.;
     304      Float_t   pheffactorrelerrsquare  = 0.;
    150305
    151306      if (fHiGainSaturation)
    152307        {
     308
     309          //
     310          // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
     311          // from the Hi Gain:
     312          //
     313          // We extract the pure NSB contribution:
     314          //
     315          Float_t nsbsquare            = pedrmssquare - elecrmssquare;
     316          Float_t nsbsquareerrsquare   = pedrmssquareerr  * pedrmssquareerr +
     317                                         elecrmssquareerr * elecrmssquareerr;
     318
     319          if (nsbsquare < 0.)
     320            nsbsquare = 0.;
    153321         
    154           Float_t logainrmssquare = fElectronicPedRms*fElectronicPedRms;
    155           Float_t nsbsquare       = pedrmssquare - logainrmssquare;
    156           //      Float_t logainrms = fElectronicPedRms + (TMath::Sqrt(fPedRms*fPedRms - fElectronicPedRms*fElectronicPedRms));
    157 
    158           if (nsbsquare > 0.)
    159               logainrmssquare = nsbsquare/100. + logainrmssquare;
    160 
    161           fRSigmaSquare = sigmasquare - logainrmssquare;
     322          //
     323          // Now, we divide the NSB by the conversion factor and
     324          // add it quadratically to the electronic noise
     325          //
     326          Float_t logainrmssquare          = nsbsquare/conversionsquare + elecrmssquare;
     327          Float_t logainrmssquareerrsquare = nsbsquareerrsquare/conversionsquare/conversionsquare
     328                                           + elecrmssquareerr * elecrmssquareerr ;
     329          //
     330          // Calculate the reduced sigma with the new "Pedestal RMS"
     331          //
     332          fRSigmaSquare            = sigmasquare - logainrmssquare;
     333          rsigmasquarerelerrsquare = (sigmasquareerr * sigmasquareerr + logainrmssquareerrsquare)
     334                                     / (fRSigmaSquare * fRSigmaSquare);
    162335
    163336          if (fRSigmaSquare > 0.)
    164             fPheFFactorMethod = fFactor*(fCharge*fCharge/100.) / fRSigmaSquare;
    165 
    166         }
    167       else  /* if (fHiGainSaturation) */
     337            {
     338              fPheFFactorMethod      = fFactor * chargesquare / fRSigmaSquare;
     339              pheffactorrelerrsquare =        ffactorrelerrsquare
     340                                      + chargessquarerelerrsquare
     341                                      +  rsigmasquarerelerrsquare ;
     342            }
     343         
     344        }    /* if (fHiGainSaturation) */
     345      else   
    168346        {
    169           fRSigmaSquare = sigmasquare - pedrmssquare;
    170           fPheFFactorMethod   =  fFactor * fCharge*fCharge / fRSigmaSquare;
     347          fRSigmaSquare            = sigmasquare - pedrmssquare;
     348          rsigmasquarerelerrsquare = (  sigmasquareerr *  sigmasquareerr
     349                                     + pedrmssquareerr * pedrmssquareerr)
     350                                   / (fRSigmaSquare * fRSigmaSquare);
     351
     352          fPheFFactorMethod      = fFactor * chargesquare / fRSigmaSquare;
     353          //
     354          // We first calculate the squared relative error in order to save the
     355          // TMath::Sqrt
     356          //
     357          pheffactorrelerrsquare = (       ffactorrelerrsquare
     358                                   + chargessquarerelerrsquare
     359                                   +  rsigmasquarerelerrsquare );
     360         
     361
     362        }   /* if (fHiGainSaturation) */
     363     
     364
     365      if (fPheFFactorMethod <= 0.)
     366        {
     367          *fLog << warn << "Cannot apply F-Factor calibration: Number of PhE smaller than 0 in pixel "
     368                << fPixId << endl;
     369          return kFALSE;
    171370        }
    172371     
    173 
    174       if (fCharge > 0.)
    175        fConversionFFactorMethod  =  fPheFFactorMethod /  fCharge ;
    176 
    177       else 
    178         *fLog << warn << "Cannot apply F-Factor method: Reduced Sigmas are smaller than 0 in pixel: "
    179               << fPixId << endl;
     372      fConversionFFactorMethod      =  fPheFFactorMethod /  fCharge ;
     373      fConversionErrorFFactorMethod =  fConversionFFactorMethod  *
     374                                       ( pheffactorrelerrsquare +
     375                                       (fErrCharge * fErrCharge / chargesquare ) );
     376
     377      fPheFFactorMethodError        =  TMath::Sqrt(pheffactorrelerrsquare) * fPheFFactorMethod;
    180378
    181379    } /*   if ((fPed > 0.)  && (fPedRms > 0.)) */
     
    186384
    187385
     386// --------------------------------------------------------------------------
     387//
     388// Set the pedestals from outside
     389//
    188390void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
    189391{
     
    194396}
    195397
     398// --------------------------------------------------------------------------
     399//
     400// 1) Fit the arrival times
     401// 2) Retrieve the results
     402// 3) Note that because of the low number of bins, the NDf is sometimes 0, so
     403//    Root does not give a reasonable Probability, the Chisquare is more significant
     404//
     405// This fit has to be done AFTER the Charges fit,
     406// otherwise only the Hi Gain will be fitted, even if there are no entries
     407//
     408//
    196409Bool_t MCalibrationPix::FitTime()
    197410{
    198411
     412  //
     413  // Fit the Low Gain
     414  //
    199415  if (fHiGainSaturation)
    200416    {
     
    206422        }
    207423    }
     424
     425  //
     426  // Fit the High Gain
     427  //
    208428  else
    209429    {
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h

    r2699 r2716  
    2323  Float_t fPed;                 // The mean pedestal (from MPedestalPix)
    2424  Float_t fPedRms;              // The pedestal  RMS (from MPedestalPix)
     25  Float_t fErrPedRms;           // The error of the pedestal  RMS (from MPedestalPix) 
     26  Float_t fElectronicPedRms;    // The pure electronic component of the RMS
     27  Float_t fErrElectronicPedRms; // The error of the pure electronic component of the RMS
    2528
    2629  Float_t fTime;                // The mean arrival time after the fit 
     
    2932 
    3033  Float_t fFactor;                  // The laboratory F-factor
     34  Float_t fFactorError;             // The laboratory F-factor Error
    3135  Float_t fPheFFactorMethod;        // The number of Phe's calculated after the F-factor method
     36  Float_t fPheFFactorMethodError;   // The error on the number of Phe's calculated after the F-factor method 
    3237
    33   Float_t fConversionFFactorMethod; // The conversion factor to Ph's calculated after the F-factor method
     38  Float_t fConversionFFactorMethod;    // The conversion factor to Ph's calculated after the F-factor method
    3439  Float_t fConversionBlindPixelMethod; // The conversion factor to Ph's calculated after the Blind Pixel method
    3540  Float_t fConversionPINDiodeMethod;   // The conversion factor to Ph's calculated after the PIN Diode method
    3641
    37   Float_t fConversionErrorFFactorMethod; // The conversion factor to Phe's calculated after the F-factor method
     42  Float_t fConversionErrorFFactorMethod;    // The conversion factor to Phe's calculated after the F-factor method
    3843  Float_t fConversionErrorBlindPixelMethod; // The conversion factor to Phe's calculated after the Blind Pixel method
    3944  Float_t fConversionErrorPINDiodeMethod;   // The conversion factor to Phe's calculated after the PIN Diode method
    4045
    41   Float_t fConversionSigmaFFactorMethod; // The conversion factor to Ph's calculated after the F-factor method
     46  Float_t fConversionSigmaFFactorMethod;    // The conversion factor to Ph's calculated after the F-factor method
    4247  Float_t fConversionSigmaBlindPixelMethod; // The conversion factor to Ph's calculated after the Blind Pixel method
    4348  Float_t fConversionSigmaPINDiodeMethod;   // The conversion factor to Phd's calculated after the PIN Diode method
    4449
    4550  Bool_t fHiGainSaturation;     // Is Lo-Gain used at all?
    46 
    47   Float_t fElectronicPedRms;
    4851
    4952  MHCalibrationPixel *fHist;    //! Pointer to the histograms performing the fits, etc. 
     
    98101  Float_t GetSigmaConversionBlindPixelMethod()  const  { return fConversionSigmaBlindPixelMethod ; }
    99102
    100   Float_t GetMeanConversionFFactorMethod()      const  { return fConversionFFactorMethod ; }
    101   Float_t GetErrorConversionFFactorMethod()     const  { return fConversionErrorFFactorMethod ; }
    102   Float_t GetSigmaConversionFFactorMethod()     const  { return fConversionSigmaFFactorMethod ; }
    103   Float_t GetPheFFactorMethod()                 const  { return fPheFFactorMethod;           } 
     103  Float_t GetMeanConversionFFactorMethod()      const  { return fConversionFFactorMethod ;       }
     104  Float_t GetErrorConversionFFactorMethod()     const  { return fConversionErrorFFactorMethod ;  }
     105  Float_t GetSigmaConversionFFactorMethod()     const  { return fConversionSigmaFFactorMethod ;  }
     106
     107  Float_t GetPheFFactorMethod()                 const  { return fPheFFactorMethod;               }
     108  Float_t GetPheFFactorMethodError()            const  { return fPheFFactorMethodError;          }   
    104109 
    105   Float_t GetMeanConversionPINDiodeMethod()     const  { return fConversionPINDiodeMethod ; }
     110  Float_t GetMeanConversionPINDiodeMethod()     const  { return fConversionPINDiodeMethod ;      }
    106111  Float_t GetErrorConversionPINDiodeMethod()    const  { return fConversionErrorPINDiodeMethod ; }
    107112  Float_t GetSigmaConversionPINDiodeMethod()    const  { return fConversionSigmaPINDiodeMethod ; }
     
    117122  Bool_t FillRChargevsTimeLoGain(Float_t rq, Int_t t)  { return fHist->FillChargevsNLoGain(rq,t); }   
    118123 
    119   Bool_t IsValid()                               const  { return fCharge >= 3.*GetPedRms() || fErrCharge >= 0; }
     124  Bool_t IsFitValid();       
     125  Bool_t IsFitted();
     126  Bool_t IsBlindPixelMethodValid();
     127  Bool_t IsFFactorMethodValid();
     128  Bool_t IsPINDiodeMethodValid();
     129 
    120130  Int_t  GetPixId()                              const  { return fPixId;   }
    121131  void   DefinePixId(Int_t i);
Note: See TracChangeset for help on using the changeset viewer.