14 # pragma warning( disable : 2259 ) 20 # pragma warning( disable : 4996 ) 35 TH3D* imp = dynamic_cast<TH3D*>( rep );
36 if ( !imp )
throw std::runtime_error(
"Cannot adopt native histogram representation." );
38 m_xAxis.initialize( m_rep->GetXaxis(), true );
39 m_yAxis.initialize( m_rep->GetYaxis(), true );
40 m_zAxis.initialize( m_rep->GetZaxis(), true );
41 const TArrayD* a = m_rep->GetSumw2();
42 if ( !a || ( a && a->GetSize() == 0 ) ) m_rep->Sumw2();
43 setTitle( m_rep->GetTitle() );
49 double xup,
int nBinsY,
double ylow,
double yup,
50 int nBinsZ,
double zlow,
double zup ) {
51 auto p =
new Histogram3D(
52 new TH3D( title.
c_str(), title.
c_str(), nBinsX, xlow, xup, nBinsY, ylow, yup, nBinsZ, zlow, zup ) );
58 const Edges& eY,
const Edges& eZ ) {
59 auto p =
new Histogram3D(
new TH3D( title.
c_str(), title.
c_str(), eX.size() - 1, &eX.front(), eY.size() - 1,
60 &eY.front(), eZ.size() - 1, &eZ.front() ) );
65 TH3D* h = getRepresentation<AIDA::IHistogram3D, TH3D>( hist );
66 Histogram3D*
n = h ?
new Histogram3D(
new TH3D( *h ) ) :
nullptr;
76 m_rep->SetDirectory(
nullptr );
80 adoptRepresentation( rep );
84 m_rep->SetDirectory(
nullptr );
89 double centreY,
double centreZ ) {
90 m_rep->SetBinContent( rIndexX( i ), rIndexY( j ), rIndexZ( k ), height );
91 m_rep->SetBinError( rIndexX( i ), rIndexY( j ), rIndexZ( k ), error );
93 if ( i >= 0 && j >= 0 && k >= 0 ) {
94 m_sumwx += centreX * height;
95 m_sumwy += centreY * height;
96 m_sumwz += centreZ * height;
98 m_sumEntries += entries;
113 auto guard = std::scoped_lock{m_fillSerialization};
114 m_rep->Fill( x, y, z, weight );
119 if ( className ==
"AIDA::IHistogram3D" ) {
120 return (AIDA::IHistogram3D*)
this;
121 }
else if ( className ==
"AIDA::IHistogram" ) {
122 return (AIDA::IHistogram*)
this;
130 # pragma warning( push ) 131 # pragma warning( disable : 1572 ) 134 m_rep->SetEntries( m_sumEntries );
137 stat[0] = sumBinHeights();
139 if ( equivalentBinEntries() != 0 ) stat[1] = ( sumBinHeights() * sumBinHeights() ) / equivalentBinEntries();
142 if ( sumBinHeights() != 0 ) meanX = m_sumwx / sumBinHeights();
143 stat[3] = ( meanX * meanX + rmsX * rmsX ) * sumBinHeights();
146 if ( sumBinHeights() != 0 ) meanY = m_sumwy / sumBinHeights();
147 stat[5] = ( meanY * meanY + rmsY * rmsY ) * sumBinHeights();
151 if ( sumBinHeights() != 0 ) meanZ = m_sumwz / sumBinHeights();
152 stat[8] = ( meanZ * meanZ + rmsZ * rmsZ ) * sumBinHeights();
155 m_rep->PutStats( &stat.
front() );
162 const char* title = titlestr.
c_str();
163 if ( h.xAxis().isFixedBinning() && h.yAxis().isFixedBinning() && h.zAxis().isFixedBinning() ) {
164 m_rep = std::make_unique<TH3D>( title, title, h.xAxis().bins(), h.xAxis().lowerEdge(), h.xAxis().upperEdge(),
165 h.yAxis().bins(), h.yAxis().lowerEdge(), h.yAxis().upperEdge(), h.zAxis().bins(),
166 h.zAxis().lowerEdge(), h.zAxis().upperEdge() );
169 for (
int i = 0; i < h.xAxis().bins(); ++i ) eX.
push_back( h.xAxis().binLowerEdge( i ) );
171 eX.push_back( h.xAxis().upperEdge() );
172 for (
int i = 0; i < h.yAxis().bins(); ++i ) eY.push_back( h.yAxis().binLowerEdge( i ) );
174 eY.push_back( h.yAxis().upperEdge() );
175 for (
int i = 0; i < h.zAxis().bins(); ++i ) eZ.push_back( h.zAxis().binLowerEdge( i ) );
177 eZ.push_back( h.zAxis().upperEdge() );
179 new TH3D( title, title, eX.size() - 1, &eX.front(), eY.size() - 1, &eY.front(), eZ.size() - 1, &eZ.front() ) );
181 m_xAxis.initialize( m_rep->GetXaxis(), true );
182 m_yAxis.initialize( m_rep->GetYaxis(), true );
183 m_zAxis.initialize( m_rep->GetZaxis(), true );
184 const TArrayD* a = m_rep->GetSumw2();
185 if ( !a || ( a && a->GetSize() == 0 ) ) m_rep->Sumw2();
192 double sumw = h.sumBinHeights();
194 if ( h.equivalentBinEntries() != 0 ) sumw2 = ( sumw * sumw ) / h.equivalentBinEntries();
195 double sumwx = h.meanX() * h.sumBinHeights();
196 double sumwx2 = ( h.meanX() * h.meanX() + h.rmsX() * h.rmsX() ) * h.sumBinHeights();
197 double sumwy = h.meanY() * h.sumBinHeights();
198 double sumwy2 = ( h.meanY() * h.meanY() + h.rmsY() * h.rmsY() ) * h.sumBinHeights();
199 double sumwz = h.meanZ() * h.sumBinHeights();
200 double sumwz2 = ( h.meanZ() * h.meanZ() + h.rmsZ() * h.rmsZ() ) * h.sumBinHeights();
206 for (
int i = -2; i < xAxis().bins(); ++i ) {
207 for (
int j = -2; j < yAxis().bins(); ++j ) {
208 for (
int k = -2; k < zAxis().bins(); ++k ) {
209 m_rep->SetBinContent( rIndexX( i ), rIndexY( j ), rIndexZ( k ), h.binHeight( i, j, k ) );
210 m_rep->SetBinError( rIndexX( i ), rIndexY( j ), rIndexZ( k ), h.binError( i, j, k ) );
212 if ( i >= 0 && j >= 0 && k >= 0 ) {
213 sumwxy += h.binHeight( i, j, k ) * h.binMeanX( i, j, k ) * h.binMeanY( i, j, k );
214 sumwxz += h.binHeight( i, j, k ) * h.binMeanX( i, j, k ) * h.binMeanZ( i, j, k );
215 sumwyz += h.binHeight( i, j, k ) * h.binMeanY( i, j, k ) * h.binMeanZ( i, j, k );
222 m_rep->SetEntries( h.allEntries() );
237 m_rep->PutStats( &stat.
front() );
242 # pragma warning( pop )
std::vector< double > Edges
void * cast(const std::string &className) const override
Introspection method.
virtual bool setBinContents(int i, int j, int k, int entries, double height, double error, double centreX, double centreY, double centreZ)
Fast filling method for a given bin. It can be also the over/underflow bin.
std::pair< DataObject *, AIDA::IHistogram3D * > createH3D(const AIDA::IHistogram3D &hist)
Copy constructor.
Histogram3D()
Standard Constructor.
bool setTitle(const std::string &title) override
Set the title of the object.
bool fill(double x, double y, double z, double weight) override
Fill bin content.
void copyFromAida(const AIDA::IHistogram3D &h)
Create new histogram from any AIDA based histogram.
std::unique_ptr< IMPLEMENTATION > m_rep
Reference to underlying implementation.
virtual bool setRms(double rmsX, double rmsY, double rmsZ)
Sets the rms of the histogram.
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
Header file for std:chrono::duration-based Counters.
Common AIDA implementation stuff for histograms and profiles using ROOT implementations.