Changeset 3675 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
04/06/04 21:58:48 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3672 r3675  
    164164   * mcalib/MCalibrationChargePINDiode.[h,cc]
    165165     - add Getters to the relative variance
     166
     167   * mcalib/MHGausEvents.[h,cc]
     168     - add to Pickup also Blackout events
    166169
    167170
  • trunk/MagicSoft/Mars/mcalib/MHGausEvents.cc

    r3641 r3675  
    5050//       Accordingly, a flag IsGausFitOK() is set.
    5151//     - One can repeat the fit within a given amount of sigmas from the previous mean
    52 //       (specified by the variable fPickupLimit) with the function RepeatFit()
     52//       (specified by the variables fPickupLimit and fBlackoutLimit) with the function RepeatFit()
    5353//     - One can completely skip the fitting to set mean, sigma and its errors directly
    5454//       from the histograms with the function BypassFit()
     
    9999using namespace std;
    100100
    101 const Float_t  MHGausEvents::fgProbLimit            = 0.001;
     101const Int_t    MHGausEvents::fgBinsAfterStripping   = 40;
     102const Float_t  MHGausEvents::fgBlackoutLimit        = 5.;
    102103const Int_t    MHGausEvents::fgNDFLimit             = 2;
    103104const Float_t  MHGausEvents::fgPickupLimit          = 5.;
     105const Float_t  MHGausEvents::fgProbLimit            = 0.001;
    104106const Int_t    MHGausEvents::fgPowerProbabilityBins = 20;
    105 const Int_t    MHGausEvents::fgBinsAfterStripping   = 40;
    106107// --------------------------------------------------------------------------
    107108//
     
    110111// - the default Probability Bins for fPowerProbabilityBins (fgPowerProbabilityBins)
    111112// - the default Probability Limit for fProbLimit  (fgProbLimit)
    112 // - the default NDF Limit for fNDFLimit  (fgNDFLimit)
    113 // - the default number for fPickupLimit  (fgPickupLimit)
     113// - the default NDF Limit for fNDFLimit           (fgNDFLimit)
     114// - the default number for fPickupLimit           (fgPickupLimit)
     115// - the default number for fBlackoutLimit         (fgBlackoutLimit)
    114116// - the default number of bins after stripping for fBinsAfterStipping (fgBinsAfterStipping)
    115 // - the default name of the fHGausHist   ("HGausHist")
    116 // - the default title of the fHGausHist  ("Histogram of Events with Gaussian Distribution")
    117 // - the default directory of the fHGausHist (NULL)
     117// - the default name of the fHGausHist            ("HGausHist")
     118// - the default title of the fHGausHist           ("Histogram of Events with Gaussian Distribution")
     119// - the default directory of the fHGausHist       (NULL)
    118120// - the default for fNbins (100)
    119121// - the default for fFirst (0.)
     
    141143  Clear();
    142144 
     145  SetBinsAfterStripping();
     146  SetBlackoutLimit();
     147  SetNDFLimit();
     148  SetPickupLimit();
    143149  SetPowerProbabilityBins();
    144150  SetProbLimit();
    145   SetNDFLimit();
    146   SetPickupLimit();
    147   SetBinsAfterStripping();
    148151
    149152  fHGausHist.SetName("HGausHist");
     
    614617// Repeats the Gauss fit in a smaller range, defined by:
    615618//
    616 // min = GetMean() - fPickupLimit * GetSigma();
    617 // max = GetMean() + fPickupLimit * GetSigma();
     619// min = GetMean() - fBlackoutLimit * GetSigma();
     620// max = GetMean() + fPickupLimit   * GetSigma();
    618621//
    619622// The fit results are retrieved and stored in class-own variables. 
     
    635638  // Get new fitting ranges
    636639  //
    637   Axis_t rmin = fMean - fPickupLimit * fSigma;
    638   Axis_t rmax = fMean + fPickupLimit * fSigma;
     640  Axis_t rmin = fMean - fBlackoutLimit * fSigma;
     641  Axis_t rmax = fMean + fPickupLimit   * fSigma;
    639642
    640643  Axis_t hmin = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetFirst());
     
    937940}
    938941
    939 
     942const Double_t MHGausEvents::GetBlackout() const
     943{
     944 
     945  if ((fMean == 0.) && (fSigma == 0.))
     946    return -1.;
     947
     948  const Int_t first = fHGausHist.GetXaxis()->GetFirst();
     949  const Int_t last  = fHGausHist.GetXaxis()->FindBin(fMean-fBlackoutLimit*fSigma);
     950
     951  if (first >= last)
     952    return 0.;
     953 
     954  return fHGausHist.Integral(first, last, "width");
     955}
     956
     957
  • trunk/MagicSoft/Mars/mcalib/MHGausEvents.h

    r3641 r3675  
    2020private:
    2121
    22   const static Float_t  fgProbLimit;            //! Default for fProbLimit (now set to: 0.001)
    23   const static Int_t    fgNDFLimit;             //! Default for fNDFLimit  (now set to: 2)
    24   const static Float_t  fgPickupLimit;          //! Default for fPickupLimit (now set to: 5. )
     22  const static Int_t    fgBinsAfterStripping;   //! Default for fBinsAfterStripping   (now set to: 40)
     23  const static Float_t  fgBlackoutLimit;        //! Default for fBlackoutLimit        (now set to: 5. )
     24  const static Int_t    fgNDFLimit;             //! Default for fNDFLimit             (now set to: 2)
     25  const static Float_t  fgProbLimit;            //! Default for fProbLimit            (now set to: 0.001)
     26  const static Float_t  fgPickupLimit;          //! Default for fPickupLimit          (now set to: 5. )
    2527  const static Int_t    fgPowerProbabilityBins; //! Default for fPowerProbabilityBins (now set to: 20)
    26   const static Int_t    fgBinsAfterStripping;   //! Default for fBinsAfterStripping (now set to: 40)
    2728 
     29  Int_t    fBinsAfterStripping;        // Bins for the Gauss Histogram after stripping off the zeros at both ends
     30  Int_t    fCurrentSize;               // Current size of the array fEvents
     31  Float_t  fEventFrequency;            // Event frequency in Hertz (to be set)
     32  Byte_t   fFlags;                     // Bit field for the fit result bits
    2833  Int_t    fPowerProbabilityBins;      // Bins for the projected power spectrum
    29   Int_t    fBinsAfterStripping;        // Bins for the Gauss Histogram after stripping off the zeros at both ends
    30   Float_t  fEventFrequency;            // Event frequency in Hertz (to be set)
    3134 
    3235  TH1I    *fHPowerProbability;         // Fourier transform of fEvents projected on y-axis
    3336  TArrayF *fPowerSpectrum;             // Fourier transform of fEvents
    34 
    3537  TGraph  *fGraphEvents;               //! TGraph to display the event array (will not be cloned!!)
    3638  TGraph  *fGraphPowerSpectrum;        //! TGraph to display the power spectrum array (will not be cloned!!)
    3739
    38 
    39   enum { kGausFitOK, kExpFitOK, kFourierSpectrumOK,
    40          kExcluded };                  //  Bits to hold information about fit results
     40  enum { kGausFitOK, kExpFitOK, kFourierSpectrumOK, kExcluded }; // Bits for information about fit results
    4141 
    42   Byte_t fFlags;                       //  Byte to hold the bits fit result bits
    43  
    44   Int_t fCurrentSize;                  //  Current size of the array fEvents
    45 
    4642protected:
    4743
    48   Double_t fMean;                      // Mean of the Gauss fit
    49   Double_t fSigma;                     // Sigma of the Gauss fit
    50   Double_t fMeanErr;                   // Error of the mean of the Gauss fit
    51   Double_t fSigmaErr;                  // Error of the sigma of the Gauss fit
    52   Double_t fProb;                      // Probability of the Gauss fit
    53 
    54   Int_t   fNbins;                      // Number histogram bins for fHGausHist (used by InitBins())
    55   Axis_t  fFirst;                      // Lower histogram edge  for fHGausHist (used by InitBins())
    56   Axis_t  fLast;                       // Upper histogram edge  for fHGausHist (used by InitBins())
    57   Int_t   fPixId;                      // Pixel ID
    58  
    59   TH1F    fHGausHist;                  // Histogram which should hold the Gaussian distribution
    60   TArrayF fEvents;                     // Array which holds the entries of GausHist
    61 
     44  Float_t  fBlackoutLimit;             // Lower number sigmas from mean until event is considered blackout
     45  TArrayF  fEvents;                    // Array which holds the entries of GausHist
    6246  TF1     *fFGausFit;                  // Gauss fit for fHGausHist
    6347  TF1     *fFExpFit;                   // Exponential fit for FHPowerProbability
    64  
     48  Axis_t   fFirst;                     // Lower histogram edge  for fHGausHist (used by InitBins())
     49  TH1F     fHGausHist;                 // Histogram to hold the Gaussian distribution
     50  Axis_t   fLast;                      // Upper histogram edge  for fHGausHist (used by InitBins())
     51  Double_t fMean;                      // Mean of the Gauss fit
     52  Double_t fMeanErr;                   // Error of the mean of the Gauss fit
     53  Int_t    fNbins;                     // Number histogram bins for fHGausHist (used by InitBins())
     54  Int_t    fNDFLimit;                  // NDF limit for judgement if fit is OK
     55  Double_t fSigma;                     // Sigma of the Gauss fit
     56  Double_t fSigmaErr;                  // Error of the sigma of the Gauss fit
     57  Float_t  fPickupLimit;               // Upper number sigmas from mean until event is considered pickup
     58  Int_t    fPixId;                     // Pixel ID
     59  Double_t fProb;                      // Probability of the Gauss fit
    6560  Float_t  fProbLimit;                 // Probability limit for judgement if fit is OK
    66   Int_t    fNDFLimit;                  // NDF limit for judgement if fit is OK
    67   Float_t  fPickupLimit;               // Upper number of sigmas from the mean until events are considered as pickup
    6861
    6962  Float_t *CreateEventXaxis(Int_t n);  // Create an x-axis for the Event TGraphs
     
    7467
    7568  // Setters
    76   void  SetPowerProbabilityBins ( const Int_t nbins=fgPowerProbabilityBins ) { fPowerProbabilityBins = nbins; }
    77   void  SetBinsAfterStripping   ( const Int_t nbins=fgBinsAfterStripping   ) { fBinsAfterStripping   = nbins; }
     69  void  SetPowerProbabilityBins ( const Int_t nbins=fgPowerProbabilityBins ) { fPowerProbabilityBins=nbins; }
     70  void  SetBinsAfterStripping   ( const Int_t nbins=fgBinsAfterStripping   ) { fBinsAfterStripping  =nbins; }
    7871
    7972 public:
     
    8780 
    8881  // Setters
    89   void  SetEventFrequency(const Float_t f)   { fEventFrequency = f; }
    90 
    91   void  SetMean    ( const Double_t d )   { fMean     = d;   }
    92   void  SetMeanErr ( const Double_t d )   { fMeanErr  = d;   }
    93   void  SetSigma   ( const Double_t d )   { fSigma    = d;   }
    94   void  SetSigmaErr( const Double_t d )   { fSigmaErr = d;   }
    95   void  SetProb    ( const Double_t d )   { fProb     = d;   }
    96   void  SetPixId   ( const Int_t i    )   { fPixId    = i;   }
    97 
    98   void  SetNbins   ( const Int_t i    )   { fNbins    = i;   } 
    99   void  SetFirst   ( const Double_t d )   { fFirst    = d;   }
    100   void  SetLast    ( const Double_t d )   { fLast     = d;   }
    101  
    102   void  SetNDFLimit    ( const Int_t   lim=fgNDFLimit    ) { fNDFLimit    = lim; } 
    103   void  SetPickupLimit ( const Float_t lim=fgPickupLimit ) { fPickupLimit = lim; }
    104   void  SetProbLimit   ( const Float_t lim=fgProbLimit   ) { fProbLimit   = lim; }
    105 
    106   // Setters ONLY for MC:
    107   void  SetGausFitOK(         const Bool_t b=kTRUE );
    108   void  SetExpFitOK(          const Bool_t b=kTRUE );
    109   void  SetFourierSpectrumOK( const Bool_t b=kTRUE );
    110   void  SetExcluded         ( const Bool_t b=kTRUE ); 
     82  void  SetBlackoutLimit    ( const Float_t  lim=fgBlackoutLimit ) { fBlackoutLimit  = lim; }
     83  void  SetEventFrequency   ( const Float_t  f                   ) { fEventFrequency = f;   }
     84  void  SetExcluded         ( const Bool_t   b=kTRUE             ); 
     85  void  SetExpFitOK         ( const Bool_t   b=kTRUE             );
     86  void  SetFourierSpectrumOK( const Bool_t   b=kTRUE             );
     87  void  SetGausFitOK        ( const Bool_t   b=kTRUE             );
     88  void  SetLast             ( const Double_t d                   ) { fLast           = d;   }
     89  void  SetFirst            ( const Double_t d                   ) { fFirst          = d;   }
     90  void  SetMean             ( const Double_t d                   ) { fMean           = d;   }
     91  void  SetMeanErr          ( const Double_t d                   ) { fMeanErr        = d;   }
     92  void  SetNbins            ( const Int_t    i                   ) { fNbins          = i;   } 
     93  void  SetNDFLimit         ( const Int_t    lim=fgNDFLimit      ) { fNDFLimit       = lim; } 
     94  void  SetPickupLimit      ( const Float_t  lim=fgPickupLimit   ) { fPickupLimit    = lim; }
     95  void  SetPixId            ( const Int_t    i                   ) { fPixId          = i;   }
     96  void  SetProb             ( const Double_t d                   ) { fProb           = d;   }
     97  void  SetProbLimit        ( const Float_t  lim=fgProbLimit     ) { fProbLimit      = lim; }
     98  void  SetSigma            ( const Double_t d                   ) { fSigma          = d;   }
     99  void  SetSigmaErr         ( const Double_t d                   ) { fSigmaErr       = d;   }
    111100
    112101  // Getters
    113   const Double_t GetMean()          const { return fMean;      }
    114   const Double_t GetMeanErr()       const { return fMeanErr;   }
    115   const Double_t GetSigma()         const { return fSigma;     }
    116   const Double_t GetSigmaErr()      const { return fSigmaErr;  }
    117   const Double_t GetChiSquare()     const;
    118   const Double_t GetProb()          const { return fProb;      }
    119   const Int_t    GetNdf()           const;
    120   const Double_t GetPickup()        const;
    121   const Int_t    GetPixId()         const { return fPixId;     }
     102  const Double_t GetBlackout()           const; 
     103  const Double_t GetChiSquare()          const;
     104  const Double_t GetExpChiSquare()       const;
     105  const Int_t    GetExpNdf()             const;
     106  const Double_t GetExpProb()            const;
     107        TArrayF *GetEvents()                   { return &fEvents;            } 
     108  const TArrayF *GetEvents()             const { return &fEvents;            }
     109        TF1     *GetFExpFit()                  { return fFExpFit;            }
     110  const TF1     *GetFExpFit()            const { return fFExpFit;            }
     111        TF1     *GetFGausFit()                 { return fFGausFit;           }
     112  const TF1     *GetFGausFit()           const { return fFGausFit;           }
     113        TGraph  *GetGraphEvents()              { return fGraphEvents;        }
     114  const TGraph  *GetGraphEvents()        const { return fGraphEvents;        }
     115        TGraph  *GetGraphPowerSpectrum()       { return fGraphPowerSpectrum; }
     116  const TGraph  *GetGraphPowerSpectrum() const { return fGraphPowerSpectrum; }
     117        TH1F    *GetHGausHist()                { return &fHGausHist;         }
     118  const TH1F    *GetHGausHist()          const { return &fHGausHist;         }
     119        TH1I    *GetHPowerProbability()        { return fHPowerProbability;  }
     120  const TH1I    *GetHPowerProbability()  const { return fHPowerProbability;  }
     121  const Double_t GetMean()               const { return fMean;               }
     122  const Double_t GetMeanErr()            const { return fMeanErr;            }
     123  const Int_t    GetNdf()                const;
     124  const Double_t GetOffset()             const;
     125  const Double_t GetPickup()             const;
     126  const Int_t    GetPixId()              const { return fPixId;              }
     127        TArrayF *GetPowerSpectrum()            { return fPowerSpectrum;      } 
     128  const TArrayF *GetPowerSpectrum()      const { return fPowerSpectrum;      }
     129  const Double_t GetProb()               const { return fProb;               }
     130  const Double_t GetSigma()              const { return fSigma;              }
     131  const Double_t GetSigmaErr()           const { return fSigmaErr;           }
     132  const Double_t GetSlope()              const;
    122133
    123   const Double_t GetSlope()        const;
    124   const Double_t GetOffset()       const;
    125   const Double_t GetExpChiSquare() const;
    126   const Double_t GetExpProb()      const;
    127   const Int_t    GetExpNdf()       const;
    128 
    129   TH1F *GetHGausHist()                     { return &fHGausHist;     }
    130   const TH1F *GetHGausHist()         const { return &fHGausHist;     }
    131 
    132   TArrayF *GetEvents()                     { return &fEvents;        } 
    133   const TArrayF *GetEvents()         const { return &fEvents;        }
    134  
    135   TArrayF *GetPowerSpectrum()              { return fPowerSpectrum;  } 
    136   const TArrayF *GetPowerSpectrum()  const { return fPowerSpectrum;  }
    137  
    138   TF1 *GetFGausFit()                       { return fFGausFit;       }
    139   const TF1 *GetFGausFit()           const { return fFGausFit;       }
    140 
    141   TH1I *GetHPowerProbability()             { return fHPowerProbability; }
    142   const TH1I *GetHPowerProbability() const { return fHPowerProbability; }
    143 
    144   TF1 *GetFExpFit()                        { return fFExpFit;        }
    145   const TF1 *GetFExpFit()            const { return fFExpFit;        }
    146 
    147   TGraph *GetGraphEvents()                 { return fGraphEvents;    }
    148   const TGraph *GetGraphEvents()     const { return fGraphEvents;    }
    149  
    150   TGraph *GetGraphPowerSpectrum()             { return fGraphPowerSpectrum;  }
    151   const TGraph *GetGraphPowerSpectrum() const { return fGraphPowerSpectrum;  }
    152  
    153   const Bool_t IsGausFitOK()          const;
    154   const Bool_t IsExpFitOK()           const;
    155   const Bool_t IsEmpty()              const;
    156   const Bool_t IsFourierSpectrumOK()  const;
    157   const Bool_t IsExcluded         ()  const;
     134  const Bool_t IsExcluded()              const;
     135  const Bool_t IsExpFitOK()              const;
     136  const Bool_t IsEmpty()                 const;
     137  const Bool_t IsFourierSpectrumOK()     const;
     138  const Bool_t IsGausFitOK()             const;
    158139
    159140  // Fill
    160   void FillArray(const Float_t f);            // Fill only the array fEvents
    161   Bool_t FillHist(const Float_t f);           // Fill only the histogram HGausHist
    162   Bool_t FillHistAndArray(const Float_t f);   // Fill bothe the array fEvents and the histogram HGausHist
     141  void   FillArray       ( const Float_t f );     // Fill only the array fEvents
     142  Bool_t FillHist        ( const Float_t f );     // Fill only the histogram HGausHist
     143  Bool_t FillHistAndArray( const Float_t f );     // Fill bothe the array fEvents and the histogram HGausHist
    163144 
    164145  // Fits
    165   Bool_t FitGaus(Option_t *option="RQ0",
    166                  const Double_t xmin=0.,
    167                  const Double_t xmax=0.);         // Fit the histogram HGausHist with a Gaussian
     146  Bool_t FitGaus(  Option_t *option="RQ0",
     147                   const Double_t xmin=0.,
     148                   const Double_t xmax=0.);       // Fit the histogram HGausHist with a Gaussian
    168149  Bool_t RepeatFit(const Option_t *option="RQ0"); // Repeat fit within limits defined by fPickupLimit
    169150  void BypassFit();                               // Take mean and RMS from the histogram
     
    176157 
    177158  // Miscelleaneous
    178   virtual void ChangeHistId(const Int_t id); // Changes names and titles of the histogram
    179   virtual void Renorm();                     // Re-normalize the results
     159  virtual void ChangeHistId(const Int_t id);      // Changes names and titles of the histogram
     160  virtual void Renorm();                          // Re-normalize the results
    180161 
    181   void CreateFourierSpectrum();              // Create the fourier spectrum out of fEvents
    182   void CreateGraphEvents();                  // Create the TGraph fGraphEvents of fEvents
    183   void CreateGraphPowerSpectrum();           // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
     162  void CreateFourierSpectrum();                   // Create the fourier spectrum out of fEvents
     163  void CreateGraphEvents();                       // Create the TGraph fGraphEvents of fEvents
     164  void CreateGraphPowerSpectrum();                // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
    184165 
    185166  ClassDef(MHGausEvents, 1) // Base class for events with Gaussian distributed values
Note: See TracChangeset for help on using the changeset viewer.