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,
|
---|
31 | // and in the conversion factor between photons and ADC counts in
|
---|
32 | // MCalibrationCam.
|
---|
33 | //
|
---|
34 | // Input Containers:
|
---|
35 | // MMcFadcHeader
|
---|
36 | // [MRawRunHeader]
|
---|
37 | //
|
---|
38 | // Output Containers:
|
---|
39 | // MCalibrationCam
|
---|
40 | //
|
---|
41 | /////////////////////////////////////////////////////////////////////////////
|
---|
42 | #include "MMcCalibrationCalc.h"
|
---|
43 |
|
---|
44 | #include "MParList.h"
|
---|
45 |
|
---|
46 | #include "MLog.h"
|
---|
47 | #include "MLogManip.h"
|
---|
48 |
|
---|
49 | #include "MCalibrationPix.h"
|
---|
50 | #include "MCalibrationCam.h"
|
---|
51 |
|
---|
52 | #include "MRawRunHeader.h"
|
---|
53 | #include "MMcFadcHeader.hxx"
|
---|
54 |
|
---|
55 | ClassImp(MMcCalibrationCalc);
|
---|
56 |
|
---|
57 | using namespace std;
|
---|
58 |
|
---|
59 | MMcCalibrationCalc::MMcCalibrationCalc(const char *name, const char *title)
|
---|
60 | {
|
---|
61 | fName = name ? name : "MMcCalibrationCalc";
|
---|
62 | fTitle = title ? title : "Write MC pedestals and conversion factors into MCalibration Container";
|
---|
63 |
|
---|
64 | }
|
---|
65 |
|
---|
66 | // --------------------------------------------------------------------------
|
---|
67 | //
|
---|
68 | // Check for the run type. Return kTRUE if it is a MC run or if there
|
---|
69 | // is no MC run header (old camera files) kFALSE in case of a different
|
---|
70 | // run type
|
---|
71 | //
|
---|
72 | Bool_t MMcCalibrationCalc::CheckRunType(MParList *pList) const
|
---|
73 | {
|
---|
74 | const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
75 | if (!run)
|
---|
76 | {
|
---|
77 | *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
|
---|
78 | return kTRUE;
|
---|
79 | }
|
---|
80 |
|
---|
81 | return run->GetRunType() == kRTMonteCarlo;
|
---|
82 | }
|
---|
83 |
|
---|
84 | // --------------------------------------------------------------------------
|
---|
85 | //
|
---|
86 | // Make sure, that there is an MCalibrationCam Object in the Parameter List.
|
---|
87 | //
|
---|
88 | Int_t MMcCalibrationCalc::PreProcess(MParList *pList)
|
---|
89 | {
|
---|
90 | //
|
---|
91 | // If it is no MC file skip this function...
|
---|
92 | //
|
---|
93 | if (!CheckRunType(pList))
|
---|
94 | return kTRUE;
|
---|
95 |
|
---|
96 | return pList->FindCreateObj(AddSerialNumber("MCalibrationCam")) ? kTRUE : kFALSE;
|
---|
97 | }
|
---|
98 |
|
---|
99 | // --------------------------------------------------------------------------
|
---|
100 | //
|
---|
101 | // Check for the runtype.
|
---|
102 | // Search for MCalibrationCam and MMcFadcHeader.
|
---|
103 | //
|
---|
104 | Bool_t MMcCalibrationCalc::ReInit(MParList *pList)
|
---|
105 | {
|
---|
106 | //
|
---|
107 | // If it is no MC file skip this function...
|
---|
108 | //
|
---|
109 | if (!CheckRunType(pList))
|
---|
110 | return kTRUE;
|
---|
111 |
|
---|
112 | //
|
---|
113 | // Now check the existence of all necessary containers. This has
|
---|
114 | // to be done only if this is a MC file.
|
---|
115 | //
|
---|
116 |
|
---|
117 | fHeaderFadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
|
---|
118 | if (!fHeaderFadc)
|
---|
119 | {
|
---|
120 | *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
|
---|
121 | return kFALSE;
|
---|
122 | }
|
---|
123 |
|
---|
124 | fCalCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationCam"));
|
---|
125 |
|
---|
126 | if (!fCalCam)
|
---|
127 | {
|
---|
128 | *fLog << err << dbginf << "Could not create MCalibrationCam... aborting. " << endl;
|
---|
129 | return kFALSE;
|
---|
130 | }
|
---|
131 |
|
---|
132 | return kTRUE;
|
---|
133 | }
|
---|
134 |
|
---|
135 |
|
---|
136 | // --------------------------------------------------------------------------
|
---|
137 | //
|
---|
138 | // Fill the MCalibrationCam object
|
---|
139 | //
|
---|
140 | Int_t MMcCalibrationCalc::Process()
|
---|
141 | {
|
---|
142 | const int num = fCalCam->GetSize();
|
---|
143 |
|
---|
144 | for (int i=0; i<num; i++)
|
---|
145 | {
|
---|
146 | MCalibrationPix &pix = (*fCalCam)[i];
|
---|
147 |
|
---|
148 | const Float_t pedestmean = fHeaderFadc->GetPedestal(i);
|
---|
149 | const Float_t pedestrms = fHeaderFadc->GetPedestalRmsHigh(i);
|
---|
150 | // per slice
|
---|
151 |
|
---|
152 | pix.SetPedestal(pedestmean, pedestrms);
|
---|
153 | }
|
---|
154 |
|
---|
155 | return kTRUE;
|
---|
156 | }
|
---|