Changeset 8957 for trunk/MagicSoft/Mars/mhbase/MH.cc
- Timestamp:
- 06/14/08 16:55:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 //
Note:
See TracChangeset
for help on using the changeset viewer.