Hist1DProjImp.cxx
Go to the documentation of this file.
1 
12 #ifdef _MSC_VER
13 // Include max() and min() missing from Microsoft Visual C++.
14 #include "msdevstudio/MSconfig.h"
15 #endif
16 
17 #include "Hist1DProjImp.h"
18 
19 #include "axes/AxisModelBase.h"
20 
21 #include "binners/BinsBase.h"
22 #include "binners/BinsFactory.h"
23 #include "binners/BinnerAxis.h"
25 
27 #include "datasrcs/NTuple.h"
28 
29 #include <cassert>
30 
31 using namespace hippodraw;
32 
33 #ifdef ITERATOR_MEMBER_DEFECT
34 using namespace std;
35 #else
36 using std::list;
37 using std::max;
38 using std::string;
39 using std::vector;
40 #endif
41 
43  : BinningProjector ( 1 )
44 {
45  BinnerAxisFactory * binner_factory = BinnerAxisFactory::instance ();
46  BinnerAxis * binner = binner_factory -> create ( "BinnerLinear" );
47 
48  BinsFactory * factory = BinsFactory::instance ();
49  m_binner = factory->create ( "Bins1DHist" );
50 
51  m_binner->setBinnerOn ( binner, Axes::X );
52 
53  m_y_label_entries = "Entries / bin";
54  m_y_label_density = "Density";
55 
56  addPointReps();
57 }
58 
64 Hist1DProjImp ( const Hist1DProjImp & projector )
65  : BinningProjector ( projector ),
66  m_y_label_entries ( projector.m_y_label_entries ),
67  m_y_label_density ( projector.m_y_label_density )
68 {
69  addPointReps();
70 }
71 
72 
75 {
76 }
77 
78 void
81 {
82  m_pointreps.push_back ( "Column" );
83  m_pointreps.push_back ( "FilledColumn" );
84  m_pointreps.push_back ( "Symbol" );
85  m_pointreps.push_back ( "Line" );
86 }
87 
88 void
91 {
92  if ( m_y_axis == 0 ) return;
93 
94  bool yes = m_binner->hasEqualWidths ();
95  if ( yes ) {
96  double width = m_binner->scaleFactor ();
97  m_y_axis->setScaleFactor ( width );
98  }
99  else {
100  m_y_axis->setScaling ( false );
101  }
102 }
103 
104 bool
107 {
108  return true;
109 }
110 
111 double
114 {
115  Range range = dataRangeOnValue ();
116 
117  return range.pos ();
118 }
119 
120 Range
123 {
124  Range range = dataRangeOn ( axis );
125  if ( axis == Axes::Y ) {
126  range.setLow ( 0.0 );
127  }
128 
129  return range;
130 }
131 
132 
133 namespace dp = hippodraw::DataPoint2DTuple;
134 
135 Range
138 {
139  Hist1DProjImp * p = const_cast < Hist1DProjImp * > ( this );
140  p->prepareValues ();
141  if ( m_proj_values -> empty () ) {
142  return Range ( 0.0, 1.0, 0.5 );
143  }
144 
145  const vector < double > & values = m_proj_values -> getColumn( dp::Y );
146  return Range ( values );
147 }
148 
150 void
152 setRange ( hippodraw::Axes::Type axis, bool const_width )
153 {
154  assert ( m_binner );
155  assert ( axis == Axes::X || axis == Axes::Y );
156 
157  if ( axis == Axes::X ) {
158  const Range & range = m_x_axis->getRange( false );
159 
160  if( m_x_axis->isLog() ) {
161  if( range.low() < 0.0 ) return;
162  m_x_axis->setRange ( range.low(), range.high(), getPosOn ( Axes::X ) );
163  const Range & range2 = m_x_axis->getRange( false );
164  setBinnerRange ( axis, range2, const_width );
165  }
166  else {
167  setBinnerRange ( axis, range, const_width );
168  }
169  }
170 }
171 
172 void
175 {
176 }
177 
178 Range
180 valueRange () const
181 {
182  return dataRangeOn ( Axes::Y );
183 }
184 
185 bool
187 wantsScaleFactor ( const std::string & axis ) const
188 {
189  return axis == "Y" || axis == "y";
190 }

Generated for HippoDraw Class Library by doxygen