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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

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

Private Attributes

const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcdbeamToken_
 
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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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 30 of file BeamSpotOnlineProducer.cc.

Constructor & Destructor Documentation

◆ BeamSpotOnlineProducer()

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

constructor

Definition at line 56 of file BeamSpotOnlineProducer.cc.

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

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

Member Function Documentation

◆ fillDescriptions()

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

Fill descriptor.

Definition at line 72 of file BeamSpotOnlineProducer.cc.

72  {
74  ps.add<bool>("changeToCMSCoordinates", false);
75  ps.add<double>("maxZ", 40.);
76  ps.add<double>("setSigmaZ", -1.);
77  ps.addUntracked<unsigned int>("beamMode", 11);
78  ps.add<InputTag>("src", InputTag("hltScalersRawToDigi"));
79  ps.add<InputTag>("gtEvmLabel", InputTag(""));
80  ps.add<double>("maxRadius", 2.0);
81  ps.add<bool>("useTransientRecord", false);
82  iDesc.addWithDefaultLabel(ps);
83 }

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

◆ produce()

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

produce a beam spot class

Definition at line 85 of file BeamSpotOnlineProducer.cc.

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

References funct::abs(), L1GtfeExtWord::beamMode(), align::BeamSpot, beamToken_, beamTransientToken_, changeFrame_, BeamSpotOnline::dxdz(), BeamSpotOnline::dydz(), BeamSpotOnline::err_sigma_z(), BeamSpotOnline::err_x(), BeamSpotOnline::err_y(), BeamSpotOnline::err_z(), f, BeamSpotObjects::GetBeamWidthX(), BeamSpotObjects::GetBeamWidthY(), BeamSpotObjects::GetBetaStar(), BeamSpotObjects::GetCovariance(), edm::EventSetup::getData(), BeamSpotObjects::Getdxdz(), BeamSpotObjects::Getdydz(), BeamSpotObjects::GetEmittanceX(), BeamSpotObjects::GetEmittanceY(), edm::EventSetup::getHandle(), BeamSpotObjects::GetSigmaZ(), BeamSpotObjects::GetX(), BeamSpotObjects::GetY(), BeamSpotObjects::GetZ(), 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_, reco::BeamSpot::setBeamWidthY(), reco::BeamSpot::setbetaStar(), reco::BeamSpot::setEmittanceX(), reco::BeamSpot::setEmittanceY(), reco::BeamSpot::setType(), BeamSpotOnline::sigma_z(), BeamSpotPI::sigmaZ, theBeamShoutMode, theMaxR2, theMaxZ, theSetSigmaZ, reco::BeamSpot::Tracker, useTransientRecord_, BeamSpotOnline::width_x(), BeamSpotOnline::width_y(), BeamSpotOnline::x(), BeamSpotOnline::y(), and BeamSpotOnline::z().

Member Data Documentation

◆ beamToken_

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

Definition at line 48 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ beamTransientToken_

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

Definition at line 49 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ changeFrame_

const bool BeamSpotOnlineProducer::changeFrame_
private

Definition at line 42 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ l1GtEvmReadoutRecordToken_

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

Definition at line 47 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ scalerToken_

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

Definition at line 46 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ theBeamShoutMode

const unsigned int BeamSpotOnlineProducer::theBeamShoutMode
private

Definition at line 51 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ theMaxR2

double BeamSpotOnlineProducer::theMaxR2
private

Definition at line 44 of file BeamSpotOnlineProducer.cc.

Referenced by BeamSpotOnlineProducer(), and produce().

◆ theMaxZ

const double BeamSpotOnlineProducer::theMaxZ
private

Definition at line 43 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ theSetSigmaZ

const double BeamSpotOnlineProducer::theSetSigmaZ
private

Definition at line 43 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

◆ useTransientRecord_

const bool BeamSpotOnlineProducer::useTransientRecord_
private

Definition at line 45 of file BeamSpotOnlineProducer.cc.

Referenced by produce().

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:48
mps_fire.i
i
Definition: mps_fire.py:428
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
reco::BeamSpot::setBeamWidthY
void setBeamWidthY(double v)
Definition: BeamSpot.h:105
BeamSpotPI::sigmaZ
Definition: BeamSpotPayloadInspectorHelper.h:36
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
align::BeamSpot
Definition: StructureType.h:95
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
BeamSpotObjects::GetSigmaZ
double GetSigmaZ() const
get sigma Z, RMS bunch length
Definition: BeamSpotObjects.h:73
L1GlobalTriggerEvmReadoutRecord::gtfeWord
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
Definition: L1GlobalTriggerEvmReadoutRecord.cc:249
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
BeamSpotObjects::GetZ
double GetZ() const
get Z beam position
Definition: BeamSpotObjects.h:71
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
BeamSpotOnline::dydz
float dydz() const
Definition: BeamSpotOnline.h:52
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
BeamSpotOnlineProducer::useTransientRecord_
const bool useTransientRecord_
Definition: BeamSpotOnlineProducer.cc:45
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
BeamSpotOnlineProducer::theMaxR2
double theMaxR2
Definition: BeamSpotOnlineProducer.cc:44
BeamSpotOnline::err_x
float err_x() const
Definition: BeamSpotOnline.h:53
BeamSpotOnlineProducer::changeFrame_
const bool changeFrame_
Definition: BeamSpotOnlineProducer.cc:42
BeamSpotOnline::sigma_z
float sigma_z() const
Definition: BeamSpotOnline.h:60
reco::BeamSpot
Definition: BeamSpot.h:21
BeamSpotOnlineProducer::beamTransientToken_
const edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcd > beamTransientToken_
Definition: BeamSpotOnlineProducer.cc:49
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:43
BeamSpotObjects::GetBetaStar
double GetBetaStar() const
get beta star
Definition: BeamSpotObjects.h:107
BeamSpotObjects::GetEmittanceX
double GetEmittanceX() const
get emittance
Definition: BeamSpotObjects.h:103
BeamSpotObjects::GetY
double GetY() const
get Y beam position
Definition: BeamSpotObjects.h:69
reco::BeamSpot::setbetaStar
void setbetaStar(double v)
Definition: BeamSpot.h:138
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
BeamSpotObjects
Definition: BeamSpotObjects.h:20
reco::BeamSpot::CovarianceMatrix
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
BeamSpotOnlineProducer::scalerToken_
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalerToken_
Definition: BeamSpotOnlineProducer.cc:46
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
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:47
BeamSpotOnlineProducer::theMaxZ
const double theMaxZ
Definition: BeamSpotOnlineProducer.cc:43
mps_fire.result
result
Definition: mps_fire.py:311
reco::BeamSpot::Point
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
BeamSpotOnlineProducer::theBeamShoutMode
const unsigned int theBeamShoutMode
Definition: BeamSpotOnlineProducer.cc:51
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
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
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87