Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small enhancements to geometry DB payload validation scripts #31320

Merged
merged 12 commits into from Sep 5, 2020
34 changes: 22 additions & 12 deletions DetectorDescription/OfflineDBLoader/src/GeometryInfoDump.cc
Expand Up @@ -18,6 +18,16 @@
using Graph = DDCompactView::Graph;
using adjl_iterator = Graph::const_adj_iterator;

// For output of values to four decimal places, round negative values
// equivalent to 0 within the precision to 0 to prevent printing "-0".
template <class valType>
static constexpr valType roundNeg0(valType value) {
if (value < 0. && value > -5.0e-5)
return (0.0);
else
return (value);
}

GeometryInfoDump::GeometryInfoDump() {}

GeometryInfoDump::~GeometryInfoDump() {}
Expand Down Expand Up @@ -52,18 +62,18 @@ void GeometryInfoDump::dumpInfo(
size_t s = snprintf(buf,
256,
",%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f,%12.4f",
epv.translation().x(),
epv.translation().y(),
epv.translation().z(),
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
roundNeg0(epv.translation().x()),
roundNeg0(epv.translation().y()),
roundNeg0(epv.translation().z()),
roundNeg0(x.X()),
roundNeg0(y.X()),
roundNeg0(z.X()),
roundNeg0(x.Y()),
roundNeg0(y.Y()),
roundNeg0(z.Y()),
roundNeg0(x.Z()),
roundNeg0(y.Z()),
roundNeg0(z.Z()));
assert(s < 256);
dump << buf;
}
Expand Down
18 changes: 8 additions & 10 deletions Geometry/CSCGeometry/test/testCSCGeometry_cfg.py
Expand Up @@ -2,30 +2,28 @@

import FWCore.ParameterSet.Config as cms

process = cms.Process("CSCGeometryAnalyzer")
process = cms.Process('CSCGeometryAnalyzer')

# Endcap Muon geometry
# ====================
process.load("Geometry.MuonNumbering.muonGeometryConstants_cff")
process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi")
process.load("Geometry.MuonCommonData.muonEndcapIdealGeometryXML_cfi")
process.load('Configuration.Geometry.GeometryExtended_cff')
cvuosalo marked this conversation as resolved.
Show resolved Hide resolved

# Fake alignment is/should be ideal geometry
# ==========================================
process.load("Alignment.CommonAlignmentProducer.FakeAlignmentSource_cfi")
process.preferFakeAlign = cms.ESPrefer("FakeAlignmentSource")
process.load('Alignment.CommonAlignmentProducer.FakeAlignmentSource_cfi')
process.preferFakeAlign = cms.ESPrefer('FakeAlignmentSource')

# flags for modelling of CSC layer & strip geometry
# =================================================
process.load("Geometry.CSCGeometry.cscGeometry_cfi")
process.load('Geometry.CSCGeometry.cscGeometry_cfi')

process.source = cms.Source("EmptySource")
process.source = cms.Source('EmptySource')

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(1)
)

process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.load('FWCore.MessageLogger.MessageLogger_cfi')
process.MessageLogger.debugModules.append('CSCGeometryESModule')
process.MessageLogger.categories.append('CSCGeometry')
process.MessageLogger.categories.append('CSCGeometryBuilder')
Expand All @@ -36,6 +34,6 @@
CSCGeometryBuilder = cms.untracked.PSet( limit = cms.untracked.int32(-1) )
)

process.producer = cms.EDAnalyzer("CSCGeometryAnalyzer")
process.producer = cms.EDAnalyzer('CSCGeometryAnalyzer')

process.p1 = cms.Path(process.producer)
36 changes: 22 additions & 14 deletions Geometry/DTGeometry/test/DTGeometryAnalyzer.cc
Expand Up @@ -5,15 +5,17 @@

#include <memory>

#include <FWCore/Framework/interface/Frameworkfwd.h>
#include <FWCore/Framework/interface/one/EDAnalyzer.h>
#include <FWCore/Framework/interface/EventSetup.h>
#include <FWCore/Framework/interface/ESHandle.h>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
cvuosalo marked this conversation as resolved.
Show resolved Hide resolved
#include "DataFormats/Math/interface/Rounding.h"

#include <Geometry/CommonDetUnit/interface/GeomDet.h>
#include "Geometry/CommonDetUnit/interface/GeomDet.h"

#include <Geometry/DTGeometry/interface/DTGeometry.h>
#include <Geometry/Records/interface/MuonGeometryRecord.h>
#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

#include <iostream>
#include <string>
Expand All @@ -22,6 +24,7 @@
#include <vector>

using namespace std;
using namespace cms_rounding;

class DTGeometryAnalyzer : public edm::one::EDAnalyzer<> {
public:
Expand All @@ -37,10 +40,14 @@ class DTGeometryAnalyzer : public edm::one::EDAnalyzer<> {
const int dashedLineWidth_;
const string dashedLine_;
const string myName_;
double tolerance_;
};

DTGeometryAnalyzer::DTGeometryAnalyzer(const edm::ParameterSet& iConfig)
: dashedLineWidth_(104), dashedLine_(string(dashedLineWidth_, '-')), myName_("DTGeometryAnalyzer") {}
: dashedLineWidth_(104),
dashedLine_(string(dashedLineWidth_, '-')),
myName_("DTGeometryAnalyzer"),
tolerance_(iConfig.getUntrackedParameter<double>("tolerance", 1.e-23)) {}

DTGeometryAnalyzer::~DTGeometryAnalyzer() {}

Expand Down Expand Up @@ -83,7 +90,7 @@ void DTGeometryAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup
cout << "Layer " << det->id() << " SL " << det->superLayer()->id() << " chamber " << det->chamber()->id()
<< " Topology W/H/L: " << topo.cellWidth() << "/" << topo.cellHeight() << "/" << topo.cellLenght()
<< " first/last/# wire " << topo.firstChannel() << "/" << topo.lastChannel() << "/" << topo.channels()
<< " Position " << surf.position() << " normVect " << surf.normalVector()
<< " Position " << surf.position() << " normVect " << roundVecIfNear0(surf.normalVector(), tolerance_)
<< " bounds W/H/L: " << surf.bounds().width() << "/" << surf.bounds().thickness() << "/"
<< surf.bounds().length() << endl;
}
Expand All @@ -93,8 +100,9 @@ void DTGeometryAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup
for (auto det : pDD->superLayers()) {
const BoundPlane& surf = det->surface();
cout << "SuperLayer " << det->id() << " chamber " << det->chamber()->id() << " Position " << surf.position()
<< " normVect " << surf.normalVector() << " bounds W/H/L: " << surf.bounds().width() << "/"
<< surf.bounds().thickness() << "/" << surf.bounds().length() << endl;
<< " normVect " << roundVecIfNear0(surf.normalVector(), tolerance_)
<< " bounds W/H/L: " << surf.bounds().width() << "/" << surf.bounds().thickness() << "/"
<< surf.bounds().length() << endl;
}

// check chamber
Expand All @@ -103,9 +111,9 @@ void DTGeometryAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup
//cout << "Chamber " << (*det)->geographicalId().det() << endl;
const BoundPlane& surf = det->surface();
//cout << "surf " << &surf << endl;
cout << "Chamber " << det->id() << " Position " << surf.position() << " normVect " << surf.normalVector()
<< " bounds W/H/L: " << surf.bounds().width() << "/" << surf.bounds().thickness() << "/"
<< surf.bounds().length() << endl;
cout << "Chamber " << det->id() << " Position " << surf.position() << " normVect "
<< roundVecIfNear0(surf.normalVector(), tolerance_) << " bounds W/H/L: " << surf.bounds().width() << "/"
<< surf.bounds().thickness() << "/" << surf.bounds().length() << endl;
}
cout << "END " << dashedLine_ << endl;

Expand Down
4 changes: 3 additions & 1 deletion Geometry/DTGeometry/test/testDTGeometryFromDB_cfg.py
Expand Up @@ -22,6 +22,8 @@

process.source = cms.Source("EmptySource")

process.prod = cms.EDAnalyzer("DTGeometryAnalyzer")
process.prod = cms.EDAnalyzer("DTGeometryAnalyzer",
tolerance = cms.untracked.double(1.0e-23)
)

process.p1 = cms.Path(process.prod)
4 changes: 3 additions & 1 deletion Geometry/DTGeometry/test/testDTGeometryFromLocalDB_cfg.py
Expand Up @@ -45,6 +45,8 @@

process.source = cms.Source("EmptySource")

process.prod = cms.EDAnalyzer("DTGeometryAnalyzer")
process.prod = cms.EDAnalyzer("DTGeometryAnalyzer",
tolerance = cms.untracked.double(1.0e-23)
)

process.p1 = cms.Path(process.prod)
4 changes: 3 additions & 1 deletion Geometry/DTGeometry/test/testDTGeometry_cfg.py
Expand Up @@ -19,7 +19,9 @@

process.out = cms.OutputModule("AsciiOutputModule")

process.prod = cms.EDAnalyzer("DTGeometryAnalyzer")
process.prod = cms.EDAnalyzer("DTGeometryAnalyzer",
tolerance = cms.untracked.double(1.0e-23)
)

process.p1 = cms.Path(process.prod)

Expand Down
26 changes: 17 additions & 9 deletions Geometry/TrackerGeometryBuilder/test/ModuleInfo.cc
Expand Up @@ -38,6 +38,7 @@

#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "DataFormats/GeometrySurface/interface/BoundSurface.h"
#include "DataFormats/Math/interface/Rounding.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "Geometry/TrackerNumberingBuilder/interface/CmsTrackerDebugNavigator.h"
Expand All @@ -59,6 +60,8 @@
#include <cmath>
#include <bitset>

using namespace cms_rounding;

class ModuleInfo : public edm::one::EDAnalyzer<> {
public:
explicit ModuleInfo(const edm::ParameterSet&);
Expand All @@ -71,14 +74,15 @@ class ModuleInfo : public edm::one::EDAnalyzer<> {
private:
bool fromDDD_;
bool printDDD_;
double tolerance_;
};

static const double density_units = 6.24151e+18;

ModuleInfo::ModuleInfo(const edm::ParameterSet& ps) {
fromDDD_ = ps.getParameter<bool>("fromDDD");
printDDD_ = ps.getUntrackedParameter<bool>("printDDD", true);
}
ModuleInfo::ModuleInfo(const edm::ParameterSet& ps)
: fromDDD_(ps.getParameter<bool>("fromDDD")),
printDDD_(ps.getUntrackedParameter<bool>("printDDD", true)),
tolerance_(ps.getUntrackedParameter<double>("tolerance", 1.e-23)) {}

ModuleInfo::~ModuleInfo() {}

Expand All @@ -92,9 +96,7 @@ void ModuleInfo::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
std::ofstream TECOutput("TECLayout_CMSSW.dat", std::ios::out);
// Numbering Scheme
std::ofstream NumberingOutput("ModuleNumbering.dat", std::ios::out);
//

//
// get the GeometricDet
//
edm::ESHandle<GeometricDet> rDD;
Expand Down Expand Up @@ -473,12 +475,12 @@ void ModuleInfo::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
} else {
out_module = tTopo->tecModule(id);
}
double out_x = module->translation().X();
double out_y = module->translation().Y();
double out_x = roundIfNear0(module->translation().X(), tolerance_);
double out_y = roundIfNear0(module->translation().Y(), tolerance_);
double out_z = module->translation().Z();
double out_r = sqrt(module->translation().X() * module->translation().X() +
module->translation().Y() * module->translation().Y());
double out_phi_rad = atan2(module->translation().Y(), module->translation().X());
double out_phi_rad = roundIfNear0(atan2(module->translation().Y(), module->translation().X()), tolerance_);
TECOutput << out_side << " " << out_disk << " " << out_sector << " " << out_petal << " " << out_ring << " "
<< out_module << " " << out_sensor << " " << out_x << " " << out_y << " " << out_z << " " << out_r
<< " " << out_phi_rad << std::endl;
Expand Down Expand Up @@ -526,6 +528,12 @@ void ModuleInfo::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
// active area versors (rotation matrix)
DD3Vector x, y, z;
module->rotation().GetComponents(x, y, z);
x = roundVecIfNear0(x, tolerance_);
y = roundVecIfNear0(y, tolerance_);
z = roundVecIfNear0(z, tolerance_);
xGlobal = roundVecIfNear0(xGlobal, tolerance_);
yGlobal = roundVecIfNear0(yGlobal, tolerance_);
zGlobal = roundVecIfNear0(zGlobal, tolerance_);
Output << "\tActive Area Rotation Matrix" << std::endl;
Output << "\t z = n = (" << std::fixed << std::setprecision(4) << z.X() << "," << std::fixed << std::setprecision(4)
<< z.Y() << "," << std::fixed << std::setprecision(4) << z.Z() << ")" << std::endl
Expand Down
Expand Up @@ -26,7 +26,8 @@
process.out = cms.OutputModule("AsciiOutputModule")

process.prod = cms.EDAnalyzer("ModuleInfo",
fromDDD = cms.bool(False)
fromDDD = cms.bool(False),
tolerance = cms.untracked.double(1.0e-23)
)

process.p1 = cms.Path(process.prod)
Expand Down
Expand Up @@ -41,7 +41,8 @@

process.prod = cms.EDAnalyzer("ModuleInfo",
fromDDD = cms.bool(True),
printDDD = cms.untracked.bool(False)
printDDD = cms.untracked.bool(False),
tolerance = cms.untracked.double(1.0e-23)
)

process.p1 = cms.Path(process.prod)
Expand Down
Expand Up @@ -28,7 +28,8 @@

process.prod = cms.EDAnalyzer("ModuleInfo",
fromDDD = cms.bool(True),
printDDD = cms.untracked.bool(False)
printDDD = cms.untracked.bool(False),
tolerance = cms.untracked.double(1.0e-23)
)

process.p1 = cms.Path(process.prod)
Expand Down
Expand Up @@ -46,7 +46,8 @@
process.out = cms.OutputModule("AsciiOutputModule")

process.prod = cms.EDAnalyzer("ModuleInfo",
fromDDD = cms.bool(False)
fromDDD = cms.bool(False),
tolerance = cms.untracked.double(1.0e-23)
)

process.p1 = cms.Path(process.prod)
Expand Down