// ---------------------------------------------------------------------- // // HepTH1F.cc - implementation of class HepTH1F // // Intended to gain access to the protected members of the Root TH1F class. // // This class is used to import an existing histogram object from possibly // some other manager and manufacture a temporary TH1F object with all the // same characteristics as the original. That way, we can use the existing // Root methods to implement the increment operators. // // Because of the eccentricities of the various managers, we do NOT manage // to get some of the statistical sums quite right - in particular the // sum of the squared weights - so the overall statistics should not be taken // too seriously. // // 25-Feb-1999 J. Marraffino Initial definition // // // ---------------------------------------------------------------------- #include "HepTuple/HepTH1F.h" #ifndef HEPTRACE_H #include "HepTuple/HepTrace.h" #endif #ifndef HEPFILEMANAGER_H #include "HepTuple/HepFileManager.h" #endif #ifndef HEPHIST1D_H #include "HepTuple/HepHist1D.h" #endif #ifndef HEPRAWHIST_H #include "HepTuple/HepRawHist.h" #endif ZM_BEGIN_NAMESPACE( zmht ) /* namespace zmht { */ // Constructor HepTH1F::HepTH1F( const HepHist1D & h ) : TH1F("Temporary", h.title().c_str(), h.nBins(), h.min(), h.max() ) { // Gather up all the data we need from h. Do type conversions as necessary. // First get the over/under-flow counts float nunder; float nover; h.getOverflows( &nover, &nunder ); // Then the bin contents. int numBins = h.nBins(); float * contents = new float[numBins]; float * errors = new float[numBins]; h.getContents( contents ); h.getErrors( errors ); // Finally, the overall statistics int numEntries; float sumW, sumW2; double sumWX, sumWX2; h.getStatistics( numEntries, sumW, sumW2, sumWX, sumWX2 ); // Move the bin contents and bin errors for( int i=0; iSetBinContent( i+1, (Stat_t)contents[i] ); } for( int i=0; iSetBinError( i+1, (Stat_t)errors[i] ); } delete [] contents; delete [] errors; // Then underflows and overflows float minX = h.min(); float maxX = h.max(); if ( nover > 0 ) { float tempx = maxX+1.0; this->Fill( tempx, nover ); } if( nunder > 0 ) { float tempx = minX-1.0; this->Fill( tempx, nunder ); } // Now set the overall statistics this->fEntries = (Stat_t)numEntries; this->fTsumw = (Stat_t)sumW; this->fTsumw2 = (Stat_t)sumW2; this->fTsumwx = (Stat_t)sumWX; this->fTsumwx2 = (Stat_t)sumWX2; } // destructor HepTH1F::~HepTH1F() { } ZM_END_NAMESPACE( zmht ) /* } // namespace zmht */