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 | #include "MPulseShape.h"
|
---|
64 |
|
---|
65 | ClassImp(MSimGeomCam);
|
---|
66 |
|
---|
67 | using namespace std;
|
---|
68 |
|
---|
69 | // --------------------------------------------------------------------------
|
---|
70 | //
|
---|
71 | // Default Constructor.
|
---|
72 | //
|
---|
73 | MSimGeomCam::MSimGeomCam(const char* name, const char *title)
|
---|
74 | : fGeom(0), fEvt(0), fStat(0), fPulsePos(0), fHeader(0), fPulse(0),
|
---|
75 | fNameGeomCam("MGeomCam")
|
---|
76 | {
|
---|
77 | fName = name ? name : "MSimGeomCam";
|
---|
78 | fTitle = title ? title : "Task to tag each photon in a MPhotonEvent with a pixel index from a MGeomCam";
|
---|
79 | }
|
---|
80 |
|
---|
81 | // --------------------------------------------------------------------------
|
---|
82 | //
|
---|
83 | // Search for the needed parameter containers.
|
---|
84 | //
|
---|
85 | Int_t MSimGeomCam::PreProcess(MParList *pList)
|
---|
86 | {
|
---|
87 | fGeom = (MGeomCam*)pList->FindObject(fNameGeomCam, "MGeomCam");
|
---|
88 | if (!fGeom)
|
---|
89 | {
|
---|
90 | *fLog << inf << fNameGeomCam << " [MGeomCam] not found..." << endl;
|
---|
91 |
|
---|
92 | fGeom = (MGeomCam*)pList->FindCreateObj(fNameGeomCam);
|
---|
93 | if (!fGeom)
|
---|
94 | return kFALSE;
|
---|
95 | }
|
---|
96 |
|
---|
97 | fEvt = (MPhotonEvent*)pList->FindObject("MPhotonEvent");
|
---|
98 | if (!fEvt)
|
---|
99 | {
|
---|
100 | *fLog << err << "MPhotonEvent not found... aborting." << endl;
|
---|
101 | return kFALSE;
|
---|
102 | }
|
---|
103 |
|
---|
104 | fPulse = (MPulseShape*)pList->FindObject("MPulseShape");
|
---|
105 | if (!fPulse)
|
---|
106 | {
|
---|
107 | *fLog << err << "MPulsShape not found... aborting." << endl;
|
---|
108 | return kFALSE;
|
---|
109 | }
|
---|
110 |
|
---|
111 | fPulsePos = (MParameterD*)pList->FindObject("IntendedPulsePos", "MParameterD");
|
---|
112 | if (!fPulsePos)
|
---|
113 | {
|
---|
114 | *fLog << err << "IntendedPulsePos [MParameterD] not found... aborting." << endl;
|
---|
115 | return kFALSE;
|
---|
116 | }
|
---|
117 |
|
---|
118 | fHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
119 | if (!fHeader)
|
---|
120 | {
|
---|
121 | *fLog << err << "MRawRunHeader not found... aborting." << endl;
|
---|
122 | return kFALSE;
|
---|
123 | }
|
---|
124 |
|
---|
125 | fStat = (MPhotonStatistics*)pList->FindCreateObj("MPhotonStatistics");
|
---|
126 | if (!fStat)
|
---|
127 | return kFALSE;
|
---|
128 |
|
---|
129 | return kTRUE;
|
---|
130 | }
|
---|
131 |
|
---|
132 |
|
---|
133 | // --------------------------------------------------------------------------
|
---|
134 | //
|
---|
135 | Int_t MSimGeomCam::Process()
|
---|
136 | {
|
---|
137 | const Int_t num = fEvt->GetNumPhotons();
|
---|
138 |
|
---|
139 | Int_t cnt = 0;
|
---|
140 | for (Int_t i=0; i<num; i++)
|
---|
141 | {
|
---|
142 | MPhotonData &ph = (*fEvt)[i];
|
---|
143 |
|
---|
144 | //
|
---|
145 | // sum the photons content in each pixel
|
---|
146 | //
|
---|
147 | for (UInt_t idx=0; idx<fGeom->GetNumPixels(); idx++)
|
---|
148 | {
|
---|
149 | // FIXME: Improve search algorithm (2D Binary search?)
|
---|
150 | // Here we convert the photons from the ceres-coordinate
|
---|
151 | // system which is viewed from the camera to the mirror
|
---|
152 | // into the camera coordinates which are viewed from
|
---|
153 | // the mirror to the camera.
|
---|
154 | // (x on the right, y upwards, right-handed)
|
---|
155 | if (!(*fGeom)[idx].IsInside(-ph.GetPosX()*10, ph.GetPosY()*10))
|
---|
156 | continue;
|
---|
157 |
|
---|
158 | ph.SetTag(idx);
|
---|
159 |
|
---|
160 | (*fEvt)[cnt++] = ph;
|
---|
161 |
|
---|
162 | break;
|
---|
163 | }
|
---|
164 | }
|
---|
165 |
|
---|
166 | fEvt->Shrink(cnt);
|
---|
167 | //fEvt->Sort();
|
---|
168 |
|
---|
169 | // ------ FIXME: Move somewhere else? MSimCalibrationSignal ------
|
---|
170 |
|
---|
171 | if (!fEvt->IsSorted())
|
---|
172 | {
|
---|
173 | *fLog << err << "ERROR - MPhotonEvent must be sorted!" << endl;
|
---|
174 | return kERROR;
|
---|
175 | }
|
---|
176 |
|
---|
177 | const Float_t freq = fHeader->GetFreqSampling()/1000.;
|
---|
178 |
|
---|
179 | // We add an additional sample at the end to support a possible shift
|
---|
180 | // of the start time of the first event by 0 to 1 sample.
|
---|
181 | const Int_t ns = fHeader->GetNumSamplesHiGain()+1;
|
---|
182 |
|
---|
183 | const Float_t first = cnt>0 ? fEvt->GetTimeFirst() : 0;
|
---|
184 | const Float_t last = cnt>0 ? fEvt->GetTimeLast() : ns*freq;
|
---|
185 |
|
---|
186 | // Length (ns), Pulse position (Units ns)
|
---|
187 | const Float_t pp = fPulsePos->GetVal();
|
---|
188 | const Float_t pw = fPulse->GetPulseWidth();
|
---|
189 |
|
---|
190 | fStat->SetTimeMedDev(fEvt->GetTimeMedianDev());
|
---|
191 | fStat->SetTime(first-pp-pw, last-pp+pw + ns*freq);
|
---|
192 | fStat->SetLength(last-first);
|
---|
193 | fStat->SetMaxIndex(fGeom->GetNumPixels()-1);
|
---|
194 | fStat->SetReadyToSave();
|
---|
195 |
|
---|
196 | // ----------------------------------------------------------------------
|
---|
197 |
|
---|
198 | return kTRUE;
|
---|
199 | }
|
---|
200 |
|
---|
201 | // --------------------------------------------------------------------------
|
---|
202 | //
|
---|
203 | // Read the parameters from the resource file.
|
---|
204 | //
|
---|
205 | // NameGeometry: MGeomCamDwarf
|
---|
206 | //
|
---|
207 | Int_t MSimGeomCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
---|
208 | {
|
---|
209 | Bool_t rc = kFALSE;
|
---|
210 | if (IsEnvDefined(env, prefix, "NameGeometry", print))
|
---|
211 | {
|
---|
212 | rc = kTRUE;
|
---|
213 | SetNameGeomCam(GetEnvValue(env, prefix, "NameGeometry", fNameGeomCam));
|
---|
214 | // FIXME: What about setup of this container?
|
---|
215 | }
|
---|
216 |
|
---|
217 | return rc;
|
---|
218 | }
|
---|