CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonGeometrySanityCheck Class Reference

#include <Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc>

Inheritance diagram for MuonGeometrySanityCheck:
edm::EDAnalyzer

Public Member Functions

 MuonGeometrySanityCheck (const edm::ParameterSet &iConfig)
 
 ~MuonGeometrySanityCheck ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 95 of file MuonGeometrySanityCheck.cc.

Constructor & Destructor Documentation

MuonGeometrySanityCheck::MuonGeometrySanityCheck ( const edm::ParameterSet iConfig)
explicit

Definition at line 122 of file MuonGeometrySanityCheck.cc.

References edm::hlt::Exception, edm::ParameterSet::getParameter(), m_frames, m_points, mergeVDriftHistosByStation::name, point, prefix, printout, and tolerance.

122  {
123  printout = iConfig.getParameter<std::string>("printout");
124  if (printout != std::string("all") && printout != std::string("bad")) {
125  throw cms::Exception("BadConfig") << "Printout must be \"all\" or \"bad\"." << std::endl;
126  }
127 
128  tolerance = iConfig.getParameter<double>("tolerance");
129  if (tolerance <= 0) {
130  throw cms::Exception("BadConfig") << "Tolerance must be positive." << std::endl;
131  }
132 
133  prefix = iConfig.getParameter<std::string>("prefix");
134 
135  std::vector<edm::ParameterSet> frames = iConfig.getParameter<std::vector<edm::ParameterSet> >("frames");
136  for (std::vector<edm::ParameterSet>::const_iterator frame = frames.begin(); frame != frames.end(); ++frame) {
137  std::string name = frame->getParameter<std::string>("name");
138  if (m_frames.find(name) != m_frames.end()) {
139  throw cms::Exception("BadConfig") << "Custom frame \"" << name << "\" has been defined twice." << std::endl;
140  }
141  m_frames[name] = new MuonGeometrySanityCheckCustomFrame(*frame, name);
142  }
143 
144  std::vector<edm::ParameterSet> points = iConfig.getParameter<std::vector<edm::ParameterSet> >("points");
145  for (std::vector<edm::ParameterSet>::const_iterator point = points.begin(); point != points.end(); ++point) {
147  }
148 }
std::vector< MuonGeometrySanityCheckPoint > m_points
T getParameter(std::string const &) const
std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > m_frames
*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
MuonGeometrySanityCheck::~MuonGeometrySanityCheck ( )

Definition at line 150 of file MuonGeometrySanityCheck.cc.

References m_frames.

150  {
151  for (std::map<std::string,const MuonGeometrySanityCheckCustomFrame*>::iterator iter = m_frames.begin(); iter != m_frames.end(); ++iter) {
152  delete iter->second;
153  }
154 }
std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > m_frames

Member Function Documentation

void MuonGeometrySanityCheck::analyze ( const edm::Event iEvent,
const edm::EventSetup iConfig 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 557 of file MuonGeometrySanityCheck.cc.

References cond::ecalcond::bad(), CSCDetId::chamber(), gather_cfg::cout, MuonSubdetId::CSC, MuonSubdetId::DT, dt, CSCDetId::endcap(), edm::EventSetup::get(), errorMatrix2Lands_multiChannel::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().

557  {
558  edm::ESHandle<DTGeometry> dtGeometry;
559  iSetup.get<MuonGeometryRecord>().get(dtGeometry);
560 
561  edm::ESHandle<CSCGeometry> cscGeometry;
562  iSetup.get<MuonGeometryRecord>().get(cscGeometry);
563 
564  int num_transformed = 0;
565  int num_tested = 0;
566  int num_bad = 0;
567  for (std::vector<MuonGeometrySanityCheckPoint>::const_iterator point = m_points.begin(); point != m_points.end(); ++point) {
568  num_transformed++;
569 
570  bool dt = (point->detector.subdetId() == MuonSubdetId::DT);
571 
572  // convert the displacement vector into the chosen coordinate system and add it to the chamber's position
573  GlobalPoint chamberPos;
574  if (dt) chamberPos = dtGeometry->idToDet(point->detector)->surface().toGlobal(LocalPoint(0., 0., 0.));
575  else chamberPos = cscGeometry->idToDet(point->detector)->surface().toGlobal(LocalPoint(0., 0., 0.));
576 
579  result = GlobalPoint(chamberPos.x() + point->displacement.x(), chamberPos.y() + point->displacement.y(), chamberPos.z() + point->displacement.z());
580  }
581 
582  else if (point->frame == MuonGeometrySanityCheckPoint::kLocal) {
583  if (dt) result = dtGeometry->idToDet(point->detector)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
584  else result = cscGeometry->idToDet(point->detector)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
585  }
586 
587  else if (point->frame == MuonGeometrySanityCheckPoint::kChamber) {
588  if (point->detector.subdetId() == MuonSubdetId::DT) {
589  DTChamberId id(point->detector);
590  if (dt) result = dtGeometry->idToDet(id)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
591  else result = cscGeometry->idToDet(id)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
592  }
593  else if (point->detector.subdetId() == MuonSubdetId::CSC) {
594  CSCDetId cscid(point->detector);
595  CSCDetId id(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber());
596  if (dt) result = dtGeometry->idToDet(id)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
597  else result = cscGeometry->idToDet(id)->surface().toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
598  }
599  else { assert(false); }
600  }
601 
602  else if (point->frame == MuonGeometrySanityCheckPoint::kCustom) {
603  GlobalPoint transformed = point->customFrame->transform(point->displacement);
604  result = GlobalPoint(chamberPos.x() + transformed.x(), chamberPos.y() + transformed.y(), chamberPos.z() + transformed.z());
605  }
606 
607  else { assert(false); }
608 
609  // convert the result into the chosen output coordinate system
610  if (point->outputFrame == MuonGeometrySanityCheckPoint::kGlobal) { }
611 
612  else if (point->outputFrame == MuonGeometrySanityCheckPoint::kLocal) {
613  LocalPoint transformed;
614  if (dt) transformed = dtGeometry->idToDet(point->detector)->surface().toLocal(result);
615  else transformed = cscGeometry->idToDet(point->detector)->surface().toLocal(result);
616  result = GlobalPoint(transformed.x(), transformed.y(), transformed.z());
617  }
618 
619  else if (point->outputFrame == MuonGeometrySanityCheckPoint::kChamber) {
620  if (point->detector.subdetId() == MuonSubdetId::DT) {
621  DTChamberId id(point->detector);
622  LocalPoint transformed;
623  if (dt) transformed = dtGeometry->idToDet(id)->surface().toLocal(result);
624  else transformed = cscGeometry->idToDet(id)->surface().toLocal(result);
625  result = GlobalPoint(transformed.x(), transformed.y(), transformed.z());
626  }
627  else if (point->detector.subdetId() == MuonSubdetId::CSC) {
628  CSCDetId cscid(point->detector);
629  CSCDetId id(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber());
630  LocalPoint transformed;
631  if (dt) transformed = dtGeometry->idToDet(id)->surface().toLocal(result);
632  else transformed = cscGeometry->idToDet(id)->surface().toLocal(result);
633  result = GlobalPoint(transformed.x(), transformed.y(), transformed.z());
634  }
635  else { assert(false); }
636  }
637 
638  else if (point->outputFrame == MuonGeometrySanityCheckPoint::kCustom) {
639  result = point->outputCustomFrame->transformInverse(result);
640  }
641 
642  std::stringstream output;
643  output << prefix << " " << point->name << " " << point->detName() << " " << result.x() << " " << result.y() << " " << result.z();
644 
645  bool bad = false;
646  if (point->has_expectation) {
647  num_tested++;
648  double residx = result.x() - point->expectation.x();
649  double residy = result.y() - point->expectation.y();
650  double residz = result.z() - point->expectation.z();
651 
652  if (fabs(residx) > tolerance || fabs(residy) > tolerance || fabs(residz) > tolerance) {
653  num_bad++;
654  bad = true;
655  output << " BAD " << residx << " " << residy << " " << residz << std::endl;
656  }
657  else {
658  output << " GOOD " << residx << " " << residy << " " << residz << std::endl;
659  }
660  }
661  else {
662  output << " UNTESTED 0 0 0" << std::endl;
663  }
664 
665  if (printout == std::string("all") || (printout == std::string("bad") && bad)) {
666  std::cout << output.str();
667  }
668  }
669 
670  std::cout << std::endl << "SUMMARY transformed: " << num_transformed << " tested: " << num_tested << " bad: " << num_bad << " good: " << (num_tested - num_bad) << std::endl;
671 }
std::vector< MuonGeometrySanityCheckPoint > m_points
float dt
Definition: AMPTWrapper.h:126
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:62
int bad(Items const &cont)
static const int CSC
Definition: MuonSubdetId.h:15
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
tuple cout
Definition: gather_cfg.py:121
static const int DT
Definition: MuonSubdetId.h:14
T x() const
Definition: PV3DBase.h:61
*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

Member Data Documentation

std::map<std::string,const MuonGeometrySanityCheckCustomFrame*> MuonGeometrySanityCheck::m_frames
private
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