// ---------------------------------------------------------------------- // // HepTH1P.cc - implementation of class HepTH1P // // Intended to gain access to the protected members of the Root TProfile class. // // This class is used to import an existing histogram object from possibly // some other manager and manufacture a temporary TProfile object with all the // same characteristics as the original. That way, we can use the existing // Root methods to implement the increment operators. // // Note that, as of the date of the initial definition, Root has no // implementation for TProfile::Multiply. A method exists but it simply // issues a warning message and returns. // // 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/HepTH1P.h" #ifndef HEPTRACE_H #include "HepTuple/HepTrace.h" #endif #ifndef HEPFILEMANAGER_H #include "HepTuple/HepFileManager.h" #endif #ifndef HEPHISTPROF_H #include "HepTuple/HepHistProf.h" #endif #ifndef HEPRAWHIST_H #include "HepTuple/HepRawHist.h" #endif ZM_BEGIN_NAMESPACE( zmht ) /* namespace zmht { */ // Constructor HepTH1P::HepTH1P( const HepHistProf & h ) : TProfile("Temporary", h.title().c_str(), h.nBinsX(), h.minX(), h.maxX(), h.minY(), h.maxY() ) { // Gather up all the data we need from h. Do type conversions as necessary. // First get the over/under-flow counts int numBins = h.nBinsX(); float numOver; float numUnder; h.getOverflows( &numOver, &numUnder ); // Then the bin contents. float * psumW = new float[numBins]; float * psumWY = new float[numBins]; float * psumWY2 = new float[numBins]; h.getSumW( psumW ); h.getSumWY( psumWY ); h.getSumWY2( psumWY2 ); // Finally, the overall statistics int numEntries; float sumW, sumW2; double sumWX, sumWX2; h.getStatistics( numEntries, sumW, sumW2, sumWX, sumWX2 ); // Move the sums for( int i=0; i 0 ) { Fill( (Axis_t)(maxX+1.0), 1.0, (Stat_t)numOver ); } if( numUnder > 0 ) { Fill( (Axis_t)(minX-1.0), 1.0, (Stat_t)numUnder ); } // 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; } void HepTH1P::finishStatProf( HepRootHistProf * h ) { // This bit of foolishness is needed because the TH1::Divide and Multiply // methods attempt to update the x sums and get it wrong. this->fEntries = h->entries(); this->fTsumwx = h->sumX(); this->fTsumwx2 = h->sumX2(); this->fTsumw = h->weight(); this->fTsumw2 = h->weight2(); } // destructor HepTH1P::~HepTH1P() { } #ifdef ROOT_2_24 // For backward compatibility ... to be removed when cdf move to v2.25 float HepTH1P::fetchWeight( // get sum of weights for specified bin int numBin ) #else double HepTH1P::fetchWeight( // get sum of weights for specified bin int numBin ) #endif { int i = numBin; if( numBin < 0 ) i = 0; if( numBin > fNcells-1 ) i = fNcells-1; return (float)fBinEntries.fArray[i]; } void HepTH1P::fetchSumW( // get sum of weights for all bins float * values ) { int numBins = fNcells; for( int i=0; i