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

Last change on this file since 2728 was 2728, checked in by tbretz, 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 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 const UInt_t imaxnumpix = fSignals->GetSize();
127
128 for (UInt_t pixidx=0; pixidx<imaxnumpix; pixidx++)
129 {
130 const MCalibrationPix &pix = (*fCalibrations)[pixidx];
131
132 if (!pix.IsBlindPixelMethodValid())
133 continue;
134
135 MExtractedSignalPix &sig = (*fSignals)[pixidx];
136
137 Float_t signal;
138 Float_t signalErr = 0.;
139
140 if (sig.IsLoGainUsed())
141 {
142 signal = sig.GetExtractedSignalLoGain()*pix.GetConversionHiLo();
143 signalErr = signal*pix.GetConversionHiLoError();
144 }
145 else
146 {
147 signal = sig.GetExtractedSignalHiGain();
148 }
149
150 // Float_t calibrationConvertionFactor = pix.GetMeanConversionFFactorMethod();
151 const Float_t calibrationConversionFactor = pix.GetMeanConversionBlindPixelMethod();
152 const Float_t calibrationConversionFactorError = pix.GetErrorConversionBlindPixelMethod();
153
154 const Float_t nphot = signal*calibrationConversionFactor;
155 Float_t nphotErr = signal*calibrationConversionFactorError
156 *signal*calibrationConversionFactorError;
157 nphotErr += signalErr*calibrationConversionFactor
158 *signalErr*calibrationConversionFactor;
159
160 nphotErr = TMath::Sqrt(nphotErr);
161
162 fCerPhotEvt->AddPixel(pixidx, nphot, nphotErr);
163 }
164
165 fCerPhotEvt->FixSize();
166 fCerPhotEvt->SetReadyToSave();
167
168 return kTRUE;
169}
Note: See TracBrowser for help on using the repository browser.