14 # pragma warning( disable : 2259 )
20 # pragma warning( disable : 4996 )
36 TH3D* imp =
dynamic_cast<TH3D*
>( rep );
37 if ( !imp )
throw std::runtime_error(
"Cannot adopt native histogram representation." );
39 m_xAxis.initialize( m_rep->GetXaxis(),
true );
40 m_yAxis.initialize( m_rep->GetYaxis(),
true );
41 m_zAxis.initialize( m_rep->GetZaxis(),
true );
42 const TArrayD* a = m_rep->GetSumw2();
43 if ( !a || ( a && a->GetSize() == 0 ) ) m_rep->Sumw2();
44 setTitle( m_rep->GetTitle() );
51 double xup,
int nBinsY,
double ylow,
double yup,
52 int nBinsZ,
double zlow,
double zup ) {
53 auto p =
new Histogram3D(
54 new TH3D( title.
c_str(), title.
c_str(), nBinsX, xlow, xup, nBinsY, ylow, yup, nBinsZ, zlow, zup ) );
62 const Edges& eY,
const Edges& eZ ) {
63 auto p =
new Histogram3D(
new TH3D( title.
c_str(), title.
c_str(), eX.size() - 1, &eX.front(), eY.size() - 1,
64 &eY.front(), eZ.size() - 1, &eZ.front() ) );
70 const AIDA::IHistogram3D& hist ) {
71 TH3D*
h = getRepresentation<AIDA::IHistogram3D, TH3D>( hist );
72 Histogram3D*
n =
h ?
new Histogram3D(
new TH3D( *
h ) ) :
nullptr;
83 m_rep->SetDirectory(
nullptr );
87 adoptRepresentation( rep );
91 m_rep->SetDirectory(
nullptr );
96 double centreY,
double centreZ ) {
97 m_rep->SetBinContent( rIndexX( i ), rIndexY(
j ), rIndexZ( k ), height );
98 m_rep->SetBinError( rIndexX( i ), rIndexY(
j ), rIndexZ( k ), error );
100 if ( i >= 0 &&
j >= 0 && k >= 0 ) {
101 m_sumwx += centreX * height;
102 m_sumwy += centreY * height;
103 m_sumwz += centreZ * height;
105 m_sumEntries += entries;
120 auto guard = std::scoped_lock{ m_fillSerialization };
121 m_rep->Fill( x, y, z, weight );
126 if ( className ==
"AIDA::IHistogram3D" ) {
127 return (AIDA::IHistogram3D*)
this;
128 }
else if ( className ==
"AIDA::IHistogram" ) {
129 return (AIDA::IHistogram*)
this;
137 # pragma warning( push )
138 # pragma warning( disable : 1572 )
141 m_rep->SetEntries( m_sumEntries );
144 stat[0] = sumBinHeights();
146 if ( equivalentBinEntries() != 0 ) stat[1] = ( sumBinHeights() * sumBinHeights() ) / equivalentBinEntries();
149 if ( sumBinHeights() != 0 ) meanX = m_sumwx / sumBinHeights();
150 stat[3] = ( meanX * meanX + rmsX * rmsX ) * sumBinHeights();
153 if ( sumBinHeights() != 0 ) meanY = m_sumwy / sumBinHeights();
154 stat[5] = ( meanY * meanY + rmsY * rmsY ) * sumBinHeights();
158 if ( sumBinHeights() != 0 ) meanZ = m_sumwz / sumBinHeights();
159 stat[8] = ( meanZ * meanZ + rmsZ * rmsZ ) * sumBinHeights();
162 m_rep->PutStats( &stat.
front() );
169 const char* title = titlestr.
c_str();
170 if (
h.xAxis().isFixedBinning() &&
h.yAxis().isFixedBinning() &&
h.zAxis().isFixedBinning() ) {
171 m_rep = std::make_unique<TH3D>( title, title,
h.xAxis().bins(),
h.xAxis().lowerEdge(),
h.xAxis().upperEdge(),
172 h.yAxis().bins(),
h.yAxis().lowerEdge(),
h.yAxis().upperEdge(),
h.zAxis().bins(),
173 h.zAxis().lowerEdge(),
h.zAxis().upperEdge() );
176 for (
int i = 0; i <
h.xAxis().bins(); ++i ) eX.
push_back(
h.xAxis().binLowerEdge( i ) );
178 eX.push_back(
h.xAxis().upperEdge() );
179 for (
int i = 0; i <
h.yAxis().bins(); ++i ) eY.push_back(
h.yAxis().binLowerEdge( i ) );
181 eY.push_back(
h.yAxis().upperEdge() );
182 for (
int i = 0; i <
h.zAxis().bins(); ++i ) eZ.push_back(
h.zAxis().binLowerEdge( i ) );
184 eZ.push_back(
h.zAxis().upperEdge() );
186 new TH3D( title, title, eX.size() - 1, &eX.front(), eY.size() - 1, &eY.front(), eZ.size() - 1, &eZ.front() ) );
188 m_xAxis.initialize( m_rep->GetXaxis(),
true );
189 m_yAxis.initialize( m_rep->GetYaxis(),
true );
190 m_zAxis.initialize( m_rep->GetZaxis(),
true );
191 const TArrayD* a = m_rep->GetSumw2();
192 if ( !a || ( a && a->GetSize() == 0 ) ) m_rep->Sumw2();
199 double sumw =
h.sumBinHeights();
201 if (
h.equivalentBinEntries() != 0 ) sumw2 = ( sumw * sumw ) /
h.equivalentBinEntries();
202 double sumwx =
h.meanX() *
h.sumBinHeights();
203 double sumwx2 = (
h.meanX() *
h.meanX() +
h.rmsX() *
h.rmsX() ) *
h.sumBinHeights();
204 double sumwy =
h.meanY() *
h.sumBinHeights();
205 double sumwy2 = (
h.meanY() *
h.meanY() +
h.rmsY() *
h.rmsY() ) *
h.sumBinHeights();
206 double sumwz =
h.meanZ() *
h.sumBinHeights();
207 double sumwz2 = (
h.meanZ() *
h.meanZ() +
h.rmsZ() *
h.rmsZ() ) *
h.sumBinHeights();
213 for (
int i = -2; i < xAxis().bins(); ++i ) {
214 for (
int j = -2;
j < yAxis().bins(); ++
j ) {
215 for (
int k = -2; k < zAxis().bins(); ++k ) {
216 m_rep->SetBinContent( rIndexX( i ), rIndexY(
j ), rIndexZ( k ),
h.binHeight( i,
j, k ) );
217 m_rep->SetBinError( rIndexX( i ), rIndexY(
j ), rIndexZ( k ),
h.binError( i,
j, k ) );
219 if ( i >= 0 &&
j >= 0 && k >= 0 ) {
220 sumwxy +=
h.binHeight( i,
j, k ) *
h.binMeanX( i,
j, k ) *
h.binMeanY( i,
j, k );
221 sumwxz +=
h.binHeight( i,
j, k ) *
h.binMeanX( i,
j, k ) *
h.binMeanZ( i,
j, k );
222 sumwyz +=
h.binHeight( i,
j, k ) *
h.binMeanY( i,
j, k ) *
h.binMeanZ( i,
j, k );
229 m_rep->SetEntries(
h.allEntries() );
244 m_rep->PutStats( &stat.
front() );
249 # pragma warning( pop )