50 Significance(
const double&
a,
const double&
b,
const double& errA,
const double& errB)
51 : m_A(
a), m_B(
b), m_ErrA(errA), m_ErrB(errB) {
52 if (m_ErrA == 0 && m_ErrB == 0) {
53 edm::LogError(
"LogicalError") <<
"Can't calculate significance when both errors are zero!" << std::endl;
55 m_combinedError =
std::sqrt((m_ErrA * m_ErrA) + (m_ErrB * m_ErrB));
61 <<
"A= " << m_A <<
"+/-" << m_ErrA <<
" " 62 <<
"B= " << m_B <<
"+/-" << m_ErrB <<
" | delta=" <<
std::abs(m_A - m_B) <<
"+/-" << m_combinedError
65 return std::abs(m_A - m_B) / m_combinedError;
74 double m_combinedError;
103 : warningThreshold_(iConfig.getParameter<double>(
"warningThr")),
104 throwingThreshold_(iConfig.getParameter<double>(
"errorThr")),
105 verbose_(iConfig.getUntrackedParameter<
bool>(
"verbose",
false)),
106 dbFromEvent_(iConfig.getParameter<
bool>(
"dbFromEvent")),
112 <<
") cannot be smaller than the throwing threshold (" <<
throwingThreshold_ <<
")" << std::endl;
116 <<
"!!!! Warning !!!\nThe Database Beam Spot is going to be taken from the Event via BeamSpotProducer!";
119 bsFromDBToken_ = esConsumes<BeamSpotObjects, BeamSpotObjectsRcd>();
136 spotEvent = *beamSpotFromEventHandle;
138 double evt_BSx0 = spotEvent.
x0();
139 double evt_BSy0 = spotEvent.
y0();
140 double evt_BSz0 = spotEvent.
z0();
141 double evt_Beamsigmaz = spotEvent.
sigmaZ();
142 double evt_BeamWidthX = spotEvent.
BeamWidthX();
143 double evt_BeamWidthY = spotEvent.
BeamWidthY();
165 spotDB = *beamSpotFromDBHandle;
168 double db_BSx0 = spotDB.
x0();
169 double db_BSy0 = spotDB.
y0();
170 double db_BSz0 = spotDB.
z0();
171 double db_Beamsigmaz = spotDB.
sigmaZ();
175 double deltaX0 = evt_BSx0 - db_BSx0;
176 double deltaY0 = evt_BSy0 - db_BSy0;
177 double deltaZ0 = evt_BSz0 - db_BSz0;
178 double deltaSigmaX = evt_BeamWidthX - db_BeamWidthX;
179 double deltaSigmaY = evt_BeamWidthY - db_BeamWidthY;
180 double deltaSigmaZ = evt_Beamsigmaz - db_Beamsigmaz;
183 edm::LogPrint(
"BeamSpotCompatibilityChecker") <<
"BS from Event: \n" << spotEvent << std::endl;
184 edm::LogPrint(
"BeamSpotCompatibilityChecker") <<
"BS from DB: \n" << spotDB << std::endl;
187 auto significances =
compareBS(spotDB, spotEvent);
188 std::vector<std::string>
labels = {
"x0",
"y0",
"z0",
"sigmaX",
"sigmaY",
"sigmaZ"};
200 for (
unsigned int i = 0;
i < 3;
i++) {
201 auto sig = significances.at(
i);
205 <<
"[" << __PRETTY_FUNCTION__ <<
"] \n DB-Event BeamSpot " <<
labels.at(
i) <<
" distance sigificance " << sig
210 <<
"[" << __PRETTY_FUNCTION__ <<
"] \n DB-Event BeamSpot " <<
labels.at(
i) <<
" distance significance " 211 << sig <<
", exceeds the threshold of " <<
warningThreshold_ <<
"!" << std::endl;
218 auto xS = Significance(beamSpotA.
x0(), beamSpotB.
x0(), beamSpotA.
x0Error(), beamSpotB.
x0Error());
219 auto yS = Significance(beamSpotA.
y0(), beamSpotB.
y0(), beamSpotA.
y0Error(), beamSpotB.
y0Error());
220 auto zS = Significance(beamSpotA.
z0(), beamSpotB.
z0(), beamSpotA.
z0Error(), beamSpotB.
z0Error());
221 auto xWS = Significance(
223 auto yWS = Significance(
227 std::array<float, 6>
ret = {
228 {xS.getSig(
false), yS.getSig(
false), zS.getSig(
false), xWS.getSig(
false), yWS.getSig(
false), zWS.getSig(
false)}};
235 desc.add<
double>(
"warningThr", 1.)->setComment(
"Threshold on the signficances to emit a warning");
236 desc.add<
double>(
"errorThr", 3.)->setComment(
"Threshold on the signficances to abort the job");
237 desc.addUntracked<
bool>(
"verbose",
false)->setComment(
"verbose output");
239 ->setComment(
"edm::InputTag on the BeamSpot from the Event (Reference)");
240 desc.add<
bool>(
"dbFromEvent",
false)
241 ->setComment(
"Switch to take the (target) DB beamspot from the event instead of the EventSetup");
243 ->setComment(
"edm::InputTag on the BeamSpot from the Event (Target)\n To be used only if dbFromEvent is True");
math::Error< dimension >::type CovarianceMatrix
double BeamWidthX() const
beam width X
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
double z() const
get Z beam position
double dydz() const
get dydz slope, crossing angle in YZ
double BeamWidthYError() const
error on beam width Y, assume error in X = Y
const edm::EDGetTokenT< reco::BeamSpot > bsFromEventToken_
double covariance(int i, int j) const
get i,j element of the full covariance matrix 7x7
ret
prodAgent to be discontinued
static std::array< float, 6 > compareBS(const reco::BeamSpot &BSA, const reco::BeamSpot &BSB)
edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > bsFromDBToken_
double x0Error() const
error on x
math::XYZPoint Point
point in the space
double beamWidthX() const
get average transverse beam width
edm::EDGetTokenT< reco::BeamSpot > dbBSfromEventToken_
Log< level::Error, false > LogError
double z0Error() const
error on z
void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const final
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static std::string to_string(const XMLCh *ch)
double sigmaZ0Error() const
error on sigma z
double x0() const
x coordinate
T const * product() const
BeamSpotCompatibilityChecker(const edm::ParameterSet &)
Abs< T >::type abs(const T &t)
double BeamWidthY() const
beam width Y
double x() const
get X beam position
#define DEFINE_FWK_MODULE(type)
double y0() const
y coordinate
const double throwingThreshold_
Log< level::Warning, true > LogPrint
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
const double warningThreshold_
double BeamWidthXError() const
error on beam width X, assume error in X = Y
Log< level::Info, false > LogInfo
double y() const
get Y beam position
double sigmaZ() const
sigma z
double sigmaZ() const
get sigma Z, RMS bunch length
double z0() const
z coordinate
static constexpr int cmToum
~BeamSpotCompatibilityChecker() override=default
Log< level::Warning, false > LogWarning
double dxdz() const
get dxdz slope, crossing angle in XZ
double y0Error() const
error on y