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 32 of file BeamSpotOnlineProducer.cc.

Constructor & Destructor Documentation

◆ BeamSpotOnlineProducer()

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

constructor

Definition at line 61 of file BeamSpotOnlineProducer.cc.

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

62  : changeFrame_(iconf.getParameter<bool>("changeToCMSCoordinates")),
63  theMaxZ(iconf.getParameter<double>("maxZ")),
64  theSetSigmaZ(iconf.getParameter<double>("setSigmaZ")),
65  useTransientRecord_(iconf.getParameter<bool>("useTransientRecord")),
67  : consumes<BeamSpotOnlineCollection>(iconf.getParameter<InputTag>("src"))),
68  l1GtEvmReadoutRecordToken_(consumes<L1GlobalTriggerEvmReadoutRecord>(iconf.getParameter<InputTag>("gtEvmLabel"))),
69  beamToken_(esConsumes<BeamSpotObjects, BeamSpotObjectsRcd>()),
70  beamTransientToken_(esConsumes<BeamSpotObjects, BeamSpotTransientObjectsRcd>()),
71  theBeamShoutMode(iconf.getUntrackedParameter<unsigned int>("beamMode", 11)) {
72  theMaxR2 = iconf.getParameter<double>("maxRadius");
73  theMaxR2 *= theMaxR2;
74 
75  produces<reco::BeamSpot>();
76 }
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 78 of file BeamSpotOnlineProducer.cc.

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

78  {
80  ps.add<bool>("changeToCMSCoordinates", false);
81  ps.add<double>("maxZ", 40.);
82  ps.add<double>("setSigmaZ", -1.);
83  ps.addUntracked<unsigned int>("beamMode", 11);
84  ps.addOptional<InputTag>("src", InputTag("hltScalersRawToDigi"))->setComment("SCAL decommissioned after Run 2");
85  ps.add<InputTag>("gtEvmLabel", InputTag(""));
86  ps.add<double>("maxRadius", 2.0);
87  ps.add<bool>("useTransientRecord", false);
88  iDesc.addWithDefaultLabel(ps);
89 }
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 91 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(), reco::BeamSpot::dimension, 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().

91  {
92  // product is a reco::BeamSpot object
93  auto result = std::make_unique<reco::BeamSpot>();
94  reco::BeamSpot aSpot;
95  //shout MODE only in stable beam
96  bool shoutMODE = false;
98  if (iEvent.getByToken(l1GtEvmReadoutRecordToken_, gtEvmReadoutRecord)) {
99  if (gtEvmReadoutRecord->gtfeWord().beamMode() == theBeamShoutMode)
100  shoutMODE = true;
101  } else {
102  shoutMODE = true;
103  }
104  bool fallBackToDB = false;
105  if (useTransientRecord_) {
106  auto const& spotDB = iSetup.getData(beamTransientToken_);
107  if (spotDB.beamType() != 2) {
108  if (shoutMODE && beamTransientRcdESWatcher_.check(iSetup)) {
109  edm::LogWarning("BeamSpotOnlineProducer")
110  << "Online Beam Spot producer falls back to DB value because the ESProducer returned a fake beamspot ";
111  }
112  fallBackToDB = true;
113  } else {
114  // translate from BeamSpotObjects to reco::BeamSpot
115  // in case we need to switch to LHC reference frame
116  // ignore for the moment rotations, and translations
117  double f = 1.;
118  if (changeFrame_)
119  f = -1.;
120  reco::BeamSpot::Point apoint(f * spotDB.x(), f * spotDB.y(), f * spotDB.z());
121 
123  for (int i = 0; i < reco::BeamSpot::dimension; ++i) {
124  for (int j = 0; j < reco::BeamSpot::dimension; ++j) {
125  matrix(i, j) = spotDB.covariance(i, j);
126  }
127  }
128  double sigmaZ = spotDB.sigmaZ();
129  if (theSetSigmaZ > 0)
131 
132  // this assume beam width same in x and y
133  aSpot = reco::BeamSpot(apoint, sigmaZ, spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
134  aSpot.setBeamWidthY(spotDB.beamWidthY());
135  aSpot.setEmittanceX(spotDB.emittanceX());
136  aSpot.setEmittanceY(spotDB.emittanceY());
137  aSpot.setbetaStar(spotDB.betaStar());
138  aSpot.setType(reco::BeamSpot::Tracker);
139  }
140  } else {
141  // get scalar collection
143  iEvent.getByToken(scalerToken_, handleScaler);
144 
145  // beam spot scalar object
146  BeamSpotOnline spotOnline;
147 
148  // product is a reco::BeamSpot object
149  auto result = std::make_unique<reco::BeamSpot>();
150 
151  if (!handleScaler->empty()) {
152  // get one element
153  spotOnline = *(handleScaler->begin());
154 
155  // in case we need to switch to LHC reference frame
156  // ignore for the moment rotations, and translations
157  double f = 1.;
158  if (changeFrame_)
159  f = -1.;
160 
161  reco::BeamSpot::Point apoint(f * spotOnline.x(), spotOnline.y(), f * spotOnline.z());
162 
164  matrix(0, 0) = spotOnline.err_x() * spotOnline.err_x();
165  matrix(1, 1) = spotOnline.err_y() * spotOnline.err_y();
166  matrix(2, 2) = spotOnline.err_z() * spotOnline.err_z();
167  matrix(3, 3) = spotOnline.err_sigma_z() * spotOnline.err_sigma_z();
168 
169  double sigmaZ = spotOnline.sigma_z();
170  if (theSetSigmaZ > 0)
172 
173  aSpot = reco::BeamSpot(apoint, sigmaZ, spotOnline.dxdz(), f * spotOnline.dydz(), spotOnline.width_x(), matrix);
174 
175  aSpot.setBeamWidthY(spotOnline.width_y());
176  aSpot.setEmittanceX(0.);
177  aSpot.setEmittanceY(0.);
178  aSpot.setbetaStar(0.);
179  aSpot.setType(reco::BeamSpot::LHC); // flag value from scalars
180 
181  // check if we have a valid beam spot fit result from online DQM
182  if (spotOnline.x() == 0 && spotOnline.y() == 0 && spotOnline.z() == 0 && spotOnline.width_x() == 0 &&
183  spotOnline.width_y() == 0) {
184  if (shoutMODE) {
185  edm::LogWarning("BeamSpotOnlineProducer")
186  << "Online Beam Spot producer falls back to DB value because the scaler values are zero ";
187  }
188  fallBackToDB = true;
189  }
190  double r2 = spotOnline.x() * spotOnline.x() + spotOnline.y() * spotOnline.y();
191  if (std::abs(spotOnline.z()) >= theMaxZ || r2 >= theMaxR2) {
192  if (shoutMODE) {
193  edm::LogError("BeamSpotOnlineProducer")
194  << "Online Beam Spot producer falls back to DB value because the scaler values are too big to be true :"
195  << spotOnline.x() << " " << spotOnline.y() << " " << spotOnline.z();
196  }
197  fallBackToDB = true;
198  }
199  } else {
200  //empty online beamspot collection: FED data was empty
201  //the error should probably have been send at unpacker level
202  fallBackToDB = true;
203  }
204  }
205  if (fallBackToDB) {
207  const BeamSpotObjects* spotDB = beamhandle.product();
208 
209  // translate from BeamSpotObjects to reco::BeamSpot
210  reco::BeamSpot::Point apoint(spotDB->x(), spotDB->y(), spotDB->z());
211 
213  for (int i = 0; i < reco::BeamSpot::dimension; ++i) {
214  for (int j = 0; j < reco::BeamSpot::dimension; ++j) {
215  matrix(i, j) = spotDB->covariance(i, j);
216  }
217  }
218 
219  // this assume beam width same in x and y
220  aSpot = reco::BeamSpot(apoint, spotDB->sigmaZ(), spotDB->dxdz(), spotDB->dydz(), spotDB->beamWidthX(), matrix);
221  aSpot.setBeamWidthY(spotDB->beamWidthY());
222  aSpot.setEmittanceX(spotDB->emittanceX());
223  aSpot.setEmittanceY(spotDB->emittanceY());
224  aSpot.setbetaStar(spotDB->betaStar());
225  aSpot.setType(reco::BeamSpot::Tracker);
226 
227  GlobalError bse(aSpot.rotatedCovariance3D());
228  if ((bse.cxx() <= 0.) || (bse.cyy() <= 0.) || (bse.czz() <= 0.)) {
229  edm::LogError("UnusableBeamSpot") << "Beamspot from fallback to DB with invalid errors: " << aSpot.covariance();
230  }
231  }
232 
233  *result = aSpot;
234 
235  iEvent.put(std::move(result));
236 }
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 50 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ beamTransientRcdESWatcher_

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

Definition at line 54 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ beamTransientToken_

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

Definition at line 51 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ changeFrame_

const bool BeamSpotOnlineProducer::changeFrame_
private

Definition at line 44 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ l1GtEvmReadoutRecordToken_

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

Definition at line 49 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ scalerToken_

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

Definition at line 48 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ theBeamShoutMode

const unsigned int BeamSpotOnlineProducer::theBeamShoutMode
private

Definition at line 56 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ theMaxR2

double BeamSpotOnlineProducer::theMaxR2
private

Definition at line 46 of file BeamSpotOnlineProducer.cc.

Referenced by BeamSpotOnlineProducer(), and produce().

◆ theMaxZ

const double BeamSpotOnlineProducer::theMaxZ
private

Definition at line 45 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ theSetSigmaZ

const double BeamSpotOnlineProducer::theSetSigmaZ
private

Definition at line 45 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ useTransientRecord_

const bool BeamSpotOnlineProducer::useTransientRecord_
private

Definition at line 47 of file BeamSpotOnlineProducer.cc.

Referenced by produce().