| 1 | ///////////////////////////////////////////////////////////////////////
|
|---|
| 2 | //
|
|---|
| 3 | // MHHillas
|
|---|
| 4 | //
|
|---|
| 5 | // This class contains histograms for every Hillas parameter
|
|---|
| 6 | //
|
|---|
| 7 | ///////////////////////////////////////////////////////////////////////
|
|---|
| 8 |
|
|---|
| 9 | #include "MHHillas.h"
|
|---|
| 10 |
|
|---|
| 11 | #include <math.h>
|
|---|
| 12 |
|
|---|
| 13 | #include <TH1.h>
|
|---|
| 14 | #include <TPad.h>
|
|---|
| 15 | #include <TCanvas.h>
|
|---|
| 16 |
|
|---|
| 17 | #include "MHillas.h"
|
|---|
| 18 |
|
|---|
| 19 | ClassImp(MHHillas);
|
|---|
| 20 |
|
|---|
| 21 | // --------------------------------------------------------------------------
|
|---|
| 22 | //
|
|---|
| 23 | // Setup four histograms for Alpha, Width, Length and Dist
|
|---|
| 24 | //
|
|---|
| 25 | MHHillas::MHHillas (const char *name, const char *title)
|
|---|
| 26 | {
|
|---|
| 27 | //
|
|---|
| 28 | // set the name and title of this object
|
|---|
| 29 | //
|
|---|
| 30 | fName = name ? name : "MHHillas" ;
|
|---|
| 31 | fTitle = title ? title : "Container for Hillas histograms" ;
|
|---|
| 32 |
|
|---|
| 33 | //
|
|---|
| 34 | // loop over all Pixels and create two histograms
|
|---|
| 35 | // one for the Low and one for the High gain
|
|---|
| 36 | // connect all the histogram with the container fHist
|
|---|
| 37 | //
|
|---|
| 38 | fAlpha = new TH1F("\\alpha [\\circ]", "Alpha of Hillas", 90, 0, 90);
|
|---|
| 39 | fWidth = new TH1F("Width [mm]", "Width of Hillas", 100, 0, 300);
|
|---|
| 40 | fLength = new TH1F("Length [mm]", "Length of Hillas", 100, 0, 300);
|
|---|
| 41 | fDist = new TH1F("Dist [mm]", "Dist of Hillas", 100, 0, 300);
|
|---|
| 42 |
|
|---|
| 43 | fAlpha->SetDirectory(NULL);
|
|---|
| 44 | fLength->SetDirectory(NULL);
|
|---|
| 45 | fDist->SetDirectory(NULL);
|
|---|
| 46 | fWidth->SetDirectory(NULL);
|
|---|
| 47 |
|
|---|
| 48 | fAlpha->GetXaxis()->SetTitle("\\alpha [\\circ]");
|
|---|
| 49 | fLength->GetXaxis()->SetTitle("Length [mm]");
|
|---|
| 50 | fDist->GetXaxis()->SetTitle("Dist [mm]");
|
|---|
| 51 | fWidth->GetXaxis()->SetTitle("Width [mm]");
|
|---|
| 52 |
|
|---|
| 53 | fAlpha->GetYaxis()->SetTitle("Counts");
|
|---|
| 54 | fLength->GetYaxis()->SetTitle("Counts");
|
|---|
| 55 | fDist->GetYaxis()->SetTitle("Counts");
|
|---|
| 56 | fWidth->GetYaxis()->SetTitle("Counts");
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | // --------------------------------------------------------------------------
|
|---|
| 60 | //
|
|---|
| 61 | // Delete the four histograms
|
|---|
| 62 | //
|
|---|
| 63 | MHHillas::~MHHillas()
|
|---|
| 64 | {
|
|---|
| 65 | delete fAlpha;
|
|---|
| 66 | delete fWidth;
|
|---|
| 67 | delete fLength;
|
|---|
| 68 | delete fDist;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | // --------------------------------------------------------------------------
|
|---|
| 72 | //
|
|---|
| 73 | // Fill the four histograms with data from a MHillas-Container.
|
|---|
| 74 | // Be careful: Only call this with an object of type MHillas
|
|---|
| 75 | //
|
|---|
| 76 | void MHHillas::Fill(const MParContainer *par)
|
|---|
| 77 | {
|
|---|
| 78 | const MHillas &h = *(MHillas*)par;
|
|---|
| 79 |
|
|---|
| 80 | fAlpha ->Fill(fabs(h.GetAlpha()));
|
|---|
| 81 | fWidth ->Fill(h.GetWidth());
|
|---|
| 82 | fLength->Fill(h.GetLength());
|
|---|
| 83 | fDist ->Fill(h.GetDist());
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | // --------------------------------------------------------------------------
|
|---|
| 87 | //
|
|---|
| 88 | // Draw clones of all four histograms. So that the object can be deleted
|
|---|
| 89 | // and the histograms are still visible in the canvas.
|
|---|
| 90 | // The cloned object are deleted together with the canvas if the canvas is
|
|---|
| 91 | // destroyed. If you want to handle dostroying the canvas you can get a
|
|---|
| 92 | // pointer to it from this function
|
|---|
| 93 | //
|
|---|
| 94 | TObject *MHHillas::DrawClone(Option_t *opt) const
|
|---|
| 95 | {
|
|---|
| 96 | TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters");
|
|---|
| 97 | c->Divide(2, 2);
|
|---|
| 98 |
|
|---|
| 99 | gROOT->SetSelectedPad(NULL);
|
|---|
| 100 |
|
|---|
| 101 | //
|
|---|
| 102 | // This is necessary to get the expected bahviour of DrawClone
|
|---|
| 103 | //
|
|---|
| 104 | c->cd(1);
|
|---|
| 105 | fAlpha->DrawCopy();
|
|---|
| 106 |
|
|---|
| 107 | c->cd(2);
|
|---|
| 108 | fLength->DrawCopy();
|
|---|
| 109 |
|
|---|
| 110 | c->cd(3);
|
|---|
| 111 | fDist->DrawCopy();
|
|---|
| 112 |
|
|---|
| 113 | c->cd(4);
|
|---|
| 114 | fWidth->DrawCopy();
|
|---|
| 115 |
|
|---|
| 116 | c->Modified();
|
|---|
| 117 | c->Update();
|
|---|
| 118 |
|
|---|
| 119 | return c;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | // --------------------------------------------------------------------------
|
|---|
| 123 | //
|
|---|
| 124 | // Creates a new canvas and draws the four histograms into it.
|
|---|
| 125 | // Be careful: The histograms belongs to this object and won't get deleted
|
|---|
| 126 | // together with the canvas.
|
|---|
| 127 | //
|
|---|
| 128 | void MHHillas::Draw(Option_t *)
|
|---|
| 129 | {
|
|---|
| 130 | if (!gPad)
|
|---|
| 131 | MakeDefCanvas("Hillas", "Histograms of Hillas Parameters");
|
|---|
| 132 |
|
|---|
| 133 | gPad->Divide(2,2);
|
|---|
| 134 |
|
|---|
| 135 | gPad->cd(1);
|
|---|
| 136 | fAlpha->Draw();
|
|---|
| 137 |
|
|---|
| 138 | gPad->cd(2);
|
|---|
| 139 | fLength->Draw();
|
|---|
| 140 |
|
|---|
| 141 | gPad->cd(3);
|
|---|
| 142 | fDist->Draw();
|
|---|
| 143 |
|
|---|
| 144 | gPad->cd(4);
|
|---|
| 145 | fWidth->Draw();
|
|---|
| 146 |
|
|---|
| 147 | gPad->Modified();
|
|---|
| 148 | gPad->Update();
|
|---|
| 149 | }
|
|---|