14 # pragma warning( disable : 2259 )
20 # pragma warning( disable : 4996 )
38 TH3D* imp =
dynamic_cast<TH3D*
>( rep );
39 if ( !imp )
throw std::runtime_error(
"Cannot adopt native histogram representation." );
41 m_xAxis.initialize( m_rep->GetXaxis(),
true );
42 m_yAxis.initialize( m_rep->GetYaxis(),
true );
43 m_zAxis.initialize( m_rep->GetZaxis(),
true );
44 const TArrayD* a = m_rep->GetSumw2();
45 if ( !a || ( a && a->GetSize() == 0 ) ) m_rep->Sumw2();
46 setTitle( m_rep->GetTitle() );
53 double xup,
int nBinsY,
double ylow,
double yup,
54 int nBinsZ,
double zlow,
double zup ) {
55 auto p =
new Histogram3D(
56 new TH3D( title.
c_str(), title.
c_str(), nBinsX, xlow, xup, nBinsY, ylow, yup, nBinsZ, zlow, zup ) );
64 const Edges& eY,
const Edges& eZ ) {
65 auto p =
new Histogram3D(
new TH3D( title.
c_str(), title.
c_str(), eX.size() - 1, &eX.front(), eY.size() - 1,
66 &eY.front(), eZ.size() - 1, &eZ.front() ) );
72 const AIDA::IHistogram3D& hist ) {
73 TH3D*
h = getRepresentation<AIDA::IHistogram3D, TH3D>( hist );
74 Histogram3D*
n =
h ?
new Histogram3D(
new TH3D( *
h ) ) :
nullptr;
85 m_rep->SetDirectory(
nullptr );
89 adoptRepresentation( rep );
93 m_rep->SetDirectory(
nullptr );
98 double centreY,
double centreZ ) {
99 m_rep->SetBinContent( rIndexX( i ), rIndexY(
j ), rIndexZ( k ), height );
100 m_rep->SetBinError( rIndexX( i ), rIndexY(
j ), rIndexZ( k ), error );
102 if ( i >= 0 &&
j >= 0 && k >= 0 ) {
103 m_sumwx += centreX * height;
104 m_sumwy += centreY * height;
105 m_sumwz += centreZ * height;
107 m_sumEntries += entries;
124 auto guard = std::scoped_lock{ m_fillSerialization };
125 m_rep->Fill( x, y, z, weight );
130 if ( className ==
"AIDA::IHistogram3D" ) {
131 return (AIDA::IHistogram3D*)
this;
132 }
else if ( className ==
"AIDA::IHistogram" ) {
133 return (AIDA::IHistogram*)
this;
141 # pragma warning( push )
142 # pragma warning( disable : 1572 )
145 m_rep->SetEntries( m_sumEntries );
148 stat[0] = sumBinHeights();
150 if ( equivalentBinEntries() != 0 ) stat[1] = ( sumBinHeights() * sumBinHeights() ) / equivalentBinEntries();
153 if ( sumBinHeights() != 0 ) meanX = m_sumwx / sumBinHeights();
154 stat[3] = ( meanX * meanX + rmsX * rmsX ) * sumBinHeights();
157 if ( sumBinHeights() != 0 ) meanY = m_sumwy / sumBinHeights();
158 stat[5] = ( meanY * meanY + rmsY * rmsY ) * sumBinHeights();
162 if ( sumBinHeights() != 0 ) meanZ = m_sumwz / sumBinHeights();
163 stat[8] = ( meanZ * meanZ + rmsZ * rmsZ ) * sumBinHeights();
166 m_rep->PutStats( &stat.
front() );
173 const char* title = titlestr.
c_str();
174 if (
h.xAxis().isFixedBinning() &&
h.yAxis().isFixedBinning() &&
h.zAxis().isFixedBinning() ) {
175 m_rep = std::make_unique<TH3D>( title, title,
h.xAxis().bins(),
h.xAxis().lowerEdge(),
h.xAxis().upperEdge(),
176 h.yAxis().bins(),
h.yAxis().lowerEdge(),
h.yAxis().upperEdge(),
h.zAxis().bins(),
177 h.zAxis().lowerEdge(),
h.zAxis().upperEdge() );
180 for (
int i = 0; i <
h.xAxis().bins(); ++i ) eX.
push_back(
h.xAxis().binLowerEdge( i ) );
182 eX.push_back(
h.xAxis().upperEdge() );
183 for (
int i = 0; i <
h.yAxis().bins(); ++i ) eY.push_back(
h.yAxis().binLowerEdge( i ) );
185 eY.push_back(
h.yAxis().upperEdge() );
186 for (
int i = 0; i <
h.zAxis().bins(); ++i ) eZ.push_back(
h.zAxis().binLowerEdge( i ) );
188 eZ.push_back(
h.zAxis().upperEdge() );
190 new TH3D( title, title, eX.size() - 1, &eX.front(), eY.size() - 1, &eY.front(), eZ.size() - 1, &eZ.front() ) );
192 m_xAxis.initialize( m_rep->GetXaxis(),
true );
193 m_yAxis.initialize( m_rep->GetYaxis(),
true );
194 m_zAxis.initialize( m_rep->GetZaxis(),
true );
195 const TArrayD* a = m_rep->GetSumw2();
196 if ( !a || ( a && a->GetSize() == 0 ) ) m_rep->Sumw2();
203 double sumw =
h.sumBinHeights();
205 if (
h.equivalentBinEntries() != 0 ) sumw2 = ( sumw * sumw ) /
h.equivalentBinEntries();
206 double sumwx =
h.meanX() *
h.sumBinHeights();
207 double sumwx2 = (
h.meanX() *
h.meanX() +
h.rmsX() *
h.rmsX() ) *
h.sumBinHeights();
208 double sumwy =
h.meanY() *
h.sumBinHeights();
209 double sumwy2 = (
h.meanY() *
h.meanY() +
h.rmsY() *
h.rmsY() ) *
h.sumBinHeights();
210 double sumwz =
h.meanZ() *
h.sumBinHeights();
211 double sumwz2 = (
h.meanZ() *
h.meanZ() +
h.rmsZ() *
h.rmsZ() ) *
h.sumBinHeights();
217 for (
int i = -2; i < xAxis().bins(); ++i ) {
218 for (
int j = -2;
j < yAxis().bins(); ++
j ) {
219 for (
int k = -2; k < zAxis().bins(); ++k ) {
220 m_rep->SetBinContent( rIndexX( i ), rIndexY(
j ), rIndexZ( k ),
h.binHeight( i,
j, k ) );
221 m_rep->SetBinError( rIndexX( i ), rIndexY(
j ), rIndexZ( k ),
h.binError( i,
j, k ) );
223 if ( i >= 0 &&
j >= 0 && k >= 0 ) {
224 sumwxy +=
h.binHeight( i,
j, k ) *
h.binMeanX( i,
j, k ) *
h.binMeanY( i,
j, k );
225 sumwxz +=
h.binHeight( i,
j, k ) *
h.binMeanX( i,
j, k ) *
h.binMeanZ( i,
j, k );
226 sumwyz +=
h.binHeight( i,
j, k ) *
h.binMeanY( i,
j, k ) *
h.binMeanZ( i,
j, k );
233 m_rep->SetEntries(
h.allEntries() );
248 m_rep->PutStats( &stat.
front() );
253 # pragma warning( pop )