| 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 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MGeomApply
|
|---|
| 28 | //
|
|---|
| 29 | // Applies the geometry to geometry dependant containers.
|
|---|
| 30 | //
|
|---|
| 31 | // It changes the size of the arrays in the containers to a size
|
|---|
| 32 | // matching the number of pixels, eg:
|
|---|
| 33 | //
|
|---|
| 34 | // MPedestalCam
|
|---|
| 35 | // MBlindPixels
|
|---|
| 36 | //
|
|---|
| 37 | // It uses the geometry (MGeomCam) found in the parameter list.
|
|---|
| 38 | // If it is not found the task tries to create the geometry
|
|---|
| 39 | // specified in the constructor. The default geometry is
|
|---|
| 40 | // MGeomCamMagic.
|
|---|
| 41 | //
|
|---|
| 42 | // Input Containers:
|
|---|
| 43 | // [MGeomCam]
|
|---|
| 44 | //
|
|---|
| 45 | // Output Containers:
|
|---|
| 46 | // [MPedestalCam]
|
|---|
| 47 | // [MBlindPixels]
|
|---|
| 48 | //
|
|---|
| 49 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 50 | #include "MGeomApply.h"
|
|---|
| 51 |
|
|---|
| 52 | #include <fstream>
|
|---|
| 53 |
|
|---|
| 54 | #include "MLog.h"
|
|---|
| 55 | #include "MLogManip.h"
|
|---|
| 56 |
|
|---|
| 57 | #include "MParList.h"
|
|---|
| 58 |
|
|---|
| 59 | #include "MGeomCam.h"
|
|---|
| 60 | #include "MPedestalCam.h"
|
|---|
| 61 | #include "MCalibrationCam.h"
|
|---|
| 62 | #include "MPedPhotCam.h"
|
|---|
| 63 | #include "MBlindPixels.h"
|
|---|
| 64 |
|
|---|
| 65 | ClassImp(MGeomApply);
|
|---|
| 66 |
|
|---|
| 67 | using namespace std;
|
|---|
| 68 |
|
|---|
| 69 | // --------------------------------------------------------------------------
|
|---|
| 70 | //
|
|---|
| 71 | // Default constructor. MGeomCamMagic is the default geometry.
|
|---|
| 72 | //
|
|---|
| 73 | MGeomApply::MGeomApply(const char *name, const char *title) : fGeomName("MGeomCamMagic")
|
|---|
| 74 | {
|
|---|
| 75 | fName = name ? name : "MGeomApply";
|
|---|
| 76 | fTitle = title ? title : "Task to apply geometry settings";
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | // --------------------------------------------------------------------------
|
|---|
| 80 | //
|
|---|
| 81 | // Try to find 'MGeomCam' in the Parameter List. If it is not found,
|
|---|
| 82 | // try to create a fGeomName object.
|
|---|
| 83 | //
|
|---|
| 84 | Int_t MGeomApply::PreProcess(MParList *pList)
|
|---|
| 85 | {
|
|---|
| 86 | MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
|
|---|
| 87 | if (cam)
|
|---|
| 88 | return kTRUE;
|
|---|
| 89 |
|
|---|
| 90 | cam = (MGeomCam*)pList->FindCreateObj(AddSerialNumber(fGeomName), "MGeomCam");
|
|---|
| 91 |
|
|---|
| 92 | return cam ? kTRUE : kFALSE;
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | // --------------------------------------------------------------------------
|
|---|
| 96 | //
|
|---|
| 97 | // Try to find 'MGeomCam' in the Parameter List. If it is not found,
|
|---|
| 98 | // processing is stopped.
|
|---|
| 99 | //
|
|---|
| 100 | // The size of MPedestalCam and MBlindPixels is set accordingly.
|
|---|
| 101 | //
|
|---|
| 102 | Bool_t MGeomApply::ReInit(MParList *pList)
|
|---|
| 103 | {
|
|---|
| 104 | MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
|
|---|
| 105 | if (!cam)
|
|---|
| 106 | {
|
|---|
| 107 | *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
|
|---|
| 108 | return kFALSE;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | // FIXME, workaround: this call to CalcPixRatio is here just to allow
|
|---|
| 112 | // the use of some camera files from the 0.7 beta version in which the
|
|---|
| 113 | // array containing pixel ratios is not initialized.
|
|---|
| 114 |
|
|---|
| 115 | cam->CalcPixRatio();
|
|---|
| 116 |
|
|---|
| 117 | MPedestalCam *ped = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
|
|---|
| 118 | if (ped)
|
|---|
| 119 | ped->InitSize(cam->GetNumPixels());
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | MCalibrationCam *cal = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationCam"));
|
|---|
| 123 | if (cal)
|
|---|
| 124 | cal->InitSize(cam->GetNumPixels());
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 | MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
|
|---|
| 128 | if (pedphot)
|
|---|
| 129 | pedphot->InitSize(cam->GetNumPixels());
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 | MBlindPixels *bnd = (MBlindPixels*)pList->FindObject(AddSerialNumber("MBlindPixels"));
|
|---|
| 133 | if (bnd)
|
|---|
| 134 | bnd->InitSize(cam->GetNumPixels());
|
|---|
| 135 |
|
|---|
| 136 | return kTRUE;
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | // --------------------------------------------------------------------------
|
|---|
| 140 | //
|
|---|
| 141 | // Implementation of SavePrimitive. Used to write the call to a constructor
|
|---|
| 142 | // to a macro. In the original root implementation it is used to write
|
|---|
| 143 | // gui elements to a macro-file.
|
|---|
| 144 | //
|
|---|
| 145 | void MGeomApply::StreamPrimitive(ofstream &out) const
|
|---|
| 146 | {
|
|---|
| 147 | out << " " << ClassName() << " " << GetUniqueName() << "(\"";
|
|---|
| 148 | out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
|
|---|
| 149 |
|
|---|
| 150 | if (fGeomName.IsNull())
|
|---|
| 151 | return;
|
|---|
| 152 |
|
|---|
| 153 | out << " " << GetUniqueName() << ".SetGeometry(\"";
|
|---|
| 154 | out << fGeomName << "\");" << endl;
|
|---|
| 155 | }
|
|---|