Ignore:
Timestamp:
06/14/08 16:55:58 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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//
Note: See TracChangeset for help on using the changeset viewer.