Changeset 1463 for trunk/MagicSoft/Mars/mhist/MH.cc
- Timestamp:
- 07/31/02 18:03:51 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MH.cc
r1449 r1463 56 56 57 57 #include "MLog.h" 58 #include "MLogManip.h" 59 60 #include "MParList.h" 61 #include "MParContainer.h" 58 62 59 63 #include "MBinning.h" … … 228 232 } 229 233 230 void MH::SetBinning(TH1 *h, const TArrayD *binsx)234 void MH::SetBinning(TH1 *h, const TArrayD &binsx) 231 235 { 232 236 MBinning bx; 233 bx.SetEdges( *binsx);237 bx.SetEdges(binsx); 234 238 SetBinning(h, &bx); 235 239 } 236 240 237 void MH::SetBinning(TH2 *h, const TArrayD *binsx, const TArrayD *binsy)241 void MH::SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy) 238 242 { 239 243 MBinning bx; 240 244 MBinning by; 241 bx.SetEdges( *binsx);242 by.SetEdges( *binsy);245 bx.SetEdges(binsx); 246 by.SetEdges(binsy); 243 247 SetBinning(h, &bx, &by); 244 248 } 245 249 246 void MH::SetBinning(TH3 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz)250 void MH::SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz) 247 251 { 248 252 MBinning bx; 249 253 MBinning by; 250 254 MBinning bz; 251 bx.SetEdges( *binsx);252 by.SetEdges( *binsy);253 bz.SetEdges( *binsz);255 bx.SetEdges(binsx); 256 by.SetEdges(binsy); 257 bz.SetEdges(binsz); 254 258 SetBinning(h, &bx, &by, &bz); 255 259 } … … 263 267 bx[nx] = binsx->GetXmax(); 264 268 265 SetBinning(h, &bx);269 SetBinning(h, bx); 266 270 } 267 271 … … 278 282 by[ny] = binsy->GetXmax(); 279 283 280 SetBinning(h, &bx, &by);284 SetBinning(h, bx, by); 281 285 } 282 286 … … 297 301 bz[nz] = binsz->GetXmax(); 298 302 299 SetBinning(h, &bx, &by, &bz);303 SetBinning(h, bx, by, bz); 300 304 } 301 305 … … 319 323 } 320 324 321 void MH::ScaleA xis(TArrayD &bins, Double_t f)325 void MH::ScaleArray(TArrayD &bins, Double_t f) 322 326 { 323 327 for (int i=0; i<bins.GetSize(); i++) … … 325 329 } 326 330 331 TArrayD MH::ScaleAxis(TAxis &axe, Double_t f) 332 { 333 TArrayD arr(axe.GetNbins()+1); 334 335 for (int i=1; i<=axe.GetNbins()+1; i++) 336 arr[i-1] = axe.GetBinLowEdge(i); 337 338 ScaleArray(arr, f); 339 340 return arr; 341 } 342 327 343 void MH::ScaleAxis(TH1 *h, Double_t fx, Double_t fy, Double_t fz) 328 344 { 329 345 if (h->InheritsFrom(TH3::Class())) 330 ScaleAxis(*((TH3*)h)->GetZaxis()->GetXbins(), fz); 346 { 347 SetBinning((TH3*)h, 348 ScaleAxis(*h->GetXaxis(), fx), 349 ScaleAxis(*h->GetYaxis(), fy), 350 ScaleAxis(*h->GetZaxis(), fz)); 351 return; 352 } 331 353 332 354 if (h->InheritsFrom(TH2::Class())) 333 ScaleAxis(*((TH2*)h)->GetYaxis()->GetXbins(), fy); 355 { 356 SetBinning((TH2*)h, 357 ScaleAxis(*h->GetXaxis(), fx), 358 ScaleAxis(*h->GetYaxis(), fy)); 359 return; 360 } 334 361 335 362 if (h->InheritsFrom(TH1::Class())) 336 ScaleAxis(*h->GetXaxis()->GetXbins(), fx); 363 SetBinning(h, ScaleAxis(*h->GetXaxis(), fx)); 364 } 365 366 Bool_t MH::ApplyBinning(const MParList &plist, TString name, TH1 *h) 367 { 368 const MBinning *bins = (MBinning*)plist.FindObject("Binning"+name); 369 if (!bins) 370 { 371 gLog << warn << "Object 'Binning" << name << "' [MBinning] not found... no binning applied." << endl; 372 return kFALSE; 373 } 374 375 SetBinning(h, bins); 376 return kTRUE; 337 377 } 338 378
Note:
See TracChangeset
for help on using the changeset viewer.