| 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 11/2003 <mailto:markus@ifae.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 25 | //
|
|---|
| 26 | // MCalibrationIntensityHiLoCam
|
|---|
| 27 | //
|
|---|
| 28 | // Storage container for intensity charge calibration results.
|
|---|
| 29 | //
|
|---|
| 30 | // Individual MCalibrationHiLoCam's can be retrieved with:
|
|---|
| 31 | // - GetCam() yielding the current cam.
|
|---|
| 32 | // - GetCam("name") yielding the current camera with name "name".
|
|---|
| 33 | // - GetCam(i) yielding the i-th camera.
|
|---|
| 34 | //
|
|---|
| 35 | // See also: MCalibrationIntensityCam, MCalibrationHiLoCam,
|
|---|
| 36 | // MCalibrationHiLoPix, MCalibrationHiLoCalc, MCalibrationQECam
|
|---|
| 37 | // MHCalibrationHiLoPix, MHCalibrationHiLoCam
|
|---|
| 38 | //
|
|---|
| 39 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 40 | #include "MCalibrationIntensityHiLoCam.h"
|
|---|
| 41 | #include "MCalibrationHiLoCam.h"
|
|---|
| 42 | #include "MCalibrationChargeCam.h"
|
|---|
| 43 | #include "MCalibrationHiLoPix.h"
|
|---|
| 44 | #include "MCalibrationChargePix.h"
|
|---|
| 45 |
|
|---|
| 46 | #include "MGeomCam.h"
|
|---|
| 47 | #include "MGeomPix.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MLogManip.h"
|
|---|
| 50 |
|
|---|
| 51 | #include <TOrdCollection.h>
|
|---|
| 52 | #include <TGraphErrors.h>
|
|---|
| 53 |
|
|---|
| 54 | ClassImp(MCalibrationIntensityHiLoCam);
|
|---|
| 55 |
|
|---|
| 56 | using namespace std;
|
|---|
| 57 |
|
|---|
| 58 | // --------------------------------------------------------------------------
|
|---|
| 59 | //
|
|---|
| 60 | // Default constructor.
|
|---|
| 61 | //
|
|---|
| 62 | MCalibrationIntensityHiLoCam::MCalibrationIntensityHiLoCam(const char *name, const char *title)
|
|---|
| 63 | {
|
|---|
| 64 |
|
|---|
| 65 | fName = name ? name : "MCalibrationIntensityHiLoCam";
|
|---|
| 66 | fTitle = title ? title : "Results of the Intensity Calibration";
|
|---|
| 67 |
|
|---|
| 68 | InitSize(1);
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | // -------------------------------------------------------------------
|
|---|
| 72 | //
|
|---|
| 73 | // Add MCalibrationHiLoCam's in the ranges from - to.
|
|---|
| 74 | //
|
|---|
| 75 | void MCalibrationIntensityHiLoCam::Add(const UInt_t from, const UInt_t to)
|
|---|
| 76 | {
|
|---|
| 77 | for (UInt_t i=from; i<to; i++)
|
|---|
| 78 | fCams->AddAt(new MCalibrationHiLoCam,i);
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | TGraphErrors *MCalibrationIntensityHiLoCam::GetHiLoRatioVsCharge( const UInt_t pixid, const MCalibrationIntensityChargeCam &chargecam,
|
|---|
| 82 | const MCalibrationCam::PulserColor_t col)
|
|---|
| 83 | {
|
|---|
| 84 |
|
|---|
| 85 | if (chargecam.GetSize() != GetSize())
|
|---|
| 86 | {
|
|---|
| 87 | *fLog << err << GetDescriptor() << ": Size mismatch between MCalibrationIntensityHiLoCam "
|
|---|
| 88 | << "and MCalibrationIntensityChargeCam. " << endl;
|
|---|
| 89 | return NULL;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | Int_t size = CountNumEntries(col);
|
|---|
| 93 |
|
|---|
| 94 | if (size == 0)
|
|---|
| 95 | return NULL;
|
|---|
| 96 |
|
|---|
| 97 | if (size != chargecam.CountNumEntries(col))
|
|---|
| 98 | {
|
|---|
| 99 | *fLog << err << GetDescriptor() << ": Size mismatch in colour between MCalibrationIntensityHiLoCam "
|
|---|
| 100 | << "and MCalibrationIntensityChargeCam. " << endl;
|
|---|
| 101 | return NULL;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | const Int_t nvalid = chargecam.CountNumValidEntries(pixid,col);
|
|---|
| 105 |
|
|---|
| 106 | if (nvalid == 0)
|
|---|
| 107 | {
|
|---|
| 108 | *fLog << err << GetDescriptor() << ": Only un-calibrated events in pixel: " << pixid << endl;
|
|---|
| 109 | return NULL;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | TArrayF ratio(nvalid);
|
|---|
| 113 | TArrayF ratioerr(nvalid);
|
|---|
| 114 | TArrayF sig(nvalid);
|
|---|
| 115 | TArrayF sigerr(nvalid);
|
|---|
| 116 |
|
|---|
| 117 | Int_t cnt = 0;
|
|---|
| 118 |
|
|---|
| 119 | for (Int_t i=0;i<GetSize();i++)
|
|---|
| 120 | {
|
|---|
| 121 | //
|
|---|
| 122 | // Get the calibration cam from the intensity cam
|
|---|
| 123 | //
|
|---|
| 124 | MCalibrationChargeCam *cam = (MCalibrationChargeCam*)chargecam.GetCam(i);
|
|---|
| 125 | MCalibrationHiLoCam *hilocam = (MCalibrationHiLoCam*)GetCam(i);
|
|---|
| 126 |
|
|---|
| 127 | if (col != MCalibrationCam::kNONE)
|
|---|
| 128 | if (hilocam->GetPulserColor() != col)
|
|---|
| 129 | continue;
|
|---|
| 130 | //
|
|---|
| 131 | // Get the calibration pix from the calibration cam
|
|---|
| 132 | //
|
|---|
| 133 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*cam)[pixid];
|
|---|
| 134 | MCalibrationHiLoPix &relpix = (MCalibrationHiLoPix&)(*hilocam)[pixid];
|
|---|
| 135 | //
|
|---|
| 136 | // Don't use bad pixels
|
|---|
| 137 | //
|
|---|
| 138 | if (!pix.IsFFactorMethodValid())
|
|---|
| 139 | continue;
|
|---|
| 140 | //
|
|---|
| 141 | ratio[cnt] = relpix.GetHiLoRatio();
|
|---|
| 142 | ratioerr[cnt] = relpix.GetHiLoRatioErr();
|
|---|
| 143 | //
|
|---|
| 144 | sig [cnt] = pix.GetPheFFactorMethod();
|
|---|
| 145 | sigerr[cnt] = pix.GetPheFFactorMethodErr();
|
|---|
| 146 | cnt++;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | TGraphErrors *gr = new TGraphErrors(nvalid,
|
|---|
| 150 | sig.GetArray(),ratio.GetArray(),
|
|---|
| 151 | sigerr.GetArray(),ratioerr.GetArray());
|
|---|
| 152 | gr->SetTitle(Form("%s%3i","Pixel ",pixid));
|
|---|
| 153 | gr->GetXaxis()->SetTitle("<Photo-electrons> [1]");
|
|---|
| 154 | gr->GetYaxis()->SetTitle("HiLo Ratio [1]");
|
|---|
| 155 | return gr;
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 | TGraphErrors *MCalibrationIntensityHiLoCam::GetHiLoRatioVsChargePerArea( const Int_t aidx,const MCalibrationIntensityChargeCam &chargecam, const MGeomCam &geom, const MCalibrationCam::PulserColor_t col)
|
|---|
| 160 | {
|
|---|
| 161 |
|
|---|
| 162 | Int_t size = CountNumEntries(col);
|
|---|
| 163 |
|
|---|
| 164 | if (size == 0)
|
|---|
| 165 | return NULL;
|
|---|
| 166 |
|
|---|
| 167 | if (size != chargecam.CountNumEntries(col))
|
|---|
| 168 | {
|
|---|
| 169 | *fLog << err << GetDescriptor() << ": Size mismatch in colour between MCalibrationIntensityHiLoCam "
|
|---|
| 170 | << "and MCalibrationIntensityChargeCam. " << endl;
|
|---|
| 171 | return NULL;
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | TArrayF ratio(size);
|
|---|
| 175 | TArrayF ratioerr(size);
|
|---|
| 176 | TArrayF sig(size);
|
|---|
| 177 | TArrayF sigerr(size);
|
|---|
| 178 |
|
|---|
| 179 | Int_t cnt = 0;
|
|---|
| 180 |
|
|---|
| 181 | for (Int_t i=0;i<GetSize();i++)
|
|---|
| 182 | {
|
|---|
| 183 | //
|
|---|
| 184 | // Get the calibration cam from the intensity cam
|
|---|
| 185 | //
|
|---|
| 186 | MCalibrationHiLoCam *hilocam = (MCalibrationHiLoCam*)GetCam(i);
|
|---|
| 187 | MCalibrationChargeCam *cam = (MCalibrationChargeCam*)chargecam.GetCam(i);
|
|---|
| 188 |
|
|---|
| 189 | if (col != MCalibrationCam::kNONE)
|
|---|
| 190 | if (hilocam->GetPulserColor() != col)
|
|---|
| 191 | continue;
|
|---|
| 192 |
|
|---|
| 193 | const MCalibrationChargePix &apix = (MCalibrationChargePix&)cam->GetAverageArea(aidx);
|
|---|
| 194 | const Float_t phe = apix.GetPheFFactorMethod();
|
|---|
| 195 | const Float_t pheerr = apix.GetPheFFactorMethodErr();
|
|---|
| 196 |
|
|---|
| 197 | sig[cnt] = phe;
|
|---|
| 198 | sigerr[cnt] = pheerr;
|
|---|
| 199 |
|
|---|
| 200 | Double_t ratiool = 0.;
|
|---|
| 201 | Double_t ratiool2 = 0.;
|
|---|
| 202 | Double_t var = 0.;
|
|---|
| 203 | Int_t num = 0;
|
|---|
| 204 | //
|
|---|
| 205 | // Get the area calibration pix from the calibration cam
|
|---|
| 206 | //
|
|---|
| 207 | for (Int_t i=0; i<cam->GetSize(); i++)
|
|---|
| 208 | {
|
|---|
| 209 | const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*cam)[i];
|
|---|
| 210 | const MCalibrationHiLoPix &relpix = (MCalibrationHiLoPix&)(*hilocam)[i];
|
|---|
| 211 | //
|
|---|
| 212 | // Don't use bad pixels
|
|---|
| 213 | //
|
|---|
| 214 | if (!pix.IsFFactorMethodValid())
|
|---|
| 215 | continue;
|
|---|
| 216 | //
|
|---|
| 217 | //
|
|---|
| 218 | if (aidx != geom[i].GetAidx())
|
|---|
| 219 | continue;
|
|---|
| 220 |
|
|---|
| 221 | ratiool += relpix.GetHiLoRatio();
|
|---|
| 222 | ratiool2 += relpix.GetHiLoRatio()*relpix.GetHiLoRatio();
|
|---|
| 223 | num++;
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | if (num > 1)
|
|---|
| 227 | {
|
|---|
| 228 | ratiool /= num;
|
|---|
| 229 | var = (ratiool2 - ratiool*ratiool*num) / (num-1);
|
|---|
| 230 |
|
|---|
| 231 | ratio[cnt] = ratiool;
|
|---|
| 232 | if (var > 0.)
|
|---|
| 233 | ratioerr[cnt] = TMath::Sqrt(var);
|
|---|
| 234 | else
|
|---|
| 235 | ratioerr[cnt] = 0.;
|
|---|
| 236 | }
|
|---|
| 237 | else
|
|---|
| 238 | {
|
|---|
| 239 | ratio[cnt] = -1.;
|
|---|
| 240 | ratioerr[cnt] = 0.;
|
|---|
| 241 | }
|
|---|
| 242 | cnt++;
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | TGraphErrors *gr = new TGraphErrors(size,
|
|---|
| 246 | sig.GetArray(),ratio.GetArray(),
|
|---|
| 247 | sigerr.GetArray(),ratioerr.GetArray());
|
|---|
| 248 | gr->SetTitle(Form("%s%3i","Area Index ",aidx));
|
|---|
| 249 | gr->GetXaxis()->SetTitle("<phes> [1]");
|
|---|
| 250 | gr->GetYaxis()->SetTitle("HiLo Ratio [1]");
|
|---|
| 251 | return gr;
|
|---|
| 252 | }
|
|---|