Changeset 8957 for trunk/MagicSoft/Mars/mhbase
- Timestamp:
- 06/14/08 16:55:58 (17 years ago)
- Location:
- trunk/MagicSoft/Mars/mhbase
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhbase/MBinning.h
r8679 r8957 94 94 Int_t GetNumBins() const { return fEdges.GetSize()-1; } 95 95 96 Double_t *GetEdges() const { return (Double_t*)fEdges.GetArray(); }96 const Double_t *GetEdges() const { return fEdges.GetArray(); } 97 97 const TArrayD &GetEdgesD() const { return fEdges; } 98 98 -
trunk/MagicSoft/Mars/mhbase/MH.cc
r8916 r8957 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.3 8 2008-06-02 17:21:24tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.39 2008-06-14 15:55:52 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 554 554 if (h->InheritsFrom(TH3::Class()) && x->InheritsFrom(TH3::Class())) 555 555 { 556 SetBinning((TH3*)h, ((TH1*)x)->GetXaxis(), ((TH1*)x)->GetYaxis(), ((TH1*)x)->GetZaxis());556 SetBinning((TH3*)h, x->GetXaxis(), x->GetYaxis(), x->GetZaxis()); 557 557 return; 558 558 } … … 561 561 if (h->InheritsFrom(TH2::Class()) && x->InheritsFrom(TH2::Class())) 562 562 { 563 SetBinning((TH2*)h, ((TH1*)x)->GetXaxis(), ((TH1*)x)->GetYaxis());563 SetBinning((TH2*)h, x->GetXaxis(), x->GetYaxis()); 564 564 return; 565 565 } … … 568 568 if (h->InheritsFrom(TH1::Class()) && x->InheritsFrom(TH1::Class())) 569 569 { 570 SetBinning(h, ((TH1*)x)->GetXaxis());570 SetBinning(h, x->GetXaxis()); 571 571 return; 572 572 } … … 869 869 // Draw first histogram 870 870 // 871 TH1 *h1 = ((TH1&)hist1).DrawCopy();871 TH1 *h1 = hist1.DrawCopy(); 872 872 gPad->SetBorderMode(0); 873 873 gPad->Update(); … … 921 921 // Draw second histogram 922 922 // 923 TH1 *h2 = ((TH1&)hist2).DrawCopy("sames");923 TH1 *h2 = hist2.DrawCopy("sames"); 924 924 gPad->Update(); 925 925 … … 1208 1208 } 1209 1209 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 axis1217 // ranging from firstybin to lastybin included.1218 // By default, bins 1 to ny are included1219 // When all bins are included, the number of entries in the projection1220 // is set to the number of entries of the 2-D histogram, otherwise1221 // 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 histogram1239 const Bool_t computeErrors = dest.GetSumw2N() ? 1 : 0;1240 1241 // Fill the projected histogram1242 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 axis1267 // ranging from firstybin to lastybin included.1268 // By default, bins 1 to ny are included1269 // When all bins are included, the number of entries in the projection1270 // is set to the number of entries of the 2-D histogram, otherwise1271 // 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 histogram1289 const Bool_t computeErrors = dest.GetSumw2N() ? 1 : 0;1290 1291 // Fill the projected histogram1292 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 1310 1210 // -------------------------------------------------------------------------- 1311 1211 // -
trunk/MagicSoft/Mars/mhbase/MH.h
r8892 r8957 119 119 const char* name="ProjectArray", const char* title="Projected Array"); 120 120 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 124 121 static void GetRangeUser(const TH1 &hist, Axis_t &lo, Axis_t &hi); 125 122 static void GetRangeUserX(const TH1 &hist, Axis_t &lo, Axis_t &hi); -
trunk/MagicSoft/Mars/mhbase/MHMatrix.cc
r8907 r8957 783 783 784 784 th1->cd(1); 785 ((TH1&)hth).DrawCopy(); // real histogram before785 hth.DrawCopy(); // real histogram before 786 786 787 787 th1->cd(2); 788 ((TH1&)hta).DrawCopy(); // histogram after788 hta.DrawCopy(); // histogram after 789 789 790 790 th1->cd(3); 791 ((TH1&)hthd).DrawCopy(); // correction factors791 hthd.DrawCopy(); // correction factors 792 792 793 793 th1->cd(4); 794 ((TH1&)thsh).DrawCopy(); // target794 thsh.DrawCopy(); // target 795 795 } 796 796 … … 895 895 SetBinning(&hthd, &thsh); 896 896 hthd.SetDirectory(NULL); 897 hthd.Divide( (TH1F*)&thsh, &hth, 1, 1);897 hthd.Divide(&thsh, &hth, 1, 1); 898 898 899 899 if (hthd.GetMaximum() <= 0) -
trunk/MagicSoft/Mars/mhbase/MHn.cc
r8893 r8957 584 584 for (int i=0; i<fNum; i++) 585 585 { 586 TString opt(fDrawOption[i]);586 TString dopt(fDrawOption[i]); 587 587 if (same) 588 opt += " same";588 dopt += " same"; 589 589 590 590 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.