#include <Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc>
Public Member Functions | |
MuonGeometrySanityCheck (const edm::ParameterSet &iConfig) | |
~MuonGeometrySanityCheck () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &iConfig) |
Private Attributes | |
std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > | m_frames |
std::vector < MuonGeometrySanityCheckPoint > | m_points |
std::string | prefix |
std::string | printout |
double | tolerance |
Description: <one line="" class="" summary>="">
Implementation: <Notes on="" implementation>="">
Definition at line 95 of file MuonGeometrySanityCheck.cc.
MuonGeometrySanityCheck::MuonGeometrySanityCheck | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 122 of file MuonGeometrySanityCheck.cc.
References Exception, edm::ParameterSet::getParameter(), m_frames, m_points, AlCaRecoCosmics_cfg::name, point, prefix, printout, and tolerance.
{ printout = iConfig.getParameter<std::string>("printout"); if (printout != std::string("all") && printout != std::string("bad")) { throw cms::Exception("BadConfig") << "Printout must be \"all\" or \"bad\"." << std::endl; } tolerance = iConfig.getParameter<double>("tolerance"); if (tolerance <= 0) { throw cms::Exception("BadConfig") << "Tolerance must be positive." << std::endl; } prefix = iConfig.getParameter<std::string>("prefix"); std::vector<edm::ParameterSet> frames = iConfig.getParameter<std::vector<edm::ParameterSet> >("frames"); for (std::vector<edm::ParameterSet>::const_iterator frame = frames.begin(); frame != frames.end(); ++frame) { std::string name = frame->getParameter<std::string>("name"); if (m_frames.find(name) != m_frames.end()) { throw cms::Exception("BadConfig") << "Custom frame \"" << name << "\" has been defined twice." << std::endl; } m_frames[name] = new MuonGeometrySanityCheckCustomFrame(*frame, name); } std::vector<edm::ParameterSet> points = iConfig.getParameter<std::vector<edm::ParameterSet> >("points"); for (std::vector<edm::ParameterSet>::const_iterator point = points.begin(); point != points.end(); ++point) { m_points.push_back(MuonGeometrySanityCheckPoint(*point, m_frames)); } }
MuonGeometrySanityCheck::~MuonGeometrySanityCheck | ( | ) |
Definition at line 150 of file MuonGeometrySanityCheck.cc.
References m_frames.
void MuonGeometrySanityCheck::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iConfig | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 559 of file MuonGeometrySanityCheck.cc.
References cond::ecalcond::bad(), CSCDetId::chamber(), gather_cfg::cout, CSC(), dt, GeomDetEnumerators::DT, CSCDetId::endcap(), edm::EventSetup::get(), ExpressReco_HICollisions_FallBack::id, MuonGeometrySanityCheckPoint::kChamber, MuonGeometrySanityCheckPoint::kCustom, MuonGeometrySanityCheckPoint::kGlobal, MuonGeometrySanityCheckPoint::kLocal, m_points, convertSQLitetoXML_cfg::output, point, prefix, printout, query::result, CSCDetId::ring(), CSCDetId::station(), tolerance, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
{ edm::ESHandle<DTGeometry> dtGeometry; iSetup.get<MuonGeometryRecord>().get(dtGeometry); edm::ESHandle<CSCGeometry> cscGeometry; iSetup.get<MuonGeometryRecord>().get(cscGeometry); int num_transformed = 0; int num_tested = 0; int num_bad = 0; for (std::vector<MuonGeometrySanityCheckPoint>::const_iterator point = m_points.begin(); point != m_points.end(); ++point) { num_transformed++; bool dt = (point->detector.subdetId() == MuonSubdetId::DT); // convert the displacement vector into the chosen coordinate system and add it to the chamber's position GlobalPoint chamberPos; if (dt) chamberPos = dtGeometry->idToDet(point->detector)->surface().toGlobal(LocalPoint(0., 0., 0.)); else chamberPos = cscGeometry->idToDet(point->detector)->surface().toGlobal(LocalPoint(0., 0., 0.)); GlobalPoint result; if (point->frame == MuonGeometrySanityCheckPoint::kGlobal) { result = GlobalPoint(chamberPos.x() + point->displacement.x(), chamberPos.y() + point->displacement.y(), chamberPos.z() + point->displacement.z()); } else if (point->frame == MuonGeometrySanityCheckPoint::kLocal) { if (dt) result = dtGeometry->idToDet(point->detector)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z())); else result = cscGeometry->idToDet(point->detector)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z())); } else if (point->frame == MuonGeometrySanityCheckPoint::kChamber) { if (point->detector.subdetId() == MuonSubdetId::DT) { DTChamberId id(point->detector); if (dt) result = dtGeometry->idToDet(id)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z())); else result = cscGeometry->idToDet(id)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z())); } else if (point->detector.subdetId() == MuonSubdetId::CSC) { CSCDetId cscid(point->detector); CSCDetId id(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber()); if (dt) result = dtGeometry->idToDet(id)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z())); else result = cscGeometry->idToDet(id)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z())); } else { assert(false); } } else if (point->frame == MuonGeometrySanityCheckPoint::kCustom) { GlobalPoint transformed = point->customFrame->transform(point->displacement); result = GlobalPoint(chamberPos.x() + transformed.x(), chamberPos.y() + transformed.y(), chamberPos.z() + transformed.z()); } else { assert(false); } // convert the result into the chosen output coordinate system if (point->outputFrame == MuonGeometrySanityCheckPoint::kGlobal) { } else if (point->outputFrame == MuonGeometrySanityCheckPoint::kLocal) { LocalPoint transformed; if (dt) transformed = dtGeometry->idToDet(point->detector)->surface().toLocal(result); else transformed = cscGeometry->idToDet(point->detector)->surface().toLocal(result); result = GlobalPoint(transformed.x(), transformed.y(), transformed.z()); } else if (point->outputFrame == MuonGeometrySanityCheckPoint::kChamber) { if (point->detector.subdetId() == MuonSubdetId::DT) { DTChamberId id(point->detector); LocalPoint transformed; if (dt) transformed = dtGeometry->idToDet(id)->surface().toLocal(result); else transformed = cscGeometry->idToDet(id)->surface().toLocal(result); result = GlobalPoint(transformed.x(), transformed.y(), transformed.z()); } else if (point->detector.subdetId() == MuonSubdetId::CSC) { CSCDetId cscid(point->detector); CSCDetId id(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber()); LocalPoint transformed; if (dt) transformed = dtGeometry->idToDet(id)->surface().toLocal(result); else transformed = cscGeometry->idToDet(id)->surface().toLocal(result); result = GlobalPoint(transformed.x(), transformed.y(), transformed.z()); } else { assert(false); } } else if (point->outputFrame == MuonGeometrySanityCheckPoint::kCustom) { result = point->outputCustomFrame->transformInverse(result); } std::stringstream output; output << prefix << " " << point->name << " " << point->detName() << " " << result.x() << " " << result.y() << " " << result.z(); bool bad = false; if (point->has_expectation) { num_tested++; double residx = result.x() - point->expectation.x(); double residy = result.y() - point->expectation.y(); double residz = result.z() - point->expectation.z(); if (fabs(residx) > tolerance || fabs(residy) > tolerance || fabs(residz) > tolerance) { num_bad++; bad = true; output << " BAD " << residx << " " << residy << " " << residz << std::endl; } else { output << " GOOD " << residx << " " << residy << " " << residz << std::endl; } } else { output << " UNTESTED 0 0 0" << std::endl; } if (printout == std::string("all") || (printout == std::string("bad") && bad)) { std::cout << output.str(); } } std::cout << std::endl << "SUMMARY transformed: " << num_transformed << " tested: " << num_tested << " bad: " << num_bad << " good: " << (num_tested - num_bad) << std::endl; }
std::map<std::string,const MuonGeometrySanityCheckCustomFrame*> MuonGeometrySanityCheck::m_frames [private] |
Definition at line 106 of file MuonGeometrySanityCheck.cc.
Referenced by MuonGeometrySanityCheck(), and ~MuonGeometrySanityCheck().
std::vector<MuonGeometrySanityCheckPoint> MuonGeometrySanityCheck::m_points [private] |
Definition at line 107 of file MuonGeometrySanityCheck.cc.
Referenced by analyze(), and MuonGeometrySanityCheck().
std::string MuonGeometrySanityCheck::prefix [private] |
Definition at line 105 of file MuonGeometrySanityCheck.cc.
Referenced by analyze(), and MuonGeometrySanityCheck().
std::string MuonGeometrySanityCheck::printout [private] |
Definition at line 103 of file MuonGeometrySanityCheck.cc.
Referenced by analyze(), and MuonGeometrySanityCheck().
double MuonGeometrySanityCheck::tolerance [private] |
Definition at line 104 of file MuonGeometrySanityCheck.cc.
Referenced by analyze(), and MuonGeometrySanityCheck().