| 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 | // MBadPixelsIntensityCam
|
|---|
| 27 | //
|
|---|
| 28 | // Base class for intensity calibration results
|
|---|
| 29 | //
|
|---|
| 30 | // Contains TClonesArrays for the following objects:
|
|---|
| 31 | // - fCams: Array of classes derived from MBadPixelsCam, one entry
|
|---|
| 32 | // per calibration camera result. Has to be created
|
|---|
| 33 | //
|
|---|
| 34 | // See also: MCalibrationIntensityChargeCam, MCalibrationIntensityQECam,
|
|---|
| 35 | // MCalibrationIntensityRelTimeCam,
|
|---|
| 36 | // MCalibrationCam, MCalibrationPix,
|
|---|
| 37 | // MCalibrationQECam, MCalibrationQEPix,
|
|---|
| 38 | // MHCalibrationChargePix, MHCalibrationChargeCam
|
|---|
| 39 | // MCalibrationChargeBlindPix, MCalibrationChargePINDiode
|
|---|
| 40 | //
|
|---|
| 41 | //
|
|---|
| 42 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 43 | #include "MBadPixelsIntensityCam.h"
|
|---|
| 44 |
|
|---|
| 45 | #include <TClonesArray.h>
|
|---|
| 46 |
|
|---|
| 47 | #include "MGeomCam.h"
|
|---|
| 48 |
|
|---|
| 49 | ClassImp(MBadPixelsIntensityCam);
|
|---|
| 50 |
|
|---|
| 51 | using namespace std;
|
|---|
| 52 | // --------------------------------------------------------------------------
|
|---|
| 53 | //
|
|---|
| 54 | // Default constructor.
|
|---|
| 55 | //
|
|---|
| 56 | // Initializes and sets owner of:
|
|---|
| 57 | // - fCams
|
|---|
| 58 | // - Initializes fCams to entry
|
|---|
| 59 | //
|
|---|
| 60 | MBadPixelsIntensityCam::MBadPixelsIntensityCam(const char *name, const char *title)
|
|---|
| 61 | {
|
|---|
| 62 |
|
|---|
| 63 | fName = name ? name : "MBadPixelsIntensityCam";
|
|---|
| 64 | fTitle = title ? title : "Base container for the Intensity Calibration";
|
|---|
| 65 |
|
|---|
| 66 | fCams = new TObjArray;
|
|---|
| 67 | fCams->SetOwner();
|
|---|
| 68 |
|
|---|
| 69 | InitSize(1);
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | // --------------------------------------------------------------------------
|
|---|
| 73 | //
|
|---|
| 74 | // Deletes the cameras if they exist
|
|---|
| 75 | //
|
|---|
| 76 | MBadPixelsIntensityCam::~MBadPixelsIntensityCam()
|
|---|
| 77 | {
|
|---|
| 78 | if (fCams)
|
|---|
| 79 | delete fCams;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | // --------------------------------------------------------------------------
|
|---|
| 83 | //
|
|---|
| 84 | // Add a new MBadPixelsCam to fCams, give it the name "name" and initialize
|
|---|
| 85 | // it with geom.
|
|---|
| 86 | //
|
|---|
| 87 | void MBadPixelsIntensityCam::AddToList( const char* name, const MGeomCam &geom)
|
|---|
| 88 | {
|
|---|
| 89 | InitSize(GetSize()+1);
|
|---|
| 90 | GetCam()->SetName(name);
|
|---|
| 91 | GetCam()->Init(geom);
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | // --------------------------------------------------------------------------
|
|---|
| 97 | //
|
|---|
| 98 | // Copy 'constructor'
|
|---|
| 99 | //
|
|---|
| 100 | void MBadPixelsIntensityCam::Copy(TObject& object) const
|
|---|
| 101 | {
|
|---|
| 102 |
|
|---|
| 103 | MBadPixelsIntensityCam &calib = (MBadPixelsIntensityCam&)object;
|
|---|
| 104 |
|
|---|
| 105 | MParContainer::Copy(calib);
|
|---|
| 106 |
|
|---|
| 107 | const UInt_t n = GetSize();
|
|---|
| 108 | if (n != 0)
|
|---|
| 109 | {
|
|---|
| 110 | calib.InitSize(n);
|
|---|
| 111 | for (UInt_t i=0; i<n; i++)
|
|---|
| 112 | GetCam(i)->Copy(*(calib.GetCam(i)));
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | // -----------------------------------------------------
|
|---|
| 118 | //
|
|---|
| 119 | // Calls Clear() for all entries fCams
|
|---|
| 120 | //
|
|---|
| 121 | void MBadPixelsIntensityCam::Clear(Option_t *o)
|
|---|
| 122 | {
|
|---|
| 123 |
|
|---|
| 124 | fCams->ForEach(MBadPixelsCam, Clear)();
|
|---|
| 125 |
|
|---|
| 126 | return;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | // -----------------------------------------------------
|
|---|
| 130 | //
|
|---|
| 131 | // Calls Print(o) for all entries fCams
|
|---|
| 132 | //
|
|---|
| 133 | void MBadPixelsIntensityCam::Print(Option_t *o) const
|
|---|
| 134 | {
|
|---|
| 135 | fCams->ForEach(MBadPixelsCam, Print)(o);
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 | // -------------------------------------------------------------------
|
|---|
| 140 | //
|
|---|
| 141 | // Calls TClonesArray::ExpandCreate() for fCams
|
|---|
| 142 | //
|
|---|
| 143 | void MBadPixelsIntensityCam::InitSize(const UInt_t n)
|
|---|
| 144 | {
|
|---|
| 145 |
|
|---|
| 146 | fCams->Expand(n);
|
|---|
| 147 |
|
|---|
| 148 | for (Int_t i=0; i<fCams->GetSize(); i++)
|
|---|
| 149 | (*fCams)[i] = new MBadPixelsCam;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | // -------------------------------------------------------------------
|
|---|
| 153 | //
|
|---|
| 154 | // If size is still 0, Intialize a first Cam.
|
|---|
| 155 | // Calls Init(geom) for all fCams
|
|---|
| 156 | //
|
|---|
| 157 | void MBadPixelsIntensityCam::Init(const MGeomCam &geom)
|
|---|
| 158 | {
|
|---|
| 159 | if (GetSize() == 0)
|
|---|
| 160 | InitSize(1);
|
|---|
| 161 |
|
|---|
| 162 | fCams->ForEach(MBadPixelsCam,Init)(geom);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 | // --------------------------------------------------------------------------
|
|---|
| 167 | //
|
|---|
| 168 | // Returns the current size of the TClonesArray fCams
|
|---|
| 169 | // independently if the MBadPixelsCam is filled with values or not.
|
|---|
| 170 | //
|
|---|
| 171 | Int_t MBadPixelsIntensityCam::GetSize() const
|
|---|
| 172 | {
|
|---|
| 173 | return fCams->GetEntries();
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | // --------------------------------------------------------------------------
|
|---|
| 177 | //
|
|---|
| 178 | // Get i-th pixel from current camera
|
|---|
| 179 | //
|
|---|
| 180 | MBadPixelsPix &MBadPixelsIntensityCam::operator[](Int_t i)
|
|---|
| 181 | {
|
|---|
| 182 | return (*GetCam(GetSize()-1))[i];
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | // --------------------------------------------------------------------------
|
|---|
| 186 | //
|
|---|
| 187 | // Get i-th pixel from current camera
|
|---|
| 188 | //
|
|---|
| 189 | const MBadPixelsPix &MBadPixelsIntensityCam::operator[](Int_t i) const
|
|---|
| 190 | {
|
|---|
| 191 | return (*GetCam(GetSize()-1))[i];
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 | // --------------------------------------------------------------------------
|
|---|
| 196 | //
|
|---|
| 197 | // Get i-th camera
|
|---|
| 198 | //
|
|---|
| 199 | MBadPixelsCam *MBadPixelsIntensityCam::GetCam(Int_t i)
|
|---|
| 200 | {
|
|---|
| 201 | return static_cast<MBadPixelsCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | // --------------------------------------------------------------------------
|
|---|
| 205 | //
|
|---|
| 206 | // Get i-th camera
|
|---|
| 207 | //
|
|---|
| 208 | const MBadPixelsCam *MBadPixelsIntensityCam::GetCam(Int_t i) const
|
|---|
| 209 | {
|
|---|
| 210 | return static_cast<MBadPixelsCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | // --------------------------------------------------------------------------
|
|---|
| 214 | //
|
|---|
| 215 | // Get camera with name 'name'
|
|---|
| 216 | //
|
|---|
| 217 | MBadPixelsCam *MBadPixelsIntensityCam::GetCam(const char *name )
|
|---|
| 218 | {
|
|---|
| 219 | return static_cast<MBadPixelsCam*>(fCams->FindObject(name));
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | // --------------------------------------------------------------------------
|
|---|
| 223 | //
|
|---|
| 224 | // Get camera with name 'name'
|
|---|
| 225 | //
|
|---|
| 226 | const MBadPixelsCam *MBadPixelsIntensityCam::GetCam(const char *name ) const
|
|---|
| 227 | {
|
|---|
| 228 | return static_cast<MBadPixelsCam*>(fCams->FindObject(name));
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | // --------------------------------------------------------------------------
|
|---|
| 232 | //
|
|---|
| 233 | // Calls GetPixelContent for the current entry in fCams
|
|---|
| 234 | //
|
|---|
| 235 | Bool_t MBadPixelsIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 236 | {
|
|---|
| 237 | return GetCam()->GetPixelContent(val,idx,cam,type);
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | // --------------------------------------------------------------------------
|
|---|
| 241 | //
|
|---|
| 242 | // Calls DrawPixelContent for the current entry in fCams
|
|---|
| 243 | //
|
|---|
| 244 | void MBadPixelsIntensityCam::DrawPixelContent( Int_t num ) const
|
|---|
| 245 | {
|
|---|
| 246 | return GetCam()->DrawPixelContent(num);
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|