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 58 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 218 of file MuonGeometrySanityCheck.cc.

References funct::abs(), Reference_intrackfit_cff::barrel, relativeConstraints::chamber, gamEcalExtractorBlocks_cff::detector, makeMuonMisalignmentScenario::endcap, mps_splice::entry, Exception, relativeConstraints::frameName, edm::ParameterSet::getParameter(), diffTreeTool::index, dataset::name, NULL, reco::HaloData::plus, point, edm::ParameterSet::retrieveUnknown(), relativeConstraints::ring, relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, and makeMuonMisalignmentScenario::wheel.

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

References gamEcalExtractorBlocks_cff::detector, hcalTTPDigis_cfi::id, convertSQLitetoXML_cfg::output, relativeConstraints::station, and makeMuonMisalignmentScenario::wheel.

529  {
530  std::stringstream output;
531  if (type == kDTChamber) {
533  output << "MB" << (id.wheel() > 0 ? "+" : "") << id.wheel() << "/" << id.station() << "/" << id.sector();
534  }
535  else if (type == kDTSuperLayer) {
537  output << "MB" << (id.wheel() > 0 ? "+" : "") << id.wheel() << "/" << id.station() << "/" << id.sector() << "/" << id.superlayer();
538  }
539  else if (type == kDTLayer) {
541  output << "MB" << (id.wheel() > 0 ? "+" : "") << id.wheel() << "/" << id.station() << "/" << id.sector() << "/" << id.superlayer() << "/" << id.layer();
542  }
543  else if (type == kCSCChamber) {
545  output << "ME" << (id.endcap() == 1 ? "+" : "-") << id.station() << "/" << id.ring() << "/" << id.chamber();
546  }
547  else if (type == kCSCLayer) {
549  output << "ME" << (id.endcap() == 1 ? "+" : "-") << id.station() << "/" << id.ring() << "/" << id.chamber() << "/" << id.layer();
550  }
551  else assert(false);
552  return output.str();
553 }
type
Definition: HCALResponse.h:21
int MuonGeometrySanityCheckPoint::number ( std::string  s)
private

Definition at line 204 of file MuonGeometrySanityCheck.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

204  {
205  if (s == std::string("0")) return 0;
206  else if (s == std::string("1")) return 1;
207  else if (s == std::string("2")) return 2;
208  else if (s == std::string("3")) return 3;
209  else if (s == std::string("4")) return 4;
210  else if (s == std::string("5")) return 5;
211  else if (s == std::string("6")) return 6;
212  else if (s == std::string("7")) return 7;
213  else if (s == std::string("8")) return 8;
214  else if (s == std::string("9")) return 9;
215  else assert(false);
216 }
bool MuonGeometrySanityCheckPoint::numeric ( std::string  s)
private

Definition at line 199 of file MuonGeometrySanityCheck.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

199  {
200  return (s == std::string("0") || s == std::string("1") || s == std::string("2") || s == std::string("3") || s == std::string("4") ||
201  s == std::string("5") || s == std::string("6") || s == std::string("7") || s == std::string("8") || s == std::string("9"));
202 }

Member Data Documentation

const MuonGeometrySanityCheckCustomFrame* MuonGeometrySanityCheckPoint::customFrame

Definition at line 82 of file MuonGeometrySanityCheck.cc.

DetId MuonGeometrySanityCheckPoint::detector

Definition at line 80 of file MuonGeometrySanityCheck.cc.

GlobalPoint MuonGeometrySanityCheckPoint::displacement

Definition at line 83 of file MuonGeometrySanityCheck.cc.

GlobalPoint MuonGeometrySanityCheckPoint::expectation

Definition at line 85 of file MuonGeometrySanityCheck.cc.

int MuonGeometrySanityCheckPoint::frame

Definition at line 81 of file MuonGeometrySanityCheck.cc.

bool MuonGeometrySanityCheckPoint::has_expectation

Definition at line 84 of file MuonGeometrySanityCheck.cc.

std::string MuonGeometrySanityCheckPoint::name

Definition at line 86 of file MuonGeometrySanityCheck.cc.

Referenced by ElectronMVAID.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__(), core.autovars.NTupleObjectType::addSubObjects(), core.autovars.NTupleObjectType::addVariables(), core.autovars.NTupleObjectType::allVars(), dirstructure.Directory::calcStats(), genericValidation.GenericValidationData::cfgName(), 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(), 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(), production_tasks.MonitorJobs::run(), BeautifulSoup.SoupStrainer::searchTag(), python.rootplot.utilities.Hist::TGraph(), python.rootplot.utilities.Hist::TH1F(), Vispa.Views.PropertyView.Property::valueChanged(), counter.Counter::write(), and average.Average::write().

const MuonGeometrySanityCheckCustomFrame* MuonGeometrySanityCheckPoint::outputCustomFrame

Definition at line 88 of file MuonGeometrySanityCheck.cc.

int MuonGeometrySanityCheckPoint::outputFrame

Definition at line 87 of file MuonGeometrySanityCheck.cc.

int MuonGeometrySanityCheckPoint::type