| 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): Markus Gaug 02/2004 <mailto:markus@ifae.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 25 | //
|
|---|
| 26 | // MHCalibrationChargeBlindCam
|
|---|
| 27 | //
|
|---|
| 28 | // Histogram class for blind pixels in the camera. Incorporates the TObjArray's:
|
|---|
| 29 | // - fBlindPixelsArray (for calibrated High Gains per pixel)
|
|---|
| 30 | //
|
|---|
| 31 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 32 | #include "MHCalibrationChargeBlindCam.h"
|
|---|
| 33 | #include "MHCalibrationChargeBlindPix.h"
|
|---|
| 34 |
|
|---|
| 35 | #include <TVirtualPad.h>
|
|---|
| 36 | #include <TCanvas.h>
|
|---|
| 37 | #include <TPad.h>
|
|---|
| 38 |
|
|---|
| 39 | #include "MLog.h"
|
|---|
| 40 | #include "MLogManip.h"
|
|---|
| 41 |
|
|---|
| 42 | #include "MCalibrationChargeBlindPix.h"
|
|---|
| 43 | #include "MCalibrationChargeBlindCam.h"
|
|---|
| 44 |
|
|---|
| 45 | #include "MExtractedSignalBlindPixel.h"
|
|---|
| 46 |
|
|---|
| 47 | #include "MParList.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MRawRunHeader.h"
|
|---|
| 50 |
|
|---|
| 51 | ClassImp(MHCalibrationChargeBlindCam);
|
|---|
| 52 |
|
|---|
| 53 | using namespace std;
|
|---|
| 54 |
|
|---|
| 55 | // --------------------------------------------------------------------------
|
|---|
| 56 | //
|
|---|
| 57 | // Default Constructor.
|
|---|
| 58 | //
|
|---|
| 59 | // Sets:
|
|---|
| 60 | // - all pointers to NULL
|
|---|
| 61 | //
|
|---|
| 62 | // Initializes and sets owner of:
|
|---|
| 63 | // - fBlindPixelsArray
|
|---|
| 64 | //
|
|---|
| 65 | MHCalibrationChargeBlindCam::MHCalibrationChargeBlindCam(const char *name, const char *title)
|
|---|
| 66 | : fCam(NULL), fRunHeader(NULL)
|
|---|
| 67 | {
|
|---|
| 68 |
|
|---|
| 69 | fBlindPixelsArray = new TObjArray;
|
|---|
| 70 | fBlindPixelsArray->SetOwner();
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | // --------------------------------------------------------------------------
|
|---|
| 74 | //
|
|---|
| 75 | // Deletes the TClonesArray of:
|
|---|
| 76 | // - fBlindPixelsArray
|
|---|
| 77 | //
|
|---|
| 78 | MHCalibrationChargeBlindCam::~MHCalibrationChargeBlindCam()
|
|---|
| 79 | {
|
|---|
| 80 | delete fBlindPixelsArray;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | // --------------------------------------------------------------------------
|
|---|
| 84 | //
|
|---|
| 85 | // Get i-th High Gain pixel (pixel number)
|
|---|
| 86 | //
|
|---|
| 87 | MHCalibrationChargeBlindPix &MHCalibrationChargeBlindCam::operator[](UInt_t i)
|
|---|
| 88 | {
|
|---|
| 89 | return *static_cast<MHCalibrationChargeBlindPix*>(fBlindPixelsArray->UncheckedAt(i));
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | // --------------------------------------------------------------------------
|
|---|
| 93 | //
|
|---|
| 94 | // Get i-th High Gain pixel (pixel number)
|
|---|
| 95 | //
|
|---|
| 96 | const MHCalibrationChargeBlindPix &MHCalibrationChargeBlindCam::operator[](UInt_t i) const
|
|---|
| 97 | {
|
|---|
| 98 | return *static_cast<MHCalibrationChargeBlindPix*>(fBlindPixelsArray->UncheckedAt(i));
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | // --------------------------------------------------------------------------
|
|---|
| 102 | //
|
|---|
| 103 | // Our own clone function is necessary since root 3.01/06 or Mars 0.4
|
|---|
| 104 | // I don't know the reason.
|
|---|
| 105 | //
|
|---|
| 106 | // Creates new MHCalibrationChargeBlindCam
|
|---|
| 107 | // Deletes the TObjArray's and Clones them individually
|
|---|
| 108 | //
|
|---|
| 109 | TObject *MHCalibrationChargeBlindCam::Clone(const char *) const
|
|---|
| 110 | {
|
|---|
| 111 |
|
|---|
| 112 | const Int_t nhi = fBlindPixelsArray->GetEntries();
|
|---|
| 113 |
|
|---|
| 114 | //
|
|---|
| 115 | // FIXME, this might be done faster and more elegant, by direct copy.
|
|---|
| 116 | //
|
|---|
| 117 | MHCalibrationChargeBlindCam *cam = new MHCalibrationChargeBlindCam();
|
|---|
| 118 |
|
|---|
| 119 | cam->fBlindPixelsArray->Expand(nhi);
|
|---|
| 120 |
|
|---|
| 121 | for (int i=0; i<nhi; i++)
|
|---|
| 122 | (*cam->fBlindPixelsArray)[i] = (*fBlindPixelsArray)[i]->Clone();
|
|---|
| 123 |
|
|---|
| 124 | return cam;
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | // --------------------------------------------------------------------------
|
|---|
| 128 | //
|
|---|
| 129 | // Gets the pointers to:
|
|---|
| 130 | // - MRunHeader
|
|---|
| 131 | // - MExtractedSignalBlindPix
|
|---|
| 132 | //
|
|---|
| 133 | // Calls Delete-Function of:
|
|---|
| 134 | // - MHCalibrationChargeBlindCam::fBlindPixelsArray
|
|---|
| 135 | //
|
|---|
| 136 | Bool_t MHCalibrationChargeBlindCam::SetupFill(const MParList *pList)
|
|---|
| 137 | {
|
|---|
| 138 |
|
|---|
| 139 | fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 140 | if (!fRunHeader)
|
|---|
| 141 | {
|
|---|
| 142 | *fLog << warn << GetDescriptor()
|
|---|
| 143 | << ": MRawRunHeader not found... will not store run numbers." << endl;
|
|---|
| 144 | return kFALSE;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | fSignal = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel");
|
|---|
| 148 | if (!fSignal)
|
|---|
| 149 | {
|
|---|
| 150 | *fLog << err << "MExtractedSignalBlindPixel not found... aborting " << endl;
|
|---|
| 151 | return kFALSE;
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | fBlindPixelsArray->Delete();
|
|---|
| 155 |
|
|---|
| 156 | return kTRUE;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | // --------------------------------------------------------------------------
|
|---|
| 161 | //
|
|---|
| 162 | // Initializes, if empty to MExtractedSignalCam::GetSize() for:
|
|---|
| 163 | // - MHCalibrationChargeBlindCam::fBlindPixelsArray
|
|---|
| 164 | //
|
|---|
| 165 | // Calls InitializeHists() for every entry in:
|
|---|
| 166 | // - MHCalibrationChargeBlindCam::fBlindPixelsArray
|
|---|
| 167 | //
|
|---|
| 168 | // Retrieves the run numbers from MRawRunHeader and stores them in fRunNumbers
|
|---|
| 169 | //
|
|---|
| 170 | Bool_t MHCalibrationChargeBlindCam::ReInit(MParList *pList)
|
|---|
| 171 | {
|
|---|
| 172 |
|
|---|
| 173 | const Int_t nblindpixels = fSignal->GetNumBlindPixels();
|
|---|
| 174 |
|
|---|
| 175 | Int_t runnr = 0;
|
|---|
| 176 |
|
|---|
| 177 | if (fRunHeader)
|
|---|
| 178 | runnr = fRunHeader->GetRunNumber();
|
|---|
| 179 |
|
|---|
| 180 | fCam = (MCalibrationChargeBlindCam*)pList->FindCreateObj("MCalibrationChargeBlindCam");
|
|---|
| 181 | if (!fCam)
|
|---|
| 182 | {
|
|---|
| 183 | *fLog << err << "Cannot find nor create MCalibrationChargeBlindCam ... abort." << endl;
|
|---|
| 184 | return kFALSE;
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | fCam->InitSize(nblindpixels);
|
|---|
| 188 |
|
|---|
| 189 | const Int_t samples = fSignal->GetNumFADCSamples();
|
|---|
| 190 | const Int_t integ = fSignal->IsExtractionType( MExtractBlindPixel::kIntegral );
|
|---|
| 191 |
|
|---|
| 192 | if (fBlindPixelsArray->GetEntries()==0)
|
|---|
| 193 | {
|
|---|
| 194 |
|
|---|
| 195 | fBlindPixelsArray->Expand(nblindpixels);
|
|---|
| 196 |
|
|---|
| 197 | for (Int_t i=0; i<nblindpixels; i++)
|
|---|
| 198 | {
|
|---|
| 199 | (*fBlindPixelsArray)[i] = new MHCalibrationChargeBlindPix;
|
|---|
| 200 | (*this)[i].ChangeHistId(i);
|
|---|
| 201 | if (integ)
|
|---|
| 202 | {
|
|---|
| 203 | (*this)[i].SetLast( samples * integ *
|
|---|
| 204 | ((*this)[i].GetLast()+0.5) - 0.5 );
|
|---|
| 205 | (*this)[i].SetSinglePheCut( samples * integ *
|
|---|
| 206 | (*this)[i].GetSinglePheCut() );
|
|---|
| 207 | }
|
|---|
| 208 | (*this)[i].InitBins();
|
|---|
| 209 | TH1F *h = (*this)[i].GetHGausHist();
|
|---|
| 210 | h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
|
|---|
| 211 | (*this)[i].SetupFill(pList);
|
|---|
| 212 | (*this)[i].SetCalibrationChargeBlindPix(&(*fCam)[i]);
|
|---|
| 213 | }
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | for (Int_t i=0; i<nblindpixels; i++)
|
|---|
| 217 | {
|
|---|
| 218 | TH1F *h = (*this)[i].GetHGausHist();
|
|---|
| 219 | h->SetTitle( Form("%s%i%s", h->GetTitle(),runnr," "));
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | return kTRUE;
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 | //--------------------------------------------------------------------------------
|
|---|
| 227 | //
|
|---|
| 228 | // Retrieves from MExtractedSignalBlindPixel:
|
|---|
| 229 | // - number of blind pixels
|
|---|
| 230 | //
|
|---|
| 231 | // For all TObjArray's, the following steps are performed:
|
|---|
| 232 | //
|
|---|
| 233 | // 1) Test size and return kFALSE if not matching
|
|---|
| 234 | // 2)
|
|---|
| 235 | //
|
|---|
| 236 | Bool_t MHCalibrationChargeBlindCam::Fill(const MParContainer *par, const Stat_t w)
|
|---|
| 237 | {
|
|---|
| 238 |
|
|---|
| 239 | const Int_t nblindpixels = fSignal->GetNumBlindPixels();
|
|---|
| 240 |
|
|---|
| 241 | if (GetSize() != nblindpixels)
|
|---|
| 242 | {
|
|---|
| 243 | gLog << err << "ERROR - Size mismatch... abort." << endl;
|
|---|
| 244 | return kFALSE;
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | for (Int_t i=0; i<nblindpixels; i++)
|
|---|
| 248 | (*this)[i].Fill(par,w);
|
|---|
| 249 |
|
|---|
| 250 | return kTRUE;
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | // --------------------------------------------------------------------------
|
|---|
| 254 | //
|
|---|
| 255 | // Calls the Finalize() function of the blind pixels
|
|---|
| 256 | //
|
|---|
| 257 | Bool_t MHCalibrationChargeBlindCam::Finalize()
|
|---|
| 258 | {
|
|---|
| 259 |
|
|---|
| 260 | for (Int_t i=0; i<GetSize(); i++)
|
|---|
| 261 | if (!(*this)[i].Finalize())
|
|---|
| 262 | return kFALSE;
|
|---|
| 263 |
|
|---|
| 264 | return kTRUE;
|
|---|
| 265 | }
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 | // -----------------------------------------------------------------------------
|
|---|
| 270 | //
|
|---|
| 271 | // Default draw:
|
|---|
| 272 | //
|
|---|
| 273 | // Displays the averaged areas, both High Gain and Low Gain
|
|---|
| 274 | //
|
|---|
| 275 | // Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
|
|---|
| 276 | //
|
|---|
| 277 | void MHCalibrationChargeBlindCam::Draw(const Option_t *opt)
|
|---|
| 278 | {
|
|---|
| 279 |
|
|---|
| 280 | const Int_t size = fBlindPixelsArray->GetEntries();
|
|---|
| 281 | if (size == 0)
|
|---|
| 282 | return;
|
|---|
| 283 |
|
|---|
| 284 | TString option(opt);
|
|---|
| 285 | option.ToLower();
|
|---|
| 286 |
|
|---|
| 287 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
|---|
| 288 | pad->SetBorderMode(0);
|
|---|
| 289 | pad->Divide(size/2+1,size/2+1);
|
|---|
| 290 |
|
|---|
| 291 | for (Int_t i=0; i<size;i++)
|
|---|
| 292 | {
|
|---|
| 293 | pad->cd(i+1);
|
|---|
| 294 | (*this)[i].Draw(option);
|
|---|
| 295 | }
|
|---|
| 296 | }
|
|---|