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{})},
85 infileName_(iConfig.getUntrackedParameter<
string>(
"infileName",
"cmsGeom10.root")),
86 outfileName_(iConfig.getUntrackedParameter<
string>(
"outfileName",
"validateDTGeometry.root")),
87 tolerance_(iConfig.getUntrackedParameter<
int>(
"tolerance", 6)) {
96 LogVerbatim(
"DTGeometry") <<
"Validating DT chamber geometry";
99 LogVerbatim(
"DTGeometry") <<
"Validating DT layer geometry";
102 LogVerbatim(
"DTGeometry") <<
"Invalid DT geometry";
115 LogVerbatim(
"DTGeometry") <<
"Failed to get matrix of DT chamber with detid: " << chId.
rawId();
124 LogVerbatim(
"DTGeometry") <<
"Failed to get shape of DT chamber with detid: " << chId.
rawId();
137 vector<float> wire_positions;
146 LogVerbatim(
"DTGeometry") <<
"Failed to get matrix of DT layer with detid: " << layerId.
rawId();
155 LogVerbatim(
"DTGeometry") <<
"Failed to get shape of DT layer with detid: " << layerId.
rawId();
164 LogVerbatim(
"DTGeometry") <<
"Parameters empty for DT layer with detid: " << layerId.
rawId();
168 float width = it->surface().bounds().width();
171 float thickness = it->surface().bounds().thickness();
174 float length = it->surface().bounds().length();
177 int firstChannel = it->specificTopology().firstChannel();
180 int lastChannel = it->specificTopology().lastChannel();
182 assert(nChannels == (lastChannel - firstChannel) + 1);
184 for (
int wireN = firstChannel; wireN - lastChannel <= 0; ++wireN) {
185 float localX1 = it->specificTopology().wirePosition(wireN);
186 float localX2 = (wireN - (firstChannel - 1) - 0.5
f) *
parameters[0] - nChannels / 2.0f *
parameters[0];
187 wire_positions.emplace_back(
getDiff(localX1, localX2));
196 double local[3] = {0.0, 0.0, 0.0};
199 matrix->LocalToMaster(local, global);
207 float shapeBottomWidth;
209 float shapeThickness;
212 shapeTopWidth = shape[2];
213 shapeBottomWidth = shape[1];
214 shapeLength = shape[4];
215 shapeThickness = shape[3];
216 }
else if (shape[0] == 2) {
217 shapeTopWidth = shape[1];
218 shapeBottomWidth = shape[1];
219 shapeLength = shape[2];
220 shapeThickness = shape[3];
222 LogVerbatim(
"DTGeometry") <<
"Failed to get box or trapezoid from shape";
226 float topWidth, bottomWidth;
232 array<const float, 4>
const& ps = tpbs->parameters();
234 assert(ps.size() == 4);
240 }
else if ((dynamic_cast<const RectangularPlaneBounds*>(bounds))) {
243 bottomWidth = topWidth;
246 LogVerbatim(
"DTGeometry") <<
"Failed to get bounds";
249 topWidths_.push_back(fabs(shapeTopWidth - topWidth));
250 bottomWidths_.push_back(fabs(shapeBottomWidth - bottomWidth));
251 lengths_.push_back(fabs(shapeLength - length));
252 thicknesses_.push_back(fabs(shapeThickness - thickness));
256 return sqrt((p1.
x() - p2.
x()) * (p1.
x() - p2.
x()) + (p1.
y() - p2.
y()) * (p1.
y() - p2.
y()) +
257 (p1.
z() - p2.
z()) * (p1.
z() - p2.
z()));
264 return (val1 - val2);
272 string gdn = d +
": distance between points in global coordinates";
275 string twn = d +
": absolute difference between top widths (along X)";
278 string bwn = d +
": absolute difference between bottom widths (along X)";
281 string ln = d +
": absolute difference between lengths (along Y)";
284 string tn = d +
": absolute difference between thicknesses (along Z)";
292 const auto [minE,
maxE] = minmax_element(
begin(data),
end(data));
294 TH1D
hist(name.c_str(), name.c_str(), 100, *minE * (1 + 0.10), *
maxE * (1 + 0.10));
296 for (
auto const& it : data)
299 hist.GetXaxis()->SetTitle(
"[cm]");
enable_if<!numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp)
virtual float length() const =0
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Point3DBase< Scalar, LocalTag > LocalPoint
~DTGeometryValidate() override
const float * getParameters(unsigned int id) const
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 width() const =0
const float * getShapePars(unsigned int id) const
void compareTransform(const GlobalPoint &, const TGeoMatrix *)
#define DEFINE_FWK_MODULE(type)
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_
virtual float thickness() const =0
const std::vector< const DTLayer * > & layers() const
Return a vector of all SuperLayer.
char data[epos_bytes_allocation]
vector< float > bottomWidths_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void makeHistogram(const string &, vector< float > &)
void analyze(const edm::Event &, const edm::EventSetup &) override