| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of CheObs, the Modular 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 appears 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, 1/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: CheObs Software Development, 2000-2009
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MSimGeomCam
|
|---|
| 28 | //
|
|---|
| 29 | // This task takes a photon list from a MPhotonEvent and checks which pixel
|
|---|
| 30 | // from a MGeomCam is hit. The photons are tagged with the corresponding
|
|---|
| 31 | // index.
|
|---|
| 32 | //
|
|---|
| 33 | // Additionally (and provisionally) it also calculates the photon event
|
|---|
| 34 | // statistics.
|
|---|
| 35 | //
|
|---|
| 36 | // Input Containers:
|
|---|
| 37 | // MPhotonEvent
|
|---|
| 38 | // fNameGeomCam [MGeomCam]
|
|---|
| 39 | // IntendedTrigPos [MParameterD]
|
|---|
| 40 | // MRawRunHeader
|
|---|
| 41 | //
|
|---|
| 42 | // Output Containers:
|
|---|
| 43 | // MPhotonStatistics
|
|---|
| 44 | // -/-
|
|---|
| 45 | //
|
|---|
| 46 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 47 | #include "MSimGeomCam.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MLog.h"
|
|---|
| 50 | #include "MLogManip.h"
|
|---|
| 51 |
|
|---|
| 52 | #include "MParList.h"
|
|---|
| 53 |
|
|---|
| 54 | #include "MGeomCam.h"
|
|---|
| 55 | #include "MGeomPix.h"
|
|---|
| 56 |
|
|---|
| 57 | #include "MPhotonEvent.h"
|
|---|
| 58 | #include "MPhotonData.h"
|
|---|
| 59 |
|
|---|
| 60 | #include "MParameters.h"
|
|---|
| 61 | #include "MRawRunHeader.h"
|
|---|
| 62 |
|
|---|
| 63 | ClassImp(MSimGeomCam);
|
|---|
| 64 |
|
|---|
| 65 | using namespace std;
|
|---|
| 66 |
|
|---|
| 67 | // --------------------------------------------------------------------------
|
|---|
| 68 | //
|
|---|
| 69 | // Default Constructor.
|
|---|
| 70 | //
|
|---|
| 71 | MSimGeomCam::MSimGeomCam(const char* name, const char *title)
|
|---|
| 72 | : fGeom(0), fEvt(0), fStat(0), fNameGeomCam("MGeomCam")
|
|---|
| 73 | {
|
|---|
| 74 | fName = name ? name : "MSimGeomCam";
|
|---|
| 75 | fTitle = title ? title : "Task to tag each photon in a MPhotonEvent with a pixel index from a MGeomCam";
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | // --------------------------------------------------------------------------
|
|---|
| 79 | //
|
|---|
| 80 | // Search for the needed parameter containers.
|
|---|
| 81 | //
|
|---|
| 82 | Int_t MSimGeomCam::PreProcess(MParList *pList)
|
|---|
| 83 | {
|
|---|
| 84 | fGeom = (MGeomCam*)pList->FindObject(fNameGeomCam, "MGeomCam");
|
|---|
| 85 | if (!fGeom)
|
|---|
| 86 | {
|
|---|
| 87 | *fLog << inf << fNameGeomCam << " [MGeomCam] not found..." << endl;
|
|---|
| 88 |
|
|---|
| 89 | fGeom = (MGeomCam*)pList->FindCreateObj(fNameGeomCam);
|
|---|
| 90 | if (!fGeom)
|
|---|
| 91 | return kFALSE;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | fEvt = (MPhotonEvent*)pList->FindObject("MPhotonEvent");
|
|---|
| 95 | if (!fEvt)
|
|---|
| 96 | {
|
|---|
| 97 | *fLog << err << "MPhotonEvent not found... aborting." << endl;
|
|---|
| 98 | return kFALSE;
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | fPulsePos = (MParameterD*)pList->FindObject("IntendedPulsePos", "MParameterD");
|
|---|
| 102 | if (!fPulsePos)
|
|---|
| 103 | {
|
|---|
| 104 | *fLog << err << "IntendedPulsePos [MParameterD] not found... aborting." << endl;
|
|---|
| 105 | return kFALSE;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | fHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 109 | if (!fHeader)
|
|---|
| 110 | {
|
|---|
| 111 | *fLog << err << "MRawRunHeader not found... aborting." << endl;
|
|---|
| 112 | return kFALSE;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | fStat = (MPhotonStatistics*)pList->FindCreateObj("MPhotonStatistics");
|
|---|
| 116 | if (!fStat)
|
|---|
| 117 | return kFALSE;
|
|---|
| 118 |
|
|---|
| 119 | return kTRUE;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 | // --------------------------------------------------------------------------
|
|---|
| 124 | //
|
|---|
| 125 | Int_t MSimGeomCam::Process()
|
|---|
| 126 | {
|
|---|
| 127 | const Int_t num = fEvt->GetNumPhotons();
|
|---|
| 128 |
|
|---|
| 129 | Int_t cnt = 0;
|
|---|
| 130 | for (Int_t i=0; i<num; i++)
|
|---|
| 131 | {
|
|---|
| 132 | MPhotonData &ph = (*fEvt)[i];
|
|---|
| 133 |
|
|---|
| 134 | //
|
|---|
| 135 | // sum the photons content in each pixel
|
|---|
| 136 | //
|
|---|
| 137 | for (UInt_t idx=0; idx<fGeom->GetNumPixels(); idx++)
|
|---|
| 138 | {
|
|---|
| 139 | // FIXME: Improve search algorithm (2D Binary search?)
|
|---|
| 140 | if (!(*fGeom)[idx].IsInside(ph.GetPosX()*10, ph.GetPosY()*10))
|
|---|
| 141 | continue;
|
|---|
| 142 |
|
|---|
| 143 | ph.SetTag(idx);
|
|---|
| 144 |
|
|---|
| 145 | (*fEvt)[cnt++] = ph;
|
|---|
| 146 |
|
|---|
| 147 | break;
|
|---|
| 148 | }
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | fEvt->Shrink(cnt);
|
|---|
| 152 | //fEvt->Sort();
|
|---|
| 153 |
|
|---|
| 154 | // ------ FIXME: Move somewhere else? MSimCalibrationSignal ------
|
|---|
| 155 |
|
|---|
| 156 | if (!fEvt->IsSorted())
|
|---|
| 157 | {
|
|---|
| 158 | *fLog << err << "ERROR - MPhotonEvent must be sorted!" << endl;
|
|---|
| 159 | return kERROR;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | const Float_t first = cnt>0 ? fEvt->GetFirst()->GetTime() : 0;
|
|---|
| 163 | const Float_t last = cnt>0 ? fEvt->GetLast()->GetTime() : -1;
|
|---|
| 164 |
|
|---|
| 165 | // Length (ns), Pulse position (Units ns)
|
|---|
| 166 | const Float_t ns = fHeader->GetFreqSampling()/1000.*fHeader->GetNumSamplesHiGain();
|
|---|
| 167 | const Float_t pp = fPulsePos->GetVal();
|
|---|
| 168 |
|
|---|
| 169 | // FIXME FIXME FIXME --- Make it depending on the trigger position?
|
|---|
| 170 |
|
|---|
| 171 | fStat->SetTime(first-pp, last+(ns-pp));
|
|---|
| 172 | fStat->SetMaxIndex(fGeom->GetNumPixels()-1);
|
|---|
| 173 | fStat->SetReadyToSave();
|
|---|
| 174 |
|
|---|
| 175 | // ----------------------------------------------------------------------
|
|---|
| 176 |
|
|---|
| 177 | return kTRUE;
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | // --------------------------------------------------------------------------
|
|---|
| 181 | //
|
|---|
| 182 | // Read the parameters from the resource file.
|
|---|
| 183 | //
|
|---|
| 184 | // NameGeometry: MGeomCamDwarf
|
|---|
| 185 | //
|
|---|
| 186 | Int_t MSimGeomCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
|---|
| 187 | {
|
|---|
| 188 | Bool_t rc = kFALSE;
|
|---|
| 189 | if (IsEnvDefined(env, prefix, "NameGeometry", print))
|
|---|
| 190 | {
|
|---|
| 191 | rc = kTRUE;
|
|---|
| 192 | SetNameGeomCam(GetEnvValue(env, prefix, "NameGeometry", fNameGeomCam));
|
|---|
| 193 | // FIXME: What about setup of this container?
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | return rc;
|
|---|
| 197 | }
|
|---|