00001 #include "BDSBin.hh" 00002 00003 #include "globals.hh" 00004 00005 #include <iostream> 00006 #include <utility> 00007 00008 BDSBin::BDSBin(G4double inXmin, G4double inXmax) 00009 { 00010 total = 0.0; 00011 sumWeightsSquared = 0.0; 00012 xmin = inXmin; 00013 xmax = inXmax; 00014 xmean = (xmax + xmin)/2.0; 00015 /* // this creates a lot of output! 00016 #ifdef BDSDEBUG 00017 G4cout << "New bin -> xmin: " << std::setw(7) << xmin 00018 << " m, xmax: " << std::setw(7) << xmax 00019 << " m, xmean: " << std::setw(7) << xmean 00020 << " m" << G4endl; 00021 #endif 00022 */ 00023 } 00024 00025 BDSBin BDSBin::operator+= (const G4double& weight) 00026 { 00027 total += weight; 00028 sumWeightsSquared += weight*weight; 00029 return *this; 00030 } 00031 00032 bool BDSBin::InRange(G4double x) 00033 { 00034 if ( x >= xmin && x < xmax) 00035 {return true;} 00036 else 00037 {return false;} 00038 } 00039 00040 std::pair<G4double, G4double> BDSBin::GetXMeanAndTotal() 00041 { 00042 return std::make_pair(xmean,total); 00043 } 00044 00045 std::ostream& operator<< (std::ostream &out, BDSBin const &bin) 00046 { 00047 return out << "(" << bin.xmin << " , " << bin.xmax << ") : " << bin.total; 00048 }