// $Id: Track.cpp,v 1.4 2003/06/12 11:06:57 helgevos Exp $ // Include files #include // local #include "Track.h" #include "math.h" //----------------------------------------------------------------------------- // Implementation file for class : Track // // 2003-02-07 : Helge VOSS //----------------------------------------------------------------------------- //============================================================================= // Standard constructor, initializes variables //============================================================================= ClassImp(Track) double Track::x(){return m_x;} ///< return x of track double Track::tx(){return m_tx;} ///< return tx of track double Track::y(){return m_y;} ///< return y of track double Track::ty(){return m_ty;} ///< return ty of track double Track::chi2(){return m_chi2;} double Track::sigma(){return m_sigma;} double Track::chargeTwoStrips(int idet){ return m_adcp1[idet] + m_adcm1[idet]; } double Track::chargeFourStrips(int idet){ return m_adcp2[idet] + m_adcp1[idet] + m_adcm1[idet] + m_adcm2[idet]; } double Track::chargeSixStrips(int idet){ return m_adcp3[idet] + m_adcp2[idet] + m_adcp1[idet] + m_adcm1[idet] + m_adcm2[idet] + m_adcm3[idet]; } double Track::adcp3(int idet){ return m_adcp3[idet];} double Track::adcp2(int idet){ return m_adcp2[idet];} double Track::adcp1(int idet){ return m_adcp1[idet];} double Track::adcm1(int idet){ return m_adcm1[idet];} double Track::adcm2(int idet){ return m_adcm2[idet];} double Track::adcm3(int idet){ return m_adcm3[idet];} void Track::setXdet(double Xdet, int idet) { m_xdet.push_back(Xdet); } void Track::setYdet(double Ydet, int idet) { m_ydet.push_back(Ydet); } void Track::setStripOnDet(double strip, int idet) { m_strip.push_back(strip); } void Track::setADCvalues(RawEvent & rev, int idet, int maxstrip){ if (idet >= m_strip.size()){ std::cout << "ERROR Track setADCvalues, need first to get stripOnDet\n"; }else{ int i = (int)floor(this->stripOnDet(idet)); m_adcm3.push_back(rev.data(std::min(maxstrip,std::max(i-2,0)))); m_adcm2.push_back(rev.data(std::min(maxstrip,std::max(i-1,0)))); m_adcm1.push_back(rev.data(std::min(maxstrip,std::max(i,0)))); m_adcp1.push_back(rev.data(std::min(maxstrip,std::max(i+1,0)))); m_adcp2.push_back(rev.data(std::min(maxstrip,std::max(i+2,0)))); m_adcp3.push_back(rev.data(std::min(maxstrip,std::max(i+3,0)))); } } double Track::xdet(int idet) { return m_xdet[idet]; } double Track::ydet(int idet) { return m_ydet[idet]; } double Track::stripOnDet( int idet) { return m_strip[idet]; } //find clostest cluster to the track and retrun its SIGNED distance in #strips double Track::minClusterDist(std::vector clList, int idet){ double dist=1000; for (std::vector::iterator icl = clList.begin(); icl != clList.end(); icl++){ if (fabs(this->stripOnDet(idet) - (*icl)->cog() ) < fabs(dist)){ dist = this->stripOnDet(idet) - (*icl)->cog(); } } return dist; } //find a cluster matching the track. Return NULL pointer if no cluster //found closer to the track than at last "mindist" given in #strips Cluster* Track::matchCluster(std::vector clList, int idet, double mindist,double minClChi2 ){///< find matching cluster double dist=1000; Cluster* mincl = NULL; for (std::vector::iterator icl = clList.begin(); icl != clList.end(); icl++){ //only take into account those clusters that pass the Chi2 cut if ((*icl)->chi2() > minClChi2) { if (fabs(this->stripOnDet(idet) - (*icl)->cog() ) < dist){ dist = fabs(this->stripOnDet(idet) - (*icl)->cog() ); if (dist < mindist) mincl = *icl; } } } return mincl; } //check if cluster is matched bool Track::ismatched(Cluster* icl,int idet, double mindist){ return (fabs(this->stripOnDet(idet) - icl->cog() ) <= mindist); } void Track::Print(){ std::cout << " x,y,tx,ty = " << m_x << " " << m_y << " " << m_tx << " " << m_ty << std::endl; for (int i=0; i< m_strip.size(); i++){ std::cout << " intersections with Ladder " << i << std::endl; std::cout << " strip/ladder intersect strip= " <