CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

VertexMerger Class Reference

Inheritance diagram for VertexMerger:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void produce (edm::Event &event, const edm::EventSetup &es)
 VertexMerger (const edm::ParameterSet &params)

Private Member Functions

bool trackFilter (const reco::TrackRef &track) const

Private Attributes

double maxFraction
double minSignificance
edm::InputTag secondaryVertexCollection

Detailed Description

Definition at line 17 of file VertexMerger.cc.


Constructor & Destructor Documentation

VertexMerger::VertexMerger ( const edm::ParameterSet params)

Definition at line 32 of file VertexMerger.cc.

                                                        :
//      primaryVertexCollection(params.getParameter<edm::InputTag>("primaryVertices")),
        secondaryVertexCollection(params.getParameter<edm::InputTag>("secondaryVertices")),
        maxFraction(params.getParameter<double>("maxFraction")),
        minSignificance(params.getParameter<double>("minSignificance"))
{
        produces<reco::VertexCollection>();
}

Member Function Documentation

void VertexMerger::produce ( edm::Event event,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 63 of file VertexMerger.cc.

References computeSharedTracks(), maxFraction, minSignificance, dt_dqm_sourceclient_common_cff::reco, and secondaryVertexCollection.

{
        using namespace reco;

        edm::Handle<VertexCollection> secondaryVertices;
        event.getByLabel(secondaryVertexCollection, secondaryVertices);

        VertexDistance3D dist;
        std::auto_ptr<VertexCollection> recoVertices(new VertexCollection);
        for(std::vector<reco::Vertex>::const_iterator sv = secondaryVertices->begin();
            sv != secondaryVertices->end(); ++sv) {
          recoVertices->push_back(*sv);
        }
       for(std::vector<reco::Vertex>::iterator sv = recoVertices->begin();
            sv != recoVertices->end(); ++sv) {

        bool shared=false;
       for(std::vector<reco::Vertex>::iterator sv2 = recoVertices->begin();
            sv2 != recoVertices->end(); ++sv2) {
                  double fr=computeSharedTracks(*sv2, *sv);
        //        std::cout << sv2-recoVertices->begin() << " vs " << sv-recoVertices->begin() << " : " << fr << " "  <<  computeSharedTracks(*sv, *sv2) << " sig " << dist.distance(*sv,*sv2).significance() << std::endl;
          //      std::cout << (fr > maxFraction) << " && " << (dist.distance(*sv,*sv2).significance() < 2)  <<  " && " <<  (sv-sv2!=0)  << " && " <<  (fr >= computeSharedTracks(*sv2, *sv))  << std::endl;
                if (fr > maxFraction && dist.distance(*sv,*sv2).significance() < minSignificance && sv-sv2!=0 
                    && fr >= computeSharedTracks(*sv, *sv2) )
                  {
                      shared=true; 
                     // std::cout << "shared " << sv-recoVertices->begin() << " and "  << sv2-recoVertices->begin() << " fractions: " << fr << " , "  << computeSharedTracks(*sv2, *sv) << " sig: " <<  dist.distance(*sv,*sv2).significance() <<  std::endl;
         
                  }
                 

        }
        if(shared) { sv=recoVertices->erase(sv)-1; }
     //    std::cout << "it = " <<  sv-recoVertices->begin() << " new size is: " << recoVertices->size() <<   std::endl;
       }

        event.put(recoVertices);



}
bool VertexMerger::trackFilter ( const reco::TrackRef track) const [private]

Member Data Documentation

double VertexMerger::maxFraction [private]

Definition at line 28 of file VertexMerger.cc.

Referenced by produce().

Definition at line 29 of file VertexMerger.cc.

Referenced by produce().

Definition at line 27 of file VertexMerger.cc.

Referenced by produce().