Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecesary loop over empty std::vector inside VertexFinderSuehara #65

Open
dudarboh opened this issue Aug 30, 2022 · 1 comment
Open

Comments

@dudarboh
Copy link

Dear experts,

The size of the savetrk is always 0. So we never actually enter the following loop, which is 44 lines long:

for(unsigned int l=0;l<savetrk.size();l++){
float okchi2=1.0e+6;
vector<Vertex*>::iterator tmpit,okit;
//first check whether this trk is unused
bool uflg=true;
for(tmpit=vtx.begin();tmpit!=vtx.end();tmpit++){
if(find((*tmpit)->getTracks().begin(), (*tmpit)->getTracks().end(), savetrk[l]) != (*tmpit)->\
getTracks().end()){
uflg=false;
break;
}
}
if(uflg==false) continue;
//start to save omitted track
for(tmpit=vtx.begin();tmpit!=vtx.end();tmpit++){
//make track vector
vector<const Track *> tmptrk;
for(unsigned int ll=0;ll<(*tmpit)->getTracks().size();ll++)
tmptrk.push_back((*tmpit)->getTracks()[ll]);
tmptrk.push_back(savetrk[l]);
Vertex *tmpvtx = VertexFitterSimple_V()(tmptrk.begin(), tmptrk.end(), (*tmpit), true);
//check max chi2
float maxchi2=0.0; //tmpvtx->getChi2Track(savetrk[ll]); //0.0;
for(unsigned int ll=0;ll<tmptrk.size();ll++)
maxchi2=max(maxchi2, (float)tmpvtx->getChi2Track(tmptrk[ll]));
if(okchi2>maxchi2){
okchi2=maxchi2;
okit=tmpit;
}
delete tmpvtx;
}
if(okchi2<cfg.chi2th){ //can add this track!
vector<const Track *> oktrk;
for(unsigned int ll=0;ll<(*okit)->getTracks().size();ll++)
oktrk.push_back((*okit)->getTracks()[ll]);
oktrk.push_back(savetrk[l]);
Vertex *okvtx = VertexFitterSimple_V() (oktrk.begin(), oktrk.end(), (*okit), true);
vtx.erase(okit);
vtx.push_back(okvtx);
}
}

Is this expected behaviour?

I am not sure what was the purpose of this loop, but at this stage of the vertexing this loop looks redundant.
Wouldn't it better to remove it?

cheers,
Bohdan

@suehara
Copy link
Member

suehara commented Oct 13, 2022

Thanks. That's funny.
I checked the history and found it's not from the original code for dbd.
I think it is not harmful...maybe OK to remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants