source: trunk/Mars/msignal/MArrivalTimeCalc.cc@ 13778

Last change on this file since 13778 was 3864, checked in by gaug, 21 years ago
*** empty log message ***
File size: 5.0 KB
Line 
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! Author(s): Sebastian Raducci 12/2003 <mailto:raducci@fisica.uniud.it>
18!
19! Copyright: MAGIC Software Development, 2002-2004
20!
21!
22\* ======================================================================== */
23
24//////////////////////////////////////////////////////////////////////////////
25//
26// MArrivalTimeCalc
27//
28// This is a task that calculates the arrival times of photons.
29// It returns the absolute maximum of the spline that interpolates
30// the FADC slices
31//
32// Input Containers:
33// MRawEvtData
34//
35// Output Containers:
36// MArrivalTime
37// MRawEvtData
38//
39//////////////////////////////////////////////////////////////////////////////
40#include "MArrivalTimeCalc.h"
41
42#include "MCubicSpline.h"
43
44#include "MLog.h"
45#include "MLogManip.h"
46
47#include "MParList.h"
48
49#include "MGeomCam.h"
50#include "MArrivalTimeCam.h"
51#include "MArrivalTimePix.h"
52
53#include "MRawEvtData.h"
54#include "MRawEvtPixelIter.h"
55
56#include "MPedestalCam.h"
57#include "MPedestalPix.h"
58
59ClassImp(MArrivalTimeCalc);
60
61using namespace std;
62
63const Byte_t MArrivalTimeCalc::fgSaturationLimit = 254;
64// --------------------------------------------------------------------------
65//
66// Default constructor.
67//
68//
69MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title)
70{
71
72 fName = name ? name : "MArrivalTimeCalc";
73 fTitle = title ? title : "Calculate photons arrival time";
74
75 SetSaturationLimit();
76}
77
78// --------------------------------------------------------------------------
79//
80// The PreProcess searches for the following input containers:
81// - MRawEvtData
82// - MPedestalCam
83//
84// The following output containers are also searched and created if
85// they were not found:
86// - MArrivalTimeCam
87//
88
89Int_t MArrivalTimeCalc::PreProcess(MParList *pList)
90{
91
92 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
93 if (!fRawEvt)
94 {
95 *fLog << err << "MRawEvtData not found... aborting." << endl;
96 return kFALSE;
97 }
98
99 fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
100 if (!fPedestals)
101 {
102 *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
103 return kFALSE;
104 }
105
106
107 fArrTime = (MArrivalTimeCam*)pList->FindCreateObj(AddSerialNumber("MArrivalTimeCam"));
108 if (!fArrTime)
109 return kFALSE;
110
111 return kTRUE;
112}
113
114// --------------------------------------------------------------------------
115//
116// Evaluation of the mean arrival times (spline interpolation)
117// per pixel and store them in the MArrivalTime container.
118//
119Int_t MArrivalTimeCalc::Process()
120{
121
122 MRawEvtPixelIter pixel(fRawEvt);
123
124 while (pixel.Next())
125 {
126
127 const UInt_t idx = pixel.GetPixelId();
128 Float_t time = 0.;
129
130
131 //
132 // If pixel is saturated we use LoGains
133 //
134 if ((pixel.GetMaxHiGainSample() >= fSaturationLimit) && pixel.HasLoGain())
135 {
136
137 const Short_t nslices = fRawEvt->GetNumLoGainSamples();
138 time = Calc(pixel.GetLoGainSamples(),nslices,idx);
139 }
140
141
142 //
143 // Use HiGains
144 //
145 else if (pixel.HasLoGain())
146 {
147
148 const Short_t nslices = fRawEvt->GetNumHiGainSamples();
149 time = Calc(pixel.GetHiGainSamples(),nslices,idx);
150 }
151
152 //
153 // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
154 //
155 MArrivalTimePix &pix = (*fArrTime)[idx];
156 pix.SetArrivalTime(time,0.);
157 }
158
159 fArrTime->SetReadyToSave();
160
161 return kTRUE;
162}
163
164// --------------------------------------------------------------------------
165//
166// Calculates the arrival time for each pixel
167// Possible Methods
168// Case 1: MCubicSpline (3rd order spline)
169//
170Float_t MArrivalTimeCalc::Calc(const Byte_t *fadcSamples, const Short_t nslices, const UInt_t idx)
171{
172
173 //
174 // Initialize the spline
175 //
176 MCubicSpline *spline = new MCubicSpline(fadcSamples);
177
178 //
179 // Now find the maximum
180 //
181 Double_t abMaximum = spline->EvalAbMax();
182 Double_t maximum = spline->EvalMax();
183 const MPedestalPix &ped = (*fPedestals)[idx];
184 const Double_t pedestal = ped.GetPedestal();
185 const Double_t halfMax = (maximum + pedestal)/2.;
186 Float_t time = (halfMax > pedestal) ? (Float_t ) spline->FindVal(halfMax,abMaximum,'l'): 0.0;
187 delete spline;
188 return time;
189
190}
191
Note: See TracBrowser for help on using the repository browser.