CMS 3D CMS Logo

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

Public Member Functions

 CSCGeometryValidate (const ParameterSet &)
 
 ~CSCGeometryValidate () override
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void clearData ()
 
void clearData2 ()
 
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 makeHistograms2 (const char *)
 
void validateCSCChamberGeometry ()
 
void validateCSCLayerGeometry ()
 

Private Attributes

vector< float > angularWidth_
 
vector< float > bottomWidths_
 
vector< float > centreToIntersection_
 
const CSCGeometrycscGeometry_
 
FWGeometry fwGeometry_
 
vector< float > globalDistances_
 
string infileName_
 
vector< float > lengths_
 
TFile * outFile_
 
string outfileName_
 
vector< float > phiOfOneEdge_
 
vector< float > sOffset_
 
vector< float > thicknesses_
 
const edm::ESGetToken< CSCGeometry, MuonGeometryRecordtokCSC_
 
int tolerance_
 
vector< float > topWidths_
 
vector< float > wireAngle_
 
vector< float > wireSpacing_
 
vector< float > yAxisOrientation_
 
vector< float > yCentreOfStripPlane_
 

Detailed Description

Definition at line 52 of file CSCGeometryValidate.cc.

Constructor & Destructor Documentation

◆ CSCGeometryValidate()

CSCGeometryValidate::CSCGeometryValidate ( const ParameterSet iConfig)
explicit

Definition at line 120 of file CSCGeometryValidate.cc.

121  : tokCSC_{esConsumes<CSCGeometry, MuonGeometryRecord>(edm::ESInputTag{})},
122  infileName_(iConfig.getUntrackedParameter<string>("infileName", "cmsGeom10.root")),
123  outfileName_(iConfig.getUntrackedParameter<string>("outfileName", "validateCSCGeometry.root")),
124  tolerance_(iConfig.getUntrackedParameter<int>("tolerance", 6)) {
126  outFile_ = TFile::Open(outfileName_.c_str(), "RECREATE");
127 }
T getUntrackedParameter(std::string const &, T const &) const
void loadMap(const char *fileName)
Definition: FWGeometry.cc:103
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > tokCSC_

◆ ~CSCGeometryValidate()

CSCGeometryValidate::~CSCGeometryValidate ( )
inlineoverride

Definition at line 55 of file CSCGeometryValidate.cc.

55 {}

Member Function Documentation

◆ analyze()

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

Definition at line 129 of file CSCGeometryValidate.cc.

References cscGeometry_, options_cfi::eventSetup, tokCSC_, validateCSCChamberGeometry(), and validateCSCLayerGeometry().

129  {
130  cscGeometry_ = &eventSetup.getData(tokCSC_);
131  LogVerbatim("CSCGeometry") << "Validating CSC chamber geometry";
134 }
Log< level::Info, true > LogVerbatim
const CSCGeometry * cscGeometry_
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > tokCSC_

◆ beginJob()

void CSCGeometryValidate::beginJob ( void  )
overrideprivate

Definition at line 348 of file CSCGeometryValidate.cc.

References outFile_.

348 { outFile_->cd(); }

◆ clearData()

void CSCGeometryValidate::clearData ( )
inlineprivate

Definition at line 75 of file CSCGeometryValidate.cc.

Referenced by validateCSCChamberGeometry().

75  {
76  globalDistances_.clear();
77  topWidths_.clear();
78  bottomWidths_.clear();
79  lengths_.clear();
80  thicknesses_.clear();
81  }
vector< float > bottomWidths_
vector< float > topWidths_
vector< float > globalDistances_
vector< float > thicknesses_

◆ clearData2()

void CSCGeometryValidate::clearData2 ( )
inlineprivate

Definition at line 83 of file CSCGeometryValidate.cc.

Referenced by validateCSCLayerGeometry().

83  {
84  yAxisOrientation_.clear();
85  sOffset_.clear();
86  yCentreOfStripPlane_.clear();
87  angularWidth_.clear();
88  centreToIntersection_.clear();
89  phiOfOneEdge_.clear();
90  wireSpacing_.clear();
91  wireAngle_.clear();
92  }
vector< float > phiOfOneEdge_
vector< float > yAxisOrientation_
vector< float > wireAngle_
vector< float > centreToIntersection_
vector< float > angularWidth_
vector< float > yCentreOfStripPlane_
vector< float > wireSpacing_

◆ compareShape()

void CSCGeometryValidate::compareShape ( const GeomDet det,
const float *  shape 
)
private

Definition at line 219 of file CSCGeometryValidate.cc.

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

Referenced by validateCSCChamberGeometry().

219  {
220  float shapeTopWidth;
221  float shapeBottomWidth;
222  float shapeLength;
223  float shapeThickness;
224 
225  if (shape[0] == 1) {
226  shapeTopWidth = shape[2];
227  shapeBottomWidth = shape[1];
228  shapeLength = shape[4];
229  shapeThickness = shape[3];
230  } else if (shape[0] == 2) {
231  shapeTopWidth = shape[1];
232  shapeBottomWidth = shape[1];
233  shapeLength = shape[2];
234  shapeThickness = shape[3];
235  } else {
236  LogVerbatim("CSCGeometry") << "Failed to get box or trapezoid from shape";
237 
238  return;
239  }
240 
241  float topWidth, bottomWidth;
242  float length, thickness;
243 
244  const Bounds* bounds = &(det->surface().bounds());
245  if (const TrapezoidalPlaneBounds* tpbs = dynamic_cast<const TrapezoidalPlaneBounds*>(bounds)) {
246  array<const float, 4> const& ps = tpbs->parameters();
247 
248  assert(ps.size() == 4);
249 
250  bottomWidth = ps[0];
251  topWidth = ps[1];
252  thickness = ps[2];
253  length = ps[3];
254  } else if ((dynamic_cast<const RectangularPlaneBounds*>(bounds))) {
255  length = det->surface().bounds().length() * 0.5;
256  topWidth = det->surface().bounds().width() * 0.5;
257  bottomWidth = topWidth;
258  thickness = det->surface().bounds().thickness() * 0.5;
259  } else {
260  LogVerbatim("CSCGeometry") << "Failed to get bounds";
261 
262  return;
263  }
264  topWidths_.push_back(fabs(shapeTopWidth - topWidth));
265  bottomWidths_.push_back(fabs(shapeBottomWidth - bottomWidth));
266  lengths_.push_back(fabs(shapeLength - length));
267  thicknesses_.push_back(fabs(shapeThickness - thickness));
268 }
Log< level::Info, true > LogVerbatim
virtual float length() const =0
vector< float > bottomWidths_
assert(be >=bs)
virtual float thickness() const =0
vector< float > topWidths_
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
vector< float > thicknesses_
Definition: Bounds.h:18
virtual float width() const =0
const Bounds & bounds() const
Definition: Surface.h:87

◆ compareTransform()

void CSCGeometryValidate::compareTransform ( const GlobalPoint gp,
const TGeoMatrix *  matrix 
)
private

Definition at line 207 of file CSCGeometryValidate.cc.

References HLT_2022v12_cff::distance, MillePedeFileConverter_cfg::e, getDistance(), globalDistances_, runTauDisplay::gp, DTRecHitClients_cfi::local, and makeMuonMisalignmentScenario::matrix.

Referenced by validateCSCChamberGeometry().

207  {
208  double local[3] = {0.0, 0.0, 0.0};
209  double global[3];
210 
211  matrix->LocalToMaster(local, global);
212 
213  float distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp);
214  if ((distance >= 0.0) && (distance < 1.0e-7))
215  distance = 0.0; // set a tollerance for the distance inside Histos
216  globalDistances_.push_back(distance);
217 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
vector< float > globalDistances_
float getDistance(const GlobalPoint &, const GlobalPoint &)

◆ endJob()

void CSCGeometryValidate::endJob ( void  )
overrideprivate

Definition at line 350 of file CSCGeometryValidate.cc.

References outFile_, and outfileName_.

350  {
351  LogVerbatim("CSCGeometry") << "Done.";
352  LogVerbatim("CSCGeometry") << "Results written to " << outfileName_;
353  outFile_->Close();
354 }
Log< level::Info, true > LogVerbatim

◆ getDiff()

float CSCGeometryValidate::getDiff ( const float  val1,
const float  val2 
)
private

Definition at line 275 of file CSCGeometryValidate.cc.

References almost_equal(), and tolerance_.

275  {
276  if (almost_equal(val1, val2, tolerance_))
277  return 0.0f;
278  else
279  return (val1 - val2);
280 }
enable_if<!numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp)

◆ getDistance()

float CSCGeometryValidate::getDistance ( const GlobalPoint p1,
const GlobalPoint p2 
)
private

Definition at line 270 of file CSCGeometryValidate.cc.

References LaserDQM_cfg::p1, SiStripOfflineCRack_cfg::p2, and mathSSE::sqrt().

Referenced by compareTransform().

270  {
271  return sqrt((p1.x() - p2.x()) * (p1.x() - p2.x()) + (p1.y() - p2.y()) * (p1.y() - p2.y()) +
272  (p1.z() - p2.z()) * (p1.z() - p2.z()));
273 }
T sqrt(T t)
Definition: SSEVec.h:19

◆ makeHistogram()

void CSCGeometryValidate::makeHistogram ( const string &  name,
vector< float > &  data 
)
private

Definition at line 333 of file CSCGeometryValidate.cc.

References data, mps_fire::end, gpuVertexFinder::hist, HLT_2022v12_cff::maxE, and Skims_PA_cff::name.

Referenced by makeHistograms(), and makeHistograms2().

333  {
334  if (data.empty())
335  return;
336 
337  const auto [minE, maxE] = minmax_element(begin(data), end(data));
338 
339  TH1D hist(name.c_str(), name.c_str(), 100, *minE * (1 + 0.10), *maxE * (1 + 0.10));
340 
341  for (auto const& it : data)
342  hist.Fill(it);
343 
344  hist.GetXaxis()->SetTitle("[cm]");
345  hist.Write();
346 }
__shared__ Hist hist
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ makeHistograms()

void CSCGeometryValidate::makeHistograms ( const char *  detector)
private

Definition at line 282 of file CSCGeometryValidate.cc.

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

Referenced by validateCSCChamberGeometry().

282  {
283  outFile_->cd();
284 
285  string d(detector);
286 
287  string gdn = d + ": distance between points in global coordinates";
289 
290  string twn = d + ": absolute difference between top widths (along X)";
292 
293  string bwn = d + ": absolute difference between bottom widths (along X)";
295 
296  string ln = d + ": absolute difference between lengths (along Y)";
297  makeHistogram(ln, lengths_);
298 
299  string tn = d + ": absolute difference between thicknesses (along Z)";
301 }
vector< float > bottomWidths_
vector< float > topWidths_
d
Definition: ztail.py:151
void makeHistogram(const string &, vector< float > &)
vector< float > globalDistances_
vector< float > thicknesses_

◆ makeHistograms2()

void CSCGeometryValidate::makeHistograms2 ( const char *  detector)
private

Definition at line 303 of file CSCGeometryValidate.cc.

References angularWidth_, centreToIntersection_, ztail::d, hgcalTestNeighbor_cfi::detector, makeHistogram(), outFile_, phiOfOneEdge_, pi, sOffset_, wireAngle_, wireSpacing_, gpuVertexFinder::ws, yAxisOrientation_, and yCentreOfStripPlane_.

Referenced by validateCSCLayerGeometry().

303  {
304  outFile_->cd();
305 
306  string d(detector);
307 
308  string ns = d + ": absolute difference between Y Axis Orientation of the Strips";
310 
311  string pi = d + ": absolute difference between Strips Offset";
313 
314  string pl = d + ": absolute difference between 'Y centre' of the Strips Planes";
316 
317  string aw = d + ": absolute difference between 'angular width' of the Strips ";
319 
320  string ci = d + ": absolute difference between 'centre to intersection' of the Strips ";
322 
323  string po = d + ": absolute difference between 'phi of one edge' of the Strips ";
325 
326  string ws = d + ": absolute difference between 'wire spacing' of the Wires ";
328 
329  string wa = d + ": absolute difference between 'wire angle' of the Wires ";
331 }
vector< float > phiOfOneEdge_
vector< float > yAxisOrientation_
vector< float > wireAngle_
vector< float > centreToIntersection_
const Double_t pi
auto &__restrict__ ws
vector< float > angularWidth_
d
Definition: ztail.py:151
vector< float > yCentreOfStripPlane_
void makeHistogram(const string &, vector< float > &)
vector< float > wireSpacing_

◆ validateCSCChamberGeometry()

void CSCGeometryValidate::validateCSCChamberGeometry ( )
private

Definition at line 136 of file CSCGeometryValidate.cc.

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

Referenced by analyze().

136  {
137  clearData();
138 
139  for (auto const& it : cscGeometry_->chambers()) {
140  CSCDetId chId = it->id();
141  GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0));
142 
143  const TGeoMatrix* matrix = fwGeometry_.getMatrix(chId.rawId());
144 
145  if (!matrix) {
146  LogVerbatim("CSCGeometry") << "Failed to get matrix of CSC chamber with detid: " << chId.rawId();
147  continue;
148  }
150 
151  auto const& shape = fwGeometry_.getShapePars(chId.rawId());
152 
153  if (!shape) {
154  LogVerbatim("CSCGeometry") << "Failed to get shape of CSC chamber with detid: " << chId.rawId();
155  continue;
156  }
157  compareShape(it, shape);
158  }
159  makeHistograms("CSC Chamber");
160 }
Log< level::Info, true > LogVerbatim
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
void compareTransform(const GlobalPoint &, const TGeoMatrix *)
void compareShape(const GeomDet *, const float *)
const CSCGeometry * cscGeometry_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:483
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:225
void makeHistograms(const char *)
const ChamberContainer & chambers() const
Return a vector of all chambers.
Definition: CSCGeometry.cc:96

◆ validateCSCLayerGeometry()

void CSCGeometryValidate::validateCSCLayerGeometry ( )
private

Definition at line 162 of file CSCGeometryValidate.cc.

References CSCRadialStripTopology::angularWidth(), angularWidth_, CSCRadialStripTopology::centreToIntersection(), centreToIntersection_, clearData2(), cscGeometry_, fwGeometry_, FWGeometry::getParameters(), CSCGeometry::layers(), makeHistograms2(), CSCLayerGeometry::numberOfStrips(), CSCLayerGeometry::numberOfWires(), CSCRadialStripTopology::phiOfOneEdge(), phiOfOneEdge_, DetId::rawId(), sOffset_, CSCLayerGeometry::stripOffset(), CSCLayerGeometry::topology(), CSCWireTopology::wireAngle(), wireAngle_, CSCWireTopology::wireSpacing(), wireSpacing_, CSCLayerGeometry::wireTopology(), CSCRadialStripTopology::yAxisOrientation(), yAxisOrientation_, CSCRadialStripTopology::yCentreOfStripPlane(), and yCentreOfStripPlane_.

Referenced by analyze().

162  {
163  clearData2();
164 
165  for (auto const& it : cscGeometry_->layers()) {
166  CSCDetId chId = it->id();
167  const CSCLayerGeometry* laygeo = it->geometry();
168  const int n_strips = laygeo->numberOfStrips();
169  const int n_wire = laygeo->numberOfWires();
170  const float strips_offset = laygeo->stripOffset();
171  const CSCStripTopology* stopo = laygeo->topology();
172  const float ycentre_of_strip_plane = stopo->yCentreOfStripPlane();
173  const float angular_width = stopo->angularWidth();
174  const float y_axis_orientation = stopo->yAxisOrientation();
175  const float centre_to_intersection = stopo->centreToIntersection();
176  const float phi_of_one_edge = stopo->phiOfOneEdge();
177  const float* parameters = fwGeometry_.getParameters(chId.rawId());
178  const CSCWireTopology* wiretopo = laygeo->wireTopology();
179  const double wire_spacing = wiretopo->wireSpacing();
180  const float wire_angle = wiretopo->wireAngle();
181 
182  if (n_strips) {
183  for (int istrips = 1; istrips <= n_strips; istrips++) {
184  yAxisOrientation_.push_back(fabs(y_axis_orientation - parameters[0]));
185  sOffset_.push_back(fabs(strips_offset - parameters[4]));
186  yCentreOfStripPlane_.push_back(fabs(ycentre_of_strip_plane - parameters[2]));
187  angularWidth_.push_back(fabs(angular_width - parameters[5]));
188  centreToIntersection_.push_back(fabs(centre_to_intersection - parameters[1]));
189  phiOfOneEdge_.push_back(fabs(phi_of_one_edge - parameters[3]));
190  }
191  } else {
192  LogVerbatim("CSCGeometry") << "ATTENTION! nStrips == 0";
193  }
194 
195  if (n_wire) {
196  for (int iwires = 1; iwires <= n_wire; iwires++) {
197  wireSpacing_.push_back(fabs(wire_spacing - parameters[6]));
198  wireAngle_.push_back(fabs(wire_angle - parameters[7]));
199  }
200  } else {
201  LogVerbatim("CSCGeometry") << "ATTENTION! nWires == 0";
202  }
203  }
204  makeHistograms2("CSC Layer");
205 }
Log< level::Info, true > LogVerbatim
float centreToIntersection() const override
vector< float > phiOfOneEdge_
const CSCWireTopology * wireTopology() const
float stripOffset(void) const
vector< float > yAxisOrientation_
float phiOfOneEdge() const override
vector< float > wireAngle_
vector< float > centreToIntersection_
float yAxisOrientation() const override
void makeHistograms2(const char *)
float wireAngle() const override
vector< float > angularWidth_
int numberOfStrips() const
float angularWidth() const override
double wireSpacing() const
const CSCGeometry * cscGeometry_
int numberOfWires() const
vector< float > yCentreOfStripPlane_
float yCentreOfStripPlane() const override
const LayerContainer & layers() const
Return a vector of all layers.
Definition: CSCGeometry.cc:98
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:472
const CSCStripTopology * topology() const
vector< float > wireSpacing_

Member Data Documentation

◆ angularWidth_

vector<float> CSCGeometryValidate::angularWidth_
private

Definition at line 108 of file CSCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateCSCLayerGeometry().

◆ bottomWidths_

vector<float> CSCGeometryValidate::bottomWidths_
private

Definition at line 101 of file CSCGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

◆ centreToIntersection_

vector<float> CSCGeometryValidate::centreToIntersection_
private

Definition at line 109 of file CSCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateCSCLayerGeometry().

◆ cscGeometry_

const CSCGeometry* CSCGeometryValidate::cscGeometry_
private

◆ fwGeometry_

FWGeometry CSCGeometryValidate::fwGeometry_
private

Definition at line 96 of file CSCGeometryValidate.cc.

Referenced by validateCSCChamberGeometry(), and validateCSCLayerGeometry().

◆ globalDistances_

vector<float> CSCGeometryValidate::globalDistances_
private

Definition at line 99 of file CSCGeometryValidate.cc.

Referenced by compareTransform(), and makeHistograms().

◆ infileName_

string CSCGeometryValidate::infileName_
private

Definition at line 115 of file CSCGeometryValidate.cc.

◆ lengths_

vector<float> CSCGeometryValidate::lengths_
private

Definition at line 102 of file CSCGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

◆ outFile_

TFile* CSCGeometryValidate::outFile_
private

Definition at line 97 of file CSCGeometryValidate.cc.

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

◆ outfileName_

string CSCGeometryValidate::outfileName_
private

Definition at line 116 of file CSCGeometryValidate.cc.

Referenced by endJob().

◆ phiOfOneEdge_

vector<float> CSCGeometryValidate::phiOfOneEdge_
private

Definition at line 110 of file CSCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateCSCLayerGeometry().

◆ sOffset_

vector<float> CSCGeometryValidate::sOffset_
private

Definition at line 106 of file CSCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateCSCLayerGeometry().

◆ thicknesses_

vector<float> CSCGeometryValidate::thicknesses_
private

Definition at line 103 of file CSCGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

◆ tokCSC_

const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> CSCGeometryValidate::tokCSC_
private

Definition at line 94 of file CSCGeometryValidate.cc.

Referenced by analyze().

◆ tolerance_

int CSCGeometryValidate::tolerance_
private

Definition at line 117 of file CSCGeometryValidate.cc.

Referenced by getDiff().

◆ topWidths_

vector<float> CSCGeometryValidate::topWidths_
private

Definition at line 100 of file CSCGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

◆ wireAngle_

vector<float> CSCGeometryValidate::wireAngle_
private

Definition at line 113 of file CSCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateCSCLayerGeometry().

◆ wireSpacing_

vector<float> CSCGeometryValidate::wireSpacing_
private

Definition at line 112 of file CSCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateCSCLayerGeometry().

◆ yAxisOrientation_

vector<float> CSCGeometryValidate::yAxisOrientation_
private

Definition at line 105 of file CSCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateCSCLayerGeometry().

◆ yCentreOfStripPlane_

vector<float> CSCGeometryValidate::yCentreOfStripPlane_
private

Definition at line 107 of file CSCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateCSCLayerGeometry().