4 #pragma warning(disable:2259) 10 #pragma warning(disable:4996) 23 using AIDA::IProfile1D;
24 using AIDA::IHistogram1D;
25 using AIDA::IHistogram2D;
29 auto p =
new Histogram2D(
new TH2D(title.
c_str(),title.
c_str(),binsX, iminX, imaxX, binsY, iminY, imaxY));
34 auto p =
new Histogram2D(
new TH2D(title.
c_str(),title.
c_str(),eX.size()-1,&eX.front(),eY.size()-1,&eY.front()));
39 auto p =
new Histogram2D(rep);
44 TH2D *
h = getRepresentation<AIDA::IHistogram2D,TH2D>(hist);
45 Histogram2D *
n = h ?
new Histogram2D(
new TH2D(*h)) : nullptr;
51 TH2 *r = getRepresentation<IHistogram2D,TH2>(hist);
52 TH1D *t = r ? r->ProjectionX(
"_px",first,last,
"e") :
nullptr;
53 if ( t ) t->SetName(nam.
c_str());
54 Histogram1D* p = ( t ?
new Histogram1D(t) : nullptr );
60 TH2 *r = getRepresentation<IHistogram2D,TH2>(hist);
61 TH1D *t = r ? r->ProjectionY(
"_py",first,last,
"e") :
nullptr;
62 if ( t ) t->SetName(nam.
c_str());
63 Histogram1D* p = ( t ?
new Histogram1D(t) : nullptr );
69 TH2 *r = getRepresentation<IHistogram2D,TH2>(hist);
70 TH1D *t = r ? r->ProjectionY(
"_px",first,last,
"e") :
nullptr;
71 if ( t ) t->SetName(nam.
c_str());
72 Histogram1D* p = ( t ?
new Histogram1D(t) : nullptr );
78 TH2 *r = Gaudi::getRepresentation<IHistogram2D,TH2>(hist);
79 TProfile *t = r ? r->ProfileX(
"_pfx",first,last,
"e") :
nullptr;
80 if ( t ) t->SetName(nam.
c_str());
81 Profile1D* p = ( t ?
new Profile1D(t) : nullptr );
87 TH2 *r = getRepresentation<IHistogram2D,TH2>(hist);
88 TProfile *t = r ? r->ProfileY(
"_pfx",first,last,
"e") :
nullptr;
89 if ( t ) t->SetName(nam.
c_str());
90 Profile1D* p = ( t ?
new Profile1D(t) : nullptr );
98 if (className ==
"AIDA::IHistogram2D")
99 return (IHistogram2D*)
this;
100 else if (className ==
"AIDA::IHistogram")
101 return (IHistogram*)
this;
107 if (binHeight(indexX, indexY)<=0)
return 0;
108 double xx = binHeight(indexX, indexY)/binError(indexX, indexY);
109 return int(xx*xx+0.5);
114 TH2D* imp =
dynamic_cast<TH2D*
>(rep);
115 if ( !imp )
throw std::runtime_error(
"Cannot adopt native histogram representation.");
117 m_xAxis.initialize(m_rep->GetXaxis(),
true);
118 m_yAxis.initialize(m_rep->GetYaxis(),
true);
119 const TArrayD* a = m_rep->GetSumw2();
120 if ( !a || (a && a->GetSize()==0) ) m_rep->Sumw2();
121 setTitle(m_rep->GetTitle());
131 m_rep->SetDirectory(
nullptr);
138 m_rep->SetDirectory(
nullptr);
145 if (i >=0 && j >= 0) {
156 return Base::reset();
162 #pragma warning(push) 163 #pragma warning(disable:1572) 166 (weight==1.) ?
m_rep->Fill(x,y) :
m_rep->Fill(x,y,weight );
192 const char* tit = h.title().c_str();
193 if (h.xAxis().isFixedBinning() && h.yAxis().isFixedBinning() )
195 h.xAxis().bins(),h.xAxis().lowerEdge(),h.xAxis().upperEdge(),
196 h.yAxis().bins(),h.yAxis().lowerEdge(),h.yAxis().upperEdge() ) );
199 for (
int i =0; i < h.xAxis().bins(); ++i)
202 eX.push_back(h.xAxis().upperEdge() );
203 for (
int i =0; i < h.yAxis().bins(); ++i)
204 eY.push_back(h.yAxis().binLowerEdge(i));
206 eY.push_back(h.yAxis().upperEdge() );
207 m_rep.
reset(
new TH2D(tit,tit,eX.size()-1,&eX.front(),eY.size()-1,&eY.front()) );
216 double sumw = h.sumBinHeights();
218 if (h.equivalentBinEntries() != 0)
219 sumw2 = ( sumw * sumw ) /h.equivalentBinEntries();
220 double sumwx = h.meanX()*h.sumBinHeights();
221 double sumwx2 = (h.meanX()*h.meanX() + h.rmsX()*h.rmsX() )*h.sumBinHeights();
222 double sumwy = h.meanY()*h.sumBinHeights();
223 double sumwy2 = (h.meanY()*h.meanY() + h.rmsY()*h.rmsY() )*h.sumBinHeights();
227 for (
int i=-2; i <
xAxis().bins(); ++i) {
228 for (
int j=-2; j <
yAxis().bins(); ++j) {
233 if ( i >= 0 && j >= 0) {
234 sumwxy += h.binHeight(i,j)*h.binMeanX(i,j)*h.binMeanY(i,j);
240 m_rep->SetEntries(h.allEntries());
int m_sumEntries
cache sumEntries (allEntries) when setting contents since Root can't compute by himself ...
std::pair< DataObject *, AIDA::IHistogram1D * > slice1DY(const std::string &name, const AIDA::IHistogram2D &h, int firstbin, int lastbin)
Create 1D slice from 2D histogram.
bool setRms(double rmsX, double rmsY)
Sets the rms of the histogram.
virtual double equivalentBinEntries() const
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]
double rmsX() const override
Returns the rms of the profile as calculated on filling-time projected on the X axis.
std::pair< DataObject *, AIDA::IHistogram1D * > project1DY(const std::string &name, const AIDA::IHistogram2D &h, int firstbin, int lastbin)
Create 1D projection in Y from 2D histogram.
bool fill(double x, double y, double weight=1.) override
Fill the Histogram2D with a value and the.
virtual bool setBinContents(int binIndexX, int binIndexY, int entries, double height, double error, double centreX, double centreY)
Fast filling method for a given bin. It can be also the over/underflow bin.
std::vector< double > Edges
double rmsY() const override
Returns the rms of the profile as calculated on filling-time projected on the Y axis.
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
virtual int rIndexX(int index) const
operator methods
Histogram2D()
Standard Constructor.
double sumBinHeights() const override
Get the sum of in range bin heights in the IProfile.
Axis m_xAxis
X axis member.
int binEntries(int indexX, int indexY) const override
The number of entries (ie the number of times fill was called for this bin).
std::pair< DataObject *, AIDA::IHistogram2D * > createH2D(const AIDA::IHistogram2D &hist)
Copy constructor.
std::pair< DataObject *, AIDA::IHistogram1D * > slice1DX(const std::string &name, const AIDA::IHistogram2D &h, int firstbin, int lastbin)
Create 1D slice from 2D histogram.
std::pair< DataObject *, AIDA::IProfile1D * > profile1DX(const std::string &name, const AIDA::IHistogram2D &h, int firstbin, int lastbin)
Create 1D profile in X from 2D histogram.
std::pair< DataObject *, AIDA::IProfile1D * > profile1DY(const std::string &name, const AIDA::IHistogram2D &h, int firstbin, int lastbin)
Create 1D profile in Y from 2D histogram.
void initialize(TAxis *itaxi, bool)
bool setTitle(const std::string &title) override
Set the title of the object.
double meanX() const override
Returns the mean of the profile, as calculated on filling-time projected on the X axis...
Axis m_yAxis
Y axis member.
void * cast(const std::string &className) const override
Introspection method.
std::unique_ptr< IMPLEMENTATION > m_rep
Reference to underlying implementation.
int entries() const override
Get the number or all the entries.
void copyFromAida(const AIDA::IHistogram2D &h)
Create new histogram from any AIDA based histogram.
virtual int rIndexY(int index) const
operator methods
double meanY() const override
Returns the mean of the profile, as calculated on filling-time projected on the Y axis...
Helper functions to set/get the application return code.
const AIDA::IAxis & yAxis() const override
Return the Y axis.
const AIDA::IAxis & xAxis() const override
Return the X axis.
Common AIDA implementation stuff for histograms and profiles using ROOT implementations.