// $Id$ // // File: DHoughFind.cc // Created: Wed Oct 31 05:59:26 EDT 2007 // Creator: davidl (on Darwin Amelia.local 8.10.1 i386) // #include #include #include using namespace std; #include "DHoughFind.h" //--------------------------------- // DHoughFind (Constructor) //--------------------------------- DHoughFind::DHoughFind() { hist = NULL; } //--------------------------------- // DHoughFind (Constructor) //--------------------------------- DHoughFind::DHoughFind(double xmin, double xmax, double ymin, double ymax, unsigned int Nbinsx, unsigned int Nbinsy) { hist = NULL; SetLimits(xmin, xmax, ymin, ymax, Nbinsx, Nbinsy); } //--------------------------------- // ~DHoughFind (Destructor) //--------------------------------- DHoughFind::~DHoughFind() { if(hist)delete[] hist; } //--------------------------------- // SetLimits //--------------------------------- void DHoughFind::SetLimits(double xmin, double xmax, double ymin, double ymax, unsigned int Nbinsx, unsigned int Nbinsy) { // If hist already has memory allocated, check if we need to reallocate if(hist){ if(this->Nbinsx*this->Nbinsy != Nbinsx*Nbinsy){ delete[] hist; hist = NULL; } } // Allocate memory if necessary if(!hist)hist = new double[Nbinsx*Nbinsy]; this->xmin = xmin; this->xmax = xmax; this->ymin = ymin; this->ymax = ymax; this->Nbinsx = Nbinsx; this->Nbinsy = Nbinsy; bin_widthx = (xmax-xmin)/(double)(Nbinsx-1); bin_widthy = (ymax-ymin)/(double)(Nbinsy-1); bin_size = bin_widthx &points) { /// Loop over "points" transforming them into lines and filling the 2-D /// histogram. // When determining the bins we just stepped into and out of, // we add a small step in the g direction to push us just over // the boundary we're currently on. We calculate the size of // that step here so we don't have to over and over inside the loop double small_step = bin_size*1.0E-3; //_DBG_<<"points.size()="< (bin_widthx*bin_widthx + bin_widthy*bin_widthy))break; // increment histo for bin we just stepped across if(ix<0 || ix>=(int)Nbinsx || iy<0 || iy>=(int)Nbinsy)break; // must have left the histo int index = ix + iy*Nbinsy; //_DBG_<<"before: index="<