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
39 
40 //
41 // class decleration
42 //
43 
45 public:
47  ~MuonGeometryDBConverter() override;
48 
50  void beginJob() override {}
51  void endJob() override {}
52 
53 private:
54  void analyze(const edm::Event &, const edm::EventSetup &) override;
55 
56  bool m_done;
58 
62  bool m_getAPEs;
63 
67 
71 
75 
79 
83 
85 };
86 
87 //
88 // constants, enums and typedefs
89 //
90 
91 //
92 // static data member definitions
93 //
94 
95 //
96 // constructors and destructor
97 //
99  : m_done(false),
100  m_input(iConfig.getParameter<std::string>("input")),
101  m_output(iConfig.getParameter<std::string>("output")),
102  m_shiftErr(0.),
103  m_angleErr(0.),
104  m_getAPEs(false),
105  idealGeometryLabelForInputXML("idealForInputXML"),
106  idealGeometryLabel("idealGeometry"),
107  dtGeomIdealToken_(esConsumes(edm::ESInputTag("", idealGeometryLabel))),
108  cscGeomIdealToken_(esConsumes(edm::ESInputTag("", idealGeometryLabel))),
109  gemGeomIdealToken_(esConsumes(edm::ESInputTag("", idealGeometryLabel))),
110  gprToken_(esConsumes<Alignments, GlobalPositionRcd>(edm::ESInputTag("", ""))) {
112  // Version V02-03-02 and earlier of this module had support for //
113  // "cfg" as an input/output format. It turns out that reading //
114  // thousands of parameters from a configuration file takes a very //
115  // long time, so "cfg" wasn't very practical. When I reorganized //
116  // the code, I didn't bother to port it. //
118 
119  if (m_input == std::string("ideal")) {
120  } else if (m_input == std::string("db")) {
121  m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
122  m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
123  m_gemLabel = iConfig.getParameter<std::string>("gemLabel");
124  m_dtAPELabel = iConfig.getParameter<std::string>("dtAPELabel");
125  m_cscAPELabel = iConfig.getParameter<std::string>("cscAPELabel");
126  m_gemAPELabel = iConfig.getParameter<std::string>("gemAPELabel");
127  m_shiftErr = iConfig.getParameter<double>("shiftErr");
128  m_angleErr = iConfig.getParameter<double>("angleErr");
129  m_getAPEs = iConfig.getParameter<bool>("getAPEs");
130  m_outputXML = iConfig.getParameter<edm::ParameterSet>("outputXML");
131 
135 
139 
143  } else if (m_input == std::string("surveydb")) {
144  m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
145  m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
146  m_gemLabel = iConfig.getParameter<std::string>("gemLabel");
147  } else if (m_input == std::string("scenario")) {
148  m_misalignmentScenario = iConfig.getParameter<edm::ParameterSet>("MisalignmentScenario");
149  m_shiftErr = iConfig.getParameter<double>("shiftErr");
150  m_angleErr = iConfig.getParameter<double>("angleErr");
151  } else if (m_input == std::string("xml")) {
152  m_fileName = iConfig.getParameter<std::string>("fileName");
153  m_shiftErr = iConfig.getParameter<double>("shiftErr");
154  m_angleErr = iConfig.getParameter<double>("angleErr");
158  } else {
159  throw cms::Exception("BadConfig") << "input must be \"ideal\", \"db\", \"surveydb\", or \"xml\"." << std::endl;
160  }
161  if (m_output == std::string("none")) {
162  } else if (m_output == std::string("db")) {
163  } else if (m_output == std::string("xml")) {
164  m_outputXML = iConfig.getParameter<edm::ParameterSet>("outputXML");
165  } else {
166  throw cms::Exception("BadConfig") << "output must be \"none\", \"db \", \"xml\"." << std::endl;
167  }
168 }
169 
171 
172 // ------------ method called to for each event ------------
174  if (!m_done) {
175  if (m_input == std::string("ideal")) {
176  MuonAlignmentInputMethod inputMethod(
178  MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod);
179  muonAlignment->fillGapsInSurvey(0., 0.);
180  muonAlignment->saveToDB();
181  } else if (m_input == std::string("db")) {
182  MuonAlignmentInputDB inputMethod(&iSetup.getData(dtGeomIdealToken_),
183  &iSetup.getData(cscGeomIdealToken_),
184  &iSetup.getData(gemGeomIdealToken_),
185  &iSetup.getData(dtAliToken_),
186  &iSetup.getData(cscAliToken_),
187  &iSetup.getData(gemAliToken_),
188  &iSetup.getData(dtAPEToken_),
189  &iSetup.getData(cscAPEToken_),
190  &iSetup.getData(gemAPEToken_),
191  &iSetup.getData(gprToken_));
192  MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod);
193  if (m_getAPEs) {
194  muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr);
195  }
196  muonAlignment->writeXML(
198  } else if (m_input == std::string("scenario")) {
199  MuonAlignmentInputMethod inputMethod(
201  MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod);
202 
203  MuonScenarioBuilder muonScenarioBuilder(muonAlignment->getAlignableMuon());
204  muonScenarioBuilder.applyScenario(m_misalignmentScenario);
205  muonAlignment->saveToDB();
206  muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr);
207  } else if (m_input == std::string("xml")) {
208  MuonAlignmentInputXML inputMethod(m_fileName,
209  &iSetup.getData(dtGeomToken_),
210  &iSetup.getData(cscGeomToken_),
211  &iSetup.getData(gemGeomToken_),
212  &iSetup.getData(dtGeomIdealToken_),
213  &iSetup.getData(cscGeomIdealToken_),
214  &iSetup.getData(gemGeomIdealToken_));
215  MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod);
216  muonAlignment->saveToDB();
217  muonAlignment->fillGapsInSurvey(m_shiftErr, m_angleErr);
218  }
219  m_done = true;
220  } // end if not done
221  else {
222  throw cms::Exception("BadConfig") << "Set maxEvents.input to 1. (Your output is okay.)" << std::endl;
223  }
224 }
225 
226 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
229  desc.setComment("Converts muon geometry between various formats.");
230  desc.add<std::string>("input", "ideal");
231  desc.add<std::string>("dtLabel", "");
232  desc.add<std::string>("cscLabel", "");
233  desc.add<std::string>("gemLabel", "");
234  desc.add<std::string>("dtAPELabel", "");
235  desc.add<std::string>("cscAPELabel", "");
236  desc.add<std::string>("gemAPELabel", "");
237  desc.add<double>("shiftErr", 1000.0);
238  desc.add<double>("angleErr", 6.28);
239  desc.add<bool>("getAPEs", true);
240  desc.add<std::string>("output", "xml");
241  desc.add<std::string>("fileName", "REPLACEME.xml");
243  outputXML.add<std::string>("fileName", "REPLACEME.xml");
244  outputXML.add<std::string>("relativeto", "ideal");
245  outputXML.add<bool>("rawIds", false);
246  outputXML.add<bool>("survey", false);
247  outputXML.add<bool>("eulerAngles", false);
248  outputXML.add<int>("precision", 10);
249  outputXML.addUntracked<bool>("suppressDTBarrel", true);
250  outputXML.addUntracked<bool>("suppressDTWheels", true);
251  outputXML.addUntracked<bool>("suppressDTStations", true);
252  outputXML.addUntracked<bool>("suppressDTChambers", false);
253  outputXML.addUntracked<bool>("suppressDTSuperLayers", false);
254  outputXML.addUntracked<bool>("suppressDTLayers", false);
255  outputXML.addUntracked<bool>("suppressCSCEndcaps", true);
256  outputXML.addUntracked<bool>("suppressCSCStations", true);
257  outputXML.addUntracked<bool>("suppressCSCRings", true);
258  outputXML.addUntracked<bool>("suppressCSCChambers", false);
259  outputXML.addUntracked<bool>("suppressCSCLayers", false);
260  outputXML.addUntracked<bool>("suppressGEMEndcaps", true);
261  outputXML.addUntracked<bool>("suppressGEMStations", true);
262  outputXML.addUntracked<bool>("suppressGEMRings", true);
263  outputXML.addUntracked<bool>("suppressGEMSuperChambers", false);
264  outputXML.addUntracked<bool>("suppressGEMChambers", true);
265  outputXML.addUntracked<bool>("suppressGEMEtaPartitions", true);
266  desc.add("outputXML", outputXML);
267  descriptions.add("muonGeometryDBConverter", desc);
268 }
269 
270 //define this as a plug-in
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
Builds a scenario from configuration and applies it to the alignable Muon.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomIdealToken_
edm::ESGetToken< Alignments, DTAlignmentRcd > dtAliToken_
const std::string idealGeometryLabel
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomToken_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
MuonGeometryDBConverter(const edm::ParameterSet &)
edm::ESGetToken< AlignmentErrorsExtended, GEMAlignmentErrorExtendedRcd > gemAPEToken_
int iEvent
Definition: GenABIO.cc:224
const std::string idealGeometryLabelForInputXML
const edm::ESGetToken< GEMGeometry, MuonGeometryRecord > gemGeomIdealToken_
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESGetToken< AlignmentErrorsExtended, CSCAlignmentErrorExtendedRcd > cscAPEToken_
edm::ESGetToken< Alignments, CSCAlignmentRcd > cscAliToken_
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > cscGeomIdealToken_
edm::ESGetToken< AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd > dtAPEToken_
static void fillDescriptions(edm::ConfigurationDescriptions &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
void applyScenario(const edm::ParameterSet &scenario) override
Apply misalignment scenario to the Muon.
edm::ESGetToken< Alignments, GEMAlignmentRcd > gemAliToken_
edm::ParameterSet m_misalignmentScenario
void analyze(const edm::Event &, const edm::EventSetup &) override
const edm::ESGetToken< Alignments, GlobalPositionRcd > gprToken_