Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Histo2DVar.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 Histo2DVar_h
30 #define Histo2DVar_h 1
31 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 //
33 // MODULE: Histo2DVar.hh
34 //
35 // Version: 1.0
36 // Date: 09/03/00
37 // Author: P R Truscott, F Lei
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 Histo2DVar class allows definition of a 2-D binning scheme (i.e. using
48 // two, 1-D binning schemes) and the storage of events according to the binning
49 // scheme. Member functions permit output of the bin contents and standard
50 // deviation of the events recorded for each bin. The member functions for
51 // this class are only those required to meet the needs of the SSAT. However,
52 // where possible the data-types of the arguments and returned values are
53 // identical to those used in the Histoograms category of LHC++. Information
54 // associated with the binning scheme is contained in VariableLengthPartition
55 // object.
56 //
57 // Since the maximum length of a VariableLengthPartition is 256, 255 bins x255
58 // bins is the maximum number size for a Histo2DVar object.
59 //
60 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 //
62 // PUBLIC MEMBER FUNCTIONS
63 // -----------------------
64 //
65 // Histo2DVar (G4String name, double *epx_list, size_t epx_list_len,
66 // side x_conv, double *epy_list, size_t epy_list_len, side y_conv)
67 // Constructor defining:
68 // 1. name is the name of the histogram;
69 // 2. epx_list is a pointer to a double array defining the x-coordinate bin
70 // edges;
71 // 3. epx_list_len is the number of values in epx_list;
72 // 4. x_conv the convention of data-points exactly on a bin-edge for the
73 // x-coordinate (if the datapoint is associated with the bin to the left
74 // of the bin-edge then conv==LEFT, otherwise conv==RIGHT);
75 // 5. epy_list is a pointer to a double array defining the y-coordinate bin
76 // edges;
77 // 6. epy_list_len is the number of values in epy_list;
78 // 7. y_conv the convention of data-points exactly on a bin-edge for the
79 // y-coordinate.
80 //
81 // Histo2DVar ()
82 // Default constructor.
83 //
84 // ~Histo2DVar ()
85 // Destructor.
86 //
87 // void reset ()
88 // Zeros-out the contents of the histogram (binning scheme is unaffected).
89 //
90 // void fill (double x_point, double y_point, double weight = 1.0)
91 // Increments the bin associated with the datapoint (x_point,y_point) by
92 // the amount weight.
93 //
94 // double get_bin_value (HistSpecialBin xSpecialBin,
95 // HistSpecialBin ySpecialBin)
96 // Returns the contents of special bin (xSpecialBin,ySpecialBin)
97 // (xSpecialBin and ySpeciaBin may have values underflow_bin, inrange or
98 // overflow_bin).
99 //
100 // double get_bin_error (HistSpecialBin xSpecialBin,
101 // HistSpecialBin ySpecialBin)
102 // Returns the error associated with special bin (xSpecialBin,ySpecialBin)
103 // (xSpecialBin and ySpeciaBin may have values underflow_bin, inrange or
104 // overflow_bin).
105 //
106 // double get_bin_value (int i, int j)
107 // Returns the contents of bin (i,j). If i is less than 0 then the value
108 // returned is for x==underflow_bin, y==underflow_bin, inrange, or
109 // overflow_bin, depending upon whether j is less than 0, in-range or
110 // greater than the number of y-bins. If i is greater than the number of
111 // x-bins then the value returned is for x==overflow_bin, y==underflow_bin,
112 // inrange, or overflow_bin, depending upon whether j is less than 0,
113 // in-range or greater than the number of y-bins.
114 //
115 // double get_bin_error (int i, int j)
116 // Returns the error associated with bin i. If i is less than 0 then the
117 // value returned is for x==underflow_bin, y==underflow_bin, inrange, or
118 // overflow_bin, depending upon whether j is less than 0, in-range or
119 // greater than the number of y-bins. If i is greater than the number of
120 // x-bins then the value returned is for x==overflow_bin, y==underflow_bin,
121 // inrange, or overflow_bin, depending upon whether j is less than 0,
122 // in-range or greater than the number of y-bins.
123 //
124 // double get_all_bins ()
125 // Returns the integral under the whole histogram, including the
126 // over-/underflow bins.
127 //
128 // void div (double r)
129 // Divides the contents of all bins by the value r.
130 //
131 // VariableLengthPartition x_part;
132 // Accesses the VariableLengthPartition x_part defining the histogram
133 // x-binning scheme.
134 //
135 // VariableLengthPartition y_part;
136 // Accesses the VariableLengthPartition y_part defining the histogram
137 // y-binning scheme.
138 //
139 // void set_name (G4String new_name)
140 // Sets the name of the histogram to new_name.
141 //
142 // char const *get_name ()
143 // Returns the name of the histogram.
144 //
145 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 //
147 // CHANGE HISTORY
148 // --------------
149 //
150 // 30 June 1999, P R Truscott, DERA UK
151 // Version number update 0.b.2 -> 0.b.3, but no functional change.
152 //
153 //
154 // 28 August 1999, F Lei & P R Truscott, DERA UK
155 // Version number update 0.b.3 -> 0.b.4, but no functional change.
156 //
157 // 17 September 1999, P R Truscott, DERA UK
158 // Version number update 0.b.4 -> 0.b.5, but no functional change.
159 //
160 // 09 March 2000, P R Truscott, DERA UK
161 // Update 0.b.3 -> 1.0, for compliance with ISO ANSI C++ (no functional change).
162 //
163 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165 //
166 #include "globals.hh"
167 
168 #include "Histograms.hh"
170 #include "side.hh"
172 //
174 {
175  public:
177  double *epx_list, size_t epx_list_len, side x_conv,
178  double *epy_list, size_t epy_list_len, side y_conv);
179  Histo2DVar ();
180  ~Histo2DVar () {};
181  void reset ();
182  void fill (double x_point, double y_point, double weight);
183  double get_bin_value (int , int );
184  double get_bin_error (int , int );
185  void div (double );
186 
189 
190  private:
191  G4String theName;
192  double totalWeight[256][256];
193  double uoflowTotalWeight[3][3];
194  double totalWeightSquared[256][256];
195  double uoflowTotalWeightSquared[3][3];
196  long nEvents[256][256];
197  long uoflownEvents[3][3];
198  long nAllEvents;
199 
200  //
201  //
202  // INLINE DECLARATIONS/DEFINTIONS:
203  //
204  public:
205  inline void set_name (G4String new_name) {theName = new_name;}
206  inline const char *get_name () {return theName.data();}
207  inline double get_bin_value
208  (HistSpecialBin xSpecialBin, HistSpecialBin ySpecialBin)
209  {return uoflowTotalWeight[xSpecialBin][ySpecialBin];}
210  inline double get_bin_error
211  (HistSpecialBin xSpecialBin, HistSpecialBin ySpecialBin)
212  {return std::sqrt(uoflowTotalWeightSquared[xSpecialBin][ySpecialBin]);}
213  inline double get_all_bins () const
214  {return uoflowTotalWeight[inrange][inrange];}
215 };
217 #endif
218 
219 
220