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

Last change on this file since 971 was 967, 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 fH = NULL;
66 fParContainer = NULL;
67}
68
69// --------------------------------------------------------------------------
70//
71// Constructor.
72//
73// - par is the name of the parameter container which should be filled into
74// the histogram
75// - hist is the name of the histogram container (which must have been
76// derived from MH)
77//
78MFillH::MFillH(const char *par, const char *hist, const char *name, const char *title)
79{
80 Init(name, title);
81
82 fParContainerName = par;
83 fHName = hist;
84}
85
86// --------------------------------------------------------------------------
87//
88// Constructor.
89//
90// - par is a pointer to the instance of your parameter container from which
91// the data should be used to fill the histogram.
92// - hist is the name of the histogram container (which must have been
93// derived from MH)
94//
95MFillH::MFillH(const MParContainer *par, const char *hist, const char *name, const char *title)
96{
97 Init(name, title);
98
99 fParContainer = par;
100 fHName = hist;
101}
102
103// --------------------------------------------------------------------------
104//
105// Constructor.
106//
107// - par is a pointer to the instance of your parameter container from which
108// the data should be used to fill the histogram.
109// - hist is a pointer to the instance of your histogram container (which must
110// have been derived from MH) into which the data should flow
111//
112MFillH::MFillH(const char *par, MH *hist, const char *name, const char *title)
113{
114 Init(name, title);
115
116 fParContainerName = par;
117 fH = hist;
118}
119
120// --------------------------------------------------------------------------
121//
122// Constructor.
123//
124// - par is a pointer to the instance of your parameter container from which
125// the data should be used to fill the histogram.
126// - hist is the name of the histogram container (which must have been
127// derived from MH)
128//
129MFillH::MFillH(const MParContainer *par, MH *hist, const char *name, const char *title)
130{
131 Init(name, title);
132
133 fParContainer = par;
134 fH = hist;
135}
136
137// --------------------------------------------------------------------------
138//
139// Checks the parameter list for the existance of the parameter container. If
140// the name of it was given in the constructor. It checks also for the
141// existance of the histogram container in the parameter list if a name was
142// given. If it is not available it tried to create a histogram container
143// with the same type as the given object name.
144//
145Bool_t MFillH::PreProcess(MParList *pList)
146{
147 if (!fParContainer)
148 {
149 fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
150 if (!fParContainer)
151 {
152 *fLog << dbginf << fParContainerName << " [MParContainer] not found... aborting." << endl;
153 return kFALSE;
154 }
155 }
156
157 if (!fH)
158 {
159 fH = (MH*)pList->FindCreateObj(fHName);
160 if (!fH)
161 return kFALSE;
162 }
163
164 return kTRUE;
165}
166
167// --------------------------------------------------------------------------
168//
169// Fills the data from the parameter conatiner into the histogram container
170//
171Bool_t MFillH::Process()
172{
173 fH->Fill(fParContainer);
174
175 return kTRUE;
176}
177
178// --------------------------------------------------------------------------
179//
180// Set the ReadyToSave flag of the histogram container, because now all data
181// has been filled into the histogram.
182//
183Bool_t MFillH::PostProcess()
184{
185 fH->SetReadyToSave();
186 return kTRUE;
187}
Note: See TracBrowser for help on using the repository browser.