18 _hitList=houghHitList;
38 for(
int i=0; i<_nTheta; i++){
56 if(_charge==-1) _houghSpace =
new TH2D(
"houghspace",
"houghspace",_nTheta,_thetaMin,_thetaMax,_nRho,_rhoMin,_rhoMax);
57 if(_charge==1 ) _houghSpace =
new TH2D(
"houghspace2",
"houghspace2",_nTheta,_thetaMin,_thetaMax,_nRho,_rhoMin,_rhoMax);
63 _mapHit =other._mapHit,
64 _nTheta =other._nTheta,
66 _thetaMin=other._thetaMin,
67 _thetaMax=other._thetaMax,
68 _rhoMin =other._rhoMin,
69 _rhoMax =other._rhoMax,
70 _hitList =other._hitList,
71 _houghPeakList=other._houghPeakList,
72 _houghTrackList=other._houghTrackList,
73 _houghSpace = other._houghSpace,
74 _charge = other._charge;
129 cout<<
"Print Peak in HoughMap sumPeak: "<<_houghPeakList.size()<<endl;
130 vector<HoughPeak>::iterator
iter =_houghPeakList.begin();
131 for(
int i=0;
iter!=_houghPeakList.end();
iter++,i++){
132 cout<<
"count of Peak on HoughMap: "<<(*iter).getHoughHitList().size()<<endl;
133 (*iter).printAllHit();
140void HoughMap::buildMap(){
141 if(
m_debug>0) cout<<
"in build map "<<endl;
144 std::vector<HoughHit>::iterator
iter = _hitList.
getList().begin();
149 double drift_CF = hit->
getR();
151 for(
int ni=0;ni<2*
m_N1;ni++){
152 double binwidth =
M_PI/_nTheta;
153 double binhigh = (_rhoMax-_rhoMin)/_nRho;
156 if( fabs(rho) >=_rhoMax )
continue;
158 int chargeOfHitOnCir = (slantOfLine/fabs(slantOfLine)) * (rho/fabs(rho));
159 if( chargeOfHitOnCir == _charge)
continue;
160 if( fabs(slantOfLine)<0.03 )
continue;
161 _houghSpace->Fill(theta,rho);
171 double aver(0),
sigma(0);
172 mapDev(_houghSpace,aver,
sigma);
174 for (
int iTheta=0; iTheta<_nTheta; iTheta++) {
175 for (
int iRho=0; iRho<_nRho; iRho++) {
176 int z=_houghSpace->GetBinContent(iTheta+1,iRho+1);
177 double thetabin = _houghSpace->GetXaxis()->GetBinCenter(iTheta+1);
178 double rhobin = _houghSpace->GetYaxis()->GetBinCenter(iRho+1);
179 double pt = (1/rhobin)/333.567;
181 if(0.06<=pt&&pt<0.07 ) MINCOUNT = 6;
182 if(pt<0.06) MINCOUNT = 5;
183 double minCount_Cut=( aver+4*
sigma >MINCOUNT)? (aver+4*
sigma):MINCOUNT;
187 if( z>=minCount_Cut) loopPeak(thetabin,rhobin,iTheta,iRho);
215void HoughMap::findPeaks(vector< vector<int> > vec_hist,
double theta_left,
double theta_right,
double rho_down,
double rho_up){
217 double rho_peak = 1./2.*(rho_down+rho_up);
218 double pt_peak = (1./rho_peak)/333.567;
219 if (0.06<=pt_peak&&pt_peak<0.07 ) minCount_Cut = 4;
220 if (pt_peak <0.06 ) minCount_Cut = 3;
221 else minCount_Cut = 5;
222 double aver(0),
sigma(0);
233 int **hough_trans_CS_peak =
new int*[_nTheta];
234 for(
int i=0; i<_nTheta; i++){
235 hough_trans_CS_peak[i] =
new int[_nRho];
236 for(
int j=0; j<_nRho; j++){ hough_trans_CS_peak[i][j]=-999;}
240 for (
int iRho=0; iRho<_nRho; iRho++) {
241 for (
int iTheta=0; iTheta<_nTheta; iTheta++) {
243 int height = vec_hist[iTheta][iRho];
244 if(height < minCount_Cut) {
245 hough_trans_CS_peak[iTheta][iRho]=0;
250 for (
int ar=iTheta-1; ar<=iTheta+1; ar++) {
251 for (
int rx=iRho-1; rx<=iRho+1; rx++) {
253 if (ar<0) { ax=ar+_nTheta; }
254 else if (ar>=_nTheta) { ax=ar-_nTheta; }
256 if ( (ax!=iTheta || rx!=iRho) && rx>=0 && rx<_nRho) {
258 int heightThisBin = vec_hist[ax][rx];
259 if (heightThisBin>max_around) { max_around=heightThisBin; }
263 if (height<max_around) { hough_trans_CS_peak[iTheta][iRho]=0; }
264 else if (height==max_around) { hough_trans_CS_peak[iTheta][iRho]=1; }
265 else if (height>max_around) { hough_trans_CS_peak[iTheta][iRho]=2; }
271 for (
int iRho=0; iRho<_nRho; iRho++) {
272 for (
int iTheta=0; iTheta<_nTheta; iTheta++) {
273 if (hough_trans_CS_peak[iTheta][iRho]==1) {
274 hough_trans_CS_peak[iTheta][iRho]=2;
275 for (
int ar=iTheta-1; ar<=iTheta+1; ar++) {
276 for (
int rx=iRho-1; rx<=iRho+1; rx++) {
278 if (ar<0) { ax=ar+_nTheta; }
279 else if (ar>=_nTheta) { ax=ar-_nTheta; }
281 if ( (ax!=iTheta || rx!=iRho) && rx>=0 && rx<_nRho) {
282 if (hough_trans_CS_peak[ax][rx]==1) { hough_trans_CS_peak[ax][rx]=0; }
287 if(hough_trans_CS_peak[iTheta][iRho]==2) {
288 int peak_num = _houghPeakList.size();
290 _houghPeakList.push_back(
HoughPeak(vec_hist[iTheta][iRho],iTheta,iRho,
exTheta(iTheta,theta_left,theta_right,
m_N2),
exRho(iRho,rho_down,rho_up,
m_N2),
true,peak_num+1,_charge) );
298 for(
int i=0; i<_nTheta; i++){
delete []hough_trans_CS_peak[i]; }
299 delete []hough_trans_CS_peak;
302int HoughMap::mergeNeighbor(
int** hough_trans_CS_peak,
double theta_left,
double theta_right,
double rho_down,
double rho_up){
307 for (
int iRho=0; iRho<_nRho; iRho++) {
308 for (
int iTheta=0; iTheta<_nTheta; iTheta++) {
309 if (hough_trans_CS_peak[iTheta][iRho]==1) {
310 hough_trans_CS_peak[iTheta][iRho]=2;
311 for (
int ar=iTheta-1; ar<=iTheta+1; ar++) {
312 for (
int rx=iRho-1; rx<=iRho+1; rx++) {
314 if (ar<0) { ax=ar+_nTheta; }
315 else if (ar>=_nTheta) { ax=ar-_nTheta; }
317 if ( (ax!=iTheta || rx!=iRho) && rx>=0 && rx<_nRho) {
318 if (hough_trans_CS_peak[ax][rx]==1) { hough_trans_CS_peak[ax][rx]=0; }
323 if(hough_trans_CS_peak[iTheta][iRho]==2) {
324 int peak_num = _houghPeakList.size();
326 _houghPeakList.push_back(
HoughPeak(_houghSpace->GetBinContent(iTheta+1,iRho+1),iTheta,iRho,
exTheta(iTheta,theta_left,theta_right,
m_N2),
exRho(iRho,rho_down,rho_up,
m_N2),
true,peak_num+1,_charge) );
331 return peakNum_Merge;
337void HoughMap::sortPeaks(){
342 double rho = rhomin+(irho+1/2.)*(rhomax-rhomin)/
n;
346 double theta= thetamin+(itheta+1/2.)*(thetamax-thetamin)/
n;
358void HoughMap::candiTrack(){
359 if( _houghPeakList.size()==0 )
return;
361 for(
int itrack=0;itrack<_houghPeakList.size();itrack++){
362 if( _houghPeakList[itrack].getisCandiTrack()==
true ) combineNeighbor(itrack);
365 for(
int ipeak=itrack+1;ipeak<_houghPeakList.size();ipeak++){
366 if(
m_debug>0) cout<<
" compare track peak : "<<itrack<<
" "<<ipeak<<endl;
367 compareTrack_and_Peak(_houghTrackList.back(),_houghPeakList[ipeak]);
413 for(
int i=0;i<sizeoftrack;i++){
414 for(
int j=0;j<sizeofpeak;j++){
419 int rho_track=track.
getRho();
421 int rho_peak=peak.
getRho();
434 cout<<
"Print Track in HoughMap: "<<endl;
435 vector<HoughTrack>::iterator
iter =_houghTrackList.begin();
436 for(
int i=0;
iter!=_houghTrackList.end();
iter++,i++){
437 cout<<
"Print Track"<<i<<endl;
438 (*iter).printRecHit();
442void HoughMap::loopPeak(
double thetabin,
double rhobin,
int iTheta,
int iRho){
446 double theta_left = thetabin-(1/2.)*(
M_PI/_nTheta);
447 double theta_right= thetabin+(1/2.)*(
M_PI/_nTheta);
448 double rho_down= rhobin-(1/2.)*((2*_rhoMax)/_nRho);
449 double rho_up = rhobin+(1/2.)*((2*_rhoMax)/_nRho);
451 std::vector<HoughHit>::iterator
iter = _hitList.
getList().begin();
452 vector< vector<int> > vec_hist(nrho,vector<int>(ntheta,0) );
453 for(
int itheta =0;itheta<ntheta;itheta++){
454 for(
int irho=0;irho<nrho;irho++){
455 vec_hist[itheta][irho]=0;
463 double drift_CF = hit->
getR();
466 hit->
makeCir(
m_N2,theta_left,theta_right,drift_CF);
467 for(
int ni=0;ni<
m_N2;ni++){
471 int chargeOfHitOnCir = (slantOfLine/fabs(slantOfLine)) * (rho/fabs(rho));
472 if( chargeOfHitOnCir == _charge )
continue;
473 if( fabs(slantOfLine)<0.03 )
continue;
475 if( theta<=theta_left|| theta>=theta_right)
continue;
476 if( rho<=rho_down || rho>=rho_up )
continue;
477 int rhobinNum = (int)( (rho-rho_down)/((rho_up-rho_down)/
m_N2) );
478 int thetabinNum = (int)( (theta-theta_left)/((theta_right-theta_left)/
m_N2) );
479 vec_hist[thetabinNum][rhobinNum]++;
485 for(
int ni=0;ni<
m_N2;ni++){
489 int chargeOfHitOnCir = (slantOfLine/fabs(slantOfLine)) * (rho/fabs(rho));
490 if( chargeOfHitOnCir == _charge )
continue;
491 if( fabs(slantOfLine)<0.03 )
continue;
493 if( theta<=theta_left|| theta>=theta_right)
continue;
494 if( rho<=rho_down || rho>=rho_up )
continue;
495 int rhobinNum = (int)( (rho-rho_down)/((rho_up-rho_down)/
m_N2) );
496 int thetabinNum = (int)( (theta-theta_left)/((theta_right-theta_left)/
m_N2) );
497 vec_hist[thetabinNum][rhobinNum]++;
503 findPeaks(vec_hist,theta_left,theta_right,rho_down,rho_up);
556 _houghSpace->GetMaximumBin(binx,biny,binz);
557 double thetabin = _houghSpace->GetXaxis()->GetBinCenter(binx);
558 double rhobin = _houghSpace->GetYaxis()->GetBinCenter(biny);
559 vector<int> vec_layer;
560 std::vector<HoughHit>::iterator iter1= _hitList.
getList().begin();
561 for(; iter1!= _hitList.
getList().end(); iter1++){
562 if( (*iter1).getSlayerType()!=0 || (*iter1).getStyle()!=0 || (*iter1).getCirList()!=0 )
continue;
563 vec_layer.push_back( (*iter1).getLayerId() );
566 if( vec_layer.size()==0 )
return;
567 vector<int>::iterator laymax=max_element( vec_layer.begin(),vec_layer.end() );
568 int maxLayer=*laymax;
572 vector<int>::iterator iterlay = vec_layer.begin();
573 for(; iterlay!= vec_layer.end(); iterlay++){
574 if ( *iterlay==*laymax) {
575 vec_layer.erase(laymax);
579 vector<int>::iterator laymax2=max_element( vec_layer.begin(),vec_layer.end() );
580 int maxLayer2=*laymax2;
583 std::vector<HoughHit>::iterator
iter = _hitList.
getList().begin();
587 double slantOfLine= hit->
getV()*
cos(thetabin) - hit->
getU()*
sin(thetabin);
590 maxlayer_slant.push_back(slantOfLine);
593 nomaxlayer_slant.push_back(slantOfLine);
599void HoughMap::cald_layer(){
601 double k,
b,theta,rho,x_cross,y_cross;
602 vector<double> vtemp,utemp;
603 std::vector<HoughHit>::iterator
iter = _hitList.
getList().begin();
613 Leastfit(utemp,vtemp,k,
b);
616 x_cross = -
b/(k+1/k);
618 rho=sqrt(x_cross*x_cross+y_cross*y_cross);
619 theta=atan2(y_cross,x_cross);
623 double cirr_track = fabs(1./(
Rho));
627 std::vector<HoughHit>::iterator iter0= _hitList.
getList().begin();
628 for(; iter0!= _hitList.
getList().end(); iter0++){
633 double cirx_hit = hit->
getMidX();
634 double ciry_hit = hit->
getMidY();
636 double l1l2 = sqrt( (cirx_hit-cirx_track)*(cirx_hit-cirx_track)+(ciry_hit-ciry_track)*(ciry_hit-ciry_track) );
638 if( l1l2>cirr_track ) deltaD = l1l2-cirr_track-cirr_hit;
639 if( l1l2<=cirr_track ) deltaD = l1l2-cirr_track+cirr_hit;
645 if(cirx_track==0||cirx_hit-cirx_track==0){
649 theta_temp=
M_PI-atan2(ciry_hit-ciry_track,cirx_hit-cirx_track)+atan2(ciry_track,cirx_track);
650 if(theta_temp>2*
M_PI){
651 theta_temp=theta_temp-2*
M_PI;
654 theta_temp=theta_temp+2*
M_PI;
659 l_temp=cirr_track*theta_temp;
662 theta_temp=2*
M_PI-theta_temp;
663 l_temp=cirr_track*(theta_temp);
672void HoughMap::hitFinding(){
673 if(
m_debug>0) cout<<
"in hit finding "<<endl;
674 for(
int ipeak=0;ipeak<_houghPeakList.size();ipeak++){
675 int hitColNum = _houghPeakList[ipeak].collectHits(_hitList);
676 if( hitColNum < 5 ) _houghPeakList[ipeak].setisCandiTrack(
false);
679void HoughMap::trackFinder(){
680 if(
m_debug>0) cout<<
"in track finder "<<endl;
681 if( _houghPeakList.size()==0 )
return;
683 for(
int itrack=0;itrack<_houghPeakList.size();itrack++){
684 if( _houghPeakList[itrack].getisCandiTrack()==
true )
685 _houghTrackList.push_back(
HoughTrack(_houghPeakList[itrack],_houghPeakList[itrack].getHoughHitList(),_houghPeakList[itrack].getRho(),_houghPeakList[itrack].getTheta() ) );
688 for(
int ipeak=itrack+1;ipeak<_houghPeakList.size();ipeak++){
689 compareTrack_and_Peak(_houghTrackList.back(),_houghPeakList[ipeak]);
693void HoughMap::Leastfit(vector<double> u,vector<double>
v,
double& k ,
double&
b){
695 double *
x=
new double[N];
696 double *
y=
new double[N];
697 for(
int i=0;i<N;i++){
702 TF1 *fpol1=
new TF1(
"fpol1",
"pol1",-50,50);
703 TGraph *tg=
new TGraph(N,x,
y);
704 tg->Fit(
"fpol1",
"QN");
705 double ktemp =fpol1->GetParameter(1);
706 double btemp =fpol1->GetParameter(0);
714void HoughMap::mapDev(vector< vector<int> > vec_hist,
double& aver ,
double&
sigma){
718 for(
int i=0;i<
m_N2;i++){
719 for(
int j=0;j<
m_N2;j++){
720 int count=vec_hist[i][j];
729 sigma=sqrt(sum2/count_use-aver*aver);
731void HoughMap::mapDev(TH2D* houghspace,
double& aver ,
double&
sigma){
735 for(
int i=0;i<
m_N1;i++){
736 for(
int j=0;j<
m_N1;j++){
737 int count=houghspace->GetBinContent(i+1,j+1);
746 sigma=sqrt(sum2/count_use-aver*aver);
double sin(const BesAngle a)
double cos(const BesAngle a)
DOUBLE_PRECISION count[3]
bool less_hits_in_peak(const HoughPeak &peaka, const HoughPeak &peakb)
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
const std::vector< HoughHit > & getList() const
const MdcDigi * digi() const
CFCir getCir(int i) const
void setFltLen(double flt)
int getSlayerType() const
double getDriftDist() const
void makeCir(int n, double phi_begin, double phi_last, double r)
double exRho(int, double, double, int)
double exTheta(int, double, double, int)
void setisCandiTrack(bool is)
vector< const HoughHit * > getHoughHitList() const
recHitCol & getHoughHitList()
int getTrackIndex() const