CMS 3D CMS Logo

BeamSpotOnlineProducer.cc
Go to the documentation of this file.
1 
25 
27 public:
29  explicit BeamSpotOnlineProducer(const edm::ParameterSet& iConf);
30 
32  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
33 
34 private:
35  const bool changeFrame_;
36  const double theMaxZ, theSetSigmaZ;
37  double theMaxR2;
41 
42  const unsigned int theBeamShoutMode;
43 };
44 
45 using namespace edm;
46 
48  : changeFrame_(iconf.getParameter<bool>("changeToCMSCoordinates")),
49  theMaxZ(iconf.getParameter<double>("maxZ")),
50  theSetSigmaZ(iconf.getParameter<double>("setSigmaZ")),
51  scalerToken_(consumes<BeamSpotOnlineCollection>(iconf.getParameter<InputTag>("src"))),
52  l1GtEvmReadoutRecordToken_(consumes<L1GlobalTriggerEvmReadoutRecord>(iconf.getParameter<InputTag>("gtEvmLabel"))),
53  beamToken_(esConsumes<BeamSpotObjects, BeamSpotObjectsRcd>()),
54  theBeamShoutMode(iconf.getUntrackedParameter<unsigned int>("beamMode", 11)) {
55  theMaxR2 = iconf.getParameter<double>("maxRadius");
56  theMaxR2 *= theMaxR2;
57 
58  produces<reco::BeamSpot>();
59 }
60 
62  //shout MODE only in stable beam
63  bool shoutMODE = false;
65  if (iEvent.getByToken(l1GtEvmReadoutRecordToken_, gtEvmReadoutRecord)) {
66  if (gtEvmReadoutRecord->gtfeWord().beamMode() == theBeamShoutMode)
67  shoutMODE = true;
68  } else {
69  shoutMODE = true;
70  }
71 
72  // get scalar collection
74  iEvent.getByToken(scalerToken_, handleScaler);
75 
76  // beam spot scalar object
77  BeamSpotOnline spotOnline;
78 
79  // product is a reco::BeamSpot object
80  auto result = std::make_unique<reco::BeamSpot>();
81 
82  reco::BeamSpot aSpot;
83 
84  bool fallBackToDB = false;
85  if (!handleScaler->empty()) {
86  // get one element
87  spotOnline = *(handleScaler->begin());
88 
89  // in case we need to switch to LHC reference frame
90  // ignore for the moment rotations, and translations
91  double f = 1.;
92  if (changeFrame_)
93  f = -1.;
94 
95  reco::BeamSpot::Point apoint(f * spotOnline.x(), spotOnline.y(), f * spotOnline.z());
96 
98  matrix(0, 0) = spotOnline.err_x() * spotOnline.err_x();
99  matrix(1, 1) = spotOnline.err_y() * spotOnline.err_y();
100  matrix(2, 2) = spotOnline.err_z() * spotOnline.err_z();
101  matrix(3, 3) = spotOnline.err_sigma_z() * spotOnline.err_sigma_z();
102 
103  double sigmaZ = spotOnline.sigma_z();
104  if (theSetSigmaZ > 0)
106 
107  aSpot = reco::BeamSpot(apoint, sigmaZ, spotOnline.dxdz(), f * spotOnline.dydz(), spotOnline.width_x(), matrix);
108 
109  aSpot.setBeamWidthY(spotOnline.width_y());
110  aSpot.setEmittanceX(0.);
111  aSpot.setEmittanceY(0.);
112  aSpot.setbetaStar(0.);
113  aSpot.setType(reco::BeamSpot::LHC); // flag value from scalars
114 
115  // check if we have a valid beam spot fit result from online DQM
116  if (spotOnline.x() == 0 && spotOnline.y() == 0 && spotOnline.z() == 0 && spotOnline.width_x() == 0 &&
117  spotOnline.width_y() == 0) {
118  if (shoutMODE) {
119  edm::LogWarning("BeamSpotFromDB")
120  << "Online Beam Spot producer falls back to DB value because the scaler values are zero ";
121  }
122  fallBackToDB = true;
123  }
124  double r2 = spotOnline.x() * spotOnline.x() + spotOnline.y() * spotOnline.y();
125  if (fabs(spotOnline.z()) >= theMaxZ || r2 >= theMaxR2) {
126  if (shoutMODE) {
127  edm::LogError("BeamSpotFromDB")
128  << "Online Beam Spot producer falls back to DB value because the scaler values are too big to be true :"
129  << spotOnline.x() << " " << spotOnline.y() << " " << spotOnline.z();
130  }
131  fallBackToDB = true;
132  }
133  } else {
134  //empty online beamspot collection: FED data was empty
135  //the error should probably have been send at unpacker level
136  fallBackToDB = true;
137  }
138 
139  if (fallBackToDB) {
141  const BeamSpotObjects* spotDB = beamhandle.product();
142 
143  // translate from BeamSpotObjects to reco::BeamSpot
144  reco::BeamSpot::Point apoint(spotDB->GetX(), spotDB->GetY(), spotDB->GetZ());
145 
147  for (int i = 0; i < 7; ++i) {
148  for (int j = 0; j < 7; ++j) {
149  matrix(i, j) = spotDB->GetCovariance(i, j);
150  }
151  }
152 
153  // this assume beam width same in x and y
154  aSpot = reco::BeamSpot(
155  apoint, spotDB->GetSigmaZ(), spotDB->Getdxdz(), spotDB->Getdydz(), spotDB->GetBeamWidthX(), matrix);
156  aSpot.setBeamWidthY(spotDB->GetBeamWidthY());
157  aSpot.setEmittanceX(spotDB->GetEmittanceX());
158  aSpot.setEmittanceY(spotDB->GetEmittanceY());
159  aSpot.setbetaStar(spotDB->GetBetaStar());
161  }
162 
163  *result = aSpot;
164 
165  iEvent.put(std::move(result));
166 }
167 
BeamSpotOnline::x
float x() const
Definition: BeamSpotOnline.h:48
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
BeamSpotObjects::GetBeamWidthY
double GetBeamWidthY() const
get average transverse beam width
Definition: BeamSpotObjects.h:77
BeamSpotObjects::Getdxdz
double Getdxdz() const
get dxdz slope, crossing angle in XZ
Definition: BeamSpotObjects.h:79
BeamSpotOnlineProducer::beamToken_
const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > beamToken_
Definition: BeamSpotOnlineProducer.cc:40
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
reco::BeamSpot::setBeamWidthY
void setBeamWidthY(double v)
Definition: BeamSpot.h:105
MessageLogger.h
BeamSpotPI::sigmaZ
Definition: BeamSpotPayloadInspectorHelper.h:35
makeMuonMisalignmentScenario.matrix
list matrix
Definition: makeMuonMisalignmentScenario.py:141
BeamSpotOnline::err_y
float err_y() const
Definition: BeamSpotOnline.h:54
reco::BeamSpot::setEmittanceY
void setEmittanceY(double v)
Definition: BeamSpot.h:137
ESHandle.h
align::BeamSpot
Definition: StructureType.h:89
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
BeamSpotOnline::err_z
float err_z() const
Definition: BeamSpotOnline.h:55
BeamSpotOnline::dxdz
float dxdz() const
Definition: BeamSpotOnline.h:51
BeamSpotOnline::y
float y() const
Definition: BeamSpotOnline.h:49
edm::EDGetTokenT< BeamSpotOnlineCollection >
BeamSpotObjects::GetSigmaZ
double GetSigmaZ() const
get sigma Z, RMS bunch length
Definition: BeamSpotObjects.h:73
edm
HLT enums.
Definition: AlignableModifier.h:19
L1GlobalTriggerEvmReadoutRecord::gtfeWord
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
Definition: L1GlobalTriggerEvmReadoutRecord.cc:249
BeamSpotObjects::GetZ
double GetZ() const
get Z beam position
Definition: BeamSpotObjects.h:71
BeamSpotOnline::dydz
float dydz() const
Definition: BeamSpotOnline.h:52
EDProducer.h
BeamSpotOnline.h
reco::BeamSpot::LHC
Definition: BeamSpot.h:24
BeamSpotOnline::err_sigma_z
float err_sigma_z() const
Definition: BeamSpotOnline.h:63
BeamSpotOnline::width_x
float width_x() const
Definition: BeamSpotOnline.h:58
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
BeamSpotOnlineProducer::theMaxR2
double theMaxR2
Definition: BeamSpotOnlineProducer.cc:37
MakerMacros.h
BeamSpotOnline::err_x
float err_x() const
Definition: BeamSpotOnline.h:53
BeamSpotObjects.h
L1GlobalTriggerEvmReadoutRecord.h
BeamSpotOnlineProducer
Definition: BeamSpotOnlineProducer.cc:26
BeamSpotObjectsRcd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
BeamSpotOnlineProducer::changeFrame_
const bool changeFrame_
Definition: BeamSpotOnlineProducer.cc:35
L1GlobalTriggerEvmReadoutRecord
Definition: L1GlobalTriggerEvmReadoutRecord.h:36
BeamSpotOnline::sigma_z
float sigma_z() const
Definition: BeamSpotOnline.h:60
reco::BeamSpot
Definition: BeamSpot.h:21
reco::BeamSpot::Tracker
Definition: BeamSpot.h:24
edm::ESHandle
Definition: DTSurvey.h:22
BeamSpotObjects::GetCovariance
double GetCovariance(int i, int j) const
get i,j element of the full covariance matrix 7x7
Definition: BeamSpotObjects.h:83
reco::BeamSpot::setEmittanceX
void setEmittanceX(double v)
Definition: BeamSpot.h:136
BeamSpotOnlineProducer::theSetSigmaZ
const double theSetSigmaZ
Definition: BeamSpotOnlineProducer.cc:36
BeamSpotObjects::GetBetaStar
double GetBetaStar() const
get beta star
Definition: BeamSpotObjects.h:107
BeamSpotObjects::GetEmittanceX
double GetEmittanceX() const
get emittance
Definition: BeamSpotObjects.h:103
BeamSpotOnlineProducer::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
produce a beam spot class
Definition: BeamSpotOnlineProducer.cc:61
edm::ParameterSet
Definition: ParameterSet.h:47
BeamSpotObjects::GetY
double GetY() const
get Y beam position
Definition: BeamSpotObjects.h:69
Event.h
reco::BeamSpot::setbetaStar
void setbetaStar(double v)
Definition: BeamSpot.h:138
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
edm::stream::EDProducer
Definition: EDProducer.h:38
BeamSpotOnlineProducer::BeamSpotOnlineProducer
BeamSpotOnlineProducer(const edm::ParameterSet &iConf)
constructor
Definition: BeamSpotOnlineProducer.cc:47
BeamSpotObjectsRcd
Definition: BeamSpotObjectsRcd.h:24
BeamSpotObjects
Definition: BeamSpotObjects.h:20
edm::EventSetup
Definition: EventSetup.h:57
reco::BeamSpot::CovarianceMatrix
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
BeamSpotOnlineProducer::scalerToken_
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalerToken_
Definition: BeamSpotOnlineProducer.cc:38
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd >
BeamSpotOnline
Definition: BeamSpotOnline.h:28
BeamSpotObjects::GetBeamWidthX
double GetBeamWidthX() const
get average transverse beam width
Definition: BeamSpotObjects.h:75
eostools.move
def move(src, dest)
Definition: eostools.py:511
BeamSpotOnline::width_y
float width_y() const
Definition: BeamSpotOnline.h:59
BeamSpotObjects::GetEmittanceY
double GetEmittanceY() const
get emittance
Definition: BeamSpotObjects.h:105
BeamSpotObjects::Getdydz
double Getdydz() const
get dydz slope, crossing angle in YZ
Definition: BeamSpotObjects.h:81
BeamSpotOnlineProducer::l1GtEvmReadoutRecordToken_
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > l1GtEvmReadoutRecordToken_
Definition: BeamSpotOnlineProducer.cc:39
BeamSpotOnlineCollection
std::vector< BeamSpotOnline > BeamSpotOnlineCollection
Definition: BeamSpotOnline.h:101
BeamSpotOnlineProducer::theMaxZ
const double theMaxZ
Definition: BeamSpotOnlineProducer.cc:36
TrackEfficiencyMonitor_cfi.theMaxZ
theMaxZ
Definition: TrackEfficiencyMonitor_cfi.py:11
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
mps_fire.result
result
Definition: mps_fire.py:311
reco::BeamSpot::Point
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
ParameterSet.h
BeamSpotOnlineProducer::theBeamShoutMode
const unsigned int theBeamShoutMode
Definition: BeamSpotOnlineProducer.cc:42
reco::BeamSpot::setType
void setType(BeamType type)
set beam type
Definition: BeamSpot.h:124
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
BeamSpotOnline::z
float z() const
Definition: BeamSpotOnline.h:50
edm::Event
Definition: Event.h:73
BeamSpotObjects::GetX
double GetX() const
get X beam position
Definition: BeamSpotObjects.h:67
L1GtfeExtWord::beamMode
const cms_uint16_t beamMode() const
Definition: L1GtfeExtWord.cc:215
edm::InputTag
Definition: InputTag.h:15