CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DTGeometryValidate Class Reference
Inheritance diagram for DTGeometryValidate:

Public Member Functions

 DTGeometryValidate (const ParameterSet &)
 
 ~DTGeometryValidate () override
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void clearData ()
 
void compareShape (const GeomDet *, const float *)
 
void compareTransform (const GlobalPoint &, const TGeoMatrix *)
 
void endJob () override
 
float getDiff (const float, const float)
 
float getDistance (const GlobalPoint &, const GlobalPoint &)
 
void makeHistogram (const string &, vector< float > &)
 
void makeHistograms (const char *)
 
void validateDTChamberGeometry ()
 
void validateDTLayerGeometry ()
 

Private Attributes

vector< float > bottomWidths_
 
edm::ESHandle< DTGeometrydtGeometry_
 
edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeometryToken_
 
FWGeometry fwGeometry_
 
vector< float > globalDistances_
 
string infileName_
 
vector< float > lengths_
 
TFile * outFile_
 
string outfileName_
 
vector< float > thicknesses_
 
int tolerance_
 
vector< float > topWidths_
 

Detailed Description

Definition at line 39 of file DTGeometryValidate.cc.

Constructor & Destructor Documentation

DTGeometryValidate::DTGeometryValidate ( const ParameterSet iConfig)
explicit

Definition at line 83 of file DTGeometryValidate.cc.

References fwGeometry_, infileName_, FWGeometry::loadMap(), outFile_, outfileName_, and tolerance_.

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)) {
89  outFile_ = new TFile(outfileName_.c_str(), "RECREATE");
90 }
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryToken_
void loadMap(const char *fileName)
Definition: FWGeometry.cc:47
DTGeometryValidate::~DTGeometryValidate ( )
inlineoverride

Definition at line 42 of file DTGeometryValidate.cc.

References analyze(), bk::beginJob(), and CSCSkim_cfi::makeHistograms.

42 {}

Member Function Documentation

void DTGeometryValidate::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
overrideprivate

Definition at line 92 of file DTGeometryValidate.cc.

References dtGeometry_, dtGeometryToken_, edm::EventSetup::getHandle(), edm::ESHandleBase::isValid(), validateDTChamberGeometry(), and validateDTLayerGeometry().

92  {
94 
95  if (dtGeometry_.isValid()) {
96  LogVerbatim("DTGeometry") << "Validating DT chamber geometry";
98 
99  LogVerbatim("DTGeometry") << "Validating DT layer geometry";
101  } else
102  LogVerbatim("DTGeometry") << "Invalid DT geometry";
103 }
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryToken_
edm::ESHandle< DTGeometry > dtGeometry_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:141
bool isValid() const
Definition: ESHandle.h:44
void DTGeometryValidate::beginJob ( void  )
overrideprivate

Definition at line 303 of file DTGeometryValidate.cc.

References outFile_.

303 { outFile_->cd(); }
void DTGeometryValidate::clearData ( )
inlineprivate

Definition at line 61 of file DTGeometryValidate.cc.

Referenced by validateDTChamberGeometry(), and validateDTLayerGeometry().

61  {
62  globalDistances_.clear();
63  topWidths_.clear();
64  bottomWidths_.clear();
65  lengths_.clear();
66  thicknesses_.clear();
67  }
vector< float > globalDistances_
vector< float > topWidths_
vector< float > lengths_
vector< float > thicknesses_
vector< float > bottomWidths_
void DTGeometryValidate::compareShape ( const GeomDet det,
const float *  shape 
)
private

Definition at line 205 of file DTGeometryValidate.cc.

References bottomWidths_, Surface::bounds(), Bounds::length(), lengths_, GeomDet::surface(), Bounds::thickness(), Calorimetry_cff::thickness, thicknesses_, topWidths_, and Bounds::width().

Referenced by validateDTChamberGeometry(), and validateDTLayerGeometry().

205  {
206  float shapeTopWidth;
207  float shapeBottomWidth;
208  float shapeLength;
209  float shapeThickness;
210 
211  if (shape[0] == 1) {
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];
221  } else {
222  LogVerbatim("DTGeometry") << "Failed to get box or trapezoid from shape";
223  return;
224  }
225 
226  float topWidth, bottomWidth;
227  float length, thickness;
228 
229  const Bounds* bounds = &(det->surface().bounds());
230 
231  if (const TrapezoidalPlaneBounds* tpbs = dynamic_cast<const TrapezoidalPlaneBounds*>(bounds)) {
232  array<const float, 4> const& ps = tpbs->parameters();
233 
234  assert(ps.size() == 4);
235 
236  bottomWidth = ps[0];
237  topWidth = ps[1];
238  thickness = ps[2];
239  length = ps[3];
240  } else if ((dynamic_cast<const RectangularPlaneBounds*>(bounds))) {
241  length = det->surface().bounds().length() * 0.5;
242  topWidth = det->surface().bounds().width() * 0.5;
243  bottomWidth = topWidth;
244  thickness = det->surface().bounds().thickness() * 0.5;
245  } else {
246  LogVerbatim("DTGeometry") << "Failed to get bounds";
247  return;
248  }
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));
253 }
virtual float length() const =0
const Bounds & bounds() const
Definition: Surface.h:89
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
virtual float width() const =0
vector< float > topWidths_
vector< float > lengths_
vector< float > thicknesses_
virtual float thickness() const =0
vector< float > bottomWidths_
Definition: Bounds.h:20
void DTGeometryValidate::compareTransform ( const GlobalPoint gp,
const TGeoMatrix *  matrix 
)
private

Definition at line 195 of file DTGeometryValidate.cc.

References HLT_2018_cff::distance, getDistance(), globalDistances_, and DTRecHitClients_cfi::local.

Referenced by validateDTChamberGeometry(), and validateDTLayerGeometry().

195  {
196  double local[3] = {0.0, 0.0, 0.0};
197  double global[3];
198 
199  matrix->LocalToMaster(local, global);
200 
201  float distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp);
202  globalDistances_.push_back(distance);
203 }
float getDistance(const GlobalPoint &, const GlobalPoint &)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
vector< float > globalDistances_
void DTGeometryValidate::endJob ( void  )
overrideprivate

Definition at line 305 of file DTGeometryValidate.cc.

References DEFINE_FWK_MODULE, outFile_, and outfileName_.

305  {
306  LogVerbatim("DTGeometry") << "Done.";
307  LogVerbatim("DTGeometry") << "Results written to " << outfileName_;
308  outFile_->Close();
309 }
float DTGeometryValidate::getDiff ( const float  val1,
const float  val2 
)
private

Definition at line 260 of file DTGeometryValidate.cc.

References almost_equal(), and tolerance_.

Referenced by validateDTLayerGeometry().

260  {
261  if (almost_equal(val1, val2, tolerance_))
262  return 0.0f;
263  else
264  return (val1 - val2);
265 }
enable_if<!numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp)
float DTGeometryValidate::getDistance ( const GlobalPoint p1,
const GlobalPoint p2 
)
private

Definition at line 255 of file DTGeometryValidate.cc.

References mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by compareTransform().

255  {
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()));
258 }
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
T x() const
Definition: PV3DBase.h:59
void DTGeometryValidate::makeHistogram ( const string &  name,
vector< float > &  data 
)
private

Definition at line 288 of file DTGeometryValidate.cc.

References begin, end, compare::hist, and HLT_2018_cff::maxE.

Referenced by makeHistograms(), and validateDTLayerGeometry().

288  {
289  if (data.empty())
290  return;
291 
292  const auto [minE, maxE] = minmax_element(begin(data), end(data));
293 
294  TH1D hist(name.c_str(), name.c_str(), 100, *minE * (1 + 0.10), *maxE * (1 + 0.10));
295 
296  for (auto const& it : data)
297  hist.Fill(it);
298 
299  hist.GetXaxis()->SetTitle("[cm]");
300  hist.Write();
301 }
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void DTGeometryValidate::makeHistograms ( const char *  detector)
private

Definition at line 267 of file DTGeometryValidate.cc.

References bottomWidths_, ztail::d, globalDistances_, lengths_, makeHistogram(), outFile_, thicknesses_, and topWidths_.

Referenced by validateDTChamberGeometry(), and validateDTLayerGeometry().

267  {
268  outFile_->cd();
269 
270  string d(detector);
271 
272  string gdn = d + ": distance between points in global coordinates";
274 
275  string twn = d + ": absolute difference between top widths (along X)";
277 
278  string bwn = d + ": absolute difference between bottom widths (along X)";
280 
281  string ln = d + ": absolute difference between lengths (along Y)";
282  makeHistogram(ln, lengths_);
283 
284  string tn = d + ": absolute difference between thicknesses (along Z)";
286 }
vector< float > globalDistances_
vector< float > topWidths_
d
Definition: ztail.py:151
vector< float > lengths_
vector< float > thicknesses_
vector< float > bottomWidths_
void makeHistogram(const string &, vector< float > &)
void DTGeometryValidate::validateDTChamberGeometry ( )
private

Definition at line 105 of file DTGeometryValidate.cc.

References DTGeometry::chambers(), clearData(), compareShape(), compareTransform(), dtGeometry_, fwGeometry_, FWGeometry::getMatrix(), FWGeometry::getShapePars(), runTauDisplay::gp, makeHistograms(), makeMuonMisalignmentScenario::matrix, and DetId::rawId().

Referenced by analyze().

105  {
106  clearData();
107 
108  for (auto const& it : dtGeometry_->chambers()) {
109  DTChamberId chId = it->id();
110  GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0));
111 
112  const TGeoMatrix* matrix = fwGeometry_.getMatrix(chId.rawId());
113 
114  if (!matrix) {
115  LogVerbatim("DTGeometry") << "Failed to get matrix of DT chamber with detid: " << chId.rawId();
116  continue;
117  }
118 
119  compareTransform(gp, matrix);
120 
121  auto const& shape = fwGeometry_.getShapePars(chId.rawId());
122 
123  if (!shape) {
124  LogVerbatim("DTGeometry") << "Failed to get shape of DT chamber with detid: " << chId.rawId();
125  continue;
126  }
127 
128  compareShape(it, shape);
129  }
130 
131  makeHistograms("DT Chamber");
132 }
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:84
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void makeHistograms(const char *)
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:163
void compareShape(const GeomDet *, const float *)
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:427
void compareTransform(const GlobalPoint &, const TGeoMatrix *)
edm::ESHandle< DTGeometry > dtGeometry_
void DTGeometryValidate::validateDTLayerGeometry ( )
private

Definition at line 134 of file DTGeometryValidate.cc.

References clearData(), compareShape(), compareTransform(), dtGeometry_, f, fwGeometry_, getDiff(), FWGeometry::getMatrix(), FWGeometry::getParameters(), FWGeometry::getShapePars(), runTauDisplay::gp, DTGeometry::layers(), makeHistogram(), makeHistograms(), makeMuonMisalignmentScenario::matrix, ecaldqm::nChannels, DetId::rawId(), Calorimetry_cff::thickness, and ApeEstimator_cff::width.

Referenced by analyze().

134  {
135  clearData();
136 
137  vector<float> wire_positions;
138 
139  for (auto const& it : dtGeometry_->layers()) {
140  DTLayerId layerId = it->id();
141  GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0));
142 
143  const TGeoMatrix* matrix = fwGeometry_.getMatrix(layerId.rawId());
144 
145  if (!matrix) {
146  LogVerbatim("DTGeometry") << "Failed to get matrix of DT layer with detid: " << layerId.rawId();
147  continue;
148  }
149 
150  compareTransform(gp, matrix);
151 
152  auto const& shape = fwGeometry_.getShapePars(layerId.rawId());
153 
154  if (!shape) {
155  LogVerbatim("DTGeometry") << "Failed to get shape of DT layer with detid: " << layerId.rawId();
156  continue;
157  }
158 
159  compareShape(it, shape);
160 
161  auto const& parameters = fwGeometry_.getParameters(layerId.rawId());
162 
163  if (parameters == nullptr) {
164  LogVerbatim("DTGeometry") << "Parameters empty for DT layer with detid: " << layerId.rawId();
165  continue;
166  }
167 
168  float width = it->surface().bounds().width();
169  assert(width == parameters[6]);
170 
171  float thickness = it->surface().bounds().thickness();
172  assert(thickness == parameters[7]);
173 
174  float length = it->surface().bounds().length();
175  assert(length == parameters[8]);
176 
177  int firstChannel = it->specificTopology().firstChannel();
178  assert(firstChannel == parameters[3]);
179 
180  int lastChannel = it->specificTopology().lastChannel();
181  int nChannels = parameters[5];
182  assert(nChannels == (lastChannel - firstChannel) + 1);
183 
184  for (int wireN = firstChannel; wireN - lastChannel <= 0; ++wireN) {
185  float localX1 = it->specificTopology().wirePosition(wireN);
186  float localX2 = (wireN - (firstChannel - 1) - 0.5f) * parameters[0] - nChannels / 2.0f * parameters[0];
187  wire_positions.emplace_back(getDiff(localX1, localX2));
188  }
189  }
190 
191  makeHistogram("DT Layer Wire localX", wire_positions);
192  makeHistograms("DT Layer");
193 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:416
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
float getDiff(const float, const float)
void makeHistograms(const char *)
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:163
void compareShape(const GeomDet *, const float *)
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:427
void compareTransform(const GlobalPoint &, const TGeoMatrix *)
edm::ESHandle< DTGeometry > dtGeometry_
double f[11][100]
const std::vector< const DTLayer * > & layers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:88
void makeHistogram(const string &, vector< float > &)

Member Data Documentation

vector<float> DTGeometryValidate::bottomWidths_
private

Definition at line 75 of file DTGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

edm::ESHandle<DTGeometry> DTGeometryValidate::dtGeometry_
private
edm::ESGetToken<DTGeometry, MuonGeometryRecord> DTGeometryValidate::dtGeometryToken_
private

Definition at line 69 of file DTGeometryValidate.cc.

Referenced by analyze().

FWGeometry DTGeometryValidate::fwGeometry_
private
vector<float> DTGeometryValidate::globalDistances_
private

Definition at line 73 of file DTGeometryValidate.cc.

Referenced by compareTransform(), and makeHistograms().

string DTGeometryValidate::infileName_
private

Definition at line 78 of file DTGeometryValidate.cc.

Referenced by DTGeometryValidate().

vector<float> DTGeometryValidate::lengths_
private

Definition at line 76 of file DTGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

TFile* DTGeometryValidate::outFile_
private

Definition at line 72 of file DTGeometryValidate.cc.

Referenced by beginJob(), DTGeometryValidate(), endJob(), and makeHistograms().

string DTGeometryValidate::outfileName_
private

Definition at line 79 of file DTGeometryValidate.cc.

Referenced by DTGeometryValidate(), and endJob().

vector<float> DTGeometryValidate::thicknesses_
private

Definition at line 77 of file DTGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

int DTGeometryValidate::tolerance_
private

Definition at line 80 of file DTGeometryValidate.cc.

Referenced by DTGeometryValidate(), and getDiff().

vector<float> DTGeometryValidate::topWidths_
private

Definition at line 74 of file DTGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().