diff --git a/InnerDetector/InDetRecTools/InDetSecVxFinderTool/InDetSecVxFinderTool/InDetImprovedJetFitterVxFinder.h b/InnerDetector/InDetRecTools/InDetSecVxFinderTool/InDetSecVxFinderTool/InDetImprovedJetFitterVxFinder.h index 7294d31843cb8b9c3b3be1a31d78868ede3773d0..886bf1d2a2b32f4d1c8d3a5b04a2eb036f64babb 100755 --- a/InnerDetector/InDetRecTools/InDetSecVxFinderTool/InDetSecVxFinderTool/InDetImprovedJetFitterVxFinder.h +++ b/InnerDetector/InDetRecTools/InDetSecVxFinderTool/InDetSecVxFinderTool/InDetImprovedJetFitterVxFinder.h @@ -154,9 +154,6 @@ namespace InDet { double m_cutIPD0BothTracksCriteriumOneForKsAndLambda; double m_cutIPZ0BothTracksCriteriumOneForKsAndLambda; double m_cutTransverseTwoTrkVtxDistanceCriteriumTwoForKsAndLambda; - //double m_cutCompatibilityToPrimaryNeutralTrackFromConversion; - //double m_cutCompatibilityToPrimaryNeutralTrackFromKs; - //double m_cutCompatibilityToPrimaryNeutralTrackFromLambda; double m_cutCompatibilityChi2ToPrimaryNeutralTrackFromConversion; double m_cutCompatibilityChi2ToPrimaryNeutralTrackFromKs; double m_cutCompatibilityChi2ToPrimaryNeutralTrackFromLambda; diff --git a/InnerDetector/InDetRecTools/InDetSecVxFinderTool/InDetSecVxFinderTool/InDetJetFitterUtils.h b/InnerDetector/InDetRecTools/InDetSecVxFinderTool/InDetSecVxFinderTool/InDetJetFitterUtils.h index b126a9c81580ac7946fa71138d6b9c9c43098488..a85555615768d0a94c29016519d23626a2c78231 100644 --- a/InnerDetector/InDetRecTools/InDetSecVxFinderTool/InDetSecVxFinderTool/InDetJetFitterUtils.h +++ b/InnerDetector/InDetRecTools/InDetSecVxFinderTool/InDetSecVxFinderTool/InDetJetFitterUtils.h @@ -27,10 +27,7 @@ #include "CLHEP/Matrix/SymMatrix.h" #include "CLHEP/Matrix/Matrix.h" #include "CLHEP/Vector/LorentzVector.h" -//#include "TrkParticleBase/LinkToTrackParticleBase.h" -//#include "TrkParticleBase/TrackParticleBaseCollection.h" -//#include "TrkParticleBase/TrackParticleBase.h" -//#include "TrkNeutralParameters/NeutralParameters.h" + #include "TrkParameters/TrackParameters.h" #include "xAODTracking/Vertex.h" diff --git a/InnerDetector/InDetRecTools/InDetSecVxFinderTool/src/InDetImprovedJetFitterVxFinder.cxx b/InnerDetector/InDetRecTools/InDetSecVxFinderTool/src/InDetImprovedJetFitterVxFinder.cxx index 38e755de09c31dd12b5b7c1db21c74b2219c07f0..65acebc345c8374159cac13d3caba07efb16709d 100755 --- a/InnerDetector/InDetRecTools/InDetSecVxFinderTool/src/InDetImprovedJetFitterVxFinder.cxx +++ b/InnerDetector/InDetRecTools/InDetSecVxFinderTool/src/InDetImprovedJetFitterVxFinder.cxx @@ -361,81 +361,51 @@ namespace InDet } - const Trk::VxSecVertexInfo* InDetImprovedJetFitterVxFinder::findSecVertex(const xAOD::Vertex & primaryVertex, - const TLorentzVector & jetMomentum, - const std::vector<const xAOD::IParticle*> & inputTracks) const - { - + const Trk::VxSecVertexInfo* + InDetImprovedJetFitterVxFinder::findSecVertex(const xAOD::Vertex & primaryVertex, + const TLorentzVector & jetMomentum, + const std::vector<const xAOD::IParticle*> & inputTracks) const{ + std::vector<const Trk::ITrackLink*> selectedTracks; - std::vector<const xAOD::IParticle*>::const_iterator trk_iter; - //std::vector<const xAOD::IParticle*>::const_iterator trk_end=inputTracks.end(); - - double sumpT=0; - - for (trk_iter= inputTracks.begin(); trk_iter != inputTracks.end(); ++trk_iter) - { - + for (trk_iter= inputTracks.begin(); trk_iter != inputTracks.end(); ++trk_iter){ const xAOD::TrackParticle * tmp=dynamic_cast<const xAOD::TrackParticle *> ((*trk_iter)); - - if (!m_trkFilter->decision(*tmp,&primaryVertex)) - { + if (!tmp or !m_trkFilter->decision(*tmp,&primaryVertex)){ continue; } - - if (!m_usepTDepTrackSel) - { - + if (!m_usepTDepTrackSel){ ElementLink<xAOD::TrackParticleContainer> linkTP; linkTP.setElement(const_cast<xAOD::TrackParticle*>(tmp)); - Trk::LinkToXAODTrackParticle* link= new Trk::LinkToXAODTrackParticle(linkTP); selectedTracks.push_back(link); - - } - else - { + }else{ sumpT+=tmp->pt(); } } - - if (m_usepTDepTrackSel) - { - for (trk_iter= inputTracks.begin(); trk_iter != inputTracks.end(); ++trk_iter) - { - + if (m_usepTDepTrackSel){ + for (trk_iter= inputTracks.begin(); trk_iter != inputTracks.end(); ++trk_iter){ const xAOD::TrackParticle * tmp=dynamic_cast<const xAOD::TrackParticle *> ((*trk_iter)); - - if (!m_trkFilter->decision(*tmp,&primaryVertex)) - { + if (!tmp or !m_trkFilter->decision(*tmp,&primaryVertex)){ continue; } - if (!((tmp->pt()>m_pTMinOffset + sumpT * m_pTMinSlope) || - (sumpT > m_pTMax && tmp->pt()>m_pTMinOffset+m_pTMax* m_pTMinSlope))) - { + (sumpT > m_pTMax && tmp->pt()>m_pTMinOffset+m_pTMax* m_pTMinSlope))){ continue; } - ElementLink<xAOD::TrackParticleContainer> linkTP; linkTP.setElement(const_cast<xAOD::TrackParticle*>(tmp)); - Trk::LinkToXAODTrackParticle* link= new Trk::LinkToXAODTrackParticle(linkTP); selectedTracks.push_back(link); - } } - Trk::RecVertex dummy; - const Trk::VxSecVertexInfo* secVxInfo=doTheFinding(primaryVertex, jetMomentum, selectedTracks); return secVxInfo; - } @@ -2066,25 +2036,11 @@ namespace InDet } - //there shouldn't be much more... - // int numberFirstBeamInteractions=0; - // int numberSecondBeamInteractions=0; - // int numberFirstLayerInteractions=0; - // int numberSecondLayerInteractions=0; - - //for the moment do not store material interactions... - - //now create the output object - //MU std::vector<Trk::VxCandidate*> myCandidates; std::vector<Trk::VxJetCandidate*> myCandidates; // This push_back is problematic for the migration to xAOD::Vertex, it works simply because VxJetCandidate inherits from VxCandidate myCandidates.push_back(myJetCandidate); - /* SERIOUS PROBLEM */ - /* 17.05.2014 Problem here: can't store jetfitter vertex in xAOD:VxCandidate! */ -// const Trk::VxJetFitterVertexInfo* myOutputInfo=new Trk::VxJetFitterVertexInfo(myCandidates, -// myTwoTrackVerticesInJet, -// mySelectedTracksInJet); + Trk::VxJetFitterVertexInfo* myOutputInfo=new Trk::VxJetFitterVertexInfo(myCandidates, myTwoTrackVerticesInJet, @@ -2100,262 +2056,193 @@ namespace InDet } - Trk::VxJetCandidate* InDetImprovedJetFitterVxFinder::findSecVertex(const Trk::RecVertex & primaryVertex, - const TLorentzVector & jetMomentum, - const std::vector<const Trk::ITrackLink*> & firstInputTracks, - const std::vector<const Trk::ITrackLink*> & secondInputTracks, - const Amg::Vector3D & vtxSeedDirection) const - { - - - if (msgLvl(MSG::VERBOSE)) msg() << " entered findSecVertex(). Applying JetFitter finding to the found sets of tracks and performing clustering (pattern recognition) " << endmsg; - + Trk::VxJetCandidate* + InDetImprovedJetFitterVxFinder::findSecVertex(const Trk::RecVertex & primaryVertex, + const TLorentzVector & jetMomentum, + const std::vector<const Trk::ITrackLink*> & firstInputTracks, + const std::vector<const Trk::ITrackLink*> & secondInputTracks, + const Amg::Vector3D & vtxSeedDirection) const { + ATH_MSG_VERBOSE( " entered findSecVertex(). Applying JetFitter finding to the found sets of tracks and performing clustering (pattern recognition) " ); Amg::Vector3D myDirection(jetMomentum.X(),jetMomentum.Y(),jetMomentum.Z()); - std::vector<std::vector<const Trk::ITrackLink*> > bunchesOfTracks; - std::vector<const Trk::ITrackLink*> tracksToAdd; - std::vector<const Trk::ITrackLink*>::const_iterator tracks2Begin=firstInputTracks.begin(); std::vector<const Trk::ITrackLink*>::const_iterator tracks2End=firstInputTracks.end(); for (std::vector<const Trk::ITrackLink*>::const_iterator tracks2Iter=tracks2Begin; - tracks2Iter!=tracks2End;++tracks2Iter) { - if (msgLvl(MSG::VERBOSE)) msg() <<" adding track to fit " << endmsg; + tracks2Iter!=tracks2End;++tracks2Iter) { + ATH_MSG_VERBOSE(" adding track to fit " ); tracksToAdd.push_back(*tracks2Iter); } - bunchesOfTracks.push_back(tracksToAdd); tracksToAdd.clear(); - std::vector<const Trk::ITrackLink*>::const_iterator tracks3Begin=secondInputTracks.begin(); std::vector<const Trk::ITrackLink*>::const_iterator tracks3End=secondInputTracks.end(); for (std::vector<const Trk::ITrackLink*>::const_iterator tracks3Iter=tracks3Begin; - tracks3Iter!=tracks3End;++tracks3Iter) { - if (msgLvl(MSG::VERBOSE)) msg() <<" adding track to fit " << endmsg; + tracks3Iter!=tracks3End;++tracks3Iter) { + ATH_MSG_VERBOSE(" adding track to fit "); tracksToAdd.push_back(*tracks3Iter); } - - if (tracksToAdd.size()!=0) - { + if (not tracksToAdd.empty()) { bunchesOfTracks.push_back(tracksToAdd); } tracksToAdd.clear(); - - //now it just uses these bunches... //now I have just to make sure that no clustering is done at first iteration //while it needs to be done at second iteration (there will be only two iterations) - - std::vector<std::vector<const Trk::ITrackLink*> >::const_iterator BunchesBegin=bunchesOfTracks.begin(); std::vector<std::vector<const Trk::ITrackLink*> >::const_iterator BunchesEnd=bunchesOfTracks.end(); - std::vector<const Trk::ITrackLink*>::const_iterator tracksToAddBegin; std::vector<const Trk::ITrackLink*>::const_iterator tracksToAddEnd; std::vector<const Trk::ITrackLink*>::const_iterator tracksToAddIter; - - - Trk::VxJetCandidate* myJetCandidate=0; - + Trk::VxJetCandidate* myJetCandidate=nullptr; for (std::vector<std::vector<const Trk::ITrackLink*> >::const_iterator BunchesIter=BunchesBegin; - BunchesIter!=BunchesEnd;++BunchesIter) { - + BunchesIter!=BunchesEnd;++BunchesIter) { if (BunchesIter==BunchesBegin) { - if (msgLvl(MSG::VERBOSE)) msg() <<" initial fit with " << (*BunchesIter).size() << " tracks " << endmsg; - myJetCandidate=m_initializationHelper->initializeJetCandidate(*BunchesIter,&primaryVertex,&myDirection,&vtxSeedDirection); - m_routines->initializeToMinDistancesToJetAxis(myJetCandidate); - if ((*BunchesIter).size()>0) - { + ATH_MSG_VERBOSE(" initial fit with " << (*BunchesIter).size() << " tracks " ); + myJetCandidate=m_initializationHelper->initializeJetCandidate(*BunchesIter,&primaryVertex,&myDirection,&vtxSeedDirection); + if (not myJetCandidate) continue; + m_routines->initializeToMinDistancesToJetAxis(myJetCandidate); + if (not BunchesIter->empty()){ doTheFit(myJetCandidate,true); } } else { - if (msgLvl(MSG::VERBOSE)) msg() <<" other fit with " << (*BunchesIter).size() << " tracks " << endmsg; - std::vector<Trk::VxVertexOnJetAxis*> setOfVertices=myJetCandidate->getVerticesOnJetAxis(); - std::vector<Trk::VxTrackAtVertex*>* setOfTracks=myJetCandidate->vxTrackAtVertex(); - tracksToAddBegin=(*BunchesIter).begin(); - tracksToAddEnd=(*BunchesIter).end(); - for (tracksToAddIter=tracksToAddBegin;tracksToAddIter!=tracksToAddEnd;++tracksToAddIter) { - std::vector<Trk::VxTrackAtVertex*> temp_vector_tracksAtVertex; - Trk::VxTrackAtVertex* newVxTrack=new Trk::VxTrackAtVertex((*tracksToAddIter)->clone()); - temp_vector_tracksAtVertex.push_back(newVxTrack); - setOfTracks->push_back(newVxTrack); - setOfVertices.push_back(new Trk::VxVertexOnJetAxis(temp_vector_tracksAtVertex)); - } - if (msgLvl(MSG::VERBOSE)) msg() <<" new overall number of tracks to fit : " << setOfVertices.size() << endmsg; - myJetCandidate->setVerticesOnJetAxis(setOfVertices); - m_initializationHelper->updateTrackNumbering(myJetCandidate); + if (not myJetCandidate) continue; + ATH_MSG_VERBOSE(" other fit with " << (*BunchesIter).size() << " tracks " ); + std::vector<Trk::VxVertexOnJetAxis*> setOfVertices=myJetCandidate->getVerticesOnJetAxis(); + std::vector<Trk::VxTrackAtVertex*>* setOfTracks=myJetCandidate->vxTrackAtVertex(); + tracksToAddBegin=(*BunchesIter).begin(); + tracksToAddEnd=(*BunchesIter).end(); + for (tracksToAddIter=tracksToAddBegin;tracksToAddIter!=tracksToAddEnd;++tracksToAddIter) { + std::vector<Trk::VxTrackAtVertex*> temp_vector_tracksAtVertex; + Trk::VxTrackAtVertex* newVxTrack=new Trk::VxTrackAtVertex((*tracksToAddIter)->clone()); + temp_vector_tracksAtVertex.push_back(newVxTrack); + setOfTracks->push_back(newVxTrack); + setOfVertices.push_back(new Trk::VxVertexOnJetAxis(temp_vector_tracksAtVertex)); + } + ATH_MSG_VERBOSE(" new overall number of tracks to fit : " << setOfVertices.size() ); + myJetCandidate->setVerticesOnJetAxis(setOfVertices); + m_initializationHelper->updateTrackNumbering(myJetCandidate); //question: should this be done??? - m_routines->initializeToMinDistancesToJetAxis(myJetCandidate); - doTheFit(myJetCandidate); + m_routines->initializeToMinDistancesToJetAxis(myJetCandidate); + doTheFit(myJetCandidate); } } - - - // std::vector<Trk::VxCandidate*> myCandidates; - // myCandidates.push_back(myJetCandidate); - //return new Trk::VxSecVertexInfo(myCandidates);//ownership of the single objects is taken over! - return myJetCandidate; - } - void InDetImprovedJetFitterVxFinder::doTheFit(Trk::VxJetCandidate* myJetCandidate, - bool performClustering) const { - - + void + InDetImprovedJetFitterVxFinder::doTheFit(Trk::VxJetCandidate* myJetCandidate, + bool performClustering) const { int numClusteringLoops=0; bool noMoreVerticesToCluster(false); - do {//reguards clustering - - if (msgLvl(MSG::VERBOSE)) msg() <<"InDetImprovedJetFitterVxFinder: ------>>>> new cycle of fit" << endmsg; - + ATH_MSG_VERBOSE("InDetImprovedJetFitterVxFinder: ------>>>> new cycle of fit" ); int numLoops=0; bool noMoreTracksToDelete(false); do {//reguards eliminating incompatible tracks... - - m_routines->performTheFit(myJetCandidate,15,false,30,0.001); - - const std::vector<Trk::VxVertexOnJetAxis*> & vertices=myJetCandidate->getVerticesOnJetAxis(); - - std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesBegin=vertices.begin(); - std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesEnd=vertices.end(); - - - //delete incompatible tracks... - float max_prob(1.); - Trk::VxVertexOnJetAxis* worseVertex(0); - for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesIter=verticesBegin; - verticesIter!=verticesEnd;++verticesIter) { - if (*verticesIter==0) { - msg(MSG::WARNING) << "One vertex is empy. Problem when trying to delete incompatible vertices. No further vertices deleted." << endmsg; - } else { - const Trk::FitQuality & fitQuality=(*verticesIter)->fitQuality(); - if (TMath::Prob(fitQuality.chiSquared(),(int)std::floor(fitQuality.numberDoF()+0.5))<max_prob) { - max_prob=TMath::Prob(fitQuality.chiSquared(),(int)std::floor(fitQuality.numberDoF()+0.5)); - worseVertex=*verticesIter; - } - } - } - if (max_prob<m_vertexProbCut) { - if (msgLvl(MSG::DEBUG)) msg() << "Deleted vertex " << worseVertex->getNumVertex() << " with probability " << max_prob << endmsg; - // std::cout << "Deleted vertex " << worseVertex->getNumVertex() << " with probability " << max_prob << std::endl; - if (worseVertex==myJetCandidate->getPrimaryVertex()) { - if (msgLvl(MSG::VERBOSE)) msg() << " It's the primary" << endmsg; - } - - m_routines->deleteVertexFromJetCandidate(worseVertex,myJetCandidate); - - } else { - noMoreTracksToDelete=true; - if (msgLvl(MSG::VERBOSE)) msg() <<"No tracks to delete: maximum probability is " << max_prob << endmsg; - } - - numLoops+=1; + m_routines->performTheFit(myJetCandidate,15,false,30,0.001); + const std::vector<Trk::VxVertexOnJetAxis*> & vertices=myJetCandidate->getVerticesOnJetAxis(); + std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesBegin=vertices.begin(); + std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesEnd=vertices.end(); + //delete incompatible tracks... + float max_prob(1.); + Trk::VxVertexOnJetAxis* worseVertex(nullptr); + for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesIter=verticesBegin; + verticesIter!=verticesEnd;++verticesIter) { + if (*verticesIter==0) { + ATH_MSG_WARNING( "One vertex is empy. Problem when trying to delete incompatible vertices. No further vertices deleted."); + } else { + const Trk::FitQuality & fitQuality=(*verticesIter)->fitQuality(); + if (TMath::Prob(fitQuality.chiSquared(),(int)std::floor(fitQuality.numberDoF()+0.5))<max_prob) { + max_prob=TMath::Prob(fitQuality.chiSquared(),(int)std::floor(fitQuality.numberDoF()+0.5)); + worseVertex=*verticesIter; + } + } + } + if (worseVertex and (max_prob<m_vertexProbCut)) { + ATH_MSG_DEBUG( "Deleted vertex " << worseVertex->getNumVertex() << " with probability " << max_prob ); + if (worseVertex==myJetCandidate->getPrimaryVertex()) { + ATH_MSG_VERBOSE( " It's the primary" ); + } + m_routines->deleteVertexFromJetCandidate(worseVertex,myJetCandidate); + } else { + noMoreTracksToDelete=true; + ATH_MSG_VERBOSE("No tracks to delete: maximum probability is " << max_prob ); + } + numLoops+=1; } while (numLoops<m_maxNumDeleteIterations&&!(noMoreTracksToDelete)); - if (!performClustering) break; - if (!m_useFastClustering && (int)myJetCandidate->getVerticesOnJetAxis().size()<m_maxTracksForDetailedClustering) { - m_routines->fillTableWithFullProbOfMerging(myJetCandidate,8,false,10,0.01); + m_routines->fillTableWithFullProbOfMerging(myJetCandidate,8,false,10,0.01); } else { - m_routines->fillTableWithFastProbOfMerging(myJetCandidate); + m_routines->fillTableWithFastProbOfMerging(myJetCandidate); } const Trk::VxClusteringTable* clusteringTablePtr(myJetCandidate->getClusteringTable()); - - - - - if (clusteringTablePtr==0) { - msg(MSG::WARNING) << " No Clustering Table while it should have been calculated... no more clustering performed during vertexing " << endmsg; - noMoreVerticesToCluster=true; + if (not clusteringTablePtr) { + ATH_MSG_WARNING( " No Clustering Table while it should have been calculated... no more clustering performed during vertexing " ); + noMoreVerticesToCluster=true; } else { - - if (msgLvl(MSG::VERBOSE)) msg() <<" clustering table is " << *clusteringTablePtr << endmsg; - - //now iterate over the full map and decide wether you want to do the clustering OR not... - float probVertex(0.); - Trk::PairOfVxVertexOnJetAxis pairOfVxVertexOnJetAxis=clusteringTablePtr->getMostCompatibleVertices(probVertex); - //a PairOfVxVertexOnJetAxis is a std::pair<VxVertexOnJetAxis*,VxVertexOnJetAxis*> - - float probVertexExcludingPrimary(0.); - Trk::PairOfVxVertexOnJetAxis pairOfVxVertexOnJetAxisExcludingPrimary=clusteringTablePtr->getMostCompatibleVerticesExcludingPrimary(probVertexExcludingPrimary); - - bool firstProbIsWithPrimary= ( fabs(probVertex-probVertexExcludingPrimary)>1e-6 ); - - if (probVertex>0.&&probVertex>m_vertexClusteringProbabilityCut&&firstProbIsWithPrimary) { - if (msgLvl(MSG::VERBOSE)) msg() <<" merging vtx number " << (*pairOfVxVertexOnJetAxis.first).getNumVertex() << - " and " << (*pairOfVxVertexOnJetAxis.second).getNumVertex() << " (should be PV)." << endmsg; - // const Trk::VxVertexOnJetAxis & mergedVertex= - m_helper->mergeVerticesInJetCandidate(*pairOfVxVertexOnJetAxis.first, - *pairOfVxVertexOnJetAxis.second, - *myJetCandidate); - //now you need to update the numbering scheme - m_initializationHelper->updateTrackNumbering(myJetCandidate);//maybe this should be moved to a lower level... - continue; - } - - if (probVertexExcludingPrimary>0.) - { - - //GP suggested by Marco Battaglia, use vertex mass in order to decide wether to split or not, so derive vertex masses first - const Trk::VxVertexOnJetAxis* firstVertex=pairOfVxVertexOnJetAxisExcludingPrimary.first; - const Trk::VxVertexOnJetAxis* secondVertex=pairOfVxVertexOnJetAxisExcludingPrimary.second; - - CLHEP::HepLorentzVector massVector1=m_jetFitterUtils->fourMomentumAtVertex(*firstVertex);//MeV - CLHEP::HepLorentzVector massVector2=m_jetFitterUtils->fourMomentumAtVertex(*secondVertex);//MeV - - CLHEP::HepLorentzVector sumMassVector=massVector1+massVector2; - - double massTwoVertex=sumMassVector.mag();//MeV - - bool doMerge(false); - - double vertexClusteringProbabilityCutWithMass; - - if(massTwoVertex< 1000.){ - vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass0010; - }else if(massTwoVertex< 1500.){ - vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass1015; - }else if(massTwoVertex< 2000.){ - vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass1520; - }else if(massTwoVertex< 2500.){ - vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass2025; - }else if(massTwoVertex< 3000.){ - vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass2530; - }else if(massTwoVertex< 4000.){ - vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass3040; - }else if(massTwoVertex< 5000.){ - vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass4050; - }else if(massTwoVertex< 6000.){ - vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass5060; - }else{ - vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass6070; - } - - if (probVertexExcludingPrimary>vertexClusteringProbabilityCutWithMass) - { + ATH_MSG_VERBOSE(" clustering table is " << *clusteringTablePtr ); + //now iterate over the full map and decide wether you want to do the clustering OR not... + float probVertex(0.); + Trk::PairOfVxVertexOnJetAxis pairOfVxVertexOnJetAxis=clusteringTablePtr->getMostCompatibleVertices(probVertex); + //a PairOfVxVertexOnJetAxis is a std::pair<VxVertexOnJetAxis*,VxVertexOnJetAxis*> + float probVertexExcludingPrimary(0.); + Trk::PairOfVxVertexOnJetAxis pairOfVxVertexOnJetAxisExcludingPrimary=clusteringTablePtr->getMostCompatibleVerticesExcludingPrimary(probVertexExcludingPrimary); + bool firstProbIsWithPrimary= ( std::fabs(probVertex-probVertexExcludingPrimary)>1e-6 ); + if (probVertex>0.&&probVertex>m_vertexClusteringProbabilityCut&&firstProbIsWithPrimary) { + ATH_MSG_VERBOSE(" merging vtx number " << (*pairOfVxVertexOnJetAxis.first).getNumVertex() << + " and " << (*pairOfVxVertexOnJetAxis.second).getNumVertex() << " (should be PV)." ); + m_helper->mergeVerticesInJetCandidate(*pairOfVxVertexOnJetAxis.first, + *pairOfVxVertexOnJetAxis.second, + *myJetCandidate); + //now you need to update the numbering scheme + m_initializationHelper->updateTrackNumbering(myJetCandidate);//maybe this should be moved to a lower level... + continue; + } + if (probVertexExcludingPrimary>0.){ + //GP suggested by Marco Battaglia, use vertex mass in order to decide wether to split or not, so derive vertex masses first + const Trk::VxVertexOnJetAxis* firstVertex=pairOfVxVertexOnJetAxisExcludingPrimary.first; + const Trk::VxVertexOnJetAxis* secondVertex=pairOfVxVertexOnJetAxisExcludingPrimary.second; + CLHEP::HepLorentzVector massVector1=m_jetFitterUtils->fourMomentumAtVertex(*firstVertex);//MeV + CLHEP::HepLorentzVector massVector2=m_jetFitterUtils->fourMomentumAtVertex(*secondVertex);//MeV + CLHEP::HepLorentzVector sumMassVector=massVector1+massVector2; + double massTwoVertex=sumMassVector.mag();//MeV + bool doMerge(false); + double vertexClusteringProbabilityCutWithMass; + if(massTwoVertex< 1000.){ + vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass0010; + }else if(massTwoVertex< 1500.){ + vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass1015; + }else if(massTwoVertex< 2000.){ + vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass1520; + }else if(massTwoVertex< 2500.){ + vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass2025; + }else if(massTwoVertex< 3000.){ + vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass2530; + }else if(massTwoVertex< 4000.){ + vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass3040; + }else if(massTwoVertex< 5000.){ + vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass4050; + }else if(massTwoVertex< 6000.){ + vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass5060; + }else{ + vertexClusteringProbabilityCutWithMass = m_vertexClusteringProbabilityCutWithMass6070; + } + if (probVertexExcludingPrimary>vertexClusteringProbabilityCutWithMass) { doMerge=true; } - - if (doMerge) - { - - if (msgLvl(MSG::VERBOSE)) msg() <<" merging vtx number " << (*pairOfVxVertexOnJetAxis.first).getNumVertex() << - " and " << (*pairOfVxVertexOnJetAxis.second).getNumVertex() << " mass merged vertex: " << massTwoVertex << endmsg; - - m_helper->mergeVerticesInJetCandidate(*pairOfVxVertexOnJetAxisExcludingPrimary.first, - *pairOfVxVertexOnJetAxisExcludingPrimary.second, - *myJetCandidate); - - m_initializationHelper->updateTrackNumbering(myJetCandidate);//maybe this should be moved to a lower level... - continue;//go to next cycle, after a succesful merging - } - } - - noMoreVerticesToCluster=true; - - + if (doMerge){ + ATH_MSG_VERBOSE(" merging vtx number " << (*pairOfVxVertexOnJetAxis.first).getNumVertex() << + " and " << (*pairOfVxVertexOnJetAxis.second).getNumVertex() << " mass merged vertex: " << massTwoVertex ); + m_helper->mergeVerticesInJetCandidate(*pairOfVxVertexOnJetAxisExcludingPrimary.first, + *pairOfVxVertexOnJetAxisExcludingPrimary.second, + *myJetCandidate); + m_initializationHelper->updateTrackNumbering(myJetCandidate);//maybe this should be moved to a lower level... + continue;//go to next cycle, after a succesful merging + } + } + noMoreVerticesToCluster=true; } numClusteringLoops+=1; } while (numClusteringLoops<m_maxClusteringIterations&&!(noMoreVerticesToCluster)); @@ -2363,10 +2250,5 @@ namespace InDet //now a section should follow where the "complicate" VxJetCandidate is transformed in a conventional "VxCandidate" //so that it can be used also by the normal B-Tagging algorithms... //TO BE COMPLETED - - //return myJetCandidate; - } - - }//end namespace Rec diff --git a/InnerDetector/InDetRecTools/InDetSecVxFinderTool/src/InDetJetFitterVxFinder.cxx b/InnerDetector/InDetRecTools/InDetSecVxFinderTool/src/InDetJetFitterVxFinder.cxx index cb02189173943a41b4b9d373d78f4e99d49fe447..3b2535d3515d0b6953e2bb492b99f0720ed2d587 100755 --- a/InnerDetector/InDetRecTools/InDetSecVxFinderTool/src/InDetJetFitterVxFinder.cxx +++ b/InnerDetector/InDetRecTools/InDetSecVxFinderTool/src/InDetJetFitterVxFinder.cxx @@ -93,140 +93,96 @@ namespace InDet StatusCode InDetJetFitterVxFinder::initialize() { - - - StatusCode sc = AthAlgTool::initialize(); - if(sc.isFailure()) - { - msg(MSG::ERROR) << " Unable to initialize the AlgTool" << endmsg; - return sc; - } - //retrieving the udator itself - sc = m_helper.retrieve(); - if(sc.isFailure()) { - msg(MSG::ERROR) << " Unable to retrieve "<<m_helper<<endmsg; - return StatusCode::FAILURE; - }else msg(MSG::INFO) << "JetFitter Helper retrieved"<<endmsg; - - - sc = m_initializationHelper.retrieve(); - if(sc.isFailure()) { - msg(MSG::ERROR) << " Unable to retrieve "<<m_initializationHelper<<endmsg; - return StatusCode::FAILURE; - }else msg(MSG::INFO) << "JetFitter Initialization Helper retrieved"<<endmsg; - - sc = m_routines.retrieve(); - if(sc.isFailure()) { - msg(MSG::ERROR) << " Unable to retrieve the JetFitter routines"<<m_routines<<endmsg; - return StatusCode::FAILURE; - }else msg(MSG::INFO) << "JetFitter Routines class retrieved"<<endmsg; - - if(m_trkFilter.retrieve().isFailure()) { - msg(MSG::ERROR) << " Unable to retrieve "<<m_trkFilter<<endmsg; - return StatusCode::FAILURE; - } else msg(MSG::INFO) << "Track filter retrieved"<<endmsg; - - msg(MSG::INFO) << "Initialize successful" << endmsg; + ATH_CHECK(m_helper.retrieve()); + ATH_CHECK(m_initializationHelper.retrieve()); + ATH_CHECK(m_routines.retrieve()); + ATH_CHECK(m_trkFilter.retrieve()); return StatusCode::SUCCESS; } StatusCode InDetJetFitterVxFinder::finalize() { - - msg(MSG::INFO) << "Finalize successful" << endmsg; - return StatusCode::SUCCESS; - + ATH_MSG_DEBUG("Finalize ok"); + return StatusCode::SUCCESS; } - const Trk::VxSecVertexInfo* InDetJetFitterVxFinder::findSecVertex(const Trk::RecVertex & primaryVertex, - const TLorentzVector & jetMomentum, - const std::vector<const Trk::TrackParticleBase*> & myTracks) const { + const Trk::VxSecVertexInfo* + InDetJetFitterVxFinder::findSecVertex(const Trk::RecVertex & primaryVertex, + const TLorentzVector & jetMomentum, + const std::vector<const Trk::TrackParticleBase*> & myTracks) const { + Amg::Vector3D myDirection(jetMomentum.Vect().X(),jetMomentum.Vect().Y(),jetMomentum.Vect().Z()); - std::vector<TrackParticle_pair> tracks; - std::vector<const Trk::TrackParticleBase*>::const_iterator tracksBegin=myTracks.begin(); std::vector<const Trk::TrackParticleBase*>::const_iterator tracksEnd=myTracks.end(); for (std::vector<const Trk::TrackParticleBase*>::const_iterator tracksIter=tracksBegin; - tracksIter!=tracksEnd;++tracksIter) { + tracksIter!=tracksEnd;++tracksIter) { if (m_trkFilter->decision(**tracksIter,&primaryVertex)==true) { - tracks.push_back(TrackParticle_pair((*tracksIter)->perigee()->momentum().perp(),*tracksIter)); + tracks.push_back(TrackParticle_pair((*tracksIter)->perigee()->momentum().perp(),*tracksIter)); } } - std::vector<std::vector<const Trk::TrackParticleBase*> > bunchesOfTracks; - std::sort(tracks.begin(),tracks.end()); - std::vector<const Trk::TrackParticleBase*> tracksToAdd; - std::vector<TrackParticle_pair>::const_iterator tracks2Begin=tracks.begin(); std::vector<TrackParticle_pair>::const_iterator tracks2End=tracks.end(); for (std::vector<TrackParticle_pair>::const_iterator tracks2Iter=tracks2Begin; - tracks2Iter!=tracks2End;++tracks2Iter) { - if (msgLvl(MSG::VERBOSE)) msg() << " track: " << (*tracks2Iter).first << " and : " << (*tracks2Iter).second << endmsg; - + tracks2Iter!=tracks2End;++tracks2Iter) { + ATH_MSG_VERBOSE( " track: " << (*tracks2Iter).first << " and : " << (*tracks2Iter).second ); tracksToAdd.push_back((*tracks2Iter).second); if (tracksToAdd.size() % m_maxTracksToFitAtOnce == 0) { - if (msgLvl(MSG::VERBOSE)) msg() << " new bunch " << endmsg; - bunchesOfTracks.push_back(tracksToAdd); - tracksToAdd.clear(); + ATH_MSG_VERBOSE( " new bunch " ); + bunchesOfTracks.push_back(tracksToAdd); + tracksToAdd.clear(); } } - bunchesOfTracks.push_back(tracksToAdd); - std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesBegin=bunchesOfTracks.begin(); std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesEnd=bunchesOfTracks.end(); - std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddBegin; std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddEnd; std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddIter; - - - Trk::VxJetCandidate* myJetCandidate=0; - + Trk::VxJetCandidate* myJetCandidate=nullptr; for (std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesIter=BunchesBegin; - BunchesIter!=BunchesEnd;++BunchesIter) { - + BunchesIter!=BunchesEnd;++BunchesIter) { if (BunchesIter==BunchesBegin) { - if (msgLvl(MSG::VERBOSE)) msg() << " initial fit with " << (*BunchesIter).size() << " tracks " << endmsg; - myJetCandidate=m_initializationHelper->initializeJetCandidate(*BunchesIter,&primaryVertex,&myDirection); - m_routines->initializeToMinDistancesToJetAxis(myJetCandidate); - doTheFit(myJetCandidate); + if (not myJetCandidate) continue; + ATH_MSG_VERBOSE( " initial fit with " << (*BunchesIter).size() << " tracks " ); + myJetCandidate=m_initializationHelper->initializeJetCandidate(*BunchesIter,&primaryVertex,&myDirection); + m_routines->initializeToMinDistancesToJetAxis(myJetCandidate); + doTheFit(myJetCandidate); } else { - if (msgLvl(MSG::VERBOSE)) msg() << " other fit with " << (*BunchesIter).size() << " tracks " << endmsg; - std::vector<Trk::VxVertexOnJetAxis*> setOfVertices=myJetCandidate->getVerticesOnJetAxis(); - std::vector<Trk::VxTrackAtVertex*>* setOfTracks=myJetCandidate->vxTrackAtVertex(); - tracksToAddBegin=(*BunchesIter).begin(); - tracksToAddEnd=(*BunchesIter).end(); - for (tracksToAddIter=tracksToAddBegin;tracksToAddIter!=tracksToAddEnd;++tracksToAddIter) { - std::vector<Trk::VxTrackAtVertex*> temp_vector_tracksAtVertex; - ElementLink<Trk::TrackParticleBaseCollection> link; - link.setElement(const_cast<Trk::TrackParticleBase*>(*tracksToAddIter)); - Trk::LinkToTrackParticleBase * linkTT = new Trk::LinkToTrackParticleBase(link); - Trk::VxTrackAtVertex* newVxTrack=new Trk::VxTrackAtVertex(linkTT); - temp_vector_tracksAtVertex.push_back(newVxTrack); - setOfTracks->push_back(newVxTrack); - setOfVertices.push_back(new Trk::VxVertexOnJetAxis(temp_vector_tracksAtVertex)); - } - if (msgLvl(MSG::VERBOSE)) msg() << " new overall number of tracks to fit : " << setOfVertices.size() << endmsg; - myJetCandidate->setVerticesOnJetAxis(setOfVertices); - m_initializationHelper->updateTrackNumbering(myJetCandidate); - doTheFit(myJetCandidate); + if (not myJetCandidate) continue; + ATH_MSG_VERBOSE(" other fit with " << (*BunchesIter).size() << " tracks " ); + std::vector<Trk::VxVertexOnJetAxis*> setOfVertices=myJetCandidate->getVerticesOnJetAxis(); + std::vector<Trk::VxTrackAtVertex*>* setOfTracks=myJetCandidate->vxTrackAtVertex(); + tracksToAddBegin=(*BunchesIter).begin(); + tracksToAddEnd=(*BunchesIter).end(); + for (tracksToAddIter=tracksToAddBegin;tracksToAddIter!=tracksToAddEnd;++tracksToAddIter) { + std::vector<Trk::VxTrackAtVertex*> temp_vector_tracksAtVertex; + ElementLink<Trk::TrackParticleBaseCollection> link; + link.setElement(const_cast<Trk::TrackParticleBase*>(*tracksToAddIter)); + Trk::LinkToTrackParticleBase * linkTT = new Trk::LinkToTrackParticleBase(link); + Trk::VxTrackAtVertex* newVxTrack=new Trk::VxTrackAtVertex(linkTT); + temp_vector_tracksAtVertex.push_back(newVxTrack); + setOfTracks->push_back(newVxTrack); + setOfVertices.push_back(new Trk::VxVertexOnJetAxis(temp_vector_tracksAtVertex)); + } + ATH_MSG_VERBOSE( " new overall number of tracks to fit : " << setOfVertices.size() ); + myJetCandidate->setVerticesOnJetAxis(setOfVertices); + m_initializationHelper->updateTrackNumbering(myJetCandidate); + doTheFit(myJetCandidate); } } - std::vector<Trk::VxCandidate*> myCandidates; myCandidates.push_back(myJetCandidate); - -// return new Trk::VxSecVertexInfo(myCandidates);//ownership of the single objects is taken over! return 0; } - const Trk::VxSecVertexInfo* InDetJetFitterVxFinder::findSecVertex(const Trk::RecVertex & primaryVertex, + const Trk::VxSecVertexInfo* + InDetJetFitterVxFinder::findSecVertex(const Trk::RecVertex & primaryVertex, const TLorentzVector & jetMomentum, const std::vector<const Trk::TrackParticleBase*> & firstInputTracks, const std::vector<const Trk::TrackParticleBase*> & secondInputTracks, @@ -234,191 +190,149 @@ namespace InDet { Amg::Vector3D myDirection(jetMomentum.Vect().X(),jetMomentum.Vect().Y(),jetMomentum.Vect().Z()); - std::vector<std::vector<const Trk::TrackParticleBase*> > bunchesOfTracks; - std::vector<const Trk::TrackParticleBase*> tracksToAdd; - std::vector<const Trk::TrackParticleBase*>::const_iterator tracks2Begin=firstInputTracks.begin(); std::vector<const Trk::TrackParticleBase*>::const_iterator tracks2End=firstInputTracks.end(); for (std::vector<const Trk::TrackParticleBase*>::const_iterator tracks2Iter=tracks2Begin; - tracks2Iter!=tracks2End;++tracks2Iter) { - if (msgLvl(MSG::VERBOSE)) msg() << " adding track to fit " << endmsg; + tracks2Iter!=tracks2End;++tracks2Iter) { + ATH_MSG_VERBOSE( " adding track to fit " ); tracksToAdd.push_back(*tracks2Iter); } - bunchesOfTracks.push_back(tracksToAdd); tracksToAdd.clear(); - std::vector<const Trk::TrackParticleBase*>::const_iterator tracks3Begin=secondInputTracks.begin(); std::vector<const Trk::TrackParticleBase*>::const_iterator tracks3End=secondInputTracks.end(); for (std::vector<const Trk::TrackParticleBase*>::const_iterator tracks3Iter=tracks3Begin; - tracks3Iter!=tracks3End;++tracks3Iter) { - if (msgLvl(MSG::VERBOSE)) msg() << " adding track to fit " << endmsg; + tracks3Iter!=tracks3End;++tracks3Iter) { + ATH_MSG_VERBOSE( " adding track to fit " ); tracksToAdd.push_back(*tracks3Iter); } - - if (tracksToAdd.size()!=0) - { + if (not tracksToAdd.empty()) { bunchesOfTracks.push_back(tracksToAdd); } tracksToAdd.clear(); - - //now it just uses these bunches... //now I have just to make sure that no clustering is done at first iteration //while it needs to be done at second iteration (there will be only two iterations) - - std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesBegin=bunchesOfTracks.begin(); std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesEnd=bunchesOfTracks.end(); - std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddBegin; std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddEnd; std::vector<const Trk::TrackParticleBase*>::const_iterator tracksToAddIter; - - Trk::VxJetCandidate* myJetCandidate=0; - for (std::vector<std::vector<const Trk::TrackParticleBase*> >::const_iterator BunchesIter=BunchesBegin; - BunchesIter!=BunchesEnd;++BunchesIter) { - + BunchesIter!=BunchesEnd;++BunchesIter) { if (BunchesIter==BunchesBegin) { - if (msgLvl(MSG::VERBOSE)) msg() << " initial fit with " << (*BunchesIter).size() << " tracks " << endmsg; - myJetCandidate=m_initializationHelper->initializeJetCandidate(*BunchesIter,&primaryVertex,&myDirection,&vtxSeedDirection); - m_routines->initializeToMinDistancesToJetAxis(myJetCandidate); - if ((*BunchesIter).size()>0) - { + ATH_MSG_VERBOSE( " initial fit with " << (*BunchesIter).size() << " tracks " ); + myJetCandidate=m_initializationHelper->initializeJetCandidate(*BunchesIter,&primaryVertex,&myDirection,&vtxSeedDirection); + if (not myJetCandidate) continue; + m_routines->initializeToMinDistancesToJetAxis(myJetCandidate); + if (not BunchesIter->empty()) { doTheFit(myJetCandidate,true); } } else { - if (msgLvl(MSG::VERBOSE)) msg() << " other fit with " << (*BunchesIter).size() << " tracks " << endmsg; - std::vector<Trk::VxVertexOnJetAxis*> setOfVertices=myJetCandidate->getVerticesOnJetAxis(); - std::vector<Trk::VxTrackAtVertex*>* setOfTracks=myJetCandidate->vxTrackAtVertex(); - tracksToAddBegin=(*BunchesIter).begin(); - tracksToAddEnd=(*BunchesIter).end(); - for (tracksToAddIter=tracksToAddBegin;tracksToAddIter!=tracksToAddEnd;++tracksToAddIter) { - std::vector<Trk::VxTrackAtVertex*> temp_vector_tracksAtVertex; - ElementLink<Trk::TrackParticleBaseCollection> link; - link.setElement(const_cast<Trk::TrackParticleBase*>(*tracksToAddIter)); - Trk::LinkToTrackParticleBase * linkTT = new Trk::LinkToTrackParticleBase(link); - Trk::VxTrackAtVertex* newVxTrack=new Trk::VxTrackAtVertex(linkTT); - temp_vector_tracksAtVertex.push_back(newVxTrack); - setOfTracks->push_back(newVxTrack); - setOfVertices.push_back(new Trk::VxVertexOnJetAxis(temp_vector_tracksAtVertex)); - } - if (msgLvl(MSG::VERBOSE)) msg() << " new overall number of tracks to fit : " << setOfVertices.size() << endmsg; - myJetCandidate->setVerticesOnJetAxis(setOfVertices); - m_initializationHelper->updateTrackNumbering(myJetCandidate); - m_routines->initializeToMinDistancesToJetAxis(myJetCandidate); - doTheFit(myJetCandidate); + if (not myJetCandidate) continue; + ATH_MSG_VERBOSE( " other fit with " << BunchesIter->size() << " tracks " ); + std::vector<Trk::VxVertexOnJetAxis*> setOfVertices=myJetCandidate->getVerticesOnJetAxis(); + std::vector<Trk::VxTrackAtVertex*>* setOfTracks=myJetCandidate->vxTrackAtVertex(); + tracksToAddBegin=(*BunchesIter).begin(); + tracksToAddEnd=(*BunchesIter).end(); + for (tracksToAddIter=tracksToAddBegin;tracksToAddIter!=tracksToAddEnd;++tracksToAddIter) { + std::vector<Trk::VxTrackAtVertex*> temp_vector_tracksAtVertex; + ElementLink<Trk::TrackParticleBaseCollection> link; + link.setElement(const_cast<Trk::TrackParticleBase*>(*tracksToAddIter)); + Trk::LinkToTrackParticleBase * linkTT = new Trk::LinkToTrackParticleBase(link); + Trk::VxTrackAtVertex* newVxTrack=new Trk::VxTrackAtVertex(linkTT); + temp_vector_tracksAtVertex.push_back(newVxTrack); + setOfTracks->push_back(newVxTrack); + setOfVertices.push_back(new Trk::VxVertexOnJetAxis(temp_vector_tracksAtVertex)); + } + ATH_MSG_VERBOSE( " new overall number of tracks to fit : " << setOfVertices.size() ); + myJetCandidate->setVerticesOnJetAxis(setOfVertices); + m_initializationHelper->updateTrackNumbering(myJetCandidate); + m_routines->initializeToMinDistancesToJetAxis(myJetCandidate); + doTheFit(myJetCandidate); } } - std::vector<Trk::VxCandidate*> myCandidates; myCandidates.push_back(myJetCandidate); - -// return new Trk::VxSecVertexInfo(myCandidates);//ownership of the single objects is taken over! return 0; } - void InDetJetFitterVxFinder::doTheFit(Trk::VxJetCandidate* myJetCandidate, - bool performClustering) const { + void + InDetJetFitterVxFinder::doTheFit(Trk::VxJetCandidate* myJetCandidate, + bool performClustering) const { - int numClusteringLoops=0; bool noMoreVerticesToCluster(false); - do {//reguards clustering - - if (msgLvl(MSG::VERBOSE)) msg() << "InDetJetFitterVxFinder: ------>>>> new cycle of fit" << endmsg; - + ATH_MSG_VERBOSE( "InDetJetFitterVxFinder: ------>>>> new cycle of fit" ); int numLoops=0; bool noMoreTracksToDelete(false); do {//reguards eliminating incompatible tracks... - - m_routines->performTheFit(myJetCandidate,10,false,30,0.001); - - const std::vector<Trk::VxVertexOnJetAxis*> & vertices=myJetCandidate->getVerticesOnJetAxis(); - - std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesBegin=vertices.begin(); - std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesEnd=vertices.end(); - - - //delete incompatible tracks... - float max_prob(1.); - Trk::VxVertexOnJetAxis* worseVertex(0); - for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesIter=verticesBegin; - verticesIter!=verticesEnd;++verticesIter) { - if (*verticesIter==0) { - if (msgLvl(MSG::WARNING)) msg() << "One vertex is empy. Problem when trying to delete incompatible vertices. No further vertices deleted." << endmsg; - } else { - const Trk::FitQuality & fitQuality=(*verticesIter)->fitQuality(); - if (TMath::Prob(fitQuality.chiSquared(),(int)std::floor(fitQuality.numberDoF()+0.5))<max_prob) { - max_prob=TMath::Prob(fitQuality.chiSquared(),(int)std::floor(fitQuality.numberDoF()+0.5)); - worseVertex=*verticesIter; - } - } - } - if (max_prob<m_vertexProbCut) { - if (msgLvl(MSG::DEBUG)) msg() << "Deleted vertex " << worseVertex->getNumVertex() << " with probability " << max_prob << endmsg; - // std::cout << "Deleted vertex " << worseVertex->getNumVertex() << " with probability " << max_prob << std::endl; - if (worseVertex==myJetCandidate->getPrimaryVertex()) { - if (msgLvl(MSG::INFO)) msg() << " The most incompatible vertex is the primary vertex. Please check..." << endmsg; - } - - m_routines->deleteVertexFromJetCandidate(worseVertex,myJetCandidate); - - } else { - noMoreTracksToDelete=true; - if (msgLvl(MSG::VERBOSE)) msg() << "No tracks to delete: maximum probability is " << max_prob << endmsg; - } - - numLoops+=1; + m_routines->performTheFit(myJetCandidate,10,false,30,0.001); + const std::vector<Trk::VxVertexOnJetAxis*> & vertices=myJetCandidate->getVerticesOnJetAxis(); + std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesBegin=vertices.begin(); + std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesEnd=vertices.end(); + //delete incompatible tracks... + float max_prob(1.); + Trk::VxVertexOnJetAxis* worseVertex(0); + for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator verticesIter=verticesBegin; + verticesIter!=verticesEnd;++verticesIter) { + if (*verticesIter==0) { + ATH_MSG_WARNING( "One vertex is empy. Problem when trying to delete incompatible vertices. No further vertices deleted." ); + } else { + const Trk::FitQuality & fitQuality=(*verticesIter)->fitQuality(); + if (TMath::Prob(fitQuality.chiSquared(),(int)std::floor(fitQuality.numberDoF()+0.5))<max_prob) { + max_prob=TMath::Prob(fitQuality.chiSquared(),(int)std::floor(fitQuality.numberDoF()+0.5)); + worseVertex=*verticesIter; + } + } + } + if (worseVertex and (max_prob<m_vertexProbCut)) { + ATH_MSG_DEBUG( "Deleted vertex " << worseVertex->getNumVertex() << " with probability " << max_prob ); + if (worseVertex==myJetCandidate->getPrimaryVertex()) { + ATH_MSG_INFO( " The most incompatible vertex is the primary vertex. Please check..." ); + } + m_routines->deleteVertexFromJetCandidate(worseVertex,myJetCandidate); + } else { + noMoreTracksToDelete=true; + ATH_MSG_VERBOSE( "No tracks to delete: maximum probability is " << max_prob ); + } + numLoops+=1; } while (numLoops<m_maxNumDeleteIterations&&!(noMoreTracksToDelete)); - if (!performClustering) break; - if (!m_useFastClustering) { - m_routines->fillTableWithFullProbOfMerging(myJetCandidate,5,false,10,0.01); + m_routines->fillTableWithFullProbOfMerging(myJetCandidate,5,false,10,0.01); } else { - m_routines->fillTableWithFastProbOfMerging(myJetCandidate); + m_routines->fillTableWithFastProbOfMerging(myJetCandidate); } const Trk::VxClusteringTable* clusteringTablePtr(myJetCandidate->getClusteringTable()); - - - - if (clusteringTablePtr==0) { - if (msgLvl(MSG::WARNING)) msg() << " No Clustering Table while it should have been calculated... no more clustering performed during vertexing " << endmsg; - noMoreVerticesToCluster=true; + ATH_MSG_WARNING( " No Clustering Table while it should have been calculated... no more clustering performed during vertexing " ); + noMoreVerticesToCluster=true; } else { - - if (msgLvl(MSG::VERBOSE)) msg() << " clustering table is " << *clusteringTablePtr << endmsg; - - //now iterate over the full map and decide wether you want to do the clustering OR not... - float probVertex(0.); - Trk::PairOfVxVertexOnJetAxis pairOfVxVertexOnJetAxis=clusteringTablePtr->getMostCompatibleVertices(probVertex); - //a PairOfVxVertexOnJetAxis is a std::pair<VxVertexOnJetAxis*,VxVertexOnJetAxis*> - - if (probVertex>0.&&probVertex>m_vertexClusteringProbabilityCut) { - if (msgLvl(MSG::VERBOSE)) msg() << " merging vtx number " << (*pairOfVxVertexOnJetAxis.first).getNumVertex() << - " and " << (*pairOfVxVertexOnJetAxis.second).getNumVertex() << endmsg; - // const Trk::VxVertexOnJetAxis & mergedVertex= - m_helper->mergeVerticesInJetCandidate(*pairOfVxVertexOnJetAxis.first, - *pairOfVxVertexOnJetAxis.second, - *myJetCandidate); - //now you need to update the numbering scheme - m_initializationHelper->updateTrackNumbering(myJetCandidate);//maybe this should be moved to a lower level... - - } else { - noMoreVerticesToCluster=true; - } + ATH_MSG_VERBOSE( " clustering table is " << *clusteringTablePtr ); + //now iterate over the full map and decide wether you want to do the clustering OR not... + float probVertex(0.); + Trk::PairOfVxVertexOnJetAxis pairOfVxVertexOnJetAxis=clusteringTablePtr->getMostCompatibleVertices(probVertex); + //a PairOfVxVertexOnJetAxis is a std::pair<VxVertexOnJetAxis*,VxVertexOnJetAxis*> + if (probVertex>0.&&probVertex>m_vertexClusteringProbabilityCut) { + ATH_MSG_VERBOSE( " merging vtx number " << (*pairOfVxVertexOnJetAxis.first).getNumVertex() << + " and " << (*pairOfVxVertexOnJetAxis.second).getNumVertex() ); + m_helper->mergeVerticesInJetCandidate(*pairOfVxVertexOnJetAxis.first, + *pairOfVxVertexOnJetAxis.second, + *myJetCandidate); + //now you need to update the numbering scheme + m_initializationHelper->updateTrackNumbering(myJetCandidate);//maybe this should be moved to a lower level... + } else { + noMoreVerticesToCluster=true; + } } numClusteringLoops+=1; } while (numClusteringLoops<m_maxClusteringIterations&&!(noMoreVerticesToCluster)); - //now a section should follow where the "complicate" VxJetCandidate is transformed in a conventional "VxCandidate" //so that it can be used also by the normal B-Tagging algorithms... //TO BE COMPLETED