source: trunk/MagicSoft/Mars/mhist/MHStarMap.cc@ 951

Last change on this file since 951 was 887, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.3 KB
Line 
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
44ClassImp(MHStarMap);
45
46MHStarMap::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
70MHStarMap::~MHStarMap()
71{
72 delete fStarMap;
73}
74
75void 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
135void MHStarMap::Fill(const MParContainer *par)
136{
137 const MHillas &h = *(MHillas*)par;
138
139 const float dist = h.GetDist();
140 const float theta = h.GetTheta();
141 const float alpha = h.GetAlpha()/kRad2Deg;
142
143 const float m = tan(theta+alpha-kPI);
144 const float t = dist*(sin(theta)-cos(theta)*m);
145
146 if (m>-1 && m<1)
147 for (int x=-298; x<298; x+=4)
148 {
149 const float y = m*x+t;
150
151 fStarMap->Fill(x, y);
152 }
153 else
154 for (int y=-298; y<298; y+=4)
155 {
156 const float x = (y-t)/m;
157
158 fStarMap->Fill(x, y);
159 }
160}
161
Note: See TracBrowser for help on using the repository browser.