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

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