CMS 3D CMS Logo

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

Public Member Functions

 RPCGeometryValidate (const ParameterSet &)
 
 ~RPCGeometryValidate () 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 validateRPCChamberGeometry ()
 
void validateRPCStripsGeometry ()
 

Private Attributes

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

Detailed Description

Definition at line 49 of file RPCGeometryValidate.cc.

Constructor & Destructor Documentation

◆ RPCGeometryValidate()

RPCGeometryValidate::RPCGeometryValidate ( const ParameterSet iConfig)
explicit

Definition at line 103 of file RPCGeometryValidate.cc.

104  : tokRPC_{esConsumes<RPCGeometry, MuonGeometryRecord>(edm::ESInputTag{})},
105  infileName_(iConfig.getUntrackedParameter<string>("infileName", "cmsGeom10.root")),
106  outfileName_(iConfig.getUntrackedParameter<string>("outfileName", "validateRPCGeometry.root")),
107  tolerance_(iConfig.getUntrackedParameter<int>("tolerance", 6)) {
109  outFile_ = new TFile(outfileName_.c_str(), "RECREATE");
110 }
T getUntrackedParameter(std::string const &, T const &) const
void loadMap(const char *fileName)
Definition: FWGeometry.cc:103
const edm::ESGetToken< RPCGeometry, MuonGeometryRecord > tokRPC_

◆ ~RPCGeometryValidate()

RPCGeometryValidate::~RPCGeometryValidate ( )
inlineoverride

Definition at line 52 of file RPCGeometryValidate.cc.

52 {}

Member Function Documentation

◆ analyze()

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

Definition at line 112 of file RPCGeometryValidate.cc.

References options_cfi::eventSetup, rpcGeometry_, tokRPC_, validateRPCChamberGeometry(), and validateRPCStripsGeometry().

112  {
113  rpcGeometry_ = &eventSetup.getData(tokRPC_);
114  LogVerbatim("RPCGeometry") << "Validating RPC chamber geometry";
117 }
Log< level::Info, true > LogVerbatim
const edm::ESGetToken< RPCGeometry, MuonGeometryRecord > tokRPC_
const RPCGeometry * rpcGeometry_

◆ beginJob()

void RPCGeometryValidate::beginJob ( void  )
overrideprivate

Definition at line 295 of file RPCGeometryValidate.cc.

References outFile_.

295 { outFile_->cd(); }

◆ clearData()

void RPCGeometryValidate::clearData ( )
inlineprivate

Definition at line 72 of file RPCGeometryValidate.cc.

Referenced by validateRPCChamberGeometry().

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

◆ clearData2()

void RPCGeometryValidate::clearData2 ( )
inlineprivate

Definition at line 80 of file RPCGeometryValidate.cc.

Referenced by validateRPCStripsGeometry().

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

◆ compareShape()

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

Definition at line 181 of file RPCGeometryValidate.cc.

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

Referenced by validateRPCChamberGeometry().

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

◆ compareTransform()

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

Definition at line 169 of file RPCGeometryValidate.cc.

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

Referenced by validateRPCChamberGeometry().

169  {
170  double local[3] = {0.0, 0.0, 0.0};
171  double global[3];
172 
173  matrix->LocalToMaster(local, global);
174 
175  float distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp);
176  if ((distance >= 0.0) && (distance < 1.0e-7))
177  distance = 0.0; // set a tollerance for the distance inside Histos
178  globalDistances_.push_back(distance);
179 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
float getDistance(const GlobalPoint &, const GlobalPoint &)
vector< float > globalDistances_

◆ endJob()

void RPCGeometryValidate::endJob ( void  )
overrideprivate

Definition at line 297 of file RPCGeometryValidate.cc.

References outFile_, and outfileName_.

297  {
298  LogVerbatim("RPCGeometry") << "Done.";
299  LogVerbatim("RPCGeometry") << "Results written to " << outfileName_;
300  outFile_->Close();
301 }
Log< level::Info, true > LogVerbatim

◆ getDiff()

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

Definition at line 237 of file RPCGeometryValidate.cc.

References almost_equal(), and tolerance_.

237  {
238  if (almost_equal(val1, val2, tolerance_))
239  return 0.0f;
240  else
241  return (val1 - val2);
242 }
enable_if<!numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp)

◆ getDistance()

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

Definition at line 232 of file RPCGeometryValidate.cc.

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

Referenced by compareTransform().

232  {
233  return sqrt((p1.x() - p2.x()) * (p1.x() - p2.x()) + (p1.y() - p2.y()) * (p1.y() - p2.y()) +
234  (p1.z() - p2.z()) * (p1.z() - p2.z()));
235 }
T sqrt(T t)
Definition: SSEVec.h:19

◆ makeHistogram()

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

Definition at line 280 of file RPCGeometryValidate.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().

280  {
281  if (data.empty())
282  return;
283 
284  const auto [minE, maxE] = minmax_element(begin(data), end(data));
285 
286  TH1D hist(name.c_str(), name.c_str(), 100, *minE * (1 + 0.10), *maxE * (1 + 0.10));
287 
288  for (auto const& it : data)
289  hist.Fill(it);
290 
291  hist.GetXaxis()->SetTitle("[cm]");
292  hist.Write();
293 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ makeHistograms()

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

Definition at line 244 of file RPCGeometryValidate.cc.

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

Referenced by validateRPCChamberGeometry().

244  {
245  outFile_->cd();
246 
247  string d(detector);
248 
249  string gdn = d + ": distance between points in global coordinates";
251 
252  string twn = d + ": absolute difference between top widths (along X)";
254 
255  string bwn = d + ": absolute difference between bottom widths (along X)";
257 
258  string ln = d + ": absolute difference between lengths (along Y)";
259  makeHistogram(ln, lengths_);
260 
261  string tn = d + ": absolute difference between thicknesses (along Z)";
263 }
vector< float > bottomWidths_
vector< float > topWidths_
vector< float > thicknesses_
void makeHistogram(const string &, vector< float > &)
d
Definition: ztail.py:151
vector< float > globalDistances_
vector< float > lengths_

◆ makeHistograms2()

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

Definition at line 265 of file RPCGeometryValidate.cc.

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

Referenced by validateRPCStripsGeometry().

265  {
266  outFile_->cd();
267 
268  string d(detector);
269 
270  string ns = d + ": absolute difference between nStrips";
271  makeHistogram(ns, nstrips_);
272 
273  string pi = d + ": absolute difference between Strips Pitch";
275 
276  string pl = d + ": absolute difference between Strips Length";
278 }
vector< float > nstrips_
vector< float > stripslen_
const Double_t pi
void makeHistogram(const string &, vector< float > &)
d
Definition: ztail.py:151

◆ validateRPCChamberGeometry()

void RPCGeometryValidate::validateRPCChamberGeometry ( )
private

Definition at line 119 of file RPCGeometryValidate.cc.

References clearData(), compareShape(), compareTransform(), fwGeometry_, FWGeometry::getMatrix(), FWGeometry::getShapePars(), runTauDisplay::gp, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, makeHistograms(), makeMuonMisalignmentScenario::matrix, DetId::rawId(), RPCGeometry::rolls(), rpcGeometry_, and l1trig_cff::shape.

Referenced by analyze().

119  {
120  clearData();
121 
122  for (auto const& it : rpcGeometry_->rolls()) {
123  RPCDetId chId = it->id();
124  GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0));
125 
126  const TGeoMatrix* matrix = fwGeometry_.getMatrix(chId.rawId());
127 
128  if (!matrix) {
129  LogVerbatim("RPCGeometry") << "Failed to get matrix of RPC chamber with detid: " << chId.rawId();
130  continue;
131  }
133 
134  auto const& shape = fwGeometry_.getShapePars(chId.rawId());
135 
136  if (!shape) {
137  LogVerbatim("RPCGeometry") << "Failed to get shape of RPC chamber with detid: " << chId.rawId();
138  continue;
139  }
141  }
142  makeHistograms("RPC Chamber");
143 }
Log< level::Info, true > LogVerbatim
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
void makeHistograms(const char *)
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 RPCGeometry * rpcGeometry_
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:225
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
Definition: RPCGeometry.cc:44
void compareShape(const GeomDet *, const float *)

◆ validateRPCStripsGeometry()

void RPCGeometryValidate::validateRPCStripsGeometry ( )
private

Definition at line 145 of file RPCGeometryValidate.cc.

References clearData2(), fwGeometry_, FWGeometry::getParameters(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, makeHistograms2(), nstrips_, pitch_, DetId::rawId(), RPCGeometry::rolls(), rpcGeometry_, StripTopology::stripLength(), and stripslen_.

Referenced by analyze().

145  {
146  clearData2();
147 
148  for (auto const& it : rpcGeometry_->rolls()) {
149  RPCDetId chId = it->id();
150  const int n_strips = it->nstrips();
151  const float n_pitch = it->pitch();
152  const StripTopology& topo = it->specificTopology();
153  const float stripLen = topo.stripLength();
154  const float* parameters = fwGeometry_.getParameters(chId.rawId());
155 
156  if (n_strips) {
157  for (int istrips = 1; istrips <= n_strips; istrips++) {
158  nstrips_.push_back(fabs(n_strips - parameters[0]));
159  pitch_.push_back(fabs(n_pitch - parameters[2]));
160  stripslen_.push_back(fabs(stripLen - parameters[1]));
161  }
162  } else {
163  LogVerbatim("RPCGeometry") << "ATTENTION! nStrips == 0";
164  }
165  }
166  makeHistograms2("RPC Strips");
167 }
Log< level::Info, true > LogVerbatim
vector< float > nstrips_
vector< float > stripslen_
virtual float stripLength() const =0
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const RPCGeometry * rpcGeometry_
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:450
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
Definition: RPCGeometry.cc:44
void makeHistograms2(const char *)

Member Data Documentation

◆ bottomWidths_

vector<float> RPCGeometryValidate::bottomWidths_
private

Definition at line 92 of file RPCGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

◆ fwGeometry_

FWGeometry RPCGeometryValidate::fwGeometry_
private

Definition at line 88 of file RPCGeometryValidate.cc.

Referenced by validateRPCChamberGeometry(), and validateRPCStripsGeometry().

◆ globalDistances_

vector<float> RPCGeometryValidate::globalDistances_
private

Definition at line 90 of file RPCGeometryValidate.cc.

Referenced by compareTransform(), and makeHistograms().

◆ infileName_

string RPCGeometryValidate::infileName_
private

Definition at line 98 of file RPCGeometryValidate.cc.

◆ lengths_

vector<float> RPCGeometryValidate::lengths_
private

Definition at line 93 of file RPCGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

◆ nstrips_

vector<float> RPCGeometryValidate::nstrips_
private

Definition at line 95 of file RPCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateRPCStripsGeometry().

◆ outFile_

TFile* RPCGeometryValidate::outFile_
private

Definition at line 89 of file RPCGeometryValidate.cc.

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

◆ outfileName_

string RPCGeometryValidate::outfileName_
private

Definition at line 99 of file RPCGeometryValidate.cc.

Referenced by endJob().

◆ pitch_

vector<float> RPCGeometryValidate::pitch_
private

Definition at line 96 of file RPCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateRPCStripsGeometry().

◆ rpcGeometry_

const RPCGeometry* RPCGeometryValidate::rpcGeometry_
private

◆ stripslen_

vector<float> RPCGeometryValidate::stripslen_
private

Definition at line 97 of file RPCGeometryValidate.cc.

Referenced by makeHistograms2(), and validateRPCStripsGeometry().

◆ thicknesses_

vector<float> RPCGeometryValidate::thicknesses_
private

Definition at line 94 of file RPCGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().

◆ tokRPC_

const edm::ESGetToken<RPCGeometry, MuonGeometryRecord> RPCGeometryValidate::tokRPC_
private

Definition at line 86 of file RPCGeometryValidate.cc.

Referenced by analyze().

◆ tolerance_

int RPCGeometryValidate::tolerance_
private

Definition at line 100 of file RPCGeometryValidate.cc.

Referenced by getDiff().

◆ topWidths_

vector<float> RPCGeometryValidate::topWidths_
private

Definition at line 91 of file RPCGeometryValidate.cc.

Referenced by compareShape(), and makeHistograms().