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 07/2001 (tbretz@uni-sw.gwdg.de)
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | // //
|
---|
27 | // MFillH //
|
---|
28 | // //
|
---|
29 | // This is a common interface (task) to fill mars histograms. Every mars //
|
---|
30 | // histogram which is derived from MH can be filled with this task. //
|
---|
31 | // //
|
---|
32 | // You must specifiy the parameter container with which data the histogram //
|
---|
33 | // container should be filled, and the histogram container which has //
|
---|
34 | // to be filled. This can be done by either specifing the name of the //
|
---|
35 | // objects in the parameter list or by specifiing a pointer to the object. //
|
---|
36 | // (s. Constructor) //
|
---|
37 | // //
|
---|
38 | // WARNING: //
|
---|
39 | // Because MFillH is a generalized task to fill histograms it doesn't //
|
---|
40 | // know about which branches from a file are necessary to fill the //
|
---|
41 | // histograms. If you are reading data from a file which is directly //
|
---|
42 | // filled into a histogram via MFillH, please call either //
|
---|
43 | // MReadTree::DisableAutoScheme() or enable the necessary branches by //
|
---|
44 | // yourself, using MReadTree::EnableBranch() //
|
---|
45 | // //
|
---|
46 | // Input Containers: //
|
---|
47 | // A parameter container //
|
---|
48 | // //
|
---|
49 | // Output Containers: //
|
---|
50 | // A histogram container //
|
---|
51 | // //
|
---|
52 | //////////////////////////////////////////////////////////////////////////////
|
---|
53 | #include "MFillH.h"
|
---|
54 |
|
---|
55 | #include "MLog.h"
|
---|
56 | #include "MLogManip.h"
|
---|
57 |
|
---|
58 | #include "MH.h"
|
---|
59 | #include "MParList.h"
|
---|
60 |
|
---|
61 | ClassImp(MFillH);
|
---|
62 |
|
---|
63 | // --------------------------------------------------------------------------
|
---|
64 | //
|
---|
65 | // Initializes name and title of the object. It is called by all
|
---|
66 | // constructors.
|
---|
67 | //
|
---|
68 | void MFillH::Init(const char *name, const char *title)
|
---|
69 | {
|
---|
70 | fName = name ? name : "MFillH";
|
---|
71 | fTitle = title ? title : "Task to fill Mars histograms";
|
---|
72 |
|
---|
73 | fH = NULL;
|
---|
74 | fParContainer = NULL;
|
---|
75 | }
|
---|
76 |
|
---|
77 | // --------------------------------------------------------------------------
|
---|
78 | //
|
---|
79 | // Constructor.
|
---|
80 | //
|
---|
81 | // - par is the name of the parameter container which should be filled into
|
---|
82 | // the histogram
|
---|
83 | // - hist is the name of the histogram container (which must have been
|
---|
84 | // derived from MH)
|
---|
85 | //
|
---|
86 | MFillH::MFillH(const char *par, const char *hist, const char *name, const char *title)
|
---|
87 | {
|
---|
88 | Init(name, title);
|
---|
89 |
|
---|
90 | fParContainerName = par;
|
---|
91 | fHName = hist;
|
---|
92 | }
|
---|
93 |
|
---|
94 | // --------------------------------------------------------------------------
|
---|
95 | //
|
---|
96 | // Constructor.
|
---|
97 | //
|
---|
98 | // - par is a pointer to the instance of your parameter container from which
|
---|
99 | // the data should be used to fill the histogram.
|
---|
100 | // - hist is the name of the histogram container (which must have been
|
---|
101 | // derived from MH)
|
---|
102 | //
|
---|
103 | MFillH::MFillH(const MParContainer *par, const char *hist, const char *name, const char *title)
|
---|
104 | {
|
---|
105 | Init(name, title);
|
---|
106 |
|
---|
107 | fParContainer = par;
|
---|
108 | fHName = hist;
|
---|
109 | }
|
---|
110 |
|
---|
111 | // --------------------------------------------------------------------------
|
---|
112 | //
|
---|
113 | // Constructor.
|
---|
114 | //
|
---|
115 | // - par is a pointer to the instance of your parameter container from which
|
---|
116 | // the data should be used to fill the histogram.
|
---|
117 | // - hist is a pointer to the instance of your histogram container (which must
|
---|
118 | // have been derived from MH) into which the data should flow
|
---|
119 | //
|
---|
120 | MFillH::MFillH(const char *par, MH *hist, const char *name, const char *title)
|
---|
121 | {
|
---|
122 | Init(name, title);
|
---|
123 |
|
---|
124 | fParContainerName = par;
|
---|
125 | fH = hist;
|
---|
126 | }
|
---|
127 |
|
---|
128 | // --------------------------------------------------------------------------
|
---|
129 | //
|
---|
130 | // Constructor.
|
---|
131 | //
|
---|
132 | // - par is a pointer to the instance of your parameter container from which
|
---|
133 | // the data should be used to fill the histogram.
|
---|
134 | // - hist is the name of the histogram container (which must have been
|
---|
135 | // derived from MH)
|
---|
136 | //
|
---|
137 | MFillH::MFillH(const MParContainer *par, MH *hist, const char *name, const char *title)
|
---|
138 | {
|
---|
139 | Init(name, title);
|
---|
140 |
|
---|
141 | fParContainer = par;
|
---|
142 | fH = hist;
|
---|
143 | }
|
---|
144 |
|
---|
145 | // --------------------------------------------------------------------------
|
---|
146 | //
|
---|
147 | // Checks the parameter list for the existance of the parameter container. If
|
---|
148 | // the name of it was given in the constructor. It checks also for the
|
---|
149 | // existance of the histogram container in the parameter list if a name was
|
---|
150 | // given. If it is not available it tried to create a histogram container
|
---|
151 | // with the same type as the given object name.
|
---|
152 | //
|
---|
153 | Bool_t MFillH::PreProcess(MParList *pList)
|
---|
154 | {
|
---|
155 | if (!fParContainer)
|
---|
156 | {
|
---|
157 | fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
|
---|
158 | if (!fParContainer)
|
---|
159 | {
|
---|
160 | *fLog << dbginf << fParContainerName << " [MParContainer] not found... aborting." << endl;
|
---|
161 | return kFALSE;
|
---|
162 | }
|
---|
163 | }
|
---|
164 |
|
---|
165 | if (!fH)
|
---|
166 | {
|
---|
167 | fH = (MH*)pList->FindCreateObj(fHName);
|
---|
168 | if (!fH)
|
---|
169 | return kFALSE;
|
---|
170 | }
|
---|
171 |
|
---|
172 | if (!fH->InheritsFrom("MH"))
|
---|
173 | {
|
---|
174 | *fLog << dbginf << fH->GetName() << " [" << fH->ClassName();
|
---|
175 | *fLog << "] doesn't inherit from MH - cannot be used for MFillH... aborting." << endl;
|
---|
176 | return kFALSE;
|
---|
177 | }
|
---|
178 |
|
---|
179 | return kTRUE;
|
---|
180 | }
|
---|
181 |
|
---|
182 | // --------------------------------------------------------------------------
|
---|
183 | //
|
---|
184 | // Fills the data from the parameter conatiner into the histogram container
|
---|
185 | //
|
---|
186 | Bool_t MFillH::Process()
|
---|
187 | {
|
---|
188 | fH->Fill(fParContainer);
|
---|
189 |
|
---|
190 | return kTRUE;
|
---|
191 | }
|
---|
192 |
|
---|
193 | // --------------------------------------------------------------------------
|
---|
194 | //
|
---|
195 | // Set the ReadyToSave flag of the histogram container, because now all data
|
---|
196 | // has been filled into the histogram.
|
---|
197 | //
|
---|
198 | Bool_t MFillH::PostProcess()
|
---|
199 | {
|
---|
200 | fH->SetReadyToSave();
|
---|
201 | return kTRUE;
|
---|
202 | }
|
---|