CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
GEMGeometryValidate Class Reference
Inheritance diagram for GEMGeometryValidate:

Public Member Functions

 GEMGeometryValidate (const ParameterSet &)
 
 ~GEMGeometryValidate () 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 validateGEMChamberGeometry ()
 
void validateGEMEtaPartitionGeometry ()
 

Private Attributes

vector< float > bottomWidths_
 
FWGeometry fwGeometry_
 
const GEMGeometrygemGeometry_
 
vector< float > globalDistances_
 
string infileName_
 
vector< float > lengths_
 
vector< float > nstrips_
 
TFile * outFile_
 
string outfileName_
 
vector< float > pitch_
 
vector< float > stripslen_
 
vector< float > thicknesses_
 
const edm::ESGetToken
< GEMGeometry,
MuonGeometryRecord
tokGeom_
 
int tolerance_
 
vector< float > topWidths_
 

Detailed Description

Definition at line 49 of file GEMGeometryValidate.cc.

Constructor & Destructor Documentation

GEMGeometryValidate::GEMGeometryValidate ( const ParameterSet iConfig)
explicit

Definition at line 103 of file GEMGeometryValidate.cc.

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

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

Definition at line 52 of file GEMGeometryValidate.cc.

52 {}

Member Function Documentation

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

Definition at line 112 of file GEMGeometryValidate.cc.

References gemGeometry_, edm::EventSetup::getData(), tokGeom_, validateGEMChamberGeometry(), and validateGEMEtaPartitionGeometry().

112  {
113  gemGeometry_ = &eventSetup.getData(tokGeom_);
114 
115  LogVerbatim("GEMGeometry") << "Validating GEM chamber geometry";
116 
118 
120 }
Log< level::Info, true > LogVerbatim
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > tokGeom_
const GEMGeometry * gemGeometry_
void GEMGeometryValidate::beginJob ( void  )
overrideprivate

Definition at line 299 of file GEMGeometryValidate.cc.

References outFile_.

299 { outFile_->cd(); }
void GEMGeometryValidate::clearData ( )
inlineprivate

Definition at line 72 of file GEMGeometryValidate.cc.

Referenced by validateGEMChamberGeometry().

72  {
73  globalDistances_.clear();
74  topWidths_.clear();
75  bottomWidths_.clear();
76  lengths_.clear();
77  thicknesses_.clear();
78  }
vector< float > lengths_
vector< float > topWidths_
vector< float > bottomWidths_
vector< float > thicknesses_
vector< float > globalDistances_
void GEMGeometryValidate::clearData2 ( )
inlineprivate

Definition at line 80 of file GEMGeometryValidate.cc.

Referenced by validateGEMEtaPartitionGeometry().

80  {
81  nstrips_.clear();
82  pitch_.clear();
83  stripslen_.clear();
84  }
vector< float > stripslen_
vector< float > nstrips_
void GEMGeometryValidate::compareShape ( const GeomDet det,
const float *  shape 
)
private

Definition at line 185 of file GEMGeometryValidate.cc.

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

Referenced by validateGEMChamberGeometry().

185  {
186  float shapeTopWidth;
187  float shapeBottomWidth;
188  float shapeLength;
189  float shapeThickness;
190 
191  if (shape[0] == 1) {
192  shapeTopWidth = shape[2];
193  shapeBottomWidth = shape[1];
194  shapeLength = shape[4];
195  shapeThickness = shape[3];
196  } else if (shape[0] == 2) {
197  shapeTopWidth = shape[1];
198  shapeBottomWidth = shape[1];
199  shapeLength = shape[2];
200  shapeThickness = shape[3];
201  } else {
202  LogVerbatim("GEMGeometry") << "Failed to get box or trapezoid from shape";
203 
204  return;
205  }
206 
207  float topWidth, bottomWidth;
208  float length, thickness;
209 
210  const Bounds* bounds = &(det->surface().bounds());
211  if (const TrapezoidalPlaneBounds* tpbs = dynamic_cast<const TrapezoidalPlaneBounds*>(bounds)) {
212  array<const float, 4> const& ps = tpbs->parameters();
213 
214  assert(ps.size() == 4);
215 
216  bottomWidth = ps[0];
217  topWidth = ps[1];
218  thickness = ps[2];
219  length = ps[3];
220  } else if ((dynamic_cast<const RectangularPlaneBounds*>(bounds))) {
221  length = det->surface().bounds().length() * 0.5;
222  topWidth = det->surface().bounds().width() * 0.5;
223  bottomWidth = topWidth;
224  thickness = det->surface().bounds().thickness() * 0.5;
225  } else {
226  LogVerbatim("GEMGeometry") << "Failed to get bounds";
227 
228  return;
229  }
230  topWidths_.push_back(fabs(shapeTopWidth - topWidth));
231  bottomWidths_.push_back(fabs(shapeBottomWidth - bottomWidth));
232  lengths_.push_back(fabs(shapeLength - length));
233  thicknesses_.push_back(fabs(shapeThickness - thickness));
234 }
Log< level::Info, true > LogVerbatim
virtual float length() const =0
vector< float > lengths_
vector< float > topWidths_
const Bounds & bounds() const
Definition: Surface.h:87
assert(be >=bs)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
virtual float thickness() const =0
vector< float > bottomWidths_
vector< float > thicknesses_
Definition: Bounds.h:18
virtual float width() const =0
void GEMGeometryValidate::compareTransform ( const GlobalPoint gp,
const TGeoMatrix *  matrix 
)
private

Definition at line 173 of file GEMGeometryValidate.cc.

References funct::abs(), HLT_FULL_cff::distance, alignCSCRings::e, getDistance(), and globalDistances_.

Referenced by validateGEMChamberGeometry().

173  {
174  double local[3] = {0.0, 0.0, 0.0};
175  double global[3];
176 
177  matrix->LocalToMaster(local, global);
178 
179  float distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp);
180  if (abs(distance) < 1.0e-7)
181  distance = 0.0; // set a tollerance for the distance inside Histos
182  globalDistances_.push_back(distance);
183 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
float getDistance(const GlobalPoint &, const GlobalPoint &)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
vector< float > globalDistances_
void GEMGeometryValidate::endJob ( void  )
overrideprivate

Definition at line 301 of file GEMGeometryValidate.cc.

References outFile_, and outfileName_.

301  {
302  LogVerbatim("GEMGeometry") << "Done.";
303  LogVerbatim("GEMGeometry") << "Results written to " << outfileName_;
304  outFile_->Close();
305 }
Log< level::Info, true > LogVerbatim
float GEMGeometryValidate::getDiff ( const float  val1,
const float  val2 
)
private

Definition at line 241 of file GEMGeometryValidate.cc.

References almost_equal(), and tolerance_.

241  {
242  if (almost_equal(val1, val2, tolerance_))
243  return 0.0f;
244  else
245  return (val1 - val2);
246 }
enable_if<!numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp)
float GEMGeometryValidate::getDistance ( const GlobalPoint p1,
const GlobalPoint p2 
)
private

Definition at line 236 of file GEMGeometryValidate.cc.

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

Referenced by compareTransform().

236  {
237  return sqrt((p1.x() - p2.x()) * (p1.x() - p2.x()) + (p1.y() - p2.y()) * (p1.y() - p2.y()) +
238  (p1.z() - p2.z()) * (p1.z() - p2.z()));
239 }
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 GEMGeometryValidate::makeHistogram ( const string &  name,
vector< float > &  data 
)
private

Definition at line 284 of file GEMGeometryValidate.cc.

References SplitLinear::begin, dataset::end, and gpuVertexFinder::hist.

Referenced by makeHistograms(), and makeHistograms2().

284  {
285  if (data.empty())
286  return;
287 
288  const auto [minE, maxE] = minmax_element(begin(data), end(data));
289 
290  TH1D hist(name.c_str(), name.c_str(), 100, *minE * (1 + 0.10), *maxE * (1 + 0.10));
291 
292  for (auto const& it : data)
293  hist.Fill(it);
294 
295  hist.GetXaxis()->SetTitle("[cm]");
296  hist.Write();
297 }
__shared__ Hist hist
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
string end
Definition: dataset.py:937
void GEMGeometryValidate::makeHistograms ( const char *  detector)
private

Definition at line 248 of file GEMGeometryValidate.cc.

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

Referenced by validateGEMChamberGeometry().

248  {
249  outFile_->cd();
250 
251  string d(detector);
252 
253  string gdn = d + ": distance between points in global coordinates";
255 
256  string twn = d + ": absolute difference between top widths (along X)";
258 
259  string bwn = d + ": absolute difference between bottom widths (along X)";
261 
262  string ln = d + ": absolute difference between lengths (along Y)";
263  makeHistogram(ln, lengths_);
264 
265  string tn = d + ": absolute difference between thicknesses (along Z)";
267 }
vector< float > lengths_
vector< float > topWidths_
tuple d
Definition: ztail.py:151
void makeHistogram(const string &, vector< float > &)
vector< float > bottomWidths_
vector< float > thicknesses_
vector< float > globalDistances_
void GEMGeometryValidate::makeHistograms2 ( const char *  detector)
private

Definition at line 269 of file GEMGeometryValidate.cc.

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

Referenced by validateGEMEtaPartitionGeometry().

269  {
270  outFile_->cd();
271 
272  string d(detector);
273 
274  string ns = d + ": absolute difference between nStrips";
275  makeHistogram(ns, nstrips_);
276 
277  string pi = d + ": absolute difference between Strips Pitch";
278  makeHistogram(pi, pitch_);
279 
280  string pl = d + ": absolute difference between Strips Length";
282 }
vector< float > stripslen_
const Double_t pi
tuple d
Definition: ztail.py:151
void makeHistogram(const string &, vector< float > &)
vector< float > nstrips_
void GEMGeometryValidate::validateGEMChamberGeometry ( )
private

Definition at line 122 of file GEMGeometryValidate.cc.

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

Referenced by analyze().

122  {
123  clearData();
124 
125  for (auto const& it : gemGeometry_->chambers()) {
126  GEMDetId chId = it->id();
127  GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0));
128 
129  const TGeoMatrix* matrix = fwGeometry_.getMatrix(chId.rawId());
130 
131  if (!matrix) {
132  LogVerbatim("GEMGeometry") << "Failed to get matrix of GEM chamber with detid: " << chId.rawId();
133  continue;
134  }
135  compareTransform(gp, matrix);
136 
137  auto const& shape = fwGeometry_.getShapePars(chId.rawId());
138 
139  if (!shape) {
140  LogVerbatim("GEMGeometry") << "Failed to get shape of GEM chamber with detid: " << chId.rawId();
141  continue;
142  }
143  compareShape(it, shape);
144  }
145  makeHistograms("GEM Chamber");
146 }
Log< level::Info, true > LogVerbatim
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:225
void compareShape(const GeomDet *, const float *)
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:483
const GEMGeometry * gemGeometry_
void makeHistograms(const char *)
void compareTransform(const GlobalPoint &, const TGeoMatrix *)
const std::vector< const GEMChamber * > & chambers() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:38
void GEMGeometryValidate::validateGEMEtaPartitionGeometry ( )
private

Definition at line 148 of file GEMGeometryValidate.cc.

References funct::abs(), clearData2(), GEMGeometry::etaPartitions(), fwGeometry_, gemGeometry_, FWGeometry::getParameters(), makeHistograms2(), nstrips_, pitch_, DetId::rawId(), StripTopology::stripLength(), and stripslen_.

Referenced by analyze().

148  {
149  clearData2();
150 
151  for (auto const& it : gemGeometry_->etaPartitions()) {
152  GEMDetId chId = it->id();
153  const int n_strips = it->nstrips();
154  const float n_pitch = it->pitch();
155  const StripTopology& topo = it->specificTopology();
156  const float stripLen = topo.stripLength();
157  const float* parameters = fwGeometry_.getParameters(chId.rawId());
158  nstrips_.push_back(abs(n_strips - parameters[0]));
159 
160  if (n_strips) {
161  for (int istrips = 1; istrips <= n_strips; istrips++) {
162  pitch_.push_back(fabs(n_pitch - parameters[2]));
163 
164  stripslen_.push_back(fabs(stripLen - parameters[1]));
165  }
166  } else {
167  LogVerbatim("GEMGeometry") << "ATTENTION! nStrips == 0";
168  }
169  }
170  makeHistograms2("GEM Eta Partition");
171 }
Log< level::Info, true > LogVerbatim
vector< float > stripslen_
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:472
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
virtual float stripLength() const =0
const GEMGeometry * gemGeometry_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:40
void makeHistograms2(const char *)
vector< float > nstrips_

Member Data Documentation

vector<float> GEMGeometryValidate::bottomWidths_
private

Definition at line 92 of file GEMGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

FWGeometry GEMGeometryValidate::fwGeometry_
private
const GEMGeometry* GEMGeometryValidate::gemGeometry_
private
vector<float> GEMGeometryValidate::globalDistances_
private

Definition at line 90 of file GEMGeometryValidate.cc.

Referenced by compareTransform(), and makeHistograms().

string GEMGeometryValidate::infileName_
private

Definition at line 98 of file GEMGeometryValidate.cc.

Referenced by GEMGeometryValidate().

vector<float> GEMGeometryValidate::lengths_
private

Definition at line 93 of file GEMGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

vector<float> GEMGeometryValidate::nstrips_
private

Definition at line 95 of file GEMGeometryValidate.cc.

Referenced by makeHistograms2(), and validateGEMEtaPartitionGeometry().

TFile* GEMGeometryValidate::outFile_
private
string GEMGeometryValidate::outfileName_
private

Definition at line 99 of file GEMGeometryValidate.cc.

Referenced by endJob(), and GEMGeometryValidate().

vector<float> GEMGeometryValidate::pitch_
private

Definition at line 96 of file GEMGeometryValidate.cc.

Referenced by makeHistograms2(), and validateGEMEtaPartitionGeometry().

vector<float> GEMGeometryValidate::stripslen_
private

Definition at line 97 of file GEMGeometryValidate.cc.

Referenced by makeHistograms2(), and validateGEMEtaPartitionGeometry().

vector<float> GEMGeometryValidate::thicknesses_
private

Definition at line 94 of file GEMGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> GEMGeometryValidate::tokGeom_
private

Definition at line 86 of file GEMGeometryValidate.cc.

Referenced by analyze().

int GEMGeometryValidate::tolerance_
private

Definition at line 100 of file GEMGeometryValidate.cc.

Referenced by GEMGeometryValidate(), and getDiff().

vector<float> GEMGeometryValidate::topWidths_
private

Definition at line 91 of file GEMGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().