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

Last change on this file since 2726 was 2726, checked in by gaug, 21 years ago
*** empty log message ***
File size: 5.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// //
35// MGeomCam //
36// MExtractedSingal //
37// MCalibrationCam //
38// //
39// Output Containers: //
40// //
41// MCerPhotEvt //
42// //
43//////////////////////////////////////////////////////////////////////////////
44
45#include "MCalibrate.h"
46#include "MCalibrationConfig.h"
47
48#include "MLog.h"
49#include "MLogManip.h"
50
51#include "MParList.h"
52#include "MH.h"
53
54#include "MGeomCam.h"
55
56#include "MCalibrationCam.h"
57#include "MCalibrationPix.h"
58
59#include "MExtractedSignalCam.h"
60#include "MExtractedSignalPix.h"
61
62#include "MCerPhotEvt.h"
63
64#include "MTime.h"
65#include "TMath.h"
66
67ClassImp(MCalibrate);
68
69using namespace std;
70// --------------------------------------------------------------------------
71//
72// Default constructor.
73//
74MCalibrate::MCalibrate(const char *name, const char *title)
75{
76
77 fName = name ? name : "MCalibrate";
78 fTitle = title ? title : "Task to calculate the number of photons in one event";
79
80}
81
82// --------------------------------------------------------------------------
83//
84// The PreProcess searches for the following input containers:
85// - MGeomCam
86// - MCalibrationCam
87// - MExtractedSignalCam
88//
89// The following output containers are also searched and created if
90// they were not found:
91//
92// - MCerPhotEvt
93//
94Int_t MCalibrate::PreProcess(MParList *pList)
95{
96
97 fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
98 if (!fGeomCam)
99 {
100 *fLog << err << dbginf << "MGeomCam not found ... aborting." << endl;
101 return kFALSE;
102 }
103
104 fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
105 if (!fSignals)
106 {
107 *fLog << err << dbginf << "MExtractedSignalCam not found ... aborting" << endl;
108 return kFALSE;
109 }
110
111 fCalibrations = (MCalibrationCam*)pList->FindObject("MCalibrationCam");
112 if (!fCalibrations)
113 {
114 *fLog << err << dbginf << "MCalibrationCam not found ... aborting." << endl;
115 return kFALSE;
116 }
117
118 fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
119 if (!fCerPhotEvt)
120 {
121 *fLog << err << dbginf << "Cannot create MCerPhotEvt ... aborting" << endl;
122 return kFALSE;
123 }
124
125 return kTRUE;
126}
127
128
129// --------------------------------------------------------------------------
130//
131//
132Int_t MCalibrate::Process()
133{
134 UInt_t imaxnumpix = fGeomCam->GetNumPixels();
135
136 for (UInt_t pixid = 0; pixid < imaxnumpix; pixid++)
137 {
138 MCalibrationPix &pix = (*fCalibrations)[pixid];
139
140
141 if (pix.IsBlindPixelMethodValid())
142 {
143 MExtractedSignalPix &sig = (*fSignals)[pixid];
144
145 Float_t signal;
146 Float_t signalErr = 0.;
147
148 if (sig.IsLoGainUsed())
149 {
150 signal = sig.GetExtractedSignalLoGain()*pix.GetConversionHiLo();
151 signalErr = signal*pix.GetConversionHiLoError();
152 }
153 else
154 {
155 signal = sig.GetExtractedSignalHiGain();
156 }
157
158 // Float_t calibrationConvertionFactor = pix.GetMeanConversionFFactorMethod();
159 Float_t calibrationConversionFactor = pix.GetMeanConversionBlindPixelMethod();
160 Float_t calibrationConversionFactorError = pix.GetErrorConversionBlindPixelMethod();
161
162 Float_t nphot = signal*calibrationConversionFactor;
163 Float_t nphotErr = signal*calibrationConversionFactorError
164 *signal*calibrationConversionFactorError;
165 nphotErr += signalErr*calibrationConversionFactor
166 *signalErr*calibrationConversionFactor;
167
168 nphotErr = TMath::Sqrt(nphotErr);
169
170 fCerPhotEvt->AddPixel(pixid, nphot, nphotErr);
171 }
172 else
173 {
174 fCerPhotEvt->AddPixel(pixid, 0., 0.);
175 (*fCerPhotEvt)[pixid].SetPixelUnused();
176 }
177 }
178
179 fCerPhotEvt->FixSize();
180 fCerPhotEvt->SetReadyToSave();
181
182 return kTRUE;
183}
184
Note: See TracBrowser for help on using the repository browser.