CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BeamSpotProducer.cc
Go to the documentation of this file.
1 
4 
10 
13 
14 //
15 // constructors and destructor
16 //
18  edm::LogInfo("RecoVertex/BeamSpotProducer") << "Initializing Beam Spot producer "
19  << "\n";
20 
21  //fVerbose=conf.getUntrackedParameter<bool>("verbose", false);
22  m_beamToken = esConsumes<BeamSpotObjects, BeamSpotObjectsRcd>();
23 
24  produces<reco::BeamSpot>();
25 }
26 
28 
29 //
30 // member functions
31 //
32 
33 // ------------ method called to produce the data ------------
35  using namespace edm;
36 
37  auto result = std::make_unique<reco::BeamSpot>();
38 
39  reco::BeamSpot aSpot;
40 
41  //typedef math::XYZPoint Point;
42  //enum { dimension = 7 };
43  //typedef math::Error<dimension>::type CovarianceMatrix;
44 
45  //try {
46  edm::LogInfo("RecoVertex/BeamSpotProducer") << "Reconstructing event number: " << iEvent.id() << "\n";
47 
49  const BeamSpotObjects* spotDB = beamhandle.product();
50 
51  // translate from BeamSpotObjects to reco::BeamSpot
52  reco::BeamSpot::Point apoint(spotDB->GetX(), spotDB->GetY(), spotDB->GetZ());
53 
55  for (int i = 0; i < 7; ++i) {
56  for (int j = 0; j < 7; ++j) {
57  matrix(i, j) = spotDB->GetCovariance(i, j);
58  }
59  }
60 
61  // this assume beam width same in x and y
62  aSpot = reco::BeamSpot(
63  apoint, spotDB->GetSigmaZ(), spotDB->Getdxdz(), spotDB->Getdydz(), spotDB->GetBeamWidthX(), matrix);
64  aSpot.setBeamWidthY(spotDB->GetBeamWidthY());
65  aSpot.setEmittanceX(spotDB->GetEmittanceX());
66  aSpot.setEmittanceY(spotDB->GetEmittanceY());
67  aSpot.setbetaStar(spotDB->GetBetaStar());
68 
69  //}
70  //
71  //catch (std::exception & err) {
72  // edm::LogInfo("RecoVertex/BeamSpotProducer")
73  // << "Exception during event number: " << iEvent.id()
74  // << "\n" << err.what() << "\n";
75  //}
76 
77  *result = aSpot;
78 
79  iEvent.put(std::move(result));
80 }
81 
82 //define this as a plug-in
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
~BeamSpotProducer() override
destructor
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
tuple result
Definition: mps_fire.py:311
int iEvent
Definition: GenABIO.cc:224
edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > m_beamToken
def move
Definition: eostools.py:511
BeamSpotProducer(const edm::ParameterSet &iConf)
constructor
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
produce a beam spot class
Log< level::Info, false > LogInfo
edm::EventID id() const
Definition: EventBase.h:59
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157