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)
 
- 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 559 of file MuonGeometrySanityCheck.cc.

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

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

Definition at line 104 of file MuonGeometrySanityCheck.cc.

Referenced by analyze(), and MuonGeometrySanityCheck().