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;
122 auto guard = std::scoped_lock{ m_fillSerialization };
123 m_rep->Fill( x, y, z, weight );
128 if ( className ==
"AIDA::IHistogram3D" ) {
129 return (AIDA::IHistogram3D*)
this;
130 }
else if ( className ==
"AIDA::IHistogram" ) {
131 return (AIDA::IHistogram*)
this;
137 m_rep->SetEntries( m_sumEntries );
140 stat[0] = sumBinHeights();
143 stat[1] = ( sumBinHeights() * sumBinHeights() ) / equivalentBinEntries();
152 meanX = m_sumwx / sumBinHeights();
153 meanY = m_sumwy / sumBinHeights();
154 meanZ = m_sumwz / sumBinHeights();
156 stat[3] = ( meanX * meanX + rmsX * rmsX ) * sumBinHeights();
157 stat[5] = ( meanY * meanY + rmsY * rmsY ) * sumBinHeights();
158 stat[8] = ( meanZ * meanZ + rmsZ * rmsZ ) * sumBinHeights();
160 m_rep->PutStats( &stat.
front() );
167 const char* title = titlestr.
c_str();
168 if (
h.xAxis().isFixedBinning() &&
h.yAxis().isFixedBinning() &&
h.zAxis().isFixedBinning() ) {
169 m_rep = std::make_unique<TH3D>( title, title,
h.xAxis().bins(),
h.xAxis().lowerEdge(),
h.xAxis().upperEdge(),
170 h.yAxis().bins(),
h.yAxis().lowerEdge(),
h.yAxis().upperEdge(),
h.zAxis().bins(),
171 h.zAxis().lowerEdge(),
h.zAxis().upperEdge() );
174 for (
int i = 0; i <
h.xAxis().bins(); ++i ) eX.
push_back(
h.xAxis().binLowerEdge( i ) );
176 eX.push_back(
h.xAxis().upperEdge() );
177 for (
int i = 0; i <
h.yAxis().bins(); ++i ) eY.push_back(
h.yAxis().binLowerEdge( i ) );
179 eY.push_back(
h.yAxis().upperEdge() );
180 for (
int i = 0; i <
h.zAxis().bins(); ++i ) eZ.push_back(
h.zAxis().binLowerEdge( i ) );
182 eZ.push_back(
h.zAxis().upperEdge() );
184 new TH3D( title, title, eX.size() - 1, &eX.front(), eY.size() - 1, &eY.front(), eZ.size() - 1, &eZ.front() ) );
186 m_xAxis.initialize( m_rep->GetXaxis(),
true );
187 m_yAxis.initialize( m_rep->GetYaxis(),
true );
188 m_zAxis.initialize( m_rep->GetZaxis(),
true );
189 const TArrayD* a = m_rep->GetSumw2();
190 if ( !a || ( a && a->GetSize() == 0 ) ) m_rep->Sumw2();
197 double sumw =
h.sumBinHeights();
200 sumw2 = ( sumw * sumw ) /
h.equivalentBinEntries();
201 double sumwx =
h.meanX() *
h.sumBinHeights();
202 double sumwx2 = (
h.meanX() *
h.meanX() +
h.rmsX() *
h.rmsX() ) *
h.sumBinHeights();
203 double sumwy =
h.meanY() *
h.sumBinHeights();
204 double sumwy2 = (
h.meanY() *
h.meanY() +
h.rmsY() *
h.rmsY() ) *
h.sumBinHeights();
205 double sumwz =
h.meanZ() *
h.sumBinHeights();
206 double sumwz2 = (
h.meanZ() *
h.meanZ() +
h.rmsZ() *
h.rmsZ() ) *
h.sumBinHeights();
212 for (
int i = -2; i < xAxis().bins(); ++i ) {
213 for (
int j = -2;
j < yAxis().bins(); ++
j ) {
214 for (
int k = -2; k < zAxis().bins(); ++k ) {
215 m_rep->SetBinContent( rIndexX( i ), rIndexY(
j ), rIndexZ( k ),
h.binHeight( i,
j, k ) );
216 m_rep->SetBinError( rIndexX( i ), rIndexY(
j ), rIndexZ( k ),
h.binError( i,
j, k ) );
218 if ( i >= 0 &&
j >= 0 && k >= 0 ) {
219 sumwxy +=
h.binHeight( i,
j, k ) *
h.binMeanX( i,
j, k ) *
h.binMeanY( i,
j, k );
220 sumwxz +=
h.binHeight( i,
j, k ) *
h.binMeanX( i,
j, k ) *
h.binMeanZ( i,
j, k );
221 sumwyz +=
h.binHeight( i,
j, k ) *
h.binMeanY( i,
j, k ) *
h.binMeanZ( i,
j, k );
228 m_rep->SetEntries(
h.allEntries() );
243 m_rep->PutStats( &stat.
front() );