CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
BeamSpotOnlineProducer Class Reference
Inheritance diagram for BeamSpotOnlineProducer:
edm::stream::EDProducer<>

Public Member Functions

 BeamSpotOnlineProducer (const edm::ParameterSet &iConf)
 constructor More...
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 produce a beam spot class More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &iDesc)
 Fill descriptor. More...
 

Private Attributes

const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcdbeamToken_
 
edm::ESWatcher< BeamSpotTransientObjectsRcdbeamTransientRcdESWatcher_
 
const edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcdbeamTransientToken_
 
const bool changeFrame_
 
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecordl1GtEvmReadoutRecordToken_
 
const edm::EDGetTokenT< BeamSpotOnlineCollectionscalerToken_
 
const unsigned int theBeamShoutMode
 
double theMaxR2
 
const double theMaxZ
 
const double theSetSigmaZ
 
const bool useTransientRecord_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description


class: BeamSpotOnlineProducer.h package: RecoVertex/BeamSpotProducer

author: Francisco Yumiceva, Fermilab (yumic.nosp@m.eva@.nosp@m.fnal..nosp@m.gov) modified by: Simone Gennai, INFN MIB


Definition at line 31 of file BeamSpotOnlineProducer.cc.

Constructor & Destructor Documentation

◆ BeamSpotOnlineProducer()

BeamSpotOnlineProducer::BeamSpotOnlineProducer ( const edm::ParameterSet iConf)
explicit

constructor

Definition at line 60 of file BeamSpotOnlineProducer.cc.

References edm::ParameterSet::getParameter(), and theMaxR2.

61  : changeFrame_(iconf.getParameter<bool>("changeToCMSCoordinates")),
62  theMaxZ(iconf.getParameter<double>("maxZ")),
63  theSetSigmaZ(iconf.getParameter<double>("setSigmaZ")),
64  useTransientRecord_(iconf.getParameter<bool>("useTransientRecord")),
66  : consumes<BeamSpotOnlineCollection>(iconf.getParameter<InputTag>("src"))),
67  l1GtEvmReadoutRecordToken_(consumes<L1GlobalTriggerEvmReadoutRecord>(iconf.getParameter<InputTag>("gtEvmLabel"))),
68  beamToken_(esConsumes<BeamSpotObjects, BeamSpotObjectsRcd>()),
69  beamTransientToken_(esConsumes<BeamSpotObjects, BeamSpotTransientObjectsRcd>()),
70  theBeamShoutMode(iconf.getUntrackedParameter<unsigned int>("beamMode", 11)) {
71  theMaxR2 = iconf.getParameter<double>("maxRadius");
72  theMaxR2 *= theMaxR2;
73 
74  produces<reco::BeamSpot>();
75 }
const edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcd > beamTransientToken_
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > l1GtEvmReadoutRecordToken_
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalerToken_
const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > beamToken_
const unsigned int theBeamShoutMode

Member Function Documentation

◆ fillDescriptions()

void BeamSpotOnlineProducer::fillDescriptions ( edm::ConfigurationDescriptions iDesc)
static

Fill descriptor.

Definition at line 77 of file BeamSpotOnlineProducer.cc.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSetDescription::addUntracked(), edm::ConfigurationDescriptions::addWithDefaultLabel(), and ProducerED_cfi::InputTag.

77  {
79  ps.add<bool>("changeToCMSCoordinates", false);
80  ps.add<double>("maxZ", 40.);
81  ps.add<double>("setSigmaZ", -1.);
82  ps.addUntracked<unsigned int>("beamMode", 11);
83  ps.addOptional<InputTag>("src", InputTag("hltScalersRawToDigi"))->setComment("SCAL decommissioned after Run 2");
84  ps.add<InputTag>("gtEvmLabel", InputTag(""));
85  ps.add<double>("maxRadius", 2.0);
86  ps.add<bool>("useTransientRecord", false);
87  iDesc.addWithDefaultLabel(ps);
88 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)

◆ produce()

void BeamSpotOnlineProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

produce a beam spot class

Definition at line 90 of file BeamSpotOnlineProducer.cc.

References funct::abs(), L1GtfeExtWord::beamMode(), align::BeamSpot, beamToken_, beamTransientRcdESWatcher_, beamTransientToken_, BeamSpotObjects::beamWidthX(), BeamSpotObjects::beamWidthY(), BeamSpotObjects::betaStar(), changeFrame_, edm::ESWatcher< T >::check(), BeamSpotObjects::covariance(), BeamSpotOnline::dxdz(), BeamSpotObjects::dxdz(), BeamSpotOnline::dydz(), BeamSpotObjects::dydz(), BeamSpotObjects::emittanceX(), BeamSpotObjects::emittanceY(), BeamSpotOnline::err_sigma_z(), BeamSpotOnline::err_x(), BeamSpotOnline::err_y(), BeamSpotOnline::err_z(), f, edm::EventSetup::getData(), edm::EventSetup::getHandle(), L1GlobalTriggerEvmReadoutRecord::gtfeWord(), mps_fire::i, iEvent, dqmiolumiharvest::j, l1GtEvmReadoutRecordToken_, reco::BeamSpot::LHC, makeMuonMisalignmentScenario::matrix, eostools::move(), edm::ESHandle< T >::product(), diffTwoXMLs::r2, mps_fire::result, scalerToken_, BeamSpotOnline::sigma_z(), beamSpotPI::sigmaZ, BeamSpotObjects::sigmaZ(), theBeamShoutMode, theMaxR2, theMaxZ, theSetSigmaZ, reco::BeamSpot::Tracker, useTransientRecord_, BeamSpotOnline::width_x(), BeamSpotOnline::width_y(), BeamSpotOnline::x(), BeamSpotObjects::x(), BeamSpotOnline::y(), BeamSpotObjects::y(), BeamSpotOnline::z(), and BeamSpotObjects::z().

90  {
91  // product is a reco::BeamSpot object
92  auto result = std::make_unique<reco::BeamSpot>();
93  reco::BeamSpot aSpot;
94  //shout MODE only in stable beam
95  bool shoutMODE = false;
97  if (iEvent.getByToken(l1GtEvmReadoutRecordToken_, gtEvmReadoutRecord)) {
98  if (gtEvmReadoutRecord->gtfeWord().beamMode() == theBeamShoutMode)
99  shoutMODE = true;
100  } else {
101  shoutMODE = true;
102  }
103  bool fallBackToDB = false;
104  if (useTransientRecord_) {
105  auto const& spotDB = iSetup.getData(beamTransientToken_);
106  if (spotDB.beamType() != 2) {
107  if (shoutMODE && beamTransientRcdESWatcher_.check(iSetup)) {
108  edm::LogWarning("BeamSpotOnlineProducer")
109  << "Online Beam Spot producer falls back to DB value because the ESProducer returned a fake beamspot ";
110  }
111  fallBackToDB = true;
112  } else {
113  // translate from BeamSpotObjects to reco::BeamSpot
114  // in case we need to switch to LHC reference frame
115  // ignore for the moment rotations, and translations
116  double f = 1.;
117  if (changeFrame_)
118  f = -1.;
119  reco::BeamSpot::Point apoint(f * spotDB.x(), f * spotDB.y(), f * spotDB.z());
120 
122  for (int i = 0; i < 7; ++i) {
123  for (int j = 0; j < 7; ++j) {
124  matrix(i, j) = spotDB.covariance(i, j);
125  }
126  }
127  double sigmaZ = spotDB.sigmaZ();
128  if (theSetSigmaZ > 0)
130 
131  // this assume beam width same in x and y
132  aSpot = reco::BeamSpot(apoint, sigmaZ, spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
133  aSpot.setBeamWidthY(spotDB.beamWidthY());
134  aSpot.setEmittanceX(spotDB.emittanceX());
135  aSpot.setEmittanceY(spotDB.emittanceY());
136  aSpot.setbetaStar(spotDB.betaStar());
137  aSpot.setType(reco::BeamSpot::Tracker);
138  }
139  } else {
140  // get scalar collection
142  iEvent.getByToken(scalerToken_, handleScaler);
143 
144  // beam spot scalar object
145  BeamSpotOnline spotOnline;
146 
147  // product is a reco::BeamSpot object
148  auto result = std::make_unique<reco::BeamSpot>();
149 
150  if (!handleScaler->empty()) {
151  // get one element
152  spotOnline = *(handleScaler->begin());
153 
154  // in case we need to switch to LHC reference frame
155  // ignore for the moment rotations, and translations
156  double f = 1.;
157  if (changeFrame_)
158  f = -1.;
159 
160  reco::BeamSpot::Point apoint(f * spotOnline.x(), spotOnline.y(), f * spotOnline.z());
161 
163  matrix(0, 0) = spotOnline.err_x() * spotOnline.err_x();
164  matrix(1, 1) = spotOnline.err_y() * spotOnline.err_y();
165  matrix(2, 2) = spotOnline.err_z() * spotOnline.err_z();
166  matrix(3, 3) = spotOnline.err_sigma_z() * spotOnline.err_sigma_z();
167 
168  double sigmaZ = spotOnline.sigma_z();
169  if (theSetSigmaZ > 0)
171 
172  aSpot = reco::BeamSpot(apoint, sigmaZ, spotOnline.dxdz(), f * spotOnline.dydz(), spotOnline.width_x(), matrix);
173 
174  aSpot.setBeamWidthY(spotOnline.width_y());
175  aSpot.setEmittanceX(0.);
176  aSpot.setEmittanceY(0.);
177  aSpot.setbetaStar(0.);
178  aSpot.setType(reco::BeamSpot::LHC); // flag value from scalars
179 
180  // check if we have a valid beam spot fit result from online DQM
181  if (spotOnline.x() == 0 && spotOnline.y() == 0 && spotOnline.z() == 0 && spotOnline.width_x() == 0 &&
182  spotOnline.width_y() == 0) {
183  if (shoutMODE) {
184  edm::LogWarning("BeamSpotOnlineProducer")
185  << "Online Beam Spot producer falls back to DB value because the scaler values are zero ";
186  }
187  fallBackToDB = true;
188  }
189  double r2 = spotOnline.x() * spotOnline.x() + spotOnline.y() * spotOnline.y();
190  if (std::abs(spotOnline.z()) >= theMaxZ || r2 >= theMaxR2) {
191  if (shoutMODE) {
192  edm::LogError("BeamSpotOnlineProducer")
193  << "Online Beam Spot producer falls back to DB value because the scaler values are too big to be true :"
194  << spotOnline.x() << " " << spotOnline.y() << " " << spotOnline.z();
195  }
196  fallBackToDB = true;
197  }
198  } else {
199  //empty online beamspot collection: FED data was empty
200  //the error should probably have been send at unpacker level
201  fallBackToDB = true;
202  }
203  }
204  if (fallBackToDB) {
206  const BeamSpotObjects* spotDB = beamhandle.product();
207 
208  // translate from BeamSpotObjects to reco::BeamSpot
209  reco::BeamSpot::Point apoint(spotDB->x(), spotDB->y(), spotDB->z());
210 
212  for (int i = 0; i < 7; ++i) {
213  for (int j = 0; j < 7; ++j) {
214  matrix(i, j) = spotDB->covariance(i, j);
215  }
216  }
217 
218  // this assume beam width same in x and y
219  aSpot = reco::BeamSpot(apoint, spotDB->sigmaZ(), spotDB->dxdz(), spotDB->dydz(), spotDB->beamWidthX(), matrix);
220  aSpot.setBeamWidthY(spotDB->beamWidthY());
221  aSpot.setEmittanceX(spotDB->emittanceX());
222  aSpot.setEmittanceY(spotDB->emittanceY());
223  aSpot.setbetaStar(spotDB->betaStar());
224  aSpot.setType(reco::BeamSpot::Tracker);
225  }
226 
227  *result = aSpot;
228 
229  iEvent.put(std::move(result));
230 }
double emittanceX() const
get emittance
float err_y() const
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
float z() const
double z() const
get Z beam position
const edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcd > beamTransientToken_
const cms_uint16_t beamMode() const
float dydz() const
double dydz() const
get dydz slope, crossing angle in YZ
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
double covariance(int i, int j) const
get i,j element of the full covariance matrix 7x7
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > l1GtEvmReadoutRecordToken_
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalerToken_
float y() const
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
float err_x() const
float err_z() const
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
double beamWidthX() const
get average transverse beam width
Log< level::Error, false > LogError
float err_sigma_z() const
float dxdz() const
float width_x() const
const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > beamToken_
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
float sigma_z() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double x() const
get X beam position
double f[11][100]
edm::ESWatcher< BeamSpotTransientObjectsRcd > beamTransientRcdESWatcher_
const unsigned int theBeamShoutMode
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
double beamWidthY() const
get average transverse beam width
float width_y() const
double y() const
get Y beam position
double sigmaZ() const
get sigma Z, RMS bunch length
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
double emittanceY() const
get emittance
double betaStar() const
get beta star
Log< level::Warning, false > LogWarning
double dxdz() const
get dxdz slope, crossing angle in XZ
def move(src, dest)
Definition: eostools.py:511
float x() const

Member Data Documentation

◆ beamToken_

const edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> BeamSpotOnlineProducer::beamToken_
private

Definition at line 49 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ beamTransientRcdESWatcher_

edm::ESWatcher<BeamSpotTransientObjectsRcd> BeamSpotOnlineProducer::beamTransientRcdESWatcher_
private

Definition at line 53 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ beamTransientToken_

const edm::ESGetToken<BeamSpotObjects, BeamSpotTransientObjectsRcd> BeamSpotOnlineProducer::beamTransientToken_
private

Definition at line 50 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ changeFrame_

const bool BeamSpotOnlineProducer::changeFrame_
private

Definition at line 43 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ l1GtEvmReadoutRecordToken_

const edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> BeamSpotOnlineProducer::l1GtEvmReadoutRecordToken_
private

Definition at line 48 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ scalerToken_

const edm::EDGetTokenT<BeamSpotOnlineCollection> BeamSpotOnlineProducer::scalerToken_
private

Definition at line 47 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ theBeamShoutMode

const unsigned int BeamSpotOnlineProducer::theBeamShoutMode
private

Definition at line 55 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ theMaxR2

double BeamSpotOnlineProducer::theMaxR2
private

Definition at line 45 of file BeamSpotOnlineProducer.cc.

Referenced by BeamSpotOnlineProducer(), and produce().

◆ theMaxZ

const double BeamSpotOnlineProducer::theMaxZ
private

Definition at line 44 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ theSetSigmaZ

const double BeamSpotOnlineProducer::theSetSigmaZ
private

Definition at line 44 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ useTransientRecord_

const bool BeamSpotOnlineProducer::useTransientRecord_
private

Definition at line 46 of file BeamSpotOnlineProducer.cc.

Referenced by produce().