1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | ///////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MHStarMap
|
---|
28 | //
|
---|
29 | // This class contains a 2-dimensional histogram. It should show some
|
---|
30 | // kind of star map. The algorith which calculates the star map
|
---|
31 | // from the Hillas parameters (Fill) can be enhanced.
|
---|
32 | //
|
---|
33 | ///////////////////////////////////////////////////////////////////////
|
---|
34 |
|
---|
35 | #include "MHStarMap.h"
|
---|
36 |
|
---|
37 | #include <TH2.h> // TH2F
|
---|
38 | #include <TStyle.h> // gStyle
|
---|
39 | #include <TColor.h> // SetRGB
|
---|
40 | #include <TCanvas.h> // TCanvas
|
---|
41 |
|
---|
42 | #include "MHillas.h"
|
---|
43 |
|
---|
44 | ClassImp(MHStarMap);
|
---|
45 |
|
---|
46 | MHStarMap::MHStarMap (const char *name, const char *title)
|
---|
47 | {
|
---|
48 | //
|
---|
49 | // default constructor
|
---|
50 | // creates an a list of histograms for all pixels and both gain channels
|
---|
51 | //
|
---|
52 |
|
---|
53 | //
|
---|
54 | // set the name and title of this object
|
---|
55 | //
|
---|
56 |
|
---|
57 | *fName = name ? name : "MHStarMap" ;
|
---|
58 | *fTitle = title ? title : "Container for a Star Map" ;
|
---|
59 |
|
---|
60 | //
|
---|
61 | // loop over all Pixels and create two histograms
|
---|
62 | // one for the Low and one for the High gain
|
---|
63 | // connect all the histogram with the container fHist
|
---|
64 | //
|
---|
65 | fStarMap = new TH2F("Star Map", "Counts",
|
---|
66 | 150, -300, 300,
|
---|
67 | 150, -300, 300);
|
---|
68 | }
|
---|
69 |
|
---|
70 | MHStarMap::~MHStarMap()
|
---|
71 | {
|
---|
72 | delete fStarMap;
|
---|
73 | }
|
---|
74 |
|
---|
75 | void MHStarMap::Draw(Option_t *)
|
---|
76 | {
|
---|
77 | //
|
---|
78 | // Creates a new canvas, creates a useful palette and
|
---|
79 | // draws the histogram in the new created canvas
|
---|
80 | //
|
---|
81 |
|
---|
82 | TCanvas *c = new TCanvas("Star Map", "Star Map created from Hillas Parameters", 500, 500);
|
---|
83 |
|
---|
84 | //
|
---|
85 | // Set the palette you wanna use:
|
---|
86 | // - you could set the root "Pretty Palette Violet->Red" by
|
---|
87 | // gStyle->SetPalette(1, 0), but in some cases this may look
|
---|
88 | // confusing
|
---|
89 | // - The maximum colors root allowes us to set by ourself
|
---|
90 | // is 50 (idx: 51-100). This colors are set to a grayscaled
|
---|
91 | // palette
|
---|
92 | // - the number of contours must be two less than the number
|
---|
93 | // of palette entries
|
---|
94 | //
|
---|
95 |
|
---|
96 | const Int_t numg = 32; // number of gray scaled colors
|
---|
97 | const Int_t numw = 32; // number of white
|
---|
98 |
|
---|
99 | Int_t palette[numg+numw];
|
---|
100 |
|
---|
101 | //
|
---|
102 | // The first half of the colors are white.
|
---|
103 | // This is some kind of optical background supression
|
---|
104 | //
|
---|
105 | gROOT->GetColor(51)->SetRGB(1, 1, 1);
|
---|
106 |
|
---|
107 | Int_t i;
|
---|
108 | for (i=0; i<numw; i++)
|
---|
109 | palette[i] = 51;
|
---|
110 |
|
---|
111 | //
|
---|
112 | // now the (gray) scaled part is coming
|
---|
113 | //
|
---|
114 | for (;i<numw+numg; i++)
|
---|
115 | {
|
---|
116 | const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0);
|
---|
117 |
|
---|
118 | gROOT->GetColor(52+i)->SetRGB(gray, gray, gray);
|
---|
119 | palette[i] = 52+i;
|
---|
120 | }
|
---|
121 |
|
---|
122 | //
|
---|
123 | // Set the palette and the number of contour levels
|
---|
124 | //
|
---|
125 | gStyle->SetPalette(numg+numw, palette);
|
---|
126 | fStarMap->SetContour(numg+numw-2);
|
---|
127 |
|
---|
128 | // gStyle->SetPalette(1, 0);
|
---|
129 | fStarMap->Draw("colz");
|
---|
130 |
|
---|
131 | c->Modified();
|
---|
132 | c->Update();
|
---|
133 | }
|
---|
134 |
|
---|
135 | void MHStarMap::Fill(const MHillas *par)
|
---|
136 | {
|
---|
137 | const float dist = par->GetDist();
|
---|
138 | const float theta = par->GetTheta();
|
---|
139 | const float alpha = par->GetAlpha()/kRad2Deg;
|
---|
140 |
|
---|
141 | const float m = tan(theta+alpha-kPI);
|
---|
142 | const float t = dist*(sin(theta)-cos(theta)*m);
|
---|
143 |
|
---|
144 | if (m>-1 && m<1)
|
---|
145 | for (int x=-298; x<298; x+=4)
|
---|
146 | {
|
---|
147 | const float y = m*x+t;
|
---|
148 |
|
---|
149 | fStarMap->Fill(x, y);
|
---|
150 | }
|
---|
151 | else
|
---|
152 | for (int y=-298; y<298; y+=4)
|
---|
153 | {
|
---|
154 | const float x = (y-t)/m;
|
---|
155 |
|
---|
156 | fStarMap->Fill(x, y);
|
---|
157 | }
|
---|
158 | }
|
---|
159 |
|
---|