CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
MuonGeometrySanityCheckCustomFrame
customFrame
 
DetId detector
 
GlobalPoint displacement
 
GlobalPoint expectation
 
int frame
 
bool has_expectation
 
std::string name
 
const
MuonGeometrySanityCheckCustomFrame
outputCustomFrame
 
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 abs, Reference_intrackfit_cff::barrel, CSCDetId, customFrame, detector, detName(), displacement, DTChamberId, DTLayerId, DTSuperLayerId, Reference_intrackfit_cff::endcap, edm::hlt::Exception, expectation, frame, relativeConstraints::frameName, edm::ParameterSet::getParameter(), has_expectation, getHLTprescales::index, kChamber, kCSCChamber, kCSCLayer, kCustom, kDTChamber, kDTLayer, kDTSuperLayer, kGlobal, kLocal, name, NULL, number(), numeric(), outputCustomFrame, outputFrame, reco::HaloData::plus, point, edm::ParameterSet::retrieveUnknown(), relativeConstraints::ring, and relativeConstraints::station.

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  bool layer_digit = false;
282  if (detName.substr(index, 1) == std::string("/")) {
283  index++;
284  while (!parsing_error && numeric(detName.substr(index, 1))) {
285  superlayer *= 10;
286  superlayer += number(detName.substr(index, 1));
287  superlayer_digit = true;
288  index++;
289  }
290  if (!superlayer_digit) parsing_error = true;
291 
292  if (detName.substr(index, 1) == std::string("/")) {
293  index++;
294  while (!parsing_error && numeric(detName.substr(index, 1))) {
295  layer *= 10;
296  layer += number(detName.substr(index, 1));
297  layer_digit = true;
298  index++;
299  }
300  }
301  }
302 
303  if (!parsing_error) {
304  bool no_such_chamber = false;
305 
306  if (wheel < -2 || wheel > 2) no_such_chamber = true;
307  if (station < 1 || station > 4) no_such_chamber = true;
308  if (station == 4 && (sector < 1 || sector > 14)) no_such_chamber = true;
309  if (station < 4 && (sector < 1 || sector > 12)) no_such_chamber = true;
310 
311  if (no_such_chamber) {
312  throw cms::Exception("BadConfig") << "Chamber doesn't exist: MB" << (plus ? "+" : "-") << wheel << "/" << station << "/" << sector << std::endl;
313  }
314 
315  if (superlayer == 0) {
316  detector = DTChamberId(wheel, station, sector);
317  type = kDTChamber;
318  }
319  else {
320  bool no_such_superlayer = false;
321  if (superlayer < 1 || superlayer > 3) no_such_superlayer = true;
322  if (station == 4 && superlayer == 2) no_such_superlayer = true;
323 
324  if (no_such_superlayer) {
325  throw cms::Exception("BadConfig") << "Superlayer doesn't exist: MB" << (plus ? "+" : "-") << wheel << "/" << station << "/" << sector << "/" << superlayer << std::endl;
326  }
327 
328  if (layer == 0) {
329  detector = DTSuperLayerId(wheel, station, sector, superlayer);
331  }
332  else {
333  bool no_such_layer = false;
334  if (layer < 1 || layer > 4) no_such_layer = true;
335 
336  if (no_such_layer) {
337  throw cms::Exception("BadConfig") << "Layer doesn't exist: MB" << (plus ? "+" : "-") << wheel << "/" << station << "/" << sector << "/" << superlayer << "/" << layer << std::endl;
338  }
339 
340  detector = DTLayerId(wheel, station, sector, superlayer, layer);
341  type = kDTLayer;
342  }
343  }
344  }
345  }
346  else if (!parsing_error && endcap) {
347  int index = 2;
348 
349  bool plus = true;
350  if (detName.substr(index, 1) == std::string("+")) {
351  plus = true;
352  index++;
353  }
354  else if (detName.substr(index, 1) == std::string("-")) {
355  plus = false;
356  index++;
357  }
358  else parsing_error = true;
359 
360  int station = 0;
361  bool station_digit = false;
362  while (!parsing_error && numeric(detName.substr(index, 1))) {
363  station *= 10;
364  station += number(detName.substr(index, 1));
365  station_digit = true;
366  index++;
367  }
368  if (!plus) station *= -1;
369  if (!station_digit) parsing_error = true;
370 
371  if (detName.substr(index, 1) != std::string("/")) parsing_error = true;
372  index++;
373 
374  int ring = 0;
375  bool ring_digit = false;
376  while (!parsing_error && numeric(detName.substr(index, 1))) {
377  ring *= 10;
378  ring += number(detName.substr(index, 1));
379  ring_digit = true;
380  index++;
381  }
382  if (!ring_digit) parsing_error = true;
383 
384  if (detName.substr(index, 1) != std::string("/")) parsing_error = true;
385  index++;
386 
387  int chamber = 0;
388  bool chamber_digit = false;
389  while (!parsing_error && numeric(detName.substr(index, 1))) {
390  chamber *= 10;
391  chamber += number(detName.substr(index, 1));
392  chamber_digit = true;
393  index++;
394  }
395  if (!chamber_digit) parsing_error = true;
396 
397  // this is optional
398  int layer = 0;
399  bool layer_digit = false;
400  if (detName.substr(index, 1) == std::string("/")) {
401  index++;
402  while (!parsing_error && numeric(detName.substr(index, 1))) {
403  layer *= 10;
404  layer += number(detName.substr(index, 1));
405  layer_digit = true;
406  index++;
407  }
408  if (!layer_digit) parsing_error = true;
409  }
410 
411  if (!parsing_error) {
412  bool no_such_chamber = false;
413 
414  int endcap = (station > 0 ? 1 : 2);
415  station = abs(station);
416  if (station < 1 || station > 4) no_such_chamber = true;
417  if (station == 1 && (ring < 1 || ring > 4)) no_such_chamber = true;
418  if (station > 1 && (ring < 1 || ring > 2)) no_such_chamber = true;
419  if (station == 1 && (chamber < 1 || chamber > 36)) no_such_chamber = true;
420  if (station > 1 && ring == 1 && (chamber < 1 || chamber > 18)) no_such_chamber = true;
421  if (station > 1 && ring == 2 && (chamber < 1 || chamber > 36)) no_such_chamber = true;
422 
423  if (no_such_chamber) {
424  throw cms::Exception("BadConfig") << "Chamber doesn't exist: ME" << (endcap == 1 ? "+" : "-") << station << "/" << ring << "/" << chamber << std::endl;
425  }
426 
427  if (layer == 0) {
428  detector = CSCDetId(endcap, station, ring, chamber);
429  type = kCSCChamber;
430  }
431  else {
432  bool no_such_layer = false;
433  if (layer < 1 || layer > 6) no_such_layer = true;
434 
435  if (no_such_layer) {
436  throw cms::Exception("BadConfig") << "Layer doesn't exist: ME" << (endcap == 1 ? "+" : "-") << station << "/" << ring << "/" << chamber << "/" << layer << std::endl;
437  }
438 
439  detector = CSCDetId(endcap, station, ring, chamber, layer);
440  type = kCSCLayer;
441  }
442  }
443  }
444 
445  if (parsing_error) {
446  throw cms::Exception("BadConfig") << "Detector name is malformed: " << detName << std::endl;
447  }
448 
449  std::string frameName = iConfig.getParameter<std::string>("frame");
450  const std::map<std::string,const MuonGeometrySanityCheckCustomFrame*>::const_iterator frameIter = frames.find(frameName);
451  if (frameName == std::string("global")) {
452  frame = kGlobal;
453  customFrame = NULL;
454  }
455  else if (frameName == std::string("local")) {
456  frame = kLocal;
457  customFrame = NULL;
458  }
459  else if (frameName == std::string("chamber")) {
460  frame = kChamber;
461  customFrame = NULL;
462  }
463  else if (frameIter != frames.end()) {
464  frame = kCustom;
465  customFrame = frameIter->second;
466  }
467  else {
468  throw cms::Exception("BadConfig") << "Frame \"" << frameName << "\" has not been defined." << std::endl;
469  }
470 
471  std::vector<double> point = iConfig.getParameter<std::vector<double> >("displacement");
472  if (point.size() != 3) {
473  throw cms::Exception("BadConfig") << "Displacement relative to detector " << detName << " doesn't have exactly three components." << std::endl;
474  }
475 
476  displacement = GlobalPoint(point[0], point[1], point[2]);
477 
478  const edm::Entry *entry = iConfig.retrieveUnknown("expectation");
479  if (entry != NULL) {
480  has_expectation = true;
481 
482  point = iConfig.getParameter<std::vector<double> >("expectation");
483  if (point.size() != 3) {
484  throw cms::Exception("BadConfig") << "Expectation for detector " << detName << ", displacement " << displacement << " doesn't have exactly three components." << std::endl;
485  }
486 
487  expectation = GlobalPoint(point[0], point[1], point[2]);
488  }
489  else {
490  has_expectation = false;
491  }
492 
493  entry = iConfig.retrieveUnknown("name");
494  if (entry != NULL) {
495  name = iConfig.getParameter<std::string>("name");
496  }
497  else {
498  name = std::string("anonymous");
499  }
500 
501  entry = iConfig.retrieveUnknown("outputFrame");
502  if (entry != NULL) {
503  frameName = iConfig.getParameter<std::string>("outputFrame");
504  const std::map<std::string,const MuonGeometrySanityCheckCustomFrame*>::const_iterator frameIter = frames.find(frameName);
505  if (frameName == std::string("global")) {
508  }
509  else if (frameName == std::string("local")) {
512  }
513  else if (frameName == std::string("chamber")) {
516  }
517  else if (frameIter != frames.end()) {
519  outputCustomFrame = frameIter->second;
520  }
521  else {
522  throw cms::Exception("BadConfig") << "Frame \"" << frameName << "\" has not been defined." << std::endl;
523  }
524  }
525  else {
528  }
529 }
type
Definition: HCALResponse.h:22
T getParameter(std::string const &) const
Entry const *const retrieveUnknown(char const *) const
const MuonGeometrySanityCheckCustomFrame * outputCustomFrame
DTSuperLayerId
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
#define abs(x)
Definition: mlp_lapack.h:159
#define NULL
Definition: scimark2.h:8
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
*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 531 of file MuonGeometrySanityCheck.cc.

References detector, kCSCChamber, kCSCLayer, kDTChamber, kDTLayer, kDTSuperLayer, convertSQLitetoXML_cfg::output, and relativeConstraints::station.

Referenced by MuonGeometrySanityCheckPoint().

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

Definition at line 204 of file MuonGeometrySanityCheck.cc.

Referenced by MuonGeometrySanityCheckPoint().

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 }
string s
Definition: asciidump.py:422
bool MuonGeometrySanityCheckPoint::numeric ( std::string  s)
private

Definition at line 199 of file MuonGeometrySanityCheck.cc.

Referenced by MuonGeometrySanityCheckPoint().

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 }
string s
Definition: asciidump.py:422

Member Data Documentation

const MuonGeometrySanityCheckCustomFrame* MuonGeometrySanityCheckPoint::customFrame

Definition at line 82 of file MuonGeometrySanityCheck.cc.

Referenced by MuonGeometrySanityCheckPoint().

DetId MuonGeometrySanityCheckPoint::detector

Definition at line 80 of file MuonGeometrySanityCheck.cc.

Referenced by detName(), and MuonGeometrySanityCheckPoint().

GlobalPoint MuonGeometrySanityCheckPoint::displacement

Definition at line 83 of file MuonGeometrySanityCheck.cc.

Referenced by MuonGeometrySanityCheckPoint().

GlobalPoint MuonGeometrySanityCheckPoint::expectation

Definition at line 85 of file MuonGeometrySanityCheck.cc.

Referenced by MuonGeometrySanityCheckPoint().

int MuonGeometrySanityCheckPoint::frame

Definition at line 81 of file MuonGeometrySanityCheck.cc.

Referenced by MuonGeometrySanityCheckPoint().

bool MuonGeometrySanityCheckPoint::has_expectation

Definition at line 84 of file MuonGeometrySanityCheck.cc.

Referenced by MuonGeometrySanityCheckPoint().

std::string MuonGeometrySanityCheckPoint::name
const MuonGeometrySanityCheckCustomFrame* MuonGeometrySanityCheckPoint::outputCustomFrame

Definition at line 88 of file MuonGeometrySanityCheck.cc.

Referenced by MuonGeometrySanityCheckPoint().

int MuonGeometrySanityCheckPoint::outputFrame

Definition at line 87 of file MuonGeometrySanityCheck.cc.

Referenced by MuonGeometrySanityCheckPoint().

int MuonGeometrySanityCheckPoint::type