Changeset 8695 for trunk/MagicSoft/Mars/mhbase
- Timestamp:
- 08/22/07 19:18:35 (17 years ago)
- Location:
- trunk/MagicSoft/Mars/mhbase
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhbase/HBaseLinkDef.h
r6915 r8695 9 9 #pragma link C++ class MH+; 10 10 #pragma link C++ class MH3+; 11 #pragma link C++ class MHn+; 11 12 #pragma link C++ class MHArray+; 12 13 #pragma link C++ class MHMatrix+; -
trunk/MagicSoft/Mars/mhbase/MH3.cc
r8669 r8695 54 54 // If the binning should have a different name than the histogram name 55 55 // the binning name can be added to the name, eg.: 56 // SetName("MyHistName;My Binning")56 // SetName("MyHistName;MyXBins;MyYBins") 57 57 // Instead of BinningMyHistName[XYZ] the parameter list will be searched 58 // for BinningMy Binning[XYZ].58 // for BinningMyXBinning, BinningMyYBins and BinningMyHistNameZ 59 59 // 60 60 // … … 86 86 // + MData *fData[3]; // Object from which the data is filled 87 87 // 88 // Class Version 3: 89 // ---------------- 90 // - Byte_t fStyleBits 88 91 // 89 92 ///////////////////////////////////////////////////////////////////////////// … … 93 96 #include <fstream> 94 97 95 #include <TPad.h>98 //#include <TPad.h> 96 99 #include <TStyle.h> 97 100 #include <TCanvas.h> … … 121 124 // 122 125 MH3::MH3(const unsigned int dim) 123 : fDimension(dim>3?3:dim), fHist(NULL) 126 : fDimension(dim>3?3:dim), fHist(NULL), fStyleBits(0) 124 127 { 125 128 switch (fDimension) … … 162 165 // 163 166 MH3::MH3(const char *memberx) 164 : fDimension(1) 167 : fDimension(1), fStyleBits(0) 165 168 { 166 169 fHist = new TH1D; … … 182 185 } 183 186 184 MH3::MH3(const TH1 &h1) : fDimension(1) 187 MH3::MH3(const TH1 &h1) 188 : fDimension(1), fStyleBits(0) 185 189 { 186 190 if (h1.InheritsFrom(TH3::Class())) … … 221 225 // 222 226 MH3::MH3(const char *memberx, const char *membery) 223 : fDimension(2) 227 : fDimension(2), fStyleBits(0) 224 228 { 225 229 fHist = new TH2D; … … 248 252 // 249 253 MH3::MH3(const char *memberx, const char *membery, const char *memberz) 250 : fDimension(3) 254 : fDimension(3), fStyleBits(0) 251 255 { 252 256 fHist = new TH3D; … … 312 316 fHist->Reset(); 313 317 314 const Int_t split = fName.First(';'); 315 316 const TString name = split<0 ? fName : fName(0, split); 317 const TString bins = split<0 ? fName : fName(split+1, fName.Length()); 318 319 TString bname("Binning"); 320 bname += bins; 318 // Tokenize name into name and binnings names 319 TObjArray *tok = fName.Tokenize(";"); 320 321 const TString name = (*tok)[0] ? (*tok)[0]->GetName() : fName.Data(); 322 323 TString bx = (*tok)[1] ? (*tok)[1]->GetName() : Form("%sX", name.Data()); 324 TString by = (*tok)[2] ? (*tok)[2]->GetName() : Form("%sY", name.Data()); 325 TString bz = (*tok)[3] ? (*tok)[3]->GetName() : Form("%sZ", name.Data()); 326 327 bx.Prepend("Binning"); 328 by.Prepend("Binning"); 329 bz.Prepend("Binning"); 330 331 delete tok; 332 321 333 322 334 MBinning *binsx = NULL; … … 327 339 { 328 340 case 3: 329 binsz = (MBinning*)plist->FindObject(b name+"Z", "MBinning");341 binsz = (MBinning*)plist->FindObject(bz, "MBinning"); 330 342 if (!binsz) 331 343 { 332 *fLog << err << dbginf << "MBinning '" << b name << "X' not found... aborting." << endl;344 *fLog << err << dbginf << "MBinning '" << bz << "' not found... aborting." << endl; 333 345 return kFALSE; 334 346 } … … 342 354 fHist->SetBit(kIsLogz); 343 355 case 2: 344 binsy = (MBinning*)plist->FindObject(b name+"Y", "MBinning");356 binsy = (MBinning*)plist->FindObject(by, "MBinning"); 345 357 if (!binsy) 346 358 { 347 *fLog << err << dbginf << "MBinning '" << b name << "Y' not found... aborting." << endl;359 *fLog << err << dbginf << "MBinning '" << by << "' not found... aborting." << endl; 348 360 return kFALSE; 349 361 } … … 357 369 fHist->SetBit(kIsLogy); 358 370 case 1: 359 binsx = (MBinning*)plist->FindObject(b name+"X", "MBinning");371 binsx = (MBinning*)plist->FindObject(bx, "MBinning"); 360 372 if (!binsx) 361 373 { 362 374 if (fDimension==1) 363 binsx = (MBinning*)plist->FindObject( bname, "MBinning");375 binsx = (MBinning*)plist->FindObject("Binning"+fName, "MBinning"); 364 376 365 377 if (!binsx) 366 378 { 367 *fLog << err << dbginf << "Neither MBinning '" << bname << "X' nor '" << bname << "' found... aborting." << endl;379 *fLog << err << dbginf << "Neither '" << bx << "' nor '" << binsx << fName << "' found... aborting." << endl; 368 380 return kFALSE; 369 381 } … … 477 489 return kFALSE; 478 490 } 479 /* 480 // -------------------------------------------------------------------------- 481 // 482 // Set the palette you wanna use: 483 // - you could set the root "Pretty Palette Violet->Red" by 484 // gStyle->SetPalette(1, 0), but in some cases this may look 485 // confusing 486 // - The maximum colors root allowes us to set by ourself 487 // is 50 (idx: 51-100). This colors are set to a grayscaled 488 // palette 489 // - the number of contours must be two less than the number 490 // of palette entries 491 // 492 void MHStarMap::PrepareDrawing() const 493 { 494 const Int_t numg = 32; // number of gray scaled colors 495 const Int_t numw = 32; // number of white 496 497 Int_t palette[numg+numw]; 498 499 // 500 // The first half of the colors are white. 501 // This is some kind of optical background supression 502 // 503 gROOT->GetColor(51)->SetRGB(1, 1, 1); 504 505 Int_t i; 506 for (i=0; i<numw; i++) 507 palette[i] = 51; 508 509 // 510 // now the (gray) scaled part is coming 511 // 512 for (;i<numw+numg; i++) 513 { 514 const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0); 515 516 gROOT->GetColor(52+i)->SetRGB(gray, gray, gray); 517 palette[i] = 52+i; 518 } 519 520 // 521 // Set the palette and the number of contour levels 522 // 523 gStyle->SetPalette(numg+numw, palette); 524 fStarMap->SetContour(numg+numw-2); 525 } 526 */ 491 492 // -------------------------------------------------------------------------- 493 // 494 // If an auto range bit is set the histogram range of the corresponding 495 // axis is set to show only the non-empty bins (with a single empty bin 496 // on both sides) 497 // 498 Bool_t MH3::Finalize() 499 { 500 Bool_t autorangex=TESTBIT(fStyleBits, 0); 501 Bool_t autorangey=TESTBIT(fStyleBits, 1); 502 //Bool_t autorangez=TESTBIT(fStyleBits, 2); 503 504 Int_t lo, hi; 505 506 if (autorangex) 507 { 508 GetRangeX(*fHist, lo, hi); 509 cout << "====> " << GetName() << " " << fHist->GetName() << ": " << lo << " " << hi <<" " << fHist->GetNbinsX() << endl; 510 fHist->GetXaxis()->SetRange(lo-2, hi+1); 511 } 512 if (autorangey) 513 { 514 GetRangeY(*fHist, lo, hi); 515 fHist->GetYaxis()->SetRange(lo-2, hi+1); 516 } 517 /* 518 if (autorangez) 519 { 520 GetRangeZ(*fHist, lo, hi); 521 fHist->GetZaxis()->SetRange(lo-2, hi+1); 522 } 523 */ 524 return kTRUE; 525 } 526 527 527 // -------------------------------------------------------------------------- 528 528 // … … 547 547 { 548 548 Int_t col = p->GetLineColor(); 549 p = ((TH2*)fHist)->ProfileX(pfx, -1, 9999, "s");549 p = ((TH2*)fHist)->ProfileX(pfx, -1, -1, "s"); 550 550 p->SetLineColor(col); 551 551 } … … 555 555 { 556 556 Int_t col = p->GetLineColor(); 557 p = ((TH2*)fHist)->ProfileY(pfy, -1, 9999, "s");557 p = ((TH2*)fHist)->ProfileY(pfy, -1, -1, "s"); 558 558 p->SetLineColor(col); 559 559 } 560 560 /* 561 561 if (fHist->TestBit(kIsLogx) && fHist->GetEntries()>0) gPad->SetLogx(); 562 562 if (fHist->TestBit(kIsLogy) && fHist->GetEntries()>0) gPad->SetLogy(); 563 563 if (fHist->TestBit(kIsLogz) && fHist->GetEntries()>0) gPad->SetLogz(); 564 */ 564 565 } 565 566 … … 587 588 pad->SetGridy(); 588 589 590 if (fHist->TestBit(kIsLogx)) pad->SetLogx(); 591 if (fHist->TestBit(kIsLogy)) pad->SetLogy(); 592 if (fHist->TestBit(kIsLogz)) pad->SetLogz(); 593 589 594 fHist->SetFillStyle(4000); 590 595 … … 624 629 *fLog << warn << "TProfile " << pfx << " already in pad." << endl; 625 630 626 p = ((TH2*)fHist)->ProfileX(pfx, -1, 9999, "s");631 p = ((TH2*)fHist)->ProfileX(pfx, -1, -1, "s"); 627 632 p->UseCurrentStyle(); 628 633 p->SetLineColor(blue ? kBlue : fHist->GetLineColor()); … … 640 645 *fLog << warn << "TProfile " << pfy << " already in pad." << endl; 641 646 642 p = ((TH2*)fHist)->ProfileY(pfy, -1, 9999, "s");647 p = ((TH2*)fHist)->ProfileY(pfy, -1, -1, "s"); 643 648 p->UseCurrentStyle(); 644 649 p->SetLineColor(blue ? kBlue : fHist->GetLineColor()); -
trunk/MagicSoft/Mars/mhbase/MH3.h
r8082 r8695 10 10 11 11 class TH1; 12 class TMethodCall;13 12 class MData; 14 13 … … 25 24 MData *fData[3]; // Object from which the data is filled 26 25 Double_t fScale[3]; // Scale for the three axis (eg unit) 26 Byte_t fStyleBits; // Set the range of a histogram automatically in Finalize 27 27 28 28 void StreamPrimitive(ostream &out) const; … … 46 46 void SetScaleY(Double_t scale) { fScale[1] = scale; } 47 47 void SetScaleZ(Double_t scale) { fScale[2] = scale; } 48 void SetScale(Double_t x, Double_t y=1, Double_t z=2) { SetScaleX(x); SetScaleY(y); SetScaleZ(z); } 48 49 49 50 void SetLogx(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogx) : fHist->ResetBit(kIsLogx); } 50 51 void SetLogy(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogy) : fHist->ResetBit(kIsLogy); } 51 52 void SetLogz(Bool_t b=kTRUE) { b ? fHist->SetBit(kIsLogz) : fHist->ResetBit(kIsLogz); } 53 void SetLog(Bool_t x=kTRUE, Bool_t y=kTRUE, Bool_t z=kTRUE) { SetLogx(x); SetLogy(y); SetLogz(z); } 54 55 void SetAutoRangeX(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 0) : CLRBIT(fStyleBits, 0); } 56 void SetAutoRangeY(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 1) : CLRBIT(fStyleBits, 1); } 57 void SetAutoRangeZ(Bool_t b=kTRUE) { b ? SETBIT(fStyleBits, 2) : CLRBIT(fStyleBits, 2); } 58 void SetAutoRange(Bool_t x=kTRUE, Bool_t y=kTRUE, Bool_t z=kTRUE) { SetAutoRangeX(x); SetAutoRangeY(y); SetAutoRangeZ(z); } 52 59 53 60 void Sumw2() const { if (fHist) fHist->Sumw2(); } … … 67 74 Bool_t SetupFill(const MParList *pList); 68 75 Bool_t Fill(const MParContainer *par, const Stat_t w=1); 76 Bool_t Finalize(); 69 77 70 78 TH1 *GetHistByName(const TString name="") const { return fHist; } … … 86 94 void Paint(Option_t *opt=""); 87 95 88 ClassDef(MH3, 2) // Generalized 1/2/3D-histogram for Mars variables96 ClassDef(MH3, 3) // Generalized 1/2/3D-histogram for Mars variables 89 97 }; 90 98 -
trunk/MagicSoft/Mars/mhbase/Makefile
r6915 r8695 25 25 MH.cc \ 26 26 MH3.cc \ 27 MHn.cc \ 27 28 MHArray.cc \ 28 29 MHMatrix.cc
Note:
See TracChangeset
for help on using the changeset viewer.