CMS 3D CMS Logo

AlcaBeamSpotFromDB.cc
Go to the documentation of this file.
1 
12 // C++ standard
13 #include <string>
14 // CMS
17 
19 
25 
27  : beamSpotToken_(esConsumes<BeamSpotObjects, BeamSpotObjectsRcd, edm::Transition::EndLuminosityBlock>()) {
28  produces<reco::BeamSpot, edm::Transition::EndLuminosityBlock>("alcaBeamSpot");
29 }
30 
32 
33 //--------------------------------------------------------------------------------------------------
35 
36 //--------------------------------------------------------------------------------------------------
38  // read DB object
39  const BeamSpotObjects *spotDB = &iSetup.getData(beamSpotToken_);
40 
41  // translate from BeamSpotObjects to reco::BeamSpot
42  reco::BeamSpot::Point apoint(spotDB->x(), spotDB->y(), spotDB->z());
43 
45  for (int i = 0; i < 7; ++i) {
46  for (int j = 0; j < 7; ++j) {
47  matrix(i, j) = spotDB->covariance(i, j);
48  }
49  }
50 
51  reco::BeamSpot aSpot;
52  // this assume beam width same in x and y
53  aSpot = reco::BeamSpot(apoint, spotDB->sigmaZ(), spotDB->dxdz(), spotDB->dydz(), spotDB->beamWidthX(), matrix);
54  aSpot.setBeamWidthY(spotDB->beamWidthY());
55  aSpot.setEmittanceX(spotDB->emittanceX());
56  aSpot.setEmittanceY(spotDB->emittanceY());
57  aSpot.setbetaStar(spotDB->betaStar());
58 
59  if (spotDB->beamType() == 2) {
61  } else {
63  }
64 
65  auto result = std::make_unique<reco::BeamSpot>();
66  *result = aSpot;
67  lumiSeg.put(std::move(result), std::string("alcaBeamSpot"));
68 
69  // std::cout << " for runs: " << iEvent.id().run() << " - " <<
70  // iEvent.id().run() << std::endl;
71  std::cout << aSpot << std::endl;
72 }
73 
75 
77 
78 // define this as a plug-in
double emittanceX() const
get emittance
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
double z() const
get Z beam position
const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > beamSpotToken_
double dydz() const
get dydz slope, crossing angle in YZ
void setbetaStar(double v)
Definition: BeamSpot.h:138
double covariance(int i, int j) const
get i,j element of the full covariance matrix 7x7
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
double beamWidthX() const
get average transverse beam width
int beamType() const
get beam type
void setType(BeamType type)
set beam type
Definition: BeamSpot.h:124
int iEvent
Definition: GenABIO.cc:224
void setBeamWidthY(double v)
Definition: BeamSpot.h:105
void setEmittanceY(double v)
Definition: BeamSpot.h:137
void put(std::unique_ptr< PROD > product)
Put a new product.
void endLuminosityBlockProduce(edm::LuminosityBlock &lumiSeg, const edm::EventSetup &iSetup) final
Transition
Definition: Transition.h:12
double x() const
get X beam position
AlcaBeamSpotFromDB(const edm::ParameterSet &)
bool getData(T &iHolder) const
Definition: EventSetup.h:122
~AlcaBeamSpotFromDB() override
double beamWidthY() const
get average transverse beam width
double y() const
get Y beam position
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) final
double sigmaZ() const
get sigma Z, RMS bunch length
double emittanceY() const
get emittance
double betaStar() const
get beta star
HLT enums.
void setEmittanceX(double v)
Definition: BeamSpot.h:136
double dxdz() const
get dxdz slope, crossing angle in XZ
def move(src, dest)
Definition: eostools.py:511