File indexing completed on 2024-04-06 11:56:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <fstream>
0021
0022 #include "FWCore/Framework/interface/Frameworkfwd.h"
0023 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0024 #include "FWCore/Framework/interface/EventSetup.h"
0025 #include "FWCore/Framework/interface/ESHandle.h"
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "FWCore/ParameterSet/interface/FileInPath.h"
0030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0031
0032 #include "Alignment/MuonAlignment/interface/MuonAlignment.h"
0033 #include "Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h"
0034 #include "Alignment/CommonAlignment/interface/AlignableNavigator.h"
0035 #include "Alignment/CommonAlignment/interface/Alignable.h"
0036 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0037 #include "DataFormats/DetId/interface/DetId.h"
0038 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
0039 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0040 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0041
0042
0043
0044
0045
0046 class MuonGeometrySVGTemplate : public edm::one::EDAnalyzer<> {
0047 public:
0048 explicit MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig);
0049 ~MuonGeometrySVGTemplate() override;
0050
0051 private:
0052 void analyze(const edm::Event &, const edm::EventSetup &iConfig) override;
0053
0054 std::string m_wheelTemplateName;
0055
0056
0057
0058
0059 };
0060
0061
0062
0063
0064
0065 MuonGeometrySVGTemplate::MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig)
0066 : m_wheelTemplateName(iConfig.getParameter<std::string>("wheelTemplateName")) {}
0067
0068 MuonGeometrySVGTemplate::~MuonGeometrySVGTemplate() = default;
0069
0070
0071 void MuonGeometrySVGTemplate::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0072
0073 MuonAlignmentInputMethod inputMethod;
0074 MuonAlignment muonAlignment(iSetup, inputMethod);
0075 AlignableNavigator *alignableNavigator = muonAlignment.getAlignableNavigator();
0076
0077 edm::FileInPath fip_BEGINNING("Alignment/MuonAlignment/data/wheel_template.svg_BEGINNING");
0078 std::ifstream in_BEGINNING(fip_BEGINNING.fullPath().c_str());
0079 edm::FileInPath fip_END("Alignment/MuonAlignment/data/wheel_template.svg_END");
0080 std::ifstream in_END(fip_END.fullPath().c_str());
0081
0082 const double height = 45.;
0083 std::ofstream out(m_wheelTemplateName.c_str());
0084
0085 while (in_BEGINNING.good()) {
0086 char c = (char)in_BEGINNING.get();
0087 if (in_BEGINNING.good())
0088 out << c;
0089 }
0090
0091 for (int station = 1; station <= 4; station++) {
0092 int numSectors = 12;
0093 if (station == 4)
0094 numSectors = 14;
0095 for (int sector = 1; sector <= numSectors; sector++) {
0096 DTChamberId id(-2, station, sector);
0097 Alignable *chamber = &*(alignableNavigator->alignableFromDetId(id));
0098
0099
0100 double width = chamber->surface().width();
0101
0102
0103 double x = -width / 2.;
0104 double y = -height / 2.;
0105
0106
0107 align::GlobalVector direction = chamber->surface().toGlobal(LocalVector(1., 0., 0.));
0108 double phi = atan2(direction.y(), direction.x());
0109
0110
0111 double tx = chamber->surface().position().x();
0112 double ty = chamber->surface().position().y();
0113
0114 out << " <rect id=\"MB_" << station << "_" << sector << "\" x=\"" << x << "\" y=\"" << y << "\" width=\""
0115 << width << "\" height=\"" << height << "\" transform=\"translate(" << tx << ", " << ty << ") rotate("
0116 << phi * 180. / M_PI
0117 << ")\" style=\"fill:#e1e1e1;fill-opacity:1;stroke:#000000;stroke-width:5.0;stroke-dasharray:1, "
0118 "1;stroke-dashoffset:0\" />"
0119 << std::endl;
0120 }
0121 }
0122
0123 while (in_END.good()) {
0124 char c = (char)in_END.get();
0125 if (in_END.good())
0126 out << c;
0127 }
0128 }
0129
0130
0131 DEFINE_FWK_MODULE(MuonGeometrySVGTemplate);