Changeset 2931


Ignore:
Timestamp:
01/27/04 20:32:42 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mcalib
Files:
12 edited

Legend:

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

    r2833 r2931  
    4545//
    4646MCalibrationBlindPix::MCalibrationBlindPix(const char *name, const char *title)
    47     : fHist(NULL),
    48       fLambda(-1.),
    49       fMu0   (-1.),
    50       fMu1   (-1.),
    51       fSigma0(-1.),
    52       fSigma1(-1.),
    53       fErrLambda(-1.),
    54       fErrMu0   (-1.),
    55       fErrMu1   (-1.),
    56       fErrSigma0(-1.),
    57       fErrSigma1(-1.),
    58       fTime     (-1.),
    59       fErrTime  (-1.)
    6047{
    6148
     
    6855    *fLog << warn << dbginf << " Could not create MHCalibrationBlindPixel " << endl;
    6956 
     57  Clear();
    7058}
    7159
     
    8270{
    8371  fHist->Reset();
     72
     73  fLambda = -1.;
     74  fMu0    = -1.;
     75  fMu1    = -1.;
     76  fSigma0 = -1.;
     77  fSigma1 = -1.;
     78  fErrLambda = -1.;
     79  fErrMu0    = -1.;
     80  fErrMu1    = -1.;
     81  fErrSigma0 = -1.;
     82  fErrSigma1 = -1.;
     83  fTime      = -1.;
     84  fErrTime   = -1;
     85
    8486}
    8587
  • trunk/MagicSoft/Mars/mcalib/MCalibrationBlindPix.h

    r2904 r2931  
    5252 
    5353  MHCalibrationBlindPixel *GetHist()     const  { return fHist;  }
     54  MHCalibrationBlindPixel *GetHist()            { return fHist;  }
    5455 
    55   Bool_t IsFitOK()                              { return fHist->IsFitOK(); }
     56  Bool_t IsFitOK()                        const  { return fHist->IsFitOK(); }
    5657 
    5758  // Fill histos
    58   Bool_t FillCharge(Float_t q)                  { return fHist->FillBlindPixelCharge(q); }
    59   Bool_t FillTime(Float_t t)                    { return fHist->FillBlindPixelTime(t); } 
    60   Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillBlindPixelChargevsN(rq,t); }   
     59  Bool_t FillCharge(Float_t q)                  const { return fHist->FillBlindPixelCharge(q); }
     60  Bool_t FillTime(Float_t t)                    const { return fHist->FillBlindPixelTime(t); } 
     61  Bool_t FillRChargevsTime(Float_t rq, Int_t t) const { return fHist->FillBlindPixelChargevsN(rq,t); }   
    6162 
    6263  // Fits
    6364  Bool_t FitCharge();
    6465  Bool_t FitTime();
    65   void ChangeFitFunc(MHCalibrationBlindPixel::FitFunc_t f)   { fHist->ChangeFitFunc(f); }
     66  void ChangeFitFunc(MHCalibrationBlindPixel::FitFunc_t f) const  { fHist->ChangeFitFunc(f); }
    6667 
    6768  // Draws
    68   void Draw(Option_t *opt="")                     { fHist->Draw(opt); }
    69   TObject *DrawClone(Option_t *opt="") const    { return fHist->DrawClone(opt); } 
     69  void Draw(Option_t *opt="")                  { fHist->Draw(opt); }
     70  TObject *DrawClone(Option_t *opt="") const  { return fHist->DrawClone(opt); } 
    7071 
    7172  ClassDef(MCalibrationBlindPix, 1)     // Storage Container for Calibration information of one pixel
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc

    r2904 r2931  
    262262      return kFALSE;
    263263    }
    264 
    265264
    266265    fNumHiGainSamples =  fSignals->GetNumUsedHiGainFADCSlices();
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc

    r2930 r2931  
    7070//
    7171MCalibrationCam::MCalibrationCam(const char *name, const char *title)
    72     : fNumPhotInsidePlexiglassAvailable(kFALSE),
    73       fMeanPhotInsidePlexiglass(-1.),
    74       fMeanPhotErrInsidePlexiglass(-1.),
    75       fNumPhotOutsidePlexiglassAvailable(kFALSE),
    76       fMeanPhotOutsidePlexiglass(-1.),
    77       fMeanPhotErrOutsidePlexiglass(-1.),
    78       fOffsets(NULL),
     72    : fOffsets(NULL),
    7973      fSlopes(NULL),
    80       fOffvsSlope(NULL),
    81       fNumExcludedPixels(0)
    82 
     74      fOffvsSlope(NULL)
    8375{
    8476    fName  = name  ? name  : "MCalibrationCam";
     
    8981    fPINDiode   = new MCalibrationPINDiode();
    9082
     83    Clear();
    9184}
    9285
     
    125118// fSize is the old size (in most cases: 1)
    126119//
    127 void MCalibrationCam::InitSize(const UInt_t size)
     120void MCalibrationCam::InitSize(const UInt_t i)
    128121{
    129122 
     
    131124  // check if we have already initialized to size
    132125  //
    133   if (CheckBounds(size))
     126  if (CheckBounds(i))
    134127    return;
    135128 
    136   fPixels->ExpandCreate(size);
     129  fPixels->ExpandCreate(i);
    137130
    138131}
     
    156149Bool_t MCalibrationCam::CheckBounds(Int_t i) const
    157150{
    158     return i < fPixels->GetEntriesFast();
     151  return i < GetSize();
    159152}
    160153
     
    187180
    188181
    189 // --------------------------------------------------------------------------
    190 //
    191 // Return true if pixel is inside bounds of the TClonesArray fPixels
    192 //
    193 Bool_t MCalibrationCam::IsPixelUsed(Int_t idx) const
    194 {
    195   if (!CheckBounds(idx))
    196     return kFALSE;
    197 
    198   return kTRUE;
    199 }
    200 
    201 // --------------------------------------------------------------------------
    202 //
    203 // Return true if pixel has already been fitted once (independent of the result)
    204 //
    205 Bool_t MCalibrationCam::IsPixelFitted(Int_t idx) const
    206 {
    207 
    208   if (!CheckBounds(idx))
    209     return kFALSE;
    210 
    211   return (*this)[idx].IsFitted();
    212 }
    213 
    214 
    215182// --------------------------------------
    216183//
    217184void MCalibrationCam::Clear(Option_t *o)
    218185{
    219     fPixels->ForEach(TObject, Clear)();
    220 }
    221 
    222 // --------------------------------------------------------------------------
    223 //
    224 // Sets the user ranges of all histograms such that
    225 // empty bins at the edges are not used. Additionally, it rebins the
    226 // histograms such that in total, 50 bins are used.
    227 //
    228 void MCalibrationCam::CutEdges()
    229 {
    230 
    231   fBlindPixel->GetHist()->CutAllEdges();
    232   fPINDiode->GetHist()->CutAllEdges();
    233 
    234   TIter Next(fPixels);
    235   MCalibrationPix *pix;
    236   while ((pix=(MCalibrationPix*)Next()))
    237     {
    238       pix->GetHist()->CutAllEdges();
    239     }
     186
     187  fPixels->ForEach(TObject, Clear)();
     188  fBlindPixel->Clear();
     189  fPINDiode->Clear();
     190
     191  fNumPhotInsidePlexiglassAvailable  = kFALSE;
     192  fMeanPhotInsidePlexiglass          = -1.;
     193  fMeanPhotErrInsidePlexiglass       = -1.;
     194  fNumPhotOutsidePlexiglassAvailable = kFALSE;
     195  fMeanPhotOutsidePlexiglass         = -1.;
     196  fMeanPhotErrOutsidePlexiglass      = -1.;
     197
     198  fNumExcludedPixels                 = 0;
    240199
    241200  return;
    242201}
    243  
     202
    244203// --------------------------------------------------------------------------
    245204//
     
    312271
    313272  *fLog << all << fNumExcludedPixels << " excluded pixels " << endl;
    314  
    315 }
     273}
     274
     275// --------------------------------------------------------------------------
     276//
     277// Return true if pixel is inside bounds of the TClonesArray fPixels
     278//
     279Bool_t MCalibrationCam::IsPixelUsed(Int_t idx) const
     280{
     281  if (!CheckBounds(idx))
     282    return kFALSE;
     283
     284  return kTRUE;
     285}
     286
     287// --------------------------------------------------------------------------
     288//
     289// Return true if pixel has already been fitted once (independent of the result)
     290//
     291Bool_t MCalibrationCam::IsPixelFitted(Int_t idx) const
     292{
     293
     294  if (!CheckBounds(idx))
     295    return kFALSE;
     296
     297  return (*this)[idx].IsFitted();
     298}
     299
     300// --------------------------------------------------------------------------
     301//
     302// Sets the user ranges of all histograms such that
     303// empty bins at the edges are not used. Additionally, it rebins the
     304// histograms such that in total, 50 bins are used.
     305//
     306void MCalibrationCam::CutEdges()
     307{
     308
     309  fBlindPixel->GetHist()->CutAllEdges();
     310  fPINDiode->GetHist()->CutAllEdges();
     311
     312  TIter Next(fPixels);
     313  MCalibrationPix *pix;
     314  while ((pix=(MCalibrationPix*)Next()))
     315    {
     316      pix->GetHist()->CutAllEdges();
     317    }
     318
     319  return;
     320}
     321 
    316322
    317323// The types are as follows:
     
    500506{
    501507
    502   if (!fPINDiode->IsFitOK())
    503     return kFALSE;
    504  
    505   const Float_t mean = fPINDiode->GetMean();
    506   const Float_t merr = fPINDiode->GetMeanError();
     508  if (!fPINDiode->IsFitValid())
     509    return kFALSE;
     510 
     511  const Float_t mean = fPINDiode->GetCharge();
     512  const Float_t merr = fPINDiode->GetErrCharge();
    507513 
    508514  switch (fColor)
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCam.h

    r2930 r2931  
    3737  TH2D* fOffvsSlope;                          //!
    3838
    39   UInt_t  fNumExcludedPixels;
     39  UInt_t fNumExcludedPixels;
    4040
    4141public:
     
    6060   
    6161  // Getters
    62   Int_t GetSize()                    const;
    63   UInt_t GetNumPixels()              const { return fNumPixels; }
     62  Int_t GetSize()                        const;
     63  UInt_t GetNumPixels()                  const { return fNumPixels; }
    6464
    65   MCalibrationBlindPix *GetBlindPixel()              const { return fBlindPixel;  }
    66   MCalibrationPINDiode *GetPINDiode()                const { return fPINDiode;    }
     65  MCalibrationBlindPix *GetBlindPixel()  const { return fBlindPixel;  }
     66  MCalibrationPINDiode *GetPINDiode()    const { return fPINDiode;    }
     67  MCalibrationBlindPix *GetBlindPixel()       { return fBlindPixel;  }
     68  MCalibrationPINDiode *GetPINDiode()         { return fPINDiode;    }
    6769
    6870  Bool_t GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma);
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.cc

    r2922 r2931  
    4444//
    4545MCalibrationPINDiode::MCalibrationPINDiode(const char *name, const char *title)
    46   : fHist(NULL),
    47     fCharge(-1.),
    48     fErrCharge(-1.),
    49     fPed(-1.),
    50     fPedRms(-1.),
    51     fSigmaCharge(-1.),
    52     fErrSigmaCharge(-1.),
    53     fTime(-1.),
    54     fErrTime(-1.)
     46    : fChargeLimit(3.),
     47      fChargeErrLimit(0.),
     48      fChargeRelErrLimit(1.),
     49      fFlags(0)
    5550{
    5651
     
    6257  if (!fHist)
    6358    *fLog << warn << dbginf << " Could not create MHCalibrationPINDiode " << endl;
    64  
     59 
     60  Clear();
     61
    6562}
    6663
     
    7774{
    7875  fHist->Reset();
     76
     77  CLRBIT(fFlags, kExcluded);
     78  CLRBIT(fFlags, kFitValid);
     79  CLRBIT(fFlags, kFitted);
     80
     81  fCharge                           =  -1.;
     82  fErrCharge                        =  -1.;
     83  fSigmaCharge                      =  -1.;
     84  fErrSigmaCharge                   =  -1.;
     85  fRSigmaSquare                     =  -1.;
     86  fChargeProb                       =  -1.;
     87  fPed                              =  -1.;
     88  fPedRms                           =  -1.;
     89  fTime                             =  -1.;
     90  fSigmaTime                        =  -1.;
     91  fTimeChiSquare                    =  -1.;
     92
     93}
     94
     95
     96// --------------------------------------------------------------------------
     97//
     98// Set the pedestals from outside
     99//
     100void MCalibrationPINDiode::SetPedestal(Float_t ped, Float_t pedrms)
     101{
     102
     103  fPed    = ped;   
     104  fPedRms = pedrms;
     105 
     106}
     107
     108// --------------------------------------------------------------------------
     109//
     110// Set the Excluded Bit from outside
     111//
     112void MCalibrationPINDiode::SetExcluded(Bool_t b )
     113{
     114  b ?  SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
     115}
     116
     117
     118// --------------------------------------------------------------------------
     119//
     120// Set the Excluded Bit from outside
     121//
     122void MCalibrationPINDiode::SetExcludeQualityCheck(Bool_t b )
     123{
     124  b ?  SETBIT(fFlags, kExcludeQualityCheck) : CLRBIT(fFlags, kExcludeQualityCheck);
     125}
     126
     127// --------------------------------------------------------------------------
     128//
     129// Set the Excluded Bit from outside
     130//
     131void MCalibrationPINDiode::SetFitValid(Bool_t b )   
     132{
     133  b ?  SETBIT(fFlags, kFitValid) : CLRBIT(fFlags, kFitValid);
     134}
     135
     136// --------------------------------------------------------------------------
     137//
     138// Set the Excluded Bit from outside
     139//
     140void MCalibrationPINDiode::SetFitted(Bool_t b )
     141{
     142  b ?  SETBIT(fFlags, kFitted) : CLRBIT(fFlags, kFitted);
     143}
     144
     145Bool_t MCalibrationPINDiode::IsExcluded() const
     146 {
     147   return TESTBIT(fFlags,kExcluded); 
     148 }
     149
     150Bool_t MCalibrationPINDiode::IsFitValid() const
     151{
     152  return TESTBIT(fFlags, kFitValid); 
     153}
     154
     155Bool_t MCalibrationPINDiode::IsFitted() const
     156{
     157  return TESTBIT(fFlags, kFitted);   
    79158}
    80159
    81160Bool_t MCalibrationPINDiode::FitCharge()
    82161{
    83   if(!fHist->FitCharge())
    84     return kFALSE;
    85 
     162
     163  //
     164  // 1) Return if the charge distribution is already succesfully fitted 
     165  //    or if the histogram is empty
     166  //
     167  if (fHist->IsFitOK() || fHist->IsEmpty())
     168    return kTRUE;
     169
     170  //
     171  // 4) Fit the Lo Gain histograms with a Gaussian
     172  //
     173  if(fHist->FitCharge())
     174    {
     175      SETBIT(fFlags,kFitted);
     176    }
     177  else
     178    {
     179      *fLog << warn << "WARNING: Could not fit charges of PINDiode " << endl;
     180      //         
     181      // 5) In case of failure print out the fit results
     182      //
     183      //          fHist->PrintChargeFitResult();
     184      CLRBIT(fFlags,kFitted);
     185    }
     186
     187  //
     188  // 6) Retrieve the results and store them in this class
     189  //
    86190  fCharge         = fHist->GetChargeMean();
    87191  fErrCharge      = fHist->GetChargeMeanErr();
    88192  fSigmaCharge    = fHist->GetChargeSigma();
    89193  fErrSigmaCharge = fHist->GetChargeSigmaErr();
     194  fChargeProb     = fHist->GetChargeProb();
     195
     196  if (CheckChargeFitValidity())
     197    SETBIT(fFlags,kFitValid);
     198  else
     199    {
     200      CLRBIT(fFlags,kFitValid);
     201      return kFALSE;
     202    }
    90203
    91204  return kTRUE;
     
    93206}
    94207
     208//
     209// The check return kTRUE if:
     210//
     211// 1) PINDiode has a fitted charge greater than 5*PedRMS
     212// 2) PINDiode has a fit error greater than 0.
     213// 3) PINDiode has a fitted charge greater its charge error
     214// 4) PINDiode has a fit Probability greater than 0.0001
     215// 5) PINDiode has a charge sigma bigger than its Pedestal RMS
     216//
     217Bool_t MCalibrationPINDiode::CheckChargeFitValidity()
     218{
     219
     220  if (TESTBIT(fFlags,kExcludeQualityCheck))
     221    return kTRUE;
     222
     223  if (fCharge < fChargeLimit*GetPedRms())
     224    {
     225      *fLog << warn << "WARNING: Fitted Charge is smaller than "
     226            << fChargeLimit << " Pedestal RMS in PINDiode " << endl;
     227      return kFALSE;
     228    }
     229 
     230  if (fErrCharge < fChargeErrLimit)
     231    {
     232      *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
     233            << fChargeErrLimit << " in PINDiode " << endl;
     234      return kFALSE;
     235    }
     236     
     237  if (fCharge < fChargeRelErrLimit*fErrCharge)
     238    {
     239      *fLog << warn << "WARNING: Fitted Charge is smaller than "
     240            << fChargeRelErrLimit << "* its error in PINDiode " << endl;
     241      return kFALSE;
     242    }
     243     
     244  if (!fHist->IsFitOK())
     245    {
     246      *fLog << warn << "WARNING: Probability of Fitted Charge too low in PINDiode " << endl;
     247      return kFALSE;
     248    }
     249
     250  if (fSigmaCharge < GetPedRms())
     251    {
     252      *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl;
     253      return kFALSE;
     254    }
     255  return kTRUE;
     256}
     257
     258
     259// --------------------------------------------------------------------------
     260//
     261// 1) Fit the arrival times
     262// 2) Retrieve the results
     263// 3) Note that because of the low number of bins, the NDf is sometimes 0, so
     264//    Root does not give a reasonable Probability, the Chisquare is more significant
     265//
    95266Bool_t MCalibrationPINDiode::FitTime()
    96267{
    97268
    98269  if(!fHist->FitTimeHiGain())
    99     return kFALSE;
    100 
    101   fTime    = fHist->GetTime();
    102   fErrTime = fHist->GetErrTime();
    103  
     270    {
     271      *fLog << warn << "WARNING: Could not fit Hi Gain times of PIN Diode" << endl;
     272      fHist->PrintTimeFitResult();
     273      return kFALSE;
     274    }
     275 
     276  fTime          = fHist->GetTimeMean();
     277  fSigmaTime     = fHist->GetTimeSigma();
     278  fTimeChiSquare = fHist->GetTimeChiSquare();
     279  fTimeProb      = fHist->GetTimeProb();
     280 
     281  if (CheckTimeFitValidity())
     282    SETBIT(fFlags,kFitValid);
     283  else
     284    CLRBIT(fFlags,kFitValid);
     285
    104286  return kTRUE;
    105 
    106 }
     287}
     288
     289//
     290// The check returns kTRUE if:
     291//
     292// The mean arrival time is at least 1.0 slices from the used edge slices
     293//
     294Bool_t MCalibrationPINDiode::CheckTimeFitValidity()
     295{
     296
     297  if (TESTBIT(fFlags,kExcludeQualityCheck))
     298    return kTRUE;
     299
     300  return kTRUE;
     301}
     302
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.h

    r2904 r2931  
    1111
    1212  MHCalibrationPINDiode *fHist; // Pointer to the histograms performing the fits, etc. 
     13
     14  const Float_t fChargeLimit;       // The limit (in units of PedRMS) for acceptance of the fitted mean charge
     15  const Float_t fChargeErrLimit;    // The limit (in units of PedRMS) for acceptance of the fitted charge sigma
     16  const Float_t fChargeRelErrLimit; // The limit (in units of Error of fitted charge) for acceptance of the fitted mean 
    1317 
     18  Float_t fPed;                   // The mean pedestal (from MPedestalPix)
     19  Float_t fPedRms;                // The pedestal  RMS (from MPedestalPix)
     20
    1421  Float_t fCharge;                // The mean charge after the fit
    1522  Float_t fErrCharge;             // The error of mean charge after the fit
    16   Float_t fPed;              // The mean pedestal (from MPedestalPix)
    17   Float_t fPedRms;           // The pedestal  RMS (from MPedestalPix)
    1823  Float_t fSigmaCharge;           // The sigma of the mean charge after the fit
    1924  Float_t fErrSigmaCharge;        // The error of the sigma of the mean charge after the fit
    20   Float_t fTime;                // The mean arrival time after the fit 
    21   Float_t fErrTime;             // The error of the mean arrival time after the fit
     25  Float_t fRSigmaSquare;          // The reduced squares of sigmas after the fit
     26  Float_t fChargeProb;            // The probability of the fit function
     27
     28  Float_t fTime;                  // The mean arrival time after the fit 
     29  Float_t fSigmaTime;             // The error of the mean arrival time after the fit
     30  Float_t fTimeChiSquare;         // The Chi Square of the fit function
     31  Float_t fTimeProb;              // The probability of the fit function
     32 
     33  Byte_t  fFlags;                 // Flag for the set Bits
     34
     35  enum  { kExcluded, kExcludeQualityCheck,
     36          kFitValid, kFitted  };
     37 
     38  Bool_t CheckChargeFitValidity();
     39  Bool_t CheckTimeFitValidity();
     40  Bool_t CheckOscillations(); 
    2241 
    2342public:
     
    2847  void Clear(Option_t *o="");
    2948 
    30   void SetPed(Float_t ped)          { fPed      = ped;      }
    31   void SetPedRms(Float_t pedrms)    { fPedRms   = pedrms; }
     49  // Getter
     50  MHCalibrationPINDiode *GetHist() const   { return fHist;    }
    3251
    33   Float_t GetMean()           const { return fCharge; }
    34   Float_t GetMeanError()      const { return fErrCharge; }
     52  // Charges
     53  Float_t GetCharge()              const { return fCharge;         }
     54  Float_t GetErrCharge()           const { return fErrCharge;      }
     55  Float_t GetChargeProb()          const { return fChargeProb;     }   
     56  Float_t GetSigmaCharge()         const { return fSigmaCharge;    }
     57  Float_t GetErrSigmaCharge()      const { return fErrSigmaCharge; }
     58  Float_t GetRSigmaSquare()        const { return fRSigmaSquare;   }
    3559
    36   Bool_t IsFitOK() const            { return fCharge > 0 && fErrCharge > 0; }
     60  // Times 
     61  Float_t GetTime()                const { return fTime;           }
     62  Float_t GetSigmaTime()           const { return fSigmaTime;      }
     63  Float_t GetTimeChiSquare()       const { return fTimeChiSquare;  }
     64  Float_t GetTimeProb()            const { return fTimeProb;  }     
    3765
     66  // Pedestals
     67  Float_t GetPed()                 const { return fPed;    }
     68  Float_t GetPedRms()              const { return fPedRms; }
     69
     70  Bool_t IsExcluded()              const;
     71  Bool_t IsFitValid()              const;
     72  Bool_t IsFitted()                const;
     73
     74  // Setters
     75  void SetPedestal(Float_t ped, Float_t pedrms);
     76  void SetExcluded(Bool_t b = kTRUE);
     77  void SetExcludeQualityCheck(Bool_t b = kTRUE);
     78  void SetFitValid(Bool_t b = kTRUE);
     79  void SetFitted(Bool_t b = kTRUE);
     80
     81  // Fill histos
    3882  Bool_t FillCharge(Float_t q)      { return fHist->FillChargeHiGain(q); }
    3983  Bool_t FillTime(Float_t t)        { return fHist->FillTimeHiGain(t); } 
    4084  Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillChargevsNHiGain(rq,t); }   
    41  
     85
     86  // Fits
    4287  Bool_t FitCharge();
    4388  Bool_t FitTime();
     89
     90  // Draws
     91  void Draw(Option_t *opt="")                    { fHist->Draw(opt); }
     92  TObject *DrawClone(Option_t *opt="") const    { return fHist->DrawClone(opt); } 
    4493 
    45   MHCalibrationPINDiode *GetHist()  const  { return fHist;  }
    46  
    47   ClassDef(MCalibrationPINDiode, 1)     // Storage Container for Calibration information of one pixel
     94  ClassDef(MCalibrationPINDiode, 1)     // Storage Container for Calibration information of the PIN Diode
    4895};
    4996
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc

    r2922 r2931  
    5858//
    5959MHCalibrationBlindPixel::MHCalibrationBlindPixel(const char *name, const char *title)
    60     :     fHBlindPixelCharge(NULL),
    61           fHBlindPixelTime(NULL),
    62           fHBlindPixelChargevsN(NULL),
    63           fHBlindPixelPSD(NULL),
    64           fSinglePheFit(NULL), 
    65           fTimeGausFit(NULL),
    66           fSinglePhePedFit(NULL),
    67           fBlindPixelChargefirst(0.),
    68           fBlindPixelChargelast(0.),
    69           fBlindPixelChargenbins(0),
    70           fFitLegend(NULL), fFitOK(kFALSE),
    71           fLambda(0.), fMu0(0.), fMu1(0.), fSigma0(0.), fSigma1(0.),
    72           fLambdaErr(0.), fMu0Err(0.), fMu1Err(0.), fSigma0Err(0.), fSigma1Err(0.),   
    73           fChisquare(0.), fProb(0.),  fNdf(0),
    74           fMeanTime(0.),  fMeanTimeErr(0.), fSigmaTime(0.), fSigmaTimeErr(0.),
    75           fLambdaCheck(0.), fLambdaCheckErr(0.),
    76           fFitFunc(kEPoisson4)
     60    :   fBlindPixelChargeNbins(500),
     61        fBlindPixelTimeNbins(32),
     62        fBlindPixelChargevsNbins(1000),
     63        fBlindPixelTimeFirst(-0.25),
     64        fBlindPixelTimeLast(15.75),
     65        fHBlindPixelPSD(NULL),
     66        fSinglePheFit(NULL), 
     67        fTimeGausFit(NULL),
     68        fSinglePhePedFit(NULL),
     69        fFitLegend(NULL)
    7770{
    7871
     
    8174
    8275    // Create a large number of bins, later we will rebin
    83     fBlindPixelChargefirst = -1000.;
    84     fBlindPixelChargelast  = gkStartBlindPixelBinNr;
    85     fBlindPixelChargenbins = gkStartBlindPixelBinNr+(int)fBlindPixelChargefirst;
     76    fBlindPixelChargefirst = -100.;
     77    fBlindPixelChargelast  = 400.;
    8678
    8779    fHBlindPixelCharge = new TH1F("HBlindPixelCharge","Distribution of Summed FADC Slices",
    88                                   fBlindPixelChargenbins,fBlindPixelChargefirst,fBlindPixelChargelast);
     80                                  fBlindPixelChargeNbins,fBlindPixelChargefirst,fBlindPixelChargelast);
    8981    fHBlindPixelCharge->SetXTitle("Sum FADC Slices");
    9082    fHBlindPixelCharge->SetYTitle("Nr. of events");
     
    9284    fHBlindPixelCharge->SetDirectory(NULL);
    9385
    94     Axis_t tfirst = -0.5;
    95     Axis_t tlast  = 15.5;
    96     Int_t nbins   = 16;
    97 
    98     fHBlindPixelTime = new TH1F("HBlindPixelTime","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
     86    fHBlindPixelTime = new TH1F("HBlindPixelTime","Distribution of Mean Arrival Times",
     87                                fBlindPixelTimeNbins,fBlindPixelTimeFirst,fBlindPixelTimeLast);
    9988    fHBlindPixelTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
    10089    fHBlindPixelTime->SetYTitle("Nr. of events");
     
    10291    fHBlindPixelTime->SetDirectory(NULL);
    10392
    104     // We define a reasonable number and later enlarge it if necessary
    105     nbins = 20000;
    106     Axis_t nfirst = -0.5;
    107     Axis_t nlast  = (Axis_t)nbins - 0.5;
    108 
    109     fHBlindPixelChargevsN = new TH1I("HBlindPixelChargevsN","Sum of Charges vs. Event Number",nbins,nfirst,nlast);
     93    fHBlindPixelChargevsN = new TH1I("HBlindPixelChargevsN","Sum of Charges vs. Event Number",
     94                                     fBlindPixelChargevsNbins,-0.5,(Axis_t)fBlindPixelChargevsNbins-0.5);
    11095    fHBlindPixelChargevsN->SetXTitle("Event Nr.");
    11196    fHBlindPixelChargevsN->SetYTitle("Sum of FADC slices");
    11297    fHBlindPixelChargevsN->SetDirectory(NULL);
    11398
     99    Clear();
    114100}
    115101
     
    126112  if (fHBlindPixelPSD)
    127113    delete fHBlindPixelPSD;
    128 
    129114  if (fSinglePheFit) 
    130115    delete fSinglePheFit;
     
    136121}
    137122
     123void MHCalibrationBlindPixel::Clear(Option_t *o)
     124{
     125 
     126  fBlindPixelChargefirst = -100.;
     127  fBlindPixelChargelast  = 400.;
     128
     129  fLambda    = 0.;
     130  fMu0       = 0.;
     131  fMu1       = 0.;
     132  fSigma0    = 0.;
     133  fSigma1    = 0.;
     134 
     135  fLambdaErr = 0.;
     136  fMu0Err    = 0.;
     137  fMu1Err    = 0.;
     138  fSigma0Err = 0.;
     139  fSigma1Err = 0.;
     140
     141  fChisquare = -1.;
     142  fProb      = -1.;
     143  fNdf       = -1;
     144
     145  fMeanTime     = -1.;
     146  fMeanTimeErr  = -1.;
     147  fSigmaTime    = -1.;
     148  fSigmaTimeErr = -1.;
     149 
     150  fLambdaCheck    = -1.;
     151  fLambdaCheckErr = -1.;
     152 
     153  fFitFunc = kEPoisson4;
     154
     155  if (fFitLegend)
     156    delete fFitLegend;
     157  if (fHBlindPixelPSD)
     158    delete fHBlindPixelPSD;
     159  if (fSinglePheFit) 
     160    delete fSinglePheFit;
     161  if (fTimeGausFit)
     162    delete fTimeGausFit;
     163  if(fSinglePhePedFit)
     164    delete fSinglePhePedFit;
     165
     166  return;
     167}
     168
     169void MHCalibrationBlindPixel::Reset()
     170{
     171 
     172  Clear();
     173
     174  fHBlindPixelCharge->Reset();
     175  fHBlindPixelTime->Reset();
     176  fHBlindPixelChargevsN->Reset();
     177 
     178}
     179
    138180Bool_t MHCalibrationBlindPixel::FillBlindPixelCharge(Float_t q)
    139181{
     
    149191{
    150192    return fHBlindPixelChargevsN->Fill(t,rq) > -1;
    151 }
    152 
    153 
    154 void MHCalibrationBlindPixel::ResetBin(Int_t i)
    155 {
    156     fHBlindPixelCharge->SetBinContent (i, 1.e-20);
    157     fHBlindPixelTime->SetBinContent(i, 1.e-20);
    158193}
    159194
     
    578613  fBlindPixelChargefirst = fHBlindPixelCharge->GetBinLowEdge(fHBlindPixelCharge->GetXaxis()->GetFirst());
    579614  fBlindPixelChargelast  = fHBlindPixelCharge->GetBinLowEdge(fHBlindPixelCharge->GetXaxis()->GetLast())+fHBlindPixelCharge->GetBinWidth(0);
    580   fBlindPixelChargenbins = nbins;
    581615
    582616  CutEdges(fHBlindPixelChargevsN,0);
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.h

    r2920 r2931  
    1717private:
    1818
     19  const Int_t fBlindPixelChargeNbins;
     20  const Int_t fBlindPixelTimeNbins;
     21  const Int_t fBlindPixelChargevsNbins;
     22  const Axis_t fBlindPixelTimeFirst;
     23  const Axis_t fBlindPixelTimeLast;
     24 
    1925  TH1F* fHBlindPixelCharge;        // Histogram with the single Phe spectrum
    2026  TH1F* fHBlindPixelTime;          // Variance of summed FADC slices
     
    2834  Axis_t  fBlindPixelChargefirst;
    2935  Axis_t  fBlindPixelChargelast;
    30   Int_t   fBlindPixelChargenbins;
    31  
    32   void ResetBin(Int_t i);
     36 
    3337  void DrawLegend();
    3438
     
    6569  ~MHCalibrationBlindPixel();
    6670
     71  void Clear(Option_t *o=""); 
     72  void Reset();
     73 
    6774  Bool_t FillBlindPixelCharge(Float_t q);
    6875  Bool_t FillBlindPixelTime(Float_t t);
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.cc

    r2905 r2931  
    3636#include <TH1.h>
    3737#include <TF1.h>
     38#include <TPaveText.h>
    3839
    3940ClassImp(MHCalibrationPINDiode);
     
    4647//
    4748MHCalibrationPINDiode::MHCalibrationPINDiode(const char *name, const char *title)
    48     : fVarGausFit(NULL)
     49    : fChargeNbins(1000),
     50      fTimeNbins(64),
     51      fChargevsNbins(10000),
     52      fTimeFirst(-0.25),
     53      fTimeLast(31.75)
    4954{
    5055
     
    5358
    5459    // Create a large number of bins, later we will rebin
    55     fChargeFirstHiGain = -1000.;
    56     fChargeLastHiGain  = gkStartPINDiodeBinNr;
    57     fChargeNbinsHiGain = gkStartPINDiodeBinNr;
     60    fChargeFirstHiGain = -100.5;
     61    fChargeLastHiGain  = 1999.5;
    5862
    59     fHPCharge = new TH1I("HPCharge","Distribution of Summed FADC Slices",
    60                          fChargeNbinsHiGain,fChargeFirstHiGain,fChargeLastHiGain);
    61     fHPCharge->SetXTitle("Sum FADC Slices");
    62     fHPCharge->SetYTitle("Nr. of events");
    63     fHPCharge->Sumw2();
    64     fHPCharge->SetDirectory(0);
     63    fHPINDiodeCharge   = new TH1F("HPINDiodeCharge","Distribution of Summed FADC Slices PINDiode",
     64                                  fChargeNbins,fChargeFirstHiGain,fChargeLastHiGain);
     65    fHPINDiodeCharge->SetXTitle("Sum FADC Slices");
     66    fHPINDiodeCharge->SetYTitle("Nr. of events");
     67    fHPINDiodeCharge->Sumw2();
     68    fHPINDiodeCharge->SetDirectory(NULL);
    6569
    66     fErrChargeFirst = 0.;
    67     fErrChargeLast  = gkStartPINDiodeBinNr;
    68     fErrChargeNbins = gkStartPINDiodeBinNr;
     70    fHPINDiodeTime = new TH1F("HPINDiodeTime","Distribution of Mean Arrival Times PINDiode",
     71                              fTimeNbins,fTimeFirst,fTimeLast);
     72    fHPINDiodeTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
     73    fHPINDiodeTime->SetYTitle("Nr. of events");
     74    fHPINDiodeTime->Sumw2();
     75    fHPINDiodeTime->SetDirectory(NULL);
    6976
    70     fHErrCharge = new TH1F("HErrCharge","Distribution of Variances of Summed FADC Slices",fErrChargeNbins,fErrChargeFirst,fErrChargeLast);
    71     fHErrCharge->SetXTitle("Variance Summed FADC Slices");
    72     fHErrCharge->SetYTitle("Nr. of events");
    73     fHErrCharge->Sumw2();
    74     fHErrCharge->SetDirectory(0);
     77    fHPINDiodeChargevsN = new TH1I("HPINDiodeChargevsN","Sum of Hi Gain Charges vs. Event Number Pixel ",
     78                                 fChargevsNbins,-0.5,(Axis_t)fChargevsNbins - 0.5);
     79    fHPINDiodeChargevsN->SetXTitle("Event Nr.");
     80    fHPINDiodeChargevsN->SetYTitle("Sum of Hi Gain FADC slices");
     81    fHPINDiodeChargevsN->SetDirectory(NULL);
    7582
    76     Int_t tfirst = 0;
    77     Int_t tlast  = 31;
    78     Int_t nbins   = 32;
    79 
    80     fHPTime = new TH1F("HPTime","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
    81     fHPTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
    82     fHPTime->SetYTitle("Nr. of events");
    83     fHPTime->Sumw2();
    84     fHPTime->SetDirectory(0);
    85 
     83    Clear();
    8684}
    8785
     
    8987{
    9088
    91   delete fHPCharge;
    92   delete fHErrCharge;
     89  delete fHPINDiodeCharge;
     90  delete fHPINDiodeTime;
     91  delete fHPINDiodeChargevsN;
     92
     93  if (fChargeGausFit)
     94    delete fChargeGausFit;
     95  if (fTimeGausFit)
     96    delete fTimeGausFit;
     97  if (fFitLegend)
     98    delete fFitLegend;
     99}
     100
     101void MHCalibrationPINDiode::Clear(Option_t *o)
     102{
    93103 
    94   if (fVarGausFit)
    95     delete fVarGausFit;
    96  
    97   delete fHPTime;
     104  fTotalEntries            = 0;
     105
     106  fChargeFirstHiGain       = -100.5;
     107  fChargeLastHiGain        = 1999.5;
     108
     109  fChargeChisquare         = -1.;
     110  fChargeProb              = -1.;
     111  fChargeNdf               = -1;
     112  fTimeChisquare           = -1.;
     113  fTimeProb                = -1.;
     114  fTimeNdf                 = -1;
     115  fTimeMean                = -1.;
     116  fTimeSigma               = -1.;
     117
     118  fTimeLowerFitRangeHiGain = 0;
     119  fTimeUpperFitRangeHiGain = 0;
     120  fTimeLowerFitRangeLoGain = 0;
     121  fTimeUpperFitRangeLoGain = 0;
     122
     123  if (fChargeGausFit)
     124    delete fChargeGausFit;
     125  if (fTimeGausFit)
     126    delete fTimeGausFit;
     127  if (fFitLegend)
     128    delete fFitLegend;
     129
     130  return;
    98131
    99132}
    100133
    101 const Double_t MHCalibrationPINDiode::GetTime() const
     134void MHCalibrationPINDiode::Reset()
    102135{
    103     return fVarGausFit->GetParameter(2);
     136
     137  Clear();
     138
     139  fHPINDiodeCharge->Reset();
     140  fHPINDiodeTime->Reset();
     141  fHPINDiodeChargevsN->Reset();
    104142}
    105143
    106 const Double_t MHCalibrationPINDiode::GetErrTime() const
     144
     145Bool_t MHCalibrationPINDiode::FillCharge(Float_t q)
    107146{
    108     return fVarGausFit->GetParameter(3);
     147    return (fHPINDiodeCharge->Fill(q) > -1);
    109148}
     149
     150Bool_t MHCalibrationPINDiode::FillTime(Float_t t)
     151{
     152    return (fHPINDiodeTime->Fill(t)   > -1);
     153}
     154
     155Bool_t MHCalibrationPINDiode::FillChargevsN(Float_t q, Int_t n)
     156{
     157    return (fHPINDiodeChargevsN->Fill(n,q) > -1);
     158}
     159
     160void MHCalibrationPINDiode::CutAllEdges()
     161{
     162
     163  Int_t nbins = 30;
     164
     165  CutEdges(fHPINDiodeCharge,nbins);
     166
     167  fChargeFirstHiGain = fHPINDiodeCharge->GetBinLowEdge(fHPINDiodeCharge->GetXaxis()->GetFirst());
     168  fChargeLastHiGain  = fHPINDiodeCharge->GetBinLowEdge(fHPINDiodeCharge->GetXaxis()->GetLast())
     169                      +fHPINDiodeCharge->GetBinWidth(0);
     170  CutEdges(fHPINDiodeChargevsN,0);
     171
     172}
     173
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.h

    r2904 r2931  
    99class TH1F;
    1010class TF1;
     11class TPaveText;
    1112
    1213class MHCalibrationPINDiode : public MHCalibrationPixel
     
    1415private:
    1516
    16   TH1I* fHPCharge;           //-> Histogram containing the summed 32 PINDiode slices
    17   TH1F* fHErrCharge;         //-> Variance of summed FADC slices
    18   TH1F* fHPTime;             //-> Histogram with time evolution of summed charges
     17  TH1F* fHPINDiodeCharge;    // Histogram containing the summed 32 PINDiode slices
     18  TH1F* fHPINDiodeErrCharge; // Variance of summed FADC slices
     19  TH1F* fHPINDiodeTime;      // Histogram with time evolution of summed charges
    1920 
    20   TF1 *fVarGausFit;
     21  TH1I* fHPINDiodeChargevsN; // Summed Charge vs. Event Nr.
    2122 
    22   Float_t  fErrChargeFirst;
    23   Float_t  fErrChargeLast;
    24   UShort_t fErrChargeNbins;
     23  const Int_t   fChargeNbins;
     24  const Int_t   fTimeNbins;
     25  const Int_t   fChargevsNbins;
     26
     27  const Axis_t  fTimeFirst;
     28  const Axis_t  fTimeLast;
    2529
    2630public:
     
    2933  ~MHCalibrationPINDiode();
    3034
    31   const Double_t GetTime() const;
    32   const Double_t GetErrTime() const;
     35  void Clear(Option_t *o="");
     36  void Reset();
    3337
     38  // Fill histos
     39  Bool_t FillCharge(Float_t q);
     40  Bool_t FillTime(Float_t t);
     41  Bool_t FillChargevsN(Float_t q, Int_t n);
     42
     43  // Fits -- not yet implemented
     44  Bool_t FitCharge(Option_t *option="RQ0") { return kTRUE; }
     45  Bool_t FitTime(Option_t *option="RQ0")   { return kTRUE; }
     46
     47  // Others
     48  void CutAllEdges();
     49 
    3450  ClassDef(MHCalibrationPINDiode, 0)  // Histograms from the Calibration PIN Diode
    3551};
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.h

    r2922 r2931  
    1919
    2020  Int_t fPixId;                  // Pixel Nr
    21   Int_t fTotalEntries;           // Number of entries
    2221
    2322  TArrayF *fHiGains;             //->
     
    2524
    2625protected:
     26
     27  Int_t fTotalEntries;           // Number of entries
    2728
    2829  TH1F* fHChargeHiGain;          // Summed FADC slices High Gain
Note: See TracChangeset for help on using the changeset viewer.