source: trunk/MagicSoft/Mars/mcalib/MCalibrateRelTimes.cc@ 6965

Last change on this file since 6965 was 6855, checked in by tbretz, 20 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!
18! Author(s): Markus Gaug 04/2004 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MCalibrateRelTimes
28//
29// This task takes the extracted arrival times from MArrivalTimeCam for each
30// pixel and applies the offset calibrated in MCalibrationRelTimeCam
31// The calibrated arrival time and its error gets stored in MSignalCam.
32//
33// Input Containers:
34// MArrivalTimeCam
35// MCalibrationRelTimeCam
36//
37// Output Containers:
38// MSignalCam
39//
40//////////////////////////////////////////////////////////////////////////////
41#include "MCalibrateRelTimes.h"
42
43#include "MLog.h"
44#include "MLogManip.h"
45
46#include "MParList.h"
47#include "MH.h"
48
49#include "MGeomCam.h"
50
51#include "MCalibrationRelTimeCam.h"
52#include "MCalibrationRelTimePix.h"
53
54#include "MArrivalTimeCam.h"
55#include "MArrivalTimePix.h"
56
57#include "MBadPixelsCam.h"
58#include "MBadPixelsPix.h"
59
60#include "MSignalCam.h"
61#include "MSignalPix.h"
62
63ClassImp(MCalibrateRelTimes);
64
65using namespace std;
66// --------------------------------------------------------------------------
67//
68// Default constructor.
69//
70MCalibrateRelTimes::MCalibrateRelTimes(const char *name, const char *title)
71 : fGeomCam(NULL), fCalibrations(NULL), fBadPixels(NULL), fSignals(NULL),
72 fArrivalTime(NULL)
73{
74 fName = name ? name : "MCalibrateRelTimes";
75 fTitle = title ? title : "Task to calculate the calibrated arrival times of photons in one event";
76}
77
78// --------------------------------------------------------------------------
79//
80// The PreProcess searches for the following input containers:
81// - MGeomCam
82// - MCalibrationRelTimesCam
83// - MArrivalTimeCam
84// - MBadPixelsCam
85//
86// The following output containers are also searched and created if
87// they were not found:
88//
89// - MArrivalTime
90//
91Int_t MCalibrateRelTimes::PreProcess(MParList *pList)
92{
93
94 fSignals = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
95
96 if (!fSignals)
97 {
98 *fLog << err << AddSerialNumber("MArrivalTimeCam") << " not found ... aborting" << endl;
99 return kFALSE;
100 }
101
102 fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
103 if (!fBadPixels)
104 *fLog << warn << AddSerialNumber("MBadPixelsCam") << " not found ... no action" << endl;
105
106
107 fCalibrations = (MCalibrationRelTimeCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
108 if (!fCalibrations)
109 {
110 *fLog << err << AddSerialNumber("MCalibrationRelTimeCam") << " not found ... aborting." << endl;
111 return kFALSE;
112 }
113
114
115 fArrivalTime = (MSignalCam*)pList->FindCreateObj(AddSerialNumber("MSignalCam"));
116 if (!fArrivalTime)
117 return kFALSE;
118
119 return kTRUE;
120}
121
122// --------------------------------------------------------------------------
123//
124// Apply the calibration factors to the extracted signal according to the
125// selected calibration method
126//
127Int_t MCalibrateRelTimes::Process()
128{
129 /*
130 if (fCalibrations->GetNumPixels() != (UInt_t)fSignals->GetSize())
131 {
132 // FIXME: MArrivalTime must be of variable size -
133 // like MSignalCam - because we must be able
134 // to reduce size by zero supression
135 // For the moment this check could be done in ReInit...
136 *fLog << err << "MArrivalTime and MCalibrationCam have different sizes... abort." << endl;
137 return kFALSE;
138 }
139 */
140
141 const UInt_t npix = fSignals->GetSize();
142
143 for (UInt_t pixidx=0; pixidx<npix; pixidx++)
144 {
145 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCalibrations)[pixidx];
146
147 if (fBadPixels && (*fBadPixels)[pixidx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
148 continue;
149
150 const Float_t offset = pix.GetTimeOffset();
151
152 MArrivalTimePix &sig = (*fSignals)[pixidx];
153
154 Float_t signal;
155
156 if (sig.IsLoGainUsed())
157 signal = sig.GetArrivalTimeLoGain();
158 else
159 signal = sig.GetArrivalTimeHiGain();
160
161 const Float_t time = signal - offset;
162
163 (*fArrivalTime)[pixidx].SetArrivalTime(time);
164
165 } /* for (UInt_t pixidx=0; pixidx<npix; pixidx++) */
166
167 fArrivalTime->SetReadyToSave();
168
169 return kTRUE;
170}
Note: See TracBrowser for help on using the repository browser.