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 41 of file DTGeometryValidate.cc.

Constructor & Destructor Documentation

DTGeometryValidate::DTGeometryValidate ( const ParameterSet iConfig)
explicit

Definition at line 87 of file DTGeometryValidate.cc.

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

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

Definition at line 45 of file DTGeometryValidate.cc.

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

45 {}

Member Function Documentation

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

Definition at line 98 of file DTGeometryValidate.cc.

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

99 {
100  dtGeometry_ = eventSetup.getHandle(dtGeometryToken_);
101 
102  if(dtGeometry_.isValid()) {
103  LogVerbatim("DTGeometry") << "Validating DT chamber geometry";
105 
106  LogVerbatim("DTGeometry") <<"Validating DT layer geometry";
108  }
109  else
110  LogVerbatim("DTGeometry") << "Invalid DT geometry";
111 }
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryToken_
edm::ESHandle< DTGeometry > dtGeometry_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:139
bool isValid() const
Definition: ESHandle.h:44
void DTGeometryValidate::beginJob ( void  )
overrideprivate

Definition at line 339 of file DTGeometryValidate.cc.

References outFile_.

339  {
340  outFile_->cd();
341 }
void DTGeometryValidate::clearData ( )
inlineprivate

Definition at line 64 of file DTGeometryValidate.cc.

Referenced by validateDTChamberGeometry(), and validateDTLayerGeometry().

64  {
65  globalDistances_.clear();
66  topWidths_.clear();
67  bottomWidths_.clear();
68  lengths_.clear();
69  thicknesses_.clear();
70  }
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 226 of file DTGeometryValidate.cc.

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

Referenced by validateDTChamberGeometry(), and validateDTLayerGeometry().

227 {
228  float shapeTopWidth;
229  float shapeBottomWidth;
230  float shapeLength;
231  float shapeThickness;
232 
233  if(shape[0] == 1) {
234  shapeTopWidth = shape[2];
235  shapeBottomWidth = shape[1];
236  shapeLength = shape[4];
237  shapeThickness = shape[3];
238  }
239  else if(shape[0] == 2) {
240  shapeTopWidth = shape[1];
241  shapeBottomWidth = shape[1];
242  shapeLength = shape[2];
243  shapeThickness = shape[3];
244  }
245  else {
246  LogVerbatim("DTGeometry") << "Failed to get box or trapezoid from shape";
247  return;
248  }
249 
250  float topWidth, bottomWidth;
251  float length, thickness;
252 
253  const Bounds* bounds = &(det->surface().bounds());
254 
255  if(const TrapezoidalPlaneBounds* tpbs = dynamic_cast<const TrapezoidalPlaneBounds*>(bounds))
256  {
257  array<const float, 4> const & ps = tpbs->parameters();
258 
259  assert(ps.size() == 4);
260 
261  bottomWidth = ps[0];
262  topWidth = ps[1];
263  thickness = ps[2];
264  length = ps[3];
265  }
266  else if((dynamic_cast<const RectangularPlaneBounds*>(bounds))) {
267  length = det->surface().bounds().length()*0.5;
268  topWidth = det->surface().bounds().width()*0.5;
269  bottomWidth = topWidth;
270  thickness = det->surface().bounds().thickness()*0.5;
271  }
272  else {
273  LogVerbatim("DTGeometry") << "Failed to get bounds";
274  return;
275  }
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));
280 }
virtual float length() const =0
const Bounds & bounds() const
Definition: Surface.h:120
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
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:22
void DTGeometryValidate::compareTransform ( const GlobalPoint gp,
const TGeoMatrix *  matrix 
)
private

Definition at line 213 of file DTGeometryValidate.cc.

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

Referenced by validateDTChamberGeometry(), and validateDTLayerGeometry().

215 {
216  double local[3] = { 0.0, 0.0, 0.0 };
217  double global[3];
218 
219  matrix->LocalToMaster(local, global);
220 
221  float distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp);
222  globalDistances_.push_back(distance);
223 }
float getDistance(const GlobalPoint &, const GlobalPoint &)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
vector< float > globalDistances_
void DTGeometryValidate::endJob ( void  )
overrideprivate

Definition at line 344 of file DTGeometryValidate.cc.

References DEFINE_FWK_MODULE, outFile_, and outfileName_.

344  {
345  LogVerbatim("DTGeometry") << "Done.";
346  LogVerbatim("DTGeometry") << "Results written to "<< outfileName_;
347  outFile_->Close();
348 }
float DTGeometryValidate::getDiff ( const float  val1,
const float  val2 
)
private

Definition at line 291 of file DTGeometryValidate.cc.

References almost_equal(), and tolerance_.

Referenced by validateDTLayerGeometry().

291  {
292  if(almost_equal(val1, val2, tolerance_))
293  return 0.0f;
294  else
295  return (val1 - val2);
296 }
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 283 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().

284 {
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()));
288 }
T y() const
Definition: PV3DBase.h:63
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
T x() const
Definition: PV3DBase.h:62
void DTGeometryValidate::makeHistogram ( const string &  name,
vector< float > &  data 
)
private

Definition at line 322 of file DTGeometryValidate.cc.

References begin, end, create_public_lumi_plots::hist, and particleFlow_cfi::maxE.

Referenced by makeHistograms(), and validateDTLayerGeometry().

323 {
324  if(data.empty())
325  return;
326 
327  const auto [minE, maxE] = minmax_element(begin(data), end(data));
328 
329  TH1D hist(name.c_str(), name.c_str(), 100, *minE*(1+0.10), *maxE*(1+0.10));
330 
331  for(auto const& it : data)
332  hist.Fill(it);
333 
334  hist.GetXaxis()->SetTitle("[cm]");
335  hist.Write();
336 }
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void DTGeometryValidate::makeHistograms ( const char *  detector)
private

Definition at line 299 of file DTGeometryValidate.cc.

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

Referenced by validateDTChamberGeometry(), and validateDTLayerGeometry().

300 {
301  outFile_->cd();
302 
303  string d(detector);
304 
305  string gdn = d+": distance between points in global coordinates";
307 
308  string twn = d + ": absolute difference between top widths (along X)";
310 
311  string bwn = d + ": absolute difference between bottom widths (along X)";
313 
314  string ln = d + ": absolute difference between lengths (along Y)";
315  makeHistogram(ln, lengths_);
316 
317  string tn = d + ": absolute difference between thicknesses (along Z)";
319 }
vector< float > globalDistances_
vector< float > topWidths_
vector< float > lengths_
vector< float > thicknesses_
vector< float > bottomWidths_
void makeHistogram(const string &, vector< float > &)
void DTGeometryValidate::validateDTChamberGeometry ( )
private

Definition at line 114 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().

114  {
115 
116  clearData();
117 
118  for(auto const& it : dtGeometry_->chambers()) {
119  DTChamberId chId = it->id();
120  GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0));
121 
122  const TGeoMatrix* matrix = fwGeometry_.getMatrix(chId.rawId());
123 
124  if(!matrix) {
125  LogVerbatim("DTGeometry") << "Failed to get matrix of DT chamber with detid: "
126  << chId.rawId();
127  continue;
128  }
129 
130  compareTransform(gp, matrix);
131 
132  auto const& shape = fwGeometry_.getShapePars(chId.rawId());
133 
134  if(!shape) {
135  LogVerbatim("DTGeometry") << "Failed to get shape of DT chamber with detid: "
136  << chId.rawId();
137  continue;
138  }
139 
140  compareShape(it, shape);
141  }
142 
143  makeHistograms("DT Chamber");
144 }
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:102
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
void makeHistograms(const char *)
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:186
void compareShape(const GeomDet *, const float *)
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:462
void compareTransform(const GlobalPoint &, const TGeoMatrix *)
edm::ESHandle< DTGeometry > dtGeometry_
void DTGeometryValidate::validateDTLayerGeometry ( )
private

Definition at line 147 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(), and ApeEstimator_cff::width.

Referenced by analyze().

147  {
148 
149  clearData();
150 
151  vector<float> wire_positions;
152 
153  for(auto const& it : dtGeometry_->layers()) {
154  DTLayerId layerId = it->id();
155  GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0));
156 
157  const TGeoMatrix* matrix = fwGeometry_.getMatrix(layerId.rawId());
158 
159  if (!matrix) {
160  LogVerbatim("DTGeometry") << "Failed to get matrix of DT layer with detid: "
161  << layerId.rawId();
162  continue;
163  }
164 
165  compareTransform(gp, matrix);
166 
167  auto const& shape = fwGeometry_.getShapePars(layerId.rawId());
168 
169  if(!shape) {
170  LogVerbatim("DTGeometry") << "Failed to get shape of DT layer with detid: "
171  << layerId.rawId();
172  continue;
173  }
174 
175  compareShape(it, shape);
176 
177  auto const& parameters = fwGeometry_.getParameters(layerId.rawId());
178 
179  if(parameters == nullptr) {
180  LogVerbatim("DTGeometry") << "Parameters empty for DT layer with detid: "
181  << layerId.rawId();
182  continue;
183  }
184 
185  float width = it->surface().bounds().width();
186  assert(width == parameters[6]);
187 
188  float thickness = it->surface().bounds().thickness();
189  assert(thickness == parameters[7]);
190 
191  float length = it->surface().bounds().length();
192  assert(length == parameters[8]);
193 
194  int firstChannel = it->specificTopology().firstChannel();
195  assert(firstChannel == parameters[3]);
196 
197  int lastChannel = it->specificTopology().lastChannel();
198  int nChannels = parameters[5];
199  assert(nChannels == (lastChannel-firstChannel)+1);
200 
201  for(int wireN = firstChannel; wireN - lastChannel <= 0; ++wireN) {
202  float localX1 = it->specificTopology().wirePosition(wireN);
203  float localX2 = (wireN -(firstChannel-1)-0.5f)*parameters[0] - nChannels/2.0f*parameters[0];
204  wire_positions.emplace_back(getDiff(localX1, localX2));
205  }
206  }
207 
208  makeHistogram("DT Layer Wire localX", wire_positions);
209  makeHistograms("DT Layer");
210 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:446
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
float getDiff(const float, const float)
void makeHistograms(const char *)
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:186
void compareShape(const GeomDet *, const float *)
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:462
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:112
void makeHistogram(const string &, vector< float > &)

Member Data Documentation

vector<float> DTGeometryValidate::bottomWidths_
private

Definition at line 78 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 72 of file DTGeometryValidate.cc.

Referenced by analyze().

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

Definition at line 76 of file DTGeometryValidate.cc.

Referenced by compareTransform(), and makeHistograms().

string DTGeometryValidate::infileName_
private

Definition at line 81 of file DTGeometryValidate.cc.

Referenced by DTGeometryValidate().

vector<float> DTGeometryValidate::lengths_
private

Definition at line 79 of file DTGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

TFile* DTGeometryValidate::outFile_
private

Definition at line 75 of file DTGeometryValidate.cc.

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

string DTGeometryValidate::outfileName_
private

Definition at line 82 of file DTGeometryValidate.cc.

Referenced by DTGeometryValidate(), and endJob().

vector<float> DTGeometryValidate::thicknesses_
private

Definition at line 80 of file DTGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

int DTGeometryValidate::tolerance_
private

Definition at line 83 of file DTGeometryValidate.cc.

Referenced by DTGeometryValidate(), and getDiff().

vector<float> DTGeometryValidate::topWidths_
private

Definition at line 77 of file DTGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().