CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
BeamSpotOnlineProducer Class Reference

#include <BeamSpotOnlineProducer.h>

Inheritance diagram for BeamSpotOnlineProducer:
edm::stream::EDProducer<>

Public Types

typedef std::vector< edm::ParameterSetParameters
 
- 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
 

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...
 
 ~BeamSpotOnlineProducer () override
 destructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

const bool changeFrame_
 
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecordl1GtEvmReadoutRecordToken_
 
const edm::EDGetTokenT< BeamSpotOnlineCollectionscalerToken_
 
const unsigned int theBeamShoutMode
 
double theMaxR2
 
const double theMaxZ
 
const double theSetSigmaZ
 

Detailed Description


class: BeamSpotOnlineProducer.h package: RecoVertex/BeamSpotProducer

author: Francisco Yumiceva, Fermilab (yumic.nosp@m.eva@.nosp@m.fnal..nosp@m.gov)


Definition at line 23 of file BeamSpotOnlineProducer.h.

Member Typedef Documentation

Definition at line 25 of file BeamSpotOnlineProducer.h.

Constructor & Destructor Documentation

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

constructor

Definition at line 15 of file BeamSpotOnlineProducer.cc.

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

16  : changeFrame_(iconf.getParameter<bool>("changeToCMSCoordinates")),
17  theMaxZ(iconf.getParameter<double>("maxZ")),
18  theSetSigmaZ(iconf.getParameter<double>("setSigmaZ")),
19  scalerToken_(consumes<BeamSpotOnlineCollection>(iconf.getParameter<InputTag>("src"))),
20  l1GtEvmReadoutRecordToken_(consumes<L1GlobalTriggerEvmReadoutRecord>(iconf.getParameter<InputTag>("gtEvmLabel"))),
21  theBeamShoutMode(iconf.getUntrackedParameter<unsigned int>("beamMode", 11)) {
22  theMaxR2 = iconf.getParameter<double>("maxRadius");
23  theMaxR2 *= theMaxR2;
24 
25  produces<reco::BeamSpot>();
26 }
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > l1GtEvmReadoutRecordToken_
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalerToken_
const unsigned int theBeamShoutMode
BeamSpotOnlineProducer::~BeamSpotOnlineProducer ( )
override

destructor

Definition at line 28 of file BeamSpotOnlineProducer.cc.

28 {}

Member Function Documentation

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

produce a beam spot class

Definition at line 30 of file BeamSpotOnlineProducer.cc.

References L1GtfeExtWord::beamMode(), align::BeamSpot, changeFrame_, DEFINE_FWK_MODULE, BeamSpotOnline::dxdz(), BeamSpotOnline::dydz(), BeamSpotOnline::err_sigma_z(), BeamSpotOnline::err_x(), BeamSpotOnline::err_y(), BeamSpotOnline::err_z(), f, edm::EventSetup::get(), BeamSpotObjects::GetBeamWidthX(), BeamSpotObjects::GetBeamWidthY(), BeamSpotObjects::GetBetaStar(), edm::Event::getByToken(), BeamSpotObjects::GetCovariance(), BeamSpotObjects::Getdxdz(), BeamSpotObjects::Getdydz(), BeamSpotObjects::GetEmittanceX(), BeamSpotObjects::GetEmittanceY(), BeamSpotObjects::GetSigmaZ(), BeamSpotObjects::GetX(), BeamSpotObjects::GetY(), BeamSpotObjects::GetZ(), L1GlobalTriggerEvmReadoutRecord::gtfeWord(), mps_fire::i, dqmiolumiharvest::j, l1GtEvmReadoutRecordToken_, reco::BeamSpot::LHC, makeMuonMisalignmentScenario::matrix, eostools::move(), edm::ESHandle< T >::product(), edm::Event::put(), diffTwoXMLs::r2, mps_fire::result, scalerToken_, BeamSpotOnline::sigma_z(), fftjetvertexadder_cfi::sigmaZ, theBeamShoutMode, theMaxR2, theMaxZ, theSetSigmaZ, reco::BeamSpot::Tracker, BeamSpotOnline::width_x(), BeamSpotOnline::width_y(), BeamSpotOnline::x(), BeamSpotOnline::y(), and BeamSpotOnline::z().

30  {
31  //shout MODE only in stable beam
32  bool shoutMODE = false;
34  if (iEvent.getByToken(l1GtEvmReadoutRecordToken_, gtEvmReadoutRecord)) {
35  if (gtEvmReadoutRecord->gtfeWord().beamMode() == theBeamShoutMode)
36  shoutMODE = true;
37  } else {
38  shoutMODE = true;
39  }
40 
41  // get scalar collection
43  iEvent.getByToken(scalerToken_, handleScaler);
44 
45  // beam spot scalar object
46  BeamSpotOnline spotOnline;
47 
48  // product is a reco::BeamSpot object
49  auto result = std::make_unique<reco::BeamSpot>();
50 
51  reco::BeamSpot aSpot;
52 
53  bool fallBackToDB = false;
54  if (!handleScaler->empty()) {
55  // get one element
56  spotOnline = *(handleScaler->begin());
57 
58  // in case we need to switch to LHC reference frame
59  // ignore for the moment rotations, and translations
60  double f = 1.;
61  if (changeFrame_)
62  f = -1.;
63 
64  reco::BeamSpot::Point apoint(f * spotOnline.x(), spotOnline.y(), f * spotOnline.z());
65 
67  matrix(0, 0) = spotOnline.err_x() * spotOnline.err_x();
68  matrix(1, 1) = spotOnline.err_y() * spotOnline.err_y();
69  matrix(2, 2) = spotOnline.err_z() * spotOnline.err_z();
70  matrix(3, 3) = spotOnline.err_sigma_z() * spotOnline.err_sigma_z();
71 
72  double sigmaZ = spotOnline.sigma_z();
73  if (theSetSigmaZ > 0)
74  sigmaZ = theSetSigmaZ;
75 
76  aSpot = reco::BeamSpot(apoint, sigmaZ, spotOnline.dxdz(), f * spotOnline.dydz(), spotOnline.width_x(), matrix);
77 
78  aSpot.setBeamWidthY(spotOnline.width_y());
79  aSpot.setEmittanceX(0.);
80  aSpot.setEmittanceY(0.);
81  aSpot.setbetaStar(0.);
82  aSpot.setType(reco::BeamSpot::LHC); // flag value from scalars
83 
84  // check if we have a valid beam spot fit result from online DQM
85  if (spotOnline.x() == 0 && spotOnline.y() == 0 && spotOnline.z() == 0 && spotOnline.width_x() == 0 &&
86  spotOnline.width_y() == 0) {
87  if (shoutMODE) {
88  edm::LogWarning("BeamSpotFromDB")
89  << "Online Beam Spot producer falls back to DB value because the scaler values are zero ";
90  }
91  fallBackToDB = true;
92  }
93  double r2 = spotOnline.x() * spotOnline.x() + spotOnline.y() * spotOnline.y();
94  if (fabs(spotOnline.z()) >= theMaxZ || r2 >= theMaxR2) {
95  if (shoutMODE) {
96  edm::LogError("BeamSpotFromDB")
97  << "Online Beam Spot producer falls back to DB value because the scaler values are too big to be true :"
98  << spotOnline.x() << " " << spotOnline.y() << " " << spotOnline.z();
99  }
100  fallBackToDB = true;
101  }
102  } else {
103  //empty online beamspot collection: FED data was empty
104  //the error should probably have been send at unpacker level
105  fallBackToDB = true;
106  }
107 
108  if (fallBackToDB) {
110  iSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
111  const BeamSpotObjects* spotDB = beamhandle.product();
112 
113  // translate from BeamSpotObjects to reco::BeamSpot
114  reco::BeamSpot::Point apoint(spotDB->GetX(), spotDB->GetY(), 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 
123  // this assume beam width same in x and y
124  aSpot = reco::BeamSpot(
125  apoint, spotDB->GetSigmaZ(), spotDB->Getdxdz(), spotDB->Getdydz(), spotDB->GetBeamWidthX(), matrix);
126  aSpot.setBeamWidthY(spotDB->GetBeamWidthY());
127  aSpot.setEmittanceX(spotDB->GetEmittanceX());
128  aSpot.setEmittanceY(spotDB->GetEmittanceY());
129  aSpot.setbetaStar(spotDB->GetBetaStar());
130  aSpot.setType(reco::BeamSpot::Tracker);
131  }
132 
133  *result = aSpot;
134 
135  iEvent.put(std::move(result));
136 }
double Getdydz() const
get dydz slope, crossing angle in YZ
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
float err_y() const
float dxdz() const
double GetY() const
get Y beam position
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > l1GtEvmReadoutRecordToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
float err_x() const
float dydz() const
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
float sigma_z() const
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalerToken_
float y() const
float x() const
double GetSigmaZ() const
get sigma Z, RMS bunch length
double GetBeamWidthX() const
get average transverse beam width
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
float z() const
float width_y() const
double GetBeamWidthY() const
get average transverse beam width
double GetEmittanceX() const
get emittance
double GetZ() const
get Z beam position
double f[11][100]
const unsigned int theBeamShoutMode
double Getdxdz() const
get dxdz slope, crossing angle in XZ
float err_z() const
double GetX() const
get X beam position
double GetBetaStar() const
get beta star
double GetCovariance(int i, int j) const
get i,j element of the full covariance matrix 7x7
T get() const
Definition: EventSetup.h:73
float width_x() const
double GetEmittanceY() const
get emittance
float err_sigma_z() const
const cms_uint16_t beamMode() const
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

const bool BeamSpotOnlineProducer::changeFrame_
private

Definition at line 36 of file BeamSpotOnlineProducer.h.

Referenced by produce().

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

Definition at line 40 of file BeamSpotOnlineProducer.h.

Referenced by produce().

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

Definition at line 39 of file BeamSpotOnlineProducer.h.

Referenced by produce().

const unsigned int BeamSpotOnlineProducer::theBeamShoutMode
private

Definition at line 42 of file BeamSpotOnlineProducer.h.

Referenced by produce().

double BeamSpotOnlineProducer::theMaxR2
private

Definition at line 38 of file BeamSpotOnlineProducer.h.

Referenced by BeamSpotOnlineProducer(), and produce().

const double BeamSpotOnlineProducer::theMaxZ
private

Definition at line 37 of file BeamSpotOnlineProducer.h.

Referenced by produce().

const double BeamSpotOnlineProducer::theSetSigmaZ
private

Definition at line 37 of file BeamSpotOnlineProducer.h.

Referenced by produce().