Ignore:
Timestamp:
06/14/08 16:55:58 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhbase
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhbase/MBinning.h

    r8679 r8957  
    9494    Int_t GetNumBins() const   { return fEdges.GetSize()-1; }
    9595
    96     Double_t *GetEdges() const { return (Double_t*)fEdges.GetArray(); }
     96    const Double_t *GetEdges() const { return fEdges.GetArray(); }
    9797    const TArrayD &GetEdgesD() const { return fEdges; }
    9898
  • trunk/MagicSoft/Mars/mhbase/MH.cc

    r8916 r8957  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.38 2008-06-02 17:21:24 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.39 2008-06-14 15:55:52 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    554554    if (h->InheritsFrom(TH3::Class()) && x->InheritsFrom(TH3::Class()))
    555555    {
    556         SetBinning((TH3*)h, ((TH1*)x)->GetXaxis(), ((TH1*)x)->GetYaxis(), ((TH1*)x)->GetZaxis());
     556        SetBinning((TH3*)h, x->GetXaxis(), x->GetYaxis(), x->GetZaxis());
    557557        return;
    558558    }
     
    561561    if (h->InheritsFrom(TH2::Class()) && x->InheritsFrom(TH2::Class()))
    562562    {
    563         SetBinning((TH2*)h, ((TH1*)x)->GetXaxis(), ((TH1*)x)->GetYaxis());
     563        SetBinning((TH2*)h, x->GetXaxis(), x->GetYaxis());
    564564        return;
    565565    }
     
    568568    if (h->InheritsFrom(TH1::Class()) && x->InheritsFrom(TH1::Class()))
    569569    {
    570         SetBinning(h, ((TH1*)x)->GetXaxis());
     570        SetBinning(h, x->GetXaxis());
    571571        return;
    572572    }
     
    869869    // Draw first histogram
    870870    //
    871     TH1 *h1 = ((TH1&)hist1).DrawCopy();
     871    TH1 *h1 = hist1.DrawCopy();
    872872    gPad->SetBorderMode(0);
    873873    gPad->Update();
     
    921921    // Draw second histogram
    922922    //
    923     TH1 *h2 = ((TH1&)hist2).DrawCopy("sames");
     923    TH1 *h2 = hist2.DrawCopy("sames");
    924924    gPad->Update();
    925925
     
    12081208}
    12091209
    1210 void MH::ProjectionX(TH1D &dest, const TH2 &src, Int_t firstybin, Int_t lastybin)
    1211 {
    1212     //*-*-*-*-*Project a 2-D histogram into a 1-D histogram along X*-*-*-*-*-*-*
    1213     //*-*      ====================================================
    1214     //
    1215     //   The projection dest is always of the type TH1D.
    1216     //   The projection is made from the channels along the Y axis
    1217     //   ranging from firstybin to lastybin included.
    1218     //   By default, bins 1 to ny are included
    1219     //   When all bins are included, the number of entries in the projection
    1220     //   is set to the number of entries of the 2-D histogram, otherwise
    1221     //   the number of entries is incremented by 1 for all non empty cells.
    1222     //
    1223     //   if Sumw2() was called for dest, the errors are computed.
    1224     //
    1225     TAxis &axex = *((TH2&)src).GetXaxis();
    1226     TAxis &axey = *((TH2&)src).GetYaxis();
    1227 
    1228     const Int_t nx = axex.GetNbins();
    1229     const Int_t ny = axey.GetNbins();
    1230     if (firstybin < 0)
    1231         firstybin = 1;
    1232     if (lastybin > ny)
    1233         lastybin = ny;
    1234 
    1235     dest.Reset();
    1236     SetBinning(&dest, &axex);
    1237 
    1238     // Create the projection histogram
    1239     const Bool_t computeErrors = dest.GetSumw2N() ? 1 : 0;
    1240 
    1241     // Fill the projected histogram
    1242     for (Int_t binx=0; binx<=nx+1; binx++)
    1243     {
    1244         Double_t err2 = 0;
    1245         for (Int_t biny=firstybin; biny<=lastybin; biny++)
    1246         {
    1247             const Double_t cont = src.GetCellContent(binx,biny);
    1248             const Double_t err1 = src.GetCellError(binx,biny);
    1249             err2 += err1*err1;
    1250             if (cont)
    1251                 dest.Fill(axex.GetBinCenter(binx), cont);
    1252         }
    1253         if (computeErrors)
    1254             dest.SetBinError(binx, TMath::Sqrt(err2));
    1255     }
    1256     if (firstybin <=1 && lastybin >= ny)
    1257         dest.SetEntries(src.GetEntries());
    1258 }
    1259 
    1260 void MH::ProjectionY(TH1D &dest, const TH2 &src, Int_t firstxbin, Int_t lastxbin)
    1261 {
    1262     //*-*-*-*-*Project a 2-D histogram into a 1-D histogram along X*-*-*-*-*-*-*
    1263     //*-*      ====================================================
    1264     //
    1265     //   The projection dest is always of the type TH1D.
    1266     //   The projection is made from the channels along the Y axis
    1267     //   ranging from firstybin to lastybin included.
    1268     //   By default, bins 1 to ny are included
    1269     //   When all bins are included, the number of entries in the projection
    1270     //   is set to the number of entries of the 2-D histogram, otherwise
    1271     //   the number of entries is incremented by 1 for all non empty cells.
    1272     //
    1273     //   if Sumw2() was called for dest, the errors are computed.
    1274     //
    1275     TAxis &axex = *((TH2&)src).GetXaxis();
    1276     TAxis &axey = *((TH2&)src).GetYaxis();
    1277 
    1278     const Int_t nx = axex.GetNbins();
    1279     const Int_t ny = axey.GetNbins();
    1280     if (firstxbin < 0)
    1281         firstxbin = 1;
    1282     if (lastxbin > nx)
    1283         lastxbin = nx;
    1284 
    1285     dest.Reset();
    1286     SetBinning(&dest, &axey);
    1287 
    1288     // Create the projection histogram
    1289     const Bool_t computeErrors = dest.GetSumw2N() ? 1 : 0;
    1290 
    1291     // Fill the projected histogram
    1292     for (Int_t biny=0; biny<=ny+1; biny++)
    1293     {
    1294         Double_t err2 = 0;
    1295         for (Int_t binx=firstxbin; binx<=lastxbin; binx++)
    1296         {
    1297             const Double_t cont = src.GetCellContent(binx,biny);
    1298             const Double_t err1 = src.GetCellError(binx,biny);
    1299             err2 += err1*err1;
    1300             if (cont)
    1301                 dest.Fill(axey.GetBinCenter(biny), cont);
    1302         }
    1303         if (computeErrors)
    1304             dest.SetBinError(biny, TMath::Sqrt(err2));
    1305     }
    1306     if (firstxbin <=1 && lastxbin >= nx)
    1307         dest.SetEntries(src.GetEntries());
    1308 }
    1309 
    13101210// --------------------------------------------------------------------------
    13111211//
  • trunk/MagicSoft/Mars/mhbase/MH.h

    r8892 r8957  
    119119                              const char* name="ProjectArray", const char* title="Projected Array");
    120120   
    121     static void ProjectionX(TH1D &dest, const TH2 &src, Int_t firstybin=-1, Int_t lastybin=9999);
    122     static void ProjectionY(TH1D &dest, const TH2 &src, Int_t firstxbin=-1, Int_t lastxbin=9999);
    123 
    124121    static void GetRangeUser(const TH1 &hist, Axis_t &lo, Axis_t &hi);
    125122    static void GetRangeUserX(const TH1 &hist, Axis_t &lo, Axis_t &hi);
  • trunk/MagicSoft/Mars/mhbase/MHMatrix.cc

    r8907 r8957  
    783783
    784784    th1->cd(1);
    785     ((TH1&)hth).DrawCopy();   // real histogram before
     785    hth.DrawCopy();   // real histogram before
    786786
    787787    th1->cd(2);
    788     ((TH1&)hta).DrawCopy();   // histogram after
     788    hta.DrawCopy();   // histogram after
    789789
    790790    th1->cd(3);
    791     ((TH1&)hthd).DrawCopy();  // correction factors
     791    hthd.DrawCopy();  // correction factors
    792792
    793793    th1->cd(4);
    794     ((TH1&)thsh).DrawCopy();  // target
     794    thsh.DrawCopy();  // target
    795795}
    796796
     
    895895    SetBinning(&hthd, &thsh);
    896896    hthd.SetDirectory(NULL);
    897     hthd.Divide((TH1F*)&thsh, &hth, 1, 1);
     897    hthd.Divide(&thsh, &hth, 1, 1);
    898898
    899899    if (hthd.GetMaximum() <= 0)
  • trunk/MagicSoft/Mars/mhbase/MHn.cc

    r8893 r8957  
    584584    for (int i=0; i<fNum; i++)
    585585    {
    586         TString opt(fDrawOption[i]);
     586        TString dopt(fDrawOption[i]);
    587587        if (same)
    588             opt += " same";
     588            dopt += " same";
    589589
    590590        pad->cd(i+1);
    591         fHist[i]->Draw(opt);
    592     }
    593 }
     591        fHist[i]->Draw(dopt);
     592    }
     593}
Note: See TracChangeset for help on using the changeset viewer.