Changeset 7899 for trunk/MagicSoft


Ignore:
Timestamp:
08/21/06 17:53:30 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MMath.cc

    r7870 r7899  
    163163// ------------------------------------------------------------------------
    164164//
    165 // Return the median value of the distribution of abs(a[i]-Median)
     165// Return the "median" (at 68.3%) value of the distribution of
     166// abs(a[i]-Median)
    166167//
    167168template <class Size, class Element>
    168 Double_t MMath::MedianDevImp(Size n, const Element *a)
    169 {
     169Double_t MMath::MedianDevImp(Size n, const Element *a, Double_t &med)
     170{
     171    static const Double_t prob = 0.682689477208650697; //MMath::.GaissProb(1.0);
     172
    170173    // Sanity check
    171174    if (n <= 0 || !a)
     
    173176
    174177    // Get median of distribution
    175     const Double_t med = TMath::Median(n, a);
     178    med = TMath::Median(n, a);
    176179
    177180    // Create the abs(a[i]-med) distribution
     
    188191
    189192    // Define where to divide
    190     const Int_t div = TMath::Nint(n*MMath::GaussProb(1.0));
     193    const Int_t div = TMath::Nint(n*prob);
    191194
    192195    // Calculate result
     
    203206// ------------------------------------------------------------------------
    204207//
    205 // Return the median value of the distribution of abs(a[i]-Median)
    206 //
    207 Double_t MMath::MedianDev(Long64_t n, const Short_t *a)
    208 {
    209     return MedianDevImp(n, a);
    210 }
    211 
    212 // ------------------------------------------------------------------------
    213 //
    214 // Return the median value of the distribution of abs(a[i]-Median)
    215 //
    216 Double_t MMath::MedianDev(Long64_t n, const Int_t *a)
    217 {
    218     return MedianDevImp(n, a);
    219 }
    220 
    221 // ------------------------------------------------------------------------
    222 //
    223 // Return the median value of the distribution of abs(a[i]-Median)
    224 //
    225 Double_t MMath::MedianDev(Long64_t n, const Float_t *a)
    226 {
    227     return MedianDevImp(n, a);
    228 }
    229 
    230 // ------------------------------------------------------------------------
    231 //
    232 // Return the median value of the distribution of abs(a[i]-Median)
    233 //
    234 Double_t MMath::MedianDev(Long64_t n, const Double_t *a)
    235 {
    236     return MedianDevImp(n, a);
    237 }
    238 
    239 // ------------------------------------------------------------------------
    240 //
    241 // Return the median value of the distribution of abs(a[i]-Median)
    242 //
    243 Double_t MMath::MedianDev(Long64_t n, const Long_t *a)
    244 {
    245     return MedianDevImp(n, a);
    246 }
    247 
    248 // ------------------------------------------------------------------------
    249 //
    250 // Return the median value of the distribution of abs(a[i]-Median)
    251 //
    252 Double_t MMath::MedianDev(Long64_t n, const Long64_t *a)
    253 {
    254     return MedianDevImp(n, a);
    255 }
     208// Return the "median" (at 68.3%) value of the distribution of
     209// abs(a[i]-Median)
     210//
     211Double_t MMath::MedianDev(Long64_t n, const Short_t *a, Double_t &med)
     212{
     213    return MedianDevImp(n, a, med);
     214}
     215
     216// ------------------------------------------------------------------------
     217//
     218// Return the "median" (at 68.3%) value of the distribution of
     219// abs(a[i]-Median)
     220//
     221Double_t MMath::MedianDev(Long64_t n, const Int_t *a, Double_t &med)
     222{
     223    return MedianDevImp(n, a, med);
     224}
     225
     226// ------------------------------------------------------------------------
     227//
     228// Return the "median" (at 68.3%) value of the distribution of
     229// abs(a[i]-Median)
     230//
     231Double_t MMath::MedianDev(Long64_t n, const Float_t *a, Double_t &med)
     232{
     233    return MedianDevImp(n, a, med);
     234}
     235
     236// ------------------------------------------------------------------------
     237//
     238// Return the "median" (at 68.3%) value of the distribution of
     239// abs(a[i]-Median)
     240//
     241Double_t MMath::MedianDev(Long64_t n, const Double_t *a, Double_t &med)
     242{
     243    return MedianDevImp(n, a, med);
     244}
     245
     246// ------------------------------------------------------------------------
     247//
     248// Return the "median" (at 68.3%) value of the distribution of
     249// abs(a[i]-Median)
     250//
     251Double_t MMath::MedianDev(Long64_t n, const Long_t *a, Double_t &med)
     252{
     253    return MedianDevImp(n, a, med);
     254}
     255
     256// ------------------------------------------------------------------------
     257//
     258// Return the "median" (at 68.3%) value of the distribution of
     259// abs(a[i]-Median)
     260//
     261Double_t MMath::MedianDev(Long64_t n, const Long64_t *a, Double_t &med)
     262{
     263    return MedianDevImp(n, a, med);
     264}
     265
     266Double_t MMath::MedianDev(Long64_t n, const Short_t  *a) { Double_t med; return MedianDevImp(n, a, med); }
     267Double_t MMath::MedianDev(Long64_t n, const Int_t    *a) { Double_t med; return MedianDevImp(n, a, med); }
     268Double_t MMath::MedianDev(Long64_t n, const Float_t  *a) { Double_t med; return MedianDevImp(n, a, med); }
     269Double_t MMath::MedianDev(Long64_t n, const Double_t *a) { Double_t med; return MedianDevImp(n, a, med); }
     270Double_t MMath::MedianDev(Long64_t n, const Long_t   *a) { Double_t med; return MedianDevImp(n, a, med); }
     271Double_t MMath::MedianDev(Long64_t n, const Long64_t *a) { Double_t med; return MedianDevImp(n, a, med); }
    256272
    257273// --------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/mbase/MMath.h

    r7867 r7899  
    1919    Double_t GaussProb(Double_t x, Double_t sigma=1, Double_t mean=0);
    2020
    21     template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a);
     21    template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a) { Double_t med; return MedianDevImp(n, a, med); }
     22    template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a, Double_t &med);
     23    Double_t  MedianDev(Long64_t n, const Short_t  *a, Double_t &med);
     24    Double_t  MedianDev(Long64_t n, const Int_t    *a, Double_t &med);
     25    Double_t  MedianDev(Long64_t n, const Float_t  *a, Double_t &med);
     26    Double_t  MedianDev(Long64_t n, const Double_t *a, Double_t &med);
     27    Double_t  MedianDev(Long64_t n, const Long_t   *a, Double_t &med);
     28    Double_t  MedianDev(Long64_t n, const Long64_t *a, Double_t &med);
    2229    Double_t  MedianDev(Long64_t n, const Short_t  *a);
    2330    Double_t  MedianDev(Long64_t n, const Int_t    *a);
  • trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc

    r7692 r7899  
    350350{
    351351    TH2D *hyx=0;
    352     if (!(hyx=(TH2D*)gPad->FindObject(MString::Form("%s_%s", h.GetName(), how))))
     352    if (!(hyx=(TH2D*)gPad->FindObject(MString::Format("%s_%s", h.GetName(), how))))
    353353        return;
    354354
    355     TH2D *h2 = (TH2D*)h.Project3D(MString::Form("dum_%s", how));
     355    TH2D *h2 = (TH2D*)h.Project3D(MString::Format("dum_%s", how));
    356356    hyx->Reset();
    357357    hyx->Add(h2);
     
    359359
    360360    TH1D *hx = 0;
    361     if ((hx=(TH1D*)gPad->FindObject(Form("Prof%s", h.GetName()))))
     361    if ((hx=(TH1D*)gPad->FindObject(MString::Format("Prof%s", h.GetName()))))
    362362    {
    363363        hx = hyx->ProfileX(Form("Prof%s", h.GetName()), -1, 9999, "s");
Note: See TracChangeset for help on using the changeset viewer.