CMS 3D CMS Logo

MuonGeometryDBConverter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MuonGeometryDBConverter
4 // Class: MuonGeometryDBConverter
5 //
13 //
14 // Original Author: Jim Pivarski
15 // Created: Sat Feb 16 00:04:55 CST 2008
16 // $Id: MuonGeometryDBConverter.cc,v 1.15 2011/09/15 09:12:01 mussgill Exp $
17 //
18 //
19 
20 
21 // system include files
30 
31 // user include files
38 
39 //
40 // class decleration
41 //
42 
44  public:
46  ~MuonGeometryDBConverter() override;
47 
49  void beginJob() override {};
50  void endJob() override {};
51 
52  private:
53  void analyze(const edm::Event&, const edm::EventSetup&) override;
54 
55  bool m_done;
57 
61  bool m_getAPEs;
62 
65 };
66 
67 //
68 // constants, enums and typedefs
69 //
70 
71 //
72 // static data member definitions
73 //
74 
75 //
76 // constructors and destructor
77 //
79  : m_done(false)
80  , m_input(iConfig.getParameter<std::string>("input"))
81  , m_output(iConfig.getParameter<std::string>("output"))
82  , m_shiftErr(0.)
83  , m_angleErr(0.)
84  , m_getAPEs(false)
85 {
87  // Version V02-03-02 and earlier of this module had support for //
88  // "cfg" as an input/output format. It turns out that reading //
89  // thousands of parameters from a configuration file takes a very //
90  // long time, so "cfg" wasn't very practical. When I reorganized //
91  // the code, I didn't bother to port it. //
93 
94  if (m_input == std::string("ideal")) {}
95 
96  else if (m_input == std::string("db")) {
97  m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
98  m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
99  m_shiftErr = iConfig.getParameter<double>("shiftErr");
100  m_angleErr = iConfig.getParameter<double>("angleErr");
101  m_getAPEs = iConfig.getParameter<bool>("getAPEs");
102  }
103 
104  else if (m_input == std::string("surveydb")) {
105  m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
106  m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
107  }
108 
109  else if (m_input == std::string("scenario")) {
110  m_misalignmentScenario = iConfig.getParameter<edm::ParameterSet>("MisalignmentScenario");
111  m_shiftErr = iConfig.getParameter<double>("shiftErr");
112  m_angleErr = iConfig.getParameter<double>("angleErr");
113  }
114 
115  else if (m_input == std::string("xml")) {
116  m_fileName = iConfig.getParameter<std::string>("fileName");
117  m_shiftErr = iConfig.getParameter<double>("shiftErr");
118  m_angleErr = iConfig.getParameter<double>("angleErr");
119  }
120 
121  else {
122  throw cms::Exception("BadConfig") << "input must be \"ideal\", \"db\", \"surveydb\", or \"xml\"." << std::endl;
123  }
124 
125  if (m_output == std::string("none")) {}
126 
127  else if (m_output == std::string("db")) {}
128 
129  else if (m_output == std::string("surveydb")) {}
130 
131  else if (m_output == std::string("xml")) {
132  m_outputXML = iConfig.getParameter<edm::ParameterSet>("outputXML");
133  }
134 
135  else {
136  throw cms::Exception("BadConfig") << "output must be \"none\", \"db\", or \"surveydb\"." << std::endl;
137  }
138 }
139 
141 
142 // ------------ method called to for each event ------------
143 void
145  if (!m_done) {
146  MuonAlignment *muonAlignment = nullptr;
147 
148  if (m_input == std::string("ideal")) {
149  MuonAlignmentInputMethod inputMethod;
150  muonAlignment = new MuonAlignment(iSetup, inputMethod);
151  muonAlignment->fillGapsInSurvey(0., 0.);
152  }
153 
154  else if (m_input == std::string("db")) {
156  muonAlignment = new MuonAlignment(iSetup, inputMethod);
157  if (m_getAPEs) {
159  }
160  }
161 
162  else if (m_input == std::string("surveydb")) {
164  muonAlignment = new MuonAlignment(iSetup, inputMethod);
165  muonAlignment->copySurveyToAlignment();
166  }
167 
168  else if (m_input == std::string("scenario")) {
169  MuonAlignmentInputMethod inputMethod;
170  muonAlignment = new MuonAlignment(iSetup, inputMethod);
171 
172  MuonScenarioBuilder muonScenarioBuilder(muonAlignment->getAlignableMuon());
173  muonScenarioBuilder.applyScenario(m_misalignmentScenario);
175  }
176 
177  else if (m_input == std::string("xml")) {
178  MuonAlignmentInputXML inputMethod(m_fileName);
179  muonAlignment = new MuonAlignment(iSetup, inputMethod);
180  muonAlignment->fillGapsInSurvey(m_shiftErr, m_angleErr);
181  }
182 
184 
185  if (muonAlignment) {
186 
187  if (m_output == std::string("none")) {}
188 
189  else if (m_output == std::string("db")) {
190  muonAlignment->saveToDB();
191  }
192 
193  else if (m_output == std::string("surveydb")) {
194  muonAlignment->saveSurveyToDB();
195  }
196 
197  else if (m_output == std::string("xml")) {
198  muonAlignment->writeXML(m_outputXML, iSetup);
199  }
200 
201  delete muonAlignment;
202 
203  }
204 
205  m_done = true;
206  } // end if not done
207  else {
208  throw cms::Exception("BadConfig") << "Set maxEvents.input to 1. (Your output is okay.)" << std::endl;
209  }
210 }
211 
212 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
213 void
215 {
217  desc.setComment("Converts muon geometry between various formats.");
218  desc.add<std::string>("input", "ideal");
219  desc.add<std::string>("dtLabel", "");
220  desc.add<std::string>("cscLabel", "");
221  desc.add<double>("shiftErr", 1000.0);
222  desc.add<double>("angleErr", 6.28);
223  desc.add<bool>("getAPEs", true);
224  desc.add<std::string>("output", "xml");
225  desc.add<std::string>("fileName", "REPLACEME.xml");
227  outputXML.add<std::string>("fileName", "REPLACEME.xml");
228  outputXML.add<std::string>("relativeto", "ideal");
229  outputXML.add<bool>("survey", false);
230  outputXML.add<bool>("rawIds", false);
231  outputXML.add<bool>("eulerAngles", false);
232  outputXML.add<int>("precision", 10);
233  outputXML.addUntracked<bool>("suppressDTBarrel", true);
234  outputXML.addUntracked<bool>("suppressDTWheels", true);
235  outputXML.addUntracked<bool>("suppressDTStations", true);
236  outputXML.addUntracked<bool>("suppressDTChambers", false);
237  outputXML.addUntracked<bool>("suppressDTSuperLayers", false);
238  outputXML.addUntracked<bool>("suppressDTLayers", false);
239  outputXML.addUntracked<bool>("suppressCSCEndcaps", true);
240  outputXML.addUntracked<bool>("suppressCSCStations", true);
241  outputXML.addUntracked<bool>("suppressCSCRings", true);
242  outputXML.addUntracked<bool>("suppressCSCChambers", false);
243  outputXML.addUntracked<bool>("suppressCSCLayers", false);
244  desc.add("outputXML", outputXML);
245  descriptions.add("muonGeometryDBConverter", desc);
246 }
247 
248 //define this as a plug-in
T getParameter(std::string const &) const
Builds a scenario from configuration and applies it to the alignable Muon.
void copyAlignmentToSurvey(double shiftErr, double angleErr)
void copySurveyToAlignment()
MuonGeometryDBConverter(const edm::ParameterSet &)
void setComment(std::string const &value)
void saveSurveyToDB()
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
AlignableMuon * getAlignableMuon()
Definition: MuonAlignment.h:30
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void fillGapsInSurvey(double shiftErr, double angleErr)
static void fillDescriptions(edm::ConfigurationDescriptions &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the Muon.
void writeXML(const edm::ParameterSet &iConfig, const edm::EventSetup &iSetup)
edm::ParameterSet m_misalignmentScenario
void analyze(const edm::Event &, const edm::EventSetup &) override