source: trunk/MagicSoft/Mars/mhist/MFillH.cc@ 915

Last change on this file since 915 was 889, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 6.2 KB
Line 
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// MFill //
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// Input Containers: //
39// A parameter container //
40// //
41// Output Containers: //
42// A histogram container //
43// //
44//////////////////////////////////////////////////////////////////////////////
45#include "MFillH.h"
46
47#include "MLog.h"
48#include "MLogManip.h"
49
50#include "MH.h"
51#include "MParList.h"
52
53ClassImp(MFillH);
54
55// --------------------------------------------------------------------------
56//
57// Initializes name and title of the object. It is called by all
58// constructors.
59//
60void MFillH::Init(const char *name, const char *title)
61{
62 *fName = name ? name : "MFillH";
63 *fTitle = title ? title : "Task to fill Mars histograms";
64}
65
66// --------------------------------------------------------------------------
67//
68// Constructor.
69//
70// - par is the name of the parameter container which should be filled into
71// the histogram
72// - hist is the name of the histogram container (which must have been
73// derived from MH)
74//
75MFillH::MFillH(const char *par, const char *hist, const char *name, const char *title)
76{
77 Init(name, title);
78
79 fParContainerName = par;
80 fHName = hist;
81}
82
83// --------------------------------------------------------------------------
84//
85// Constructor.
86//
87// - par is a pointer to the instance of your parameter container from which
88// the data should be used to fill the histogram.
89// - hist is the name of the histogram container (which must have been
90// derived from MH)
91//
92MFillH::MFillH(const MParContainer *par, const char *hist, const char *name, const char *title)
93{
94 Init(name, title);
95
96 fParContainer = par;
97 fHName = hist;
98}
99
100// --------------------------------------------------------------------------
101//
102// Constructor.
103//
104// - par is a pointer to the instance of your parameter container from which
105// the data should be used to fill the histogram.
106// - hist is a pointer to the instance of your histogram container (which must
107// have been derived from MH) into which the data should flow
108//
109MFillH::MFillH(const char *par, MH *hist, const char *name, const char *title)
110{
111 Init(name, title);
112
113 fParContainerName = par;
114 fH = hist;
115}
116
117// --------------------------------------------------------------------------
118//
119// Constructor.
120//
121// - par is a pointer to the instance of your parameter container from which
122// the data should be used to fill the histogram.
123// - hist is the name of the histogram container (which must have been
124// derived from MH)
125//
126MFillH::MFillH(const MParContainer *par, MH *hist, const char *name, const char *title)
127{
128 Init(name, title);
129
130 fParContainer = par;
131 fH = hist;
132}
133
134// --------------------------------------------------------------------------
135//
136// Checks the parameter list for the existance of the parameter container. If
137// the name of it was given in the constructor. It checks also for the
138// existance of the histogram container in the parameter list if a name was
139// given. If it is not available it tried to create a histogram container
140// with the same type as the given object name.
141//
142Bool_t MFillH::PreProcess(MParList *pList)
143{
144 if (!fParContainer)
145 {
146 fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
147 if (!fParContainer)
148 {
149 *fLog << dbginf << fParContainerName << " not found... aborting." << endl;
150 return kFALSE;
151 }
152 }
153
154 if (!fH)
155 {
156 fH = (MH*)pList->FindCreateObj(fHName);
157 if (!fH)
158 return kFALSE;
159 }
160
161 return kTRUE;
162}
163
164// --------------------------------------------------------------------------
165//
166// Fills the data from the parameter conatiner into the histogram container
167//
168Bool_t MFillH::Process()
169{
170 fH->Fill(fParContainer);
171
172 return kTRUE;
173}
174
175// --------------------------------------------------------------------------
176//
177// Set the ReadyToSave flag of the histogram container, because now all data
178// has been filled into the histogram.
179//
180Bool_t MFillH::PostProcess()
181{
182 fH->SetReadyToSave();
183 return kTRUE;
184}
Note: See TracBrowser for help on using the repository browser.