4 #pragma warning(disable:2259)
10 #pragma warning(disable:4996)
36 bool fill (
double x,
double y,
double z,
double weight);
38 virtual bool setBinContents(
int i,
int j,
int k,
int entries,
double height,
double error,
double centreX,
double centreY,
double centreZ );
40 virtual bool setRms(
double rmsX,
double rmsY,
double rmsZ);
44 void* cast(
const std::string & className)
const;
46 void copyFromAida(
const AIDA::IHistogram3D & h);
48 virtual const CLID&
clID()
const {
return classID(); }
62 TH3D* imp =
dynamic_cast<TH3D*
>(rep);
64 if ( m_rep )
delete m_rep;
66 m_xAxis.initialize(m_rep->GetXaxis(),
true);
67 m_yAxis.initialize(m_rep->GetYaxis(),
true);
68 m_zAxis.initialize(m_rep->GetZaxis(),
true);
69 const TArrayD* a = m_rep->GetSumw2();
70 if ( 0 == a || (a && a->GetSize()==0) ) m_rep->Sumw2();
71 setTitle(m_rep->GetTitle());
74 throw std::runtime_error(
"Cannot adopt native histogram representation.");
79 std::pair<DataObject*,AIDA::IHistogram3D*>
80 Gaudi::createH3D(
const std::string& title,
int nBinsX,
double xlow,
double xup,
int nBinsY,
double ylow,
double yup,
int nBinsZ,
double zlow,
double zup) {
81 Histogram3D* p =
new Histogram3D(
new TH3D(title.c_str(),title.c_str(),nBinsX,xlow,xup,nBinsY,ylow,yup,nBinsZ,zlow,zup));
82 return std::pair<DataObject*,AIDA::IHistogram3D*>(p,p);
86 std::pair<DataObject*,AIDA::IHistogram3D*>
87 Gaudi::createH3D(
const std::string& title,
const Edges& eX,
const Edges& eY,
const Edges& eZ) {
88 Histogram3D* p =
new Histogram3D(
new TH3D(title.c_str(),title.c_str(),eX.size()-1,&eX.front(), eY.size()-1,&eY.front(), eZ.size()-1,&eZ.front()));
89 return std::pair<DataObject*,AIDA::IHistogram3D*>(p,p);
92 std::pair<DataObject*,AIDA::IHistogram3D*>
Gaudi::createH3D(
const AIDA::IHistogram3D& hist) {
93 TH3D *h = getRepresentation<AIDA::IHistogram3D,TH3D>(hist);
94 Histogram3D *
n = h ?
new Histogram3D(
new TH3D(*h)) : 0;
95 return std::pair<DataObject*,AIDA::IHistogram3D*>(
n,
n);
106 m_rep->SetDirectory(0);
111 adoptRepresentation(rep);
116 m_rep->SetDirectory(0);
121 m_rep->SetBinContent(rIndexX(i), rIndexY(j), rIndexZ(k), height);
122 m_rep->SetBinError(rIndexX(i), rIndexY(j), rIndexZ(k), error);
124 if (i >=0 && j >= 0 && k >= 0) {
125 m_sumwx += centreX*height;
126 m_sumwy += centreY*height;
127 m_sumwz += centreZ*height;
129 m_sumEntries += entries;
143 m_rep->Fill ( x , y, z, weight );
148 if (className ==
"AIDA::IHistogram3D") {
149 return (AIDA::IHistogram3D*)
this;
151 else if (className ==
"AIDA::IHistogram") {
152 return (AIDA::IHistogram*)
this;
160 #pragma warning(push)
161 #pragma warning(disable:1572)
164 m_rep->SetEntries(m_sumEntries);
165 std::vector<double> stat(11);
167 stat[0] = sumBinHeights();
169 if (equivalentBinEntries() != 0)
170 stat[1] = ( sumBinHeights() * sumBinHeights() ) / equivalentBinEntries();
173 if ( sumBinHeights() != 0 ) meanX = m_sumwx/ sumBinHeights();
174 stat[3] = ( meanX*meanX + rmsX*rmsX )* sumBinHeights();
177 if ( sumBinHeights() != 0 ) meanY = m_sumwy/ sumBinHeights();
178 stat[5] = ( meanY*meanY + rmsY*rmsY )* sumBinHeights();
182 if ( sumBinHeights() != 0 ) meanZ = m_sumwz/ sumBinHeights();
183 stat[8] = ( meanZ*meanZ + rmsZ*rmsZ )* sumBinHeights();
186 m_rep->PutStats(&stat.front());
193 const char* tit = h.title().c_str();
194 if (h.xAxis().isFixedBinning() && h.yAxis().isFixedBinning() && h.zAxis().isFixedBinning() ) {
195 m_rep =
new TH3D(tit,tit,
196 h.xAxis().bins(), h.xAxis().lowerEdge(), h.xAxis().upperEdge(),
197 h.yAxis().bins(), h.yAxis().lowerEdge(), h.yAxis().upperEdge(),
198 h.zAxis().bins(), h.zAxis().lowerEdge(), h.zAxis().upperEdge() );
202 for (
int i =0;
i < h.xAxis().bins(); ++
i)
203 eX.push_back(h.xAxis().binLowerEdge(
i));
205 eX.push_back(h.xAxis().upperEdge() );
206 for (
int i =0;
i < h.yAxis().bins(); ++
i)
207 eY.push_back(h.yAxis().binLowerEdge(
i));
209 eY.push_back(h.yAxis().upperEdge() );
210 for (
int i =0;
i < h.zAxis().bins(); ++
i)
211 eZ.push_back(h.zAxis().binLowerEdge(
i));
213 eZ.push_back(h.zAxis().upperEdge() );
214 m_rep =
new TH3D(tit,tit,eX.size()-1,&eX.front(),eY.size()-1,&eY.front(),eZ.size()-1,&eZ.front());
216 m_xAxis.initialize(m_rep->GetXaxis(),
true);
217 m_yAxis.initialize(m_rep->GetYaxis(),
true);
218 m_zAxis.initialize(m_rep->GetZaxis(),
true);
219 const TArrayD* a = m_rep->GetSumw2();
220 if ( 0 == a || (a && a->GetSize()==0) ) m_rep->Sumw2();
227 double sumw = h.sumBinHeights();
229 if (h.equivalentBinEntries() != 0)
230 sumw2 = ( sumw * sumw ) /h.equivalentBinEntries();
231 double sumwx = h.meanX()*h.sumBinHeights();
232 double sumwx2 = (h.meanX()*h.meanX() + h.rmsX()*h.rmsX() )*h.sumBinHeights();
233 double sumwy = h.meanY()*h.sumBinHeights();
234 double sumwy2 = (h.meanY()*h.meanY() + h.rmsY()*h.rmsY() )*h.sumBinHeights();
235 double sumwz = h.meanZ()*h.sumBinHeights();
236 double sumwz2 = (h.meanZ()*h.meanZ() + h.rmsZ()*h.rmsZ() )*h.sumBinHeights();
242 for (
int i=-2;
i < xAxis().bins(); ++
i) {
243 for (
int j=-2; j < yAxis().bins(); ++j) {
244 for (
int k=-2; k < zAxis().bins(); ++k) {
245 m_rep->SetBinContent(rIndexX(
i), rIndexY(j), rIndexZ(k), h.binHeight(
i,j,k) );
246 m_rep->SetBinError(rIndexX(
i), rIndexY(j), rIndexZ(k), h.binError(
i,j,k) );
248 if (
i >= 0 && j >= 0 && k >= 0) {
249 sumwxy += h.binHeight(
i,j,k)*h.binMeanX(
i,j,k)*h.binMeanY(
i,j,k);
250 sumwxz += h.binHeight(
i,j,k)*h.binMeanX(
i,j,k)*h.binMeanZ(
i,j,k);
251 sumwyz += h.binHeight(
i,j,k)*h.binMeanY(
i,j,k)*h.binMeanZ(
i,j,k);
258 m_rep->SetEntries(h.allEntries());
261 std::vector<double> stat(11);
273 m_rep->PutStats(&stat.front());
static const CLID & classID()
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
std::vector< double > Edges
IMPLEMENTATION * m_rep
Reference to underlying implementation.
virtual bool setBinContents(int i, int j, int k, int entries, double height, double error, double centreX, double centreY, double centreZ)
Fast filling method for a given bin. It can be also the over/underflow bin.
virtual const CLID & clID() const
Retrieve reference to class defininition identifier.
Histogram3D()
Standard Constructor.
AIDA implementation for 2 D histograms using ROOT THD2.
unsigned int CLID
Class ID definition.
void copyFromAida(const AIDA::IHistogram3D &h)
Create new histogram from any AIDA based histogram.
std::pair< DataObject *, AIDA::IHistogram3D * > createH3D(const AIDA::IHistogram3D &hist)
Copy constructor.
#define DECLARE_DATAOBJECT_FACTORY(x)
virtual bool setRms(double rmsX, double rmsY, double rmsZ)
Sets the rms of the histogram.
This is a number of static methods for bootstrapping the Gaudi framework.
void * cast(const std::string &className) const
Introspection method.
virtual bool setTitle(const std::string &title)
Set the title of the object.
A DataObject is the base class of any identifiable object on any data store.
bool fill(double x, double y, double z, double weight)
Fill bin content.
virtual ~Histogram3D()
Destructor.
Common AIDA implementation stuff for histograms and profiles using ROOT implementations.
virtual void adoptRepresentation(TObject *rep)
Adopt ROOT histogram representation.