| 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, 09/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | ! Markus Gaug, 03/2004 <mailto:markus@ifae.es>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MGeomApply
|
|---|
| 29 | //
|
|---|
| 30 | // Applies the geometry to geometry dependant containers.
|
|---|
| 31 | //
|
|---|
| 32 | // It changes the size of the arrays in the containers to a size
|
|---|
| 33 | // matching the number of pixels, eg:
|
|---|
| 34 | //
|
|---|
| 35 | // MPedestalCam
|
|---|
| 36 | // MCalibrationChargeCam
|
|---|
| 37 | // MCalibrationQECam
|
|---|
| 38 | // MPedPhotCam
|
|---|
| 39 | // MExtractedSignalCam
|
|---|
| 40 | // MBlindPixels
|
|---|
| 41 | // MArrivalTimeCam
|
|---|
| 42 | // MArrivalTimePix
|
|---|
| 43 | //
|
|---|
| 44 | // It uses the geometry (MGeomCam) found in the parameter list.
|
|---|
| 45 | // If it is not found the task tries to create the geometry
|
|---|
| 46 | // specified in the constructor. The default geometry is
|
|---|
| 47 | // MGeomCamMagic.
|
|---|
| 48 | //
|
|---|
| 49 | // Input Containers:
|
|---|
| 50 | // [MGeomCam]
|
|---|
| 51 | //
|
|---|
| 52 | // Output Containers:
|
|---|
| 53 | // [MPedestalCam]
|
|---|
| 54 | // [MCalibrationChargeCam]
|
|---|
| 55 | // [MPedPhotCam]
|
|---|
| 56 | // [MExtractedSignalCam]
|
|---|
| 57 | // [MBlindPixels]
|
|---|
| 58 | // [MArrivalTime]
|
|---|
| 59 | // [MArrivalTimeCam]
|
|---|
| 60 | //
|
|---|
| 61 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 62 | #include "MGeomApply.h"
|
|---|
| 63 |
|
|---|
| 64 | #include <fstream>
|
|---|
| 65 |
|
|---|
| 66 | #include "MLog.h"
|
|---|
| 67 | #include "MLogManip.h"
|
|---|
| 68 |
|
|---|
| 69 | #include "MParList.h"
|
|---|
| 70 |
|
|---|
| 71 | #include "MGeomCam.h"
|
|---|
| 72 | #include "MPedestalCam.h"
|
|---|
| 73 | #include "MCalibrationChargeCam.h"
|
|---|
| 74 | #include "MCalibrationRelTimeCam.h"
|
|---|
| 75 | #include "MCalibrationQECam.h"
|
|---|
| 76 | #include "MCalibrationPedCam.h"
|
|---|
| 77 | #include "MPedPhotCam.h"
|
|---|
| 78 | #include "MExtractedSignalCam.h"
|
|---|
| 79 | #include "MBlindPixels.h"
|
|---|
| 80 | #include "MArrivalTimeCam.h"
|
|---|
| 81 | #include "MBadPixelsCam.h"
|
|---|
| 82 |
|
|---|
| 83 | ClassImp(MGeomApply);
|
|---|
| 84 |
|
|---|
| 85 | using namespace std;
|
|---|
| 86 |
|
|---|
| 87 | // --------------------------------------------------------------------------
|
|---|
| 88 | //
|
|---|
| 89 | // Default constructor. MGeomCamMagic is the default geometry.
|
|---|
| 90 | //
|
|---|
| 91 | MGeomApply::MGeomApply(const char *name, const char *title) : fGeomName("MGeomCamMagic")
|
|---|
| 92 | {
|
|---|
| 93 | fName = name ? name : "MGeomApply";
|
|---|
| 94 | fTitle = title ? title : "Task to apply geometry settings";
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | // --------------------------------------------------------------------------
|
|---|
| 98 | //
|
|---|
| 99 | // Try to find 'MGeomCam' in the Parameter List. If it is not found,
|
|---|
| 100 | // try to create a fGeomName object.
|
|---|
| 101 | //
|
|---|
| 102 | Int_t MGeomApply::PreProcess(MParList *pList)
|
|---|
| 103 | {
|
|---|
| 104 | MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
|
|---|
| 105 | if (cam)
|
|---|
| 106 | return kTRUE;
|
|---|
| 107 |
|
|---|
| 108 | cam = (MGeomCam*)pList->FindCreateObj(AddSerialNumber(fGeomName), "MGeomCam");
|
|---|
| 109 |
|
|---|
| 110 | return cam ? kTRUE : kFALSE;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | // --------------------------------------------------------------------------
|
|---|
| 114 | //
|
|---|
| 115 | // Try to find 'MGeomCam' in the Parameter List. If it is not found,
|
|---|
| 116 | // processing is stopped.
|
|---|
| 117 | //
|
|---|
| 118 | // The size of MPedestalCam and MBlindPixels is set accordingly.
|
|---|
| 119 | //
|
|---|
| 120 | Bool_t MGeomApply::ReInit(MParList *pList)
|
|---|
| 121 | {
|
|---|
| 122 | MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
|
|---|
| 123 | if (!cam)
|
|---|
| 124 | {
|
|---|
| 125 | *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
|
|---|
| 126 | return kFALSE;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | // FIXME, workaround: this call to CalcPixRatio is here just to allow
|
|---|
| 130 | // the use of some camera files from the 0.7 beta version in which the
|
|---|
| 131 | // array containing pixel ratios is not initialized.
|
|---|
| 132 | cam->CalcPixRatio();
|
|---|
| 133 |
|
|---|
| 134 | MPedestalCam *ped = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
|
|---|
| 135 | if (ped)
|
|---|
| 136 | ped->InitSize(cam->GetNumPixels());
|
|---|
| 137 |
|
|---|
| 138 | MCalibrationChargeCam *cal =
|
|---|
| 139 | (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
|
|---|
| 140 | if (cal)
|
|---|
| 141 | {
|
|---|
| 142 | cal->InitSize ( cam->GetNumPixels() );
|
|---|
| 143 | cal->InitAverageAreas ( cam->GetNumAreas() );
|
|---|
| 144 | cal->InitAverageSectors( cam->GetNumSectors() );
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | MCalibrationRelTimeCam *cat =
|
|---|
| 148 | (MCalibrationRelTimeCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
|
|---|
| 149 | if (cat)
|
|---|
| 150 | {
|
|---|
| 151 | cat->InitSize ( cam->GetNumPixels() );
|
|---|
| 152 | cat->InitAverageAreas ( cam->GetNumAreas() );
|
|---|
| 153 | cat->InitAverageSectors( cam->GetNumSectors() );
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | MCalibrationQECam *qe =
|
|---|
| 157 | (MCalibrationQECam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
|
|---|
| 158 | if (qe)
|
|---|
| 159 | {
|
|---|
| 160 | qe->InitSize ( cam->GetNumPixels() );
|
|---|
| 161 | qe->InitAverageAreas ( cam->GetNumAreas() );
|
|---|
| 162 | qe->InitAverageSectors ( cam->GetNumSectors() );
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | MCalibrationPedCam *pcam =
|
|---|
| 166 | (MCalibrationPedCam*)pList->FindObject(AddSerialNumber("MCalibrationPedCam"));
|
|---|
| 167 | if (pcam)
|
|---|
| 168 | {
|
|---|
| 169 | pcam->InitSize ( cam->GetNumPixels() );
|
|---|
| 170 | pcam->InitAverageAreas ( cam->GetNumAreas() );
|
|---|
| 171 | pcam->InitAverageSectors ( cam->GetNumSectors() );
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
|
|---|
| 175 | if (pedphot)
|
|---|
| 176 | pedphot->InitSize(cam->GetNumPixels());
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 | MExtractedSignalCam *ext = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
|
|---|
| 180 | if (ext)
|
|---|
| 181 | ext->InitSize(cam->GetNumPixels());
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 | MBlindPixels *bnd = (MBlindPixels*)pList->FindObject(AddSerialNumber("MBlindPixels"));
|
|---|
| 185 | if (bnd)
|
|---|
| 186 | bnd->InitSize(cam->GetNumPixels());
|
|---|
| 187 |
|
|---|
| 188 | MArrivalTimeCam *tme = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
|
|---|
| 189 | if (tme)
|
|---|
| 190 | tme->InitSize(cam->GetNumPixels());
|
|---|
| 191 |
|
|---|
| 192 | MBadPixelsCam *bad = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
|
|---|
| 193 | if (bad)
|
|---|
| 194 | bad->InitSize(cam->GetNumPixels());
|
|---|
| 195 |
|
|---|
| 196 | return kTRUE;
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | // --------------------------------------------------------------------------
|
|---|
| 200 | //
|
|---|
| 201 | // Implementation of SavePrimitive. Used to write the call to a constructor
|
|---|
| 202 | // to a macro. In the original root implementation it is used to write
|
|---|
| 203 | // gui elements to a macro-file.
|
|---|
| 204 | //
|
|---|
| 205 | void MGeomApply::StreamPrimitive(ofstream &out) const
|
|---|
| 206 | {
|
|---|
| 207 | out << " " << ClassName() << " " << GetUniqueName() << "(\"";
|
|---|
| 208 | out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
|
|---|
| 209 |
|
|---|
| 210 | if (fGeomName.IsNull())
|
|---|
| 211 | return;
|
|---|
| 212 |
|
|---|
| 213 | out << " " << GetUniqueName() << ".SetGeometry(\"";
|
|---|
| 214 | out << fGeomName << "\");" << endl;
|
|---|
| 215 | }
|
|---|