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 edm::EDConsumerBase

Public Member Functions

 MuonGeometrySanityCheck (const edm::ParameterSet &iConfig)
 
 ~MuonGeometrySanityCheck ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &iConfig) override
 

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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 Exception, edm::ParameterSet::getParameter(), m_frames, m_points, mergeVDriftHistosByStation::name, point, prefix, printout, AlCaHLTBitMon_QueryRunRegistry::string, 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 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 557 of file MuonGeometrySanityCheck.cc.

References assert(), 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, mps_fire::result, CSCDetId::ring(), CSCDetId::station(), AlCaHLTBitMon_QueryRunRegistry::string, 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
assert(m_qm.get())
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
tuple result
Definition: mps_fire.py:83
static const int CSC
Definition: MuonSubdetId.h:13
T z() const
Definition: PV3DBase.h:64
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
tuple cout
Definition: gather_cfg.py:145
static const int DT
Definition: MuonSubdetId.h:12
T x() const
Definition: PV3DBase.h:62
*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