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::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 MuonGeometrySanityCheck (const edm::ParameterSet &iConfig)
 
 ~MuonGeometrySanityCheck () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

const edm::ESGetToken< CSCGeometry, MuonGeometryRecordcscGeomToken_
 
const edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeomToken_
 
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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

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

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

Definition at line 84 of file MuonGeometrySanityCheck.cc.

Constructor & Destructor Documentation

◆ MuonGeometrySanityCheck()

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

Definition at line 114 of file MuonGeometrySanityCheck.cc.

References Exception, amptDefault_cfi::frame, edm::ParameterSet::getParameter(), m_frames, m_points, mergeVDriftHistosByStation::name, point, prefix, printout, AlCaHLTBitMon_QueryRunRegistry::string, and tolerance.

115  : dtGeomToken_(esConsumes<edm::Transition::BeginRun>()), cscGeomToken_(esConsumes<edm::Transition::BeginRun>()) {
116  printout = iConfig.getParameter<std::string>("printout");
117  if (printout != std::string("all") && printout != std::string("bad")) {
118  throw cms::Exception("BadConfig") << "Printout must be \"all\" or \"bad\"." << std::endl;
119  }
120 
121  tolerance = iConfig.getParameter<double>("tolerance");
122  if (tolerance <= 0) {
123  throw cms::Exception("BadConfig") << "Tolerance must be positive." << std::endl;
124  }
125 
126  prefix = iConfig.getParameter<std::string>("prefix");
127 
128  std::vector<edm::ParameterSet> frames = iConfig.getParameter<std::vector<edm::ParameterSet> >("frames");
129  for (std::vector<edm::ParameterSet>::const_iterator frame = frames.begin(); frame != frames.end(); ++frame) {
130  std::string name = frame->getParameter<std::string>("name");
131  if (m_frames.find(name) != m_frames.end()) {
132  throw cms::Exception("BadConfig") << "Custom frame \"" << name << "\" has been defined twice." << std::endl;
133  }
135  }
136 
137  std::vector<edm::ParameterSet> points = iConfig.getParameter<std::vector<edm::ParameterSet> >("points");
138  for (std::vector<edm::ParameterSet>::const_iterator point = points.begin(); point != points.end(); ++point) {
140  }
141 }
std::vector< MuonGeometrySanityCheckPoint > m_points
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > m_frames
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken_
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
*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::~MuonGeometrySanityCheck ( )
override

Definition at line 143 of file MuonGeometrySanityCheck.cc.

References m_frames.

143  {
144  for (std::map<std::string, const MuonGeometrySanityCheckCustomFrame *>::iterator iter = m_frames.begin();
145  iter != m_frames.end();
146  ++iter) {
147  delete iter->second;
148  }
149 }
std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > m_frames

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 586 of file MuonGeometrySanityCheck.cc.

References cms::cuda::assert(), CSCDetId::chamber(), gather_cfg::cout, MuonSubdetId::CSC, cscGeomToken_, MuonSubdetId::DT, dt, dtGeomToken_, CSCDetId::endcap(), edm::EventSetup::getData(), EcalPhiSymFlatTableProducers_cfi::id, DTGeometry::idToDet(), CSCGeometry::idToDet(), 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, GeomDet::surface(), Surface::toGlobal(), tolerance, GloballyPositioned< T >::toLocal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

586  {
587  const DTGeometry *dtGeometry = &iSetup.getData(dtGeomToken_);
588  const CSCGeometry *cscGeometry = &iSetup.getData(cscGeomToken_);
589 
590  int num_transformed = 0;
591  int num_tested = 0;
592  int num_bad = 0;
593  for (std::vector<MuonGeometrySanityCheckPoint>::const_iterator point = m_points.begin(); point != m_points.end();
594  ++point) {
595  num_transformed++;
596 
597  bool dt = (point->detector.subdetId() == MuonSubdetId::DT);
598 
599  // convert the displacement vector into the chosen coordinate system and add it to the chamber's position
600  GlobalPoint chamberPos;
601  if (dt)
602  chamberPos = dtGeometry->idToDet(point->detector)->surface().toGlobal(LocalPoint(0., 0., 0.));
603  else
604  chamberPos = cscGeometry->idToDet(point->detector)->surface().toGlobal(LocalPoint(0., 0., 0.));
605 
608  result = GlobalPoint(chamberPos.x() + point->displacement.x(),
609  chamberPos.y() + point->displacement.y(),
610  chamberPos.z() + point->displacement.z());
611  }
612 
613  else if (point->frame == MuonGeometrySanityCheckPoint::kLocal) {
614  if (dt)
615  result = dtGeometry->idToDet(point->detector)
616  ->surface()
617  .toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
618  else
619  result = cscGeometry->idToDet(point->detector)
620  ->surface()
621  .toGlobal(LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
622  }
623 
624  else if (point->frame == MuonGeometrySanityCheckPoint::kChamber) {
625  if (point->detector.subdetId() == MuonSubdetId::DT) {
626  DTChamberId id(point->detector);
627  if (dt)
628  result = dtGeometry->idToDet(id)->surface().toGlobal(
629  LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
630  else
631  result = cscGeometry->idToDet(id)->surface().toGlobal(
632  LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
633  } else if (point->detector.subdetId() == MuonSubdetId::CSC) {
634  CSCDetId cscid(point->detector);
635  CSCDetId id(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber());
636  if (dt)
637  result = dtGeometry->idToDet(id)->surface().toGlobal(
638  LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
639  else
640  result = cscGeometry->idToDet(id)->surface().toGlobal(
641  LocalPoint(point->displacement.x(), point->displacement.y(), point->displacement.z()));
642  } else {
643  assert(false);
644  }
645  }
646 
647  else if (point->frame == MuonGeometrySanityCheckPoint::kCustom) {
648  GlobalPoint transformed = point->customFrame->transform(point->displacement);
650  chamberPos.x() + transformed.x(), chamberPos.y() + transformed.y(), chamberPos.z() + transformed.z());
651  }
652 
653  else {
654  assert(false);
655  }
656 
657  // convert the result into the chosen output coordinate system
658  if (point->outputFrame == MuonGeometrySanityCheckPoint::kGlobal) {
659  }
660 
661  else if (point->outputFrame == MuonGeometrySanityCheckPoint::kLocal) {
662  LocalPoint transformed;
663  if (dt)
664  transformed = dtGeometry->idToDet(point->detector)->surface().toLocal(result);
665  else
666  transformed = cscGeometry->idToDet(point->detector)->surface().toLocal(result);
667  result = GlobalPoint(transformed.x(), transformed.y(), transformed.z());
668  }
669 
670  else if (point->outputFrame == MuonGeometrySanityCheckPoint::kChamber) {
671  if (point->detector.subdetId() == MuonSubdetId::DT) {
672  DTChamberId id(point->detector);
673  LocalPoint transformed;
674  if (dt)
675  transformed = dtGeometry->idToDet(id)->surface().toLocal(result);
676  else
677  transformed = cscGeometry->idToDet(id)->surface().toLocal(result);
678  result = GlobalPoint(transformed.x(), transformed.y(), transformed.z());
679  } else if (point->detector.subdetId() == MuonSubdetId::CSC) {
680  CSCDetId cscid(point->detector);
681  CSCDetId id(cscid.endcap(), cscid.station(), cscid.ring(), cscid.chamber());
682  LocalPoint transformed;
683  if (dt)
684  transformed = dtGeometry->idToDet(id)->surface().toLocal(result);
685  else
686  transformed = cscGeometry->idToDet(id)->surface().toLocal(result);
687  result = GlobalPoint(transformed.x(), transformed.y(), transformed.z());
688  } else {
689  assert(false);
690  }
691  }
692 
693  else if (point->outputFrame == MuonGeometrySanityCheckPoint::kCustom) {
694  result = point->outputCustomFrame->transformInverse(result);
695  }
696 
697  std::stringstream output;
698  output << prefix << " " << point->name << " " << point->detName() << " " << result.x() << " " << result.y() << " "
699  << result.z();
700 
701  bool bad = false;
702  if (point->has_expectation) {
703  num_tested++;
704  double residx = result.x() - point->expectation.x();
705  double residy = result.y() - point->expectation.y();
706  double residz = result.z() - point->expectation.z();
707 
708  if (fabs(residx) > tolerance || fabs(residy) > tolerance || fabs(residz) > tolerance) {
709  num_bad++;
710  bad = true;
711  output << " BAD " << residx << " " << residy << " " << residz << std::endl;
712  } else {
713  output << " GOOD " << residx << " " << residy << " " << residz << std::endl;
714  }
715  } else {
716  output << " UNTESTED 0 0 0" << std::endl;
717  }
718 
719  if (printout == std::string("all") || (printout == std::string("bad") && bad)) {
720  std::cout << output.str();
721  }
722  }
723 
724  std::cout << std::endl
725  << "SUMMARY transformed: " << num_transformed << " tested: " << num_tested << " bad: " << num_bad
726  << " good: " << (num_tested - num_bad) << std::endl;
727 }
std::vector< MuonGeometrySanityCheckPoint > m_points
float dt
Definition: AMPTWrapper.h:136
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
T z() const
Definition: PV3DBase.h:61
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
LocalPoint toLocal(const GlobalPoint &gp) const
assert(be >=bs)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
const GeomDet * idToDet(DetId) const override
Definition: DTGeometry.cc:77
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken_
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
Definition: output.py:1
static constexpr int DT
Definition: MuonSubdetId.h:11
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
static constexpr int CSC
Definition: MuonSubdetId.h:12
*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
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91

Member Data Documentation

◆ cscGeomToken_

const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> MuonGeometrySanityCheck::cscGeomToken_
private

Definition at line 99 of file MuonGeometrySanityCheck.cc.

Referenced by analyze().

◆ dtGeomToken_

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> MuonGeometrySanityCheck::dtGeomToken_
private

Definition at line 98 of file MuonGeometrySanityCheck.cc.

Referenced by analyze().

◆ m_frames

std::map<std::string, const MuonGeometrySanityCheckCustomFrame *> MuonGeometrySanityCheck::m_frames
private

Definition at line 95 of file MuonGeometrySanityCheck.cc.

Referenced by MuonGeometrySanityCheck(), and ~MuonGeometrySanityCheck().

◆ m_points

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

Definition at line 96 of file MuonGeometrySanityCheck.cc.

Referenced by analyze(), and MuonGeometrySanityCheck().

◆ prefix

std::string MuonGeometrySanityCheck::prefix
private

Definition at line 94 of file MuonGeometrySanityCheck.cc.

Referenced by analyze(), and MuonGeometrySanityCheck().

◆ printout

std::string MuonGeometrySanityCheck::printout
private

Definition at line 92 of file MuonGeometrySanityCheck.cc.

Referenced by analyze(), and MuonGeometrySanityCheck().

◆ tolerance

double MuonGeometrySanityCheck::tolerance
private