4 #pragma warning(disable:2259) 10 #pragma warning(disable:4996) 19 auto p =
new Histogram1D(
new TH1D(title.
c_str(),title.
c_str(),nBins,xlow,xup));
24 auto p =
new Histogram1D(
new TH1D(title.
c_str(),title.
c_str(),e.size()-1,&e.front()));
29 TH1D *
h = getRepresentation<AIDA::IHistogram1D,TH1D>(hist);
30 auto n = ( h ?
new Histogram1D(
new TH1D(*h)) : nullptr );
36 if (className ==
"AIDA::IHistogram1D")
37 return const_cast<AIDA::IHistogram1D*
>((AIDA::IHistogram1D*)
this);
38 if (className ==
"AIDA::IHistogram")
39 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);
72 if ( initialize_axis ) {
75 const TArrayD* a =
m_rep->GetSumw2();
76 if ( !a || (a && a->GetSize()==0) )
m_rep->Sumw2();
78 m_rep->SetDirectory(
nullptr);
86 for(
int i=1, n=
m_rep->GetNbinsX(); i<=
n; ++i) {
111 if (i != AIDA::IAxis::UNDERFLOW_BIN && i != AIDA::IAxis::OVERFLOW_BIN )
120 #pragma warning(push) 121 #pragma warning(disable:1572) 141 m_rep->SetEntries(allEntries);
148 if (eqBinEntries != 0)
159 (weight == 1.) ?
m_rep->Fill(x) :
m_rep->Fill(x,weight);
166 if (h.axis().isFixedBinning() ) {
167 m_rep.
reset(
new TH1D(tit.
c_str(),tit.
c_str(),h.axis().bins(),h.axis().lowerEdge(),h.axis().upperEdge()) );
171 for (
int i =0; i < h.axis().bins(); ++i) {
175 e.push_back(h.axis().upperEdge() );
183 double sumw = h.sumBinHeights();
186 if (h.equivalentBinEntries() != 0)
187 sumw2 = ( sumw * sumw ) /h.equivalentBinEntries();
189 double sumwx = h.mean()*h.sumBinHeights();
190 double sumwx2 = (h.mean()*h.mean() + h.rms()*h.rms() )*h.sumBinHeights();
193 for (
int i=-2; i <
axis().
bins(); ++i) {
200 m_rep->SetEntries(h.allEntries());
220 for (
int j = 0; j < size; j++) {
224 if (
"Title" == key) {
229 int isFixedBinning, bins;
230 s >> isFixedBinning >> bins;
232 if ( isFixedBinning ) {
233 s >> lowerEdge >> upperEdge;
238 for (
int i = 0; i <= bins; ++i )
239 s >> *(
double*)&edges[i];
247 for (
int i = 0; i <= bins + 1; ++i ) {
249 m_rep->SetBinContent( i, binHeight );
250 m_rep->SetBinError( i, binError );
254 m_rep->SetEntries( allEntries );
256 s >> stats[0] >> stats[1] >> stats[2] >> stats[3];
257 m_rep->PutStats( stats );
264 for (
int i = 0; i <
annotation().size(); i++) {
268 const AIDA::IAxis &
axis( this->
axis() );
269 const int isFixedBinning = axis.isFixedBinning();
270 const int bins = axis.bins();
271 s << isFixedBinning << bins;
272 if ( isFixedBinning ) {
273 s << axis.lowerEdge();
276 for (
int i = 0; i < bins; ++i )
277 s << axis.binLowerEdge(i);
279 s << axis.upperEdge();
280 for (
int i = 0; i <= bins + 1; ++i )
281 s <<
m_rep->GetBinContent(i) <<
m_rep->GetBinError( i );
283 s <<
m_rep->GetEntries();
285 m_rep->GetStats( stats );
286 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)
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.
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.