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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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

111  {
112  printout = iConfig.getParameter<std::string>("printout");
113  if (printout != std::string("all") && printout != std::string("bad")) {
114  throw cms::Exception("BadConfig") << "Printout must be \"all\" or \"bad\"." << std::endl;
115  }
116 
117  tolerance = iConfig.getParameter<double>("tolerance");
118  if (tolerance <= 0) {
119  throw cms::Exception("BadConfig") << "Tolerance must be positive." << std::endl;
120  }
121 
122  prefix = iConfig.getParameter<std::string>("prefix");
123 
124  std::vector<edm::ParameterSet> frames = iConfig.getParameter<std::vector<edm::ParameterSet> >("frames");
125  for (std::vector<edm::ParameterSet>::const_iterator frame = frames.begin(); frame != frames.end(); ++frame) {
126  std::string name = frame->getParameter<std::string>("name");
127  if (m_frames.find(name) != m_frames.end()) {
128  throw cms::Exception("BadConfig") << "Custom frame \"" << name << "\" has been defined twice." << std::endl;
129  }
131  }
132 
133  std::vector<edm::ParameterSet> points = iConfig.getParameter<std::vector<edm::ParameterSet> >("points");
134  for (std::vector<edm::ParameterSet>::const_iterator point = points.begin(); point != points.end(); ++point) {
136  }
137 }

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

◆ ~MuonGeometrySanityCheck()

MuonGeometrySanityCheck::~MuonGeometrySanityCheck ( )
override

Definition at line 139 of file MuonGeometrySanityCheck.cc.

139  {
140  for (std::map<std::string, const MuonGeometrySanityCheckCustomFrame *>::iterator iter = m_frames.begin();
141  iter != m_frames.end();
142  ++iter) {
143  delete iter->second;
144  }
145 }

References m_frames.

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 582 of file MuonGeometrySanityCheck.cc.

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

References cms::cuda::assert(), CSCDetId::chamber(), gather_cfg::cout, MuonSubdetId::CSC, MuonSubdetId::DT, dt, CSCDetId::endcap(), edm::EventSetup::get(), get, triggerObjects_cff::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().

Member Data Documentation

◆ 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
MuonGeometrySanityCheck::printout
std::string printout
Definition: MuonGeometrySanityCheck.cc:92
MuonGeometrySanityCheckPoint
Definition: MuonGeometrySanityCheck.cc:57
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
HLT_FULL_cff.points
points
Definition: HLT_FULL_cff.py:21453
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
pixelTrack::Quality::bad
MuonGeometrySanityCheck::m_points
std::vector< MuonGeometrySanityCheckPoint > m_points
Definition: MuonGeometrySanityCheck.cc:96
CSCGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cms::cuda::assert
assert(be >=bs)
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
dt
float dt
Definition: AMPTWrapper.h:136
MuonGeometrySanityCheck::m_frames
std::map< std::string, const MuonGeometrySanityCheckCustomFrame * > m_frames
Definition: MuonGeometrySanityCheck.cc:95
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
MuonGeometrySanityCheckCustomFrame
Definition: MuonGeometrySanityCheck.cc:47
MuonGeometrySanityCheck::tolerance
double tolerance
Definition: MuonGeometrySanityCheck.cc:93
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
edm::ESHandle< DTGeometry >
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
MuonGeometrySanityCheck::prefix
std::string prefix
Definition: MuonGeometrySanityCheck.cc:94
MuonGeometrySanityCheckPoint::kChamber
Definition: MuonGeometrySanityCheck.cc:64
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuonGeometrySanityCheckPoint::kCustom
Definition: MuonGeometrySanityCheck.cc:64
CSCDetId
Definition: CSCDetId.h:26
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
get
#define get
MuonGeometrySanityCheckPoint::kGlobal
Definition: MuonGeometrySanityCheck.cc:64
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
Exception
Definition: hltDiff.cc:245
MuonGeometrySanityCheckPoint::kLocal
Definition: MuonGeometrySanityCheck.cc:64
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
mps_fire.result
result
Definition: mps_fire.py:311
DTChamberId
Definition: DTChamberId.h:14
point
*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
DTGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: DTGeometry.cc:77
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34