CMS 3D CMS Logo

BeamSpotOnlineProducer.cc
Go to the documentation of this file.
1 
4 
10 
12 
13 using namespace edm;
14 
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 }
27 
29 
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)
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());
131  }
132 
133  *result = aSpot;
134 
135  iEvent.put(std::move(result));
136 }
137 
BeamSpotOnlineProducer.h
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
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
reco::BeamSpot::setBeamWidthY
void setBeamWidthY(double v)
Definition: BeamSpot.h:105
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
ESHandle.h
align::BeamSpot
Definition: StructureType.h:89
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
edm
HLT enums.
Definition: AlignableModifier.h:19
L1GlobalTriggerEvmReadoutRecord::gtfeWord
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
Definition: L1GlobalTriggerEvmReadoutRecord.cc:249
BeamSpotObjects::GetZ
double GetZ() const
get Z beam position
Definition: BeamSpotObjects.h:71
BeamSpotOnlineProducer::~BeamSpotOnlineProducer
~BeamSpotOnlineProducer() override
destructor
Definition: BeamSpotOnlineProducer.cc:28
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
edm::Handle
Definition: AssociativeIterator.h:50
BeamSpotOnlineProducer::theMaxR2
double theMaxR2
Definition: BeamSpotOnlineProducer.h:38
MakerMacros.h
BeamSpotOnline::err_x
float err_x() const
Definition: BeamSpotOnline.h:53
BeamSpotObjects.h
BeamSpotOnlineProducer
Definition: BeamSpotOnlineProducer.h:23
BeamSpotObjectsRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpot.h
BeamSpotOnlineProducer::changeFrame_
const bool changeFrame_
Definition: BeamSpotOnlineProducer.h:36
L1GlobalTriggerEvmReadoutRecord
Definition: L1GlobalTriggerEvmReadoutRecord.h:36
BeamSpotOnline::sigma_z
float sigma_z() const
Definition: BeamSpotOnline.h:60
reco::BeamSpot
Definition: BeamSpot.h:21
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.h:37
edm::LogWarning
Definition: MessageLogger.h:141
BeamSpotObjects::GetBetaStar
double GetBetaStar() const
get beta star
Definition: BeamSpotObjects.h:107
BeamSpotObjects::GetEmittanceX
double GetEmittanceX() const
get emittance
Definition: BeamSpotObjects.h:103
BeamSpotOnlineProducer::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
produce a beam spot class
Definition: BeamSpotOnlineProducer.cc:30
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
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
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
BeamSpotOnlineProducer::BeamSpotOnlineProducer
BeamSpotOnlineProducer(const edm::ParameterSet &iConf)
constructor
Definition: BeamSpotOnlineProducer.cc:15
BeamSpotObjectsRcd
Definition: BeamSpotObjectsRcd.h:24
BeamSpotObjects
Definition: BeamSpotObjects.h:20
edm::EventSetup
Definition: EventSetup.h:57
reco::BeamSpot::CovarianceMatrix
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
BeamSpotOnlineProducer::scalerToken_
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalerToken_
Definition: BeamSpotOnlineProducer.h:39
get
#define get
BeamSpotOnline
Definition: BeamSpotOnline.h:28
BeamSpotObjects::GetBeamWidthX
double GetBeamWidthX() const
get average transverse beam width
Definition: BeamSpotObjects.h:75
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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.h:40
BeamSpotOnlineCollection
std::vector< BeamSpotOnline > BeamSpotOnlineCollection
Definition: BeamSpotOnline.h:101
BeamSpotOnlineProducer::theMaxZ
const double theMaxZ
Definition: BeamSpotOnlineProducer.h:37
TrackEfficiencyMonitor_cfi.theMaxZ
theMaxZ
Definition: TrackEfficiencyMonitor_cfi.py:11
EventSetup.h
mps_fire.result
result
Definition: mps_fire.py:303
reco::BeamSpot::Point
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
BeamSpotOnlineProducer::theBeamShoutMode
const unsigned int theBeamShoutMode
Definition: BeamSpotOnlineProducer.h:42
reco::BeamSpot::setType
void setType(BeamType type)
set beam type
Definition: BeamSpot.h:124
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
fftjetvertexadder_cfi.sigmaZ
sigmaZ
Definition: fftjetvertexadder_cfi.py:32
BeamSpotOnline::z
float z() const
Definition: BeamSpotOnline.h:50
edm::Event
Definition: Event.h:73
IOVSyncValue.h
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