Skip to content

Commit

Permalink
Merge pull request #23 from andresailer/primVtx
Browse files Browse the repository at this point in the history
[WIP/RFC] Fix issues if BeamspotConstraint is false
  • Loading branch information
tomohikosan authored Jun 16, 2017
2 parents c9c193d + fe293aa commit 14f59b2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/VertexFinderSuehara.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void associateIPTracks(vector<Vertex*>& vertices, Vertex* ip, VertexFinderSuehar
//using AVF method
void associateIPTracksAVF(vector<Vertex*>& vertices, Vertex* ip, VertexFinderSueharaConfig& cfg);

void buildUp(TrackVec& tracks, vector<Vertex*>& vtx, vector<Vertex*>& v0vtx, double chi2thpri, VertexFinderSueharaConfig& cfg, Vertex* ip = 0);
void buildUp(TrackVec& tracks, vector<Vertex*>& vtx, vector<Vertex*>& v0vtx, double chi2thpri, VertexFinderSueharaConfig& cfg, Vertex** ip = 0);
void buildUpForJetClustering(TrackVec& tracks, vector<Vertex*>& vtx);

vector<Vertex*> makeSingleTrackVertices
Expand Down
1 change: 1 addition & 0 deletions src/LCIOStorer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ void LCIOStorer::WriteVertices(VertexVec* pvvtx, const char* newName, const char
for (unsigned int n=0; n<pvvtx->size(); n++) {
// set ID to the lcfiplus::Vertex
const lcfiplus::Vertex* flavtx = (*pvvtx)[n];
if( not flavtx ) continue;
flavtx->setId(n);

// It seems that multiple entries in LCIO collection are not allowed: currently make independent entries
Expand Down
9 changes: 5 additions & 4 deletions src/VertexFinderSuehara.cc
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ void VertexFinderSuehara::associateIPTracksAVF(vector<Vertex *> &vertices, Verte
if(loopiptracks.size()==0) loopiptracks.push_back(*it);
else{
vector<const Track *>::iterator it3=loopiptracks.begin();
while(ip->getChi2Track(*it)<ip->getChi2Track(*it3) && it3 != loopiptracks.end()){
while(it3 != loopiptracks.end() && ip->getChi2Track(*it)<ip->getChi2Track(*it3) ){
it3++;
}
if(it3 == loopiptracks.end()) loopiptracks.push_back(*it);
Expand Down Expand Up @@ -1036,15 +1036,16 @@ void VertexFinderSuehara::associateIPTracksAVF(vector<Vertex *> &vertices, Verte
return;
}

void VertexFinderSuehara::buildUp(TrackVec& tracks, vector<Vertex*>& vtx, vector<Vertex*>& v0vtx, double chi2thpri, VertexFinderSueharaConfig& cfg, Vertex* ip) {
void VertexFinderSuehara::buildUp(TrackVec& tracks, vector<Vertex*>& vtx, vector<Vertex*>& v0vtx, double chi2thpri, VertexFinderSueharaConfig& cfg, Vertex** pIP) {

// obtain primary vertex
Vertex* nip = 0;
std::unique_ptr<Vertex> nip;
Vertex*& ip = *pIP;
if (!ip) {
ip = findPrimaryVertex(tracks, chi2thpri);
// vtx.push_back(ip);
} else {
nip = new Vertex(ip->getChi2(), ip->getProb(), ip->getX(), ip->getY(), ip->getZ(), ip->getCov(), true);
nip = std::unique_ptr<Vertex>(new Vertex(ip->getChi2(), ip->getProb(), ip->getX(), ip->getY(), ip->getZ(), ip->getCov(), true));
// vtx.push_back(nip);
}

Expand Down
8 changes: 6 additions & 2 deletions src/lcfiplus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ const Vertex* Event::getPrimaryVertex(const char* privtxname) const {
const char* classname = "vector<lcfiplus::Vertex*>";

// if(!IsExist(privtxname,classname))throw(Exception("Event::getPrimaryVertex(): collection not found."));

return (*(vector<const lcfiplus::Vertex*>*)GetObject(privtxname,classname))[0];
auto const& primaryVertices = (*(vector<const lcfiplus::Vertex*>*)GetObject(privtxname,classname));
if(primaryVertices.size() > 0 ){
return primaryVertices[0];
} else {
return nullptr;
}
}

const vector<const Vertex*>& Event::getSecondaryVertices(const char* secvtxname) const {
Expand Down
24 changes: 20 additions & 4 deletions src/process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,18 @@ void BuildUpVertex::process() {
//cout << "BuildUpVertex / track selection: " << passedTracks.size() << "/" << tracks.size() << " accepted." << endl;

Vertex* primvtx;

bool haveToGetNewVertex = false;
try {
primvtx = new Vertex(*event->getPrimaryVertex(_primvtxcolname.c_str()));
const Vertex *primVertex = event->getPrimaryVertex(_primvtxcolname.c_str());
if (primVertex) {
primvtx = new Vertex(*primVertex);
} else {
throw lcfiplus::Exception("No primary Vertex");
}
} catch (lcfiplus::Exception& e) {
cout << "BuildUpVertex::process(): primary vertex not found - invoking primary vertex finder internally." << endl;
primvtx = 0;
haveToGetNewVertex = true;
primvtx = nullptr;
}

VertexFinderSuehara::VertexFinderSueharaConfig cfg;
Expand All @@ -182,7 +188,17 @@ void BuildUpVertex::process() {

// build up vertexing
vector<Vertex*> v0tmp;
VertexFinderSuehara::buildUp(passedTracks, *_vertices, (_v0vertices ? *_v0vertices : v0tmp), _chi2thpri, cfg, primvtx);
VertexFinderSuehara::buildUp(passedTracks, *_vertices, (_v0vertices ? *_v0vertices : v0tmp), _chi2thpri, cfg, &primvtx);
if(haveToGetNewVertex) {
const vector<const Vertex*>* _vertex=nullptr;
Event::Instance()->Get(_primvtxcolname.c_str(), _vertex);
vector<const Vertex*>* _tmpVertex = const_cast<vector<const Vertex*>*> (_vertex);
if(_vertex && _vertex->size() == 1 && const_cast<Vertex*>((*_vertex)[0]) == nullptr) {
(*_tmpVertex)[0] = primvtx ;
}

}

// TODO: deletion of v0tmp

if (_doassoc){
Expand Down

0 comments on commit 14f59b2

Please sign in to comment.