CMS 3D CMS Logo

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

Public Types

enum  {
  kDTChamber, kDTSuperLayer, kDTLayer, kCSCChamber,
  kCSCLayer
}
 
enum  { kGlobal, kLocal, kChamber, kCustom }
 

Public Member Functions

std::string detName () const
 
 MuonGeometrySanityCheckPoint (const edm::ParameterSet &iConfig, const std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > &frames)
 

Public Attributes

const MuonGeometrySanityCheckCustomFramecustomFrame
 
DetId detector
 
GlobalPoint displacement
 
GlobalPoint expectation
 
int frame
 
bool has_expectation
 
std::string name
 
const MuonGeometrySanityCheckCustomFrameoutputCustomFrame
 
int outputFrame
 
int type
 

Private Member Functions

int number (std::string s)
 
bool numeric (std::string s)
 

Detailed Description

Definition at line 57 of file MuonGeometrySanityCheck.cc.

Member Enumeration Documentation

anonymous enum
anonymous enum

Constructor & Destructor Documentation

MuonGeometrySanityCheckPoint::MuonGeometrySanityCheckPoint ( const edm::ParameterSet iConfig,
const std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > &  frames 
)

Definition at line 222 of file MuonGeometrySanityCheck.cc.

References funct::abs(), Reference_intrackfit_cff::barrel, relativeConstraints::chamber, hgcalTestNeighbor_cfi::detector, makeMuonMisalignmentScenario::endcap, mps_splice::entry, Exception, amptDefault_cfi::frame, relativeConstraints::frameName, edm::ParameterSet::getParameter(), Skims_PA_cff::name, contentValuesFiles::number, reco::HaloData::plus, point, edm::ParameterSet::retrieveUnknown(), relativeConstraints::ring, relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, and makeMuonMisalignmentScenario::wheel.

223  {
224  std::string detName = iConfig.getParameter<std::string>("detector");
225 
226  bool parsing_error = false;
227 
228  bool barrel = (detName.substr(0, 2) == std::string("MB"));
229  bool endcap = (detName.substr(0, 2) == std::string("ME"));
230  if (!barrel && !endcap)
231  parsing_error = true;
232 
233  if (!parsing_error && barrel) {
234  int index = 2;
235 
236  bool plus = true;
237  if (detName.substr(index, 1) == std::string("+")) {
238  plus = true;
239  index++;
240  } else if (detName.substr(index, 1) == std::string("-")) {
241  plus = false;
242  index++;
243  }
244 
245  int wheel = 0;
246  bool wheel_digit = false;
247  while (!parsing_error && numeric(detName.substr(index, 1))) {
248  wheel *= 10;
249  wheel += number(detName.substr(index, 1));
250  wheel_digit = true;
251  index++;
252  }
253  if (!plus)
254  wheel *= -1;
255  if (!wheel_digit)
256  parsing_error = true;
257 
258  if (detName.substr(index, 1) != std::string("/"))
259  parsing_error = true;
260  index++;
261 
262  int station = 0;
263  bool station_digit = false;
264  while (!parsing_error && numeric(detName.substr(index, 1))) {
265  station *= 10;
266  station += number(detName.substr(index, 1));
267  station_digit = true;
268  index++;
269  }
270  if (!station_digit)
271  parsing_error = true;
272 
273  if (detName.substr(index, 1) != std::string("/"))
274  parsing_error = true;
275  index++;
276 
277  int sector = 0;
278  bool sector_digit = false;
279  while (!parsing_error && numeric(detName.substr(index, 1))) {
280  sector *= 10;
281  sector += number(detName.substr(index, 1));
282  sector_digit = true;
283  index++;
284  }
285  if (!sector_digit)
286  parsing_error = true;
287 
288  // these are optional
289  int superlayer = 0;
290  bool superlayer_digit = false;
291  int layer = 0;
292  if (detName.substr(index, 1) == std::string("/")) {
293  index++;
294  while (!parsing_error && numeric(detName.substr(index, 1))) {
295  superlayer *= 10;
296  superlayer += number(detName.substr(index, 1));
297  superlayer_digit = true;
298  index++;
299  }
300  if (!superlayer_digit)
301  parsing_error = true;
302 
303  if (detName.substr(index, 1) == std::string("/")) {
304  index++;
305  while (!parsing_error && numeric(detName.substr(index, 1))) {
306  layer *= 10;
307  layer += number(detName.substr(index, 1));
308  index++;
309  }
310  }
311  }
312 
313  if (!parsing_error) {
314  bool no_such_chamber = false;
315 
316  if (wheel < -2 || wheel > 2)
317  no_such_chamber = true;
318  if (station < 1 || station > 4)
319  no_such_chamber = true;
320  if (station == 4 && (sector < 1 || sector > 14))
321  no_such_chamber = true;
322  if (station < 4 && (sector < 1 || sector > 12))
323  no_such_chamber = true;
324 
325  if (no_such_chamber) {
326  throw cms::Exception("BadConfig") << "Chamber doesn't exist: MB" << (plus ? "+" : "-") << wheel << "/"
327  << station << "/" << sector << std::endl;
328  }
329 
330  if (superlayer == 0) {
331  detector = DTChamberId(wheel, station, sector);
332  type = kDTChamber;
333  } else {
334  bool no_such_superlayer = false;
335  if (superlayer < 1 || superlayer > 3)
336  no_such_superlayer = true;
337  if (station == 4 && superlayer == 2)
338  no_such_superlayer = true;
339 
340  if (no_such_superlayer) {
341  throw cms::Exception("BadConfig") << "Superlayer doesn't exist: MB" << (plus ? "+" : "-") << wheel << "/"
342  << station << "/" << sector << "/" << superlayer << std::endl;
343  }
344 
345  if (layer == 0) {
346  detector = DTSuperLayerId(wheel, station, sector, superlayer);
348  } else {
349  bool no_such_layer = false;
350  if (layer < 1 || layer > 4)
351  no_such_layer = true;
352 
353  if (no_such_layer) {
354  throw cms::Exception("BadConfig")
355  << "Layer doesn't exist: MB" << (plus ? "+" : "-") << wheel << "/" << station << "/" << sector << "/"
356  << superlayer << "/" << layer << std::endl;
357  }
358 
359  detector = DTLayerId(wheel, station, sector, superlayer, layer);
360  type = kDTLayer;
361  }
362  }
363  }
364  } else if (!parsing_error && endcap) {
365  int index = 2;
366 
367  bool plus = true;
368  if (detName.substr(index, 1) == std::string("+")) {
369  plus = true;
370  index++;
371  } else if (detName.substr(index, 1) == std::string("-")) {
372  plus = false;
373  index++;
374  } else
375  parsing_error = true;
376 
377  int station = 0;
378  bool station_digit = false;
379  while (!parsing_error && numeric(detName.substr(index, 1))) {
380  station *= 10;
381  station += number(detName.substr(index, 1));
382  station_digit = true;
383  index++;
384  }
385  if (!plus)
386  station *= -1;
387  if (!station_digit)
388  parsing_error = true;
389 
390  if (detName.substr(index, 1) != std::string("/"))
391  parsing_error = true;
392  index++;
393 
394  int ring = 0;
395  bool ring_digit = false;
396  while (!parsing_error && numeric(detName.substr(index, 1))) {
397  ring *= 10;
398  ring += number(detName.substr(index, 1));
399  ring_digit = true;
400  index++;
401  }
402  if (!ring_digit)
403  parsing_error = true;
404 
405  if (detName.substr(index, 1) != std::string("/"))
406  parsing_error = true;
407  index++;
408 
409  int chamber = 0;
410  bool chamber_digit = false;
411  while (!parsing_error && numeric(detName.substr(index, 1))) {
412  chamber *= 10;
413  chamber += number(detName.substr(index, 1));
414  chamber_digit = true;
415  index++;
416  }
417  if (!chamber_digit)
418  parsing_error = true;
419 
420  // this is optional
421  int layer = 0;
422  bool layer_digit = false;
423  if (detName.substr(index, 1) == std::string("/")) {
424  index++;
425  while (!parsing_error && numeric(detName.substr(index, 1))) {
426  layer *= 10;
427  layer += number(detName.substr(index, 1));
428  layer_digit = true;
429  index++;
430  }
431  if (!layer_digit)
432  parsing_error = true;
433  }
434 
435  if (!parsing_error) {
436  bool no_such_chamber = false;
437 
438  int endcap = (station > 0 ? 1 : 2);
439  station = abs(station);
440  if (station < 1 || station > 4)
441  no_such_chamber = true;
442  if (station == 1 && (ring < 1 || ring > 4))
443  no_such_chamber = true;
444  if (station > 1 && (ring < 1 || ring > 2))
445  no_such_chamber = true;
446  if (station == 1 && (chamber < 1 || chamber > 36))
447  no_such_chamber = true;
448  if (station > 1 && ring == 1 && (chamber < 1 || chamber > 18))
449  no_such_chamber = true;
450  if (station > 1 && ring == 2 && (chamber < 1 || chamber > 36))
451  no_such_chamber = true;
452 
453  if (no_such_chamber) {
454  throw cms::Exception("BadConfig") << "Chamber doesn't exist: ME" << (endcap == 1 ? "+" : "-") << station << "/"
455  << ring << "/" << chamber << std::endl;
456  }
457 
458  if (layer == 0) {
459  detector = CSCDetId(endcap, station, ring, chamber);
460  type = kCSCChamber;
461  } else {
462  bool no_such_layer = false;
463  if (layer < 1 || layer > 6)
464  no_such_layer = true;
465 
466  if (no_such_layer) {
467  throw cms::Exception("BadConfig") << "Layer doesn't exist: ME" << (endcap == 1 ? "+" : "-") << station << "/"
468  << ring << "/" << chamber << "/" << layer << std::endl;
469  }
470 
471  detector = CSCDetId(endcap, station, ring, chamber, layer);
472  type = kCSCLayer;
473  }
474  }
475  }
476 
477  if (parsing_error) {
478  throw cms::Exception("BadConfig") << "Detector name is malformed: " << detName << std::endl;
479  }
480 
481  std::string frameName = iConfig.getParameter<std::string>("frame");
482  const std::map<std::string, const MuonGeometrySanityCheckCustomFrame *>::const_iterator frameIter =
483  frames.find(frameName);
484  if (frameName == std::string("global")) {
485  frame = kGlobal;
486  customFrame = nullptr;
487  } else if (frameName == std::string("local")) {
488  frame = kLocal;
489  customFrame = nullptr;
490  } else if (frameName == std::string("chamber")) {
491  frame = kChamber;
492  customFrame = nullptr;
493  } else if (frameIter != frames.end()) {
494  frame = kCustom;
495  customFrame = frameIter->second;
496  } else {
497  throw cms::Exception("BadConfig") << "Frame \"" << frameName << "\" has not been defined." << std::endl;
498  }
499 
500  std::vector<double> point = iConfig.getParameter<std::vector<double> >("displacement");
501  if (point.size() != 3) {
502  throw cms::Exception("BadConfig") << "Displacement relative to detector " << detName
503  << " doesn't have exactly three components." << std::endl;
504  }
505 
506  displacement = GlobalPoint(point[0], point[1], point[2]);
507 
508  const edm::Entry *entry = iConfig.retrieveUnknown("expectation");
509  if (entry != nullptr) {
510  has_expectation = true;
511 
512  point = iConfig.getParameter<std::vector<double> >("expectation");
513  if (point.size() != 3) {
514  throw cms::Exception("BadConfig") << "Expectation for detector " << detName << ", displacement " << displacement
515  << " doesn't have exactly three components." << std::endl;
516  }
517 
518  expectation = GlobalPoint(point[0], point[1], point[2]);
519  } else {
520  has_expectation = false;
521  }
522 
523  entry = iConfig.retrieveUnknown("name");
524  if (entry != nullptr) {
525  name = iConfig.getParameter<std::string>("name");
526  } else {
527  name = std::string("anonymous");
528  }
529 
530  entry = iConfig.retrieveUnknown("outputFrame");
531  if (entry != nullptr) {
532  frameName = iConfig.getParameter<std::string>("outputFrame");
533  const std::map<std::string, const MuonGeometrySanityCheckCustomFrame *>::const_iterator frameIter =
534  frames.find(frameName);
535  if (frameName == std::string("global")) {
537  outputCustomFrame = nullptr;
538  } else if (frameName == std::string("local")) {
540  outputCustomFrame = nullptr;
541  } else if (frameName == std::string("chamber")) {
543  outputCustomFrame = nullptr;
544  } else if (frameIter != frames.end()) {
546  outputCustomFrame = frameIter->second;
547  } else {
548  throw cms::Exception("BadConfig") << "Frame \"" << frameName << "\" has not been defined." << std::endl;
549  }
550  } else {
552  outputCustomFrame = nullptr;
553  }
554 }
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
const MuonGeometrySanityCheckCustomFrame * outputCustomFrame
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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
Definition: invegas.h:5
const MuonGeometrySanityCheckCustomFrame * customFrame

Member Function Documentation

std::string MuonGeometrySanityCheckPoint::detName ( ) const

Definition at line 556 of file MuonGeometrySanityCheck.cc.

References hgcalTestNeighbor_cfi::detector, triggerObjects_cff::id, convertSQLitetoXML_cfg::output, relativeConstraints::station, and makeMuonMisalignmentScenario::wheel.

556  {
557  std::stringstream output;
558  if (type == kDTChamber) {
560  output << "MB" << (id.wheel() > 0 ? "+" : "") << id.wheel() << "/" << id.station() << "/" << id.sector();
561  } else if (type == kDTSuperLayer) {
563  output << "MB" << (id.wheel() > 0 ? "+" : "") << id.wheel() << "/" << id.station() << "/" << id.sector() << "/"
564  << id.superlayer();
565  } else if (type == kDTLayer) {
567  output << "MB" << (id.wheel() > 0 ? "+" : "") << id.wheel() << "/" << id.station() << "/" << id.sector() << "/"
568  << id.superlayer() << "/" << id.layer();
569  } else if (type == kCSCChamber) {
571  output << "ME" << (id.endcap() == 1 ? "+" : "-") << id.station() << "/" << id.ring() << "/" << id.chamber();
572  } else if (type == kCSCLayer) {
574  output << "ME" << (id.endcap() == 1 ? "+" : "-") << id.station() << "/" << id.ring() << "/" << id.chamber() << "/"
575  << id.layer();
576  } else
577  assert(false);
578  return output.str();
579 }
type
Definition: HCALResponse.h:21
int MuonGeometrySanityCheckPoint::number ( std::string  s)
private

Definition at line 197 of file MuonGeometrySanityCheck.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

197  {
198  if (s == std::string("0"))
199  return 0;
200  else if (s == std::string("1"))
201  return 1;
202  else if (s == std::string("2"))
203  return 2;
204  else if (s == std::string("3"))
205  return 3;
206  else if (s == std::string("4"))
207  return 4;
208  else if (s == std::string("5"))
209  return 5;
210  else if (s == std::string("6"))
211  return 6;
212  else if (s == std::string("7"))
213  return 7;
214  else if (s == std::string("8"))
215  return 8;
216  else if (s == std::string("9"))
217  return 9;
218  else
219  assert(false);
220 }
bool MuonGeometrySanityCheckPoint::numeric ( std::string  s)
private

Definition at line 191 of file MuonGeometrySanityCheck.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

191  {
192  return (s == std::string("0") || s == std::string("1") || s == std::string("2") || s == std::string("3") ||
193  s == std::string("4") || s == std::string("5") || s == std::string("6") || s == std::string("7") ||
194  s == std::string("8") || s == std::string("9"));
195 }

Member Data Documentation

const MuonGeometrySanityCheckCustomFrame* MuonGeometrySanityCheckPoint::customFrame

Definition at line 71 of file MuonGeometrySanityCheck.cc.

DetId MuonGeometrySanityCheckPoint::detector

Definition at line 69 of file MuonGeometrySanityCheck.cc.

GlobalPoint MuonGeometrySanityCheckPoint::displacement

Definition at line 72 of file MuonGeometrySanityCheck.cc.

GlobalPoint MuonGeometrySanityCheckPoint::expectation

Definition at line 74 of file MuonGeometrySanityCheck.cc.

int MuonGeometrySanityCheckPoint::frame

Definition at line 70 of file MuonGeometrySanityCheck.cc.

bool MuonGeometrySanityCheckPoint::has_expectation

Definition at line 73 of file MuonGeometrySanityCheck.cc.

std::string MuonGeometrySanityCheckPoint::name

Definition at line 75 of file MuonGeometrySanityCheck.cc.

Referenced by ElectronMVAID.ElectronMVAID::__call__(), FWLite.ElectronMVAID::__call__(), dirstructure.Directory::__create_pie_image(), DisplayManager.DisplayManager::__del__(), dqm_interfaces.DirID::__eq__(), BeautifulSoup.Tag::__eq__(), dirstructure.Directory::__get_full_path(), dirstructure.Comparison::__get_img_name(), dataset.Dataset::__getDataType(), dataset.Dataset::__getFileInfoList(), dirstructure.Comparison::__make_image(), core.autovars.NTupleVariable::__repr__(), core.autovars.NTupleObjectType::__repr__(), core.autovars.NTupleObject::__repr__(), core.autovars.NTupleCollection::__repr__(), dirstructure.Directory::__repr__(), dqm_interfaces.DirID::__repr__(), dirstructure.Comparison::__repr__(), config.Service::__setattr__(), config.CFG::__str__(), counter.Counter::__str__(), average.Average::__str__(), BeautifulSoup.Tag::__str__(), BeautifulSoup.SoupStrainer::__str__(), FWLite.WorkingPoints::_reformat_cut_definitions(), core.autovars.NTupleObjectType::addSubObjects(), core.autovars.NTupleObjectType::addVariables(), core.autovars.NTupleObjectType::allVars(), dirstructure.Directory::calcStats(), genericValidation.GenericValidationData::cfgName(), crabFunctions.CrabTask::crabConfig(), crabFunctions.CrabTask::crabFolder(), genericValidation.GenericValidationData::createCrabCfg(), geometryComparison.GeometryComparison::createScript(), genericValidation.GenericValidationData::createScript(), validation.Sample::digest(), python.rootplot.utilities.Hist::divide(), python.rootplot.utilities.Hist::divide_wilson(), DisplayManager.DisplayManager::Draw(), TreeCrawler.Package::dump(), core.autovars.NTupleVariable::fillBranch(), core.autovars.NTupleObject::fillBranches(), core.autovars.NTupleCollection::fillBranchesScalar(), core.autovars.NTupleCollection::fillBranchesVector(), core.autovars.NTupleCollection::get_cpp_declaration(), core.autovars.NTupleCollection::get_cpp_wrapper_class(), core.autovars.NTupleCollection::get_py_wrapper_class(), utils.StatisticalTest::get_status(), production_tasks.Task::getname(), dataset.CMSDataset::getPrimaryDatasetEntries(), dataset.PrivateDataset::getPrimaryDatasetEntries(), primaryVertexValidation.PrimaryVertexValidation::getRepMap(), zMuMuValidation.ZMuMuValidation::getRepMap(), alignment.Alignment::getRepMap(), genericValidation.GenericValidationData::getRepMap(), crabFunctions.CrabTask::handleNoState(), VIDSelectorBase.VIDSelectorBase::initialize(), personalPlayback.Applet::log(), core.autovars.NTupleVariable::makeBranch(), core.autovars.NTupleObject::makeBranches(), core.autovars.NTupleCollection::makeBranchesScalar(), core.autovars.NTupleCollection::makeBranchesVector(), plotscripts.SawTeethFunction::pp(), dirstructure.Directory::print_report(), dataset.BaseDataset::printInfo(), dataset.Dataset::printInfo(), crabFunctions.CrabTask::resubmit_failed(), production_tasks.MonitorJobs::run(), BeautifulSoup.SoupStrainer::searchTag(), python.rootplot.utilities.Hist::TGraph(), python.rootplot.utilities.Hist::TH1F(), crabFunctions.CrabTask::update(), crabFunctions.CrabTask::updateJobStats(), Vispa.Views.PropertyView.Property::valueChanged(), counter.Counter::write(), and average.Average::write().

const MuonGeometrySanityCheckCustomFrame* MuonGeometrySanityCheckPoint::outputCustomFrame

Definition at line 77 of file MuonGeometrySanityCheck.cc.

int MuonGeometrySanityCheckPoint::outputFrame

Definition at line 76 of file MuonGeometrySanityCheck.cc.

int MuonGeometrySanityCheckPoint::type