CMS 3D CMS Logo

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

Public Member Functions

 ME0GeometryValidate (const ParameterSet &)
 
 ~ME0GeometryValidate () 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 validateME0ChamberGeometry ()
 
void validateME0EtaPartitionGeometry ()
 
void validateME0EtaPartitionGeometry2 ()
 

Private Attributes

vector< float > bottomWidths_
 
FWGeometry fwGeometry_
 
vector< float > globalDistances_
 
string infileName_
 
vector< float > lengths_
 
const ME0Geometryme0Geometry_
 
vector< float > nstrips_
 
TFile * outFile_
 
string outfileName_
 
vector< float > pitch_
 
vector< float > stripslen_
 
vector< float > thicknesses_
 
const edm::ESGetToken< ME0Geometry, MuonGeometryRecordtokGeom_
 
int tolerance_
 
vector< float > topWidths_
 

Detailed Description

Definition at line 49 of file ME0GeometryValidate.cc.

Constructor & Destructor Documentation

◆ ME0GeometryValidate()

ME0GeometryValidate::ME0GeometryValidate ( const ParameterSet iConfig)
explicit

Definition at line 104 of file ME0GeometryValidate.cc.

105  : tokGeom_{esConsumes<ME0Geometry, MuonGeometryRecord>(edm::ESInputTag{})},
106  infileName_(iConfig.getUntrackedParameter<string>("infileName", "cmsRecoGeom-2026.root")),
107  outfileName_(iConfig.getUntrackedParameter<string>("outfileName", "validateME0Geometry.root")),
108  tolerance_(iConfig.getUntrackedParameter<int>("tolerance", 6)) {
110  outFile_ = TFile::Open(outfileName_.c_str(), "RECREATE");
111 }
T getUntrackedParameter(std::string const &, T const &) const
void loadMap(const char *fileName)
Definition: FWGeometry.cc:103
const edm::ESGetToken< ME0Geometry, MuonGeometryRecord > tokGeom_

◆ ~ME0GeometryValidate()

ME0GeometryValidate::~ME0GeometryValidate ( )
inlineoverride

Definition at line 52 of file ME0GeometryValidate.cc.

52 {}

Member Function Documentation

◆ analyze()

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

Definition at line 113 of file ME0GeometryValidate.cc.

References options_cfi::eventSetup, LogTrace, me0Geometry_, tokGeom_, validateME0ChamberGeometry(), validateME0EtaPartitionGeometry(), and validateME0EtaPartitionGeometry2().

113  {
114  me0Geometry_ = &eventSetup.getData(tokGeom_);
115  LogTrace("ME0Geometry") << "Validating ME0 chamber geometry";
119 }
#define LogTrace(id)
const ME0Geometry * me0Geometry_
const edm::ESGetToken< ME0Geometry, MuonGeometryRecord > tokGeom_

◆ beginJob()

void ME0GeometryValidate::beginJob ( void  )
overrideprivate

Definition at line 329 of file ME0GeometryValidate.cc.

References outFile_.

329 { outFile_->cd(); }

◆ clearData()

void ME0GeometryValidate::clearData ( )
inlineprivate

Definition at line 73 of file ME0GeometryValidate.cc.

Referenced by validateME0ChamberGeometry(), and validateME0EtaPartitionGeometry2().

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

◆ clearData2()

void ME0GeometryValidate::clearData2 ( )
inlineprivate

Definition at line 81 of file ME0GeometryValidate.cc.

Referenced by validateME0EtaPartitionGeometry().

81  {
82  nstrips_.clear();
83  pitch_.clear();
84  stripslen_.clear();
85  }
vector< float > nstrips_
vector< float > stripslen_

◆ compareShape()

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

Definition at line 213 of file ME0GeometryValidate.cc.

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

Referenced by validateME0ChamberGeometry(), and validateME0EtaPartitionGeometry2().

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

◆ compareTransform()

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

Definition at line 201 of file ME0GeometryValidate.cc.

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

Referenced by validateME0ChamberGeometry(), and validateME0EtaPartitionGeometry2().

201  {
202  double local[3] = {0.0, 0.0, 0.0};
203  double global[3];
204 
205  matrix->LocalToMaster(local, global);
206 
207  float distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp);
208  if (abs(distance) < 1.0e-7)
209  distance = 0.0; // set a tollerance for the distance inside Histos
210  globalDistances_.push_back(distance);
211 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
vector< float > globalDistances_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float getDistance(const GlobalPoint &, const GlobalPoint &)

◆ endJob()

void ME0GeometryValidate::endJob ( void  )
overrideprivate

Definition at line 331 of file ME0GeometryValidate.cc.

References LogTrace, outFile_, and outfileName_.

331  {
332  LogTrace("ME0Geometry") << "Done.";
333  LogTrace("ME0Geometry") << "Results written to " << outfileName_;
334  outFile_->Close();
335 }
#define LogTrace(id)

◆ getDiff()

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

Definition at line 271 of file ME0GeometryValidate.cc.

References almost_equal(), and tolerance_.

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

◆ getDistance()

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

Definition at line 266 of file ME0GeometryValidate.cc.

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

Referenced by compareTransform().

266  {
267  return sqrt((p1.x() - p2.x()) * (p1.x() - p2.x()) + (p1.y() - p2.y()) * (p1.y() - p2.y()) +
268  (p1.z() - p2.z()) * (p1.z() - p2.z()));
269 }
T sqrt(T t)
Definition: SSEVec.h:19

◆ makeHistogram()

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

Definition at line 314 of file ME0GeometryValidate.cc.

References data, mps_fire::end, compareTotals::hist, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, HLT_2023v12_cff::maxE, and Skims_PA_cff::name.

Referenced by makeHistograms(), and makeHistograms2().

314  {
315  if (data.empty())
316  return;
317 
318  const auto [minE, maxE] = minmax_element(begin(data), end(data));
319 
320  TH1D hist(name.c_str(), name.c_str(), 100, *minE * (1 + 0.10), *maxE * (1 + 0.10));
321 
322  for (auto const& it : data)
323  hist.Fill(it);
324 
325  hist.GetXaxis()->SetTitle("[cm]");
326  hist.Write();
327 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ makeHistograms()

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

Definition at line 278 of file ME0GeometryValidate.cc.

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

Referenced by validateME0ChamberGeometry(), and validateME0EtaPartitionGeometry2().

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

◆ makeHistograms2()

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

Definition at line 299 of file ME0GeometryValidate.cc.

References ztail::d, hgcalTestNeighbor_cfi::detector, makeHistogram(), nstrips_, outFile_, pi, pitch_, and stripslen_.

Referenced by validateME0EtaPartitionGeometry().

299  {
300  outFile_->cd();
301 
302  string d(detector);
303 
304  string ns = d + ": absolute difference between nStrips";
305  makeHistogram(ns, nstrips_);
306 
307  string pi = d + ": absolute difference between Strips Pitch";
309 
310  string pl = d + ": absolute difference between Strips Length";
312 }
const Double_t pi
vector< float > nstrips_
d
Definition: ztail.py:151
vector< float > stripslen_
void makeHistogram(const string &, vector< float > &)

◆ validateME0ChamberGeometry()

void ME0GeometryValidate::validateME0ChamberGeometry ( )
private

Definition at line 121 of file ME0GeometryValidate.cc.

References ME0Geometry::chambers(), clearData(), compareShape(), compareTransform(), fwGeometry_, FWGeometry::getMatrix(), FWGeometry::getShapePars(), runTauDisplay::gp, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogTrace, makeHistograms(), makeMuonMisalignmentScenario::matrix, me0Geometry_, DetId::rawId(), and l1trig_cff::shape.

Referenced by analyze().

121  {
122  clearData();
123 
124  for (auto const& it : me0Geometry_->chambers()) {
125  ME0DetId chId = it->id();
126  GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0));
127  const TGeoMatrix* matrix = fwGeometry_.getMatrix(chId.rawId());
128 
129  if (!matrix) {
130  LogTrace("ME0Geometry") << "Failed to get matrix of ME0 chamber with detid: " << chId.rawId();
131  continue;
132  }
134 
135  auto const& shape = fwGeometry_.getShapePars(chId.rawId());
136 
137  if (!shape) {
138  LogTrace("ME0Geometry") << "Failed to get shape of ME0 chamber with detid: " << chId.rawId();
139  continue;
140  }
142  }
143  makeHistograms("ME0 Chamber");
144 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
#define LogTrace(id)
const std::vector< const ME0Chamber * > & chambers() const
Return a vector of all ME0 chambers.
Definition: ME0Geometry.cc:29
const ME0Geometry * me0Geometry_
void compareShape(const GeomDet *, const float *)
void compareTransform(const GlobalPoint &, const TGeoMatrix *)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:461
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:225
void makeHistograms(const char *)

◆ validateME0EtaPartitionGeometry()

void ME0GeometryValidate::validateME0EtaPartitionGeometry ( )
private

Definition at line 171 of file ME0GeometryValidate.cc.

References funct::abs(), clearData2(), MillePedeFileConverter_cfg::e, ME0Geometry::etaPartitions(), f, fwGeometry_, FWGeometry::getParameters(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, makeHistograms2(), me0Geometry_, nstrips_, pitch_, DetId::rawId(), StripTopology::stripLength(), and stripslen_.

Referenced by analyze().

171  {
172  clearData2();
173 
174  for (auto const& it : me0Geometry_->etaPartitions()) {
175  ME0DetId chId = it->id();
176  const int n_strips = it->nstrips();
177  const float n_pitch = it->pitch();
178  const StripTopology& topo = it->specificTopology();
179  const float stripLen = topo.stripLength();
180  const float* parameters = fwGeometry_.getParameters(chId.rawId());
181  nstrips_.push_back(std::abs(n_strips - parameters[0]));
182 
183  if (n_strips) {
184  for (int istrips = 1; istrips <= n_strips; istrips++) {
185  if (std::abs(n_pitch - parameters[2]) < 1.0e-05)
186  pitch_.push_back(0.0f);
187  else
188  pitch_.push_back(std::abs(n_pitch - parameters[2]));
189  if (std::abs(stripLen - parameters[1]) < 1.0e-05)
190  pitch_.push_back(0.0f);
191  else
192  stripslen_.push_back(std::abs(stripLen - parameters[1]));
193  }
194  } else {
195  LogWarning("ME0Geometry") << "ATTENTION! nStrips == 0";
196  }
197  }
198  makeHistograms2("ME0 Eta Partition");
199 }
vector< float > nstrips_
virtual float stripLength() const =0
const ME0Geometry * me0Geometry_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
void makeHistograms2(const char *)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:450
vector< float > stripslen_
Log< level::Warning, false > LogWarning
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
Definition: ME0Geometry.cc:33

◆ validateME0EtaPartitionGeometry2()

void ME0GeometryValidate::validateME0EtaPartitionGeometry2 ( )
private

Definition at line 146 of file ME0GeometryValidate.cc.

References clearData(), compareShape(), compareTransform(), ME0Geometry::etaPartitions(), fwGeometry_, FWGeometry::getMatrix(), FWGeometry::getShapePars(), runTauDisplay::gp, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogTrace, makeHistograms(), makeMuonMisalignmentScenario::matrix, me0Geometry_, DetId::rawId(), and l1trig_cff::shape.

Referenced by analyze().

146  {
147  clearData();
148 
149  for (auto const& it : me0Geometry_->etaPartitions()) {
150  ME0DetId chId = it->id();
151  GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0));
152  const TGeoMatrix* matrix = fwGeometry_.getMatrix(chId.rawId());
153 
154  if (!matrix) {
155  LogTrace("ME0Geometry") << "Failed to get matrix of ME0 eta partition 2 with detid: " << chId.rawId();
156  continue;
157  }
159 
160  auto const& shape = fwGeometry_.getShapePars(chId.rawId());
161 
162  if (!shape) {
163  LogTrace("ME0Geometry") << "Failed to get shape of ME0 eta partition 2 with detid: " << chId.rawId();
164  continue;
165  }
167  }
168  makeHistograms("ME0 Eta Partition");
169 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
#define LogTrace(id)
const ME0Geometry * me0Geometry_
void compareShape(const GeomDet *, const float *)
void compareTransform(const GlobalPoint &, const TGeoMatrix *)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:461
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:225
void makeHistograms(const char *)
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
Definition: ME0Geometry.cc:33

Member Data Documentation

◆ bottomWidths_

vector<float> ME0GeometryValidate::bottomWidths_
private

Definition at line 93 of file ME0GeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

◆ fwGeometry_

FWGeometry ME0GeometryValidate::fwGeometry_
private

◆ globalDistances_

vector<float> ME0GeometryValidate::globalDistances_
private

Definition at line 91 of file ME0GeometryValidate.cc.

Referenced by compareTransform(), and makeHistograms().

◆ infileName_

string ME0GeometryValidate::infileName_
private

Definition at line 99 of file ME0GeometryValidate.cc.

◆ lengths_

vector<float> ME0GeometryValidate::lengths_
private

Definition at line 94 of file ME0GeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

◆ me0Geometry_

const ME0Geometry* ME0GeometryValidate::me0Geometry_
private

◆ nstrips_

vector<float> ME0GeometryValidate::nstrips_
private

Definition at line 96 of file ME0GeometryValidate.cc.

Referenced by makeHistograms2(), and validateME0EtaPartitionGeometry().

◆ outFile_

TFile* ME0GeometryValidate::outFile_
private

Definition at line 90 of file ME0GeometryValidate.cc.

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

◆ outfileName_

string ME0GeometryValidate::outfileName_
private

Definition at line 100 of file ME0GeometryValidate.cc.

Referenced by endJob().

◆ pitch_

vector<float> ME0GeometryValidate::pitch_
private

Definition at line 97 of file ME0GeometryValidate.cc.

Referenced by makeHistograms2(), and validateME0EtaPartitionGeometry().

◆ stripslen_

vector<float> ME0GeometryValidate::stripslen_
private

Definition at line 98 of file ME0GeometryValidate.cc.

Referenced by makeHistograms2(), and validateME0EtaPartitionGeometry().

◆ thicknesses_

vector<float> ME0GeometryValidate::thicknesses_
private

Definition at line 95 of file ME0GeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

◆ tokGeom_

const edm::ESGetToken<ME0Geometry, MuonGeometryRecord> ME0GeometryValidate::tokGeom_
private

Definition at line 87 of file ME0GeometryValidate.cc.

Referenced by analyze().

◆ tolerance_

int ME0GeometryValidate::tolerance_
private

Definition at line 101 of file ME0GeometryValidate.cc.

Referenced by getDiff().

◆ topWidths_

vector<float> ME0GeometryValidate::topWidths_
private

Definition at line 92 of file ME0GeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().