4 #pragma warning( disable : 2259 ) 10 #pragma warning( disable : 4996 ) 27 TH3D* imp =
dynamic_cast<TH3D*
>( rep );
28 if ( !imp )
throw std::runtime_error(
"Cannot adopt native histogram representation." );
30 m_xAxis.initialize( m_rep->GetXaxis(), true );
31 m_yAxis.initialize( m_rep->GetYaxis(), true );
32 m_zAxis.initialize( m_rep->GetZaxis(), true );
33 const TArrayD* a = m_rep->GetSumw2();
34 if ( !a || ( a && a->GetSize() == 0 ) ) m_rep->Sumw2();
35 setTitle( m_rep->GetTitle() );
41 double xup,
int nBinsY,
double ylow,
double yup,
42 int nBinsZ,
double zlow,
double zup )
45 new TH3D( title.
c_str(), title.
c_str(), nBinsX, xlow, xup, nBinsY, ylow, yup, nBinsZ, zlow, zup ) );
53 auto p =
new Histogram3D(
new TH3D( title.
c_str(), title.
c_str(), eX.size() - 1, &eX.front(), eY.size() - 1,
54 &eY.front(), eZ.size() - 1, &eZ.front() ) );
60 TH3D* h = getRepresentation<AIDA::IHistogram3D, TH3D>( hist );
72 m_rep->SetDirectory(
nullptr );
81 m_rep->SetDirectory(
nullptr );
86 double centreY,
double centreZ )
91 if ( i >= 0 && j >= 0 && k >= 0 ) {
112 m_rep->Fill( x, y, z, weight );
118 if ( className ==
"AIDA::IHistogram3D" ) {
119 return (AIDA::IHistogram3D*)
this;
120 }
else if ( className ==
"AIDA::IHistogram" ) {
121 return (AIDA::IHistogram*)
this;
129 #pragma warning( push ) 130 #pragma warning( disable : 1572 ) 162 const char* tit = h.title().c_str();
163 if ( h.xAxis().isFixedBinning() && h.yAxis().isFixedBinning() && h.zAxis().isFixedBinning() ) {
164 m_rep.
reset(
new TH3D( tit, tit, h.xAxis().bins(), h.xAxis().lowerEdge(), h.xAxis().upperEdge(), h.yAxis().bins(),
165 h.yAxis().lowerEdge(), h.yAxis().upperEdge(), h.zAxis().bins(), h.zAxis().lowerEdge(),
166 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( tit, tit, eX.size() - 1, &eX.front(), eY.size() - 1, &eY.front(), eZ.size() - 1, &eZ.front() ) );
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 ) {
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() );
242 #pragma warning( pop ) int rIndexZ(int index) const
int rIndexX(int index) const
double meanZ() const override
The mean of the IHistogram3D along the z axis.
int entries() const override
Get the number or all the entries.
const AIDA::IAxis & yAxis() const override
Get the y axis of the IHistogram3D.
std::vector< double > Edges
const AIDA::IAxis & zAxis() const override
Get the z axis of the IHistogram3D.
double rmsZ() const override
The RMS of the IHistogram3D along the z axis.
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.
AIDA implementation for 3 D histograms using ROOT THD2.
double sumBinHeights() const override
Get the sum of in range bin heights in the IProfile.
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.
int rIndexY(int index) const
void copyFromAida(const AIDA::IHistogram3D &h)
Create new histogram from any AIDA based histogram.
std::unique_ptr< IMPLEMENTATION > m_rep
Reference to underlying implementation.
void initialize(TAxis *itaxi, bool)
const AIDA::IAxis & xAxis() const override
Get the x axis of the IHistogram3D.
virtual bool setRms(double rmsX, double rmsY, double rmsZ)
Sets the rms of the histogram.
double rmsY() const override
The RMS of the IHistogram3D along the y axis.
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
double rmsX() const override
The RMS of the IHistogram3D along the x axis.
double meanY() const override
The mean of the IHistogram3D along the y axis.
void * cast(const std::string &className) const override
Introspection method.
double equivalentBinEntries() const override
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]
Helper functions to set/get the application return code.
double meanX() const override
The mean of the IHistogram3D along the x axis.
Common AIDA implementation stuff for histograms and profiles using ROOT implementations.