Changeset 952 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 09/27/01 13:25:51 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHHillas.cc
r897 r952 19 19 ClassImp(MHHillas); 20 20 21 // -------------------------------------------------------------------------- 22 // 23 // Setup four histograms for Alpha, Width, Length and Dist 24 // 21 25 MHHillas::MHHillas (const char *name, const char *title) 22 26 { … … 57 61 } 58 62 63 // -------------------------------------------------------------------------- 64 // 65 // Delete the four histograms 66 // 59 67 MHHillas::~MHHillas() 60 68 { … … 65 73 } 66 74 75 // -------------------------------------------------------------------------- 76 // 77 // Fill the four histograms with data from a MHillas-Container. 78 // Be careful: Only call this with an object of type MHillas 79 // 67 80 void MHHillas::Fill(const MParContainer *par) 68 81 { … … 75 88 } 76 89 90 // -------------------------------------------------------------------------- 91 // 92 // Draw clones of all four histograms. So that the object can be deleted 93 // and the histograms are still visible in the canvas. 94 // The cloned object are deleted together with the canvas if the canvas is 95 // destroyed. If you want to handle dostroying the canvas you can get a 96 // pointer to it from this function 97 // 98 TObject *MHHillas::DrawClone(Option_t *opt) 99 { 100 TCanvas *c = new TCanvas("Hillas", "Histograms of Hillas Parameters"); 101 c->Divide(2,2); 102 103 // 104 // This is necessary to get the expected bahviour of DrawClone 105 // 106 gROOT->SetSelectedPad(NULL); 107 108 c->cd(1); 109 fAlpha->DrawClone()->SetBit(kCanDelete); 110 111 c->cd(2); 112 fLength->DrawClone()->SetBit(kCanDelete); 113 114 c->cd(3); 115 fDist->DrawClone()->SetBit(kCanDelete); 116 117 c->cd(4); 118 fWidth->DrawClone()->SetBit(kCanDelete); 119 120 c->Modified(); 121 c->Update(); 122 123 return c; 124 } 125 126 // -------------------------------------------------------------------------- 127 // 128 // Creates a new canvas and draws the four histograms into it. 129 // Be careful: The histograms belongs to this object and won't get deleted 130 // together with the canvas. 131 // 77 132 void MHHillas::Draw(Option_t *) 78 133 { … … 86 141 87 142 c->cd(1); 88 fAlpha->SetBit(kCanDelete);143 //fAlpha->SetBit(kCanDelete); 89 144 fAlpha->Draw(); 145 90 146 c->cd(2); 91 fLength->SetBit(kCanDelete);147 //fLength->SetBit(kCanDelete); 92 148 fLength->Draw(); 149 93 150 c->cd(3); 94 fDist->SetBit(kCanDelete);151 //fDist->SetBit(kCanDelete); 95 152 fDist->Draw(); 153 96 154 c->cd(4); 97 fWidth->SetBit(kCanDelete);155 //fWidth->SetBit(kCanDelete); 98 156 fWidth->Draw(); 99 157 -
trunk/MagicSoft/Mars/mhist/MHHillas.h
r887 r952 33 33 34 34 void Draw(Option_t *opt=NULL); 35 TObject *DrawClone(Option_t *opt=NULL); 35 36 36 37 ClassDef(MHHillas, 1) // Container which holds hostograms for the Hillas parameters -
trunk/MagicSoft/Mars/mhist/MHStarMap.cc
r887 r952 44 44 ClassImp(MHStarMap); 45 45 46 // -------------------------------------------------------------------------- 47 // 48 // Create the star map histogram 49 // 46 50 MHStarMap::MHStarMap (const char *name, const char *title) 47 51 { … … 68 72 } 69 73 74 // -------------------------------------------------------------------------- 75 // 76 // delete the histogram instance 77 // 70 78 MHStarMap::~MHStarMap() 71 79 { … … 73 81 } 74 82 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 83 // -------------------------------------------------------------------------- 84 // 85 // Fill the four histograms with data from a MHillas-Container. 86 // Be careful: Only call this with an object of type MHillas 87 // 135 88 void MHStarMap::Fill(const MParContainer *par) 136 89 { … … 160 113 } 161 114 115 // -------------------------------------------------------------------------- 116 // 117 // Set the palette you wanna use: 118 // - you could set the root "Pretty Palette Violet->Red" by 119 // gStyle->SetPalette(1, 0), but in some cases this may look 120 // confusing 121 // - The maximum colors root allowes us to set by ourself 122 // is 50 (idx: 51-100). This colors are set to a grayscaled 123 // palette 124 // - the number of contours must be two less than the number 125 // of palette entries 126 // 127 void MHStarMap::PrepareDrawing() 128 { 129 const Int_t numg = 32; // number of gray scaled colors 130 const Int_t numw = 32; // number of white 131 132 Int_t palette[numg+numw]; 133 134 // 135 // The first half of the colors are white. 136 // This is some kind of optical background supression 137 // 138 gROOT->GetColor(51)->SetRGB(1, 1, 1); 139 140 Int_t i; 141 for (i=0; i<numw; i++) 142 palette[i] = 51; 143 144 // 145 // now the (gray) scaled part is coming 146 // 147 for (;i<numw+numg; i++) 148 { 149 const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0); 150 151 gROOT->GetColor(52+i)->SetRGB(gray, gray, gray); 152 palette[i] = 52+i; 153 } 154 155 // 156 // Set the palette and the number of contour levels 157 // 158 gStyle->SetPalette(numg+numw, palette); 159 fStarMap->SetContour(numg+numw-2); 160 } 161 162 163 // -------------------------------------------------------------------------- 164 // 165 // Draw clones of the histograms, so that the object can be deleted 166 // and the histogram is still visible in the canvas. 167 // The cloned object is deleted together with the canvas if the canvas is 168 // destroyed. If you want to handle destroying the canvas you can get a 169 // pointer to it from this function 170 // 171 TObject *MHStarMap::DrawClone(Option_t *opt) 172 { 173 TCanvas *c = new TCanvas("Star Map", "Star Map created from Hillas Parameters", 500, 500); 174 175 // 176 // This is necessary to get the expected bahviour of DrawClone 177 // 178 gROOT->SetSelectedPad(NULL); 179 180 PrepareDrawing(); 181 182 fStarMap->DrawClone("colz")->SetBit(kCanDelete); 183 184 c->Modified(); 185 c->Update(); 186 187 return c; 188 } 189 190 // -------------------------------------------------------------------------- 191 // 192 // Creates a new canvas and draw the histogram into it. 193 // Be careful: The histogram belongs to this object and won't get deleted 194 // together with the canvas. 195 // 196 void MHStarMap::Draw(Option_t *) 197 { 198 TCanvas *c = new TCanvas("Star Map", "Star Map created from Hillas Parameters", 500, 500); 199 200 PrepareDrawing(); 201 202 fStarMap->Draw("colz"); 203 204 c->Modified(); 205 c->Update(); 206 } 207 -
trunk/MagicSoft/Mars/mhist/MHStarMap.h
r887 r952 23 23 TH2F *fStarMap; 24 24 25 void PrepareDrawing(); 26 25 27 public: 26 28 MHStarMap(const char *name=NULL, const char *title=NULL); … … 29 31 void Fill(const MParContainer *par); 30 32 31 TH2F *GetHist() { return fStarMap; } 33 TH2F *GetHist() { return fStarMap; } 34 32 35 void Draw(Option_t *opt=NULL); 36 TObject *DrawClone(Option_t *opt=NULL); 33 37 34 38 ClassDef(MHStarMap, 1) // Container to hold 2-dim histogram (starmap)
Note:
See TracChangeset
for help on using the changeset viewer.