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);
58 void makeHistograms(
const char*);
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")),
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();
183 assert(nChannels == (lastChannel - firstChannel) + 1);
185 for (
int wireN = firstChannel; wireN - lastChannel <= 0; ++wireN) {
186 float localX1 = it->specificTopology().wirePosition(wireN);
187 float localX2 = (wireN - (firstChannel - 1) - 0.5
f) *
parameters[0] - nChannels / 2.0f *
parameters[0];
188 wire_positions.emplace_back(
getDiff(localX1, localX2));
197 double local[3] = {0.0, 0.0, 0.0};
200 matrix->LocalToMaster(local, global);
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));
253 thicknesses_.push_back(fabs(shapeThickness - thickness));
257 return sqrt((p1.
x() - p2.
x()) * (p1.
x() - p2.
x()) + (p1.
y() - p2.
y()) * (p1.
y() - p2.
y()) +
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)";
293 const auto [minE, maxE] = minmax_element(
begin(data),
end(data));
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
T getUntrackedParameter(std::string const &, T const &) const
Point3DBase< Scalar, LocalTag > LocalPoint
virtual float length() const =0
~DTGeometryValidate() override
const float * getParameters(unsigned int id) const
#define DEFINE_FWK_MODULE(type)
float getDistance(const GlobalPoint &, const GlobalPoint &)
Global3DPoint GlobalPoint
DTGeometryValidate(const ParameterSet &)
constexpr uint32_t rawId() const
get the raw id
float getDiff(const float, const float)
void validateDTChamberGeometry()
const Bounds & bounds() const
void makeHistograms(const char *)
const TGeoMatrix * getMatrix(unsigned int id) const
const Plane & surface() const
The nominal surface of the GeomDet.
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
void compareShape(const GeomDet *, const float *)
virtual float thickness() const =0
const float * getShapePars(unsigned int id) const
void compareTransform(const GlobalPoint &, const TGeoMatrix *)
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryToken_
vector< float > globalDistances_
void validateDTLayerGeometry()
edm::ESHandle< DTGeometry > dtGeometry_
void loadMap(const char *fileName)
vector< float > topWidths_
Abs< T >::type abs(const T &t)
vector< float > thicknesses_
enable_if<!numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp)
char data[epos_bytes_allocation]
vector< float > bottomWidths_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void makeHistogram(const string &, vector< float > &)
virtual float width() const =0
void analyze(const edm::Event &, const edm::EventSetup &) override