00001 #include "RecoVertex/PrimaryVertexProducer/interface/DummyPrimaryVertexProducer.h" 00002 00003 #include "DataFormats/VertexReco/interface/Vertex.h" 00004 #include "DataFormats/VertexReco/interface/VertexFwd.h" 00005 #include "DataFormats/Common/interface/EDProduct.h" 00006 #include "DataFormats/Common/interface/Handle.h" 00007 #include "FWCore/Framework/interface/MakerMacros.h" 00008 00009 // 00010 // constants, enums and typedefs 00011 // 00012 00013 // 00014 // static data member definitions 00015 // 00016 00017 // 00018 // constructors and destructor 00019 // 00020 DummyPrimaryVertexProducer::DummyPrimaryVertexProducer(const edm::ParameterSet& iConfig) 00021 { 00022 using namespace reco; 00023 //register your products 00024 //#ifdef THIS_IS_AN_EVENT_EXAMPLE 00025 // produces<VertexCollection>(); 00026 00027 //if do put with a label 00028 produces<VertexCollection>("PrimaryVertex"); 00029 //#endif 00030 00031 //now do what ever other initialization is needed 00032 00033 } 00034 00035 00036 DummyPrimaryVertexProducer::~DummyPrimaryVertexProducer() 00037 { 00038 00039 // do anything here that needs to be done at desctruction time 00040 // (e.g. close files, deallocate resources etc.) 00041 00042 } 00043 00044 00045 // 00046 // member functions 00047 // 00048 00049 // ------------ method called to produce the data ------------ 00050 void 00051 DummyPrimaryVertexProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) 00052 { 00053 using namespace edm; 00054 00055 //Read 'ExampleData' from the Event 00056 // Handle<ExampleData> pIn; 00057 // iEvent.getByLabel("example",pIn); 00058 00059 reco::Vertex::Point pos(-1, -1, -1); 00060 reco::Vertex::Error err; 00061 double chi2 = -1; double ndof = 1; double ntks = 0; 00062 00063 00064 std::auto_ptr<reco::VertexCollection> result(new reco::VertexCollection); // empty vertex collection,on the heap ?? 00065 reco::VertexCollection tmpVColl; 00066 reco::Vertex v(pos, err, chi2, ndof, ntks); 00067 tmpVColl.push_back(v); 00068 *result = tmpVColl; 00069 iEvent.put(result, "PrimaryVertex"); 00070 00071 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE 00072 //Read SetupData from the SetupRecord in the EventSetup 00073 ESHandle<SetupData> pSetup; 00074 iSetup.get<SetupRecord>().get(pSetup); 00075 #endif 00076 } 00077 00078 //define this as a plug-in 00079 //DEFINE_FWK_MODULE(DummyPrimaryVertexProducer);