Ignore:
Timestamp:
04/03/01 13:28:36 (24 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r712 r717  
    1111#include "MHStarMap.h"
    1212
    13 #include <TH2.h>
    14 #include <TStyle.h>
    15 #include <TCanvas.h>
     13#include <TH2.h>      // TH2F
     14#include <TStyle.h>   // gStyle
     15#include <TColor.h>   // SetRGB
     16#include <TCanvas.h>  // TCanvas
    1617
    1718#include "MHillas.h"
     
    3940    //
    4041    fStarMap = new TH2F("Star Map", "Counts",
    41                         50, -300, 300,
    42                         50, -300, 300);
     42                        150, -300, 300,
     43                        150, -300, 300);
    4344}
    4445
     
    5051void MHStarMap::Draw(Option_t *)
    5152{
     53    //
     54    // Creates a new canvas, creates a useful palette and
     55    // draws the histogram in the new created canvas
     56    //
     57
    5258    TCanvas *c = new TCanvas("Star Map", "Star Map created from Hillas Parameters", 500, 500);
    5359
    54     gStyle->SetPalette(1, 0);
     60    //
     61    // Set the palette you wanna use:
     62    //  - you could set the root "Pretty Palette Violet->Red" by
     63    //    gStyle->SetPalette(1, 0), but in some cases this may look
     64    //    confusing
     65    //  - The maximum colors root allowes us to set by ourself
     66    //    is 50 (idx: 51-100). This colors are set to a grayscaled
     67    //    palette
     68    //  - the number of contours must be two less than the number
     69    //    of palette entries
     70    //
     71
     72    const Int_t numg = 32; // number of gray scaled colors
     73    const Int_t numw = 32; // number of white
     74
     75    Int_t palette[numg+numw];
     76
     77    //
     78    // The first half of the colors are white.
     79    // This is some kind of optical background supression
     80    //
     81    gROOT->GetColor(51)->SetRGB(1, 1, 1);
     82
     83    Int_t i;
     84    for (i=0; i<numw; i++)
     85        palette[i] = 51;
     86
     87    //
     88    // now the (gray) scaled part is coming
     89    //
     90    for (;i<numw+numg; i++)
     91    {
     92        const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0);
     93
     94        gROOT->GetColor(52+i)->SetRGB(gray, gray, gray);
     95        palette[i] = 52+i;
     96    }
     97
     98    //
     99    // Set the palette and the number of contour levels
     100    //
     101    gStyle->SetPalette(numg+numw, palette);
     102    fStarMap->SetContour(numg+numw-2);
     103
     104    // gStyle->SetPalette(1, 0);
    55105    fStarMap->Draw("colz");
    56106
     
    68118    const float t = dist*(sin(theta)-cos(theta)*m);
    69119
    70     float y0 = -m*300+t;
    71     for (int i=-297; i<300; i+=3)
    72     {
    73         const float y1 = m*i+t;
     120    if (m>-1 && m<1)
     121        for (int x=-298; x<298; x+=4)
     122        {
     123            const float y = m*x+t;
    74124
    75 //        if (y1<=y0-3 || y1>=y0+3)
    76 //            continue;
     125            fStarMap->Fill(x, y);
     126        }
     127    else
     128        for (int y=-298; y<298; y+=4)
     129        {
     130            const float x = (y-t)/m;
    77131
    78         fStarMap->Fill(i, y1);
    79         y0 = y1;
    80     }
     132            fStarMap->Fill(x, y);
     133        }
    81134}
    82135
Note: See TracChangeset for help on using the changeset viewer.