File indexing completed on 2024-04-06 12:32:49
0001 #include "DataFormats/Common/interface/Handle.h"
0002 #include "FWCore/Utilities/interface/InputTag.h"
0003 #include "Geometry/CommonTopologies/interface/StripTopology.h"
0004 #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h"
0005 #include "Validation/MuonGEMDigis/plugins/GEMCheckGeometry.h"
0006
0007 #include <iomanip>
0008
0009 GEMCheckGeometry::GEMCheckGeometry(const edm::ParameterSet &gc) {
0010 GE11PhiBegin_ = gc.getUntrackedParameter<double>("GE11PhiBegin", -5.);
0011 GE11PhiStep_ = gc.getUntrackedParameter<double>("GE11PhiStep", 10);
0012 minPhi_ = gc.getUntrackedParameter<double>("minPhi", -180.);
0013 maxPhi_ = gc.getUntrackedParameter<double>("maxPhi", +180.);
0014 detailPlot_ = gc.getParameter<bool>("detailPlot");
0015 geomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
0016 }
0017
0018 void GEMCheckGeometry::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &Run, edm::EventSetup const &iSetup) {
0019 if (!detailPlot_)
0020 return;
0021
0022 const auto gemH = iSetup.getHandle(geomToken_);
0023 if (!gemH.isValid()) {
0024 edm::LogError("GEMCheckGeometry") << "Failed to initialize GEM geometry.";
0025 return;
0026 }
0027 const GEMGeometry *geometry = gemH.product();
0028
0029 ibooker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask");
0030 LogDebug("GEMCheckGeometry") << "ibooker set current folder\n";
0031
0032 for (auto region : geometry->regions()) {
0033 TString title = TString::Format("Geometry's phi distribution on Region %d ; #phi(degree); ;", region->region());
0034 TString name = TString::Format("geo_phi_r%d", region->region());
0035 auto temp_me = ibooker.book2D(name.Data(), title.Data(), 360000, -180., 180, 12, 1, 13);
0036 temp_me->setBinLabel(1, "St1,La1_even", 2);
0037 temp_me->setBinLabel(2, "St1,La1_odd", 2);
0038 temp_me->setBinLabel(3, "St1,La2_even", 2);
0039 temp_me->setBinLabel(4, "St1,La2_odd", 2);
0040 temp_me->setBinLabel(5, "St2,La1_even", 2);
0041 temp_me->setBinLabel(6, "St2,La1_odd", 2);
0042 temp_me->setBinLabel(7, "St2,La2_even", 2);
0043 temp_me->setBinLabel(8, "St2,La2_odd", 2);
0044 theStdPlots.insert(std::map<UInt_t, MonitorElement *>::value_type(name.Hash(), temp_me));
0045 }
0046
0047 for (auto region : geometry->regions()) {
0048 for (auto station : region->stations()) {
0049 for (auto ring : station->rings()) {
0050 for (auto sch : ring->superChambers()) {
0051 for (auto ch : sch->chambers()) {
0052 for (auto roll : ch->etaPartitions()) {
0053 const StripTopology *topology(&(roll->specificTopology()));
0054 auto parameters(roll->specs()->parameters());
0055 float nStrips(parameters[3]);
0056 for (int strip = 0; strip <= nStrips; strip++) {
0057 LocalPoint lEdge(topology->localPosition(strip));
0058
0059 double phi = roll->toGlobal(lEdge).phi().degrees();
0060
0061 GEMDetId id(roll->id());
0062 int region_idx = id.region();
0063 int station_idx = id.station();
0064 int chamber_idx = id.chamber();
0065 int layer_idx = id.layer();
0066 int value = (station_idx - 1) * 4 + (layer_idx - 1) * 2 + (chamber_idx % 2) + 1;
0067
0068 if (region_idx == 1) {
0069 UInt_t hash = TString("geo_phi_r1").Hash();
0070 theStdPlots[hash]->Fill(phi, value);
0071 } else {
0072 UInt_t hash = TString("geo_phi_r-1").Hash();
0073 theStdPlots[hash]->Fill(phi, value);
0074 }
0075 }
0076 }
0077 }
0078 }
0079 }
0080 }
0081 }
0082 }
0083
0084 GEMCheckGeometry::~GEMCheckGeometry() {}
0085
0086 void GEMCheckGeometry::analyze(const edm::Event &e, const edm::EventSetup &) {}