//----------------------------------------------------------- // File and Version Information: // $Id: LinearInterpolPolicy.cc,v 1.4 2006/02/24 13:42:22 sneubert Exp $ // // Description: // Implementation of class LinearIP // see LinearInterpolationPolicy.hh for details // // Environment: // Software developed for the PANDA Detector at FAIR. // // Author List: // Sebastian Neubert TUM (original author) // // //----------------------------------------------------------- // This Class' Header ------------------ #include "LinearInterpolPolicy.h" // C/C++ Headers ---------------------- #include "assert.h" // Collaborating Class Headers -------- #include "TpcPoint.h" #include "TpcPrimaryCluster.h" #include "TRandom.h" // Class Member definitions ----------- void LinearInterpolPolicy::Interpolate(const TpcPoint* hit1, const TpcPoint* hit2, TClonesArray* ClusterList, unsigned int from, unsigned int n){ if(n==0)return; //calculate direction and distance between hits double x=hit1->GetX(); double y=hit1->GetY(); double z=hit1->GetZ(); double dx= hit2->GetX()-x; double dy= hit2->GetY()-y; double dz= hit2->GetZ()-z; double l=sqrt(dx*dx+dy*dy+dz*dz); if(l<1E-12)l=1E-12; dx/=l; dy/=l; dz/=l; //average distance between clusters: double s=l/n; assert(from+n<=ClusterList->GetEntriesFast()); for(unsigned int i=0;iExp(s); ((TpcPrimaryCluster*)ClusterList->At(from+i))->setpos(x+=dx*step,y+=dy*step,z+=dz*step); } };