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")),
65  scalerToken_(consumes<BeamSpotOnlineCollection>(iconf.getParameter<InputTag>("src"))),
66  l1GtEvmReadoutRecordToken_(consumes<L1GlobalTriggerEvmReadoutRecord>(iconf.getParameter<InputTag>("gtEvmLabel"))),
67  beamToken_(esConsumes<BeamSpotObjects, BeamSpotObjectsRcd>()),
68  beamTransientToken_(esConsumes<BeamSpotObjects, BeamSpotTransientObjectsRcd>()),
69  theBeamShoutMode(iconf.getUntrackedParameter<unsigned int>("beamMode", 11)) {
70  theMaxR2 = iconf.getParameter<double>("maxRadius");
71  theMaxR2 *= theMaxR2;
72 
73  produces<reco::BeamSpot>();
74 }
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 76 of file BeamSpotOnlineProducer.cc.

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

76  {
78  ps.add<bool>("changeToCMSCoordinates", false);
79  ps.add<double>("maxZ", 40.);
80  ps.add<double>("setSigmaZ", -1.);
81  ps.addUntracked<unsigned int>("beamMode", 11);
82  ps.add<InputTag>("src", InputTag("hltScalersRawToDigi"));
83  ps.add<InputTag>("gtEvmLabel", InputTag(""));
84  ps.add<double>("maxRadius", 2.0);
85  ps.add<bool>("useTransientRecord", false);
86  iDesc.addWithDefaultLabel(ps);
87 }
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 89 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().

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