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) |
Definition at line 58 of file MuonGeometrySanityCheck.cc.
anonymous enum |
Definition at line 62 of file MuonGeometrySanityCheck.cc.
{ kDTChamber, kDTSuperLayer, kDTLayer, kCSCChamber, kCSCLayer };
anonymous enum |
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, 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.
{ std::string detName = iConfig.getParameter<std::string>("detector"); bool parsing_error = false; bool barrel = (detName.substr(0, 2) == std::string("MB")); bool endcap = (detName.substr(0, 2) == std::string("ME")); if (!barrel && !endcap) parsing_error = true; if (!parsing_error && barrel) { int index = 2; bool plus = true; if (detName.substr(index, 1) == std::string("+")) { plus = true; index++; } else if (detName.substr(index, 1) == std::string("-")) { plus = false; index++; } int wheel = 0; bool wheel_digit = false; while (!parsing_error && numeric(detName.substr(index, 1))) { wheel *= 10; wheel += number(detName.substr(index, 1)); wheel_digit = true; index++; } if (!plus) wheel *= -1; if (!wheel_digit) parsing_error = true; if (detName.substr(index, 1) != std::string("/")) parsing_error = true; index++; int station = 0; bool station_digit = false; while (!parsing_error && numeric(detName.substr(index, 1))) { station *= 10; station += number(detName.substr(index, 1)); station_digit = true; index++; } if (!station_digit) parsing_error = true; if (detName.substr(index, 1) != std::string("/")) parsing_error = true; index++; int sector = 0; bool sector_digit = false; while (!parsing_error && numeric(detName.substr(index, 1))) { sector *= 10; sector += number(detName.substr(index, 1)); sector_digit = true; index++; } if (!sector_digit) parsing_error = true; // these are optional int superlayer = 0; bool superlayer_digit = false; int layer = 0; if (detName.substr(index, 1) == std::string("/")) { index++; while (!parsing_error && numeric(detName.substr(index, 1))) { superlayer *= 10; superlayer += number(detName.substr(index, 1)); superlayer_digit = true; index++; } if (!superlayer_digit) parsing_error = true; if (detName.substr(index, 1) == std::string("/")) { index++; while (!parsing_error && numeric(detName.substr(index, 1))) { layer *= 10; layer += number(detName.substr(index, 1)); index++; } } } if (!parsing_error) { bool no_such_chamber = false; if (wheel < -2 || wheel > 2) no_such_chamber = true; if (station < 1 || station > 4) no_such_chamber = true; if (station == 4 && (sector < 1 || sector > 14)) no_such_chamber = true; if (station < 4 && (sector < 1 || sector > 12)) no_such_chamber = true; if (no_such_chamber) { throw cms::Exception("BadConfig") << "Chamber doesn't exist: MB" << (plus ? "+" : "-") << wheel << "/" << station << "/" << sector << std::endl; } if (superlayer == 0) { detector = DTChamberId(wheel, station, sector); type = kDTChamber; } else { bool no_such_superlayer = false; if (superlayer < 1 || superlayer > 3) no_such_superlayer = true; if (station == 4 && superlayer == 2) no_such_superlayer = true; if (no_such_superlayer) { throw cms::Exception("BadConfig") << "Superlayer doesn't exist: MB" << (plus ? "+" : "-") << wheel << "/" << station << "/" << sector << "/" << superlayer << std::endl; } if (layer == 0) { detector = DTSuperLayerId(wheel, station, sector, superlayer); type = kDTSuperLayer; } else { bool no_such_layer = false; if (layer < 1 || layer > 4) no_such_layer = true; if (no_such_layer) { throw cms::Exception("BadConfig") << "Layer doesn't exist: MB" << (plus ? "+" : "-") << wheel << "/" << station << "/" << sector << "/" << superlayer << "/" << layer << std::endl; } detector = DTLayerId(wheel, station, sector, superlayer, layer); type = kDTLayer; } } } } else if (!parsing_error && endcap) { int index = 2; bool plus = true; if (detName.substr(index, 1) == std::string("+")) { plus = true; index++; } else if (detName.substr(index, 1) == std::string("-")) { plus = false; index++; } else parsing_error = true; int station = 0; bool station_digit = false; while (!parsing_error && numeric(detName.substr(index, 1))) { station *= 10; station += number(detName.substr(index, 1)); station_digit = true; index++; } if (!plus) station *= -1; if (!station_digit) parsing_error = true; if (detName.substr(index, 1) != std::string("/")) parsing_error = true; index++; int ring = 0; bool ring_digit = false; while (!parsing_error && numeric(detName.substr(index, 1))) { ring *= 10; ring += number(detName.substr(index, 1)); ring_digit = true; index++; } if (!ring_digit) parsing_error = true; if (detName.substr(index, 1) != std::string("/")) parsing_error = true; index++; int chamber = 0; bool chamber_digit = false; while (!parsing_error && numeric(detName.substr(index, 1))) { chamber *= 10; chamber += number(detName.substr(index, 1)); chamber_digit = true; index++; } if (!chamber_digit) parsing_error = true; // this is optional int layer = 0; bool layer_digit = false; if (detName.substr(index, 1) == std::string("/")) { index++; while (!parsing_error && numeric(detName.substr(index, 1))) { layer *= 10; layer += number(detName.substr(index, 1)); layer_digit = true; index++; } if (!layer_digit) parsing_error = true; } if (!parsing_error) { bool no_such_chamber = false; int endcap = (station > 0 ? 1 : 2); station = abs(station); if (station < 1 || station > 4) no_such_chamber = true; if (station == 1 && (ring < 1 || ring > 4)) no_such_chamber = true; if (station > 1 && (ring < 1 || ring > 2)) no_such_chamber = true; if (station == 1 && (chamber < 1 || chamber > 36)) no_such_chamber = true; if (station > 1 && ring == 1 && (chamber < 1 || chamber > 18)) no_such_chamber = true; if (station > 1 && ring == 2 && (chamber < 1 || chamber > 36)) no_such_chamber = true; if (no_such_chamber) { throw cms::Exception("BadConfig") << "Chamber doesn't exist: ME" << (endcap == 1 ? "+" : "-") << station << "/" << ring << "/" << chamber << std::endl; } if (layer == 0) { detector = CSCDetId(endcap, station, ring, chamber); type = kCSCChamber; } else { bool no_such_layer = false; if (layer < 1 || layer > 6) no_such_layer = true; if (no_such_layer) { throw cms::Exception("BadConfig") << "Layer doesn't exist: ME" << (endcap == 1 ? "+" : "-") << station << "/" << ring << "/" << chamber << "/" << layer << std::endl; } detector = CSCDetId(endcap, station, ring, chamber, layer); type = kCSCLayer; } } } if (parsing_error) { throw cms::Exception("BadConfig") << "Detector name is malformed: " << detName << std::endl; } std::string frameName = iConfig.getParameter<std::string>("frame"); const std::map<std::string,const MuonGeometrySanityCheckCustomFrame*>::const_iterator frameIter = frames.find(frameName); if (frameName == std::string("global")) { frame = kGlobal; customFrame = NULL; } else if (frameName == std::string("local")) { frame = kLocal; customFrame = NULL; } else if (frameName == std::string("chamber")) { frame = kChamber; customFrame = NULL; } else if (frameIter != frames.end()) { frame = kCustom; customFrame = frameIter->second; } else { throw cms::Exception("BadConfig") << "Frame \"" << frameName << "\" has not been defined." << std::endl; } std::vector<double> point = iConfig.getParameter<std::vector<double> >("displacement"); if (point.size() != 3) { throw cms::Exception("BadConfig") << "Displacement relative to detector " << detName << " doesn't have exactly three components." << std::endl; } displacement = GlobalPoint(point[0], point[1], point[2]); const edm::Entry *entry = iConfig.retrieveUnknown("expectation"); if (entry != NULL) { has_expectation = true; point = iConfig.getParameter<std::vector<double> >("expectation"); if (point.size() != 3) { throw cms::Exception("BadConfig") << "Expectation for detector " << detName << ", displacement " << displacement << " doesn't have exactly three components." << std::endl; } expectation = GlobalPoint(point[0], point[1], point[2]); } else { has_expectation = false; } entry = iConfig.retrieveUnknown("name"); if (entry != NULL) { name = iConfig.getParameter<std::string>("name"); } else { name = std::string("anonymous"); } entry = iConfig.retrieveUnknown("outputFrame"); if (entry != NULL) { frameName = iConfig.getParameter<std::string>("outputFrame"); const std::map<std::string,const MuonGeometrySanityCheckCustomFrame*>::const_iterator frameIter = frames.find(frameName); if (frameName == std::string("global")) { outputFrame = kGlobal; outputCustomFrame = NULL; } else if (frameName == std::string("local")) { outputFrame = kLocal; outputCustomFrame = NULL; } else if (frameName == std::string("chamber")) { outputFrame = kChamber; outputCustomFrame = NULL; } else if (frameIter != frames.end()) { outputFrame = kCustom; outputCustomFrame = frameIter->second; } else { throw cms::Exception("BadConfig") << "Frame \"" << frameName << "\" has not been defined." << std::endl; } } else { outputFrame = kGlobal; outputCustomFrame = NULL; } }
std::string MuonGeometrySanityCheckPoint::detName | ( | ) | const |
Definition at line 529 of file MuonGeometrySanityCheck.cc.
References detector, kCSCChamber, kCSCLayer, kDTChamber, kDTLayer, kDTSuperLayer, convertSQLitetoXML_cfg::output, and relativeConstraints::station.
Referenced by MuonGeometrySanityCheckPoint().
{ std::stringstream output; if (type == kDTChamber) { DTChamberId id(detector); output << "MB" << (id.wheel() > 0 ? "+" : "") << id.wheel() << "/" << id.station() << "/" << id.sector(); } else if (type == kDTSuperLayer) { DTSuperLayerId id(detector); output << "MB" << (id.wheel() > 0 ? "+" : "") << id.wheel() << "/" << id.station() << "/" << id.sector() << "/" << id.superlayer(); } else if (type == kDTLayer) { DTLayerId id(detector); output << "MB" << (id.wheel() > 0 ? "+" : "") << id.wheel() << "/" << id.station() << "/" << id.sector() << "/" << id.superlayer() << "/" << id.layer(); } else if (type == kCSCChamber) { CSCDetId id(detector); output << "ME" << (id.endcap() == 1 ? "+" : "-") << id.station() << "/" << id.ring() << "/" << id.chamber(); } else if (type == kCSCLayer) { CSCDetId id(detector); output << "ME" << (id.endcap() == 1 ? "+" : "-") << id.station() << "/" << id.ring() << "/" << id.chamber() << "/" << id.layer(); } else assert(false); return output.str(); }
int MuonGeometrySanityCheckPoint::number | ( | std::string | s | ) | [private] |
Definition at line 204 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheckPoint().
{ if (s == std::string("0")) return 0; else if (s == std::string("1")) return 1; else if (s == std::string("2")) return 2; else if (s == std::string("3")) return 3; else if (s == std::string("4")) return 4; else if (s == std::string("5")) return 5; else if (s == std::string("6")) return 6; else if (s == std::string("7")) return 7; else if (s == std::string("8")) return 8; else if (s == std::string("9")) return 9; else assert(false); }
bool MuonGeometrySanityCheckPoint::numeric | ( | std::string | s | ) | [private] |
Definition at line 199 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheckPoint().
Definition at line 82 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheckPoint().
Definition at line 80 of file MuonGeometrySanityCheck.cc.
Referenced by detName(), and MuonGeometrySanityCheckPoint().
Definition at line 83 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheckPoint().
Definition at line 85 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheckPoint().
Definition at line 81 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheckPoint().
Definition at line 84 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheckPoint().
std::string MuonGeometrySanityCheckPoint::name |
Definition at line 86 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheckPoint().
Definition at line 88 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheckPoint().
Definition at line 87 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheckPoint().
Definition at line 79 of file MuonGeometrySanityCheck.cc.