| 1 | ///////////////////////////////////////////////////////////////////////
|
|---|
| 2 | //
|
|---|
| 3 | // MHStarMap
|
|---|
| 4 | //
|
|---|
| 5 | // This class contains a 2-dimensional histogram. It should show some
|
|---|
| 6 | // kind of star map. The algorith which calculates the star map
|
|---|
| 7 | // from the Hillas parameters (Fill) can be enhanced.
|
|---|
| 8 | //
|
|---|
| 9 | ///////////////////////////////////////////////////////////////////////
|
|---|
| 10 |
|
|---|
| 11 | #include "MHStarMap.h"
|
|---|
| 12 |
|
|---|
| 13 | #include <TH2.h> // TH2F
|
|---|
| 14 | #include <TStyle.h> // gStyle
|
|---|
| 15 | #include <TColor.h> // SetRGB
|
|---|
| 16 | #include <TCanvas.h> // TCanvas
|
|---|
| 17 |
|
|---|
| 18 | #include "MHillas.h"
|
|---|
| 19 |
|
|---|
| 20 | ClassImp(MHStarMap)
|
|---|
| 21 |
|
|---|
| 22 | MHStarMap::MHStarMap (const char *name, const char *title)
|
|---|
| 23 | {
|
|---|
| 24 | //
|
|---|
| 25 | // default constructor
|
|---|
| 26 | // creates an a list of histograms for all pixels and both gain channels
|
|---|
| 27 | //
|
|---|
| 28 |
|
|---|
| 29 | //
|
|---|
| 30 | // set the name and title of this object
|
|---|
| 31 | //
|
|---|
| 32 |
|
|---|
| 33 | *fName = name ? name : "MHStarMap" ;
|
|---|
| 34 | *fTitle = title ? title : "Container for a Star Map" ;
|
|---|
| 35 |
|
|---|
| 36 | //
|
|---|
| 37 | // loop over all Pixels and create two histograms
|
|---|
| 38 | // one for the Low and one for the High gain
|
|---|
| 39 | // connect all the histogram with the container fHist
|
|---|
| 40 | //
|
|---|
| 41 | fStarMap = new TH2F("Star Map", "Counts",
|
|---|
| 42 | 150, -300, 300,
|
|---|
| 43 | 150, -300, 300);
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | MHStarMap::~MHStarMap()
|
|---|
| 47 | {
|
|---|
| 48 | delete fStarMap;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | void MHStarMap::Draw(Option_t *)
|
|---|
| 52 | {
|
|---|
| 53 | //
|
|---|
| 54 | // Creates a new canvas, creates a useful palette and
|
|---|
| 55 | // draws the histogram in the new created canvas
|
|---|
| 56 | //
|
|---|
| 57 |
|
|---|
| 58 | TCanvas *c = new TCanvas("Star Map", "Star Map created from Hillas Parameters", 500, 500);
|
|---|
| 59 |
|
|---|
| 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);
|
|---|
| 105 | fStarMap->Draw("colz");
|
|---|
| 106 |
|
|---|
| 107 | c->Modified();
|
|---|
| 108 | c->Update();
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | void MHStarMap::Fill(MHillas *par)
|
|---|
| 112 | {
|
|---|
| 113 | const float dist = par->GetDist();
|
|---|
| 114 | const float theta = par->GetTheta();
|
|---|
| 115 | const float alpha = par->GetAlpha()/kRad2Deg;
|
|---|
| 116 |
|
|---|
| 117 | const float m = tan(theta+alpha-kPI);
|
|---|
| 118 | const float t = dist*(sin(theta)-cos(theta)*m);
|
|---|
| 119 |
|
|---|
| 120 | if (m>-1 && m<1)
|
|---|
| 121 | for (int x=-298; x<298; x+=4)
|
|---|
| 122 | {
|
|---|
| 123 | const float y = m*x+t;
|
|---|
| 124 |
|
|---|
| 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;
|
|---|
| 131 |
|
|---|
| 132 | fStarMap->Fill(x, y);
|
|---|
| 133 | }
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|