CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonGeometrySVGTemplate.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MuonGeometrySVGTemplate
4 // Class: MuonGeometrySVGTemplate
5 //
13 //
14 // Original Author: Jim Pivarski
15 // Created: Wed Jul 14 18:31:18 CDT 2010
16 //
17 //
18 
19 
20 // system include files
21 #include <fstream>
22 
32 
42 
43 //
44 // class decleration
45 //
46 
48  public:
49  explicit MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig);
51 
52  private:
53  virtual void analyze(const edm::Event&, const edm::EventSetup &iConfig) override;
54 
56 // std::string m_disk1TemplateName;
57 // std::string m_disk23TemplateName;
58 // std::string m_diskp4TemplateName;
59 // std::string m_diskm4TemplateName;
60 };
61 
62 //
63 // constants, enums and typedefs
64 //
65 
66 //
67 // static data member definitions
68 //
69 
70 //
71 // constructors and destructor
72 //
73 
75  : m_wheelTemplateName(iConfig.getParameter<std::string>("wheelTemplateName"))
76 {}
77 
79 
80 // ------------ method called to for each event ------------
81 void
83  // loads ideal geometry
84  MuonAlignmentInputMethod inputMethod;
85  MuonAlignment muonAlignment(iSetup, inputMethod);
86  AlignableNavigator *alignableNavigator = muonAlignment.getAlignableNavigator();
87 
88  edm::FileInPath fip_BEGINNING("Alignment/MuonAlignment/data/wheel_template.svg_BEGINNING");
89  std::ifstream in_BEGINNING(fip_BEGINNING.fullPath().c_str());
90  edm::FileInPath fip_END("Alignment/MuonAlignment/data/wheel_template.svg_END");
91  std::ifstream in_END(fip_END.fullPath().c_str());
92 
93  const double height = 45.; // assume all chambers are 45 cm tall (local z)
94  std::ofstream out(m_wheelTemplateName.c_str());
95 
96  while (in_BEGINNING.good()) {
97  char c = (char) in_BEGINNING.get();
98  if (in_BEGINNING.good()) out << c;
99  }
100 
101  for (int station = 1; station <= 4; station++) {
102  int numSectors = 12;
103  if (station == 4) numSectors = 14;
104  for (int sector = 1; sector <= numSectors; sector++) {
105  DTChamberId id(-2, station, sector); // wheel -2 has a +1 signConvention for x
106  Alignable *chamber = &*(alignableNavigator->alignableFromDetId(id));
107 
108  // different stations, sectors have different widths (*very* fortunate that Alignment software provides this)
109  double width = chamber->surface().width();
110 
111  // lower-left corner of chamber in the chamber's coordinates
112  double x = -width/2.;
113  double y = -height/2.;
114 
115  // phi position of chamber
116  align::GlobalVector direction = chamber->surface().toGlobal(LocalVector(1., 0., 0.));
117  double phi = atan2(direction.y(), direction.x());
118 
119  // we'll apply a translation to put the chamber in its place
120  double tx = chamber->surface().position().x();
121  double ty = chamber->surface().position().y();
122 
123  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;
124  }
125  }
126 
127  while (in_END.good()) {
128  char c = (char) in_END.get();
129  if (in_END.good()) out << c;
130  }
131 }
132 
133 //define this as a plug-in
align::Scalar width() const
Local3DVector LocalVector
Definition: LocalVector.h:12
MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
AlignableNavigator * getAlignableNavigator()
Definition: MuonAlignment.h:32
T y() const
Definition: PV3DBase.h:63
int iEvent
Definition: GenABIO.cc:230
#define M_PI
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
tuple out
Definition: dbtoconf.py:99
virtual void analyze(const edm::Event &, const edm::EventSetup &iConfig) override
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
std::string fullPath() const
Definition: FileInPath.cc:165
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.