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;
135 m_rep->SetEntries( m_sumEntries );
138 stat[0] = sumBinHeights();
141 stat[1] = ( sumBinHeights() * sumBinHeights() ) / equivalentBinEntries();
150 meanX = m_sumwx / sumBinHeights();
151 meanY = m_sumwy / sumBinHeights();
152 meanZ = m_sumwz / sumBinHeights();
154 stat[3] = ( meanX * meanX + rmsX * rmsX ) * sumBinHeights();
155 stat[5] = ( meanY * meanY + rmsY * rmsY ) * sumBinHeights();
156 stat[8] = ( meanZ * meanZ + rmsZ * rmsZ ) * sumBinHeights();
158 m_rep->PutStats( &stat.
front() );
165 const char* title = titlestr.
c_str();
166 if (
h.xAxis().isFixedBinning() &&
h.yAxis().isFixedBinning() &&
h.zAxis().isFixedBinning() ) {
167 m_rep = std::make_unique<TH3D>( title, title,
h.xAxis().bins(),
h.xAxis().lowerEdge(),
h.xAxis().upperEdge(),
168 h.yAxis().bins(),
h.yAxis().lowerEdge(),
h.yAxis().upperEdge(),
h.zAxis().bins(),
169 h.zAxis().lowerEdge(),
h.zAxis().upperEdge() );
172 for (
int i = 0; i <
h.xAxis().bins(); ++i ) eX.
push_back(
h.xAxis().binLowerEdge( i ) );
174 eX.push_back(
h.xAxis().upperEdge() );
175 for (
int i = 0; i <
h.yAxis().bins(); ++i ) eY.push_back(
h.yAxis().binLowerEdge( i ) );
177 eY.push_back(
h.yAxis().upperEdge() );
178 for (
int i = 0; i <
h.zAxis().bins(); ++i ) eZ.push_back(
h.zAxis().binLowerEdge( i ) );
180 eZ.push_back(
h.zAxis().upperEdge() );
182 new TH3D( title, title, eX.size() - 1, &eX.front(), eY.size() - 1, &eY.front(), eZ.size() - 1, &eZ.front() ) );
184 m_xAxis.initialize( m_rep->GetXaxis(),
true );
185 m_yAxis.initialize( m_rep->GetYaxis(),
true );
186 m_zAxis.initialize( m_rep->GetZaxis(),
true );
187 const TArrayD* a = m_rep->GetSumw2();
188 if ( !a || ( a && a->GetSize() == 0 ) ) m_rep->Sumw2();
195 double sumw =
h.sumBinHeights();
198 sumw2 = ( sumw * sumw ) /
h.equivalentBinEntries();
199 double sumwx =
h.meanX() *
h.sumBinHeights();
200 double sumwx2 = (
h.meanX() *
h.meanX() +
h.rmsX() *
h.rmsX() ) *
h.sumBinHeights();
201 double sumwy =
h.meanY() *
h.sumBinHeights();
202 double sumwy2 = (
h.meanY() *
h.meanY() +
h.rmsY() *
h.rmsY() ) *
h.sumBinHeights();
203 double sumwz =
h.meanZ() *
h.sumBinHeights();
204 double sumwz2 = (
h.meanZ() *
h.meanZ() +
h.rmsZ() *
h.rmsZ() ) *
h.sumBinHeights();
210 for (
int i = -2; i < xAxis().bins(); ++i ) {
211 for (
int j = -2;
j < yAxis().bins(); ++
j ) {
212 for (
int k = -2; k < zAxis().bins(); ++k ) {
213 m_rep->SetBinContent( rIndexX( i ), rIndexY(
j ), rIndexZ( k ),
h.binHeight( i,
j, k ) );
214 m_rep->SetBinError( rIndexX( i ), rIndexY(
j ), rIndexZ( k ),
h.binError( i,
j, k ) );
216 if ( i >= 0 &&
j >= 0 && k >= 0 ) {
217 sumwxy +=
h.binHeight( i,
j, k ) *
h.binMeanX( i,
j, k ) *
h.binMeanY( i,
j, k );
218 sumwxz +=
h.binHeight( i,
j, k ) *
h.binMeanX( i,
j, k ) *
h.binMeanZ( i,
j, k );
219 sumwyz +=
h.binHeight( i,
j, k ) *
h.binMeanY( i,
j, k ) *
h.binMeanZ( i,
j, k );
226 m_rep->SetEntries(
h.allEntries() );
241 m_rep->PutStats( &stat.
front() );