Ignore:
Timestamp:
09/16/02 10:10:17 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MH3.cc

    r1483 r1524  
    6262#include <fstream.h>
    6363
     64#include <TPad.h>
     65#include <TStyle.h>
     66#include <TCanvas.h>
     67
    6468#include <TH2.h>
    6569#include <TH3.h>
    6670#include <TProfile.h>
    6771#include <TProfile2D.h>
    68 #include <TPad.h>
    69 #include <TCanvas.h>
    7072
    7173#include "MLog.h"
     
    7375
    7476#include "MParList.h"
    75 
     77#include "MBinning.h"
    7678#include "MDataChain.h"
    7779
     
    202204            return kFALSE;
    203205        }
     206        if (binsz->IsLogarithmic())
     207            fHist->SetBit(kIsLogz);
    204208        fHist->SetZTitle(fData[2]->GetTitle());
    205209        if (!fData[2]->PreProcess(plist))
     
    212216            return kFALSE;
    213217        }
     218        if (binsy->IsLogarithmic())
     219            fHist->SetBit(kIsLogy);
    214220        fHist->SetYTitle(fData[1]->GetTitle());
    215221        if (!fData[1]->PreProcess(plist))
     
    222228            return kFALSE;
    223229        }
     230        if (binsx->IsLogarithmic())
     231            fHist->SetBit(kIsLogx);
    224232        fHist->SetXTitle(fData[0]->GetTitle());
    225233        if (!fData[0]->PreProcess(plist))
     
    306314    return kFALSE;
    307315}
     316/*
     317// --------------------------------------------------------------------------
     318//
     319// Set the palette you wanna use:
     320//  - you could set the root "Pretty Palette Violet->Red" by
     321//    gStyle->SetPalette(1, 0), but in some cases this may look
     322//    confusing
     323//  - The maximum colors root allowes us to set by ourself
     324//    is 50 (idx: 51-100). This colors are set to a grayscaled
     325//    palette
     326//  - the number of contours must be two less than the number
     327//    of palette entries
     328//
     329void MHStarMap::PrepareDrawing() const
     330{
     331    const Int_t numg = 32; // number of gray scaled colors
     332    const Int_t numw = 32; // number of white
     333
     334    Int_t palette[numg+numw];
     335
     336    //
     337    // The first half of the colors are white.
     338    // This is some kind of optical background supression
     339    //
     340    gROOT->GetColor(51)->SetRGB(1, 1, 1);
     341
     342    Int_t i;
     343    for (i=0; i<numw; i++)
     344        palette[i] = 51;
     345
     346    //
     347    // now the (gray) scaled part is coming
     348    //
     349    for (;i<numw+numg; i++)
     350    {
     351        const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0);
     352
     353        gROOT->GetColor(52+i)->SetRGB(gray, gray, gray);
     354        palette[i] = 52+i;
     355    }
     356
     357    //
     358    // Set the palette and the number of contour levels
     359    //
     360    gStyle->SetPalette(numg+numw, palette);
     361    fStarMap->SetContour(numg+numw-2);
     362}
     363*/
     364// --------------------------------------------------------------------------
     365//
     366// Setup a inversed deep blue sea palette for the fCenter histogram.
     367//
     368void MH3::SetColors() const
     369{
     370    // FIXME: This must be redone each time the canvas is repainted....
     371    gStyle->SetPalette(51, NULL);
     372    Int_t c[50];
     373    for (int i=0; i<50; i++)
     374        c[49-i] = gStyle->GetColorPalette(i);
     375    gStyle->SetPalette(50, c);
     376}
    308377
    309378// --------------------------------------------------------------------------
    310379//
    311380// Draw clone of histogram. So that the object can be deleted
     381//
     382// Possible options are:
     383//   PROFX: Draw a x-profile into the histogram (for 2D histograms only)
     384//   PROFY: Draw a y-profile into the histogram (for 2D histograms only)
     385//   ONLY:  Draw the profile histogram only (for 2D histograms only)
     386//
     387// If the kIsLog?-Bit is set the axis is displayed lkogarithmically.
     388// eg this is set when applying a logarithmic MBinning
     389//
    312390// and the histogram is still visible in the canvas.
    313391// The cloned object are deleted together with the canvas if the canvas is
     
    324402    gROOT->SetSelectedPad(NULL);
    325403
    326     fHist->DrawCopy(opt);
    327 
    328404    TString str(opt);
     405
     406    if (str.Contains("COL", TString::kIgnoreCase))
     407        SetColors();
     408
     409    Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2;
     410    if (!only)
     411        fHist->DrawCopy(opt);
     412
    329413    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
    330414    {
    331415        TProfile *p = ((TH2*)fHist)->ProfileX();
    332         p->Draw("same");
     416        p->Draw(only?"":"same");
    333417        p->SetBit(kCanDelete);
    334418        p->SetDirectory(NULL);
     
    337421    {
    338422        TProfile *p = ((TH2*)fHist)->ProfileY();
    339         p->Draw("same");
     423        p->Draw(only?"":"same");
    340424        p->SetBit(kCanDelete);
    341425        p->SetDirectory(NULL);
    342426    }
    343427
     428    if (fHist->TestBit(kIsLogx)) c.SetLogx();
     429    if (fHist->TestBit(kIsLogy)) c.SetLogy();
     430    if (fHist->TestBit(kIsLogz)) c.SetLogz();
     431
    344432    c.Modified();
    345433    c.Update();
     
    351439//
    352440// Creates a new canvas and draws the histogram into it.
     441//
     442// Possible options are:
     443//   PROFX: Draw a x-profile into the histogram (for 2D histograms only)
     444//   PROFY: Draw a y-profile into the histogram (for 2D histograms only)
     445//   ONLY:  Draw the profile histogram only (for 2D histograms only)
     446//
     447// If the kIsLog?-Bit is set the axis is displayed lkogarithmically.
     448// eg this is set when applying a logarithmic MBinning
     449//
    353450// Be careful: The histogram belongs to this object and won't get deleted
    354451// together with the canvas.
     
    359456        MH::MakeDefCanvas(fHist);
    360457
    361     fHist->Draw(opt);
    362 
    363458    TString str(opt);
     459
     460    if (str.Contains("COL", TString::kIgnoreCase))
     461        SetColors();
     462
     463    Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2;
     464    if (!only)
     465        fHist->Draw(opt);
     466
    364467    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
    365468    {
    366469        TProfile *p = ((TH2*)fHist)->ProfileX();
    367         p->Draw("same");
     470        p->Draw(only?"":"same");
    368471        p->SetBit(kCanDelete);
    369472        p->SetDirectory(NULL);
     
    372475    {
    373476        TProfile *p = ((TH2*)fHist)->ProfileY();
    374         p->Draw("same");
     477        p->Draw(only?"":"same");
    375478        p->SetBit(kCanDelete);
    376479        p->SetDirectory(NULL);
    377480    }
     481
     482    if (fHist->TestBit(kIsLogx)) gPad->SetLogx();
     483    if (fHist->TestBit(kIsLogy)) gPad->SetLogy();
     484    if (fHist->TestBit(kIsLogz)) gPad->SetLogz();
    378485
    379486    gPad->Modified();
Note: See TracChangeset for help on using the changeset viewer.