source: trunk/MagicSoft/Mars/msignal/MArrivalTimeCalc.cc@ 3322

Last change on this file since 3322 was 3320, checked in by gaug, 21 years ago
*** empty log message ***
File size: 4.7 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!
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 "MCubicSpline.h"
44
45#include "MLog.h"
46#include "MLogManip.h"
47
48#include "MParList.h"
49
50#include "MGeomCam.h"
51#include "MArrivalTimeCam.h"
52#include "MArrivalTimePix.h"
53
54#include "MRawEvtData.h"
55#include "MRawEvtPixelIter.h"
56
57ClassImp(MArrivalTimeCalc);
58
59using namespace std;
60
61// --------------------------------------------------------------------------
62//
63// Default constructor.
64//
65//
66MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title)
67{
68
69 fName = name ? name : "MArrivalTimeCalc";
70 fTitle = title ? title : "Calculate photons arrival time";
71
72}
73
74// --------------------------------------------------------------------------
75//
76// The PreProcess searches for the following input containers:
77// - MRawEvtData
78// - MArrivalTime
79//
80// The following output containers are also searched and created if
81// they were not found:
82// - MArrivalTime
83//
84
85Int_t MArrivalTimeCalc::PreProcess(MParList *pList)
86{
87
88
89 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
90 if (!fRawEvt)
91 {
92 *fLog << err << "MRawEvtData not found... aborting." << endl;
93 return kFALSE;
94 }
95
96 fArrTime = (MArrivalTimeCam*)pList->FindCreateObj(AddSerialNumber("MArrivalTimeCam"));
97 if (!fArrTime)
98 return kFALSE;
99
100 return kTRUE;
101}
102
103// --------------------------------------------------------------------------
104//
105// The ReInit searches for the following input containers:
106// - MGeomCam
107//
108Bool_t MArrivalTimeCalc::ReInit(MParList *pList)
109{
110 MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
111 if (!cam)
112 {
113 *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
114 return kFALSE;
115 }
116
117 return kTRUE;
118}
119
120// --------------------------------------------------------------------------
121//
122// Evaluation of the mean arrival times (spline interpolation)
123// per pixel and store them in the MArrivalTime container.
124//
125Int_t MArrivalTimeCalc::Process()
126{
127
128 MRawEvtPixelIter pixel(fRawEvt);
129
130 while (pixel.Next())
131 {
132
133 const UInt_t idx = pixel.GetPixelId();
134 Float_t time = 0.;
135
136
137 //
138 // If pixel is saturated we use LoGains
139 //
140 if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
141 {
142
143 const Short_t nslices = fRawEvt->GetNumLoGainSamples();
144 time = Calc(pixel.GetLoGainSamples(),nslices);
145 }
146
147
148 //
149 // Use HiGains
150 //
151 else if (pixel.HasLoGain())
152 {
153
154 const Short_t nslices = fRawEvt->GetNumHiGainSamples();
155 time = Calc(pixel.GetHiGainSamples(),nslices);
156 }
157
158 //
159 // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
160 //
161 MArrivalTimePix &pix = (*fArrTime)[idx];
162 pix.SetArrivalTime(time,0.);
163 }
164
165 fArrTime->SetReadyToSave();
166
167 return kTRUE;
168}
169
170// --------------------------------------------------------------------------
171//
172// Calculates the arrival time for each pixel
173// Possible Methods
174// Case 1: MCubicSpline (3rd order spline)
175//
176Float_t MArrivalTimeCalc::Calc(const Byte_t *fadcSamples, const Short_t nslices)
177{
178
179 //
180 // Initialize the spline
181 //
182 MCubicSpline *spline = new MCubicSpline(fadcSamples);
183
184 //
185 // Now find the maximum
186 //
187 return (Float_t)spline->EvalAbMax();
188}
189
Note: See TracBrowser for help on using the repository browser.