CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SecondaryVertexTagInfoProxy Class Reference

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

List of all members.

Public Member Functions

 SecondaryVertexTagInfoProxy (const edm::ParameterSet &)

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

edm::InputTag svTagInfoCollection_

Detailed Description

Definition at line 23 of file SecondaryVertexTagInfoProxy.cc.


Constructor & Destructor Documentation

SecondaryVertexTagInfoProxy::SecondaryVertexTagInfoProxy ( const edm::ParameterSet config) [explicit]

Definition at line 37 of file SecondaryVertexTagInfoProxy.cc.

References edm::ParameterSet::getUntrackedParameter(), and svTagInfoCollection_.

{
    // Get the cfg parameter
    svTagInfoCollection_ = config.getUntrackedParameter<edm::InputTag> ( "svTagInfoProducer" );

    // Declare the type of objects to be produced.
    produces<reco::VertexCollection>();
    produces<edm::AssociationMap<edm::OneToMany<reco::SecondaryVertexTagInfoCollection, reco::VertexCollection> > >();
}

Member Function Documentation

void SecondaryVertexTagInfoProxy::produce ( edm::Event event,
const edm::EventSetup setup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 48 of file SecondaryVertexTagInfoProxy.cc.

References getHLTprescales::index, and svTagInfoCollection_.

{
    // Vertex collection
    edm::Handle<reco::SecondaryVertexTagInfoCollection> svTagInfoCollection;
    event.getByLabel(svTagInfoCollection_, svTagInfoCollection);

    // Auto pointers to the collection to be added to the event
    std::auto_ptr<reco::VertexCollection> proxy (new reco::VertexCollection);
    std::auto_ptr<edm::AssociationMap<edm::OneToMany<reco::SecondaryVertexTagInfoCollection, reco::VertexCollection> > >
    assoc (new edm::AssociationMap<edm::OneToMany<reco::SecondaryVertexTagInfoCollection, reco::VertexCollection> >);

    // Get a reference before to put in the event
    reco::VertexRefProd vertexRefProd = event.getRefBeforePut<reco::VertexCollection>();

    // General index
    std::size_t index = 0;

    // Loop over SecondaryVertexTagInfo collection
    for (std::size_t svIndex = 0; svIndex < svTagInfoCollection->size(); ++svIndex)
    {
        // Reference to svTagInfo
        reco::SecondaryVertexTagInfoRef svTagInfo(svTagInfoCollection, svIndex);

        // Loop over the vertexes and add them to the new collection
        for (unsigned int vIndex = 0; vIndex < svTagInfo->nVertices(); ++vIndex)
        {
            proxy->push_back(svTagInfo->secondaryVertex(vIndex));
            assoc->insert(svTagInfo, reco::VertexRef(vertexRefProd, index));
            ++index;
        }
    }

    // Adding the collection to the event
    event.put(proxy);
    event.put(assoc);
}

Member Data Documentation

Definition at line 33 of file SecondaryVertexTagInfoProxy.cc.

Referenced by produce(), and SecondaryVertexTagInfoProxy().