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/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MHCurrents
|
---|
28 | //
|
---|
29 | /////////////////////////////////////////////////////////////////////////////
|
---|
30 | #include "MHCurrents.h"
|
---|
31 |
|
---|
32 | #include <TCanvas.h>
|
---|
33 |
|
---|
34 | #include "MLog.h"
|
---|
35 | #include "MLogManip.h"
|
---|
36 |
|
---|
37 | #include "MParList.h"
|
---|
38 | #include "MCurrents.h"
|
---|
39 | #include "MCamDisplay.h"
|
---|
40 |
|
---|
41 | #include "MGeomCam.h"
|
---|
42 | #include "MGeomPix.h"
|
---|
43 |
|
---|
44 | ClassImp(MHCurrents);
|
---|
45 |
|
---|
46 | // --------------------------------------------------------------------------
|
---|
47 | //
|
---|
48 | // Reset all pixels to 0 and reset fEntries to 0.
|
---|
49 | //
|
---|
50 | void MHCurrents::Clear()
|
---|
51 | {
|
---|
52 | // FIXME: Implement a clear function with setmem
|
---|
53 | for (int i=0; i<577; i++)
|
---|
54 | fSum[i] = 0;
|
---|
55 |
|
---|
56 | fEntries = 0;
|
---|
57 | }
|
---|
58 |
|
---|
59 | // --------------------------------------------------------------------------
|
---|
60 | //
|
---|
61 | // Initialize the name and title of the task.
|
---|
62 | // Resets the sum histogram
|
---|
63 | //
|
---|
64 | MHCurrents::MHCurrents(const char *name, const char *title)
|
---|
65 | : fSum(577), fCam(NULL), fEvt(NULL), fDispl(NULL)
|
---|
66 | {
|
---|
67 | //
|
---|
68 | // set the name and title of this object
|
---|
69 | //
|
---|
70 | fName = name ? name : "MHCurrents";
|
---|
71 | fTitle = title ? title : "Average of MCerPhotEvts";
|
---|
72 |
|
---|
73 | Clear();
|
---|
74 | }
|
---|
75 |
|
---|
76 | // --------------------------------------------------------------------------
|
---|
77 | //
|
---|
78 | // Delete the corresponding camera display if available
|
---|
79 | //
|
---|
80 | MHCurrents::~MHCurrents()
|
---|
81 | {
|
---|
82 | if (fDispl)
|
---|
83 | delete fDispl;
|
---|
84 | }
|
---|
85 |
|
---|
86 | // --------------------------------------------------------------------------
|
---|
87 | //
|
---|
88 | // Get the event (MCerPhotEvt) the histogram might be filled with. If
|
---|
89 | // it is not given, it is assumed, that it is filled with the argument
|
---|
90 | // of the Fill function.
|
---|
91 | // Looks for the camera geometry MGeomCam and resets the sum histogram.
|
---|
92 | //
|
---|
93 | Bool_t MHCurrents::SetupFill(const MParList *plist)
|
---|
94 | {
|
---|
95 | fEvt = (MCurrents*)plist->FindObject("MCurrents");
|
---|
96 | if (!fEvt)
|
---|
97 | *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl;
|
---|
98 |
|
---|
99 | fCam = (MGeomCam*)plist->FindObject("MGeomCam");
|
---|
100 | if (!fCam)
|
---|
101 | *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
|
---|
102 |
|
---|
103 | Clear();
|
---|
104 |
|
---|
105 | return kTRUE;
|
---|
106 | }
|
---|
107 |
|
---|
108 | // --------------------------------------------------------------------------
|
---|
109 | //
|
---|
110 | // Fill the histograms with data from a MCerPhotEvt-Container.
|
---|
111 | //
|
---|
112 | Bool_t MHCurrents::Fill(const MParContainer *par, const Stat_t w)
|
---|
113 | {
|
---|
114 | const MCurrents *evt = par ? (MCurrents*)par : fEvt;
|
---|
115 | if (!evt)
|
---|
116 | {
|
---|
117 | *fLog << err << dbginf << "No MCurrents found..." << endl;
|
---|
118 | return kFALSE;
|
---|
119 | }
|
---|
120 |
|
---|
121 | for (UInt_t i=0; i<577; i++)
|
---|
122 | fSum[i] += (*evt)[i];
|
---|
123 |
|
---|
124 | fEntries++;
|
---|
125 |
|
---|
126 | return kTRUE;
|
---|
127 | }
|
---|
128 |
|
---|
129 | // --------------------------------------------------------------------------
|
---|
130 | //
|
---|
131 | // Scale the sum container with the number of entries
|
---|
132 | //
|
---|
133 | Bool_t MHCurrents::Finalize()
|
---|
134 | {
|
---|
135 | for (UInt_t i=0; i<577; i++)
|
---|
136 | fSum[i] /= fEntries;
|
---|
137 |
|
---|
138 | return kTRUE;
|
---|
139 | }
|
---|
140 |
|
---|
141 | // --------------------------------------------------------------------------
|
---|
142 | //
|
---|
143 | // Draw the present 'fill status'
|
---|
144 | //
|
---|
145 | void MHCurrents::Draw(Option_t *)
|
---|
146 | {
|
---|
147 | if (!fCam)
|
---|
148 | {
|
---|
149 | *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl;
|
---|
150 | return;
|
---|
151 | }
|
---|
152 |
|
---|
153 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600);
|
---|
154 | pad->SetBorderMode(0);
|
---|
155 |
|
---|
156 | AppendPad("");
|
---|
157 | }
|
---|
158 |
|
---|
159 | // --------------------------------------------------------------------------
|
---|
160 | //
|
---|
161 | // If a camera display is not yet assigned, assign a new one.
|
---|
162 | //
|
---|
163 | void MHCurrents::Paint(Option_t *option)
|
---|
164 | {
|
---|
165 | if (!fCam)
|
---|
166 | {
|
---|
167 | *fLog << warn << "WARNING - Cannot paint " << GetDescriptor() << ": No Camera Geometry available." << endl;
|
---|
168 | return;
|
---|
169 | }
|
---|
170 |
|
---|
171 | if (!fDispl)
|
---|
172 | fDispl = new MCamDisplay(fCam);
|
---|
173 |
|
---|
174 | fDispl->FillCurrents(fSum);
|
---|
175 | fDispl->Paint();
|
---|
176 | }
|
---|