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 // system include files
29 
30 // user include files
37 
38 //
39 // class decleration
40 //
41 
43 public:
45  ~MuonGeometryDBConverter() override;
46 
48  void beginJob() override{};
49  void endJob() override{};
50 
51 private:
52  void analyze(const edm::Event &, const edm::EventSetup &) override;
53 
54  bool m_done;
56 
60  bool m_getAPEs;
61 
66 };
67 
68 //
69 // constants, enums and typedefs
70 //
71 
72 //
73 // static data member definitions
74 //
75 
76 //
77 // constructors and destructor
78 //
80  : m_done(false),
81  m_input(iConfig.getParameter<std::string>("input")),
82  m_output(iConfig.getParameter<std::string>("output")),
83  m_shiftErr(0.),
84  m_angleErr(0.),
85  m_getAPEs(false),
86  idealGeometryLabelForInputMethod("idealForInputMethod"),
87  idealGeometryLabelForInputDB("idealForInputDB"),
88  idealGeometryLabelForInputXML("idealForInputXML"),
89  idealGeometryLabelForInputSurveyDB("idealForInputSurveyDB") {
91  // Version V02-03-02 and earlier of this module had support for //
92  // "cfg" as an input/output format. It turns out that reading //
93  // thousands of parameters from a configuration file takes a very //
94  // long time, so "cfg" wasn't very practical. When I reorganized //
95  // the code, I didn't bother to port it. //
97 
98  if (m_input == std::string("ideal")) {
99  }
100 
101  else if (m_input == std::string("db")) {
102  m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
103  m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
104  m_shiftErr = iConfig.getParameter<double>("shiftErr");
105  m_angleErr = iConfig.getParameter<double>("angleErr");
106  m_getAPEs = iConfig.getParameter<bool>("getAPEs");
107  }
108 
109  else if (m_input == std::string("surveydb")) {
110  m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
111  m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
112  }
113 
114  else if (m_input == std::string("scenario")) {
115  m_misalignmentScenario = iConfig.getParameter<edm::ParameterSet>("MisalignmentScenario");
116  m_shiftErr = iConfig.getParameter<double>("shiftErr");
117  m_angleErr = iConfig.getParameter<double>("angleErr");
118  }
119 
120  else if (m_input == std::string("xml")) {
121  m_fileName = iConfig.getParameter<std::string>("fileName");
122  m_shiftErr = iConfig.getParameter<double>("shiftErr");
123  m_angleErr = iConfig.getParameter<double>("angleErr");
124  }
125 
126  else {
127  throw cms::Exception("BadConfig") << "input must be \"ideal\", \"db\", \"surveydb\", or \"xml\"." << std::endl;
128  }
129 
130  if (m_output == std::string("none")) {
131  }
132 
133  else if (m_output == std::string("db")) {
134  }
135 
136  else if (m_output == std::string("surveydb")) {
137  }
138 
139  else if (m_output == std::string("xml")) {
140  m_outputXML = iConfig.getParameter<edm::ParameterSet>("outputXML");
141  }
142 
143  else {
144  throw cms::Exception("BadConfig") << "output must be \"none\", \"db\", or \"surveydb\"." << std::endl;
145  }
146 }
147 
149 
150 // ------------ method called to for each event ------------
152  if (!m_done) {
153  MuonAlignment *muonAlignment = nullptr;
154 
155  if (m_input == std::string("ideal")) {
156  MuonAlignmentInputMethod inputMethod;
157  muonAlignment = new MuonAlignment(iSetup, inputMethod);
158  muonAlignment->fillGapsInSurvey(0., 0.);
159  }
160 
161  else if (m_input == std::string("db")) {
163  muonAlignment = new MuonAlignment(iSetup, inputMethod);
164  if (m_getAPEs) {
165  muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr);
166  }
167  }
168 
169  else if (m_input == std::string("surveydb")) {
171  muonAlignment = new MuonAlignment(iSetup, inputMethod);
172  muonAlignment->copySurveyToAlignment();
173  }
174 
175  else if (m_input == std::string("scenario")) {
176  MuonAlignmentInputMethod inputMethod;
177  muonAlignment = new MuonAlignment(iSetup, inputMethod);
178 
179  MuonScenarioBuilder muonScenarioBuilder(muonAlignment->getAlignableMuon());
180  muonScenarioBuilder.applyScenario(m_misalignmentScenario);
181  muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr);
182  }
183 
184  else if (m_input == std::string("xml")) {
186  muonAlignment = new MuonAlignment(iSetup, inputMethod);
187  muonAlignment->fillGapsInSurvey(m_shiftErr, m_angleErr);
188  }
189 
191 
192  if (muonAlignment) {
193  if (m_output == std::string("none")) {
194  }
195 
196  else if (m_output == std::string("db")) {
197  muonAlignment->saveToDB();
198  }
199 
200  else if (m_output == std::string("surveydb")) {
201  muonAlignment->saveSurveyToDB();
202  }
203 
204  else if (m_output == std::string("xml")) {
205  muonAlignment->writeXML(m_outputXML, iSetup);
206  }
207 
208  delete muonAlignment;
209  }
210 
211  m_done = true;
212  } // end if not done
213  else {
214  throw cms::Exception("BadConfig") << "Set maxEvents.input to 1. (Your output is okay.)" << std::endl;
215  }
216 }
217 
218 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
221  desc.setComment("Converts muon geometry between various formats.");
222  desc.add<std::string>("input", "ideal");
223  desc.add<std::string>("dtLabel", "");
224  desc.add<std::string>("cscLabel", "");
225  desc.add<double>("shiftErr", 1000.0);
226  desc.add<double>("angleErr", 6.28);
227  desc.add<bool>("getAPEs", true);
228  desc.add<std::string>("output", "xml");
229  desc.add<std::string>("fileName", "REPLACEME.xml");
231  outputXML.add<std::string>("fileName", "REPLACEME.xml");
232  outputXML.add<std::string>("relativeto", "ideal");
233  outputXML.add<bool>("survey", false);
234  outputXML.add<bool>("rawIds", false);
235  outputXML.add<bool>("eulerAngles", false);
236  outputXML.add<int>("precision", 10);
237  outputXML.addUntracked<bool>("suppressDTBarrel", true);
238  outputXML.addUntracked<bool>("suppressDTWheels", true);
239  outputXML.addUntracked<bool>("suppressDTStations", true);
240  outputXML.addUntracked<bool>("suppressDTChambers", false);
241  outputXML.addUntracked<bool>("suppressDTSuperLayers", false);
242  outputXML.addUntracked<bool>("suppressDTLayers", false);
243  outputXML.addUntracked<bool>("suppressCSCEndcaps", true);
244  outputXML.addUntracked<bool>("suppressCSCStations", true);
245  outputXML.addUntracked<bool>("suppressCSCRings", true);
246  outputXML.addUntracked<bool>("suppressCSCChambers", false);
247  outputXML.addUntracked<bool>("suppressCSCLayers", false);
248  desc.add("outputXML", outputXML);
249  descriptions.add("muonGeometryDBConverter", desc);
250 }
251 
252 //define this as a plug-in
MuonAlignmentInputMethod.h
MuonGeometryDBConverter::m_angleErr
double m_angleErr
Definition: MuonGeometryDBConverter.cc:58
EDAnalyzer.h
MuonAlignmentInputDB.h
MuonGeometryDBConverter::endJob
void endJob() override
Definition: MuonGeometryDBConverter.cc:49
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
ESHandle.h
MuonGeometryDBConverter::m_getAPEs
bool m_getAPEs
Definition: MuonGeometryDBConverter.cc:60
MuonGeometryDBConverter::beginJob
void beginJob() override
Definition: MuonGeometryDBConverter.cc:48
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MuonGeometryDBConverter::m_input
std::string m_input
Definition: MuonGeometryDBConverter.cc:55
MuonAlignmentInputXML
Definition: MuonAlignmentInputXML.h:33
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
MuonGeometryDBConverter::m_output
std::string m_output
Definition: MuonGeometryDBConverter.cc:55
MuonGeometryDBConverter::MuonGeometryDBConverter
MuonGeometryDBConverter(const edm::ParameterSet &)
Definition: MuonGeometryDBConverter.cc:79
MuonGeometryDBConverter::m_cscLabel
std::string m_cscLabel
Definition: MuonGeometryDBConverter.cc:57
MuonScenarioBuilder.h
MuonGeometryDBConverter::idealGeometryLabelForInputMethod
std::string idealGeometryLabelForInputMethod
Definition: MuonGeometryDBConverter.cc:64
MuonAlignment
Definition: MuonAlignment.h:20
MuonGeometryDBConverter::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: MuonGeometryDBConverter.cc:219
MakerMacros.h
MuonScenarioBuilder::applyScenario
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the Muon.
Definition: MuonScenarioBuilder.cc:35
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
MuonGeometryDBConverter::m_dtLabel
std::string m_dtLabel
Definition: MuonGeometryDBConverter.cc:57
MuonAlignmentInputSurveyDB
Definition: MuonAlignmentInputSurveyDB.h:31
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
MuonGeometryDBConverter::m_outputXML
edm::ParameterSet m_outputXML
Definition: MuonGeometryDBConverter.cc:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
MuonAlignmentInputDB
Definition: MuonAlignmentInputDB.h:29
MuonAlignment.h
MuonAlignmentInputSurveyDB.h
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
MuonGeometryDBConverter::idealGeometryLabelForInputDB
std::string idealGeometryLabelForInputDB
Definition: MuonGeometryDBConverter.cc:64
convertSQLitetoXML_cfg.outputXML
outputXML
Definition: convertSQLitetoXML_cfg.py:73
MuonGeometryDBConverter::idealGeometryLabelForInputXML
std::string idealGeometryLabelForInputXML
Definition: MuonGeometryDBConverter.cc:64
MuonAlignmentInputXML.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
Exception
Definition: hltDiff.cc:246
MuonGeometryDBConverter::m_shiftErr
double m_shiftErr
Definition: MuonGeometryDBConverter.cc:58
MuonGeometryDBConverter::m_done
bool m_done
Definition: MuonGeometryDBConverter.cc:54
MuonGeometryDBConverter::m_misalignmentScenario
edm::ParameterSet m_misalignmentScenario
Definition: MuonGeometryDBConverter.cc:62
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MuonGeometryDBConverter
Definition: MuonGeometryDBConverter.cc:42
MuonGeometryDBConverter::~MuonGeometryDBConverter
~MuonGeometryDBConverter() override
Definition: MuonGeometryDBConverter.cc:148
ParameterSet.h
MuonGeometryDBConverter::idealGeometryLabelForInputSurveyDB
std::string idealGeometryLabelForInputSurveyDB
Definition: MuonGeometryDBConverter.cc:64
MuonGeometryDBConverter::m_fileName
std::string m_fileName
Definition: MuonGeometryDBConverter.cc:59
edm::Event
Definition: Event.h:73
CSCOverlapsAlignmentAlgorithm_cff.muonAlignment
muonAlignment
Definition: CSCOverlapsAlignmentAlgorithm_cff.py:33
MuonGeometryDBConverter::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: MuonGeometryDBConverter.cc:151
MuonAlignmentInputMethod
Definition: MuonAlignmentInputMethod.h:34
MuonScenarioBuilder
Builds a scenario from configuration and applies it to the alignable Muon.
Definition: MuonScenarioBuilder.h:19