|
Gaudi Framework, version v21r8 |
| Home | Generated: 17 Mar 2010 |
#include <H1D.h>


Public Member Functions | |
| Histogram1D () | |
| Standard constructor. | |
| Histogram1D (TH1D *rep) | |
| Standard constructor with initialization. The histogram representation will be adopted. | |
| virtual | ~Histogram1D () |
| Destructor. | |
| virtual void | adoptRepresentation (TObject *rep) |
| Adopt ROOT histogram representation. | |
| virtual bool | setBinContents (int i, int entries, double height, double error, double centre) |
| set bin content (entries and centre are not used ) | |
| virtual bool | reset () |
| need to overwrite reset to reset the sums | |
| virtual bool | setStatistics (int allEntries, double eqBinEntries, double mean, double rms) |
| set histogram statistics | |
| virtual bool | fill (double x, double weight) |
| Fill the Profile1D with a value and the corresponding weight. | |
| bool | setRms (double rms) |
| Update histogram RMS. | |
| void | copyFromAida (const AIDA::IHistogram1D &h) |
| Create new histogram from any AIDA based histogram. | |
| virtual const CLID & | clID () const |
| Retrieve reference to class defininition identifier. | |
| StreamBuffer & | serialize (StreamBuffer &s) |
| Serialization mechanism, Serialize the object for reading. | |
| StreamBuffer & | serialize (StreamBuffer &s) const |
| Serialization mechanism, Serialize the object for writing. | |
Static Public Member Functions | |
| static const CLID & | classID () |
| Retrieve reference to class definition structure (static access). | |
Protected Attributes | |
| double | m_sumwx |
| cache sumwx when setting contents since I don't have bin mean | |
Private Member Functions | |
| void | init (const std::string &title, bool initialize_axis=true) |
| void | initSums () |
Definition at line 17 of file H1D.h.
| Gaudi::Histogram1D::Histogram1D | ( | ) |
| Gaudi::Histogram1D::Histogram1D | ( | TH1D * | rep | ) |
| virtual Gaudi::Histogram1D::~Histogram1D | ( | ) | [inline, virtual] |
| void Gaudi::Histogram1D::init | ( | const std::string & | title, | |
| bool | initialize_axis = true | |||
| ) | [private] |
Definition at line 62 of file H1D.cpp.
00062 { 00063 m_classType = "IHistogram1D"; 00064 if ( initialize_axis ) { 00065 m_axis.initialize(m_rep->GetXaxis(),false); 00066 } 00067 const TArrayD* a = m_rep->GetSumw2(); 00068 if ( 0 == a || (a && a->GetSize()==0) ) m_rep->Sumw2(); 00069 setTitle(title); 00070 m_rep->SetDirectory(0); 00071 m_sumEntries = 0; 00072 m_sumwx = 0; 00073 }
| void Gaudi::Histogram1D::initSums | ( | ) | [private] |
| void Gaudi::Histogram1D::adoptRepresentation | ( | TObject * | rep | ) | [virtual] |
| bool Gaudi::Histogram1D::setBinContents | ( | int | i, | |
| int | entries, | |||
| double | height, | |||
| double | error, | |||
| double | centre | |||
| ) | [virtual] |
set bin content (entries and centre are not used )
Definition at line 99 of file H1D.cpp.
00099 { 00100 m_rep->SetBinContent(rIndex(i),height); 00101 m_rep->SetBinError(rIndex(i),error); 00102 // accumulate sumwx for in range bins 00103 if (i != AIDA::IAxis::UNDERFLOW_BIN && i != AIDA::IAxis::OVERFLOW_BIN ) 00104 m_sumwx += centre*height; 00105 m_sumEntries += entries; 00106 return true; 00107 }
| bool Gaudi::Histogram1D::reset | ( | ) | [virtual] |
| bool Gaudi::Histogram1D::setStatistics | ( | int | allEntries, | |
| double | eqBinEntries, | |||
| double | mean, | |||
| double | rms | |||
| ) | [virtual] |
set histogram statistics
Definition at line 126 of file H1D.cpp.
00126 { 00127 m_rep->SetEntries(allEntries); 00128 // fill statistcal vector for Root 00129 std::vector<double> stat(11); 00130 // sum weights 00131 stat[0] = sumBinHeights(); 00132 // sum weights **2 00133 stat[1] = 0; 00134 if (eqBinEntries != 0) 00135 stat[1] = ( sumBinHeights() * sumBinHeights() ) / eqBinEntries; 00136 // sum weights * x 00137 stat[2] = mean*sumBinHeights(); 00138 // sum weight * x **2 00139 stat[3] = ( mean*mean + rms*rms )* sumBinHeights(); 00140 m_rep->PutStats(&stat.front()); 00141 return true; 00142 }
| bool Gaudi::Histogram1D::fill | ( | double | x, | |
| double | weight | |||
| ) | [virtual] |
| bool Gaudi::Histogram1D::setRms | ( | double | rms | ) |
Update histogram RMS.
Definition at line 109 of file H1D.cpp.
00109 { 00110 m_rep->SetEntries(m_sumEntries); 00111 std::vector<double> stat(11); 00112 // sum weights 00113 stat[0] = sumBinHeights(); 00114 stat[1] = 0; 00115 if (equivalentBinEntries() != 0) 00116 stat[1] = ( sumBinHeights() * sumBinHeights() ) / equivalentBinEntries(); 00117 stat[2] = m_sumwx; 00118 double mean = 0; 00119 if ( sumBinHeights() != 0 ) mean = m_sumwx/ sumBinHeights(); 00120 stat[3] = ( mean*mean + rms*rms )* sumBinHeights(); 00121 m_rep->PutStats(&stat.front()); 00122 return true; 00123 }
| void Gaudi::Histogram1D::copyFromAida | ( | const AIDA::IHistogram1D & | h | ) |
Create new histogram from any AIDA based histogram.
Definition at line 149 of file H1D.cpp.
00149 { 00150 // implement here the copy 00151 std::string tit = h.title()+"Copy"; 00152 delete m_rep; 00153 if (h.axis().isFixedBinning() ) { 00154 m_rep = new TH1D(tit.c_str(),tit.c_str(),h.axis().bins(),h.axis().lowerEdge(),h.axis().upperEdge()); 00155 } 00156 else { 00157 Edges e; 00158 for (int i =0; i < h.axis().bins(); ++i) { 00159 e.push_back(h.axis().binLowerEdge(i)); 00160 } 00161 // add also upperedges at the end 00162 e.push_back(h.axis().upperEdge() ); 00163 m_rep = new TH1D(tit.c_str(),tit.c_str(),e.size()-1,&e.front()); 00164 } 00165 m_axis.initialize(m_rep->GetXaxis(),false); 00166 m_rep->Sumw2(); 00167 m_sumEntries = 0; 00168 m_sumwx = 0; 00169 // sumw 00170 double sumw = h.sumBinHeights(); 00171 // sumw2 00172 double sumw2 = 0; 00173 if (h.equivalentBinEntries() != 0) 00174 sumw2 = ( sumw * sumw ) /h.equivalentBinEntries(); 00175 00176 double sumwx = h.mean()*h.sumBinHeights(); 00177 double sumwx2 = (h.mean()*h.mean() + h.rms()*h.rms() )*h.sumBinHeights(); 00178 00179 // copy the contents in 00180 for (int i=-2; i < axis().bins(); ++i) { 00181 // root binning starts from one ! 00182 m_rep->SetBinContent(rIndex(i),h.binHeight(i) ); 00183 m_rep->SetBinError(rIndex(i),h.binError(i) ); 00184 } 00185 // need to do set entries after setting contents otherwise root will recalulate them 00186 // taking into account how many time SetBinContents() has been called 00187 m_rep->SetEntries(h.allEntries()); 00188 // stat vector 00189 std::vector<double> stat(11); 00190 stat[0] = sumw; 00191 stat[1] = sumw2; 00192 stat[2] = sumwx; 00193 stat[3] = sumwx2; 00194 m_rep->PutStats(&stat.front()); 00195 }
| virtual const CLID& Gaudi::Histogram1D::clID | ( | ) | const [inline, virtual] |
Retrieve reference to class defininition identifier.
Reimplemented from DataObject.
Definition at line 46 of file H1D.h.
00046 { return Gaudi::Histogram1D::classID(); }
| static const CLID& Gaudi::Histogram1D::classID | ( | ) | [inline, static] |
| StreamBuffer & Gaudi::Histogram1D::serialize | ( | StreamBuffer & | s | ) | [virtual] |
Serialization mechanism, Serialize the object for reading.
| s | the StreamBuffer containing the data to be read |
Reimplemented from DataObject.
Definition at line 197 of file H1D.cpp.
00197 { 00198 DataObject::serialize(s); 00199 std::string title; 00200 int size; 00201 s >> size; 00202 for (int j = 0; j < size; j++) { 00203 std::string key, value; 00204 s >> key >> value; 00205 annotation().addItem (key, value); 00206 if ("Title" == key) { 00207 title = value; 00208 } 00209 } 00210 double lowerEdge, upperEdge, binHeight, binError; 00211 int isFixedBinning, bins; 00212 s >> isFixedBinning >> bins; 00213 00214 if ( m_rep ) delete m_rep; 00215 if ( isFixedBinning ) { 00216 s >> lowerEdge >> upperEdge; 00217 m_rep = new TH1D(title.c_str(),title.c_str(),bins,lowerEdge,upperEdge); 00218 } else { 00219 Edges edges; 00220 edges.resize(bins); 00221 for ( int i = 0; i <= bins; ++i ) 00222 s >> *(double*)&edges[i]; 00223 m_rep = new TH1D(title.c_str(),title.c_str(),edges.size()-1,&edges.front()); 00224 } 00225 m_axis.initialize(m_rep->GetXaxis(),true); 00226 m_rep->Sumw2(); 00227 m_sumEntries = 0; 00228 m_sumwx = 0; 00229 00230 for ( int i = 0; i <= bins + 1; ++i ) { 00231 s >> binHeight >> binError; 00232 m_rep->SetBinContent( i, binHeight ); 00233 m_rep->SetBinError( i, binError ); 00234 } 00235 Stat_t allEntries; 00236 s >> allEntries; 00237 m_rep->SetEntries( allEntries ); 00238 Stat_t stats[4]; // stats array 00239 s >> stats[0] >> stats[1] >> stats[2] >> stats[3]; 00240 m_rep->PutStats( stats ); 00241 return s; 00242 }
| StreamBuffer & Gaudi::Histogram1D::serialize | ( | StreamBuffer & | s | ) | const [virtual] |
Serialization mechanism, Serialize the object for writing.
| s | the StreamBuffer where to write the data |
Reimplemented from DataObject.
Definition at line 244 of file H1D.cpp.
00244 { 00245 DataObject::serialize(s); 00246 s << static_cast<int>( annotation().size() ); 00247 for (int i = 0; i < annotation().size(); i++) { 00248 s << annotation().key(i); 00249 s << annotation().value(i); 00250 } 00251 const AIDA::IAxis & axis( this->axis() ); 00252 const int isFixedBinning = axis.isFixedBinning(); 00253 const int bins = axis.bins(); 00254 s << isFixedBinning << bins; 00255 if ( isFixedBinning ) { 00256 s << axis.lowerEdge(); 00257 } 00258 else { 00259 for ( int i = 0; i < bins; ++i ) 00260 s << axis.binLowerEdge(i); 00261 } 00262 s << axis.upperEdge(); 00263 for ( int i = 0; i <= bins + 1; ++i ) 00264 s << m_rep->GetBinContent(i) << m_rep->GetBinError( i ); 00265 00266 s << m_rep->GetEntries(); 00267 Stat_t stats[4]; // stats array 00268 m_rep->GetStats( stats ); 00269 s << stats[0] << stats[1] << stats[2] << stats[3]; 00270 return s; 00271 }
double Gaudi::Histogram1D::m_sumwx [protected] |