![]() |
![]() |
00001 00002 // system include files 00003 #include <memory> 00004 00005 // user include files 00006 #include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h" 00007 #include "DataFormats/Common/interface/AssociationMap.h" 00008 #include "DataFormats/VertexReco/interface/Vertex.h" 00009 #include "DataFormats/VertexReco/interface/VertexFwd.h" 00010 00011 #include "FWCore/Framework/interface/Frameworkfwd.h" 00012 #include "FWCore/Framework/interface/EDProducer.h" 00013 #include "FWCore/Framework/interface/Event.h" 00014 #include "FWCore/Framework/interface/MakerMacros.h" 00015 00016 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00017 00018 00019 // 00020 // class decleration 00021 // 00022 00023 class SecondaryVertexTagInfoProxy : public edm::EDProducer 00024 { 00025 public: 00026 00027 explicit SecondaryVertexTagInfoProxy(const edm::ParameterSet&); 00028 00029 private: 00030 00031 virtual void produce(edm::Event&, const edm::EventSetup&); 00032 00033 edm::InputTag svTagInfoCollection_; 00034 }; 00035 00036 00037 SecondaryVertexTagInfoProxy::SecondaryVertexTagInfoProxy(const edm::ParameterSet& config) 00038 { 00039 // Get the cfg parameter 00040 svTagInfoCollection_ = config.getUntrackedParameter<edm::InputTag> ( "svTagInfoProducer" ); 00041 00042 // Declare the type of objects to be produced. 00043 produces<reco::VertexCollection>(); 00044 produces<edm::AssociationMap<edm::OneToMany<reco::SecondaryVertexTagInfoCollection, reco::VertexCollection> > >(); 00045 } 00046 00047 00048 void SecondaryVertexTagInfoProxy::produce(edm::Event& event, const edm::EventSetup& setup) 00049 { 00050 // Vertex collection 00051 edm::Handle<reco::SecondaryVertexTagInfoCollection> svTagInfoCollection; 00052 event.getByLabel(svTagInfoCollection_, svTagInfoCollection); 00053 00054 // Auto pointers to the collection to be added to the event 00055 std::auto_ptr<reco::VertexCollection> proxy (new reco::VertexCollection); 00056 std::auto_ptr<edm::AssociationMap<edm::OneToMany<reco::SecondaryVertexTagInfoCollection, reco::VertexCollection> > > 00057 assoc (new edm::AssociationMap<edm::OneToMany<reco::SecondaryVertexTagInfoCollection, reco::VertexCollection> >); 00058 00059 // Get a reference before to put in the event 00060 reco::VertexRefProd vertexRefProd = event.getRefBeforePut<reco::VertexCollection>(); 00061 00062 // General index 00063 std::size_t index = 0; 00064 00065 // Loop over SecondaryVertexTagInfo collection 00066 for (std::size_t svIndex = 0; svIndex < svTagInfoCollection->size(); ++svIndex) 00067 { 00068 // Reference to svTagInfo 00069 reco::SecondaryVertexTagInfoRef svTagInfo(svTagInfoCollection, svIndex); 00070 00071 // Loop over the vertexes and add them to the new collection 00072 for (unsigned int vIndex = 0; vIndex < svTagInfo->nVertices(); ++vIndex) 00073 { 00074 proxy->push_back(svTagInfo->secondaryVertex(vIndex)); 00075 assoc->insert(svTagInfo, reco::VertexRef(vertexRefProd, index)); 00076 ++index; 00077 } 00078 } 00079 00080 // Adding the collection to the event 00081 event.put(proxy); 00082 event.put(assoc); 00083 } 00084 00085 00086 //define this as a plug-in 00087 DEFINE_FWK_MODULE(SecondaryVertexTagInfoProxy);