Go to the documentation of this file.00001
00002 #include "RecoVertex/BeamSpotProducer/interface/BeamSpotProducer.h"
00003 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00004
00005 #include "FWCore/Framework/interface/MakerMacros.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "FWCore/Framework/interface/ESHandle.h"
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "FWCore/Framework/interface/IOVSyncValue.h"
00010 #include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
00011 #include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"
00012
00013 #include "DataFormats/Math/interface/Error.h"
00014 #include "DataFormats/Math/interface/Point3D.h"
00015
00016
00017
00018
00019 BeamSpotProducer::BeamSpotProducer(const edm::ParameterSet& iConf) {
00020
00021 edm::LogInfo("RecoVertex/BeamSpotProducer")
00022 << "Initializing Beam Spot producer " << "\n";
00023
00024
00025
00026 produces<reco::BeamSpot>();
00027
00028 }
00029
00030
00031 BeamSpotProducer::~BeamSpotProducer() {}
00032
00033
00034
00035
00036
00037
00038 void
00039 BeamSpotProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00040
00041 using namespace edm;
00042
00043 std::auto_ptr<reco::BeamSpot> result(new reco::BeamSpot);
00044
00045 reco::BeamSpot aSpot;
00046
00047
00048
00049
00050
00051
00052
00053
00054 edm::LogInfo("RecoVertex/BeamSpotProducer")
00055 << "Reconstructing event number: " << iEvent.id() << "\n";
00056
00057 edm::ESHandle< BeamSpotObjects > beamhandle;
00058 iSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
00059 const BeamSpotObjects *spotDB = beamhandle.product();
00060
00061
00062 reco::BeamSpot::Point apoint( spotDB->GetX(), spotDB->GetY(), spotDB->GetZ() );
00063
00064 reco::BeamSpot::CovarianceMatrix matrix;
00065 for ( int i=0; i<7; ++i ) {
00066 for ( int j=0; j<7; ++j ) {
00067 matrix(i,j) = spotDB->GetCovariance(i,j);
00068 }
00069 }
00070
00071
00072 aSpot = reco::BeamSpot( apoint,
00073 spotDB->GetSigmaZ(),
00074 spotDB->Getdxdz(),
00075 spotDB->Getdydz(),
00076 spotDB->GetBeamWidthX(),
00077 matrix );
00078 aSpot.setBeamWidthY( spotDB->GetBeamWidthY() );
00079 aSpot.setEmittanceX( spotDB->GetEmittanceX() );
00080 aSpot.setEmittanceY( spotDB->GetEmittanceY() );
00081 aSpot.setbetaStar( spotDB->GetBetaStar() );
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 *result = aSpot;
00092
00093 iEvent.put(result);
00094
00095 }
00096
00097
00098 DEFINE_FWK_MODULE(BeamSpotProducer);
00099