CMS 3D CMS Logo

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 // system include files
20 #include <fstream>
21 
31 
41 
42 //
43 // class decleration
44 //
45 
47 public:
48  explicit MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig);
49  ~MuonGeometrySVGTemplate() override;
50 
51 private:
52  void analyze(const edm::Event &, const edm::EventSetup &iConfig) override;
53 
55  // std::string m_disk1TemplateName;
56  // std::string m_disk23TemplateName;
57  // std::string m_diskp4TemplateName;
58  // std::string m_diskm4TemplateName;
59 };
60 
61 //
62 // constants, enums and typedefs
63 //
64 
65 //
66 // static data member definitions
67 //
68 
69 //
70 // constructors and destructor
71 //
72 
74  : m_wheelTemplateName(iConfig.getParameter<std::string>("wheelTemplateName")) {}
75 
77 
78 // ------------ method called to for each event ------------
80  // loads ideal geometry
81  MuonAlignmentInputMethod inputMethod;
82  MuonAlignment muonAlignment(iSetup, inputMethod);
83  AlignableNavigator *alignableNavigator = muonAlignment.getAlignableNavigator();
84 
85  edm::FileInPath fip_BEGINNING("Alignment/MuonAlignment/data/wheel_template.svg_BEGINNING");
86  std::ifstream in_BEGINNING(fip_BEGINNING.fullPath().c_str());
87  edm::FileInPath fip_END("Alignment/MuonAlignment/data/wheel_template.svg_END");
88  std::ifstream in_END(fip_END.fullPath().c_str());
89 
90  const double height = 45.; // assume all chambers are 45 cm tall (local z)
91  std::ofstream out(m_wheelTemplateName.c_str());
92 
93  while (in_BEGINNING.good()) {
94  char c = (char)in_BEGINNING.get();
95  if (in_BEGINNING.good())
96  out << c;
97  }
98 
99  for (int station = 1; station <= 4; station++) {
100  int numSectors = 12;
101  if (station == 4)
102  numSectors = 14;
103  for (int sector = 1; sector <= numSectors; sector++) {
104  DTChamberId id(-2, station, sector); // wheel -2 has a +1 signConvention for x
105  Alignable *chamber = &*(alignableNavigator->alignableFromDetId(id));
106 
107  // different stations, sectors have different widths (*very* fortunate that Alignment software provides this)
108  double width = chamber->surface().width();
109 
110  // lower-left corner of chamber in the chamber's coordinates
111  double x = -width / 2.;
112  double y = -height / 2.;
113 
114  // phi position of chamber
115  align::GlobalVector direction = chamber->surface().toGlobal(LocalVector(1., 0., 0.));
116  double phi = atan2(direction.y(), direction.x());
117 
118  // we'll apply a translation to put the chamber in its place
119  double tx = chamber->surface().position().x();
120  double ty = chamber->surface().position().y();
121 
122  out << " <rect id=\"MB_" << station << "_" << sector << "\" x=\"" << x << "\" y=\"" << y << "\" width=\""
123  << width << "\" height=\"" << height << "\" transform=\"translate(" << tx << ", " << ty << ") rotate("
124  << phi * 180. / M_PI
125  << ")\" style=\"fill:#e1e1e1;fill-opacity:1;stroke:#000000;stroke-width:5.0;stroke-dasharray:1, "
126  "1;stroke-dashoffset:0\" />"
127  << std::endl;
128  }
129  }
130 
131  while (in_END.good()) {
132  char c = (char)in_END.get();
133  if (in_END.good())
134  out << c;
135  }
136 }
137 
138 //define this as a plug-in
Vector3DBase< Scalar, GlobalTag >
DDAxes::y
MuonAlignmentInputMethod.h
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
MessageLogger.h
ESHandle.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
relativeConstraints.station
station
Definition: relativeConstraints.py:67
Alignable
Definition: Alignable.h:27
MuonGeometrySVGTemplate::MuonGeometrySVGTemplate
MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig)
Definition: MuonGeometrySVGTemplate.cc:73
EDAnalyzer.h
DDAxes::x
CSCDetId.h
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
FileInPath.h
MuonAlignment
Definition: MuonAlignment.h:20
edm::FileInPath
Definition: FileInPath.h:64
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
AlignableNavigator.h
DTChamberId.h
AlignableNavigator
Definition: AlignableNavigator.h:25
MuonGeometrySVGTemplate::~MuonGeometrySVGTemplate
~MuonGeometrySVGTemplate() override
Definition: MuonGeometrySVGTemplate.cc:76
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
MuonAlignment.h
MuonGeometrySVGTemplate::analyze
void analyze(const edm::Event &, const edm::EventSetup &iConfig) override
Definition: MuonGeometrySVGTemplate.cc:79
Event.h
MuonGeometrySVGTemplate::m_wheelTemplateName
std::string m_wheelTemplateName
Definition: MuonGeometrySVGTemplate.cc:54
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
LocalVector
Local3DVector LocalVector
Definition: LocalVector.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
MuonGeometrySVGTemplate
Definition: MuonGeometrySVGTemplate.cc:46
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
MuonSubdetId.h
DDAxes::phi
std
Definition: JetResolutionObject.h:76
AlignableNavigator::alignableFromDetId
AlignableDetOrUnitPtr alignableFromDetId(const DetId &detid)
Returns AlignableDetOrUnitPtr corresponding to given DetId.
Definition: AlignableNavigator.cc:91
DetId.h
Frameworkfwd.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
Alignable.h
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
EventSetup.h
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
DTChamberId
Definition: DTChamberId.h:14
ParameterSet.h
edm::Event
Definition: Event.h:73
CSCOverlapsAlignmentAlgorithm_cff.muonAlignment
muonAlignment
Definition: CSCOverlapsAlignmentAlgorithm_cff.py:33
GlobalPoint.h
MuonAlignmentInputMethod
Definition: MuonAlignmentInputMethod.h:34
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163