Changeset 2603


Ignore:
Timestamp:
12/05/03 01:08:44 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2599 r2603  
    99     - implemented some of Thomas Bretz suggestions to make the code nicer
    1010     - implemented the possibility to have cosmics in the calibration data
    11        and still fit it
    12      - conversion HiGain/LoGain now left out (it seems to be already done in
    13         the data)
     11       and remove it
     12     - implemented the conversion factors for the blind pixel method
    1413
    1514  * mhist/MHCalibration*
  • trunk/MagicSoft/Mars/macros/calibration.C

    r2599 r2603  
    184184    MHCamera disp10  (geomcam, "MCalibrationCam;pedrms", "Pedestal RMS");
    185185    MHCamera disp11  (geomcam, "MCalibrationCam;rq", "Reduced Charges");
    186     MHCamera disp12  (geomcam, "MCalibrationCam;errrq", "Error of Reduced Charges");
     186    MHCamera disp12  (geomcam, "MCalibrationCam;rsigma", "Reduced Sigmas");
    187187    MHCamera disp13  (geomcam, "MCalibrationCam;phe", "Nr. of Phe's (F-Factor Method)");
    188188    MHCamera disp14  (geomcam, "MCalibrationCam;convphe", "Conversion Factor (F-Factor Method)");
     189    MHCamera disp15  (geomcam, "MCalibrationCam;photons", "Nr. of Photons (Blind Pixel Method)");
     190    MHCamera disp16  (geomcam, "MCalibrationCam;convphot", "Conversion Factor (Blind Pixel Method)");
    189191
    190192    disp1.SetCamContent(*cam, 0);
     
    200202    disp11.SetCamContent(*cam, 10);
    201203    disp12.SetCamContent(*cam, 11);
    202     disp12.SetCamContent(*cam, 12);
    203     disp13.SetCamContent(*cam, 13);
     204    disp13.SetCamContent(*cam, 12);
     205    disp14.SetCamContent(*cam, 13);
     206    disp15.SetCamContent(*cam, 14);
     207    disp16.SetCamContent(*cam, 15);
     208
    204209
    205210    disp1.SetYTitle("Q [FADC counts]");
    206     disp2.SetYTitle("\\Delta_{Q} [FADC counts]");
     211    disp2.SetYTitle("\\Delta Q [FADC counts]");
    207212    disp3.SetYTitle("\\sigma_{Q} [FADC counts]");
    208     disp4.SetYTitle("\\Delta_{\\sigma_{Q}} [FADC counts]");
     213    disp4.SetYTitle("\\Delta {\\sigma_{Q}} [FADC counts]");
    209214    disp5.SetYTitle("P [au]");
    210215    disp6.SetYTitle("T [FADC slices]");
    211     disp7.SetYTitle("\\Delta_{T} [FADC slices]");
     216    disp7.SetYTitle("\\Delta T [FADC slices]");
    212217    disp8.SetYTitle("P [au]");
    213218    disp9.SetYTitle("P [FADC counts/ slice ]");
    214219    disp10.SetYTitle("RMS_{P} [FADC counts / slice ]");
    215220    disp11.SetYTitle("Q [FADC counts]");
    216     disp12.SetYTitle("\\Delta_{Q} [FADC counts]");
     221    disp12.SetYTitle("\\sigma^2_{Q} - RMS^2_{P} [FADC counts^2]");
    217222    disp13.SetYTitle("Nr Phe's");
    218223    disp14.SetYTitle("Conversion Factor [Phe/FADC count]");
     224    disp15.SetYTitle("Nr Photons");
     225    disp16.SetYTitle("Conversion Factor [Ph/FADC count]");
    219226
    220227    MStatusDisplay *d2 = new MStatusDisplay;
     
    350357    obj->Draw();
    351358
     359    TCanvas *c6 = &d2->AddTab("Blind Pixel Method");
     360    c6->Divide(2, 2);
     361
     362    c6->cd(1);
     363    gStyle->SetOptStat(1111);
     364    obj=disp15.DrawCopy("hist");
     365
     366    c6->cd(3);
     367    obj->Draw();
     368
     369    c6->cd(2);
     370    gStyle->SetOptStat(1101);
     371    obj=disp16.DrawCopy("hist");
     372
     373    c6->cd(4);
     374    obj->Draw();
     375
    352376
    353377#endif
  • trunk/MagicSoft/Mars/manalysis/MCalibrationBlindPix.cc

    r2525 r2603  
    5959  fErrLambda = fErrMu0 = fErrMu1 = fErrSigma0 = fErrSigma1 = 0;
    6060 
    61   fT = fErrT = 0;
     61  fTime = fErrTime = 0;
    6262}
    6363
     
    7676}
    7777
    78 Bool_t MCalibrationBlindPix::FitQ()
     78Bool_t MCalibrationBlindPix::FitCharge()
    7979{
    8080  if (!fHist->FitSinglePhe())
     
    9898
    9999
    100 Bool_t MCalibrationBlindPix::FitT()
     100Bool_t MCalibrationBlindPix::FitTime()
    101101{
    102102
    103   if(!fHist->FitT())
     103  if(!fHist->FitTime())
    104104    return kFALSE;
    105105
    106   fT    = fHist->GetMeanT();
    107   fErrT = fHist->GetMeanTErr();
     106  fTime    = fHist->GetMeanTime();
     107  fErrTime = fHist->GetMeanTimeErr();
    108108 
    109109  return kTRUE;
  • trunk/MagicSoft/Mars/manalysis/MCalibrationBlindPix.h

    r2599 r2603  
    2424  Float_t fErrSigma1;        // The error of the width of the first phe-peak 
    2525 
    26   Float_t fT;                // The mean arrival time after the fit 
    27   Float_t fErrT;             // The error of the mean arrival time after the fit
     26  Float_t fTime;                // The mean arrival time after the fit 
     27  Float_t fErrTime;             // The error of the mean arrival time after the fit
    2828 
    2929  MHCalibrationBlindPixel *fHist; // Pointer to the histograms performing the fits, etc. 
     
    4848  Float_t GetErrSigma1() const    { return fErrSigma1;  }
    4949
    50   Float_t GetT()         const    { return fT;         }
    51   Float_t GetErrT()      const    { return fErrT;      }
     50  Float_t GetTime()         const    { return fTime;         }
     51  Float_t GetErrTime()      const    { return fErrTime;      }
    5252 
    53   Bool_t FillQ(Int_t q)            { return fHist->FillBlindPixelQ(q); }
    54   Bool_t FillT(Int_t t)            { return fHist->FillBlindPixelT(t); } 
    55   Bool_t FillRQvsT(Float_t rq, Int_t t) { return fHist->FillBlindPixelQvsN(rq,t); }   
     53  Bool_t FillCharge(Int_t q)            { return fHist->FillBlindPixelCharge(q); }
     54  Bool_t FillTime(Int_t t)            { return fHist->FillBlindPixelTime(t); } 
     55  Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillBlindPixelChargevsN(rq,t); }   
    5656 
    5757  Bool_t IsValid()                 { return fLambda > 0. || fErrLambda > 0.; }
    5858 
    59   Bool_t FitQ();
    60   Bool_t FitT();
     59  Bool_t FitCharge();
     60  Bool_t FitTime();
    6161 
    6262  virtual void Draw(Option_t *opt="")         { fHist->Draw(opt); }
  • trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.cc

    r2599 r2603  
    5353//               Every MCalibrationPix holds a histogram class,             //
    5454//               MHCalibrationPixel which itself hold histograms of type:   //
    55 //               HQ(npix) (distribution of summed FADC time slice entries)  //
    56 //               HT(npix) (distribution of position of maximum)             //
    57 //               HQvsN(npix) (distribution of charges vs. event number.     //
    58 //                                                                          //
    59 // PostProcess:  All histograms HQ(npix) are fitted to a Gaussian           //
    60 //               All histograms HT(npix) are fitted to a Gaussian           //
    61 //               The histogram HBPQ (blind pixel) is fitted to a single     //
     55//               HCharge(npix) (distribution of summed FADC time slice entries)  //
     56//               HTime(npix) (distribution of position of maximum)             //
     57//               HChargevsN(npix) (distribution of charges vs. event number.     //
     58//                                                                          //
     59// PostProcess:  All histograms HCharge(npix) are fitted to a Gaussian           //
     60//               All histograms HTime(npix) are fitted to a Gaussian           //
     61//               The histogram HBlindPixelCharge (blind pixel) is fitted to a single     //
    6262//                   PhE fit                                                //
    63 //               The histogram HBPT (blind pixel) is fitted to a Gaussian   //
     63//               The histogram HBlindPixelTime (blind pixel) is fitted to a Gaussian   //
    6464//               The histograms of the PIN Diode are fitted to Gaussians    //
    6565//                                                                          //
    6666//               Fits can be excluded via the commands:                     //
    67 //               MalibrationCam::SetSkipTFits()   (skip all time fits)      //
    68 //               MalibrationCam::SetSkipBPFits()  (skip all blind pixel fits) //
    69 //               MalibrationCam::SetSkipPDFits()  (skip all PIN Diode fits) //
     67//               MalibrationCam::SetSkipTimeFits()   (skip all time fits)      //
     68//               MalibrationCam::SetSkipBlindPixelFits()  (skip all blind pixel fits) //
     69//               MalibrationCam::SetSkipPinDiodeFits()  (skip all PIN Diode fits) //
    7070//                                                                          //
    7171//////////////////////////////////////////////////////////////////////////////
     
    9494
    9595#include "MTime.h"
     96#include "TMath.h"
    9697
    9798ClassImp(MCalibrationCalc);
     
    115116    AddToBranchList("MRawEvtData.fLoGainFadcSamples");
    116117
    117     SETBIT(fFlags, kUseTFits);
    118     SETBIT(fFlags, kUseBPFit);
    119     SETBIT(fFlags, kUsePDFit);
     118    SETBIT(fFlags, kUseTimeFits);
     119    SETBIT(fFlags, kUseBlindPixelFit);
     120    SETBIT(fFlags, kUsePinDiodeFit);
    120121}
    121122
     
    219220      {
    220221        MCalibrationPix &pix = (*fCalibrations)[i];
    221         pix.ChangePixId(i);
     222        pix.DefinePixId(i);
    222223      }
    223224   
     
    244245    MRawEvtPixelIter pixel(fRawEvt);
    245246
     247    // Create a first loop to sort out the cosmics ...
     248    //
     249    // This is a very primitive check for the number of cosmicpixs
     250    // The cut will be applied in the fit, but for the blind pixel,
     251    // we need to remove this event
     252    //
     253    // FIXME: In the future need a much more sophisticated one!!!
     254    //
     255   
    246256    while (pixel.Next())
    247257      {
    248258
     259        const Int_t pixid = pixel.GetPixelId();
     260
     261        Int_t sum = pixel.GetSumHiGainSamples();
     262
     263        MPedestalPix    &ped = (*fPedestals)[pixid];
     264 
     265        Float_t pedes  = ped.GetPedestal();
     266        Float_t pedrms = ped.GetPedestalRms();
     267       
     268        if ((float)sum < (pedes*fNumHiGainSamples)+(1.5*pedrms) )
     269           cosmicpix++;
     270     }
     271
     272
     273    if (cosmicpix > 50.)
     274      {
     275        fCosmics++;
     276        return kTRUE;
     277      }
     278
     279    pixel.Reset();
     280
     281    while (pixel.Next())
     282      {
     283
    249284        UShort_t sat = 0;
     285        UShort_t lowgainoverflow = 0;
     286
    250287        const Int_t pixid = pixel.GetPixelId();
    251288
     
    269306            //         performed in the data?!?
    270307            //
    271             sum = (max > gkSaturationLimit              // overflow of LoGain ??? -> GimmeABreak!!!
    272                    ? fHistOverFlow++, gkLoGainOverFlow  // OUCH (Florian was maybe right)
    273                    : sum  );                            // OUFF (Florian was wrong) !!
    274             //                   : sum*gkConversionHiLo    );          // OUFF (Florian was wrong) !!
    275 
    276             if (fHistOverFlow)
    277               *fLog << err << dbginf << "Warning: Saturation of LoGain reached! "
    278                     << err << dbginf << "sum = " << sum << endl;
    279 
     308            sum = (max > gkSaturationLimit                // overflow of LoGain ??? -> GimmeABreak!!!
     309                   ? lowgainoverflow++, gkLoGainOverFlow  // OUCH (Florian was maybe right)
     310                   : sum*gkConversionHiLo    );          // OUFF (Florian was wrong) !!
     311                   //                   : sum  );
     312
     313            if (lowgainoverflow)
     314                {
     315                  *fLog << err << dbginf << "Warning: Saturation of LoGain reached in pixel: " << pixid << " "
     316                        << "   sum = " << sum << endl;
     317                    fHistOverFlow++;
     318                }
    280319          }
    281320
     
    293332        pedrms *= (sat ? fNumLoGainSamples : fNumHiGainSamples );
    294333
    295         //
    296         // This is a very primitive check for the number of cosmicpixs
    297         // The cut will be applied in the fit, but for the blind pixel,
    298         // we need to remove this event
    299         //
    300         // FIXME: In the future need a much more sophisticated one!!!
    301         //
    302 
    303         if ((float)sum < pedes+4.*pedrms)
    304            cosmicpix++;
    305 
    306334        Float_t rsum      = (float)sum - pedes;
    307335       
     
    315343            //        the rest of the pixels (which is the case right now)
    316344            //
    317             if (cosmicpix < 100.)
    318               {
    319                 if (!blindpixel.FillQ(sum))
    320                   *fLog << warn <<
    321                     "Overflow or Underflow occurred filling Blind Pixel sum = " << sum << endl;
    322 
    323                 if (!blindpixel.FillT((int)mid))
    324                   *fLog << warn <<
    325                     "Overflow or Underflow occurred filling Blind Pixel time = " << (int)mid << endl;
    326 
    327                 if (!blindpixel.FillRQvsT(rsum,fEvents))
    328                   *fLog << warn <<
    329                     "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl;
    330               }
     345            if (!blindpixel.FillCharge(sum))
     346              *fLog << warn <<
     347                "Overflow or Underflow occurred filling Blind Pixel sum = " << sum << endl;
     348
     349            if (!blindpixel.FillTime((int)mid))
     350              *fLog << warn <<
     351                "Overflow or Underflow occurred filling Blind Pixel time = " << (int)mid << endl;
     352           
     353            if (!blindpixel.FillRChargevsTime(rsum,fEvents))
     354              *fLog << warn <<
     355                "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl;
    331356           
    332357          case gkCalibrationPINDiodeId:
    333             if (!pindiode.FillQ(sum))
     358            if (!pindiode.FillCharge(sum))
    334359              *fLog << warn <<
    335                 "Overflow or Underflow occurred filling HQ: means = " << sum << endl;
    336             if (!pindiode.FillT((int)mid))
     360                "Overflow or Underflow occurred filling HCharge: means = " << sum << endl;
     361            if (!pindiode.FillTime((int)mid))
    337362              *fLog << warn <<
    338                 "Overflow or Underflow occurred filling HT: time = " << (int)mid << endl;
    339             if (!pindiode.FillRQvsT(rsum,fEvents))
     363                "Overflow or Underflow occurred filling HTime: time = " << (int)mid << endl;
     364            if (!pindiode.FillRChargevsTime(rsum,fEvents))
    340365              *fLog << warn <<
    341                 "Overflow or Underflow occurred filling HQvsN: eventnr = " << fEvents << endl;
     366                "Overflow or Underflow occurred filling HChargevsN: eventnr = " << fEvents << endl;
    342367
    343368          default:
    344369
    345             if (!pix.FillQ(sum))
    346               *fLog << warn << "Could not fill Q of pixel: " << pixid
     370            if (!pix.FillCharge(sum))
     371              *fLog << warn << "Could not fill Charge of pixel: " << pixid
    347372                    << " signal = " << sum << endl;
    348373
     
    350375            // Fill the reduced charge into the control histo for better visibility
    351376            //
    352             if (!pix.FillRQvsT(rsum,fEvents))
    353               *fLog << warn << "Could not fill red. Q vs. EvtNr of pixel: " << pixid
     377            if (!pix.FillRChargevsTime(rsum,fEvents))
     378              *fLog << warn << "Could not fill red. Charge vs. EvtNr of pixel: " << pixid
    354379                    << " signal = " << rsum  << " event Nr: " << fEvents << endl;
    355380
    356381
    357             if (!pix.FillT((int)mid))
    358             *fLog << warn << "Could not fill T of pixel: " << pixid << " time = " << (int)mid << endl;
     382            if (!pix.FillTime((int)mid))
     383            *fLog << warn << "Could not fill Time of pixel: " << pixid << " time = " << (int)mid << endl;
    359384
    360385
     
    362387
    363388      } /* while (pixel.Next()) */
    364 
    365     if (cosmicpix > 300.)
    366         fCosmics++;
    367389
    368390    return kTRUE;
     
    389411  // Fit the blind pixel
    390412  //
    391   if (TESTBIT(fFlags,kUseBPFit))
     413  if (TESTBIT(fFlags,kUseBlindPixelFit))
    392414    {
    393       if (!blindpixel.FitQ())
     415      if (blindpixel.FitCharge())
     416        if (!fCalibrations->CalcNrPhotInnerPixel())
     417          *fLog << err << dbginf << "Could not calculate Number of photons from the blind pixel " << endl;
     418      else
    394419        *fLog << err << dbginf << "Could not fit the blind pixel " << endl;
    395420     
    396       if (!blindpixel.FitT())
     421      if (!blindpixel.FitTime())
    397422        *fLog << warn << "Could not the Times of the blind pixel " << endl;
    398423
     
    412437
    413438      const Float_t ped    = (*fPedestals)[pixid].GetPedestal() * fNumHiGainSamples;
    414       const Float_t prms   = (*fPedestals)[pixid].GetPedestalRms() * fNumHiGainSamples;
     439      const Float_t prms   = (*fPedestals)[pixid].GetPedestalRms() * TMath::Sqrt((float)fNumHiGainSamples);
    415440
    416441      pix.SetPedestal(ped,prms);
    417442
    418       if (TESTBIT(fFlags,kUseTFits))
    419         pix.FitT();
     443      if (TESTBIT(fFlags,kUseTimeFits))
     444        pix.FitTime();
    420445     
    421       pix.FitQ();
     446      pix.FitCharge();
    422447    }
    423448
  • trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.h

    r2581 r2603  
    4747  enum
    4848    {
    49       kUseTFits = 1,
    50       kUseBPFit = 2,
    51       kUsePDFit = 3
     49      kUseTimeFits = 1,
     50      kUseBlindPixelFit = 2,
     51      kUsePinDiodeFit = 3
    5252    };
    5353
     
    6969  MCalibrationCalc(const char *name=NULL, const char *title=NULL);
    7070
    71   void SetSkipTFits(Bool_t b=kTRUE)
    72       {b ? CLRBIT(fFlags, kUseTFits) : SETBIT(fFlags, kUseTFits);}
    73   void SetSkipBPFit(Bool_t b=kTRUE)
    74       {b ? CLRBIT(fFlags, kUseBPFit) : SETBIT(fFlags, kUseBPFit);}
    75   void SetSkipPDFit(Bool_t b=kTRUE)
    76       {b ? CLRBIT(fFlags, kUsePDFit) : SETBIT(fFlags, kUsePDFit);}
     71  void SetSkipTimeFits(Bool_t b=kTRUE)
     72      {b ? CLRBIT(fFlags, kUseTimeFits) : SETBIT(fFlags, kUseTimeFits);}
     73  void SetSkipBlindPixelFit(Bool_t b=kTRUE)
     74      {b ? CLRBIT(fFlags, kUseBlindPixelFit) : SETBIT(fFlags, kUseBlindPixelFit);}
     75  void SetSkipPinDiodeFit(Bool_t b=kTRUE)
     76      {b ? CLRBIT(fFlags, kUsePinDiodeFit) : SETBIT(fFlags, kUsePinDiodeFit);}
    7777
    7878  void SetPulserColor(PulserColor_t color)    { fColor = color; }
  • trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc

    r2599 r2603  
    5656//
    5757MCalibrationCam::MCalibrationCam(const char *name, const char *title)
    58     : fMeanNrPhotAvailable(kFALSE)
     58    : fMeanNrPhotAvailable(kFALSE),
     59      fMeanNrPhotInnerPix(-1.)
    5960{
    6061    fName  = name  ? name  : "MCalibrationCam";
     
    128129    return NULL;
    129130 
    130 //    return (*this)[idx];
    131131  return (MCalibrationPix*)fPixels->At(idx);
    132132}
     
    148148    return kFALSE;
    149149
    150   return (&(*this)[idx]);
     150  return kTRUE;
    151151}
    152152
    153153Bool_t MCalibrationCam::IsPixelFitted(Int_t idx) const
    154154{
    155   return ((*this)[idx].GetRQ() > 0. && (*this)[idx].GetErrRQ() > 0.);
     155  return ((*this)[idx].GetRCharge() > 0. && (*this)[idx].GetErrRCharge() > 0.);
    156156}
    157157
     
    170170// The number of succesful fits is returned
    171171//
    172 UShort_t MCalibrationCam::FitQ(Int_t i)
     172UShort_t MCalibrationCam::FitCharge(Int_t i)
    173173{
    174174
     
    189189      while ((pix=(MCalibrationPix*)Next()))
    190190        {
    191           if (pix->FitQ())
     191          if (pix->FitCharge())
    192192            nsuccess++;
    193193        }
     
    195195  else                  // fit only the pixel with index i
    196196    {
    197       if((*this)[i].FitQ())
     197      if((*this)[i].FitCharge())
    198198        nsuccess++;
    199199    }
     
    209209// The number of succesful fits is returned
    210210//
    211 UShort_t MCalibrationCam::FitAllQ()
     211UShort_t MCalibrationCam::FitAllCharge()
    212212{
    213213
     
    222222  while ((pix=(MCalibrationPix*)Next()))
    223223    {
    224       if (pix->FitQ())
    225         nsuccess++;
    226     }
    227  
    228   if (fBlindPixel->FitQ())
    229         nsuccess++;
    230 
    231   if (fPINDiode->FitQ())
     224      if (pix->FitCharge())
     225        nsuccess++;
     226    }
     227 
     228  if (fBlindPixel->FitCharge())
     229        nsuccess++;
     230
     231  if (fPINDiode->FitCharge())
    232232        nsuccess++;
    233233
     
    245245// The number of succesful fits is returned
    246246//
    247 UShort_t MCalibrationCam::FitT(Int_t i)
     247UShort_t MCalibrationCam::FitTime(Int_t i)
    248248{
    249249
     
    264264      while ((pix=(MCalibrationPix*)Next()))
    265265        {
    266          if (pix->FitT())
     266         if (pix->FitTime())
    267267            nsuccess++;
    268268        }
     
    270270  else                     // fit only the pixel with index i
    271271    {
    272       if((*this)[i].FitT())
     272      if((*this)[i].FitTime())
    273273        nsuccess++;
    274274    }
     
    285285// The number of succesful fits is returned
    286286//
    287 UShort_t MCalibrationCam::FitAllT()
     287UShort_t MCalibrationCam::FitAllTime()
    288288{
    289289
     
    298298  while ((pix=(MCalibrationPix*)Next()))
    299299    {
    300       if (pix->FitT())
    301         nsuccess++;
    302     }
    303  
    304   if (fBlindPixel->FitT())
    305         nsuccess++;
    306 
    307   if (fPINDiode->FitT())
     300      if (pix->FitTime())
     301        nsuccess++;
     302    }
     303 
     304  if (fBlindPixel->FitTime())
     305        nsuccess++;
     306
     307  if (fPINDiode->FitTime())
    308308       nsuccess++;
    309309
     
    364364    {
    365365
    366         *fLog << id << ": " << pix->GetPed() << " " << pix->GetPedRms() << " Charges: " ;
    367         *fLog << pix->GetQ() << " " << pix->GetRQ() << endl;
     366        *fLog << id << " Pedestals: " << pix->GetPed() << " +- " << pix->GetPedRms() << " Charge: "
     367              << pix->GetCharge() << " Reduced Charge: " << pix->GetRCharge() << " +- "
     368              << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigma() << endl;
    368369
    369370        id++;
     
    378379    {
    379380    case 0:
    380        val = (*this)[idx].GetQ();
     381       val = (*this)[idx].GetCharge();
    381382        break;
    382383    case 1:
    383        val = (*this)[idx].GetErrQ();
     384       val = (*this)[idx].GetErrCharge();
    384385        break;
    385386    case 2:
    386        val = (*this)[idx].GetSigmaQ();
     387       val = (*this)[idx].GetSigmaCharge();
    387388        break;
    388389    case 3:
    389        val = (*this)[idx].GetErrSigmaQ();
     390       val = (*this)[idx].GetErrSigmaCharge();
    390391        break;
    391392    case 4:
    392        val = (*this)[idx].GetQProb();
     393       val = (*this)[idx].GetChargeProb();
    393394        break;
    394395    case 5:
    395        val = (*this)[idx].GetT();
     396       val = (*this)[idx].GetTime();
    396397        break;
    397398    case 6:
    398        val = (*this)[idx].GetSigmaT();
     399       val = (*this)[idx].GetSigmaTime();
    399400        break;
    400401    case 7:
    401        val = (*this)[idx].GetTProb();
     402       val = (*this)[idx].GetTimeProb();
    402403        break;
    403404    case 8:
     
    408409        break;
    409410    case 10:
    410       val = (*this)[idx].GetRQ();
    411         break;
     411      val = (*this)[idx].GetRCharge();
     412      break;
    412413    case 11:
    413       val = (*this)[idx].GetErrRQ();
     414      val = (*this)[idx].GetRSigma();
    414415      break;
    415416    case 12:
     
    419420      val = (*this)[idx].GetConversionFFactorMethod();
    420421      break;
     422    case 14:
     423      val = (double)fMeanNrPhotInnerPix;
     424      break;
     425    case 15:
     426      if ((fMeanNrPhotInnerPix > 0. ) && ((*this)[idx].GetRCharge() > 100.))
     427        val = fMeanNrPhotInnerPix / (*this)[idx].GetRCharge();
     428      else
     429        val = -1.;
     430      break;
    421431    default:
    422432      return kFALSE;
     
    443453    {
    444454    case kECGreen:
    445       fMeanNrPhotInnerPix = mean /
    446                            (gkCalibrationBlindPixelQEGreen
    447                             *TMath::Power(10,gkCalibrationBlindPixelAttGreen)
    448                             *gkCalibrationBlindPixelArea);
     455      fMeanNrPhotInnerPix = (mean / gkCalibrationBlindPixelQEGreen) // real photons
     456                            *TMath::Power(10,gkCalibrationBlindPixelAttGreen) // correct for absorption
     457                            / gkCalibrationBlindPixelArea;          // correct for area
    449458      break;
    450459    case kECBlue:
    451       fMeanNrPhotInnerPix = mean /
    452                            (gkCalibrationBlindPixelQEBlue
     460      fMeanNrPhotInnerPix = (mean / gkCalibrationBlindPixelQEBlue )
    453461                            *TMath::Power(10,gkCalibrationBlindPixelAttBlue)
    454                             *gkCalibrationBlindPixelArea);
     462                            / gkCalibrationBlindPixelArea;
    455463      break;
    456464    case kECUV:
    457       fMeanNrPhotInnerPix = mean /
    458                            (gkCalibrationBlindPixelQEUV
     465      fMeanNrPhotInnerPix = (mean / gkCalibrationBlindPixelQEUV )
    459466                            *TMath::Power(10,gkCalibrationBlindPixelAttUV)
    460                             *gkCalibrationBlindPixelArea);
     467                            / gkCalibrationBlindPixelArea;
    461468      break;
    462469    }
     
    478485      return kFALSE;
    479486
    480   mean = fMeanNrPhotInnerPix / (*this)[ipx].GetRQ();
     487  mean = fMeanNrPhotInnerPix / (*this)[ipx].GetRCharge();
    481488
    482489  //
  • trunk/MagicSoft/Mars/manalysis/MCalibrationCam.h

    r2599 r2603  
    3333 
    3434  Int_t fNumPixels;
    35   TClonesArray *fPixels;             // FIXME: Change TClonesArray away from a pointer?
     35  TClonesArray *fPixels;             //! FIXME: Change TClonesArray away from a pointer?
    3636 
    37   MCalibrationBlindPix *fBlindPixel; // containing blind pixel data with fitresults
    38   MCalibrationPINDiode *fPINDiode;   // containing PIN Diode data with fit results   
     37  MCalibrationBlindPix *fBlindPixel; //! containing blind pixel data with fitresults
     38  MCalibrationPINDiode *fPINDiode;   //! containing PIN Diode data with fit results   
    3939
    4040  Float_t fMeanNrPhotInnerPix;       // The mean number of photons in an inner pixel 
     
    4242  Bool_t  fMeanNrPhotAvailable;
    4343
    44   Bool_t CalcNrPhotInnerPixel();
    45  
    4644public:
    4745 
     
    7068  MCalibrationPix &operator[](Int_t i) const;
    7169 
    72   UShort_t FitQ(Int_t i=-1);
    73   UShort_t FitAllQ();
    74   UShort_t FitT(Int_t i=-1);
    75   UShort_t FitAllT();
     70  UShort_t FitCharge(Int_t i=-1);
     71  UShort_t FitAllCharge();
     72  UShort_t FitTime(Int_t i=-1);
     73  UShort_t FitAllTime();
    7674 
    7775  Bool_t CheckBounds(Int_t i) const;
     
    8179  void CutEdges();
    8280 
     81  Bool_t CalcNrPhotInnerPixel();
    8382  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
    8483  void DrawPixelContent(Int_t num) const;   
  • trunk/MagicSoft/Mars/manalysis/MCalibrationConfig.h

    r2525 r2603  
    1515
    1616// The conversion factor between High Gain and Low Gain
    17 const UShort_t gkConversionHiLo = 10;
     17const UShort_t gkConversionHiLo = 10.;
    1818
    1919// The penalty constant to produce overflow in the histogram
     
    2626
    2727// Average QE of Blind Pixel (three colours)
    28 const Float_t gkCalibrationBlindPixelQEGreen = 15.4;
    29 const Float_t gkCalibrationBlindPixelQEBlue  = 22.6;
    30 const Float_t gkCalibrationBlindPixelQEUV    = 24.7;
     28const Float_t gkCalibrationBlindPixelQEGreen = 0.154;
     29const Float_t gkCalibrationBlindPixelQEBlue  = 0.226;
     30const Float_t gkCalibrationBlindPixelQEUV    = 0.247;
    3131
    3232// Attenuation factor Blind Pixel (three colours)
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPINDiode.cc

    r2525 r2603  
    4343//
    4444MCalibrationPINDiode::MCalibrationPINDiode(const char *name, const char *title)
    45     : fHist(NULL)
     45  : fHist(NULL),
     46    fCharge(-1.),
     47    fErrCharge(-1.),
     48    fPed(-1.),
     49    fPedRms(-1.),
     50    fSigmaCharge(-1.),
     51    fErrSigmaCharge(-1.),
     52    fTime(-1.),
     53    fErrTime(-1.),
     54    fRCharge(-1.),
     55    fErrRCharge(-1.)
    4656{
    4757
     
    5060
    5161  fHist = new MHCalibrationPINDiode();
    52 
    53   fQ   = fErrQ     = 0.;
    54   fPed = fPedRms   = 0.;
    55   fT   = fErrT  = 0.;
    56   fRQ  = fErrRQ = 0.;
    57   fSigmaQ = fErrSigmaQ = 0.;
    5862
    5963}
     
    7377}
    7478
    75 Bool_t MCalibrationPINDiode::FitQ()
     79Bool_t MCalibrationPINDiode::FitCharge()
    7680{
    77   if(!fHist->FitQ())
     81  if(!fHist->FitCharge())
    7882    return kFALSE;
    7983
    80   fQ         = fHist->GetQMean();
    81   fErrQ      = fHist->GetQMeanErr();
    82   fSigmaQ    = fHist->GetQSigma();
    83   fErrSigmaQ = fHist->GetQSigmaErr();
     84  fCharge         = fHist->GetChargeMean();
     85  fErrCharge      = fHist->GetChargeMeanErr();
     86  fSigmaCharge    = fHist->GetChargeSigma();
     87  fErrSigmaCharge = fHist->GetChargeSigmaErr();
    8488
    8589  return kTRUE;
     
    8791}
    8892
    89 Bool_t MCalibrationPINDiode::FitT()
     93Bool_t MCalibrationPINDiode::FitTime()
    9094{
    9195
    92   if(!fHist->FitT())
     96  if(!fHist->FitTime())
    9397    return kFALSE;
    9498
    95   fT = fHist->GetT();
    96   fErrT = fHist->GetErrT();
     99  fTime    = fHist->GetTime();
     100  fErrTime = fHist->GetErrTime();
    97101 
    98102  return kTRUE;
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPINDiode.h

    r2525 r2603  
    1212private:
    1313
    14   Float_t fQ;                // The mean charge after the fit
    15   Float_t fErrQ;             // The error of mean charge after the fit
     14  MHCalibrationPINDiode *fHist; // Pointer to the histograms performing the fits, etc. 
     15 
     16  Float_t fCharge;                // The mean charge after the fit
     17  Float_t fErrCharge;             // The error of mean charge after the fit
    1618  Float_t fPed;              // The mean pedestal (from MPedestalPix)
    1719  Float_t fPedRms;           // The pedestal  RMS (from MPedestalPix)
    18   Float_t fSigmaQ;           // The sigma of the mean charge after the fit
    19   Float_t fErrSigmaQ;        // The error of the sigma of the mean charge after the fit
    20   Float_t fT;                // The mean arrival time after the fit 
    21   Float_t fErrT;             // The error of the mean arrival time after the fit
     20  Float_t fSigmaCharge;           // The sigma of the mean charge after the fit
     21  Float_t fErrSigmaCharge;        // The error of the sigma of the mean charge after the fit
     22  Float_t fTime;                // The mean arrival time after the fit 
     23  Float_t fErrTime;             // The error of the mean arrival time after the fit
    2224 
    23   Float_t fRQ;               // The reduced mean charge after the fit
    24   Float_t fErrRQ;            // The error of the reduced mean charge after the fit 
    25  
    26   MHCalibrationPINDiode *fHist; // Pointer to the histograms performing the fits, etc. 
     25  Float_t fRCharge;               // The reduced mean charge after the fit
     26  Float_t fErrRCharge;            // The error of the reduced mean charge after the fit 
    2727 
    2828public:
     
    3636  void SetPedRms(Float_t pedrms)    { fPedRms   = pedrms; }
    3737
    38   Bool_t IsValid() const { return fRQ >=0 || fErrRQ >= 0; }
     38  Bool_t IsValid() const { return fRCharge >=0 || fErrRCharge >= 0; }
    3939
    40   Bool_t FillQ(Int_t q)            { return fHist->FillQ(q); }
    41   Bool_t FillT(Int_t t)            { return fHist->FillT(t); } 
    42   Bool_t FillRQvsT(Float_t rq, Int_t t) { return fHist->FillQvsN(rq,t); }   
     40  Bool_t FillCharge(Int_t q)            { return fHist->FillCharge(q); }
     41  Bool_t FillTime(Int_t t)            { return fHist->FillTime(t); } 
     42  Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillChargevsN(rq,t); }   
    4343 
    44   Bool_t FitQ();
    45   Bool_t FitT();
     44  Bool_t FitCharge();
     45  Bool_t FitTime();
    4646 
    4747  MHCalibrationPINDiode *GetHist()  const  { return fHist;  }
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc

    r2599 r2603  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//                                                                         //
    27 // MCalibrationPix                                                            //
     27// MCalibrationPix                                                         //
    2828//                                                                         //
    2929// This is the storage container to hold informations about the pedestal   //
     
    4646MCalibrationPix::MCalibrationPix(const char *name, const char *title)
    4747    : fPixId(-1),
    48       fQ(-1.),
    49       fErrQ(-1.),
    50       fSigmaQ(-1.),
    51       fErrSigmaQ(-1.),
    52       fQProb(-1.),
     48      fCharge(-1.),
     49      fErrCharge(-1.),
     50      fSigmaCharge(-1.),
     51      fErrSigmaCharge(-1.),
     52      fChargeProb(-1.),
    5353      fPed(-1.),
    5454      fPedRms(-1.),
    55       fT(-1.),
    56       fSigmaT(-1.),
    57       fTProb(-1.),
    58       fRQ(-1.),
    59       fErrRQ(-1.),
     55      fTime(-1.),
     56      fSigmaTime(-1.),
     57      fTimeProb(-1.),
     58      fRCharge(-1.),
     59      fErrRCharge(-1.),
     60      fRSigma(-1.),
    6061      fFactor(1.3),
    6162      fPheFFactorMethod(-1.),
     
    6667  fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results";
    6768
    68   fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel");
     69  fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel ");
     70
    6971}
    7072
     
    7577
    7678
    77 void MCalibrationPix::ChangePixId(Int_t i)
     79void MCalibrationPix::DefinePixId(Int_t i)
    7880{
    7981 
     
    9395}
    9496
    95 Bool_t MCalibrationPix::FitQ()
     97Bool_t MCalibrationPix::FitCharge()
    9698{
    9799
    98   if (fHist->IsFitted())
     100  if (fHist->IsFitOK())
    99101    return kTRUE;
    100102
    101103  if (fPed && fPedRms)
    102     fHist->SetLowerFitRange(fPed + 2.0*fPedRms);
     104    fHist->SetLowerFitRange(fPed + 1.5*fPedRms);
    103105  else
    104106    *fLog << warn << "Cannot set lower fit range to suppress cosmics: Pedestals not available" << endl;
    105107
    106   if(!fHist->FitQ())
     108  if(!fHist->FitCharge())
    107109    {
    108110      *fLog << warn << "Could not fit charges of pixel " << fPixId << endl;
    109       fHist->PrintQFitResult();
     111      fHist->PrintChargeFitResult();
    110112      return kFALSE;
    111113    }
    112114 
    113   fQ         = fHist->GetQMean();
    114   fErrQ      = fHist->GetQMeanErr();
    115   fSigmaQ    = fHist->GetQSigma();
    116   fErrSigmaQ = fHist->GetQSigmaErr();
    117   fQProb     = fHist->GetQProb();
     115  fCharge         = fHist->GetChargeMean();
     116  fErrCharge      = fHist->GetChargeMeanErr();
     117  fSigmaCharge    = fHist->GetChargeSigma();
     118  fErrSigmaCharge = fHist->GetChargeSigmaErr();
     119  fChargeProb     = fHist->GetChargeProb();
    118120
    119121  if ((fPed > 0.)  && (fPedRms > 0.))
    120122    {
    121123     
    122     fRQ      = fQ - fPed;
    123     fErrRQ   = TMath::Sqrt(fErrQ*fErrQ + fPedRms*fPedRms);
     124    fRCharge      = fCharge - fPed;
     125    fErrRCharge   = TMath::Sqrt(fErrCharge*fErrCharge + fPedRms*fPedRms);
    124126
    125     fPheFFactorMethod =
    126       fFactor
    127       * fRQ * fRQ
    128       / (fSigmaQ * fSigmaQ - fPedRms*fPedRms) ;
     127    fRSigma       = (fSigmaCharge*fSigmaCharge) - (fPedRms*fPedRms);
    129128
    130     fConversionFFactorMethod = fPheFFactorMethod / fRQ ;
    131    
     129    if (fRSigma > 0. )
     130      {
     131       fPheFFactorMethod =  fFactor * fRCharge*fRCharge / fRSigma;
     132       fConversionFFactorMethod = fPheFFactorMethod / fRCharge ;
     133      }
     134    else
     135      {
     136        *fLog << warn << "Cannot apply F-Factor method: Reduced Sigmas are smaller than 0 in pixel: "
     137              << fPixId << endl;
     138      }
     139
    132140    }
    133141
     
    142150  fPedRms = pedrms;
    143151 
    144   if ((!fRQ) && fQ)
    145     fRQ = fQ - fPed;
    146   if ((!fErrRQ) && fErrQ)
    147     fErrRQ   = TMath::Sqrt(fErrQ*fErrQ + fPedRms*fPedRms);
     152  if ((fRCharge == -1.) && (fCharge > 0.))
     153    fRCharge = fCharge - fPed;
     154  if ((fErrRCharge == -1.) && (fErrCharge > 0.))
     155    fErrRCharge   = TMath::Sqrt(fErrCharge*fErrCharge + fPedRms*fPedRms);
    148156
    149157}
    150158
    151 Bool_t MCalibrationPix::FitT()
     159Bool_t MCalibrationPix::FitTime()
    152160{
    153161
    154   if(!fHist->FitT())
     162  if(!fHist->FitTime())
    155163    {
    156164      *fLog << warn << "Could not fit times of pixel " << fPixId << endl;
    157       fHist->PrintTFitResult();
     165      fHist->PrintTimeFitResult();
    158166      return kFALSE;
    159167    }
    160168
    161   fT       = fHist->GetTMean();
    162   fSigmaT  = fHist->GetTSigma();
    163   fTProb   = fHist->GetTProb();
     169  fTime       = fHist->GetTimeMean();
     170  fSigmaTime  = fHist->GetTimeSigma();
     171  fTimeProb   = fHist->GetTimeProb();
    164172
    165173  return kTRUE;
    166  
    167174}
    168175
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h

    r2599 r2603  
    1414  Int_t   fPixId;           // the pixel Id
    1515 
    16   Float_t fQ;                // The mean charge after the fit
    17   Float_t fErrQ;             // The error of mean charge after the fit
    18   Float_t fSigmaQ;           // The sigma of the mean charge after the fit
    19   Float_t fErrSigmaQ;        // The error of the sigma of the mean charge after the fit
    20   Float_t fQProb;            // The probability of the fit function
     16  Float_t fCharge;              // The mean charge after the fit
     17  Float_t fErrCharge;           // The error of mean charge after the fit
     18  Float_t fSigmaCharge;         // The sigma of the mean charge after the fit
     19  Float_t fErrSigmaCharge;      // The error of the sigma of the mean charge after the fit
     20  Float_t fChargeProb;          // The probability of the fit function
    2121
    22   Float_t fPed;              // The mean pedestal (from MPedestalPix)
    23   Float_t fPedRms;           // The pedestal  RMS (from MPedestalPix)
     22  Float_t fPed;                 // The mean pedestal (from MPedestalPix)
     23  Float_t fPedRms;              // The pedestal  RMS (from MPedestalPix)
    2424
    25   Float_t fT;                // The mean arrival time after the fit 
    26   Float_t fSigmaT;           // The error of the mean arrival time after the fit
    27   Float_t fTProb;            // The probability of the fit function
     25  Float_t fTime;                // The mean arrival time after the fit 
     26  Float_t fSigmaTime;           // The error of the mean arrival time after the fit
     27  Float_t fTimeProb;            // The probability of the fit function
    2828 
    29   Float_t fRQ;               // The reduced mean charge after the fit
    30   Float_t fErrRQ;            // The error of the reduced mean charge after the fit 
     29  Float_t fRCharge;             // The reduced mean charge after the fit
     30  Float_t fErrRCharge;          // The error of the reduced mean charge after the fit 
     31  Float_t fRSigma;              // The reduced squares of sigmas after the fit
     32 
     33  Float_t fFactor;                  // The laboratory F-factor
     34  Float_t fPheFFactorMethod;        // The number of Phe's calculated after the F-factor method
     35  Float_t fConversionFFactorMethod; // The conversion factor to Phe's calculated after the F-factor method
    3136
    32   Float_t fFactor;            // The F-factor
    33   Float_t fPheFFactorMethod;  // The number of Phe's calculated after the F-factor method
    34   Float_t fConversionFFactorMethod; // The conversion factor to Phe's calculated after the F-factor method
    35    
    36   MHCalibrationPixel *fHist; // Pointer to the histograms performing the fits, etc. 
     37  MHCalibrationPixel *fHist;    //! Pointer to the histograms performing the fits, etc. 
    3738 
    3839public:
     
    4344  void Clear(Option_t *o="");
    4445
    45   Float_t GetQ()     const    { return fQ;     }
    46   Float_t GetRQ()    const    { return fRQ;    }
     46  Float_t GetCharge()         const    { return fCharge;         }
     47  Float_t GetRCharge()        const    { return fRCharge;        }
     48  Float_t GetRSigma()         const    { return fRSigma;         }
    4749   
    48   Float_t GetErrQ()  const    { return fErrQ;  }
    49   Float_t GetErrRQ() const    { return fErrRQ; }   
    50   Float_t GetQProb() const    { return fQProb;    }   
     50  Float_t GetErrCharge()      const    { return fErrCharge;      }
     51  Float_t GetErrRCharge()     const    { return fErrRCharge;    }   
     52  Float_t GetChargeProb()     const    { return fChargeProb;     }   
    5153 
    52   Float_t GetSigmaQ()    const   { return fSigmaQ;    }
    53   Float_t GetErrSigmaQ() const   { return fErrSigmaQ; }
    54   Float_t GetT()         const   { return fT;         }
    55   Float_t GetSigmaT()    const   { return fSigmaT;    }
    56   Float_t GetTProb()     const   { return fTProb;    }   
     54  Float_t GetSigmaCharge()    const    { return fSigmaCharge;    }
     55  Float_t GetErrSigmaCharge() const    { return fErrSigmaCharge; }
     56  Float_t GetTime()         const    { return fTime;         }
     57  Float_t GetSigmaTime()    const    { return fSigmaTime;    }
     58  Float_t GetTimeProb()     const    { return fTimeProb;     }   
    5759 
    58   Float_t GetPed()       const    { return fPed;     }
    59   Float_t GetPedRms()    const    { return fPedRms;    }   
     60  Float_t GetPed()          const    { return fPed;       }
     61  Float_t GetPedRms()       const    { return fPedRms;    }   
    6062
    61   void SetPedestal(Float_t ped, Float_t pedrms);       
     63  void SetPedestal(Float_t ped, Float_t pedrms);
    6264
    63   Bool_t FillQ(Int_t q)                 { return fHist->FillQ(q); }
    64   Bool_t FillT(Int_t t)                 { return fHist->FillT(t); } 
    65   Bool_t FillRQvsT(Float_t rq, Int_t t) { return fHist->FillQvsN(rq,t); }   
     65  Bool_t FillCharge(Int_t q)           { return fHist->FillCharge(q); }
     66  Bool_t FillTime(Int_t t)             { return fHist->FillTime(t); } 
     67  Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillChargevsN(rq,t); }   
    6668 
    67   Bool_t IsValid()      const           { return fRQ >=0 || fErrRQ >= 0; }
    68   Int_t  GetPixId()     const           { return fPixId;   }
    69   void ChangePixId(Int_t i);
     69  Bool_t IsValid()          const    { return fRCharge >=0 || fErrRCharge >= 0; }
     70  Int_t  GetPixId()         const    { return fPixId;   }
     71  void   DefinePixId(Int_t i);
    7072 
    71   Bool_t FitQ();
    72   Bool_t FitT();
     73  Bool_t FitCharge();
     74  Bool_t FitTime();
    7375 
    74   MHCalibrationPixel *GetHist()     const  { return fHist;  }
    75   virtual void Draw(Option_t *opt="")     { fHist->Draw(opt); }
     76  MHCalibrationPixel *GetHist() const  { return fHist;  }
     77  virtual void Draw(Option_t *opt="")   { fHist->Draw(opt); }
    7678 
    77   Float_t GetPheFFactorMethod() const        { return fPheFFactorMethod;  } 
    78   Float_t GetConversionFFactorMethod() const { return fConversionFFactorMethod;  }
     79  Float_t GetPheFFactorMethod()           const { return fPheFFactorMethod;           } 
     80  Float_t GetConversionFFactorMethod()    const { return fConversionFFactorMethod;    }
    7981 
    8082  ClassDef(MCalibrationPix, 1)  // Storage Container for Calibration information of one pixel
  • trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.cc

    r2599 r2603  
    6969
    7070    // Create a large number of bins, later we will rebin
    71     fBlindPixelQfirst = 0;
    72     fBlindPixelQlast  = gkStartBlindPixelBinNr;
    73     fBlindPixelQnbins = gkStartBlindPixelBinNr;
    74 
    75     fHBlindPixelQ = new TH1I("HBlindPixelQ","Distribution of Summed FADC Slices",fBlindPixelQnbins,fBlindPixelQfirst,fBlindPixelQlast);
    76     fHBlindPixelQ->SetXTitle("Sum FADC Slices");
    77     fHBlindPixelQ->SetYTitle("Nr. of events");
    78     fHBlindPixelQ->Sumw2();
    79 
    80     fErrBlindPixelQfirst = 0.;
    81     fErrBlindPixelQlast  = gkStartBlindPixelBinNr;
    82     fErrBlindPixelQnbins = gkStartBlindPixelBinNr;
    83 
    84     fHBlindPixelErrQ = new TH1F("HBlindPixelErrQ","Distribution of Variances of Summed FADC Slices",
    85                         fErrBlindPixelQnbins,fErrBlindPixelQfirst,fErrBlindPixelQlast);
    86     fHBlindPixelErrQ->SetXTitle("Variance Summed FADC Slices");
    87     fHBlindPixelErrQ->SetYTitle("Nr. of events");
    88     fHBlindPixelErrQ->Sumw2();
     71    fBlindPixelChargefirst = 0;
     72    fBlindPixelChargelast  = gkStartBlindPixelBinNr;
     73    fBlindPixelChargenbins = gkStartBlindPixelBinNr;
     74
     75    fHBlindPixelCharge = new TH1I("HBlindPixelCharge","Distribution of Summed FADC Slices",fBlindPixelChargenbins,fBlindPixelChargefirst,fBlindPixelChargelast);
     76    fHBlindPixelCharge->SetXTitle("Sum FADC Slices");
     77    fHBlindPixelCharge->SetYTitle("Nr. of events");
     78    fHBlindPixelCharge->Sumw2();
     79
     80    fErrBlindPixelChargefirst = 0.;
     81    fErrBlindPixelChargelast  = gkStartBlindPixelBinNr;
     82    fErrBlindPixelChargenbins = gkStartBlindPixelBinNr;
     83
     84    fHBlindPixelErrCharge = new TH1F("HBlindPixelErrCharge","Distribution of Variances of Summed FADC Slices",
     85                        fErrBlindPixelChargenbins,fErrBlindPixelChargefirst,fErrBlindPixelChargelast);
     86    fHBlindPixelErrCharge->SetXTitle("Variance Summed FADC Slices");
     87    fHBlindPixelErrCharge->SetYTitle("Nr. of events");
     88    fHBlindPixelErrCharge->Sumw2();
    8989
    9090    Axis_t tfirst = -0.5;
     
    9292    Int_t nbins   = 16;
    9393
    94     fHBlindPixelT = new TH1I("HBlindPixelT","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
    95     fHBlindPixelT->SetXTitle("Mean Arrival Times [FADC slice nr]");
    96     fHBlindPixelT->SetYTitle("Nr. of events");
    97     fHBlindPixelT->Sumw2();
     94    fHBlindPixelTime = new TH1I("HBlindPixelTime","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
     95    fHBlindPixelTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
     96    fHBlindPixelTime->SetYTitle("Nr. of events");
     97    fHBlindPixelTime->Sumw2();
    9898
    9999    // We define a reasonable number and later enlarge it if necessary
     
    102102    Axis_t nlast  = (Axis_t)nbins - 0.5;
    103103
    104     fHBlindPixelQvsN = new TH1I("HBlindPixelQvsN","Sum of Charges vs. Event Number",nbins,nfirst,nlast);
    105     fHBlindPixelQvsN->SetXTitle("Event Nr.");
    106     fHBlindPixelQvsN->SetYTitle("Sum of FADC slices");
     104    fHBlindPixelChargevsN = new TH1I("HBlindPixelChargevsN","Sum of Charges vs. Event Number",nbins,nfirst,nlast);
     105    fHBlindPixelChargevsN->SetXTitle("Event Nr.");
     106    fHBlindPixelChargevsN->SetYTitle("Sum of FADC slices");
    107107
    108108    fgSinglePheFitFunc = &gfKto8;
     
    113113{
    114114
    115   delete fHBlindPixelQ;
    116   delete fHBlindPixelT;
    117   delete fHBlindPixelErrQ;
     115  delete fHBlindPixelCharge;
     116  delete fHBlindPixelTime;
     117  delete fHBlindPixelErrCharge;
    118118 
    119119  if (fSinglePheFit)
     
    127127void MHCalibrationBlindPixel::ResetBin(Int_t i)
    128128{
    129     fHBlindPixelQ->SetBinContent (i, 1.e-20);
    130     fHBlindPixelErrQ->SetBinContent  (i, 1.e-20);
    131     fHBlindPixelT->SetBinContent(i, 1.e-20);
     129    fHBlindPixelCharge->SetBinContent (i, 1.e-20);
     130    fHBlindPixelErrCharge->SetBinContent  (i, 1.e-20);
     131    fHBlindPixelTime->SetBinContent(i, 1.e-20);
    132132}
    133133
     
    150150  fFitLegend->SetTextSize(0.05);
    151151
    152   char line1[32];
    153   sprintf(line1,"Mean: #lambda = %2.2f #pm %2.2f",GetLambda(),GetLambdaErr());
     152  const TString line1 =
     153  Form("Mean: #lambda = %2.2f #pm %2.2f",GetLambda(),GetLambdaErr());
    154154  fFitLegend->AddText(line1);
    155155
    156   char line2[32];
    157   sprintf(line2,"Pedestal: #mu_{0} = %2.2f #pm %2.2f",GetMu0(),GetMu0Err());
     156  const TString line2 =
     157  Form("Pedestal: #mu_{0} = %2.2f #pm %2.2f",GetMu0(),GetMu0Err());
    158158  fFitLegend->AddText(line2);
    159159
    160   char line3[32];
    161   sprintf(line3,"Width Pedestal: #sigma_{0} = %2.2f #pm %2.2f",GetSigma0(),GetSigma0Err());
     160  const TString line3 =
     161  Form("Width Pedestal: #sigma_{0} = %2.2f #pm %2.2f",GetSigma0(),GetSigma0Err());
    162162  fFitLegend->AddText(line3);
    163163
    164   char line4[32];
    165   sprintf(line4,"1^{st} Phe-peak: #mu_{1} = %2.2f #pm %2.2f",GetMu1(),GetMu1Err());
     164  const TString line4 =
     165  Form("1^{st} Phe-peak: #mu_{1} = %2.2f #pm %2.2f",GetMu1(),GetMu1Err());
    166166  fFitLegend->AddText(line4);
    167167
    168   char line5[32];
    169   sprintf(line5,"Width 1^{st} Phe-peak: #sigma_{1} = %2.2f #pm %2.2f",GetSigma1(),GetSigma1Err());
     168  const TString line5 =
     169  Form("Width 1^{st} Phe-peak: #sigma_{1} = %2.2f #pm %2.2f",GetSigma1(),GetSigma1Err());
    170170  fFitLegend->AddText(line5);
    171171
    172   char line7[32];
    173   sprintf(line7,"#chi^{2} / N_{dof}: %4.2f / %3i",GetChiSquare(),GetNdf());
     172  const TString line7 =
     173  Form("#chi^{2} / N_{dof}: %4.2f / %3i",GetChiSquare(),GetNdf());
    174174  fFitLegend->AddText(line7);
    175175
    176   char line8[32];
    177   sprintf(line8,"Probability: %4.2f ",GetProb());
     176  const TString line8 =
     177  Form("Probability: %4.2f ",GetProb());
    178178  fFitLegend->AddText(line8);
    179179
     
    209209    gPad->SetTicks();
    210210
    211     fHBlindPixelQ->DrawCopy(opt);
     211    fHBlindPixelCharge->DrawCopy(opt);
    212212   
    213213    if (fSinglePheFit)
     
    231231    gPad->SetLogy(1);
    232232    gPad->SetBorderMode(0);
    233     fHBlindPixelT->DrawCopy(opt);
    234 
    235     if (fHBlindPixelT->GetFunction("GausTime"))
     233    fHBlindPixelTime->DrawCopy(opt);
     234
     235    if (fHBlindPixelTime->GetFunction("GausTime"))
    236236      {
    237         TF1 *tfit = fHBlindPixelT->GetFunction("GausTime");
     237        TF1 *tfit = fHBlindPixelTime->GetFunction("GausTime");
    238238        if (tfit->GetProb() < 0.01)
    239239          tfit->SetLineColor(kRed);
     
    248248    c->cd(4);
    249249
    250     fHBlindPixelQvsN->DrawCopy(opt);
     250    fHBlindPixelChargevsN->DrawCopy(opt);
    251251
    252252    c->Modified();
     
    260260  gRandom->SetSeed();
    261261
    262   if (fHBlindPixelQ->GetEntries() != 0)
     262  if (fHBlindPixelCharge->GetEntries() != 0)
    263263    {
    264       *fLog << err << "Histogram " << fHBlindPixelQ->GetTitle() << " is already filled. " << endl;
     264      *fLog << err << "Histogram " << fHBlindPixelCharge->GetTitle() << " is already filled. " << endl;
    265265      *fLog << err << "Create new class MHCalibrationBlindPixel for simulation! " << endl;
    266266      return kFALSE;
     
    268268 
    269269  TF1 *simulateSinglePhe = new TF1("simulateSinglePhe",fgSinglePheFitFunc,
    270                                    fBlindPixelQfirst,fBlindPixelQlast,fgSinglePheFitNPar);
     270                                   fBlindPixelChargefirst,fBlindPixelChargelast,fgSinglePheFitNPar);
    271271 
    272272  simulateSinglePhe->SetParameters(lambda,mu0,mu1,sigma0,sigma1);
    273273  simulateSinglePhe->SetParNames("#lambda","#mu_0","#mu_1","#sigma_0","#sigma_1");
    274   simulateSinglePhe->SetNpx(fBlindPixelQnbins); 
     274  simulateSinglePhe->SetNpx(fBlindPixelChargenbins); 
    275275
    276276  for (Int_t i=0;i<10000; i++)
    277277    {
    278       fHBlindPixelQ->Fill(simulateSinglePhe->GetRandom());
     278      fHBlindPixelCharge->Fill(simulateSinglePhe->GetRandom());
    279279    }
    280280 
     
    303303  // Get the fitting ranges
    304304  //
    305   rmin = (rmin != 0.) ? rmin : fBlindPixelQfirst;
    306   rmax = (rmax != 0.) ? rmax : fBlindPixelQlast;
     305  rmin = (rmin != 0.) ? rmin : fBlindPixelChargefirst;
     306  rmax = (rmax != 0.) ? rmax : fBlindPixelChargelast;
    307307
    308308  //
     
    310310  // otherwise the fit goes gaga because of high number of dimensions ...
    311311  //
    312   const Stat_t   entries      = fHBlindPixelQ->GetSumOfWeights();
     312  const Stat_t   entries      = fHBlindPixelCharge->GetSumOfWeights();
    313313  const Double_t lambda_guess = 0.2;
    314   const Double_t mu_0_guess = fHBlindPixelQ->GetBinCenter(fHBlindPixelQ->GetMaximumBin());
     314  const Double_t mu_0_guess = fHBlindPixelCharge->GetBinCenter(fHBlindPixelCharge->GetMaximumBin());
    315315  const Double_t si_0_guess = mu_0_guess/10.;
    316316  const Double_t mu_1_guess = mu_0_guess + 50.;
     
    333333  // ROOT gives us another nice example of user-unfriendly behavior:
    334334  // Although the normalization of the function fSinglePhe and the
    335   // Histogram fHBlindPixelQ agree (!!), the fit does not normalize correctly INTERNALLY
     335  // Histogram fHBlindPixelCharge agree (!!), the fit does not normalize correctly INTERNALLY
    336336  // in the fitting procedure !!!
    337337  //
     
    343343  //
    344344  //  const Int_t  npx     = fSinglePheFit->GetNpx();
    345   //  const Int_t  bins    = fHBlindPixelQ->GetXaxis()->GetLast()-fHBlindPixelQ->GetXaxis()->GetFirst();
    346   //  fHBlindPixelQ->Scale(gkSq2Pi*(float)bins/npx/entries);
     345  //  const Int_t  bins    = fHBlindPixelCharge->GetXaxis()->GetLast()-fHBlindPixelCharge->GetXaxis()->GetFirst();
     346  //  fHBlindPixelCharge->Scale(gkSq2Pi*(float)bins/npx/entries);
    347347
    348348  //
     
    351351  // mysteries of ROOT which takes you a whole day to find out :-)
    352352  //
    353   //  fSinglePheFit->SetNpx(fQnbins); 
    354 
    355   fHBlindPixelQ->Fit(fSinglePheFit,opt);
     353  //  fSinglePheFit->SetNpx(fChargenbins); 
     354
     355  fHBlindPixelCharge->Fit(fSinglePheFit,opt);
    356356
    357357  fLambda = fSinglePheFit->GetParameter(0);
     
    405405  Int_t nbins = 50;
    406406
    407   *fLog << "New number of bins in HSinQ: " << CutEdges(fHBlindPixelQ,nbins) << endl;
    408 
    409   fBlindPixelQfirst = fHBlindPixelQ->GetBinLowEdge(fHBlindPixelQ->GetXaxis()->GetFirst());
    410   fBlindPixelQlast  = fHBlindPixelQ->GetBinLowEdge(fHBlindPixelQ->GetXaxis()->GetLast())+fHBlindPixelQ->GetBinWidth(0);
    411   fBlindPixelQnbins = nbins;
    412 
    413   *fLog << "New number of bins in HErrQ: " << CutEdges(fHBlindPixelErrQ,30) << endl;
    414   fErrBlindPixelQfirst = fHBlindPixelErrQ->GetBinLowEdge(fHBlindPixelErrQ->GetXaxis()->GetFirst());
    415   fErrBlindPixelQlast  = fHBlindPixelErrQ->GetBinLowEdge(fHBlindPixelErrQ->GetXaxis()->GetLast())+fHBlindPixelErrQ->GetBinWidth(0);
    416   fErrBlindPixelQnbins = nbins;
    417 
    418   CutEdges(fHBlindPixelQvsN,0);
    419 
    420 }
    421 
    422 Bool_t MHCalibrationBlindPixel::FitT(Axis_t rmin, Axis_t rmax, Option_t *opt)
     407  *fLog << "New number of bins in HSinCharge: " << CutEdges(fHBlindPixelCharge,nbins) << endl;
     408
     409  fBlindPixelChargefirst = fHBlindPixelCharge->GetBinLowEdge(fHBlindPixelCharge->GetXaxis()->GetFirst());
     410  fBlindPixelChargelast  = fHBlindPixelCharge->GetBinLowEdge(fHBlindPixelCharge->GetXaxis()->GetLast())+fHBlindPixelCharge->GetBinWidth(0);
     411  fBlindPixelChargenbins = nbins;
     412
     413  *fLog << "New number of bins in HErrCharge: " << CutEdges(fHBlindPixelErrCharge,30) << endl;
     414  fErrBlindPixelChargefirst = fHBlindPixelErrCharge->GetBinLowEdge(fHBlindPixelErrCharge->GetXaxis()->GetFirst());
     415  fErrBlindPixelChargelast  = fHBlindPixelErrCharge->GetBinLowEdge(fHBlindPixelErrCharge->GetXaxis()->GetLast())+fHBlindPixelErrCharge->GetBinWidth(0);
     416  fErrBlindPixelChargenbins = nbins;
     417
     418  CutEdges(fHBlindPixelChargevsN,0);
     419
     420}
     421
     422Bool_t MHCalibrationBlindPixel::FitTime(Axis_t rmin, Axis_t rmax, Option_t *opt)
    423423{
    424424 
     
    429429  rmax = (rmax != 0.) ? rmax : 9.;
    430430
    431   const Stat_t   entries     = fHBlindPixelT->GetEntries();
    432   const Double_t mu_guess    = fHBlindPixelT->GetBinCenter(fHBlindPixelT->GetMaximumBin());
     431  const Stat_t   entries     = fHBlindPixelTime->GetEntries();
     432  const Double_t mu_guess    = fHBlindPixelTime->GetBinCenter(fHBlindPixelTime->GetMaximumBin());
    433433  const Double_t sigma_guess = (rmax - rmin)/2.;
    434434  const Double_t area_guess  = entries/gkSq2Pi;
     
    441441  fTimeGausFit->SetParLimits(2,0.,rmax-rmin);
    442442
    443   fHBlindPixelT->Fit(fTimeGausFit,opt);
     443  fHBlindPixelTime->Fit(fTimeGausFit,opt);
    444444
    445445  rmin = fTimeGausFit->GetParameter(1) - 2.*fTimeGausFit->GetParameter(2);
     
    447447  fTimeGausFit->SetRange(rmin,rmax); 
    448448
    449   fHBlindPixelT->Fit(fTimeGausFit,opt);
    450 
    451 
    452   fMeanT     = fTimeGausFit->GetParameter(2);
    453   fSigmaT    = fTimeGausFit->GetParameter(3);
    454   fMeanTErr  = fTimeGausFit->GetParError(2);
    455   fSigmaTErr = fTimeGausFit->GetParError(3);
     449  fHBlindPixelTime->Fit(fTimeGausFit,opt);
     450
     451
     452  fMeanTime     = fTimeGausFit->GetParameter(2);
     453  fSigmaTime    = fTimeGausFit->GetParameter(3);
     454  fMeanTimeErr  = fTimeGausFit->GetParError(2);
     455  fSigmaTimeErr = fTimeGausFit->GetParError(3);
    456456
    457457  Float_t prob = fTimeGausFit->GetProb();
  • trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h

    r2599 r2603  
    3232private:
    3333
    34   TH1I* fHBlindPixelQ;        //-> Histogram with the single Phe spectrum
    35   TH1F* fHBlindPixelErrQ;     //-> Variance of summed FADC slices
    36   TH1I* fHBlindPixelT;        //-> Variance of summed FADC slices
    37   TH1I* fHBlindPixelQvsN;     //-> Summed Charge vs. Event Nr.
     34  TH1I* fHBlindPixelCharge;        //-> Histogram with the single Phe spectrum
     35  TH1F* fHBlindPixelErrCharge;     //-> Variance of summed FADC slices
     36  TH1I* fHBlindPixelTime;        //-> Variance of summed FADC slices
     37  TH1I* fHBlindPixelChargevsN;     //-> Summed Charge vs. Event Nr.
    3838 
    3939  TF1 *fSinglePheFit;
    4040  TF1 *fTimeGausFit; 
    4141
    42   Axis_t  fBlindPixelQfirst;
    43   Axis_t  fBlindPixelQlast;
    44   Int_t   fBlindPixelQnbins;
     42  Axis_t  fBlindPixelChargefirst;
     43  Axis_t  fBlindPixelChargelast;
     44  Int_t   fBlindPixelChargenbins;
    4545 
    46   Axis_t fErrBlindPixelQfirst;
    47   Axis_t fErrBlindPixelQlast;
    48   Int_t  fErrBlindPixelQnbins;
     46  Axis_t fErrBlindPixelChargefirst;
     47  Axis_t fErrBlindPixelChargelast;
     48  Int_t  fErrBlindPixelChargenbins;
    4949
    5050  void ResetBin(Int_t i);
     
    7373  Int_t     fNdf;       
    7474
    75   Double_t  fMeanT;
    76   Double_t  fMeanTErr;
    77   Double_t  fSigmaT;
    78   Double_t  fSigmaTErr;
     75  Double_t  fMeanTime;
     76  Double_t  fMeanTimeErr;
     77  Double_t  fSigmaTime;
     78  Double_t  fSigmaTimeErr;
    7979 
    8080public:
     
    8383  ~MHCalibrationBlindPixel();
    8484
    85   Bool_t FillBlindPixelQ(Int_t q)         { return fHBlindPixelQ->Fill(q) > -1;  } 
    86   Bool_t FillErrBlindPixelQ(Float_t errq) { return fHBlindPixelErrQ->Fill(errq) > -1; }
    87   Bool_t FillBlindPixelT(Int_t t)         { return fHBlindPixelT->Fill(t) > -1;  }
    88   Bool_t FillBlindPixelQvsN(Stat_t rq, Int_t t) { return fHBlindPixelQvsN->Fill(t,rq) > -1;  } 
     85  Bool_t FillBlindPixelCharge(Int_t q)         { return fHBlindPixelCharge->Fill(q) > -1;  } 
     86  Bool_t FillErrBlindPixelCharge(Float_t errq) { return fHBlindPixelErrCharge->Fill(errq) > -1; }
     87  Bool_t FillBlindPixelTime(Int_t t)         { return fHBlindPixelTime->Fill(t) > -1;  }
     88  Bool_t FillBlindPixelChargevsN(Stat_t rq, Int_t t) { return fHBlindPixelChargevsN->Fill(t,rq) > -1;  } 
    8989 
    9090  const Double_t GetLambda()   const { return fLambda; }
     
    104104  const Int_t    GetNdf()     const { return fNdf;       }   
    105105
    106   const Double_t GetMeanT()      const { return fMeanT; }
    107   const Double_t GetMeanTErr()    const { return fMeanTErr; }
    108   const Double_t GetSigmaT()      const { return fSigmaT; }
    109   const Double_t GetSigmaTErr()    const { return fSigmaTErr; }
     106  const Double_t GetMeanTime()      const { return fMeanTime; }
     107  const Double_t GetMeanTimeErr()    const { return fMeanTimeErr; }
     108  const Double_t GetSigmaTime()      const { return fSigmaTime; }
     109  const Double_t GetSigmaTimeErr()    const { return fSigmaTimeErr; }
    110110
    111   const TH1F *GetHErrQ() { return fHBlindPixelErrQ; }
    112   const TH1F *GetHErrQ() const { return fHBlindPixelErrQ; }
     111  const TH1F *GetHErrCharge() { return fHBlindPixelErrCharge; }
     112  const TH1F *GetHErrCharge() const { return fHBlindPixelErrCharge; }
    113113 
    114114  Bool_t SimulateSinglePhe(Double_t lambda,
     
    119119 
    120120  Bool_t FitSinglePhe(Axis_t rmin=0, Axis_t rmax=0, Option_t *opt="R0+");
    121   Bool_t FitT(Axis_t rmin=0., Axis_t rmax=0.,Option_t *opt="R0+");
     121  Bool_t FitTime(Axis_t rmin=0., Axis_t rmax=0.,Option_t *opt="R0+");
    122122
    123123  void ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par=5);
  • trunk/MagicSoft/Mars/mhist/MHCalibrationConfig.h

    r2599 r2603  
    2020const Int_t gkStartPINDiodeBinNr = 4000;
    2121
    22 // Starting number of bins for the histo: (maximum possible by hardware = 40800)
    23 const Int_t gkStartPixelBinNr = 20000;
    24 
    25 // Starting number for the highest value of the Q-histo:
    26 const Axis_t gkStartQlast      = 10000.;
    27 
    2822// Square root of 2 pi:
    2923const Float_t gkSq2Pi = 2.506628274631;
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPINDiode.cc

    r2525 r2603  
    6767
    6868    // Create a large number of bins, later we will rebin
    69     fQfirst = 0;
    70     fQlast  = gkStartPINDiodeBinNr;
    71     fQnbins = gkStartPINDiodeBinNr;
     69    fChargeFirst = 0;
     70    fChargeLast  = gkStartPINDiodeBinNr;
     71    fChargeNbins = gkStartPINDiodeBinNr;
    7272
    73     fHPQ = new TH1I("HPQ","Distribution of Summed FADC Slices",fQnbins,fQfirst,fQlast);
    74     fHPQ->SetXTitle("Sum FADC Slices");
    75     fHPQ->SetYTitle("Nr. of events");
    76     fHPQ->Sumw2();
     73    fHPCharge = new TH1I("HPCharge","Distribution of Summed FADC Slices",fChargeNbins,fChargeFirst,fChargeLast);
     74    fHPCharge->SetXTitle("Sum FADC Slices");
     75    fHPCharge->SetYTitle("Nr. of events");
     76    fHPCharge->Sumw2();
    7777
    78     fErrQfirst = 0.;
    79     fErrQlast  = gkStartPINDiodeBinNr;
    80     fErrQnbins = gkStartPINDiodeBinNr;
     78    fErrChargeFirst = 0.;
     79    fErrChargeLast  = gkStartPINDiodeBinNr;
     80    fErrChargeNbins = gkStartPINDiodeBinNr;
    8181
    82     fHErrQ = new TH1F("HErrQ","Distribution of Variances of Summed FADC Slices",fErrQnbins,fErrQfirst,fErrQlast);
    83     fHErrQ->SetXTitle("Variance Summed FADC Slices");
    84     fHErrQ->SetYTitle("Nr. of events");
    85     fHErrQ->Sumw2();
     82    fHErrCharge = new TH1F("HErrCharge","Distribution of Variances of Summed FADC Slices",fErrChargeNbins,fErrChargeFirst,fErrChargeLast);
     83    fHErrCharge->SetXTitle("Variance Summed FADC Slices");
     84    fHErrCharge->SetYTitle("Nr. of events");
     85    fHErrCharge->Sumw2();
    8686
    8787    Int_t tfirst = 0;
     
    8989    Int_t nbins   = 32;
    9090
    91     fHPT = new TH1I("HPT","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
    92     fHPT->SetXTitle("Mean Arrival Times [FADC slice nr]");
    93     fHPT->SetYTitle("Nr. of events");
    94     fHPT->Sumw2();
     91    fHPTime = new TH1I("HPTime","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
     92    fHPTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
     93    fHPTime->SetYTitle("Nr. of events");
     94    fHPTime->Sumw2();
    9595
    9696}
     
    9999{
    100100
    101   delete fHPQ;
    102   delete fHErrQ;
     101  delete fHPCharge;
     102  delete fHErrCharge;
    103103 
    104104  if (fVarGausFit)
    105105    delete fVarGausFit;
    106106 
    107   delete fHPT;
     107  delete fHPTime;
    108108
    109109}
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPINDiode.h

    r2525 r2603  
    2626private:
    2727
    28   TH1I* fHPQ;             //-> Histogram containing the summed 32 PINDiode slices
    29   TH1F* fHErrQ;           //-> Variance of summed FADC slices
    30   TH1I* fHPT;             //-> Histogram with time evolution of summed charges
     28  TH1I* fHPCharge;             //-> Histogram containing the summed 32 PINDiode slices
     29  TH1F* fHErrCharge;           //-> Variance of summed FADC slices
     30  TH1I* fHPTime;             //-> Histogram with time evolution of summed charges
    3131 
    3232 
    3333  TF1 *fVarGausFit;
    3434 
    35   Float_t  fErrQfirst;
    36   Float_t  fErrQlast;
    37   UShort_t fErrQnbins;
     35  Float_t  fErrChargeFirst;
     36  Float_t  fErrChargeLast;
     37  UShort_t fErrChargeNbins;
    3838
    3939public:
     
    4242  ~MHCalibrationPINDiode();
    4343
    44   const Double_t GetT()      const { return fVarGausFit->GetParameter(2); }
    45   const Double_t GetErrT()    const { return fVarGausFit->GetParameter(3); }
     44  const Double_t GetTime()      const { return fVarGausFit->GetParameter(2); }
     45  const Double_t GetErrTime()    const { return fVarGausFit->GetParameter(3); }
    4646
    4747  ClassDef(MHCalibrationPINDiode, 0)
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc

    r2599 r2603  
    6262MHCalibrationPixel::MHCalibrationPixel(const char *name, const char *title)
    6363      : fPixId(-1),
    64         fQGausFit(NULL),
    65         fTGausFit(NULL),
     64        fChargeGausFit(NULL),
     65        fTimeGausFit(NULL),
    6666        fFitLegend(NULL),
    6767        fLowerFitRange(0.),
    6868        fFitOK(kFALSE),
    69         fQChisquare(-1.),
    70         fQProb(-1.),
    71         fQNdf(-1),
    72         fTChisquare(-1.),
    73         fTProb(-1.),
    74         fTNdf(-1)
     69        fChargeChisquare(-1.),
     70        fChargeProb(-1.),
     71        fChargeNdf(-1),
     72        fTimeChisquare(-1.),
     73        fTimeProb(-1.),
     74        fTimeNdf(-1)
    7575{
    7676
     
    7878    fTitle = title ? title : "Fill the accumulated charges and times of all events and perform fits";
    7979
    80     TString qtitle = "Distribution of Summed FADC Slices Pixel ";
    81 
    8280    // Create a large number of bins, later we will rebin
    83     fQfirst = -0.5;
    84     fQlast  = gkStartQlast - 0.5;
    85     fQnbins = gkStartPixelBinNr;
    86 
    87     fHQ = new TH1I("HQ",qtitle.Data(),
    88                    fQnbins,fQfirst,fQlast);
    89     fHQ->SetXTitle("Sum FADC Slices");
    90     fHQ->SetYTitle("Nr. of events");
    91     fHQ->Sumw2();
    92 
    93     fHQ->SetDirectory(NULL);
    94 
    95     TString ttitle = "Distribution of Mean Arrival Times Pixel ";
     81    fChargeFirst = -0.5;
     82    fChargeLast  = 10000. - 0.5;
     83    fChargeNbins = 20000;
     84
     85    fHCharge = new TH1I("HCharge","Distribution of Summed FADC Slices Pixel ",
     86                   fChargeNbins,fChargeFirst,fChargeLast);
     87    fHCharge->SetXTitle("Sum FADC Slices");
     88    fHCharge->SetYTitle("Nr. of events");
     89    fHCharge->Sumw2();
     90
     91    fHCharge->SetDirectory(NULL);
    9692
    9793    Axis_t tfirst = -0.5;
    9894    Axis_t tlast  = 15.5;
    99     Int_t nbins  = 16;
    100 
    101     fHT = new TH1I("HT",ttitle.Data(),
    102                   nbins,tfirst,tlast);
    103     fHT->SetXTitle("Mean Arrival Times [FADC slice nr]");
    104     fHT->SetYTitle("Nr. of events");
    105     fHT->Sumw2();
    106 
    107     fHT->SetDirectory(NULL);
     95    Int_t  ntbins = 16;
     96
     97    fHTime = new TH1I("HTime","Distribution of Mean Arrival Times Pixel ",
     98                  ntbins,tfirst,tlast);
     99    fHTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
     100    fHTime->SetYTitle("Nr. of events");
     101    fHTime->Sumw2();
     102
     103    fHTime->SetDirectory(NULL);
    108104
    109105    TString qvsntitle = "Sum of Charges vs. Event Number Pixel ";
    110106
    111107    // We define a reasonable number and later enlarge it if necessary
    112     nbins = 20000;
     108    Int_t  nqbins = 20000;
    113109    Axis_t nfirst = -0.5;
    114     Axis_t nlast  = (Axis_t)nbins - 0.5;
    115 
    116     fHQvsN = new TH1I("HQvsN",qvsntitle.Data(),
    117                      nbins,nfirst,nlast);
    118     fHQvsN->SetXTitle("Event Nr.");
    119     fHQvsN->SetYTitle("Sum of FADC slices");
    120 
    121     fHQvsN->SetDirectory(NULL);
     110    Axis_t nlast  = (Axis_t)nqbins - 0.5;
     111
     112    fHChargevsN = new TH1I("HChargevsN",qvsntitle.Data(),
     113                     nqbins,nfirst,nlast);
     114    fHChargevsN->SetXTitle("Event Nr.");
     115    fHChargevsN->SetYTitle("Sum of FADC slices");
     116
     117    fHChargevsN->SetDirectory(NULL);
    122118
    123119}
     
    126122{
    127123
    128   delete fHQ;
    129   delete fHT;
    130   delete fHQvsN;
    131 
    132   if (fQGausFit)
    133     delete fQGausFit;
    134   if (fTGausFit)
    135     delete fTGausFit;
     124  delete fHCharge;
     125  delete fHTime;
     126  delete fHChargevsN;
     127
     128  if (fChargeGausFit)
     129    delete fChargeGausFit;
     130  if (fTimeGausFit)
     131    delete fTimeGausFit;
    136132  if (fFitLegend)
    137133    delete fFitLegend;
     
    145141  fPixId = id;
    146142 
    147   TString nameQ = TString(fHQ->GetName());
     143  TString nameQ = TString(fHCharge->GetName());
    148144  nameQ += id;
    149   fHQ->SetName(nameQ.Data());
    150 
    151   TString nameT = TString(fHT->GetName());
     145  fHCharge->SetName(nameQ.Data());
     146
     147  TString nameT = TString(fHTime->GetName());
    152148  nameT += id;
    153   fHT->SetName(nameT.Data());
    154 
    155   TString nameQvsN  = TString(fHQvsN->GetName());
     149  fHTime->SetName(nameT.Data());
     150
     151  TString nameQvsN  = TString(fHChargevsN->GetName());
    156152  nameQvsN += id;
    157   fHQvsN->SetName(nameQvsN.Data());
     153  fHChargevsN->SetName(nameQvsN.Data());
     154
     155  TString titleQ = TString(fHCharge->GetTitle());
     156  titleQ += id;
     157  fHCharge->SetTitle(titleQ.Data());
     158
     159  TString titleT = TString(fHTime->GetTitle());
     160  titleT += id;
     161  fHTime->SetTitle(titleT.Data());
     162
     163  TString titleQvsN  = TString(fHChargevsN->GetTitle());
     164  titleQvsN += id;
     165  fHChargevsN->SetTitle(titleQvsN.Data());
    158166}
    159167
     
    162170{
    163171 
    164   for (Int_t i = fHQ->FindBin(fQfirst); i <= fHQ->FindBin(fQlast); i++)
    165       fHQ->SetBinContent(i, 1.e-20);
     172  for (Int_t i = fHCharge->FindBin(fChargeFirst);
     173       i <= fHCharge->FindBin(fChargeLast); i++)
     174    fHCharge->SetBinContent(i, 1.e-20);
    166175
    167176  for (Int_t i = 0; i < 16; i++)
    168       fHT->SetBinContent(i, 1.e-20);
    169  
    170   fQlast     = gkStartQlast;
    171 
    172   fHQ->GetXaxis()->SetRangeUser(0.,fQlast);
     177      fHTime->SetBinContent(i, 1.e-20);
     178 
     179  fChargeLast     = 9999.5;
     180
     181  fHCharge->GetXaxis()->SetRangeUser(0.,fChargeLast);
    173182
    174183  return;
     
    183192{
    184193
    185   fHQ->Reset();
    186   fHT->Reset();
     194  fHCharge->Reset();
     195  fHTime->Reset();
    187196
    188197  return kTRUE;
     
    208217  fFitLegend->SetTextSize(0.05);
    209218
    210   char line1[32];
    211   sprintf(line1,"Mean: Q_{#mu} = %2.2f #pm %2.2f",fQMean,fQMeanErr);
     219  const TString line1 =
     220    Form("Mean: Q_{#mu} = %2.2f #pm %2.2f",fChargeMean,fChargeMeanErr);
     221
    212222  fFitLegend->AddText(line1);
    213223
    214   char line4[32];
    215   sprintf(line4,"Sigma: #sigma_{Q} = %2.2f #pm %2.2f",fQSigma,fQSigmaErr);
     224
     225  const TString line4 =
     226    Form("Sigma: #sigma_{Q} = %2.2f #pm %2.2f",fChargeSigma,fChargeSigmaErr);
     227
    216228  fFitLegend->AddText(line4);
    217229
    218   char line7[32];
    219   sprintf(line7,"#chi^{2} / N_{dof}: %4.2f / %3i",fQChisquare,fQNdf);
     230
     231  const TString line7 =
     232    Form("#chi^{2} / N_{dof}: %4.2f / %3i",fChargeChisquare,fChargeNdf);
     233
    220234  fFitLegend->AddText(line7);
    221235
    222   char line8[32];
    223   sprintf(line8,"Probability: %4.3f ",fQProb);
     236
     237  const TString line8 =
     238    Form("Probability: %4.3f ",fChargeProb);
     239
    224240  fFitLegend->AddText(line8);
     241
    225242
    226243  if (fFitOK)
     
    256273    gPad->SetTicks();
    257274
    258     fHQ->DrawCopy(opt);
     275    fHCharge->Draw(opt);
    259276   
    260     if (fQGausFit)
     277    if (fChargeGausFit)
    261278      {
    262279        if (fFitOK)
    263           fQGausFit->SetLineColor(kGreen);         
     280          fChargeGausFit->SetLineColor(kGreen);         
    264281        else
    265           fQGausFit->SetLineColor(kRed);
    266 
    267         fQGausFit->DrawCopy("same");
     282          fChargeGausFit->SetLineColor(kRed);
     283
     284        fChargeGausFit->Draw("same");
    268285        c->Modified();
    269286        c->Update();
     
    279296
    280297    gPad->SetLogy(1);
    281     fHT->DrawCopy(opt);
    282 
    283     if (fTGausFit)
     298    fHTime->Draw(opt);
     299
     300    if (fTimeGausFit)
    284301      {
    285         if (fTChisquare > 1.)
    286           fTGausFit->SetLineColor(kRed);
     302        if (fTimeChisquare > 1.)
     303          fTimeGausFit->SetLineColor(kRed);
    287304        else
    288           fTGausFit->SetLineColor(kGreen);
    289 
    290         fTGausFit->DrawCopy("same");
     305          fTimeGausFit->SetLineColor(kGreen);
     306
     307        fTimeGausFit->Draw("same");
    291308        c->Modified();
    292309        c->Update();
     
    297314
    298315    c->cd(4);
    299     fHQvsN->DrawCopy(opt);
    300 }
    301 
    302 
    303 
    304 Bool_t MHCalibrationPixel::FitT(Axis_t rmin, Axis_t rmax, Option_t *option)
    305 {
    306 
    307   if (fTGausFit)
     316    fHChargevsN->Draw(opt);
     317}
     318
     319
     320
     321Bool_t MHCalibrationPixel::FitTime(Axis_t rmin, Axis_t rmax, Option_t *option)
     322{
     323
     324  if (fTimeGausFit)
    308325    return kFALSE;
    309326
     
    311328  rmax = (rmax != 0.) ? rmax : 9.;
    312329
    313   const Stat_t   entries     = fHT->GetEntries();
    314   const Double_t mu_guess    = fHT->GetBinCenter(fHT->GetMaximumBin());
     330  const Stat_t   entries     = fHTime->GetEntries();
     331  const Double_t mu_guess    = fHTime->GetBinCenter(fHTime->GetMaximumBin());
    315332  const Double_t sigma_guess = (rmax - rmin)/2.;
    316333  const Double_t area_guess  = entries/gkSq2Pi;
     
    318335  TString name = TString("GausTime");
    319336  name += fPixId;
    320   fTGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 
    321 
    322   if (!fTGausFit)
     337  fTimeGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 
     338
     339  if (!fTimeGausFit)
    323340    {
    324341    *fLog << err << dbginf << "Could not create fit function for Gauss fit" << endl;
     
    326343    }
    327344
    328   fTGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
    329   fTGausFit->SetParNames("Area","#mu","#sigma");
    330   fTGausFit->SetParLimits(0,0.,entries);
    331   fTGausFit->SetParLimits(1,rmin,rmax);
    332   fTGausFit->SetParLimits(2,0.,(rmax-rmin)/2.);
    333   fTGausFit->SetRange(rmin,rmax);
    334 
    335   fHT->Fit(fTGausFit,option);
    336 
    337   rmin = fTGausFit->GetParameter(1) - 3.*fTGausFit->GetParameter(2);
    338   rmax = fTGausFit->GetParameter(1) + 3.*fTGausFit->GetParameter(2);
    339   fTGausFit->SetRange(rmin,rmax); 
    340 
    341   fHT->Fit(fTGausFit,option);
    342 
    343   fTChisquare = fTGausFit->GetChisquare();
    344   fTNdf       = fTGausFit->GetNDF();
    345   fTProb      = fTGausFit->GetProb();
    346   fTMean      = fTGausFit->GetParameter(1);
    347   fTSigma     = fTGausFit->GetParameter(2);
    348 
    349   if (fTChisquare > 1.)
     345  fTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
     346  fTimeGausFit->SetParNames("Area","#mu","#sigma");
     347  fTimeGausFit->SetParLimits(0,0.,entries);
     348  fTimeGausFit->SetParLimits(1,rmin,rmax);
     349  fTimeGausFit->SetParLimits(2,0.,(rmax-rmin));
     350  fTimeGausFit->SetRange(rmin,rmax);
     351
     352  fHTime->Fit(fTimeGausFit,option);
     353
     354  rmin = fTimeGausFit->GetParameter(1) - 3.*fTimeGausFit->GetParameter(2);
     355  rmax = fTimeGausFit->GetParameter(1) + 3.*fTimeGausFit->GetParameter(2);
     356  fTimeGausFit->SetRange(rmin,rmax); 
     357
     358  fHTime->Fit(fTimeGausFit,option);
     359
     360  fTimeChisquare = fTimeGausFit->GetChisquare();
     361  fTimeNdf       = fTimeGausFit->GetNDF();
     362  fTimeProb      = fTimeGausFit->GetProb();
     363
     364  fTimeMean      = fTimeGausFit->GetParameter(1);
     365  fTimeSigma     = fTimeGausFit->GetParameter(2);
     366
     367  if (fTimeChisquare > 1.)
    350368    {
    351369      *fLog << warn << "Fit of the Arrival times failed ! " << endl;
     
    357375}
    358376
    359 Bool_t MHCalibrationPixel::FitQ(Option_t *option)
    360 {
    361 
    362   if (fQGausFit)
     377Bool_t MHCalibrationPixel::FitCharge(Option_t *option)
     378{
     379
     380  if (fChargeGausFit)
    363381    return kFALSE;
    364382
     
    366384  // Get the fitting ranges
    367385  //
    368   Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fQfirst;
     386  Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirst;
    369387  Axis_t rmax = 0.;
    370388
     
    373391  // otherwise the fit goes gaga because of high number of dimensions ...
    374392  //
    375   const Stat_t   entries  = fHQ->GetEntries();
    376   const Double_t ar_guess = entries/gkSq2Pi;
    377   const Double_t mu_guess = fHQ->GetBinCenter(fHQ->GetMaximumBin());
    378   const Double_t si_guess = mu_guess/50.;
    379 
    380   TString name = TString("QGausFit");
     393  const Stat_t   entries    = fHCharge->GetEntries();
     394  const Double_t area_guess = entries/gkSq2Pi;
     395  const Double_t mu_guess   = fHCharge->GetBinCenter(fHCharge->GetMaximumBin());
     396  const Double_t sigma_guess = mu_guess/15.;
     397
     398  TString name = TString("ChargeGausFit");
    381399  name += fPixId;
    382400
    383   fQGausFit = new TF1(name.Data(),"gaus",rmin,fQlast);
    384 
    385   if (!fQGausFit)
     401  fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLast);
     402
     403  if (!fChargeGausFit)
    386404    {
    387405    *fLog << err << dbginf << "Could not create fit function for Gauss fit" << endl;
     
    389407    }
    390408 
    391   fQGausFit->SetParameters(ar_guess,mu_guess,si_guess);
    392   fQGausFit->SetParNames("Area","#mu","#sigma");
    393   fQGausFit->SetParLimits(0,0.,entries);
    394   fQGausFit->SetParLimits(1,rmin,fQlast);
    395   fQGausFit->SetParLimits(2,0.,fQlast-rmin);
    396   fQGausFit->SetRange(rmin,fQlast);
    397   fQGausFit->Update();
    398 
    399   fHQ->Fit(fQGausFit,option);
    400  
    401   rmin = fQGausFit->GetParameter(1) - 3.*fQGausFit->GetParameter(2);
    402   rmax = fQGausFit->GetParameter(1) + 3.*fQGausFit->GetParameter(2);
    403 
    404   fQGausFit->SetRange(rmin,rmax); 
    405   fHQ->Fit(fQGausFit,option);
    406 
    407   rmin = fQGausFit->GetParameter(1) - 3.5*fQGausFit->GetParameter(2);
    408   rmax = fQGausFit->GetParameter(1) + 3.5*fQGausFit->GetParameter(2);
    409 
    410   fQGausFit->SetRange(rmin,rmax); 
    411   fHQ->Fit(fQGausFit,option);
    412 
    413   fQChisquare = fQGausFit->GetChisquare();
    414   fQNdf       = fQGausFit->GetNDF();
    415   fQProb      = fQGausFit->GetProb();
    416   fQMean      = fQGausFit->GetParameter(1);
    417   fQMeanErr   = fQGausFit->GetParError(1);
    418   fQSigma     = fQGausFit->GetParameter(2);
    419   fQSigmaErr  = fQGausFit->GetParError(2);
     409  fChargeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
     410  fChargeGausFit->SetParNames("Area","#mu","#sigma");
     411  fChargeGausFit->SetParLimits(0,0.,entries);
     412  fChargeGausFit->SetParLimits(1,rmin,fChargeLast);
     413  fChargeGausFit->SetParLimits(2,0.,fChargeLast-rmin);
     414  fChargeGausFit->SetRange(rmin,fChargeLast);
     415
     416  fHCharge->Fit(fChargeGausFit,option);
     417 
     418  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     419 
     420  rmin = (rtry < rmin ? rmin : rtry);
     421  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
     422  fChargeGausFit->SetRange(rmin,rmax); 
     423
     424  fHCharge->Fit(fChargeGausFit,option);
     425
     426  //  rmin = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
     427  //  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
     428  //  fChargeGausFit->SetRange(rmin,rmax); 
     429
     430  // fHCharge->Fit(fChargeGausFit,option);
     431
     432  fChargeChisquare = fChargeGausFit->GetChisquare();
     433  fChargeNdf       = fChargeGausFit->GetNDF();
     434  fChargeProb      = fChargeGausFit->GetProb();
     435  fChargeMean      = fChargeGausFit->GetParameter(1);
     436  fChargeMeanErr   = fChargeGausFit->GetParError(1);
     437  fChargeSigma     = fChargeGausFit->GetParameter(2);
     438  fChargeSigmaErr  = fChargeGausFit->GetParError(2);
    420439
    421440  //
     
    423442  // The Probability is greater than gkProbLimit (default 0.01 == 99%)
    424443  //
    425   if (fQProb < gkProbLimit)
     444  if (fChargeProb < gkProbLimit)
    426445    {
    427       *fLog << warn << "Prob: " << fQProb << " is smaller than the allowed value: " << gkProbLimit << endl;
     446      *fLog << warn << "Prob: " << fChargeProb << " is smaller than the allowed value: " << gkProbLimit << endl;
    428447      fFitOK = kFALSE;
    429448      return kFALSE;
     
    442461  Int_t nbins = 50;
    443462
    444   CutEdges(fHQ,nbins);
    445 
    446   fQfirst = fHQ->GetBinLowEdge(fHQ->GetXaxis()->GetFirst());
    447   fQlast  = fHQ->GetBinLowEdge(fHQ->GetXaxis()->GetLast())+fHQ->GetBinWidth(0);
    448   fQnbins = nbins;
    449 
    450   CutEdges(fHQvsN,0);
    451 
    452 }
    453 
    454 void MHCalibrationPixel::PrintQFitResult()
    455 {
    456  
    457   *fLog << "Results of the Summed Charges Fit: "                 << endl;
    458   *fLog << "Chisquare: "        << fQChisquare                   << endl;
    459   *fLog << "DoF: "              << fQNdf                         << endl;
    460   *fLog << "Probability: "      << fQProb                        << endl;
    461   *fLog                                                          << endl;
    462  
    463 }
    464 
    465 void MHCalibrationPixel::PrintTFitResult()
    466 {
    467 
    468   *fLog << "Results of the Arrival Time Slices Fit: "             << endl;
    469   *fLog << "Chisquare: "   << fTChisquare                         << endl;
    470   *fLog << "Ndf: "         << fTNdf                               << endl;
    471   *fLog << "Probability: " << fTProb                              << endl;
    472   *fLog                                                           << endl;
    473 
    474 }
     463  CutEdges(fHCharge,nbins);
     464
     465  fChargeFirst = fHCharge->GetBinLowEdge(fHCharge->GetXaxis()->GetFirst());
     466  fChargeLast  = fHCharge->GetBinLowEdge(fHCharge->GetXaxis()->GetLast())+fHCharge->GetBinWidth(0);
     467  fChargeNbins = nbins;
     468
     469  CutEdges(fHChargevsN,0);
     470
     471}
     472
     473void MHCalibrationPixel::PrintChargeFitResult()
     474{
     475 
     476  *fLog << "Results of the Summed Charges Fit: "                      << endl;
     477  *fLog << "Chisquare: "        << fChargeChisquare                   << endl;
     478  *fLog << "DoF: "              << fChargeNdf                         << endl;
     479  *fLog << "Probability: "      << fChargeProb                        << endl;
     480  *fLog                                                               << endl;
     481 
     482}
     483
     484void MHCalibrationPixel::PrintTimeFitResult()
     485{
     486
     487  *fLog << "Results of the Time Slices Fit: "                        << endl;
     488  *fLog << "Chisquare: "   << fTimeChisquare                         << endl;
     489  *fLog << "Ndf: "         << fTimeNdf                               << endl;
     490  *fLog << "Probability: " << fTimeProb                              << endl;
     491  *fLog                                                              << endl;
     492
     493}
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h

    r2599 r2603  
    3131protected:
    3232
    33   TH1I* fHQ;              //-> Summed FADC slices
    34   TH1I* fHT;              //-> Mean arrival time in number of FADC sice
    35 
    36   TH1I* fHQvsN;           //-> Summed Charge vs. Event Nr.
     33  TH1I* fHCharge;              //-> Summed FADC slices
     34  TH1I* fHTime;                //-> Mean arrival time in number of FADC sice
     35  TH1I* fHChargevsN;           //-> Summed Charge vs. Event Nr.
    3736 
    38   TF1* fQGausFit;
    39   TF1* fTGausFit;
     37  TF1* fChargeGausFit;
     38  TF1* fTimeGausFit;
    4039 
    4140  TPaveText *fFitLegend; 
    4241 
    4342  Axis_t  fLowerFitRange;
    44   Axis_t  fQfirst;
    45   Axis_t  fQlast;
    46   Int_t   fQnbins;
     43  Axis_t  fChargeFirst;
     44  Axis_t  fChargeLast;
     45  Int_t   fChargeNbins;
    4746
    4847  Bool_t fFitOK;
    4948
    50   Double_t fQChisquare;
    51   Double_t fQProb;
    52   Int_t    fQNdf;
     49  Double_t fChargeChisquare;
     50  Double_t fChargeProb;
     51  Int_t    fChargeNdf;
    5352
    54   Double_t fQMean;
    55   Double_t fQMeanErr;
    56   Double_t fQSigma;
    57   Double_t fQSigmaErr;
     53  Double_t fChargeMean;
     54  Double_t fChargeMeanErr;
     55  Double_t fChargeSigma;
     56  Double_t fChargeSigmaErr;
    5857 
    59   Double_t fTChisquare;
    60   Double_t fTProb;
    61   Int_t    fTNdf;
     58  Double_t fTimeChisquare;
     59  Double_t fTimeProb;
     60  Int_t    fTimeNdf;
    6261
    63   Double_t fTMean;
    64   Double_t fTSigma;
     62  Double_t fTimeMean;
     63  Double_t fTimeSigma;
    6564 
    6665  virtual void DrawLegend();
     
    7675  Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; }
    7776
    78   Bool_t FillQ(Int_t q) {  return fHQ->Fill(q) > -1; }
    79   Bool_t FillT(Int_t t) {  return fHT->Fill(t) > -1; }
    80   Bool_t FillQvsN(Float_t q, Int_t n) { return fHQvsN->Fill(n,q) > -1; }
     77  Bool_t FillCharge(Int_t q)               { return fHCharge->Fill(q)      > -1; }
     78  Bool_t FillTime(Int_t t)                 { return fHTime->Fill(t)        > -1; }
     79  Bool_t FillChargevsN(Float_t q, Int_t n) { return fHChargevsN->Fill(n,q) > -1; }
    8180
    82   const TH1I *GetHQ()       { return fHQ; }
    83   const TH1I *GetHQ() const { return fHQ; }
     81  const TH1I *GetHCharge()                 { return fHCharge;    }
     82  const TH1I *GetHCharge() const           { return fHCharge;    }
    8483
    85   const Double_t GetQMean()    const { return fQMean; }
    86   const Double_t GetQMeanErr()  const { return fQMeanErr; }
    87   const Double_t GetQSigma()   const { return fQSigma; }
    88   const Double_t GetQSigmaErr() const { return fQSigmaErr; }
    89   const Double_t GetArea()    const { return fQGausFit->GetParameter(0); }
    90   const Double_t GetAreaErr()  const { return fQGausFit->GetParError(0); }
     84  const Double_t GetChargeMean()     const { return fChargeMean;    }
     85  const Double_t GetChargeMeanErr()  const { return fChargeMeanErr; }
     86  const Double_t GetChargeSigma()    const { return fChargeSigma;  }
     87  const Double_t GetChargeSigmaErr() const { return fChargeSigmaErr; }
     88  const Double_t GetArea()           const { return fChargeGausFit->GetParameter(0); }
     89  const Double_t GetAreaErr()        const { return fChargeGausFit->GetParError(0); }
    9190
    92   const Double_t GetQChiSquare() const { return fQChisquare; }
    93   const Double_t GetQProb()    const { return fQProb;      } 
    94   const Int_t    GetQNdf()     const { return fQNdf;       }   
     91  const Double_t GetChargeChiSquare() const { return fChargeChisquare; }
     92  const Double_t GetChargeProb()      const { return fChargeProb;      } 
     93  const Int_t    GetChargeNdf()       const { return fChargeNdf;       }   
    9594
    96   const Double_t GetTMean()   const  { return fTMean; }
    97   const Double_t GetTSigma()  const  { return fTSigma; }
     95  const Double_t GetTimeMean()        const { return fTimeMean; }
     96  const Double_t GetTimeSigma()       const { return fTimeSigma; }
    9897
    99   const Double_t GetTChiSquare() const { return fTChisquare; }
    100   const Double_t GetTProb()      const { return fTProb; }
    101   const Int_t    GetTNdf()       const { return fTNdf;       }   
     98  const Double_t GetTimeChiSquare()   const { return fTimeChisquare; }
     99  const Double_t GetTimeProb()        const { return fTimeProb;      }
     100  const Int_t    GetTimeNdf()         const { return fTimeNdf;       }   
    102101 
    103   const TH1I *GetHT()       { return fHT; }
    104   const TH1I *GetHT() const { return fHT; }
     102  const TH1I *GetHTime()                    { return fHTime; }
     103  const TH1I *GetHTime()              const { return fHTime; }
    105104 
    106   const TH1I *GetHQvsN()       { return fHQvsN; }
    107   const TH1I *GetHQvsN() const { return fHQvsN; }
     105  const TH1I *GetHChargevsN()               { return fHChargevsN; }
     106  const TH1I *GetHChargevsN()         const { return fHChargevsN; }
    108107 
    109   Bool_t FitQ(Option_t *option="RQ0"); 
    110   Bool_t FitT(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
     108  Bool_t FitCharge(Option_t *option="RQ0"); 
     109  Bool_t FitTime(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");   
    111110
    112111  virtual void Draw(Option_t *option="");
     
    116115  void SetLowerFitRange(Axis_t min)  { fLowerFitRange = min; }
    117116
    118   void PrintQFitResult();
    119   void PrintTFitResult(); 
     117  void PrintChargeFitResult();
     118  void PrintTimeFitResult(); 
    120119
    121   Bool_t IsFitted()    { return fFitOK; }
     120  Bool_t IsFitOK()    { return fFitOK; }
    122121 
    123122  ClassDef(MHCalibrationPixel, 1)
Note: See TracChangeset for help on using the changeset viewer.