Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <fstream>
00022
00023 #include "FWCore/Framework/interface/Frameworkfwd.h"
00024 #include "FWCore/Framework/interface/EDAnalyzer.h"
00025 #include "FWCore/Framework/interface/EventSetup.h"
00026 #include "FWCore/Framework/interface/ESHandle.h"
00027 #include "FWCore/Framework/interface/Event.h"
00028 #include "FWCore/Framework/interface/MakerMacros.h"
00029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00030 #include "FWCore/ParameterSet/interface/FileInPath.h"
00031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00032
00033 #include "Alignment/MuonAlignment/interface/MuonAlignment.h"
00034 #include "Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h"
00035 #include "Alignment/CommonAlignment/interface/AlignableNavigator.h"
00036 #include "Alignment/CommonAlignment/interface/Alignable.h"
00037 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00038 #include "DataFormats/DetId/interface/DetId.h"
00039 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
00040 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00041 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00042
00043
00044
00045
00046
00047 class MuonGeometrySVGTemplate : public edm::EDAnalyzer {
00048 public:
00049 explicit MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig);
00050 ~MuonGeometrySVGTemplate();
00051
00052 private:
00053 virtual void analyze(const edm::Event&, const edm::EventSetup &iConfig);
00054
00055 std::string m_wheelTemplateName;
00056
00057
00058
00059
00060 };
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 MuonGeometrySVGTemplate::MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig)
00075 : m_wheelTemplateName(iConfig.getParameter<std::string>("wheelTemplateName"))
00076 {}
00077
00078 MuonGeometrySVGTemplate::~MuonGeometrySVGTemplate() {}
00079
00080
00081 void
00082 MuonGeometrySVGTemplate::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
00083
00084 MuonAlignmentInputMethod inputMethod;
00085 MuonAlignment muonAlignment(iSetup, inputMethod);
00086 AlignableNavigator *alignableNavigator = muonAlignment.getAlignableNavigator();
00087
00088 edm::FileInPath fip_BEGINNING("Alignment/MuonAlignment/data/wheel_template.svg_BEGINNING");
00089 std::ifstream in_BEGINNING(fip_BEGINNING.fullPath().c_str());
00090 edm::FileInPath fip_END("Alignment/MuonAlignment/data/wheel_template.svg_END");
00091 std::ifstream in_END(fip_END.fullPath().c_str());
00092
00093 const double height = 45.;
00094 std::ofstream out(m_wheelTemplateName.c_str());
00095
00096 while (in_BEGINNING.good()) {
00097 char c = (char) in_BEGINNING.get();
00098 if (in_BEGINNING.good()) out << c;
00099 }
00100
00101 for (int station = 1; station <= 4; station++) {
00102 int numSectors = 12;
00103 if (station == 4) numSectors = 14;
00104 for (int sector = 1; sector <= numSectors; sector++) {
00105 DTChamberId id(-2, station, sector);
00106 Alignable *chamber = &*(alignableNavigator->alignableFromDetId(id));
00107
00108
00109 double width = chamber->surface().width();
00110
00111
00112 double x = -width/2.;
00113 double y = -height/2.;
00114
00115
00116 align::GlobalVector direction = chamber->surface().toGlobal(LocalVector(1., 0., 0.));
00117 double phi = atan2(direction.y(), direction.x());
00118
00119
00120 double tx = chamber->surface().position().x();
00121 double ty = chamber->surface().position().y();
00122
00123 out << " <rect id=\"MB_" << station << "_" << sector << "\" x=\"" << x << "\" y=\"" << y << "\" width=\"" << width << "\" height=\"" << height << "\" transform=\"translate(" << tx << ", " << ty << ") rotate(" << phi*180./M_PI << ")\" style=\"fill:#e1e1e1;fill-opacity:1;stroke:#000000;stroke-width:5.0;stroke-dasharray:1, 1;stroke-dashoffset:0\" />" << std::endl;
00124 }
00125 }
00126
00127 while (in_END.good()) {
00128 char c = (char) in_END.get();
00129 if (in_END.good()) out << c;
00130 }
00131 }
00132
00133
00134 DEFINE_FWK_MODULE(MuonGeometrySVGTemplate);