| 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 07/2004 <mailto:markus@ifae.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MCalibrationBlindCam
|
|---|
| 28 | //
|
|---|
| 29 | // Base class for Blind Pixels Calibration results. Derived classes intialize
|
|---|
| 30 | // the actual values of the MCalibrationBlindPix's.
|
|---|
| 31 | //
|
|---|
| 32 | // Contains TObjArrays for the following objects:
|
|---|
| 33 | // - fBlindPixels: Array of classes derived from MCalibrationBlindPix, one entry
|
|---|
| 34 | // per blind pixel.
|
|---|
| 35 | //
|
|---|
| 36 | // All TObjArrays have to enlarged by the corresponding calls to (e.g. in MGeomApply):
|
|---|
| 37 | // - InitSize()
|
|---|
| 38 | //
|
|---|
| 39 | // See also: MCalibrationBlindCamOneOldStyle
|
|---|
| 40 | //
|
|---|
| 41 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 42 | #include "MCalibrationBlindCam.h"
|
|---|
| 43 | #include "MCalibrationBlindPix.h"
|
|---|
| 44 |
|
|---|
| 45 | #include <TObjArray.h>
|
|---|
| 46 |
|
|---|
| 47 | #include "MLogManip.h"
|
|---|
| 48 |
|
|---|
| 49 | ClassImp(MCalibrationBlindCam);
|
|---|
| 50 |
|
|---|
| 51 | using namespace std;
|
|---|
| 52 | // --------------------------------------------------------------------------
|
|---|
| 53 | //
|
|---|
| 54 | // Default constructor.
|
|---|
| 55 | //
|
|---|
| 56 | MCalibrationBlindCam::MCalibrationBlindCam(Int_t nblind,const char *name, const char *title)
|
|---|
| 57 | {
|
|---|
| 58 |
|
|---|
| 59 | fName = name ? name : "MCalibrationBlindCam";
|
|---|
| 60 | fTitle = title ? title : "Calibration Information of blinded pixels in camera";
|
|---|
| 61 |
|
|---|
| 62 | InitSize(nblind);
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | void MCalibrationBlindCam::Add(const UInt_t a, const UInt_t b)
|
|---|
| 66 | {
|
|---|
| 67 | for (UInt_t i=a; i<b; i++)
|
|---|
| 68 | (*fPixels)[i] = new MCalibrationBlindPix;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | // --------------------------------------------------------------------------
|
|---|
| 72 | //
|
|---|
| 73 | // Copy 'constructor'
|
|---|
| 74 | //
|
|---|
| 75 | void MCalibrationBlindCam::Copy(TObject& object) const
|
|---|
| 76 | {
|
|---|
| 77 |
|
|---|
| 78 | MCalibrationBlindCam &calib = (MCalibrationBlindCam&)object;
|
|---|
| 79 |
|
|---|
| 80 | // MParContainer::Copy(calib);
|
|---|
| 81 |
|
|---|
| 82 | const UInt_t n = GetSize();
|
|---|
| 83 | if (n != 0)
|
|---|
| 84 | {
|
|---|
| 85 | calib.InitSize(n);
|
|---|
| 86 | for (UInt_t i=0; i<n; i++)
|
|---|
| 87 | (*this)[i].Copy(calib[i]);
|
|---|
| 88 | }
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | // --------------------------------------------------------------------------
|
|---|
| 93 | //
|
|---|
| 94 | // Expands and creates new MCalibrationPix's. Cannot use ExpandCreate(), because
|
|---|
| 95 | // for some reason, the constructor of MCalibrationPix does not initialize the
|
|---|
| 96 | // Arrays correctly, then.
|
|---|
| 97 | //
|
|---|
| 98 | void MCalibrationBlindCam::InitSize( const UInt_t n)
|
|---|
| 99 | {
|
|---|
| 100 | const UInt_t size = GetSize();
|
|---|
| 101 | fPixels->Expand(n);
|
|---|
| 102 |
|
|---|
| 103 | for (UInt_t i=size; i<n; i++)
|
|---|
| 104 | (*fPixels)[i] = new MCalibrationBlindPix;
|
|---|
| 105 |
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | // --------------------------------------------------------------------------
|
|---|
| 109 | //
|
|---|
| 110 | // Return true, if any of the blind pixels have an available photon flux
|
|---|
| 111 | //
|
|---|
| 112 | Bool_t MCalibrationBlindCam::IsFluxInsidePlexiglassAvailable() const
|
|---|
| 113 | {
|
|---|
| 114 | for (Int_t i=0; i<GetSize(); i++)
|
|---|
| 115 | {
|
|---|
| 116 | MCalibrationBlindPix &bp = (MCalibrationBlindPix&)(*this)[i];
|
|---|
| 117 | if (bp.IsFluxInsidePlexiglassAvailable())
|
|---|
| 118 | return kTRUE;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | return kFALSE;
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | // --------------------------------------------------------------------------
|
|---|
| 125 | //
|
|---|
| 126 | // Returns weighted average of the flux calculated by each blind pixel
|
|---|
| 127 | //
|
|---|
| 128 | Float_t MCalibrationBlindCam::GetFluxInsidePlexiglass() const
|
|---|
| 129 | {
|
|---|
| 130 |
|
|---|
| 131 | Float_t flux = 0.;
|
|---|
| 132 | Float_t fluxvar = 0.;
|
|---|
| 133 |
|
|---|
| 134 | for (Int_t i=0; i<GetSize(); i++)
|
|---|
| 135 | {
|
|---|
| 136 | MCalibrationBlindPix &bp = (MCalibrationBlindPix&)(*this)[i];
|
|---|
| 137 | if (bp.IsFluxInsidePlexiglassAvailable())
|
|---|
| 138 | {
|
|---|
| 139 | const Float_t weight = 1./
|
|---|
| 140 | bp.GetFluxInsidePlexiglassErr()
|
|---|
| 141 | / bp.GetFluxInsidePlexiglassErr();
|
|---|
| 142 | flux += weight * bp.GetFluxInsidePlexiglass();
|
|---|
| 143 | fluxvar += weight;
|
|---|
| 144 | }
|
|---|
| 145 | }
|
|---|
| 146 | return fluxvar > 0.0001 ? flux / fluxvar : -1.;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | // --------------------------------------------------------------------------
|
|---|
| 150 | //
|
|---|
| 151 | // Returns weighted variance of the flux calculated by each blind pixel
|
|---|
| 152 | //
|
|---|
| 153 | Float_t MCalibrationBlindCam::GetFluxInsidePlexiglassVar() const
|
|---|
| 154 | {
|
|---|
| 155 |
|
|---|
| 156 | Float_t fluxvar = 0.;
|
|---|
| 157 |
|
|---|
| 158 | for (Int_t i=0; i<GetSize(); i++)
|
|---|
| 159 | {
|
|---|
| 160 | MCalibrationBlindPix &bp = (MCalibrationBlindPix&)(*this)[i];
|
|---|
| 161 | if (bp.IsFluxInsidePlexiglassAvailable())
|
|---|
| 162 | {
|
|---|
| 163 | const Float_t weight = 1./
|
|---|
| 164 | bp.GetFluxInsidePlexiglassErr()
|
|---|
| 165 | / bp.GetFluxInsidePlexiglassErr();
|
|---|
| 166 | fluxvar += weight;
|
|---|
| 167 | }
|
|---|
| 168 | }
|
|---|
| 169 | return fluxvar > 0.0001 ? 1. / fluxvar : -1.;
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | // --------------------------------------------------------------------------
|
|---|
| 173 | //
|
|---|
| 174 | // Returns weighted rel. variance of the flux calculated by each blind pixel
|
|---|
| 175 | //
|
|---|
| 176 | Float_t MCalibrationBlindCam::GetFluxInsidePlexiglassRelVar() const
|
|---|
| 177 | {
|
|---|
| 178 |
|
|---|
| 179 | Float_t flux = 0.;
|
|---|
| 180 | Float_t fluxvar = 0.;
|
|---|
| 181 |
|
|---|
| 182 | for (Int_t i=0; i<GetSize(); i++)
|
|---|
| 183 | {
|
|---|
| 184 | MCalibrationBlindPix &bp = (MCalibrationBlindPix&)(*this)[i];
|
|---|
| 185 | if (bp.IsFluxInsidePlexiglassAvailable())
|
|---|
| 186 | {
|
|---|
| 187 | const Float_t weight = 1./
|
|---|
| 188 | bp.GetFluxInsidePlexiglassErr()
|
|---|
| 189 | / bp.GetFluxInsidePlexiglassErr();
|
|---|
| 190 | flux += weight * bp.GetFluxInsidePlexiglass();
|
|---|
| 191 | fluxvar += weight;
|
|---|
| 192 | }
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | return fluxvar > 0.0001 ? flux * fluxvar : -1.;
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|