| 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): Nicola Galante, 2003 <mailto:nicola.galante@pi.infn.it>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MHMcTriggerLvl2
|
|---|
| 28 | //
|
|---|
| 29 | // This class contains histograms for the Trigger Level2 image parameters
|
|---|
| 30 | //
|
|---|
| 31 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 32 |
|
|---|
| 33 | #include "MHMcTriggerLvl2.h"
|
|---|
| 34 |
|
|---|
| 35 | #include <math.h>
|
|---|
| 36 |
|
|---|
| 37 | #include <TH1.h>
|
|---|
| 38 | #include <TF1.h>
|
|---|
| 39 | #include <TPad.h>
|
|---|
| 40 | #include <TStyle.h>
|
|---|
| 41 | #include <TCanvas.h>
|
|---|
| 42 | #include <TPaveLabel.h>
|
|---|
| 43 |
|
|---|
| 44 | #include "MLog.h"
|
|---|
| 45 | #include "MLogManip.h"
|
|---|
| 46 |
|
|---|
| 47 | #include "MParList.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MMcTriggerLvl2.h"
|
|---|
| 50 | #include "MGeomCam.h"
|
|---|
| 51 | #include "MBinning.h"
|
|---|
| 52 |
|
|---|
| 53 | /*
|
|---|
| 54 | Please, DON'T USE IFDEFS IN SUCH A CONTEXT, Thomas.
|
|---|
| 55 | --------------------------------------------------
|
|---|
| 56 | #ifndef COLOR_LINELPS
|
|---|
| 57 | #define COLOR_LINELPS Int_t colorlps = 1
|
|---|
| 58 | COLOR_LINELPS;
|
|---|
| 59 | #endif
|
|---|
| 60 |
|
|---|
| 61 | #ifndef COLOR_LINESBC
|
|---|
| 62 | #define COLOR_LINESBC Int_t colorsbc = 1
|
|---|
| 63 | COLOR_LINESBC;
|
|---|
| 64 | #endif
|
|---|
| 65 |
|
|---|
| 66 | #ifndef COLOR_LINEPS
|
|---|
| 67 | #define COLOR_LINEPS Int_t colorps = 1
|
|---|
| 68 | COLOR_LINEPS;
|
|---|
| 69 | #endif
|
|---|
| 70 | */
|
|---|
| 71 |
|
|---|
| 72 | /* Use this insteadif you want to have some value which is the same for all
|
|---|
| 73 | your instances of MHMcTriggerLvl2, if not define the values in the constructor
|
|---|
| 74 | and remove the 'static'
|
|---|
| 75 | */
|
|---|
| 76 |
|
|---|
| 77 | Int_t MHMcTriggerLvl2::fColorLps = 1;
|
|---|
| 78 | Int_t MHMcTriggerLvl2::fColorSbc = 1;
|
|---|
| 79 | Int_t MHMcTriggerLvl2::fColorPs = 1;
|
|---|
| 80 |
|
|---|
| 81 | ClassImp(MHMcTriggerLvl2);
|
|---|
| 82 |
|
|---|
| 83 | // --------------------------------------------------------------------------
|
|---|
| 84 | //
|
|---|
| 85 | // Setup three histograms for fLutPseudoSize, fPseudoSize, fSizeBiggerCell
|
|---|
| 86 | //
|
|---|
| 87 | MHMcTriggerLvl2::MHMcTriggerLvl2(const char *name, const char *title)
|
|---|
| 88 | {
|
|---|
| 89 | //
|
|---|
| 90 | // set the name and title of this object
|
|---|
| 91 | //
|
|---|
| 92 | fName = name ? name : "MHMcTriggerLvl2";
|
|---|
| 93 | fTitle = title ? title : "Trigger L2 image parameters";
|
|---|
| 94 |
|
|---|
| 95 | hfLutPseudoSize = new TH1F("hfLutPseudoSize", "number of compact pixels in one lut", 13, 0, 12);
|
|---|
| 96 | hfPseudoSize = new TH1F("hfPseudoSize", "Multiplicity of the cluster identified by the L2T", 13, 0, 12);
|
|---|
| 97 | hfSizeBiggerCell = new TH1F("hfSizeBiggerCell", "Number of fired pixel in bigger cell", 37, 0, 36);
|
|---|
| 98 |
|
|---|
| 99 | hfLutPseudoSizeNorm = new TH1F("hfLutPseudoSizeNorm", "Normalized Number of compact pixels in one lut", 13, 0, 12);
|
|---|
| 100 | hfPseudoSizeNorm = new TH1F("hfPseudoSizeNorm", "Normalized Multiplicity of the cluster identified by the L2T", 13, 0, 12);
|
|---|
| 101 | hfSizeBiggerCellNorm = new TH1F("hfSizeBiggerCellNorm", "Normalized Number of fired pixel in bigger cell", 37, 0, 36);
|
|---|
| 102 |
|
|---|
| 103 | hfLutPseudoSize->SetDirectory(NULL);
|
|---|
| 104 | hfLutPseudoSizeNorm->SetDirectory(NULL);
|
|---|
| 105 | hfPseudoSize->SetDirectory(NULL);
|
|---|
| 106 | hfPseudoSizeNorm->SetDirectory(NULL);
|
|---|
| 107 | hfSizeBiggerCell->SetDirectory(NULL);
|
|---|
| 108 | hfSizeBiggerCellNorm->SetDirectory(NULL);
|
|---|
| 109 |
|
|---|
| 110 | hfLutPseudoSize->SetXTitle("Number of Pixels");
|
|---|
| 111 | hfLutPseudoSizeNorm->SetXTitle("Number of Pixels");
|
|---|
| 112 | hfPseudoSize->SetXTitle("Number of Pixels");
|
|---|
| 113 | hfPseudoSizeNorm->SetXTitle("Number of Pixels");
|
|---|
| 114 | hfSizeBiggerCell->SetXTitle("Number of Pixels");
|
|---|
| 115 | hfSizeBiggerCellNorm->SetXTitle("Number of Pixels");
|
|---|
| 116 |
|
|---|
| 117 | hfLutPseudoSize->SetYTitle("Counts");
|
|---|
| 118 | hfLutPseudoSizeNorm->SetYTitle("Counts/Total Counts");
|
|---|
| 119 | hfPseudoSize->SetYTitle("Counts");
|
|---|
| 120 | hfPseudoSizeNorm->SetYTitle("Counts/Total Counts");
|
|---|
| 121 | hfSizeBiggerCell->SetYTitle("Counts");
|
|---|
| 122 | hfSizeBiggerCellNorm->SetYTitle("Counts/Total Counts");
|
|---|
| 123 |
|
|---|
| 124 | f1 = new TF1("FNorm", "1", -1, 40);
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | // --------------------------------------------------------------------------
|
|---|
| 128 | //
|
|---|
| 129 | // Delete the histograms
|
|---|
| 130 | //
|
|---|
| 131 | MHMcTriggerLvl2::~MHMcTriggerLvl2()
|
|---|
| 132 | {
|
|---|
| 133 | delete hfLutPseudoSize;
|
|---|
| 134 | delete hfPseudoSize;
|
|---|
| 135 | delete hfSizeBiggerCell;
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | // --------------------------------------------------------------------------
|
|---|
| 139 | //
|
|---|
| 140 | // Fill the histograms with data from a MMcTriggerLvl2-Container.
|
|---|
| 141 | // Be careful: Only call this with an object of type MMcTriggerLvl2
|
|---|
| 142 | //
|
|---|
| 143 | Bool_t MHMcTriggerLvl2::Fill(const MParContainer *par)
|
|---|
| 144 | {
|
|---|
| 145 | const MMcTriggerLvl2 &h = *(MMcTriggerLvl2 *)par;
|
|---|
| 146 |
|
|---|
| 147 | hfLutPseudoSize->Fill(h.GetLutPseudoSize());
|
|---|
| 148 | hfPseudoSize->Fill(h.GetPseudoSize());
|
|---|
| 149 | hfSizeBiggerCell->Fill(h.GetSizeBiggerCell());
|
|---|
| 150 |
|
|---|
| 151 | return kTRUE;
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 | // --------------------------------------------------------------------------
|
|---|
| 156 | //
|
|---|
| 157 | // This is the private function member which draw a clone of a histogram.
|
|---|
| 158 | // This method is called by the DrawClone method.
|
|---|
| 159 | //
|
|---|
| 160 | TObject *MHMcTriggerLvl2::DrawHist(TH1 &hist, TH1 &histNorm, const TString &canvasname, Int_t &col) const
|
|---|
| 161 | {
|
|---|
| 162 | col++;
|
|---|
| 163 |
|
|---|
| 164 | TCanvas *c = (TCanvas*)gROOT->FindObject(canvasname);
|
|---|
| 165 |
|
|---|
| 166 | Bool_t same = kTRUE;
|
|---|
| 167 | if (!c)
|
|---|
| 168 | {
|
|---|
| 169 | c = MakeDefCanvas(canvasname,canvasname, 800, 610);
|
|---|
| 170 | c->Divide(2,1);
|
|---|
| 171 | same = kFALSE;
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | c->cd(1);
|
|---|
| 175 | hist.SetLineColor(col);
|
|---|
| 176 | hist.DrawCopy(same?"same":"");
|
|---|
| 177 |
|
|---|
| 178 | c->cd(2);
|
|---|
| 179 | histNorm.SetLineColor(col);
|
|---|
| 180 | histNorm.DrawCopy(same?"same":"");
|
|---|
| 181 |
|
|---|
| 182 | return c;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 | // --------------------------------------------------------------------------
|
|---|
| 187 | //
|
|---|
| 188 | // Draw a clone of a data member histogram. So that the object can be deleted
|
|---|
| 189 | // and the histogram is still visible in the canvas.
|
|---|
| 190 | // The cloned object are deleted together with the canvas if the canvas is
|
|---|
| 191 | // destroyed. If you want to handle dostroying the canvas you can get a
|
|---|
| 192 | // pointer to it from this function
|
|---|
| 193 | // Possible options are:
|
|---|
| 194 | // "lps" for the fLutPseudoSize histogram;
|
|---|
| 195 | // "sbc" for the fSizeBiggerCell histogram;
|
|---|
| 196 | // "ps" for the fPseudoSize histogram;
|
|---|
| 197 | // default: "ps"
|
|---|
| 198 | //
|
|---|
| 199 | TObject *MHMcTriggerLvl2::DrawClone(Option_t *opt) const
|
|---|
| 200 | {
|
|---|
| 201 | TString str(opt);
|
|---|
| 202 |
|
|---|
| 203 | if (str.IsNull())
|
|---|
| 204 | str = "ps";
|
|---|
| 205 |
|
|---|
| 206 | if (!str.Contains("lps", TString::kIgnoreCase) &&
|
|---|
| 207 | !str.Contains("sbc", TString::kIgnoreCase) &&
|
|---|
| 208 | !str.Contains("ps", TString::kIgnoreCase))
|
|---|
| 209 | {
|
|---|
| 210 | *fLog << "ARGH!@! Possible options are \"lps\", \"sbc\", \"ps\" or NULL!" <<endl;
|
|---|
| 211 | return NULL;
|
|---|
| 212 | }
|
|---|
| 213 |
|
|---|
| 214 | TH1 *hist=NormalizeHist(hfLutPseudoSizeNorm, hfLutPseudoSize);
|
|---|
| 215 |
|
|---|
| 216 | if (!hist)
|
|---|
| 217 | return NULL;
|
|---|
| 218 |
|
|---|
| 219 | if (str.Contains("lps",TString::kIgnoreCase))
|
|---|
| 220 | return DrawHist(*hfLutPseudoSize, *hist, "CanvasLPS", fColorLps);
|
|---|
| 221 |
|
|---|
| 222 | if (str.Contains("sbc",TString::kIgnoreCase))
|
|---|
| 223 | return DrawHist(*hfSizeBiggerCell, *hist, "CanvasSBC", fColorSbc);
|
|---|
| 224 |
|
|---|
| 225 | if (str.Contains("ps",TString::kIgnoreCase))
|
|---|
| 226 | return DrawHist(*hfPseudoSize, *hist, "CanvasPS", fColorPs);
|
|---|
| 227 |
|
|---|
| 228 | return NULL;
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 | // --------------------------------------------------------------------------
|
|---|
| 234 | //
|
|---|
| 235 | // Creates a new canvas and draws the three histograms into it.
|
|---|
| 236 | // Be careful: The histograms belongs to this object and won't get deleted
|
|---|
| 237 | // together with the canvas.
|
|---|
| 238 | //
|
|---|
| 239 | void MHMcTriggerLvl2::Draw(Option_t *)
|
|---|
| 240 | {
|
|---|
| 241 | MakeDefCanvas("c","L2T Parameters", 720, 810);
|
|---|
| 242 |
|
|---|
| 243 | TPad* pad1 = new TPad("pad1","Pad with fLutPseudoSize", 0.003, 0.7, 0.4, 0.997);
|
|---|
| 244 | TPad* pad2 = new TPad("pad2","Pad with fSizeBiggerCell", 0.403, 0.7, 0.997, 0.997);
|
|---|
| 245 | TPad* pad3 = new TPad("pad3","Pad with fPseudoSize", 0.003, 0.003, 0.997, 0.697);
|
|---|
| 246 | pad1->Draw();
|
|---|
| 247 | pad2->Draw();
|
|---|
| 248 | pad3->Draw();
|
|---|
| 249 |
|
|---|
| 250 | pad1->cd();
|
|---|
| 251 | hfLutPseudoSize->Draw();
|
|---|
| 252 |
|
|---|
| 253 | pad2->cd();
|
|---|
| 254 | hfSizeBiggerCell->Draw();
|
|---|
| 255 |
|
|---|
| 256 | pad3->cd();
|
|---|
| 257 | hfPseudoSize->Draw();
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 | // --------------------------------------------------------------------------
|
|---|
| 263 | //
|
|---|
| 264 | // Return the histogram by its name
|
|---|
| 265 | //
|
|---|
| 266 | TH1 *MHMcTriggerLvl2::GetHistByName(const TString name)
|
|---|
| 267 | {
|
|---|
| 268 | if (name.Contains("hfLutPseudoSize", TString::kIgnoreCase))
|
|---|
| 269 | return hfLutPseudoSize;
|
|---|
| 270 | if (name.Contains("hfSizeBiggerCell", TString::kIgnoreCase))
|
|---|
| 271 | return hfSizeBiggerCell;
|
|---|
| 272 | if (name.Contains("hfPseudoSize", TString::kIgnoreCase))
|
|---|
| 273 | return hfPseudoSize;
|
|---|
| 274 |
|
|---|
| 275 | if (name.Contains("hfLutPseudoSizeNorm", TString::kIgnoreCase))
|
|---|
| 276 | return hfLutPseudoSizeNorm;
|
|---|
| 277 | if (name.Contains("hfSizeBiggerCellNorm", TString::kIgnoreCase))
|
|---|
| 278 | return hfSizeBiggerCellNorm;
|
|---|
| 279 | if (name.Contains("hfPseudoSizeNorm", TString::kIgnoreCase))
|
|---|
| 280 | return hfPseudoSizeNorm;
|
|---|
| 281 |
|
|---|
| 282 | return NULL;
|
|---|
| 283 | }
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 | // --------------------------------------------------------------------------
|
|---|
| 288 | //
|
|---|
| 289 | // Normalize the histogram on its integral, i.e. normalize the
|
|---|
| 290 | // values of the histogram on the statistics. This method creates
|
|---|
| 291 | // a copy (histNorm) of the histogram to normalize (hist) and normalize
|
|---|
| 292 | // the copy (histNorm) on its integral. It returns histNorm.
|
|---|
| 293 | //
|
|---|
| 294 | TH1 *MHMcTriggerLvl2::NormalizeHist(TH1 *histNorm, TH1 *hist) const
|
|---|
| 295 | {
|
|---|
| 296 | if (histNorm == hist){
|
|---|
| 297 | *fLog << "ARGH!@! You cannot pass the same histogram into each argument!" << endl;
|
|---|
| 298 | return NULL;
|
|---|
| 299 | }
|
|---|
| 300 |
|
|---|
| 301 | if ((hist == NULL) || (hist->Integral() == (Stat_t)0)){
|
|---|
| 302 | *fLog << "ARGH!@! You are trying to normalize the histogram to 0!" << endl;
|
|---|
| 303 | return NULL;
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 | histNorm->Reset("ICE");
|
|---|
| 307 | histNorm->Add(hist, 1);
|
|---|
| 308 | histNorm->Divide(f1, (Double_t)(hist->Integral()));
|
|---|
| 309 |
|
|---|
| 310 | return histNorm;
|
|---|
| 311 | }
|
|---|