60 const std::map<std::string, const MuonGeometrySanityCheckCustomFrame *> &frames);
95 std::map<std::string, const MuonGeometrySanityCheckCustomFrame *>
m_frames;
96 std::vector<MuonGeometrySanityCheckPoint>
m_points;
118 throw cms::Exception(
"BadConfig") <<
"Printout must be \"all\" or \"bad\"." << std::endl;
123 throw cms::Exception(
"BadConfig") <<
"Tolerance must be positive." << std::endl;
128 std::vector<edm::ParameterSet> frames = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"frames");
129 for (std::vector<edm::ParameterSet>::const_iterator frame = frames.begin(); frame != frames.end(); ++frame) {
132 throw cms::Exception(
"BadConfig") <<
"Custom frame \"" << name <<
"\" has been defined twice." << std::endl;
137 std::vector<edm::ParameterSet> points = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"points");
138 for (std::vector<edm::ParameterSet>::const_iterator
point = points.begin();
point != points.end(); ++
point) {
144 for (std::map<std::string, const MuonGeometrySanityCheckCustomFrame *>::iterator iter =
m_frames.begin();
153 std::vector<double> numbers = iConfig.
getParameter<std::vector<double> >(
"matrix");
154 if (numbers.size() != 9) {
155 throw cms::Exception(
"BadConfig") <<
"Custom frame \"" << name <<
"\" has a matrix which is not 3x3." << std::endl;
159 matrix[0][0] = numbers[0];
160 matrix[0][1] = numbers[1];
161 matrix[0][2] = numbers[2];
162 matrix[1][0] = numbers[3];
163 matrix[1][1] = numbers[4];
164 matrix[1][2] = numbers[5];
165 matrix[2][0] = numbers[6];
166 matrix[2][1] = numbers[7];
167 matrix[2][2] = numbers[8];
173 throw cms::Exception(
"BadConfig") <<
"Could not invert matrix for custom frame \"" << name <<
"\"." << std::endl;
179 input[0] = point.
x();
180 input[1] = point.
x();
181 input[2] = point.
x();
183 return GlobalPoint(output[0], output[1], output[3]);
188 input[0] = point.
x();
189 input[1] = point.
x();
190 input[2] = point.
x();
192 return GlobalPoint(output[0], output[1], output[3]);
227 const edm::ParameterSet &
iConfig,
const std::map<std::string, const MuonGeometrySanityCheckCustomFrame *> &frames) {
230 bool parsing_error =
false;
234 if (!barrel && !endcap)
235 parsing_error =
true;
237 if (!parsing_error && barrel) {
241 if (detName.substr(index, 1) ==
std::string(
"+")) {
244 }
else if (detName.substr(index, 1) ==
std::string(
"-")) {
250 bool wheel_digit =
false;
251 while (!parsing_error &&
numeric(detName.substr(index, 1))) {
253 wheel +=
number(detName.substr(index, 1));
260 parsing_error =
true;
263 parsing_error =
true;
267 bool station_digit =
false;
268 while (!parsing_error &&
numeric(detName.substr(index, 1))) {
270 station +=
number(detName.substr(index, 1));
271 station_digit =
true;
275 parsing_error =
true;
278 parsing_error =
true;
282 bool sector_digit =
false;
283 while (!parsing_error &&
numeric(detName.substr(index, 1))) {
285 sector +=
number(detName.substr(index, 1));
290 parsing_error =
true;
294 bool superlayer_digit =
false;
296 if (detName.substr(index, 1) ==
std::string(
"/")) {
298 while (!parsing_error &&
numeric(detName.substr(index, 1))) {
300 superlayer +=
number(detName.substr(index, 1));
301 superlayer_digit =
true;
304 if (!superlayer_digit)
305 parsing_error =
true;
307 if (detName.substr(index, 1) ==
std::string(
"/")) {
309 while (!parsing_error &&
numeric(detName.substr(index, 1))) {
311 layer +=
number(detName.substr(index, 1));
317 if (!parsing_error) {
318 bool no_such_chamber =
false;
320 if (wheel < -2 || wheel > 2)
321 no_such_chamber =
true;
322 if (station < 1 || station > 4)
323 no_such_chamber =
true;
324 if (station == 4 && (sector < 1 || sector > 14))
325 no_such_chamber =
true;
326 if (station < 4 && (sector < 1 || sector > 12))
327 no_such_chamber =
true;
329 if (no_such_chamber) {
330 throw cms::Exception(
"BadConfig") <<
"Chamber doesn't exist: MB" << (plus ?
"+" :
"-") << wheel <<
"/"
331 << station <<
"/" << sector << std::endl;
334 if (superlayer == 0) {
338 bool no_such_superlayer =
false;
339 if (superlayer < 1 || superlayer > 3)
340 no_such_superlayer =
true;
341 if (station == 4 && superlayer == 2)
342 no_such_superlayer =
true;
344 if (no_such_superlayer) {
345 throw cms::Exception(
"BadConfig") <<
"Superlayer doesn't exist: MB" << (plus ?
"+" :
"-") << wheel <<
"/"
346 << station <<
"/" << sector <<
"/" << superlayer << std::endl;
353 bool no_such_layer =
false;
354 if (layer < 1 || layer > 4)
355 no_such_layer =
true;
359 <<
"Layer doesn't exist: MB" << (plus ?
"+" :
"-") << wheel <<
"/" << station <<
"/" << sector <<
"/"
360 << superlayer <<
"/" << layer << std::endl;
368 }
else if (!parsing_error && endcap) {
372 if (detName.substr(index, 1) ==
std::string(
"+")) {
375 }
else if (detName.substr(index, 1) ==
std::string(
"-")) {
379 parsing_error =
true;
382 bool station_digit =
false;
383 while (!parsing_error &&
numeric(detName.substr(index, 1))) {
385 station +=
number(detName.substr(index, 1));
386 station_digit =
true;
392 parsing_error =
true;
395 parsing_error =
true;
399 bool ring_digit =
false;
400 while (!parsing_error &&
numeric(detName.substr(index, 1))) {
402 ring +=
number(detName.substr(index, 1));
407 parsing_error =
true;
410 parsing_error =
true;
414 bool chamber_digit =
false;
415 while (!parsing_error &&
numeric(detName.substr(index, 1))) {
417 chamber +=
number(detName.substr(index, 1));
418 chamber_digit =
true;
422 parsing_error =
true;
426 bool layer_digit =
false;
427 if (detName.substr(index, 1) ==
std::string(
"/")) {
429 while (!parsing_error &&
numeric(detName.substr(index, 1))) {
431 layer +=
number(detName.substr(index, 1));
436 parsing_error =
true;
439 if (!parsing_error) {
440 bool no_such_chamber =
false;
442 int endcap = (station > 0 ? 1 : 2);
443 station =
abs(station);
444 if (station < 1 || station > 4)
445 no_such_chamber =
true;
446 if (station == 1 && (ring < 1 || ring > 4))
447 no_such_chamber =
true;
448 if (station > 1 && (ring < 1 || ring > 2))
449 no_such_chamber =
true;
450 if (station == 1 && (chamber < 1 || chamber > 36))
451 no_such_chamber =
true;
452 if (station > 1 && ring == 1 && (chamber < 1 || chamber > 18))
453 no_such_chamber =
true;
454 if (station > 1 && ring == 2 && (chamber < 1 || chamber > 36))
455 no_such_chamber =
true;
457 if (no_such_chamber) {
458 throw cms::Exception(
"BadConfig") <<
"Chamber doesn't exist: ME" << (endcap == 1 ?
"+" :
"-") << station <<
"/"
459 << ring <<
"/" << chamber << std::endl;
466 bool no_such_layer =
false;
467 if (layer < 1 || layer > 6)
468 no_such_layer =
true;
471 throw cms::Exception(
"BadConfig") <<
"Layer doesn't exist: ME" << (endcap == 1 ?
"+" :
"-") << station <<
"/"
472 << ring <<
"/" << chamber <<
"/" << layer << std::endl;
482 throw cms::Exception(
"BadConfig") <<
"Detector name is malformed: " << detName << std::endl;
486 const std::map<std::string, const MuonGeometrySanityCheckCustomFrame *>::const_iterator frameIter =
487 frames.find(frameName);
497 }
else if (frameIter != frames.end()) {
501 throw cms::Exception(
"BadConfig") <<
"Frame \"" << frameName <<
"\" has not been defined." << std::endl;
504 std::vector<double>
point = iConfig.
getParameter<std::vector<double> >(
"displacement");
505 if (point.size() != 3) {
506 throw cms::Exception(
"BadConfig") <<
"Displacement relative to detector " << detName
507 <<
" doesn't have exactly three components." << std::endl;
513 if (entry !=
nullptr) {
516 point = iConfig.
getParameter<std::vector<double> >(
"expectation");
517 if (point.size() != 3) {
519 <<
" doesn't have exactly three components." << std::endl;
528 if (entry !=
nullptr) {
535 if (entry !=
nullptr) {
537 const std::map<std::string, const MuonGeometrySanityCheckCustomFrame *>::const_iterator frameIter =
538 frames.find(frameName);
548 }
else if (frameIter != frames.end()) {
552 throw cms::Exception(
"BadConfig") <<
"Frame \"" << frameName <<
"\" has not been defined." << std::endl;
564 output <<
"MB" << (
id.wheel() > 0 ?
"+" :
"") <<
id.wheel() <<
"/" <<
id.station() <<
"/" <<
id.sector();
567 output <<
"MB" << (
id.wheel() > 0 ?
"+" :
"") <<
id.wheel() <<
"/" <<
id.station() <<
"/" <<
id.sector() <<
"/"
571 output <<
"MB" << (
id.wheel() > 0 ?
"+" :
"") <<
id.wheel() <<
"/" <<
id.station() <<
"/" <<
id.sector() <<
"/"
572 <<
id.superlayer() <<
"/" <<
id.layer();
575 output <<
"ME" << (
id.endcap() == 1 ?
"+" :
"-") <<
id.
station() <<
"/" <<
id.ring() <<
"/" <<
id.chamber();
578 output <<
"ME" << (
id.endcap() == 1 ?
"+" :
"-") <<
id.
station() <<
"/" <<
id.ring() <<
"/" <<
id.chamber() <<
"/"
590 int num_transformed = 0;
609 chamberPos.
y() +
point->displacement.y(),
610 chamberPos.
z() +
point->displacement.z());
650 chamberPos.
x() + transformed.
x(), chamberPos.
y() + transformed.
y(), chamberPos.
z() + transformed.
z());
667 result =
GlobalPoint(transformed.
x(), transformed.
y(), transformed.
z());
678 result =
GlobalPoint(transformed.
x(), transformed.
y(), transformed.
z());
687 result =
GlobalPoint(transformed.x(), transformed.y(), transformed.z());
694 result =
point->outputCustomFrame->transformInverse(result);
698 output <<
prefix <<
" " <<
point->name <<
" " <<
point->detName() <<
" " << result.
x() <<
" " << result.
y() <<
" "
702 if (
point->has_expectation) {
704 double residx = result.
x() -
point->expectation.x();
705 double residy = result.
y() -
point->expectation.y();
706 double residz = result.
z() -
point->expectation.z();
711 output <<
" BAD " << residx <<
" " << residy <<
" " << residz << std::endl;
713 output <<
" GOOD " << residx <<
" " << residy <<
" " << residz << std::endl;
716 output <<
" UNTESTED 0 0 0" << std::endl;
725 <<
"SUMMARY transformed: " << num_transformed <<
" tested: " << num_tested <<
" bad: " << num_bad
726 <<
" good: " << (num_tested - num_bad) << std::endl;
std::vector< MuonGeometrySanityCheckPoint > m_points
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
std::string detName() const
void analyze(const edm::Event &, const edm::EventSetup &iConfig) override
Point3DBase< Scalar, LocalTag > LocalPoint
uint16_t *__restrict__ id
#define DEFINE_FWK_MODULE(type)
const MuonGeometrySanityCheckCustomFrame * outputCustomFrame
Global3DPoint GlobalPoint
int number(std::string s)
std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > m_frames
GlobalPoint transform(GlobalPoint point) const
const Plane & surface() const
The nominal surface of the GeomDet.
constexpr std::array< uint8_t, layerIndexSize > layer
static std::string const input
bool getData(T &iHolder) const
AlgebraicMatrix matrixInverse
CLHEP::HepMatrix AlgebraicMatrix
LocalPoint toLocal(const GlobalPoint &gp) const
const GeomDet * idToDet(DetId) const override
Abs< T >::type abs(const T &t)
MuonGeometrySanityCheckPoint(const edm::ParameterSet &iConfig, const std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > &frames)
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken_
MuonGeometrySanityCheckCustomFrame(const edm::ParameterSet &iConfig, std::string name)
CLHEP::HepVector AlgebraicVector
T getParameter(std::string const &) const
GlobalPoint transformInverse(GlobalPoint point) const
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
MuonGeometrySanityCheck(const edm::ParameterSet &iConfig)
Entry const * retrieveUnknown(char const *) const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
bool numeric(std::string s)
const MuonGeometrySanityCheckCustomFrame * customFrame
const GeomDet * idToDet(DetId) const override
~MuonGeometrySanityCheck() override