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): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MMcPedestalCopy
|
---|
28 | //
|
---|
29 | // This task looks for the ìnformation about FADC pedestals in
|
---|
30 | // MMcFadcHeader and translates it to the pedestal values in
|
---|
31 | // MPedestalCam
|
---|
32 | //
|
---|
33 | // Input Containers:
|
---|
34 | // MMcFadcHeader
|
---|
35 | //
|
---|
36 | // Output Containers:
|
---|
37 | // MPedestalCam
|
---|
38 | //
|
---|
39 | /////////////////////////////////////////////////////////////////////////////
|
---|
40 | #include "MMcPedestalCopy.h"
|
---|
41 |
|
---|
42 | #include "MParList.h"
|
---|
43 |
|
---|
44 | #include "MLog.h"
|
---|
45 | #include "MLogManip.h"
|
---|
46 |
|
---|
47 | #include "MPedestalPix.h"
|
---|
48 | #include "MPedestalCam.h"
|
---|
49 |
|
---|
50 | #include "MRawRunHeader.h"
|
---|
51 | #include "MMcRunHeader.hxx"
|
---|
52 | #include "MMcFadcHeader.hxx"
|
---|
53 |
|
---|
54 | ClassImp(MMcPedestalCopy);
|
---|
55 |
|
---|
56 | using namespace std;
|
---|
57 |
|
---|
58 | MMcPedestalCopy::MMcPedestalCopy(const char *name, const char *title)
|
---|
59 | {
|
---|
60 | fName = name ? name : "MMcPedestalCopy";
|
---|
61 | fTitle = title ? title : "Copy MC pedestals into MPedestal Container";
|
---|
62 |
|
---|
63 | //
|
---|
64 | // This is not needed here using MReadMarsFile because for the
|
---|
65 | // RunHeader tree the auto scheme is disabled by default
|
---|
66 | //
|
---|
67 | AddToBranchList("MMcFadcHeader.fPedesMean");
|
---|
68 | AddToBranchList("MMcFadcHeader.fElecNoise");
|
---|
69 | }
|
---|
70 |
|
---|
71 | // --------------------------------------------------------------------------
|
---|
72 | //
|
---|
73 | // Check for the run type. Return kTRUE if it is a MC run or if there
|
---|
74 | // is no MC run header (old camera files) kFALSE in case of a different
|
---|
75 | // run type
|
---|
76 | //
|
---|
77 | Bool_t MMcPedestalCopy::CheckRunType(MParList *pList) const
|
---|
78 | {
|
---|
79 | const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
80 | if (!run)
|
---|
81 | {
|
---|
82 | *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
|
---|
83 | return kTRUE;
|
---|
84 | }
|
---|
85 |
|
---|
86 | return run->GetRunType() == kRTMonteCarlo;
|
---|
87 | }
|
---|
88 |
|
---|
89 | // --------------------------------------------------------------------------
|
---|
90 | //
|
---|
91 | // Search for MPedestalCam and MMcFadcHeader.
|
---|
92 | //
|
---|
93 | Int_t MMcPedestalCopy::PreProcess(MParList *pList)
|
---|
94 | {
|
---|
95 | fMcRun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
|
---|
96 | if (!fMcRun)
|
---|
97 | *fLog << warn << dbginf << "MMcRunHeader not found... assuming camera<0.7" << endl;
|
---|
98 |
|
---|
99 | fPedCam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
|
---|
100 | if (!fPedCam)
|
---|
101 | return kFALSE;
|
---|
102 |
|
---|
103 | fMcPed = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
|
---|
104 | if (!fMcPed)
|
---|
105 | {
|
---|
106 | *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
|
---|
107 | return kFALSE;
|
---|
108 | }
|
---|
109 |
|
---|
110 | return kTRUE;
|
---|
111 | }
|
---|
112 |
|
---|
113 | // --------------------------------------------------------------------------
|
---|
114 | //
|
---|
115 | // Check for the runtype.
|
---|
116 | // Initialize the size of MPedestalCam to the number of pixels from
|
---|
117 | // MMcFadcHeader.
|
---|
118 | //
|
---|
119 | Bool_t MMcPedestalCopy::ReInit(MParList *pList)
|
---|
120 | {
|
---|
121 | if (!CheckRunType(pList))
|
---|
122 | return kFALSE;
|
---|
123 |
|
---|
124 | const int num = fPedCam->GetSize();
|
---|
125 |
|
---|
126 | const Bool_t camver70 = fMcRun && fMcRun->GetCamVersion()>=70;
|
---|
127 |
|
---|
128 | for (int i=0; i<num; i++)
|
---|
129 | {
|
---|
130 | MPedestalPix &pix = (*fPedCam)[i];
|
---|
131 |
|
---|
132 | // Here one should compute the Pedestal taking into account how
|
---|
133 | // the MC makes the transformation analogic-digital for the FADC.
|
---|
134 |
|
---|
135 | const Float_t pedest = fMcPed->GetPedestal(i);
|
---|
136 | const Float_t sigma = camver70 ? fMcPed->GetPedestalRmsHigh(i) : fMcPed->GetElecNoise(i);
|
---|
137 |
|
---|
138 | pix.Set(pedest, sigma);
|
---|
139 | }
|
---|
140 |
|
---|
141 | if (camver70)
|
---|
142 | fPedCam->SetReadyToSave();
|
---|
143 |
|
---|
144 | return kTRUE;
|
---|
145 | }
|
---|