23 #include <type_traits> 29 typename enable_if<!numeric_limits<T>::is_integer,
bool>
::type 50 void endJob()
override;
52 void validateDTChamberGeometry();
53 void validateDTLayerGeometry();
55 void compareTransform(
const GlobalPoint&,
const TGeoMatrix*);
56 void compareShape(
const GeomDet*,
const float*);
59 float getDiff(
const float,
const float);
61 void makeHistograms(
const char*);
62 void makeHistogram(
const string&, vector<float>&);
65 globalDistances_.clear();
67 bottomWidths_.clear();
88 : dtGeometryToken_{esConsumes<DTGeometry, MuonGeometryRecord>(
edm::ESInputTag{})},
89 infileName_(iConfig.getUntrackedParameter<
string>(
"infileName",
"cmsGeom10.root")),
90 outfileName_(iConfig.getUntrackedParameter<
string>(
"outfileName",
"validateDTGeometry.root")),
91 tolerance_(iConfig.getUntrackedParameter<
int>(
"tolerance", 6))
103 LogVerbatim(
"DTGeometry") <<
"Validating DT chamber geometry";
106 LogVerbatim(
"DTGeometry") <<
"Validating DT layer geometry";
110 LogVerbatim(
"DTGeometry") <<
"Invalid DT geometry";
125 LogVerbatim(
"DTGeometry") <<
"Failed to get matrix of DT chamber with detid: " 135 LogVerbatim(
"DTGeometry") <<
"Failed to get shape of DT chamber with detid: " 151 vector<float> wire_positions;
160 LogVerbatim(
"DTGeometry") <<
"Failed to get matrix of DT layer with detid: " 170 LogVerbatim(
"DTGeometry") <<
"Failed to get shape of DT layer with detid: " 180 LogVerbatim(
"DTGeometry") <<
"Parameters empty for DT layer with detid: " 185 float width = it->surface().bounds().width();
188 float thickness = it->surface().bounds().thickness();
191 float length = it->surface().bounds().length();
194 int firstChannel = it->specificTopology().firstChannel();
197 int lastChannel = it->specificTopology().lastChannel();
199 assert(nChannels == (lastChannel-firstChannel)+1);
201 for(
int wireN = firstChannel; wireN - lastChannel <= 0; ++wireN) {
202 float localX1 = it->specificTopology().wirePosition(wireN);
204 wire_positions.emplace_back(
getDiff(localX1, localX2));
216 double local[3] = { 0.0, 0.0, 0.0 };
219 matrix->LocalToMaster(local, global);
229 float shapeBottomWidth;
231 float shapeThickness;
234 shapeTopWidth = shape[2];
235 shapeBottomWidth = shape[1];
236 shapeLength = shape[4];
237 shapeThickness = shape[3];
239 else if(shape[0] == 2) {
240 shapeTopWidth = shape[1];
241 shapeBottomWidth = shape[1];
242 shapeLength = shape[2];
243 shapeThickness = shape[3];
246 LogVerbatim(
"DTGeometry") <<
"Failed to get box or trapezoid from shape";
250 float topWidth, bottomWidth;
251 float length, thickness;
257 array<const float, 4>
const & ps = tpbs->parameters();
259 assert(ps.size() == 4);
266 else if((dynamic_cast<const RectangularPlaneBounds*>(bounds))) {
269 bottomWidth = topWidth;
273 LogVerbatim(
"DTGeometry") <<
"Failed to get bounds";
276 topWidths_.push_back(fabs(shapeTopWidth - topWidth));
277 bottomWidths_.push_back(fabs(shapeBottomWidth - bottomWidth));
278 lengths_.push_back(fabs(shapeLength - length));
279 thicknesses_.push_back(fabs(shapeThickness - thickness));
285 return sqrt((p1.
x()-p2.
x())*(p1.
x()-p2.
x())+
286 (p1.
y()-p2.
y())*(p1.
y()-p2.
y())+
287 (p1.
z()-p2.
z())*(p1.
z()-p2.
z()));
295 return (val1 - val2);
305 string gdn = d+
": distance between points in global coordinates";
308 string twn = d +
": absolute difference between top widths (along X)";
311 string bwn = d +
": absolute difference between bottom widths (along X)";
314 string ln = d +
": absolute difference between lengths (along Y)";
317 string tn = d +
": absolute difference between thicknesses (along Z)";
327 const auto [minE,
maxE] = minmax_element(
begin(data),
end(data));
329 TH1D
hist(name.c_str(), name.c_str(), 100, *minE*(1+0.10), *
maxE*(1+0.10));
331 for(
auto const& it : data)
334 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