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): Sebastian Raducci 12/2003 <mailto:raducci@fisica.uniud.it>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2002-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MArrivalTimeCalc
|
---|
28 | //
|
---|
29 | // This is a task that calculates the arrival times of photons.
|
---|
30 | // It returns the absolute maximum of the spline that interpolates
|
---|
31 | // the FADC slices
|
---|
32 | //
|
---|
33 | // Input Containers:
|
---|
34 | // MRawEvtData
|
---|
35 | //
|
---|
36 | // Output Containers:
|
---|
37 | // MArrivalTime
|
---|
38 | // MRawEvtData
|
---|
39 | //
|
---|
40 | //////////////////////////////////////////////////////////////////////////////
|
---|
41 | #include "MArrivalTimeCalc.h"
|
---|
42 |
|
---|
43 | #include "MLog.h"
|
---|
44 | #include "MLogManip.h"
|
---|
45 |
|
---|
46 | #include "MParList.h"
|
---|
47 |
|
---|
48 | #include "MGeomCam.h"
|
---|
49 | #include "MArrivalTime.h"
|
---|
50 | #include "MRawEvtData.h"
|
---|
51 | #include "MRawEvtPixelIter.h"
|
---|
52 |
|
---|
53 | #include <TSpline.h>
|
---|
54 |
|
---|
55 | ClassImp(MArrivalTimeCalc);
|
---|
56 |
|
---|
57 | using namespace std;
|
---|
58 |
|
---|
59 | // --------------------------------------------------------------------------
|
---|
60 | //
|
---|
61 | // Default constructor.
|
---|
62 | //
|
---|
63 | MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title)
|
---|
64 | {
|
---|
65 |
|
---|
66 | fName = name ? name : "MArrivalTimeCalc";
|
---|
67 | fTitle = title ? title : "Calculate photons arrival time";
|
---|
68 |
|
---|
69 | }
|
---|
70 |
|
---|
71 | // --------------------------------------------------------------------------
|
---|
72 | //
|
---|
73 | // The PreProcess searches for the following input containers:
|
---|
74 | // - MRawEvtData
|
---|
75 | // - MArrivalTime
|
---|
76 | //
|
---|
77 | // The following output containers are also searched and created if
|
---|
78 | // they were not found:
|
---|
79 | // - MArrivalTime
|
---|
80 | //
|
---|
81 | Int_t MArrivalTimeCalc::PreProcess(MParList *pList)
|
---|
82 | {
|
---|
83 | fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
|
---|
84 | if (!fRawEvt)
|
---|
85 | {
|
---|
86 | *fLog << err << "MRawEvtData not found... aborting." << endl;
|
---|
87 | return kFALSE;
|
---|
88 | }
|
---|
89 |
|
---|
90 | fArrTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
|
---|
91 | if (!fArrTime)
|
---|
92 | return kFALSE;
|
---|
93 |
|
---|
94 | return kTRUE;
|
---|
95 | }
|
---|
96 |
|
---|
97 | // --------------------------------------------------------------------------
|
---|
98 | //
|
---|
99 | // The ReInit searches for the following input containers:
|
---|
100 | // - MGeomCam
|
---|
101 | //
|
---|
102 | Bool_t MArrivalTimeCalc::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 | fArrTime->InitSize(cam->GetNumPixels());
|
---|
112 |
|
---|
113 | return kTRUE;
|
---|
114 | }
|
---|
115 |
|
---|
116 | // --------------------------------------------------------------------------
|
---|
117 | //
|
---|
118 | // Evaluation of the mean arrival times (spline interpolation)
|
---|
119 | // per pixel and store them in the MArrivalTime container.
|
---|
120 | //
|
---|
121 | Int_t MArrivalTimeCalc::Process()
|
---|
122 | {
|
---|
123 |
|
---|
124 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
125 |
|
---|
126 | while (pixel.Next())
|
---|
127 | {
|
---|
128 |
|
---|
129 | const UInt_t idx = pixel.GetPixelId();
|
---|
130 | Float_t max = 0.;
|
---|
131 |
|
---|
132 |
|
---|
133 | //
|
---|
134 | // If pixel is saturated we use LoGains
|
---|
135 | //
|
---|
136 | if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
|
---|
137 | {
|
---|
138 |
|
---|
139 | const Short_t nslices = fRawEvt->GetNumLoGainSamples();
|
---|
140 | max = Calc(pixel.GetLoGainSamples(),nslices);
|
---|
141 | }
|
---|
142 |
|
---|
143 |
|
---|
144 | //
|
---|
145 | // Use HiGains
|
---|
146 | //
|
---|
147 | else if (pixel.HasLoGain())
|
---|
148 | {
|
---|
149 |
|
---|
150 | const Short_t nslices = fRawEvt->GetNumHiGainSamples();
|
---|
151 | max = Calc(pixel.GetHiGainSamples(),nslices);
|
---|
152 | }
|
---|
153 |
|
---|
154 | //
|
---|
155 | // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
|
---|
156 | //
|
---|
157 | fArrTime->SetTime(idx,max);
|
---|
158 |
|
---|
159 | }
|
---|
160 |
|
---|
161 | fArrTime->SetReadyToSave();
|
---|
162 |
|
---|
163 | return kTRUE;
|
---|
164 | }
|
---|
165 |
|
---|
166 | //
|
---|
167 | // Calculates the arrival time for each pixel
|
---|
168 | // Possible Methods
|
---|
169 | // Case 1: Spline5 (From TSpline5 Root Class)
|
---|
170 | //
|
---|
171 | //
|
---|
172 | Float_t MArrivalTimeCalc::Calc(const Byte_t *fadcSamples, const Short_t nslices)
|
---|
173 | {
|
---|
174 |
|
---|
175 | //
|
---|
176 | // Initialize a double pointer with filled FADC slices
|
---|
177 | //
|
---|
178 | Double_t ptr[nslices];
|
---|
179 |
|
---|
180 | //
|
---|
181 | // Initialize the spline
|
---|
182 | //
|
---|
183 | for (Int_t i = 0; i < nslices; i++)
|
---|
184 | ptr[i]=(Double_t)fadcSamples[i];
|
---|
185 |
|
---|
186 | TSpline5 spline("spline",0.,(Double_t)(nslices - 1),ptr,nslices);
|
---|
187 |
|
---|
188 | //
|
---|
189 | // Now find the maximum evaluating the spline function at every 1/10 time slice
|
---|
190 | //
|
---|
191 | Double_t abscissa=0.0;
|
---|
192 | Double_t maxAb=0.0;
|
---|
193 | Double_t maxOrd=0.0;
|
---|
194 | Double_t swap = 0.0;
|
---|
195 |
|
---|
196 | while (abscissa <= nslices - 1)
|
---|
197 | {
|
---|
198 |
|
---|
199 | swap = spline.Eval(abscissa);
|
---|
200 |
|
---|
201 | if (swap > maxOrd)
|
---|
202 | {
|
---|
203 | maxOrd = swap;
|
---|
204 | maxAb = abscissa;
|
---|
205 | }
|
---|
206 | abscissa += 0.1;
|
---|
207 | }
|
---|
208 |
|
---|
209 | return (Float_t)maxAb;
|
---|
210 | }
|
---|
211 |
|
---|