source: trunk/MagicSoft/Mars/manalysis/MCalibrate.cc@ 2733

Last change on this file since 2733 was 2731, checked in by moralejo, 21 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): 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
60#include "MTime.h"
61#include "TMath.h"
62
63ClassImp(MCalibrate);
64
65using namespace std;
66// --------------------------------------------------------------------------
67//
68// Default constructor.
69//
70MCalibrate::MCalibrate(const char *name, const char *title)
71{
72 fName = name ? name : "MCalibrate";
73 fTitle = title ? title : "Task to calculate the number of photons in one event";
74}
75
76// --------------------------------------------------------------------------
77//
78// The PreProcess searches for the following input containers:
79// - MGeomCam
80// - MCalibrationCam
81// - MExtractedSignalCam
82//
83// The following output containers are also searched and created if
84// they were not found:
85//
86// - MCerPhotEvt
87//
88Int_t MCalibrate::PreProcess(MParList *pList)
89{
90 fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
91 if (!fSignals)
92 {
93 *fLog << err << "MExtractedSignalCam not found ... aborting" << endl;
94 return kFALSE;
95 }
96
97 fCalibrations = (MCalibrationCam*)pList->FindObject("MCalibrationCam");
98 if (!fCalibrations)
99 {
100 *fLog << err << "MCalibrationCam not found ... aborting." << endl;
101 return kFALSE;
102 }
103
104 fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
105 if (!fCerPhotEvt)
106 return kFALSE;
107
108 return kTRUE;
109}
110
111// --------------------------------------------------------------------------
112//
113//
114Int_t MCalibrate::Process()
115{
116 /*
117 if (fCalibrations->GetNumPixels() != (UInt_t)fSignals->GetSize())
118 {
119 // FIXME: MExtractedSignal must be of variable size -
120 // like MCerPhotEvt - because we must be able
121 // to reduce size by zero supression
122 // For the moment this check could be done in ReInit...
123 *fLog << err << "MExtractedSignal and MCalibrationCam have different sizes... abort." << endl;
124 return kFALSE;
125 }
126 */
127
128 const UInt_t imaxnumpix = fSignals->GetSize();
129
130 for (UInt_t pixidx=0; pixidx<imaxnumpix; pixidx++)
131 {
132 const MCalibrationPix &pix = (*fCalibrations)[pixidx];
133
134 if (!pix.IsBlindPixelMethodValid())
135 continue;
136
137 MExtractedSignalPix &sig = (*fSignals)[pixidx];
138
139 Float_t signal;
140 Float_t signalErr = 0.;
141
142 if (sig.IsLoGainUsed())
143 {
144 signal = sig.GetExtractedSignalLoGain()*pix.GetConversionHiLo();
145 signalErr = signal*pix.GetConversionHiLoError();
146 }
147 else
148 {
149 signal = sig.GetExtractedSignalHiGain();
150 }
151
152 // Float_t calibrationConversionFactor = pix.GetMeanConversionFFactorMethod();
153 const Float_t calibrationConversionFactor = pix.GetMeanConversionBlindPixelMethod();
154 const Float_t calibrationConversionFactorError = pix.GetErrorConversionBlindPixelMethod();
155
156 const Float_t nphot = signal*calibrationConversionFactor;
157 Float_t nphotErr = signal*calibrationConversionFactorError
158 *signal*calibrationConversionFactorError;
159 nphotErr += signalErr*calibrationConversionFactor
160 *signalErr*calibrationConversionFactor;
161
162 nphotErr = TMath::Sqrt(nphotErr);
163
164 fCerPhotEvt->AddPixel(pixidx, nphot, nphotErr);
165 }
166
167 fCerPhotEvt->FixSize();
168 fCerPhotEvt->SetReadyToSave();
169
170 return kTRUE;
171}
Note: See TracBrowser for help on using the repository browser.