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

Last change on this file since 2692 was 2691, checked in by blanch, 21 years ago
*** empty log message ***
File size: 5.4 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
97 fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
98 if (!fCalibrations)
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
135 UInt_t imaxnumpix = fGeomCam->GetNumPixels();
136
137 for (UInt_t pixid = 0; pixid < imaxnumpix; pixid++)
138 {
139
140 MCalibrationPix &pix = (*fCalibrations)[pixid];
141
142 if (pix.IsValid())
143 {
144 MExtractedSignalPix &sig = (*fSignals)[pixid];
145
146 Bool_t logain = sig.IsLoGainUsed();
147
148 Float_t signal;
149 if (logain)
150 signal = sig.GetExtractedSignalLoGain();
151 else
152 signal = sig.GetExtractedSignalHiGain();
153
154
155 // Float_t fCalibraitonConvertionFactor = pix.GetMeanConversionFFactorMethod();
156 Float_t fCalibrationConvertionFactor = pix.GetMeanConversionBlindPixelMethod();
157 Float_t fCalibrationConvertionFactorError = pix.GetErrorConversionBlindPixelMethod();
158
159
160 Float_t nphot = signal*fCalibrationConvertionFactor;
161 Float_t nphoterr = signal*fCalibrationConvertionFactorError;;
162
163 fCerPhotEvt->AddPixel(pixid, nphot, nphoterr);
164 }
165 else
166 (*fCerPhotEvt)[pixid].SetPixelUnused();
167 }
168
169 fCerPhotEvt->FixSize();
170 fCerPhotEvt->SetReadyToSave();
171
172 return kTRUE;
173}
174
Note: See TracBrowser for help on using the repository browser.