CMS 3D CMS Logo

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 () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > m_frames
 
std::vector< MuonGeometrySanityCheckPointm_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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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(), MuonGeometrySanityCheckCustomFrame::MuonGeometrySanityCheckCustomFrame(), dataset::name, point, hiPixelPairStep_cff::points, tablePrinter::prefix, AlCaHLTBitMon_QueryRunRegistry::string, and RecoTauCleanerPlugins::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 ( )
override

Definition at line 150 of file MuonGeometrySanityCheck.cc.

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 
)
overrideprivate

Definition at line 557 of file MuonGeometrySanityCheck.cc.

References CSCDetId::chamber(), gather_cfg::cout, MuonSubdetId::CSC, DEFINE_FWK_MODULE, MuonSubdetId::DT, dt, CSCDetId::endcap(), edm::EventSetup::get(), triggerObjects_cff::id, DTGeometry::idToDet(), CSCGeometry::idToDet(), MuonGeometrySanityCheckPoint::kChamber, MuonGeometrySanityCheckPoint::kCustom, MuonGeometrySanityCheckPoint::kGlobal, MuonGeometrySanityCheckPoint::kLocal, convertSQLitetoXML_cfg::output, point, tablePrinter::prefix, mps_fire::result, CSCDetId::ring(), CSCDetId::station(), AlCaHLTBitMon_QueryRunRegistry::string, GeomDet::surface(), Surface::toGlobal(), RecoTauCleanerPlugins::tolerance, GloballyPositioned< T >::toLocal(), 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
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
float dt
Definition: AMPTWrapper.h:126
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:99
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
static const int CSC
Definition: MuonSubdetId.h:13
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:64
const GeomDet * idToDet(DetId) const override
Definition: DTGeometry.cc:75
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

Definition at line 106 of file MuonGeometrySanityCheck.cc.

std::vector<MuonGeometrySanityCheckPoint> MuonGeometrySanityCheck::m_points
private

Definition at line 107 of file MuonGeometrySanityCheck.cc.

std::string MuonGeometrySanityCheck::prefix
private

Definition at line 105 of file MuonGeometrySanityCheck.cc.

std::string MuonGeometrySanityCheck::printout
private

Definition at line 103 of file MuonGeometrySanityCheck.cc.

double MuonGeometrySanityCheck::tolerance
private

Definition at line 104 of file MuonGeometrySanityCheck.cc.

Referenced by utils.BinToBin1percent::do_test().