4 #pragma warning(disable:2259) 10 #pragma warning(disable:4996) 18 auto p =
new Histogram1D(
new TH1D(title.
c_str(),title.
c_str(),nBins,xlow,xup));
23 auto p =
new Histogram1D(
new TH1D(title.
c_str(),title.
c_str(),e.size()-1,&e.front()));
28 TH1D *
h = getRepresentation<AIDA::IHistogram1D,TH1D>(hist);
29 auto n = ( h ?
new Histogram1D(
new TH1D(*h)) : nullptr );
35 if (className ==
"AIDA::IHistogram1D")
36 return const_cast<AIDA::IHistogram1D*
>((AIDA::IHistogram1D*)
this);
37 if (className ==
"AIDA::IHistogram")
38 return const_cast<AIDA::IHistogram*
>((AIDA::IHistogram*)
this);
44 if (binHeight(index)<=0)
return 0;
45 double xx = binHeight(index)/binError(index);
46 return int(xx*xx+0.5);
51 TH1D* imp =
dynamic_cast<TH1D*
>(rep);
71 if ( initialize_axis ) {
74 const TArrayD* a =
m_rep->GetSumw2();
75 if ( !a || (a && a->GetSize()==0) )
m_rep->Sumw2();
77 m_rep->SetDirectory(
nullptr);
85 for(
int i=1, n=
m_rep->GetNbinsX(); i<=
n; ++i) {
110 if (i != AIDA::IAxis::UNDERFLOW_BIN && i != AIDA::IAxis::OVERFLOW_BIN )
119 #pragma warning(push) 120 #pragma warning(disable:1572) 140 m_rep->SetEntries(allEntries);
147 if (eqBinEntries != 0)
158 (weight == 1.) ?
m_rep->Fill(x) :
m_rep->Fill(x,weight);
165 if (h.axis().isFixedBinning() ) {
166 m_rep.
reset(
new TH1D(tit.
c_str(),tit.
c_str(),h.axis().bins(),h.axis().lowerEdge(),h.axis().upperEdge()) );
170 for (
int i =0; i < h.axis().bins(); ++i) {
174 e.push_back(h.axis().upperEdge() );
182 double sumw = h.sumBinHeights();
185 if (h.equivalentBinEntries() != 0)
186 sumw2 = ( sumw * sumw ) /h.equivalentBinEntries();
188 double sumwx = h.mean()*h.sumBinHeights();
189 double sumwx2 = (h.mean()*h.mean() + h.rms()*h.rms() )*h.sumBinHeights();
192 for (
int i=-2; i <
axis().
bins(); ++i) {
199 m_rep->SetEntries(h.allEntries());
219 for (
int j = 0; j < size; j++) {
223 if (
"Title" == key) {
228 int isFixedBinning, bins;
229 s >> isFixedBinning >> bins;
231 if ( isFixedBinning ) {
232 s >> lowerEdge >> upperEdge;
237 for (
int i = 0; i <= bins; ++i )
238 s >> *(
double*)&edges[i];
246 for (
int i = 0; i <= bins + 1; ++i ) {
248 m_rep->SetBinContent( i, binHeight );
249 m_rep->SetBinError( i, binError );
253 m_rep->SetEntries( allEntries );
255 s >> stats[0] >> stats[1] >> stats[2] >> stats[3];
256 m_rep->PutStats( stats );
263 for (
int i = 0; i <
annotation().size(); i++) {
267 const AIDA::IAxis &
axis( this->
axis() );
268 const int isFixedBinning = axis.isFixedBinning();
269 const int bins = axis.bins();
270 s << isFixedBinning << bins;
271 if ( isFixedBinning ) {
272 s << axis.lowerEdge();
275 for (
int i = 0; i < bins; ++i )
276 s << axis.binLowerEdge(i);
278 s << axis.upperEdge();
279 for (
int i = 0; i <= bins + 1; ++i )
280 s <<
m_rep->GetBinContent(i) <<
m_rep->GetBinError( i );
282 s <<
m_rep->GetEntries();
284 m_rep->GetStats( stats );
285 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
std::pair< DataObject *, AIDA::IHistogram1D * > createH1D(const AIDA::IHistogram1D &hist)
Copy constructor.
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)
#define DECLARE_DATAOBJECT_FACTORY(x)
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
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.
AIDA implementation for 1 D histograms using ROOT THD1.
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.
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.