Skip to content

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

@dudarboh

Description

@dudarboh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions