23 #include <type_traits> 47 void endJob()
override;
49 void validateDTChamberGeometry();
50 void validateDTLayerGeometry();
52 void compareTransform(
const GlobalPoint&,
const TGeoMatrix*);
53 void compareShape(
const GeomDet*,
const float*);
56 float getDiff(
const float,
const float);
59 void makeHistogram(
const string&, vector<float>&);
62 globalDistances_.clear();
64 bottomWidths_.clear();
84 : dtGeometryToken_{esConsumes<DTGeometry, MuonGeometryRecord>(
edm::ESInputTag{})},
86 iConfig.getUntrackedParameter<
string>(
"infileName",
"Geometry/DTGeometryBuilder/data/cmsRecoGeom-2021.root")),
87 outfileName_(iConfig.getUntrackedParameter<
string>(
"outfileName",
"validateDTGeometry.root")),
88 tolerance_(iConfig.getUntrackedParameter<
int>(
"tolerance", 6)) {
90 fwGeometry_.loadMap(
fp.fullPath().c_str());
91 outFile_ = TFile::Open(outfileName_.c_str(),
"RECREATE");
98 LogVerbatim(
"DTGeometry") <<
"Validating DT chamber geometry";
100 LogVerbatim(
"DTGeometry") <<
"Validating DT layer geometry";
103 LogVerbatim(
"DTGeometry") <<
"Invalid DT geometry";
116 LogVerbatim(
"DTGeometry") <<
"Failed to get matrix of DT chamber with detid: " << chId.
rawId();
125 LogVerbatim(
"DTGeometry") <<
"Failed to get shape of DT chamber with detid: " << chId.
rawId();
138 vector<float> wire_positions;
147 LogVerbatim(
"DTGeometry") <<
"Failed to get matrix of DT layer with detid: " << layerId.
rawId();
156 LogVerbatim(
"DTGeometry") <<
"Failed to get shape of DT layer with detid: " << layerId.
rawId();
165 LogVerbatim(
"DTGeometry") <<
"Parameters empty for DT layer with detid: " << layerId.
rawId();
169 float width =
it->surface().bounds().width();
172 float thickness =
it->surface().bounds().thickness();
175 float length =
it->surface().bounds().length();
178 int firstChannel =
it->specificTopology().firstChannel();
181 int lastChannel =
it->specificTopology().lastChannel();
185 for (
int wireN = firstChannel; wireN - lastChannel <= 0; ++wireN) {
186 float localX1 =
it->specificTopology().wirePosition(wireN);
188 wire_positions.emplace_back(
getDiff(localX1, localX2));
197 double local[3] = {0.0, 0.0, 0.0};
208 float shapeBottomWidth;
210 float shapeThickness;
213 shapeTopWidth =
shape[2];
214 shapeBottomWidth =
shape[1];
215 shapeLength =
shape[4];
216 shapeThickness =
shape[3];
217 }
else if (
shape[0] == 2) {
218 shapeTopWidth =
shape[1];
219 shapeBottomWidth =
shape[1];
220 shapeLength =
shape[2];
221 shapeThickness =
shape[3];
223 LogVerbatim(
"DTGeometry") <<
"Failed to get box or trapezoid from shape";
227 float topWidth, bottomWidth;
233 array<const float, 4>
const& ps = tpbs->parameters();
241 }
else if ((dynamic_cast<const RectangularPlaneBounds*>(
bounds))) {
244 bottomWidth = topWidth;
247 LogVerbatim(
"DTGeometry") <<
"Failed to get bounds";
250 topWidths_.push_back(fabs(shapeTopWidth - topWidth));
251 bottomWidths_.push_back(fabs(shapeBottomWidth - bottomWidth));
252 lengths_.push_back(fabs(shapeLength - length));
258 (
p1.z() -
p2.z()) * (
p1.z() -
p2.z()));
265 return (val1 - val2);
273 string gdn =
d +
": distance between points in global coordinates";
276 string twn =
d +
": absolute difference between top widths (along X)";
279 string bwn =
d +
": absolute difference between bottom widths (along X)";
282 string ln =
d +
": absolute difference between lengths (along Y)";
285 string tn =
d +
": absolute difference between thicknesses (along Z)";
295 TH1D
hist(
name.c_str(),
name.c_str(), 100, *minE * (1 + 0.10), *
maxE * (1 + 0.10));
297 for (
auto const&
it :
data)
300 hist.GetXaxis()->SetTitle(
"[cm]");
Log< level::Info, true > LogVerbatim
enable_if<!numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp)
Point3DBase< Scalar, LocalTag > LocalPoint
virtual float length() const =0
~DTGeometryValidate() override
float getDistance(const GlobalPoint &, const GlobalPoint &)
Global3DPoint GlobalPoint
DTGeometryValidate(const ParameterSet &)
float getDiff(const float, const float)
void validateDTChamberGeometry()
void makeHistograms(const char *)
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
void compareShape(const GeomDet *, const float *)
virtual float thickness() const =0
void compareTransform(const GlobalPoint &, const TGeoMatrix *)
static constexpr int nChannels
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryToken_
vector< float > globalDistances_
void validateDTLayerGeometry()
edm::ESHandle< DTGeometry > dtGeometry_
vector< float > topWidths_
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
vector< float > thicknesses_
const Plane & surface() const
The nominal surface of the GeomDet.
constexpr uint32_t rawId() const
get the raw id
const float * getShapePars(unsigned int id) const
char data[epos_bytes_allocation]
const float * getParameters(unsigned int id) const
const TGeoMatrix * getMatrix(unsigned int id) const
vector< float > bottomWidths_
const std::vector< const DTLayer * > & layers() const
Return a vector of all SuperLayer.
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
void makeHistogram(const string &, vector< float > &)
virtual float width() const =0
void analyze(const edm::Event &, const edm::EventSetup &) override
const Bounds & bounds() const