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

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