AmpTools
Histogram.cc
Go to the documentation of this file.
1 //******************************************************************************
2 // This file is part of AmpTools, a package for performing Amplitude Analysis
3 //
4 // Copyright Trustees of Indiana University 2010, all rights reserved
5 //
6 // This software written by Matthew Shepherd, Ryan Mitchell, and
7 // Hrayr Matevosyan at Indiana University, Bloomington
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions
11 // are met:
12 // 1. Redistributions of source code must retain the above copyright
13 // notice and author attribution, this list of conditions and the
14 // following disclaimer.
15 // 2. Redistributions in binary form must reproduce the above copyright
16 // notice and author attribution, this list of conditions and the
17 // following disclaimer in the documentation and/or other materials
18 // provided with the distribution.
19 // 3. Neither the name of the University nor the names of its contributors
20 // may be used to endorse or promote products derived from this software
21 // without specific prior written permission.
22 //
23 // Creation of derivative forms of this software for commercial
24 // utilization may be subject to restriction; written permission may be
25 // obtained from the Trustees of Indiana University.
26 //
27 // INDIANA UNIVERSITY AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES,
28 // EXPRESS OR IMPLIED. By way of example, but not limitation, INDIANA
29 // UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCANTABILITY OR
30 // FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THIS SOFTWARE OR
31 // DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS,
32 // OR OTHER RIGHTS. Neither Indiana University nor the authors shall be
33 // held liable for any liability with respect to any claim by the user or
34 // any other party arising from use of the program.
35 //******************************************************************************
36 
37 #include <iostream>
38 #include <math.h>
39 #include <assert.h>
40 
41 #include "IUAmpTools/Histogram.h"
42 
43 using namespace std;
44 
45 Histogram::Histogram( string name, string title ) :
46 m_nBins( 0 ),
47 m_xLow( 0 ),
48 m_xHigh( 0 ),
49 m_entries( 0 ),
50 m_binContents( 0 ),
51 m_name( name ),
52 m_title( title ){}
53 
54 
55 void
57 
58  m_binContents = vector< double >( m_nBins );
59  m_entries = 0;
60 }
61 
62 void
63 Histogram::normalize( double integral ){
64 
65  double scaleFactor = integral / m_entries;
66 
67  for( int i = 0; i < m_nBins; ++i ){
68 
69  m_binContents[i] *= scaleFactor;
70  }
71 
72  m_entries *= scaleFactor;
73 }
74 
75 void
77 
78  assert( m_nBins <= MAXBINS );
79 
80  for( int i = 0; i < m_nBins; ++i ){
81 
82  m_binContents[i] += hStruct.contents[i];
83  }
84 
85  m_entries += hStruct.entries;
86 }
int m_nBins
Definition: Histogram.h:84
void normalize(double scaleFactor)
Definition: Histogram.cc:63
#define MAXBINS
Definition: Histogram.h:46
void clear()
Definition: Histogram.cc:56
void operator+=(HistStruct &hStruct)
Definition: Histogram.cc:76
vector< double > m_binContents
Definition: Histogram.h:89
float contents[MAXBINS]
Definition: Histogram.h:53
float entries
Definition: Histogram.h:52
Histogram(string name="Histogram", string title="hist")
Definition: Histogram.cc:45
double m_entries
Definition: Histogram.h:88