4 # pragma warning( disable : 2259 ) 10 # pragma warning( disable : 4996 ) 20 auto p =
new Histogram1D(
new TH1D( title.
c_str(), title.
c_str(), nBins, xlow, xup ) );
25 auto p =
new Histogram1D(
new TH1D( title.
c_str(), title.
c_str(), e.size() - 1, &e.front() ) );
30 TH1D* h = getRepresentation<AIDA::IHistogram1D, TH1D>( hist );
31 auto n = ( h ?
new Histogram1D(
new TH1D( *h ) ) : nullptr );
38 if ( className ==
"AIDA::IHistogram1D" )
return const_cast<AIDA::IHistogram1D*
>( (AIDA::IHistogram1D*)
this );
39 if ( className ==
"AIDA::IHistogram" )
return const_cast<AIDA::IHistogram*
>( (AIDA::IHistogram*)
this );
45 if ( binHeight( index ) <= 0 )
return 0;
46 double xx = binHeight( index ) / binError( index );
47 return int( xx * xx + 0.5 );
52 TH1D* imp =
dynamic_cast<TH1D*
>( rep );
53 if ( !imp )
throw std::runtime_error(
"Cannot adopt native histogram representation." );
69 const TArrayD* a =
m_rep->GetSumw2();
70 if ( !a || ( a && a->GetSize() == 0 ) )
m_rep->Sumw2();
72 m_rep->SetDirectory(
nullptr );
80 for (
int i = 1, n =
m_rep->GetNbinsX(); i <=
n; ++i ) {
105 if ( i != AIDA::IAxis::UNDERFLOW_BIN && i != AIDA::IAxis::OVERFLOW_BIN )
m_sumwx += centre * height;
113 # pragma warning( push ) 114 # pragma warning( disable : 1572 ) 133 m_rep->SetEntries( allEntries );
152 ( weight == 1. ) ?
m_rep->Fill( x ) :
m_rep->Fill( x, weight );
159 if ( h.axis().isFixedBinning() ) {
161 new TH1D( title.
c_str(), title.
c_str(), h.axis().bins(), h.axis().lowerEdge(), h.axis().upperEdge() ) );
164 for (
int i = 0; i < h.axis().bins(); ++i ) { e.
push_back( h.axis().binLowerEdge( i ) ); }
166 e.push_back( h.axis().upperEdge() );
174 double sumw = h.sumBinHeights();
177 if ( h.equivalentBinEntries() != 0 ) sumw2 = ( sumw * sumw ) / h.equivalentBinEntries();
179 double sumwx = h.mean() * h.sumBinHeights();
180 double sumwx2 = ( h.mean() * h.mean() + h.rms() * h.rms() ) * h.sumBinHeights();
183 for (
int i = -2; i <
axis().
bins(); ++i ) {
185 m_rep->SetBinContent(
rIndex( i ), h.binHeight( i ) );
186 m_rep->SetBinError(
rIndex( i ), h.binError( i ) );
190 m_rep->SetEntries( h.allEntries() );
202 # pragma warning( pop ) 210 for (
int j = 0; j <
size; j++ ) {
214 if (
"Title" == key ) { title = value; }
217 int isFixedBinning, bins;
218 s >> isFixedBinning >> bins;
220 if ( isFixedBinning ) {
221 s >> lowerEdge >> upperEdge;
226 for (
int i = 0; i <= bins; ++i ) s >> edges[i];
234 for (
int i = 0; i <= bins + 1; ++i ) {
236 m_rep->SetBinContent( i, binHeight );
237 m_rep->SetBinError( i, binError );
241 m_rep->SetEntries( allEntries );
243 s >> stats[0] >> stats[1] >> stats[2] >> stats[3];
244 m_rep->PutStats( stats );
251 for (
int i = 0; i <
annotation().size(); i++ ) {
255 const AIDA::IAxis&
axis( this->
axis() );
256 const int isFixedBinning = axis.isFixedBinning();
257 const int bins = axis.bins();
258 s << isFixedBinning << bins;
259 if ( isFixedBinning ) {
260 s << axis.lowerEdge();
262 for (
int i = 0; i < bins; ++i ) s << axis.binLowerEdge( i );
264 s << axis.upperEdge();
265 for (
int i = 0; i <= bins + 1; ++i ) s <<
m_rep->GetBinContent( i ) <<
m_rep->GetBinError( i );
267 s <<
m_rep->GetEntries();
269 m_rep->GetStats( stats );
270 s << stats[0] << stats[1] << stats[2] << stats[3];
bool fill(double x, double weight) override
Fill the Profile1D with a value and the corresponding weight.
std::string title() const override
Get the title of the object.
void * cast(const std::string &cl) const override
Manual cast by class name.
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
std::mutex m_fillSerialization
int entries() const override
Get the number or all the entries.
virtual bool setStatistics(int allEntries, double eqBinEntries, double mean, double rms)
set histogram statistics
The stream buffer is a small object collecting object data.
StreamBuffer & serialize(StreamBuffer &s)
Serialization mechanism, Serialize the object for reading.
double sumBinHeights() const override
Get the sum of in range bin heights in the IProfile.
bool reset() override
need to overwrite reset to reset the sums
double binHeight(int index) const override
Total height of the corresponding bin (ie the sum of the weights in this bin).
std::vector< double > Edges
void init(const std::string &title, bool initialize_axis=true)
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
double binError(int index) const override
The error of a given bin.
Axis & axis()
Access to axis object.
std::unique_ptr< IMPLEMENTATION > m_rep
Reference to underlying implementation.
bool setTitle(const std::string &title) override
Set the title of the object.
int allEntries() const override
Get the number or all the entries, both in range and underflow/overflow bins of the IProfile...
int bins() const override
The number of bins (excluding underflow and overflow) on the IAxis.
int binEntries(int index) const override
Number of entries in the corresponding bin (ie the number of times fill was called for this bin)...
double rms() const override
The RMS of the whole IHistogram1D.
void copyFromAida(const AIDA::IHistogram1D &h)
Create new histogram from any AIDA based histogram.
void initialize(TAxis *itaxi, bool)
bool setRms(double rms)
Update histogram RMS.
virtual double equivalentBinEntries() const
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]
virtual bool setBinContents(int i, int entries, double height, double error, double centre)
set bin content (entries and centre are not used )
virtual int rIndex(int index) const
operator methods
AIDA::IAnnotation & annotation() override
Access annotation object.
Histogram1D()
Standard constructor.
Helper functions to set/get the application return code.
std::pair< DataObject *, AIDA::IHistogram1D * > createH1D(const AIDA::IHistogram1D &hist)
Copy constructor.
double mean() const override
The mean of the whole IHistogram1D.
double m_sumwx
cache sumwx when setting contents since I don't have bin mean
Common AIDA implementation stuff for histograms and profiles using ROOT implementations.