| 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 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MHBadPixels
|
|---|
| 28 | //
|
|---|
| 29 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 30 | #include "MHBadPixels.h"
|
|---|
| 31 |
|
|---|
| 32 | #include <TCanvas.h>
|
|---|
| 33 |
|
|---|
| 34 | #include "MPointingPos.h"
|
|---|
| 35 | #include "MBadPixelsCam.h"
|
|---|
| 36 | #include "MGeomCam.h"
|
|---|
| 37 | #include "MPedPhotCam.h"
|
|---|
| 38 | #include "MParList.h"
|
|---|
| 39 | #include "MBinning.h"
|
|---|
| 40 |
|
|---|
| 41 | #include "MLog.h"
|
|---|
| 42 | #include "MLogManip.h"
|
|---|
| 43 |
|
|---|
| 44 | ClassImp(MHBadPixels);
|
|---|
| 45 |
|
|---|
| 46 | using namespace std;
|
|---|
| 47 |
|
|---|
| 48 | // -------------------------------------------------------------------------
|
|---|
| 49 | //
|
|---|
| 50 | // Constructor.
|
|---|
| 51 | //
|
|---|
| 52 | MHBadPixels::MHBadPixels(const char *name, const char *title)
|
|---|
| 53 | {
|
|---|
| 54 | fName = name ? name : "MHBadPixels";
|
|---|
| 55 | fTitle = title ? title : "Histogram for Bad Pixels vs. Theta";
|
|---|
| 56 |
|
|---|
| 57 | fBadId = new TH2D;
|
|---|
| 58 | fBadId->SetName("2D-IdBadPixels");
|
|---|
| 59 | fBadId->SetTitle("2D-IdBadPixels");
|
|---|
| 60 | fBadId->SetDirectory(NULL);
|
|---|
| 61 | fBadId->UseCurrentStyle();
|
|---|
| 62 | fBadId->SetXTitle("\\Theta [\\circ]");
|
|---|
| 63 | fBadId->SetYTitle("pixel Id");
|
|---|
| 64 | fBadId->SetTitleOffset(1.2, "Y");
|
|---|
| 65 |
|
|---|
| 66 | fBadN = new TH2D;
|
|---|
| 67 | fBadN->SetName("2D-NBadPixels");
|
|---|
| 68 | fBadN->SetTitle("2D-NBadPixels");
|
|---|
| 69 | fBadN->SetDirectory(NULL);
|
|---|
| 70 | fBadN->UseCurrentStyle();
|
|---|
| 71 | fBadN->SetXTitle("\\Theta [\\circ]");
|
|---|
| 72 | fBadN->SetYTitle("number of bad pixels");
|
|---|
| 73 | fBadN->SetTitleOffset(1.2, "Y");
|
|---|
| 74 |
|
|---|
| 75 | // define default binnings
|
|---|
| 76 | fBinsTheta = new MBinning;
|
|---|
| 77 | fBinsTheta->SetEdgesCos(10, 0.0, 90.0); // theta
|
|---|
| 78 |
|
|---|
| 79 | fBinsPix = new MBinning;
|
|---|
| 80 | fBinsPix->SetEdges(578, -0.5, 577.5); // pixel id
|
|---|
| 81 |
|
|---|
| 82 | SetBinning(fBadId, fBinsTheta, fBinsPix);
|
|---|
| 83 | SetBinning(fBadN, fBinsTheta, fBinsPix);
|
|---|
| 84 |
|
|---|
| 85 | //-----------------------------------------
|
|---|
| 86 | fNamePedPhotCam = "MPedPhotCamFromData";
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | // -------------------------------------------------------------------------
|
|---|
| 91 | //
|
|---|
| 92 | // Destructor.
|
|---|
| 93 | //
|
|---|
| 94 | MHBadPixels::~MHBadPixels()
|
|---|
| 95 | {
|
|---|
| 96 | delete fBadId;
|
|---|
| 97 | delete fBadN;
|
|---|
| 98 |
|
|---|
| 99 | delete fBinsTheta;
|
|---|
| 100 | delete fBinsPix;
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | // --------------------------------------------------------------------------
|
|---|
| 104 | //
|
|---|
| 105 | // Set the binnings and prepare the filling of the histogram
|
|---|
| 106 | //
|
|---|
| 107 | Bool_t MHBadPixels::SetupFill(const MParList *plist)
|
|---|
| 108 | {
|
|---|
| 109 | fCam = (MGeomCam*)plist->FindObject(AddSerialNumber("MGeomCam"));
|
|---|
| 110 | if (!fCam)
|
|---|
| 111 | {
|
|---|
| 112 | *fLog << err << "MHBadPixels::SetupFill; MGeomCam not found... aborting." << endl;
|
|---|
| 113 | return kFALSE;
|
|---|
| 114 | }
|
|---|
| 115 | *fLog << "MHBadPixels::SetupFill; fCam = " << fCam << endl;
|
|---|
| 116 |
|
|---|
| 117 | fPointPos = (MPointingPos*)plist->FindObject("MPointingPos");
|
|---|
| 118 | if (!fPointPos)
|
|---|
| 119 | {
|
|---|
| 120 | *fLog << err << "MPointingPos not found... aborting." << endl;
|
|---|
| 121 | return kFALSE;
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | fPedPhot = (MPedPhotCam*)plist->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam");
|
|---|
| 125 | if (!fPedPhot)
|
|---|
| 126 | {
|
|---|
| 127 | *fLog << err << AddSerialNumber(fNamePedPhotCam)
|
|---|
| 128 | << "[MPedPhotCam] not found... aborting." << endl;
|
|---|
| 129 | return kFALSE;
|
|---|
| 130 | }
|
|---|
| 131 | fPedPhot->InitSize(fCam->GetNumPixels());
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 | //----------------------------------------------------
|
|---|
| 135 | *fLog << inf << "Name of MPedPhotCam container : " << fNamePedPhotCam
|
|---|
| 136 | << endl;
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 | //----------------------------------------------------
|
|---|
| 140 | // redefine the binnings
|
|---|
| 141 |
|
|---|
| 142 | // Get Theta Binning
|
|---|
| 143 | const MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
|
|---|
| 144 | if (!binstheta)
|
|---|
| 145 | {
|
|---|
| 146 | *fLog << err << "Object 'BinningTheta' [MBinning] not found... use default binning." << endl;
|
|---|
| 147 | binstheta = fBinsTheta;
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | // Define binning for pixel number
|
|---|
| 151 | const UInt_t npix1 = fPedPhot->GetSize()+1;
|
|---|
| 152 | //*fLog << "MHBadPixels::SetupFill(); npix1 = " << npix1 << endl;
|
|---|
| 153 | MBinning binspix("BinningPixel");
|
|---|
| 154 | binspix.SetEdges(npix1, -0.5, npix1-0.5);
|
|---|
| 155 |
|
|---|
| 156 | // Set binnings in histograms
|
|---|
| 157 | SetBinning(fBadId, binstheta, &binspix);
|
|---|
| 158 | SetBinning(fBadN, binstheta, &binspix);
|
|---|
| 159 |
|
|---|
| 160 | *fLog << "MHBadPixels::SetupFill(); binnings were set" << endl;
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 | return kTRUE;
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | // ------------------------------------------------------------------------
|
|---|
| 168 | //
|
|---|
| 169 | // Fill the histograms
|
|---|
| 170 | //
|
|---|
| 171 |
|
|---|
| 172 | Bool_t MHBadPixels::Fill(const MParContainer *par, const Stat_t w)
|
|---|
| 173 | {
|
|---|
| 174 | if (!par)
|
|---|
| 175 | return kFALSE;
|
|---|
| 176 |
|
|---|
| 177 | Double_t theta = fPointPos->GetZd();
|
|---|
| 178 |
|
|---|
| 179 | const MBadPixelsCam *fBadPixels = (MBadPixelsCam*)par;
|
|---|
| 180 |
|
|---|
| 181 | const UInt_t entries = fPedPhot->GetSize();
|
|---|
| 182 | UInt_t nb = 0;
|
|---|
| 183 | for (UInt_t i=0; i<entries; i++)
|
|---|
| 184 | {
|
|---|
| 185 | //*fLog << "MHBadPixels::Fill; i = " << i << endl;
|
|---|
| 186 |
|
|---|
| 187 | if ( (*fBadPixels)[i].IsUnsuitable() )
|
|---|
| 188 | {
|
|---|
| 189 | //*fLog << "MHBadPixels::Fill; (UnSuitable) " << endl;
|
|---|
| 190 |
|
|---|
| 191 | fBadId->Fill(theta, i, w);
|
|---|
| 192 | nb++;
|
|---|
| 193 | }
|
|---|
| 194 | }
|
|---|
| 195 | fBadN->Fill(theta, nb, w);
|
|---|
| 196 |
|
|---|
| 197 | return kTRUE;
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | // --------------------------------------------------------------------
|
|---|
| 201 | //
|
|---|
| 202 | // Draw the histograms
|
|---|
| 203 | //
|
|---|
| 204 | void MHBadPixels::Draw(Option_t *option)
|
|---|
| 205 | {
|
|---|
| 206 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
|---|
| 207 | pad->SetBorderMode(0);
|
|---|
| 208 |
|
|---|
| 209 | pad->Divide(2,2);
|
|---|
| 210 |
|
|---|
| 211 | TH1D *h;
|
|---|
| 212 |
|
|---|
| 213 | pad->cd(1);
|
|---|
| 214 | fBadId->Draw(option);
|
|---|
| 215 |
|
|---|
| 216 | pad->cd(2);
|
|---|
| 217 | fBadN->Draw(option);
|
|---|
| 218 |
|
|---|
| 219 | pad->cd(3);
|
|---|
| 220 | gPad->SetBorderMode(0);
|
|---|
| 221 | h = ((TH2*)fBadId)->ProjectionY("ProjY-pixId", -1, 9999, "");
|
|---|
| 222 | h->SetDirectory(NULL);
|
|---|
| 223 | h->SetTitle("Distribution of bad pixel Id");
|
|---|
| 224 | h->SetXTitle("Id of bad pixel");
|
|---|
| 225 | h->SetYTitle("No. of events");
|
|---|
| 226 | h->SetTitleOffset(1.2, "Y");
|
|---|
| 227 | h->Draw(option);
|
|---|
| 228 | h->SetBit(kCanDelete);
|
|---|
| 229 |
|
|---|
| 230 | pad->cd(4);
|
|---|
| 231 | gPad->SetBorderMode(0);
|
|---|
| 232 | h = ((TH2*)fBadN)->ProjectionY("ProjY-pixN", -1, 9999, "");
|
|---|
| 233 | h->SetDirectory(NULL);
|
|---|
| 234 | h->SetTitle("Distribution of no.of bad pixels");
|
|---|
| 235 | h->SetXTitle("No. of bad pixels");
|
|---|
| 236 | h->SetYTitle("No. of events");
|
|---|
| 237 | h->SetTitleOffset(1.2, "Y");
|
|---|
| 238 | h->Draw(option);
|
|---|
| 239 | h->SetBit(kCanDelete);
|
|---|
| 240 |
|
|---|
| 241 | pad->Modified();
|
|---|
| 242 | pad->Update();
|
|---|
| 243 | }
|
|---|
| 244 | //==========================================================================
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|