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