source: trunk/MagicSoft/Mars/mcalib/MCalibrate.cc@ 2896

Last change on this file since 2896 was 2896, checked in by moralejo, 21 years ago
*** empty log message ***
File size: 5.1 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): Javier Lopez 12/2003 <mailto:jlopez@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MCalibrate
28//
29// This task takes the integrated charge from MExtractedSignal and apply
30// the calibration constants from MCalibraitionCam to the charge. Then
31// stores number of photons obtained in MCerPhotEvt.
32//
33// Input Containers:
34// MExtractedSingal
35// MCalibrationCam
36//
37// Output Containers:
38// MCerPhotEvt
39//
40//////////////////////////////////////////////////////////////////////////////
41#include "MCalibrate.h"
42#include "MCalibrationConfig.h"
43
44#include "MLog.h"
45#include "MLogManip.h"
46
47#include "MParList.h"
48#include "MH.h"
49
50#include "MGeomCam.h"
51
52#include "MCalibrationCam.h"
53#include "MCalibrationPix.h"
54
55#include "MExtractedSignalCam.h"
56#include "MExtractedSignalPix.h"
57
58#include "MCerPhotEvt.h"
59
60ClassImp(MCalibrate);
61
62using namespace std;
63// --------------------------------------------------------------------------
64//
65// Default constructor.
66//
67MCalibrate::MCalibrate(const char *name, const char *title)
68{
69 fName = name ? name : "MCalibrate";
70 fTitle = title ? title : "Task to calculate the number of photons in one event";
71}
72
73// --------------------------------------------------------------------------
74//
75// The PreProcess searches for the following input containers:
76// - MGeomCam
77// - MCalibrationCam
78// - MExtractedSignalCam
79//
80// The following output containers are also searched and created if
81// they were not found:
82//
83// - MCerPhotEvt
84//
85Int_t MCalibrate::PreProcess(MParList *pList)
86{
87 fSignals = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
88 if (!fSignals)
89 {
90 *fLog << err << AddSerialNumber("MExtractedSignalCam") << " not found ... aborting" << endl;
91 return kFALSE;
92 }
93
94 fCalibrations = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationCam"));
95 if (!fCalibrations)
96 {
97 *fLog << err << AddSerialNumber("MCalibrationCam") << " not found ... aborting." << endl;
98 return kFALSE;
99 }
100
101 fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt"));
102 if (!fCerPhotEvt)
103 return kFALSE;
104
105 return kTRUE;
106}
107
108// --------------------------------------------------------------------------
109//
110//
111Int_t MCalibrate::Process()
112{
113 /*
114 if (fCalibrations->GetNumPixels() != (UInt_t)fSignals->GetSize())
115 {
116 // FIXME: MExtractedSignal must be of variable size -
117 // like MCerPhotEvt - because we must be able
118 // to reduce size by zero supression
119 // For the moment this check could be done in ReInit...
120 *fLog << err << "MExtractedSignal and MCalibrationCam have different sizes... abort." << endl;
121 return kFALSE;
122 }
123 */
124
125 UInt_t numpix = fSignals->GetSize();
126
127 for (UInt_t pixid=0; pixid< numpix; pixid++)
128 {
129 const MCalibrationPix &pix = (*fCalibrations)[pixid];
130
131 if (!pix.IsFitValid())
132 continue;
133
134 MExtractedSignalPix &sig = (*fSignals)[pixid];
135
136 Float_t signal;
137 Float_t signalErr = 0.;
138
139 if (sig.IsLoGainUsed())
140 {
141 signal = sig.GetExtractedSignalLoGain()*pix.GetConversionHiLo();
142 signalErr = signal*pix.GetConversionHiLoError();
143 }
144 else
145 {
146 signal = sig.GetExtractedSignalHiGain();
147 }
148
149 // Float_t calibrationConversionFactor = pix.GetMeanConversionFFactorMethod();
150 const Float_t calibrationConversionFactor = pix.GetMeanConversionBlindPixelMethod();
151 const Float_t calibrationConversionFactorError = pix.GetErrorConversionBlindPixelMethod();
152
153 const Float_t nphot = signal*calibrationConversionFactor;
154
155 Float_t nphotErr = signal*calibrationConversionFactorError
156 *signal*calibrationConversionFactorError;
157
158 nphotErr += signalErr*calibrationConversionFactor
159 *signalErr*calibrationConversionFactor;
160
161 nphotErr = TMath::Sqrt(nphotErr);
162
163 MCerPhotPix *cpix = fCerPhotEvt->AddPixel(pixid, nphot, nphotErr);
164
165 if (sig.GetNumLoGainSaturated() > 0)
166 cpix->SetPixelSaturated();
167 }
168
169 fCerPhotEvt->FixSize();
170 fCerPhotEvt->SetReadyToSave();
171
172 return kTRUE;
173}
Note: See TracBrowser for help on using the repository browser.