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

Last change on this file since 7749 was 7353, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 4.2 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//
86Int_t MCalibrateRelTimes::PreProcess(MParList *pList)
87{
88 fSignals = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
89
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
114// --------------------------------------------------------------------------
115//
116// Apply the calibration factors to the extracted signal according to the
117// selected calibration method
118//
119Int_t MCalibrateRelTimes::Process()
120{
121 const UInt_t npix = fSignals->GetSize();
122
123 for (UInt_t idx=0; idx<npix; idx++)
124 {
125 if (fBadPixels && (*fBadPixels)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
126 continue;
127
128 const MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCalibrations)[idx];
129 const MArrivalTimePix &sig = (*fSignals)[idx];
130
131 const Float_t signal = sig.GetArrivalTime();
132 const Float_t offset = pix.GetTimeOffset();
133
134 (*fArrivalTime)[idx].SetArrivalTime(signal - offset);
135 }
136
137 fArrivalTime->SetReadyToSave();
138
139 return kTRUE;
140}
Note: See TracBrowser for help on using the repository browser.