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

Last change on this file since 9614 was 8618, checked in by tbretz, 17 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-2006
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
48#include "MGeomCam.h"
49
50#include "MCalibrationRelTimeCam.h"
51#include "MCalibrationRelTimePix.h"
52
53#include "MArrivalTimeCam.h"
54#include "MArrivalTimePix.h"
55
56#include "MBadPixelsCam.h"
57#include "MBadPixelsPix.h"
58
59#include "MSignalCam.h"
60#include "MSignalPix.h"
61
62#include "MRawRunHeader.h"
63
64ClassImp(MCalibrateRelTimes);
65
66using namespace std;
67// --------------------------------------------------------------------------
68//
69// Default constructor.
70//
71MCalibrateRelTimes::MCalibrateRelTimes(const char *name, const char *title)
72 : fGeomCam(NULL), fCalibrations(NULL), fBadPixels(NULL), fSignals(NULL),
73 fArrivalTime(NULL)
74{
75 fName = name ? name : "MCalibrateRelTimes";
76 fTitle = title ? title : "Task to calculate the calibrated arrival times of photons in one event";
77}
78
79// --------------------------------------------------------------------------
80//
81// The PreProcess searches for the following input containers:
82// - MGeomCam
83// - MCalibrationRelTimesCam
84// - MArrivalTimeCam
85// - MBadPixelsCam
86//
87Int_t MCalibrateRelTimes::PreProcess(MParList *pList)
88{
89 fSignals = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
90 if (!fSignals)
91 {
92 *fLog << err << AddSerialNumber("MArrivalTimeCam") << " not found ... aborting" << endl;
93 return kFALSE;
94 }
95
96 fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
97 if (!fBadPixels)
98 *fLog << warn << AddSerialNumber("MBadPixelsCam") << " not found ... ignoring." << endl;
99
100 fCalibrations = (MCalibrationRelTimeCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
101 if (!fCalibrations)
102 {
103 *fLog << err << AddSerialNumber("MCalibrationRelTimeCam") << " not found ... aborting." << endl;
104 return kFALSE;
105 }
106
107 fArrivalTime = (MSignalCam*)pList->FindCreateObj(AddSerialNumber("MSignalCam"));
108 if (!fArrivalTime)
109 return kFALSE;
110
111 return kTRUE;
112}
113
114Bool_t MCalibrateRelTimes::ReInit(MParList *pList)
115{
116 MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
117 if (!runheader)
118 {
119 *fLog << err << AddSerialNumber("MRawRunHeader") << " not found ... aborting." << endl;
120 return kFALSE;
121 }
122
123 fFreq = runheader->GetFreqSampling();
124
125 return kTRUE;
126}
127
128// --------------------------------------------------------------------------
129//
130// Apply the calibration factors to the extracted signal according to the
131// selected calibration method
132//
133Int_t MCalibrateRelTimes::Process()
134{
135 const UInt_t npix = fSignals->GetSize();
136
137 for (UInt_t idx=0; idx<npix; idx++)
138 {
139 if (fBadPixels && (*fBadPixels)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
140 continue;
141
142 const MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCalibrations)[idx];
143 const MArrivalTimePix &sig = (*fSignals)[idx];
144
145 const Float_t signal = sig.GetArrivalTime();
146 const Float_t offset = pix.GetTimeOffset();
147
148 // convert from slices to ns
149 const Float_t time = 1000*(signal-offset)/fFreq; // [ns]
150
151 (*fArrivalTime)[idx].SetArrivalTime(time);
152
153 // FIXME: Is this necessary or explicitly done by the signal-
154 // extractor (may depend on the fact whether independent
155 // extractor are or can be used for signal and arrival time)
156 if (fBadPixels && !sig.IsArrivalTimeValid())
157 (*fBadPixels)[idx].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt);
158 }
159
160 fArrivalTime->SetReadyToSave();
161
162 return kTRUE;
163}
Note: See TracBrowser for help on using the repository browser.