Changeset 2904


Ignore:
Timestamp:
01/24/04 01:52:51 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2903 r2904  
    1313   * mcalib/MCalibrationBlindPix.h
    1414   * mcalib/MHCalibrationBlindPixel.[h,cc]
     15   * mcalib/MCalibrationPix.[h,cc]
    1516   * mcalib/MHCalibrationPixel.[h,cc]
    16    * mcalib/MHCalibrationPixel.[h,cc]
     17   * mcalib/MCalibrationCalc.[h,cc]
    1718     - use MArrivalTime for Storage (or calculation) of time
    1819       in MExtractSignal
    1920     - pass from TH1I histos to TH1F for times
     21
     22   * mcalib/MCalibrationBlindPix.h
     23   * mcalib/MHCalibrationBlindPixel.[h,cc]
     24   * mcalib/MCalibrationPix.[h,cc]
     25   * mcalib/MHCalibrationPixel.[h,cc]
     26   * mcalib/MCalibrationCalc.[h,cc]
     27     - clean up  setters
     28     - pass to bit-fields for all flags
    2029
    2130
  • trunk/MagicSoft/Mars/mcalib/MCalibrationBlindPix.h

    r2885 r2904  
    5757  // Fill histos
    5858  Bool_t FillCharge(Float_t q)                  { return fHist->FillBlindPixelCharge(q); }
    59   Bool_t FillTime(Int_t t)                      { return fHist->FillBlindPixelTime(t); } 
     59  Bool_t FillTime(Float_t t)                    { return fHist->FillBlindPixelTime(t); } 
    6060  Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillBlindPixelChargevsN(rq,t); }   
    6161 
     
    6868  void Draw(Option_t *opt="")                     { fHist->Draw(opt); }
    6969  TObject *DrawClone(Option_t *opt="") const    { return fHist->DrawClone(opt); } 
    70 
    7170 
    7271  ClassDef(MCalibrationBlindPix, 1)     // Storage Container for Calibration information of one pixel
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc

    r2885 r2904  
    2727//   MCalibrationCalc
    2828//
    29 //   This is a task which calculates the number of photons from the FADC
    30 //   time slices. At the moment it integrates simply the FADC values.
    31 //
    32 //
    33 //  The class MCalibrationCam hold one entry of type MCalibrationPix for
    34 //  every pixel. It is filled in the following way:
    35 //  PreParocess: MalibrationCam::InitSize(577) is called which allocates
    36 //               memory in an TClonesArray of type MCalibrationPix and
    37 //               all pointers to NULL.
    38 //
    39 //  Process:     The NULL pointer is tested on every pixel via
    40 //               MalibrationCam::IsPixelUsed(npix).
    41 //
    42 //               In case, IsPixelUsed returns NULL,
    43 //               MalibrationCam::AddPixel(npix) is invoked which creates a
    44 //               new MCalibrationPix(npix) in the npix's entry
    45 //               of the TClonesArray.
    46 //
     29//   Task to calculate the calibration conversion factors from the FADC
     30//   time slices. The integrated time slices have to be delivered by an
     31//   MExtractedSignalCam. The pedestals by an MPedestalCam and possibly
     32//   arrival times from MArrivalTime
     33//
     34//   The output container MCalibrationCam holds one entry of type MCalibrationPix
     35//   for every pixel. It is filled in the following way:
     36//
     37//   ProProcess: Search for MPedestalCam, MExtractedSignalCam
     38//               Initialize MCalibrationCam
     39//               Initialize MArrivalTime if exists
     40//               Initialize pulser light wavelength
     41//               
     42//   ReInit:     MCalibrationCam::InitSize(NumPixels) is called which allocates
     43//               memory in a TClonesArray of type MCalibrationPix
     44//               Initialize number of used FADC slices
     45//               Optionally exclude pixels from calibration               
     46//
     47//   Process:    Optionally, a cut on cosmics can be performed
     48//               
    4749//               Every MCalibrationPix holds a histogram class,
    4850//               MHCalibrationPixel which itself hold histograms of type:
     
    5254//               HChargevsN(npix) (distribution of charges vs. event number.
    5355//
    54 // PostProcess:  All histograms HCharge(npix) are fitted to a Gaussian
    55 //               All histograms HTime(npix) are fitted to a Gaussian
    56 //               The histogram HBlindPixelCharge (blind pixel) is fitted to
    57 //               a single
    58 //                   PhE fit
    59 //               The histogram HBlindPixelTime (blind pixel) is fitted to a
    60 //               Gaussian
    61 //               The histograms of the PIN Diode are fitted to Gaussians
    62 //
    63 //               Fits can be excluded via the commands:
    64 //               MalibrationCam::SetSkipTimeFits()   (skip all time fits)
    65 //               MalibrationCam::SetSkipBlindPixelFits()  (skip all blind
    66 //               pixel fits)
    67 //               MalibrationCam::SetSkipPinDiodeFits()  (skip all PIN Diode
    68 //               fits)
     56//  PostProcess:  All histograms HCharge(npix) are fitted to a Gaussian
     57//                All histograms HTime(npix) are fitted to a Gaussian
     58//                The histogram HBlindPixelCharge (blind pixel) is fitted to
     59//                a single PhE fit
     60//
     61//                The histograms of the PIN Diode are fitted to Gaussians
     62//
     63//                Fits can be excluded via the commands:
     64//                MalibrationCam::SkipTimeFits()   (skip all time fits)
     65//                MalibrationCam::SkipBlindPixelFits()  (skip all blind
     66//                pixel fits)
     67//                MalibrationCam::SkipPinDiodeFits()  (skip all PIN Diode
     68//                fits)
    6969//
    7070//  Input Containers:
    7171//   MRawEvtData
     72//   MPedestalCam
     73//   MExtractedSignalCam
    7274//
    7375//  Output Containers:
     
    8082#include <fstream>
    8183
    82 // FXIME: This has to be removed!!!!
     84// FXIME: This has to be removed!!!! (YES, WHEN WE HAVE ACCESS TO THE DATABASE!!!!!)
    8385#include "MCalibrationConfig.h"
    8486
     
    106108#include "MCalibrationPINDiode.h"
    107109
     110#include "MArrivalTime.h"
     111
    108112ClassImp(MCalibrationCalc);
    109113
     
    116120MCalibrationCalc::MCalibrationCalc(const char *name, const char *title)
    117121    : fPedestals(NULL), fCalibrations(NULL), fSignals(NULL),
    118       fRawEvt(NULL), fRunHeader(NULL), fEvtTime(NULL),
    119       fEvents(0), fHistOverFlow(0), fCosmics(0),
     122      fRawEvt(NULL), fRunHeader(NULL), fArrivalTime(NULL), fEvtTime(NULL),
     123      fEvents(0), fCosmics(0),
    120124      fNumHiGainSamples(0), fNumLoGainSamples(0), fConversionHiLo(0.),
    121125      fNumExcludedPixels(0),
     
    131135    AddToBranchList("MRawEvtData.fLoGainFadcSamples");
    132136
    133     SETBIT(fFlags, kUseTimeFits);
     137    SETBIT(fFlags, kUseTimes);
    134138    SETBIT(fFlags, kUseBlindPixelFit);
    135139    SETBIT(fFlags, kUsePinDiodeFit);
     140    SETBIT(fFlags, kUseCosmicsRejection);
     141    SETBIT(fFlags, kUseQualityChecks);
    136142
    137143}
     
    158164//  - MHCalibrationBlindPixel
    159165//  - MCalibrationCam
     166//
     167// The following output containers are only searched, but not created
     168//
     169//  - MArrivaltime
    160170//  - MTime
    161171//
     
    186196      }
    187197
     198    fArrivalTime  = (MArrivalTime*)pList->FindObject("MArrivalTime");
     199
     200    if (!fArrivalTime)
     201      CLRBIT(fFlags,kUseTimes);
     202
     203    fEvtTime      = (MTime*)pList->FindObject("MTime");
    188204
    189205    switch (fColor)
     
    268284                                     fSignals->GetLastUsedSliceLoGain());
    269285       
     286        if (!TESTBIT(fFlags,kUseQualityChecks))
     287          pix.SetExcludeQualityCheck();
     288
    270289      }
    271290   
     
    340359{
    341360
    342     Int_t cosmicpix = 0;
    343 
    344     MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel());
    345     MCalibrationPINDiode &pindiode   = *(fCalibrations->GetPINDiode());
    346 
    347     MRawEvtPixelIter pixel(fRawEvt);
    348 
    349     //
    350     // Create a first loop to sort out the cosmics ...
    351     //
    352     // This is a very primitive check for the number of cosmicpixs
    353     // The cut will be applied in the fit, but for the blind pixel,
    354     // we need to remove this event
    355     //
    356     // FIXME: In the future need a much more sophisticated one!!!
    357     //
    358 
    359     while (pixel.Next())
    360       {
    361        
    362         const UInt_t pixid = pixel.GetPixelId();
    363        
    364         MExtractedSignalPix &sig =  (*fSignals)[pixid];
    365         MPedestalPix        &ped =  (*fPedestals)[pixid];
    366         Float_t pedrms           = ped.GetPedestalRms()*fSqrtHiGainSamples;
    367         Float_t sumhi            = sig.GetExtractedSignalHiGain();
     361  //
     362  // Initialize pointers to blind pixel, PIN Diode and individual pixels
     363  //
     364  MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel());
     365  MCalibrationPINDiode &pindiode   = *(fCalibrations->GetPINDiode());
     366 
     367  MRawEvtPixelIter pixel(fRawEvt);
     368 
     369  //
     370  // Perform cosmics cut
     371  //
     372  if (TESTBIT(fFlags,kUseCosmicsRejection))
     373    {
    368374       
    369         //
    370         // We consider a pixel as presumably due to cosmics
    371         // if its sum of FADC slices is lower than 3 pedestal RMS
    372         //
    373         if (sumhi < 3.*pedrms ) 
    374           cosmicpix++;
    375      }
    376 
    377     //
    378     // If the camera contains more than 230
    379     // (this is the number of outer pixels plus about 50 inner ones)
    380     // presumed pixels due to cosmics, then the event is discarted.
    381     // This procedure is more or less equivalent to keeping only events
    382     // with at least 350 pixels with high signals.
    383     //
    384     if (cosmicpix > 230.)
    385       {
    386         fCosmics++;
    387         return kCONTINUE;
    388       }
    389 
    390     pixel.Reset();
    391     fEvents++;
    392 
    393 
    394     //
    395     // Create a second loop to do fill the calibration histograms
    396     //
    397 
    398     while (pixel.Next())
    399       {
    400 
    401         const UInt_t pixid = pixel.GetPixelId();
    402        
    403         MCalibrationPix &pix = (*fCalibrations)[pixid];
    404 
    405         if (pix.IsExcluded())
    406           continue;
    407 
    408         MExtractedSignalPix &sig =  (*fSignals)[pixid];
    409        
    410         Float_t sumhi  = sig.GetExtractedSignalHiGain();
    411         Float_t sumlo  = sig.GetExtractedSignalLoGain();
    412         Float_t mtime  = sig.GetMeanArrivalTime();
    413 
    414 
    415         switch(pixid)
    416           {
    417            
    418           case gkCalibrationBlindPixelId:
    419 
    420             if (!blindpixel.FillCharge(sumhi))
    421               *fLog << warn <<
    422                 "Overflow or Underflow occurred filling Blind Pixel sum = " << sumhi << endl;
    423 
    424             if (!blindpixel.FillTime((int)mtime))
    425               *fLog << warn <<
    426                 "Overflow or Underflow occurred filling Blind Pixel time = " << mtime << endl;
    427            
    428             if (!blindpixel.FillRChargevsTime(sumhi,fEvents))
    429               *fLog << warn <<
    430                 "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl;
    431             break;
    432            
    433           case gkCalibrationPINDiodeId:
    434             if (!pindiode.FillCharge(sumhi))
    435               *fLog << warn <<
    436                 "Overflow or Underflow occurred filling PINDiode: sum = " << sumhi << endl;
    437             if (!pindiode.FillTime((int)mtime))
    438               *fLog << warn <<
    439                 "Overflow or Underflow occurred filling PINDiode: time = " << mtime << endl;
    440             if (!pindiode.FillRChargevsTime(sumhi,fEvents))
    441               *fLog << warn <<
    442                 "Overflow or Underflow occurred filling PINDiode: eventnr = " << fEvents << endl;
    443             break;
    444 
    445           default:
    446 
    447             pix.SetChargesInGraph(sumhi,sumlo);
    448 
    449             if (!pix.FillRChargevsTimeLoGain(sumlo,fEvents))
    450               *fLog << warn << "Could not fill Lo Gain Charge vs. EvtNr of pixel: "
    451                     << pixid << " signal = " << sumlo  << " event Nr: " << fEvents << endl;
    452                
    453             if (!pix.FillRChargevsTimeHiGain(sumhi,fEvents))
    454               *fLog << warn << "Could not fill Hi Gain Charge vs. EvtNr of pixel: "
    455                     << pixid << " signal = " << sumhi  << " event Nr: " << fEvents << endl;
    456 
    457             if (sig.IsLoGainUsed())
    458               {
    459                
    460                 if (!pix.FillChargeLoGain(sumlo))
    461                   *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid
    462                         << " signal = " << sumlo << endl;
    463 
    464                 if (!pix.FillTimeLoGain((int)mtime))
    465                   *fLog << warn << "Could not fill Lo Gain Time of pixel: "
    466                         << pixid << " time = " << mtime << endl;
    467                
    468               }
    469             else
    470               {
    471                 if (!pix.FillChargeHiGain(sumhi))
    472                   *fLog << warn << "Could not fill Hi Gain Charge of pixel: " << pixid
    473                         << " signal = " << sumhi << endl;
    474                
    475                 if (!pix.FillTimeHiGain((int)mtime))
    476                   *fLog << warn << "Could not fill Hi Gain Time of pixel: "
    477                         << pixid << " time = " << mtime << endl;
    478                
    479               }
    480             break;
    481            
    482           } /* switch(pixid) */
    483 
    484       } /* while (pixel.Next()) */
    485 
    486     return kTRUE;
     375      Int_t cosmicpix = 0;
     376     
     377      //
     378      // Create a first loop to sort out the cosmics ...
     379      //
     380      // This is a very primitive check for the number of cosmicpixs
     381      // The cut will be applied in the fit, but for the blind pixel,
     382      // we need to remove this event
     383      //
     384      // FIXME: In the future need a much more sophisticated one!!!
     385      //
     386     
     387      while (pixel.Next())
     388        {
     389         
     390          const UInt_t pixid = pixel.GetPixelId();
     391         
     392          MExtractedSignalPix &sig =  (*fSignals)[pixid];
     393          MPedestalPix        &ped =  (*fPedestals)[pixid];
     394          Float_t pedrms           = ped.GetPedestalRms()*fSqrtHiGainSamples;
     395          Float_t sumhi            = sig.GetExtractedSignalHiGain();
     396         
     397          //
     398          // We consider a pixel as presumably due to cosmics
     399          // if its sum of FADC slices is lower than 3 pedestal RMS
     400          //
     401          if (sumhi < 3.*pedrms ) 
     402            cosmicpix++;
     403        }
     404     
     405      //
     406      // If the camera contains more than 230
     407      // (this is the number of outer pixels plus about 50 inner ones)
     408      // presumed pixels due to cosmics, then the event is discarted.
     409      // This procedure is more or less equivalent to keeping only events
     410      // with at least 350 pixels with high signals.
     411      //
     412      if (cosmicpix > 230.)
     413        {
     414          fCosmics++;
     415          return kCONTINUE;
     416        }
     417     
     418      pixel.Reset();
     419    }
     420 
     421  fEvents++;
     422 
     423  //
     424  // Create a (second) loop to do fill the calibration histograms
     425  //
     426 
     427  while (pixel.Next())
     428    {
     429     
     430      const UInt_t pixid = pixel.GetPixelId();
     431     
     432      MCalibrationPix &pix = (*fCalibrations)[pixid];
     433     
     434      if (pix.IsExcluded())
     435        continue;
     436     
     437      MExtractedSignalPix &sig =  (*fSignals)[pixid];
     438     
     439      const Float_t sumhi  = sig.GetExtractedSignalHiGain();
     440      const Float_t sumlo  = sig.GetExtractedSignalLoGain();
     441
     442      Double_t mtime = 0.;
     443
     444      if (TESTBIT(fFlags,kUseTimes))
     445        mtime = (*fArrivalTime)[pixid];
     446     
     447      switch(pixid)
     448        {
     449         
     450        case gkCalibrationBlindPixelId:
     451         
     452          if (!blindpixel.FillCharge(sumhi))
     453            *fLog << warn <<
     454              "Overflow or Underflow occurred filling Blind Pixel sum = " << sumhi << endl;
     455         
     456          if (TESTBIT(fFlags,kUseTimes))
     457            {
     458              if (!blindpixel.FillTime(mtime))
     459                *fLog << warn <<
     460                  "Overflow or Underflow occurred filling Blind Pixel time = " << mtime << endl;
     461            }
     462         
     463          if (!blindpixel.FillRChargevsTime(sumhi,fEvents))
     464            *fLog << warn <<
     465              "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl;
     466          break;
     467         
     468        case gkCalibrationPINDiodeId:
     469
     470          if (!pindiode.FillCharge(sumhi))
     471            *fLog << warn <<
     472              "Overflow or Underflow occurred filling PINDiode: sum = " << sumhi << endl;
     473
     474          if (TESTBIT(fFlags,kUseTimes))
     475            {
     476              if (!pindiode.FillTime(mtime))
     477                *fLog << warn <<
     478                  "Overflow or Underflow occurred filling PINDiode: time = " << mtime << endl;
     479            }
     480         
     481          if (!pindiode.FillRChargevsTime(sumhi,fEvents))
     482            *fLog << warn <<
     483              "Overflow or Underflow occurred filling PINDiode: eventnr = " << fEvents << endl;
     484          break;
     485         
     486        default:
     487         
     488          pix.FillChargesInGraph(sumhi,sumlo);
     489
     490          if (!pix.FillRChargevsTimeLoGain(sumlo,fEvents))
     491            *fLog << warn << "Could not fill Lo Gain Charge vs. EvtNr of pixel: "
     492                  << pixid << " signal = " << sumlo  << " event Nr: " << fEvents << endl;
     493         
     494          if (!pix.FillRChargevsTimeHiGain(sumhi,fEvents))
     495            *fLog << warn << "Could not fill Hi Gain Charge vs. EvtNr of pixel: "
     496                  << pixid << " signal = " << sumhi  << " event Nr: " << fEvents << endl;
     497         
     498          if (sig.IsLoGainUsed())
     499            {
     500             
     501              if (!pix.FillChargeLoGain(sumlo))
     502                *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid
     503                      << " signal = " << sumlo << endl;
     504             
     505              if (TESTBIT(fFlags,kUseTimes))
     506                {
     507                  if (!pix.FillTimeLoGain(mtime))
     508                    *fLog << warn << "Could not fill Lo Gain Time of pixel: "
     509                          << pixid << " time = " << mtime << endl;
     510                }
     511            } /* if (sig.IsLoGainUsed()) */
     512          else
     513            {
     514              if (!pix.FillChargeHiGain(sumhi))
     515                *fLog << warn << "Could not fill Hi Gain Charge of pixel: " << pixid
     516                      << " signal = " << sumhi << endl;
     517             
     518              if (TESTBIT(fFlags,kUseTimes))
     519                {
     520                  if (!pix.FillTimeHiGain(mtime))
     521                    *fLog << warn << "Could not fill Hi Gain Time of pixel: "
     522                          << pixid << " time = " << mtime << endl;
     523                }
     524            } /* else (sig.IsLoGainUsed()) */
     525          break;
     526         
     527        } /* switch(pixid) */
     528     
     529    } /* while (pixel.Next()) */
     530 
     531  return kTRUE;
    487532}
    488533
     
    531576        }
    532577
    533       //blindpixel.DrawClone();
     578      blindpixel.DrawClone();
    534579    }
    535580  else
     
    573618      // Perform the Gauss fits to the arrival times
    574619      //
    575       if (TESTBIT(fFlags,kUseTimeFits))
     620      if (TESTBIT(fFlags,kUseTimes))
    576621        pix.FitTime();
    577622     
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.h

    r2885 r2904  
    11#ifndef MARS_MCalibrationCalc
    22#define MARS_MCalibrationCalc
     3
     4/////////////////////////////////////////////////////////////////////////////
     5//                                                                         //
     6// MCalibrationCalc                                                   //
     7//                                                                         //
     8// Integrates the time slices of the all pixels of a calibration event     //
     9// and substract the pedestal value                                        //
     10//                                                                         //
     11/////////////////////////////////////////////////////////////////////////////
    312
    413#ifndef MARS_MTask
     
    615#endif
    716
     17#ifndef ROOT_TArrayI
     18#include "TArrayI.h"
     19#endif
     20
     21#ifndef MARS_MCalibrationCam
     22#include "MCalibrationCam.h"
     23#endif
     24
     25#include "TString.h"
     26
     27class MRawEvtData;
     28class MRawRunHeader;
     29
    830class MPedestalCam;
    931class MCalibrationCam;
    1032class MExtractedSignalCam;
    11 
    12 class MCalibrationBlindPix;
    13 class MCalibrationPINDiode;
     33class MArrivalTime;
    1434
    1535class MTime;
    16 class MRawEvtData;
    17 class MRawRunHeader;
    1836
    1937class MCalibrationCalc : public MTask
     
    2846  MRawRunHeader            *fRunHeader;    // RunHeader information
    2947
     48  MArrivalTime             *fArrivalTime;  // Calculated Arrival Times
     49 
    3050  MTime                    *fEvtTime;      // Time of the event
    3151
    3252  Int_t fEvents;                           // Number of events 
    33   Int_t fHistOverFlow;                     // Number of events with saturated Low Gain
    3453  Int_t fCosmics;                          // Number of events due to supposed cosmics
    3554
     
    6180  MCalibrationCalc(const char *name=NULL, const char *title=NULL);
    6281
    63 
    6482private:
    6583
    66   enum  { kUseTimeFits, kUseBlindPixelFit, kUsePinDiodeFit };
     84  enum  { kUseTimes, kUseBlindPixelFit, kUsePinDiodeFit,
     85          kUseCosmicsRejection, kUseQualityChecks };
    6786
    6887public:
    6988
    70   // Skipping fits
    71   void SkipTimeFits(Bool_t b=kTRUE)
    72       {b ? CLRBIT(fFlags, kUseTimeFits) : SETBIT(fFlags, kUseTimeFits);}
     89  // Skipping parts of the work
     90  void SkipTime(Bool_t b=kTRUE)
     91      {b ? CLRBIT(fFlags, kUseTimes) : SETBIT(fFlags, kUseTimes);}
    7392  void SkipBlindPixelFit(Bool_t b=kTRUE)
    7493      {b ? CLRBIT(fFlags, kUseBlindPixelFit) : SETBIT(fFlags, kUseBlindPixelFit);}
    7594  void SkipPinDiodeFit(Bool_t b=kTRUE)
    7695      {b ? CLRBIT(fFlags, kUsePinDiodeFit) : SETBIT(fFlags, kUsePinDiodeFit);}
     96  void SkipCosmicsRejection(Bool_t b=kTRUE)
     97      {b ? CLRBIT(fFlags, kUseCosmicsRejection) : SETBIT(fFlags, kUseCosmicsRejection);}
     98  void SkipQualityChecks(Bool_t b=kTRUE)
     99      {b ? CLRBIT(fFlags, kUseQualityChecks) : SETBIT(fFlags, kUseQualityChecks);}
    77100
    78101  // Setters
     
    82105  // Getters
    83106  MCalibrationBlindPix *GetBlindPixel() const;
    84   MCalibrationPINDiode *GetPINDiode() const;
     107  MCalibrationPINDiode *GetPINDiode()   const;
    85108
    86109  // Exclude pixels from configuration file
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.h

    r2885 r2904  
    3737
    3838  Bool_t FillCharge(Float_t q)      { return fHist->FillChargeHiGain(q); }
    39   Bool_t FillTime(Int_t t)          { return fHist->FillTimeHiGain(t); } 
     39  Bool_t FillTime(Float_t t)        { return fHist->FillTimeHiGain(t); } 
    4040  Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillChargevsNHiGain(rq,t); }   
    4141 
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc

    r2852 r2904  
    8383      fConversionSigmaBlindPixelMethod(-1.),
    8484      fConversionSigmaPINDiodeMethod(-1.),
    85       fHiGainSaturation(kFALSE),
    86       fExcluded(kFALSE),
    87       fFitValid(kFALSE),       
    88       fFitted(kFALSE),
    89       fBlindPixelMethodValid(kFALSE),
    90       fFFactorMethodValid(kFALSE),
    91       fPINDiodeMethodValid(kFALSE),
    92       fChargeLimit(5.),
    93       fChargeErrLimit(0.)
     85      fFlags(0),
     86      fChargeLimit(3.),
     87      fChargeErrLimit(0.),
     88      fChargeRelErrLimit(1.)
    9489{
    9590
     
    109104    *fLog << warn << dbginf << " Could not create MHCalibrationPixel " << endl;
    110105
     106  CLRBIT(fFlags, kHiGainSaturation);
     107  CLRBIT(fFlags, kExcluded);
     108  CLRBIT(fFlags, kFitValid);
     109  CLRBIT(fFlags, kFitted);
     110  CLRBIT(fFlags, kBlindPixelMethodValid);
     111  CLRBIT(fFlags, kFFactorMethodValid);
     112  CLRBIT(fFlags, kPINDiodeMethodValid);
     113
    111114}
    112115
     
    115118  delete fHist;
    116119}
     120
     121
    117122
    118123
     
    132137void MCalibrationPix::Clear(Option_t *o)
    133138{
     139
    134140  fHist->Reset();
     141
     142  CLRBIT(fFlags, kHiGainSaturation);
     143  CLRBIT(fFlags, kExcluded);
     144  CLRBIT(fFlags, kFitValid);
     145  CLRBIT(fFlags, kFitted);
     146  CLRBIT(fFlags, kBlindPixelMethodValid);
     147  CLRBIT(fFlags, kFFactorMethodValid);
     148  CLRBIT(fFlags, kPINDiodeMethodValid);
     149
     150}
     151
     152// --------------------------------------------------------------------------
     153//
     154// Set the pedestals from outside
     155//
     156void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
     157{
     158
     159  fPed    = ped;   
     160  fPedRms = pedrms;
     161 
     162}
     163
     164// --------------------------------------------------------------------------
     165//
     166// Set the conversion factors from outside (only for MC)
     167//
     168void MCalibrationPix::SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)
     169{
     170  fConversionFFactorMethod = c;
     171  fConversionErrorFFactorMethod = err;
     172  fConversionSigmaFFactorMethod = sig;
     173}
     174
     175
     176// --------------------------------------------------------------------------
     177//
     178// Set the conversion factors from outside (only for MC)
     179//
     180void MCalibrationPix::SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig)
     181{
     182  fConversionBlindPixelMethod = c;
     183  fConversionErrorBlindPixelMethod = err;
     184  fConversionSigmaBlindPixelMethod = sig;
     185}
     186
     187// --------------------------------------------------------------------------
     188//
     189// Set the conversion factors from outside (only for MC)
     190//
     191void MCalibrationPix::SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig)
     192{
     193  fConversionPINDiodeMethod = c ;
     194  fConversionErrorPINDiodeMethod = err;
     195  fConversionSigmaPINDiodeMethod = sig;
     196}
     197
     198// --------------------------------------------------------------------------
     199//
     200// Set the Hi Gain Saturation Bit from outside (only for MC)
     201//
     202void MCalibrationPix::SetHiGainSaturation(Bool_t b)
     203{
     204
     205  if (b)
     206    {
     207      SETBIT(fFlags, kHiGainSaturation);
     208      fHist->SetUseLoGain(1);
     209    }
     210  else   
     211    {
     212      CLRBIT(fFlags, kHiGainSaturation);
     213      fHist->SetUseLoGain(0);
     214    }
     215}
     216
     217// --------------------------------------------------------------------------
     218//
     219// Set the Excluded Bit from outside
     220//
     221void MCalibrationPix::SetExcluded(Bool_t b )
     222{
     223  b ?  SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
     224}
     225
     226
     227// --------------------------------------------------------------------------
     228//
     229// Set the Excluded Bit from outside
     230//
     231void MCalibrationPix::SetExcludeQualityCheck(Bool_t b )
     232{
     233  b ?  SETBIT(fFlags, kExcludeQualityCheck) : CLRBIT(fFlags, kExcludeQualityCheck);
     234}
     235
     236// --------------------------------------------------------------------------
     237//
     238// Set the Excluded Bit from outside
     239//
     240void MCalibrationPix::SetFitValid(Bool_t b )   
     241{
     242  b ?  SETBIT(fFlags, kFitValid) : CLRBIT(fFlags, kFitValid);
     243}
     244
     245// --------------------------------------------------------------------------
     246//
     247// Set the Excluded Bit from outside
     248//
     249void MCalibrationPix::SetFitted(Bool_t b )
     250{
     251  b ?  SETBIT(fFlags, kFitted) : CLRBIT(fFlags, kFitted);
     252}
     253   
     254// --------------------------------------------------------------------------
     255//
     256// Set the Excluded Bit from outside
     257//
     258void MCalibrationPix::SetBlindPixelMethodValid(Bool_t b )
     259{
     260  b ?  SETBIT(fFlags, kBlindPixelMethodValid) : CLRBIT(fFlags, kBlindPixelMethodValid);
     261}   
     262
     263// --------------------------------------------------------------------------
     264//
     265// Set the Excluded Bit from outside
     266//
     267void MCalibrationPix::SetFFactorMethodValid(Bool_t b )
     268{
     269  b ?  SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid);
     270}   
     271
     272// --------------------------------------------------------------------------
     273//
     274// Set the Excluded Bit from outside
     275//
     276void MCalibrationPix::SetPINDiodeMethodValid(Bool_t b ) 
     277{
     278  b ?  SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid);
     279}
     280
     281
     282Bool_t MCalibrationPix::IsExcluded() const
     283 {
     284   return TESTBIT(fFlags,kExcluded); 
     285 }
     286
     287Bool_t MCalibrationPix::IsFitValid() const
     288{
     289  return TESTBIT(fFlags, kFitValid); 
     290}
     291
     292Bool_t MCalibrationPix::IsFitted() const
     293{
     294  return TESTBIT(fFlags, kFitted);   
     295}
     296
     297Bool_t MCalibrationPix::IsBlindPixelMethodValid() const
     298{
     299  return TESTBIT(fFlags, kBlindPixelMethodValid);
     300}
     301
     302Bool_t MCalibrationPix::IsFFactorMethodValid()  const
     303{
     304  return TESTBIT(fFlags, kFFactorMethodValid);     
     305}
     306
     307Bool_t MCalibrationPix::IsPINDiodeMethodValid() const
     308{
     309  return TESTBIT(fFlags, kPINDiodeMethodValid);   
    135310}
    136311
     
    203378          // 5) In case of failure print out the fit results
    204379          //
    205           fHist->PrintChargeFitResult();
     380          //      fHist->PrintChargeFitResult();
     381          CLRBIT(fFlags,kFitted);
    206382        }
     383      else
     384        SETBIT(fFlags,kFitted);
    207385    }
    208386  else
     
    217395          // 5) In case of failure print out the fit results
    218396          //
    219           fHist->PrintChargeFitResult();
     397          //      fHist->PrintChargeFitResult();
     398          CLRBIT(fFlags,kFitted);
    220399        }
     400      else
     401        SETBIT(fFlags,kFitted);
    221402    }
    222403 
     
    231412  fChargeProb     = fHist->GetChargeProb();
    232413
    233   if (fCharge <= 0.)
    234     {
    235       *fLog << warn << "WARNING: Cannot apply calibration: Mean Fitted Charges are smaller than 0 in pixel "
    236             << fPixId << endl;
     414  if (CheckChargeFitValidity())
     415    SETBIT(fFlags,kFitValid);
     416  else
     417    {
     418      CLRBIT(fFlags,kFitValid);
    237419      return kFALSE;
    238420    }
    239 
    240   if (fErrCharge > 0.)
    241     fFitted = kTRUE;
    242 
    243   if (CheckChargeFitValidity())
    244     fFitValid = kTRUE;
    245 
    246421 
    247422  //
     
    273448      Float_t pedRmsSquareErrSquare           = 4.*fErrPedRms*fErrPedRms * pedRmsSquare;
    274449
    275       if (fHiGainSaturation)
     450      if (TESTBIT(fFlags,kHiGainSaturation))
    276451        {
    277452         
     
    306481          pedRmsSquareErrSquare  = convertedNsbSquareErrSquare  + elecRmsSquareErrSquare;
    307482         
    308         }    /* if (fHiGainSaturation) */
     483        }    /* if (kHiGainSaturation) */
    309484     
    310485      //
     
    317492                << "WARNING: Cannot apply F-Factor calibration: Reduced Sigma smaller than 0 in pixel "
    318493                << fPixId << endl;
    319           if (fHiGainSaturation)
     494          if (TESTBIT(fFlags,kHiGainSaturation))
    320495            ApplyLoGainConversion();
    321496          return kFALSE;
     
    340515      // Calculate the conversion factors
    341516      //
    342       if (fHiGainSaturation)
     517      if (TESTBIT(fFlags,kHiGainSaturation))
    343518        ApplyLoGainConversion();
    344519     
     
    352527           (fConversionFFactorMethod > 0.) &&
    353528           (fConversionErrorFFactorMethod/fConversionFFactorMethod < 0.1) )
    354         fFFactorMethodValid = kTRUE;
    355      
     529        SETBIT(fFlags,kFFactorMethodValid);
     530      else
     531        CLRBIT(fFlags,kFFactorMethodValid);
    356532     
    357533    } /*   if ((fPed > 0.)  && (fPedRms > 0.)) */
     
    366542// 1) Pixel has a fitted charge greater than 5*PedRMS
    367543// 2) Pixel has a fit error greater than 0.
    368 // 3) Pixel has a fit Probability greater than 0.0001
    369 // 4) Pixel has a charge sigma bigger than its Pedestal RMS
     544// 3) Pixel has a fitted charge greater its charge error
     545// 4) Pixel has a fit Probability greater than 0.0001
     546// 5) Pixel has a charge sigma bigger than its Pedestal RMS
    370547//
    371548Bool_t MCalibrationPix::CheckChargeFitValidity()
    372549{
    373550
     551  if (TESTBIT(fFlags,kExcludeQualityCheck))
     552    return kTRUE;
     553
    374554  Float_t equivpedestal = GetPedRms();
    375555
    376   if (fHiGainSaturation)
     556  if (TESTBIT(fFlags,kHiGainSaturation))
    377557    equivpedestal /= fConversionHiLo;
    378558     
     
    391571    }
    392572     
     573  if (fCharge < fChargeRelErrLimit*fErrCharge)
     574    {
     575      *fLog << warn << "WARNING: Error of Fitted Charge is greater than "
     576            << fChargeRelErrLimit << "* Fitted Charges itself in Pixel " << fPixId << endl;
     577      return kFALSE;
     578    }
     579     
    393580  if (!fHist->IsFitOK())
    394581    {
     
    413600{
    414601
     602  if (TESTBIT(fFlags,kExcludeQualityCheck))
     603    return kTRUE;
     604
    415605  Float_t lowerrange;
    416606  Float_t upperrange;
    417607
    418   if (fHiGainSaturation)
     608  if (TESTBIT(fFlags,kHiGainSaturation))
    419609    {
    420610      lowerrange = (Float_t)fHist->GetTimeLowerFitRangeLoGain()+1.;
     
    481671
    482672
    483 // --------------------------------------------------------------------------
    484 //
    485 // Set the pedestals from outside
    486 //
    487 void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
    488 {
    489 
    490   fPed    = ped;   
    491   fPedRms = pedrms;
    492  
    493 }
    494673
    495674// --------------------------------------------------------------------------
     
    510689  // Fit the Low Gain
    511690  //
    512   if (fHiGainSaturation)
     691  if (TESTBIT(fFlags,kHiGainSaturation))
    513692    {
    514693      if(!fHist->FitTimeLoGain())
     
    538717  fTimeProb      = fHist->GetTimeProb();
    539718
    540   if (!CheckTimeFitValidity())
    541     fFitValid = kFALSE;
     719  if (CheckTimeFitValidity())
     720    SETBIT(fFlags,kFitValid);
     721  else
     722    CLRBIT(fFlags,kFitValid);
    542723
    543724  return kTRUE;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h

    r2852 r2904  
    5252  Float_t fConversionHiLoError;             // The error of the conversion factor between Hi Gain and Lo Gain 
    5353 
    54   Bool_t  fHiGainSaturation;                // Is Lo-Gain used at all?
     54  Byte_t  fFlags;                           // Flag for the set Bits
    5555
    56   Bool_t  fExcluded;
    57   Bool_t  fFitValid;       
    58   Bool_t  fFitted;
    59   Bool_t  fBlindPixelMethodValid;
    60   Bool_t  fFFactorMethodValid;
    61   Bool_t  fPINDiodeMethodValid;
     56  enum  { kHiGainSaturation,
     57          kExcluded, kExcludeQualityCheck,
     58          kFitValid, kFitted,
     59          kBlindPixelMethodValid, kFFactorMethodValid, kPINDiodeMethodValid };
    6260 
    63   MHCalibrationPixel *fHist;    //! Pointer to the histograms performing the fits, etc. 
     61  MHCalibrationPixel *fHist;                //! Pointer to the histograms performing the fits, etc. 
    6462
    6563  Float_t fChargeLimit;
    6664  Float_t fChargeErrLimit;
     65  Float_t fChargeRelErrLimit; 
    6766 
    6867  Bool_t CheckChargeFitValidity();
     
    7877
    7978  // Getter
    80   Bool_t IsExcluded()              const { return fExcluded;  } 
    81   Bool_t IsFitValid()              const { return fFitValid;  }
    82   Bool_t IsFitted()                const { return fFitted;    }
    83   Bool_t IsBlindPixelMethodValid() const { return fBlindPixelMethodValid;  }
    84   Bool_t IsFFactorMethodValid()    const { return fFFactorMethodValid;     }
    85   Bool_t IsPINDiodeMethodValid()   const { return fPINDiodeMethodValid;    }
     79  MHCalibrationPixel *GetHist() const   { return fHist;     }
    8680
    8781  // Charges
     
    117111  Float_t GetSigmaConversionPINDiodeMethod()   const { return fConversionSigmaPINDiodeMethod ; }
    118112
    119   // FIXME: Remove this from stored data members
     113  Int_t   GetPixId()                           const  { return fPixId;   }
     114
    120115  Float_t GetPed()                             const { return fPed;    }
    121116  Float_t GetPedRms()                          const { return fPedRms; }
    122117
     118  Bool_t IsExcluded()              const;
     119  Bool_t IsFitValid()              const;
     120  Bool_t IsFitted()                const;
     121  Bool_t IsBlindPixelMethodValid() const;
     122  Bool_t IsFFactorMethodValid()    const;
     123  Bool_t IsPINDiodeMethodValid()   const;
     124
    123125  // Setter
    124126  void SetPedestal(Float_t ped, Float_t pedrms);
    125   void SetHiGainSaturation()             { fHiGainSaturation = kTRUE; fHist->SetUseLoGain(); }
     127  void SetConversionHiLo(Float_t c)      { fConversionHiLo      = c;    }
     128  void SetConversionHiLoError(Float_t e)  { fConversionHiLoError = e;    }
    126129
    127   void SetConversionHiLo(Float_t c)      { fConversionHiLo      = c;    }
    128   void SetConversionHiLoError(Float_t e) { fConversionHiLoError = e;    }
     130  // Setters for MC
     131  void SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig);
     132  void SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig);
     133  void SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig);
    129134
    130   void SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)
    131   {
    132       fConversionFFactorMethod = c;
    133       fConversionErrorFFactorMethod = err;
    134       fConversionSigmaFFactorMethod = sig;
    135   }
    136   void SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig)
    137   {
    138       fConversionBlindPixelMethod = c;
    139       fConversionErrorBlindPixelMethod = err;
    140       fConversionSigmaBlindPixelMethod = sig;
    141   }
    142 
    143   void SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig)
    144   {
    145       fConversionPINDiodeMethod = c ;
    146       fConversionErrorPINDiodeMethod = err;
    147       fConversionSigmaPINDiodeMethod = sig;
    148   }
    149 
    150   void SetExcluded(Bool_t b = kTRUE)            { fExcluded = b;   } 
    151   void SetFitValid(Bool_t b = kTRUE)            { fFitValid = b;  }
    152   void SetFitted(Bool_t b = kTRUE)             { fFitted   = b;  }
    153   void SetBlindPixelMethodValid(Bool_t b = kTRUE)    { fBlindPixelMethodValid = b;  }
    154   void SetFFactorMethodValid(Bool_t b = kTRUE)      { fFFactorMethodValid = b;  }
    155   void SetPINDiodeMethodValid(Bool_t b = kTRUE)      { fPINDiodeMethodValid = b;  }
    156 
    157   // Unknown
    158   void   ApplyLoGainConversion();
    159 
    160   void   SetChargesInGraph(Float_t qhi,Float_t qlo) { fHist->SetPointInGraph(qhi,qlo); }
    161 
     135  // Bit Setters
     136  void SetHiGainSaturation(Bool_t b = kTRUE);
     137  void SetExcluded(Bool_t b = kTRUE);
     138  void SetExcludeQualityCheck(Bool_t b = kTRUE);
     139  void SetFitValid(Bool_t b = kTRUE);
     140  void SetFitted(Bool_t b = kTRUE);
     141  void SetBlindPixelMethodValid(Bool_t b = kTRUE);
     142  void SetFFactorMethodValid(Bool_t b = kTRUE);
     143  void SetPINDiodeMethodValid(Bool_t b = kTRUE);
     144 
     145  // Fill histos
    162146  Bool_t FillChargeHiGain(Float_t q)                   { return fHist->FillChargeHiGain(q); }
    163   Bool_t FillTimeHiGain(Int_t t)                       { return fHist->FillTimeHiGain(t); } 
     147  Bool_t FillTimeHiGain(Float_t t)                     { return fHist->FillTimeHiGain(t); } 
    164148  Bool_t FillRChargevsTimeHiGain(Float_t rq, Int_t t)  { return fHist->FillChargevsNHiGain(rq,t); }   
    165149
    166150  Bool_t FillChargeLoGain(Float_t q)                   { return fHist->FillChargeLoGain(q); }
    167   Bool_t FillTimeLoGain(Int_t t)                       { return fHist->FillTimeLoGain(t); } 
     151  Bool_t FillTimeLoGain(Float_t t)                     { return fHist->FillTimeLoGain(t); } 
    168152  Bool_t FillRChargevsTimeLoGain(Float_t rq, Int_t t)  { return fHist->FillChargevsNLoGain(rq,t); }   
    169153 
    170   // FIXME: Not necessary -> pixidx (not id anyhow!) == index in array!
    171   //        Only needed n histograms which have to move to an MH-class anyhow!
    172   Int_t  GetPixId()                              const  { return fPixId;   }
     154  Bool_t FillChargesInGraph(Float_t qhi,Float_t qlo)   { return fHist->FillPointInGraph(qhi,qlo); }
     155
    173156  void   DefinePixId(Int_t i);
    174  
     157
     158  // Fits
    175159  Bool_t FitCharge();
    176160  Bool_t FitTime();
    177161 
    178   MHCalibrationPixel *GetHist() const   { return fHist;     }
    179   void Draw(Option_t *opt="")            { fHist->Draw(opt); }
     162  // Draws
     163  void Draw(Option_t *opt="")                    { fHist->Draw(opt); }
     164  TObject *DrawClone(Option_t *opt="") const    { return fHist->DrawClone(opt); } 
    180165 
     166  // Miscellaneous
     167  void   ApplyLoGainConversion();
     168
    181169  ClassDef(MCalibrationPix, 1)  // Storage Container for Calibration information of one pixel
    182170};
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc

    r2885 r2904  
    9696    Int_t nbins   = 16;
    9797
    98     fHBlindPixelTime = new TH1I("HBlindPixelTime","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
     98    fHBlindPixelTime = new TH1F("HBlindPixelTime","Distribution of Mean Arrival Times",nbins,tfirst,tlast);
    9999    fHBlindPixelTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
    100100    fHBlindPixelTime->SetYTitle("Nr. of events");
     
    141141}
    142142
    143 Bool_t MHCalibrationBlindPixel::FillBlindPixelTime(Int_t t)
     143Bool_t MHCalibrationBlindPixel::FillBlindPixelTime(Float_t t)
    144144{
    145145    return fHBlindPixelTime->Fill(t) > -1;
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.h

    r2885 r2904  
    1010class TF1;
    1111class TPaveText;
    12 
    13 /*
    14 #ifndef MARS_MHCalibrationConfig
    15 #include "MHCalibrationConfig.h"
    16 #endif
    17 
    18 #ifndef MARS_MFFT
    19 #include "MFFT.h"
    20 #endif
    21 
    22 #ifndef ROOT_TH1
    23 #include "TH1.h"
    24 #endif
    25 
    26 #ifndef ROOT_TH1F
    27 #include "TH1F.h"
    28 #endif
    29 
    30 #ifndef ROOT_TF1
    31 #include "TF1.h"
    32 #endif
    33 
    34 #ifndef ROOT_TPaveText
    35 #include "TPaveText.h"
    36 #endif
    37 */
    38 
    39 
    40 const Double_t NoWay = 10000000000.0;
    4112
    4213class TMath;
     
    4718
    4819  TH1F* fHBlindPixelCharge;        // Histogram with the single Phe spectrum
    49   TH1I* fHBlindPixelTime;          // Variance of summed FADC slices
     20  TH1F* fHBlindPixelTime;          // Variance of summed FADC slices
    5021  TH1I* fHBlindPixelChargevsN;     // Summed Charge vs. Event Nr.
    5122  TH1F* fHBlindPixelPSD;           // Power spectrum density of fHBlindPixelChargevsN
     
    9566
    9667  Bool_t FillBlindPixelCharge(Float_t q);
    97   Bool_t FillBlindPixelTime(Int_t t);
     68  Bool_t FillBlindPixelTime(Float_t t);
    9869  Bool_t FillBlindPixelChargevsN(Stat_t rq, Int_t t);
    9970 
     
    153124private:
    154125
     126  const static Double_t fNoWay = 10000000000.0;
     127
    155128  Bool_t InitFit(Axis_t min, Axis_t max);
    156129  void ExitFit(TF1 *f); 
     
    168141     
    169142      if (mu1 < mu0)
    170         return NoWay;
     143        return fNoWay;
    171144
    172145      Double_t sigma0 = par[3];
     
    174147     
    175148      if (sigma1 < sigma0)
    176         return NoWay;
     149        return fNoWay;
    177150     
    178151      Double_t mu2 = (2.*mu1)-mu0; 
     
    224197     
    225198      if (mu1 < mu0)
    226         return NoWay;
     199        return fNoWay;
    227200
    228201      Double_t sigma0 = par[3];
     
    230203     
    231204      if (sigma1 < sigma0)
    232         return NoWay;
     205        return fNoWay;
    233206     
    234207      Double_t mu2 = (2.*mu1)-mu0; 
     
    281254     
    282255      if (mu1 < mu0)
    283         return NoWay;
     256        return fNoWay;
    284257     
    285258      Double_t sigma0 = par[3];
     
    287260     
    288261      if (sigma1 < sigma0)
    289         return NoWay;
     262        return fNoWay;
    290263     
    291264     
     
    346319     
    347320      if (mu1 < mu0)
    348         return NoWay;
     321        return fNoWay;
    349322     
    350323      Double_t sigma0 = par[3];
     
    352325     
    353326      if (sigma1 < sigma0)
    354         return NoWay;
     327        return fNoWay;
    355328     
    356329     
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.h

    r2885 r2904  
    1616  TH1I* fHPCharge;           //-> Histogram containing the summed 32 PINDiode slices
    1717  TH1F* fHErrCharge;         //-> Variance of summed FADC slices
    18   TH1I* fHPTime;             //-> Histogram with time evolution of summed charges
    19  
     18  TH1F* fHPTime;             //-> Histogram with time evolution of summed charges
    2019 
    2120  TF1 *fVarGausFit;
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc

    r2885 r2904  
    4141#include <TCanvas.h>
    4242#include <TPaveText.h>
     43#include <TText.h>
    4344
    4445#include "MLog.h"
     
    5657      : fPixId(-1),
    5758        fTotalEntries(0),
    58         fHiGains(NULL),
    59         fLoGains(NULL),
     59        fHChargeHiGain(NULL), 
     60        fHTimeHiGain(NULL),
     61        fHChargevsNHiGain(NULL),
     62        fHChargeLoGain(NULL), 
     63        fHTimeLoGain(NULL),   
     64        fHChargevsNLoGain(NULL),
    6065        fChargeGausFit(NULL),
    6166        fTimeGausFit(NULL),
    6267        fHivsLoGain(NULL),
    6368        fFitLegend(NULL),
    64         fLowerFitRange(-2000.),
    65         fChargeFirstHiGain(-2000.5),
    66         fChargeLastHiGain(9999.5),
    67         fChargeNbinsHiGain(12000),
    68         fChargeFirstLoGain(-2000.5),
     69        fLowerFitRange(-100.),
     70        fChargeFirstHiGain(-100.5),
     71        fChargeLastHiGain(1999.5),
     72        fChargeNbinsHiGain(2100),
     73        fChargeFirstLoGain(-100.5),
    6974        fChargeLastLoGain(9999.5),
    70         fChargeNbinsLoGain(1200),
     75        fChargeNbinsLoGain(1010),
    7176        fChargeChisquare(-1.),
    7277        fChargeProb(-1.),
     
    8186        fTimeLowerFitRangeLoGain(0),
    8287        fTimeUpperFitRangeLoGain(0),
    83         fUseLoGain(kFALSE),
    84         fFitOK(kFALSE),
    8588        fOffset(0.),
    8689        fSlope(0.)
     
    111114    Int_t  ntbins = 16;
    112115
    113     fHTimeHiGain = new TH1I("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ",
     116    fHTimeHiGain = new TH1F("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ",
    114117                            ntbins,tfirst,tlast);
    115118    fHTimeHiGain->SetXTitle("Mean Arrival Times [Hi Gain FADC slice nr]");
     
    117120    fHTimeHiGain->SetDirectory(NULL);
    118121
    119     fHTimeLoGain = new TH1I("HTimeLoGain","Distribution of Mean Arrival Lo Gain Times Pixel ",
     122    fHTimeLoGain = new TH1F("HTimeLoGain","Distribution of Mean Arrival Lo Gain Times Pixel ",
    120123                            ntbins,tfirst,tlast);
    121124    fHTimeLoGain->SetXTitle("Mean Arrival Times [Lo Gain FADC slice nr]");
     
    170173    delete fHivsLoGain;
    171174
    172 
    173 }
    174 
    175 const Double_t MHCalibrationPixel::GetArea() const
    176 {
    177     return fChargeGausFit->GetParameter(0);
    178 }
    179 
    180 const Double_t MHCalibrationPixel::GetAreaErr() const
    181 {
    182     return fChargeGausFit->GetParError(0);
    183 }
    184 
    185 Bool_t MHCalibrationPixel::IsEmpty()
     175}
     176
     177Bool_t MHCalibrationPixel::IsEmpty() const
    186178{
    187179    return !(fHChargeHiGain->GetEntries() || fHChargeLoGain->GetEntries());
    188180}
    189  
     181
     182Bool_t MHCalibrationPixel::IsUseLoGain() const
     183{
     184  return TESTBIT(fFlags,kUseLoGain);
     185}
     186
     187Bool_t MHCalibrationPixel::IsFitOK() const
     188{
     189    return TESTBIT(fFlags,kFitOK);
     190}
     191
    190192Bool_t MHCalibrationPixel::FillChargeLoGain(Float_t q)
    191193{
     
    193195}
    194196
    195 Bool_t MHCalibrationPixel::FillTimeLoGain(Int_t t)
     197Bool_t MHCalibrationPixel::FillTimeLoGain(Float_t t)
    196198{
    197199    return (fHTimeLoGain->Fill(t)   > -1);
     
    205207Bool_t MHCalibrationPixel::FillChargeHiGain(Float_t q)
    206208{
    207     return (fHChargeHiGain->Fill(q)      > -1);
    208 }
    209 
    210 Bool_t MHCalibrationPixel::FillTimeHiGain(Int_t t)
    211 {
    212     return (fHTimeHiGain->Fill(t)        > -1);
     209    return (fHChargeHiGain->Fill(q) > -1);
     210}
     211
     212Bool_t MHCalibrationPixel::FillTimeHiGain(Float_t t)
     213{
     214    return (fHTimeHiGain->Fill(t) > -1);
    213215}
    214216
     
    285287
    286288
     289Bool_t MHCalibrationPixel::SetupFill(const MParList *plist)
     290{
     291 
     292  fHChargeHiGain->Reset();
     293  fHTimeHiGain->Reset();
     294  fHChargeLoGain->Reset();
     295  fHTimeLoGain->Reset();
     296
     297  return kTRUE;
     298}
     299
     300
    287301void MHCalibrationPixel::Reset()
    288302{
     
    293307
    294308  for (Int_t i = 0; i < 16; i++)
    295       fHTimeHiGain->SetBinContent(i, 1.e-20);
    296  
    297   fChargeLastHiGain     = 9999.5;
    298 
    299   fHChargeHiGain->GetXaxis()->SetRangeUser(0.,fChargeLastHiGain);
     309    fHTimeHiGain->SetBinContent(i, 1.e-20);
     310
     311  fChargeFirstHiGain    = -100.5;
     312  fChargeLastHiGain     = 1999.5;
     313
     314  fHChargeHiGain->GetXaxis()->UnZoom();
    300315
    301316 for (Int_t i = fHChargeLoGain->FindBin(fChargeFirstLoGain);
     
    306321      fHTimeLoGain->SetBinContent(i, 1.e-20);
    307322 
     323  fChargeFirstLoGain    = -100.5;
    308324  fChargeLastLoGain     = 9999.5;
    309325
    310   fHChargeLoGain->GetXaxis()->SetRangeUser(0.,fChargeLastLoGain);
     326  fHChargeLoGain->GetXaxis()->UnZoom();
    311327
    312328  return;
     
    319335  if (fHChargeHiGain->Integral() > fHChargeLoGain->Integral())
    320336    {
    321       fUseLoGain = kFALSE;
     337      CLRBIT(fFlags,kUseLoGain);
    322338      return kFALSE;
    323339    }
    324340  else
    325341    {
    326       fUseLoGain = kTRUE;
     342      SETBIT(fFlags,kUseLoGain);
    327343      return kTRUE;
    328344    }
    329345}
    330346
    331 void MHCalibrationPixel::SetPointInGraph(Float_t qhi,Float_t qlo)
     347Bool_t MHCalibrationPixel::FillPointInGraph(Float_t qhi,Float_t qlo)
    332348{
    333349
     
    337353  fHiGains->AddAt(qhi,fTotalEntries-1);
    338354  fLoGains->AddAt(qlo,fTotalEntries-1);
     355
     356  return kTRUE;
    339357
    340358}
     
    350368  fFitLegend = new TPaveText(0.05,0.05,0.95,0.95);
    351369
    352   if (fFitOK)
     370  if (IsFitOK())
    353371      fFitLegend->SetFillColor(80);
    354372  else
     
    360378  const TString line1 =
    361379    Form("Mean: Q_{#mu} = %2.2f #pm %2.2f",fChargeMean,fChargeMeanErr);
    362 
    363   fFitLegend->AddText(line1);
    364 
     380  TText *t1 = fFitLegend->AddText(line1);
     381  t1->SetBit(kCanDelete);
    365382
    366383  const TString line4 =
    367384    Form("Sigma: #sigma_{Q} = %2.2f #pm %2.2f",fChargeSigma,fChargeSigmaErr);
    368 
    369   fFitLegend->AddText(line4);
    370 
     385  TText *t2 =  fFitLegend->AddText(line4);
     386  t2->SetBit(kCanDelete);
    371387
    372388  const TString line7 =
    373389    Form("#chi^{2} / N_{dof}: %4.2f / %3i",fChargeChisquare,fChargeNdf);
    374 
    375   fFitLegend->AddText(line7);
    376 
     390  TText *t3 =  fFitLegend->AddText(line7);
     391  t3->SetBit(kCanDelete);
    377392
    378393  const TString line8 =
    379394    Form("Probability: %4.3f ",fChargeProb);
    380 
    381   fFitLegend->AddText(line8);
    382 
    383   if (fFitOK)
    384     fFitLegend->AddText("Result of the Fit: OK");
     395  TText *t4 =  fFitLegend->AddText(line8);
     396  t4->SetBit(kCanDelete);
     397
     398  if (IsFitOK())
     399    {
     400      TText *t5 = fFitLegend->AddText("Result of the Fit: OK");
     401      t5->SetBit(kCanDelete);
     402    }
    385403  else
    386     fFitLegend->AddText("Result of the Fit: NOT OK");
    387 
     404    {
     405      TText *t6 = fFitLegend->AddText("Result of the Fit: NOT OK");
     406      t6->SetBit(kCanDelete);
     407    }
     408 
    388409  fFitLegend->SetBit(kCanDelete);
    389410  fFitLegend->Draw();
    390411
    391412}
     413
     414
     415TObject *MHCalibrationPixel::DrawClone(Option_t *option) const
     416{
     417
     418  gROOT->SetSelectedPad(NULL);
     419 
     420  MHCalibrationPixel *newobj = (MHCalibrationPixel*)Clone();
     421
     422  if (!newobj)
     423    return 0;
     424  newobj->SetBit(kCanDelete);
     425
     426
     427  if (strlen(option))
     428    newobj->Draw(option);
     429  else   
     430    newobj->Draw(GetDrawOption());
     431 
     432  return newobj;
     433}
     434 
    392435
    393436
     
    400443
    401444  if (!fHivsLoGain)
    402     FitHiGainvsLoGain();
     445   FitHiGainvsLoGain();
    403446     
    404447  gStyle->SetOptFit(0);
    405   gStyle->SetOptStat(1111111);
     448  gStyle->SetOptStat(111111);
     449 
     450  gROOT->SetSelectedPad(NULL);
    406451 
    407452  TCanvas *c = MakeDefCanvas(this,600,900);
    408  
    409   gROOT->SetSelectedPad(NULL);
    410453 
    411454  c->Divide(2,4);
     
    420463    gPad->SetLogy(0);
    421464
    422   fHChargeHiGain->DrawCopy(opt);
     465  fHChargeHiGain->Draw(opt);
    423466 
    424467  c->Modified();
    425468  c->Update();
    426469 
    427   if (fUseLoGain)
     470  if (IsUseLoGain())
    428471    {
    429472
     
    436479        gPad->SetLogy(0);
    437480
    438       fHChargeLoGain->DrawCopy(opt);
     481      fHChargeLoGain->Draw(opt);
    439482     
    440483      if (fChargeGausFit)
    441484        {
    442           if (fFitOK)
     485          if (IsFitOK())
    443486            fChargeGausFit->SetLineColor(kGreen);         
    444487          else
    445488            fChargeGausFit->SetLineColor(kRed);
    446489         
    447           fChargeGausFit->DrawCopy("same");
     490          fChargeGausFit->Draw("same");
    448491        }
    449492      c->Modified();
     
    453496      gROOT->SetSelectedPad(NULL);
    454497      gStyle->SetOptFit();
    455       fHivsLoGain->Draw("prof");
    456 
     498      if (fHivsLoGain)
     499        fHivsLoGain->Draw("prof");
    457500      gPad->Modified();
    458501      gPad->Update();
     
    466509      if (fChargeGausFit)
    467510        {
    468           if (fFitOK)
     511          if (IsFitOK())
    469512            fChargeGausFit->SetLineColor(kGreen);         
    470513          else
    471514            fChargeGausFit->SetLineColor(kRed);
    472515         
    473           fChargeGausFit->DrawCopy("same");
     516          fChargeGausFit->Draw("same");
    474517        }
    475518
     
    482525        gPad->SetLogy(0);
    483526     
    484       fHChargeLoGain->DrawCopy(opt);
     527      fHChargeLoGain->Draw(opt);
    485528      c->Modified();
    486529      c->Update();
     
    493536      gROOT->SetSelectedPad(NULL);
    494537      gStyle->SetOptFit();
    495       fHivsLoGain->Draw("prof");
     538      if (fHivsLoGain)
     539        fHivsLoGain->Draw("prof");
    496540      gPad->Modified();
    497541      gPad->Update();
     
    506550  gPad->SetTicks(); 
    507551  gPad->SetLogy(0);
    508   fHTimeHiGain->DrawCopy(opt);
     552  fHTimeHiGain->Draw(opt);
    509553  c->Modified();
    510554  c->Update();
    511555 
    512   if (fUseLoGain)
     556  if (IsUseLoGain())
    513557      {
    514558       
     
    516560        gPad->SetTicks();
    517561        gPad->SetLogy(0);
    518         fHTimeLoGain->DrawCopy(opt);
     562        fHTimeLoGain->Draw(opt);
    519563        c->Modified();
    520564        c->Update();
     
    527571              fTimeGausFit->SetLineColor(kGreen);
    528572           
    529             fTimeGausFit->DrawCopy("same");
     573            fTimeGausFit->Draw("same");
    530574            c->Modified();
    531575            c->Update();
     
    541585              fTimeGausFit->SetLineColor(kGreen);
    542586           
    543             fTimeGausFit->DrawCopy("same");
     587            fTimeGausFit->Draw("same");
    544588            c->Modified();
    545589            c->Update();
     
    549593        gPad->SetTicks();
    550594        gPad->SetLogy(0);
    551         fHTimeLoGain->DrawCopy(opt);   
     595        fHTimeLoGain->Draw(opt);       
    552596        c->Modified();
    553597        c->Update();
     
    559603    c->cd(7);
    560604    gPad->SetTicks();
    561     fHChargevsNHiGain->DrawCopy(opt);
     605    fHChargevsNHiGain->Draw(opt);
    562606    c->Modified();
    563607    c->Update();
     
    565609    c->cd(8);
    566610    gPad->SetTicks();
    567     fHChargevsNLoGain->DrawCopy(opt);
     611    fHChargevsNLoGain->Draw(opt);
    568612    c->Modified();
    569613    c->Update();
    570614
    571 
     615    return;
    572616}
    573617
     
    575619{
    576620
     621  *fLog << inf << "Fit Hi Gain vs Lo Gain " << endl;
     622
    577623  if (fHivsLoGain)
     624    return;
     625
     626  if ((!fHiGains) || (!fLoGains) || (fHiGains->GetSize() == 0) || (fLoGains->GetSize() == 0))
    578627    return;
    579628
     
    587636  titleHiLoGain += fPixId;
    588637  fHivsLoGain->SetName(titleHiLoGain.Data());
    589 
    590638 
    591639  for (Int_t i=0;i<fTotalEntries;i++)
    592640    fHivsLoGain->Fill(fHiGains->At(i),fLoGains->At(i),1);
    593641 
    594   fHivsLoGain->Fit("pol1","rq","",fHivsLoGain->GetMean()-2.5*fHivsLoGain->GetRMS(),fHivsLoGain->GetMean()+2.*fHivsLoGain->GetRMS());
     642  fHivsLoGain->Fit("pol1","rq","",fHivsLoGain->GetMean()-2.5*fHivsLoGain->GetRMS(),
     643                                  fHivsLoGain->GetMean()+2.0*fHivsLoGain->GetRMS());
    595644 
    596645  fOffset = fHivsLoGain->GetFunction("pol1")->GetParameter(0);
     
    772821  if (fChargeProb < gkProbLimit)
    773822    {
    774       *fLog << warn << "WARNING: Fit Probability " << fChargeProb
    775             << " is smaller than the allowed value: " << gkProbLimit << endl;
    776       fFitOK = kFALSE;
     823      //      *fLog << warn << "WARNING: Fit Probability " << fChargeProb
     824      //            << " is smaller than the allowed value: " << gkProbLimit << endl;
     825      CLRBIT(fFlags,kFitOK);
    777826      return kFALSE;
    778827    }
    779828 
    780   fFitOK = kTRUE;
     829  SETBIT(fFlags,kFitOK);
    781830  return kTRUE;
    782831}
     
    852901  if (fChargeProb < gkProbLimit)
    853902    {
    854       *fLog << warn << "WARNING: Fit Probability " << fChargeProb
    855             << " is smaller than the allowed value: " << gkProbLimit << endl;
    856       fFitOK = kFALSE;
     903      //      *fLog << warn << "WARNING: Fit Probability " << fChargeProb
     904      //            << " is smaller than the allowed value: " << gkProbLimit << endl;
     905      CLRBIT(fFlags,kFitOK);
    857906      return kFALSE;
    858907    }
    859908 
    860  
    861   fFitOK = kTRUE;
     909  SETBIT(fFlags,kFitOK);
    862910   
    863911  return kTRUE;
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.h

    r2885 r2904  
    2121  Int_t fTotalEntries;           // Number of entries
    2222
    23   TArrayF *fHiGains;
    24   TArrayF *fLoGains;
     23  TArrayF *fHiGains;             //->
     24  TArrayF *fLoGains;             //->
    2525
    2626protected:
    2727
    2828  TH1F* fHChargeHiGain;          // Summed FADC slices High Gain
    29   TH1I* fHTimeHiGain;            // Mean arrival time in number of FADC sice
     29  TH1F* fHTimeHiGain;            // Mean arrival time in number of FADC sice
    3030  TH1I* fHChargevsNHiGain;       // Summed Charge vs. Event Nr.
    31  
     31                         
    3232  TH1F* fHChargeLoGain;          // Summed FADC slices Low Gain
    33   TH1I* fHTimeLoGain;            // Mean arrival time in number of FADC sice
     33  TH1F* fHTimeLoGain;            // Mean arrival time in number of FADC sice
    3434  TH1I* fHChargevsNLoGain;       // Summed Charge vs. Event Nr.
    3535
     
    7070  Byte_t   fTimeLowerFitRangeLoGain;
    7171  Byte_t   fTimeUpperFitRangeLoGain;
     72
     73  Byte_t   fFlags;
     74
     75  enum   { kUseLoGain, kFitOK };
    7276 
    73   Bool_t fUseLoGain;
    74   Bool_t fFitOK;
    75 
    7677  Double_t fOffset;
    7778  Double_t fSlope;
     
    8788 
    8889  // Setters
    89   void   SetPointInGraph(Float_t qhi, Float_t qlo);
    90   void   SetUseLoGain(Bool_t b = kTRUE)                { fUseLoGain = b; }
     90  void   SetUseLoGain(Bool_t b = kTRUE)
     91    { b ? SETBIT(fFlags, kUseLoGain) : SETBIT(fFlags, kUseLoGain); }
    9192
    9293  void SetTimeFitRangesHiGain(Byte_t low, Byte_t up) { fTimeLowerFitRangeHiGain = low,
     
    105106  const Double_t GetChargeSigma()    const { return fChargeSigma;   }
    106107  const Double_t GetChargeSigmaErr() const { return fChargeSigmaErr; }
    107   const Double_t GetArea()           const;
    108   const Double_t GetAreaErr()        const;
    109 
    110108  const Double_t GetChargeChiSquare() const { return fChargeChisquare; }
    111109  const Double_t GetChargeProb()      const { return fChargeProb;      } 
     
    124122  const Int_t    GetTimeNdf()         const { return fTimeNdf;       }   
    125123 
    126   const TH1I *GetHTime()                    { return fHTimeHiGain; }
    127   const TH1I *GetHTime()              const { return fHTimeHiGain; }
     124  const TH1F *GetHTime()                    { return fHTimeHiGain; }
     125  const TH1F *GetHTime()              const { return fHTimeHiGain; }
    128126 
    129127  const TH1I *GetHChargevsN()               { return fHChargevsNHiGain; }
     
    135133  Bool_t UseLoGain();
    136134
    137   Bool_t IsFitOK() { return fFitOK; }
    138   Bool_t IsEmpty();
     135  Bool_t IsFitOK()     const;   
     136  Bool_t IsUseLoGain() const;
     137  Bool_t IsEmpty()     const;
    139138 
    140139  // Fill histos
    141140  Bool_t FillChargeLoGain(Float_t q);
    142   Bool_t FillTimeLoGain(Int_t t);
     141  Bool_t FillTimeLoGain(Float_t t);
    143142  Bool_t FillChargevsNLoGain(Float_t q, Int_t n);
    144143
    145144  Bool_t FillChargeHiGain(Float_t q);
    146   Bool_t FillTimeHiGain(Int_t t);
     145  Bool_t FillTimeHiGain(Float_t t);
    147146  Bool_t FillChargevsNHiGain(Float_t q, Int_t n);
    148147
     148  Bool_t FillPointInGraph(Float_t qhi, Float_t qlo);
     149
     150  Bool_t SetupFill(const MParList *pList);
     151  Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; }
     152 
    149153  // Fits
    150154  Bool_t FitChargeHiGain(Option_t *option="RQ0"); 
     
    158162  // Draws
    159163  virtual void Draw(Option_t *option="");
    160 
     164  TObject *DrawClone(Option_t *option="") const;
     165 
    161166  // Prints
    162167  void PrintChargeFitResult();
Note: See TracChangeset for help on using the changeset viewer.