Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Histo1DVar.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 #ifndef Histo1DVar_h
30 #define Histo1DVar_h 1
31 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 //
33 // MODULE: Histo1DVar.hh
34 //
35 // Version: 1.0
36 // Date: 09/03/00
37 // Author: P R Truscott
38 // Organisation: DERA UK
39 // Customer: ESA/ESTEC, NOORDWIJK
40 // Contract: 12115/96/NL/JG Work Order No. 3
41 //
42 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 //
44 // DESCRIPTION
45 // -----------
46 //
47 // The Histo1DVar class allows definition of a 1-D binning scheme and the
48 // storage of events according to that scheme. Member functions permit output
49 // of the bin contents and standard deviation of the events recorded for each
50 // bin. The member functions for this class are only those required to meet
51 // the needs of the SSAT. However, where possible, the data-types of the
52 // arguments and returned values are identical to those used in the Histoograms
53 // category of LHC++. Information associated with the binning scheme is
54 // contained in a VariableLengthPartition object.
55 //
56 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 //
58 // PUBLIC MEMBER FUNCTIONS
59 // -----------------------
60 //
61 // Histo1DVar (G4String name, double *ep_list,
62 // size_t ep_list_len, side conv)
63 // Constructor defining the name and binning scheme for the histogram:
64 // 1. name is the name of the histogram;
65 // 2. ep_list is a pointer to a double array defining the bin edges;
66 // 3. ep_list_len is the number of values in ep_list;
67 // 4. conv the convention of data-points exactly on a bin-edge (if the
68 // datapoint is associated with the bin to the left of the bin-edge then
69 // conv==LEFT, otherwise conv==RIGHT).
70 //
71 // Histo1DVar ()
72 // Default constructor.
73 //
74 // ~Histo1DVar ()
75 // Destructor.
76 //
77 // void reset ()
78 // Zeros-out the contents of the histogram (binning scheme is unaffected).
79 //
80 // void fill (double data_point, double weight = 1.0)
81 // Increments the bin associated with the datapoint data_point by the amount
82 // weight.
83 //
84 // double get_bin_value (HistSpecialBin specialBin)
85 // Returns the contents of special bin specialBin (specialBin may have
86 // values underflow_bin, inrange or overflow_bin).
87 //
88 // double get_bin_error (HistSpecialBin specialBin)
89 // Returns the error associated with special bin specialBin (specialBin may
90 // have values underflow_bin, inrange or overflow_bin).
91 //
92 // double get_bin_value (int i)
93 // Returns the contents of bin i (if i is less than 0 then the underflow_bin
94 // is returned; if i is greater than the number of bins then the
95 // overflow_bin is returned).
96 //
97 // double get_bin_error (int i)
98 // Returns the error associated with bin i (if i is less than 0 then the
99 // error associated with the underflow_bin is returned; if i is greater than
100 // the number of bins then the error associated with the overflow_bin is
101 // returned).
102 //
103 // double get_all_bins ()
104 // Returns the integral under the whole histogram, including underflow_bin
105 // and overflow_bin.
106 //
107 // void div (double r)
108 // Divides the contents of all bins by the value r.
109 //
110 // VariableLengthPartition part;
111 // Accesses the VariableLengthPartition part defining the histogram binning
112 // scheme.
113 //
114 // void set_name (G4String new_name)
115 // Sets the name of the histogram to new_name.
116 //
117 // char const *get_name ()
118 // Returns the name of the histogram.
119 //
120 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121 //
122 // CHANGE HISTORY
123 // --------------
124 //
125 // 30 June 1999, P R Truscott, DERA UK
126 // Version number update 0.b.2 -> 0.b.3, but no functional change.
127 //
128 //
129 // 28 August 1999, F Lei & P R Truscott, DERA UK
130 // Version number update 0.b.3 -> 0.b.4, but no functional change.
131 //
132 // 17 September 1999, P R Truscott, DERA UK
133 // Version number update 0.b.4 -> 0.b.5, but no functional change.
134 //
135 // 09 March 2000, P R Truscott, DERA UK
136 // Update 0.b.3 -> 1.0, for compliance with ISO ANSI C++ (no functional change).
137 //
138 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140 //
141 #include "globals.hh"
142 
143 #include "Histograms.hh"
145 #include "side.hh"
146 #include <vector>
148 //
150 {
151 public:
152  Histo1DVar (G4String name, double *ep_list, size_t ep_list_len, side conv);
153  Histo1DVar ();
154  ~Histo1DVar () {};
155  void reset ();
156  void fill (double data_point, double weight);
157  double get_bin_value (HistSpecialBin specialBin);
158  double get_bin_error (HistSpecialBin specialBin);
159  double get_bin_value (int );
160  double get_bin_error (int);
161  double get_bin_position (int);
162  double get_all_bins ();
163  void div (double r);
164 
166 
167 private:
168  G4String theName;
169  size_t length;
170  std::vector<double> totalWeight;
171  std::vector<double> meanPosition;
172  double overflowTotalWeight;
173  double underflowTotalWeight;
174  double meanOverflowPosition;
175  double meanUnderflowPosition;
176  std::vector<double> totalWeightSquared;
177  double overflowTotalWeightSquared;
178  double underflowTotalWeightSquared;
179  std::vector<long> nEvents;
180  long overflownEvents;
181  long underflownEvents;
182  long nAllEvents;
183 
184  //
185  //
186  // INLINE DECLARATIONS/DEFINTIONS:
187  //
188 public:
189  inline void set_name (G4String new_name) {theName = new_name;}
190  inline const char *get_name () {return theName.data();}
191 };
193 #endif
194 
195 
196 
197 
198