source: trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc@ 3261

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