4 #pragma warning( disable : 2259 ) 10 #pragma warning( disable : 4996 ) 21 auto p =
new Histogram1D(
new TH1D( title.
c_str(), title.
c_str(), nBins, xlow, xup ) );
27 auto p =
new Histogram1D(
new TH1D( title.
c_str(), title.
c_str(), e.size() - 1, &e.front() ) );
33 TH1D* h = getRepresentation<AIDA::IHistogram1D, TH1D>( hist );
34 auto n = ( h ?
new Histogram1D(
new TH1D( *h ) ) : nullptr );
43 if ( className ==
"AIDA::IHistogram1D" )
return const_cast<AIDA::IHistogram1D*
>( (AIDA::IHistogram1D*)
this );
44 if ( className ==
"AIDA::IHistogram" )
return const_cast<AIDA::IHistogram*
>( (AIDA::IHistogram*)
this );
51 if ( binHeight( index ) <= 0 )
return 0;
52 double xx = binHeight( index ) / binError( index );
53 return int( xx * xx + 0.5 );
59 TH1D* imp =
dynamic_cast<TH1D*
>( rep );
60 if ( !imp )
throw std::runtime_error(
"Cannot adopt native histogram representation." );
77 if ( initialize_axis ) {
80 const TArrayD* a =
m_rep->GetSumw2();
81 if ( !a || ( a && a->GetSize() == 0 ) )
m_rep->Sumw2();
83 m_rep->SetDirectory(
nullptr );
92 for (
int i = 1, n =
m_rep->GetNbinsX(); i <=
n; ++i ) {
102 return Base::reset();
120 if ( i != AIDA::IAxis::UNDERFLOW_BIN && i != AIDA::IAxis::OVERFLOW_BIN )
m_sumwx += centre * height;
128 #pragma warning( push ) 129 #pragma warning( disable : 1572 ) 150 m_rep->SetEntries( allEntries );
168 ( weight == 1. ) ?
m_rep->Fill( x ) :
m_rep->Fill( x, weight );
176 if ( h.axis().isFixedBinning() ) {
177 m_rep.
reset(
new TH1D( tit.
c_str(), tit.
c_str(), h.axis().bins(), h.axis().lowerEdge(), h.axis().upperEdge() ) );
180 for (
int i = 0; i < h.axis().bins(); ++i ) {
181 e.
push_back( h.axis().binLowerEdge( i ) );
184 e.push_back( h.axis().upperEdge() );
192 double sumw = h.sumBinHeights();
195 if ( h.equivalentBinEntries() != 0 ) sumw2 = ( sumw * sumw ) / h.equivalentBinEntries();
197 double sumwx = h.mean() * h.sumBinHeights();
198 double sumwx2 = ( h.mean() * h.mean() + h.rms() * h.rms() ) * h.sumBinHeights();
201 for (
int i = -2; i <
axis().
bins(); ++i ) {
203 m_rep->SetBinContent(
rIndex( i ), h.binHeight( i ) );
204 m_rep->SetBinError(
rIndex( i ), h.binError( i ) );
208 m_rep->SetEntries( h.allEntries() );
220 #pragma warning( pop ) 229 for (
int j = 0; j <
size; j++ ) {
233 if (
"Title" == key ) {
238 int isFixedBinning, bins;
239 s >> isFixedBinning >> bins;
241 if ( isFixedBinning ) {
242 s >> lowerEdge >> upperEdge;
247 for (
int i = 0; i <= bins; ++i ) s >> *(
double*)&edges[i];
255 for (
int i = 0; i <= bins + 1; ++i ) {
257 m_rep->SetBinContent( i, binHeight );
258 m_rep->SetBinError( i, binError );
262 m_rep->SetEntries( allEntries );
264 s >> stats[0] >> stats[1] >> stats[2] >> stats[3];
265 m_rep->PutStats( stats );
273 for (
int i = 0; i <
annotation().size(); i++ ) {
277 const AIDA::IAxis&
axis( this->
axis() );
278 const int isFixedBinning = axis.isFixedBinning();
279 const int bins = axis.bins();
280 s << isFixedBinning << bins;
281 if ( isFixedBinning ) {
282 s << axis.lowerEdge();
284 for (
int i = 0; i < bins; ++i ) s << axis.binLowerEdge( i );
286 s << axis.upperEdge();
287 for (
int i = 0; i <= bins + 1; ++i ) s <<
m_rep->GetBinContent( i ) <<
m_rep->GetBinError( i );
289 s <<
m_rep->GetEntries();
291 m_rep->GetStats( stats );
292 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.
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.