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): Abelardo Moralejo, 12/2003 <mailto:moralejo@pd.infn.it>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MMcCalibrationCalc
|
---|
28 | //
|
---|
29 | // This task looks for the ìnformation about FADC pedestals in
|
---|
30 | // MMcFadcHeader and translates it to the pedestal mean and rms (in adc counts),
|
---|
31 | // and in the conversion factor between photons and ADC counts in
|
---|
32 | // MCalibrationCam.
|
---|
33 | // Then we create and fill also the MPedPhotCam object containing the pedestal
|
---|
34 | // rms in units of photons.
|
---|
35 | //
|
---|
36 | // Input Containers:
|
---|
37 | // MMcFadcHeader
|
---|
38 | // [MRawRunHeader]
|
---|
39 | //
|
---|
40 | // Output Containers:
|
---|
41 | // MCalibrationCam
|
---|
42 | // MPedPhotCam
|
---|
43 | //
|
---|
44 | /////////////////////////////////////////////////////////////////////////////
|
---|
45 | #include "MMcCalibrationCalc.h"
|
---|
46 |
|
---|
47 | #include "MParList.h"
|
---|
48 |
|
---|
49 | #include "MLog.h"
|
---|
50 | #include "MLogManip.h"
|
---|
51 |
|
---|
52 | #include "MCalibrationPix.h"
|
---|
53 | #include "MCalibrationCam.h"
|
---|
54 | #include "MExtractedSignalCam.h"
|
---|
55 | #include "MExtractedSignalPix.h"
|
---|
56 | #include "MPedPhotCam.h"
|
---|
57 | #include "MPedPhotPix.h"
|
---|
58 |
|
---|
59 | #include "MRawRunHeader.h"
|
---|
60 | #include "MMcFadcHeader.hxx"
|
---|
61 |
|
---|
62 | ClassImp(MMcCalibrationCalc);
|
---|
63 |
|
---|
64 | using namespace std;
|
---|
65 |
|
---|
66 | MMcCalibrationCalc::MMcCalibrationCalc(const char *name, const char *title)
|
---|
67 | {
|
---|
68 | fName = name ? name : "MMcCalibrationCalc";
|
---|
69 | fTitle = title ? title : "Write MC pedestals and conversion factors into MCalibration Container";
|
---|
70 |
|
---|
71 | fADC2PheInner = 1.;
|
---|
72 | fADC2PheOuter = 1.;
|
---|
73 |
|
---|
74 | }
|
---|
75 |
|
---|
76 | // --------------------------------------------------------------------------
|
---|
77 | //
|
---|
78 | // Check for the run type. Return kTRUE if it is a MC run or if there
|
---|
79 | // is no MC run header (old camera files) kFALSE in case of a different
|
---|
80 | // run type
|
---|
81 | //
|
---|
82 | Bool_t MMcCalibrationCalc::CheckRunType(MParList *pList) const
|
---|
83 | {
|
---|
84 | const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
85 | if (!run)
|
---|
86 | {
|
---|
87 | *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
|
---|
88 | return kTRUE;
|
---|
89 | }
|
---|
90 |
|
---|
91 | return run->GetRunType() == kRTMonteCarlo;
|
---|
92 | }
|
---|
93 |
|
---|
94 | // --------------------------------------------------------------------------
|
---|
95 | //
|
---|
96 | // Make sure, that there is an MCalibrationCam Object in the Parameter List.
|
---|
97 | //
|
---|
98 | Int_t MMcCalibrationCalc::PreProcess(MParList *pList)
|
---|
99 | {
|
---|
100 | //
|
---|
101 | // If it is no MC file skip this function...
|
---|
102 | //
|
---|
103 | if (!CheckRunType(pList))
|
---|
104 | return kTRUE;
|
---|
105 |
|
---|
106 | if ( ! pList->FindCreateObj(AddSerialNumber("MCalibrationCam")))
|
---|
107 | {
|
---|
108 | *fLog << err << dbginf << "Cannot create MCalibrationCam... aborting." << endl;
|
---|
109 | return kFALSE;
|
---|
110 | }
|
---|
111 |
|
---|
112 | fSignalCam = (MExtractedSignalCam*) pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
|
---|
113 | if ( ! fSignalCam)
|
---|
114 | {
|
---|
115 | *fLog << err << dbginf << "Cannot find MExtractedSignalCam... aborting." << endl;
|
---|
116 | return kFALSE;
|
---|
117 | }
|
---|
118 |
|
---|
119 | return kTRUE;
|
---|
120 |
|
---|
121 | }
|
---|
122 |
|
---|
123 | // --------------------------------------------------------------------------
|
---|
124 | //
|
---|
125 | // Check for the runtype.
|
---|
126 | // Search for MCalibrationCam and MMcFadcHeader.
|
---|
127 | //
|
---|
128 | Bool_t MMcCalibrationCalc::ReInit(MParList *pList)
|
---|
129 | {
|
---|
130 | //
|
---|
131 | // If it is no MC file skip this function...
|
---|
132 | //
|
---|
133 | if (!CheckRunType(pList))
|
---|
134 | return kTRUE;
|
---|
135 |
|
---|
136 | //
|
---|
137 | // Now check the existence of all necessary containers. This has
|
---|
138 | // to be done only if this is a MC file.
|
---|
139 | //
|
---|
140 |
|
---|
141 | fHeaderFadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
|
---|
142 | if (!fHeaderFadc)
|
---|
143 | {
|
---|
144 | *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
|
---|
145 | return kFALSE;
|
---|
146 | }
|
---|
147 |
|
---|
148 | fCalCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationCam"));
|
---|
149 |
|
---|
150 | if (!fCalCam)
|
---|
151 | {
|
---|
152 | *fLog << err << dbginf << "Could not create MCalibrationCam... aborting. " << endl;
|
---|
153 | return kFALSE;
|
---|
154 | }
|
---|
155 |
|
---|
156 | return kTRUE;
|
---|
157 | }
|
---|
158 |
|
---|
159 |
|
---|
160 | // --------------------------------------------------------------------------
|
---|
161 | //
|
---|
162 | // Fill the MCalibrationCam object
|
---|
163 | //
|
---|
164 | Int_t MMcCalibrationCalc::Process()
|
---|
165 | {
|
---|
166 | const int num = fCalCam->GetSize();
|
---|
167 |
|
---|
168 | for (int i=0; i<num; i++)
|
---|
169 | {
|
---|
170 | MCalibrationPix &calpix = (*fCalCam)[i];
|
---|
171 | MExtractedSignalPix &sigpix = (*fSignalCam)[i];
|
---|
172 |
|
---|
173 | const Float_t pedestmean = sigpix.IsLoGainUsed()?
|
---|
174 | fSignalCam->GetNumUsedLoGainFADCSlices()*fHeaderFadc->GetPedestal(i) :
|
---|
175 | fSignalCam->GetNumUsedHiGainFADCSlices()*fHeaderFadc->GetPedestal(i);
|
---|
176 |
|
---|
177 | const Float_t pedestrms = sigpix.IsLoGainUsed()?
|
---|
178 | sqrt((Double_t)(fSignalCam->GetNumUsedLoGainFADCSlices())) * fHeaderFadc->GetPedestalRmsLow(i) :
|
---|
179 | sqrt((Double_t)(fSignalCam->GetNumUsedHiGainFADCSlices())) * fHeaderFadc->GetPedestalRmsHigh(i);
|
---|
180 |
|
---|
181 | // ped mean and rms per pixel, according to signal calculation:
|
---|
182 |
|
---|
183 | calpix.SetPedestal(pedestmean, pedestrms);
|
---|
184 |
|
---|
185 | if (i < 397) // FIXME!
|
---|
186 | calpix.SetConversionBlindPixelMethod(fADC2PheInner, 0., 0.);
|
---|
187 | else
|
---|
188 | calpix.SetConversionBlindPixelMethod(fADC2PheOuter, 0., 0.);
|
---|
189 |
|
---|
190 | }
|
---|
191 |
|
---|
192 | return kTRUE;
|
---|
193 | }
|
---|