CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
47 
48 
49  private:
50  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
51 
52  bool m_done;
54 
58  bool m_getAPEs;
59 
62 };
63 
64 //
65 // constants, enums and typedefs
66 //
67 
68 //
69 // static data member definitions
70 //
71 
72 //
73 // constructors and destructor
74 //
76  : m_done(false)
77  , m_input(iConfig.getParameter<std::string>("input"))
78  , m_output(iConfig.getParameter<std::string>("output"))
79  , m_shiftErr(0.)
80  , m_angleErr(0.)
81  , m_getAPEs(false)
82 {
84  // Version V02-03-02 and earlier of this module had support for //
85  // "cfg" as an input/output format. It turns out that reading //
86  // thousands of parameters from a configuration file takes a very //
87  // long time, so "cfg" wasn't very practical. When I reorganized //
88  // the code, I didn't bother to port it. //
90 
91  if (m_input == std::string("ideal")) {}
92 
93  else if (m_input == std::string("db")) {
94  m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
95  m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
96  m_shiftErr = iConfig.getParameter<double>("shiftErr");
97  m_angleErr = iConfig.getParameter<double>("angleErr");
98  m_getAPEs = iConfig.getParameter<bool>("getAPEs");
99  }
100 
101  else if (m_input == std::string("surveydb")) {
102  m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
103  m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
104  }
105 
106  else if (m_input == std::string("scenario")) {
107  m_misalignmentScenario = iConfig.getParameter<edm::ParameterSet>("MisalignmentScenario");
108  m_shiftErr = iConfig.getParameter<double>("shiftErr");
109  m_angleErr = iConfig.getParameter<double>("angleErr");
110  }
111 
112  else if (m_input == std::string("xml")) {
113  m_fileName = iConfig.getParameter<std::string>("fileName");
114  m_shiftErr = iConfig.getParameter<double>("shiftErr");
115  m_angleErr = iConfig.getParameter<double>("angleErr");
116  }
117 
118  else {
119  throw cms::Exception("BadConfig") << "input must be \"ideal\", \"db\", \"surveydb\", or \"xml\"." << std::endl;
120  }
121 
122  if (m_output == std::string("none")) {}
123 
124  else if (m_output == std::string("db")) {}
125 
126  else if (m_output == std::string("surveydb")) {}
127 
128  else if (m_output == std::string("xml")) {
129  m_outputXML = iConfig.getParameter<edm::ParameterSet>("outputXML");
130  }
131 
132  else {
133  throw cms::Exception("BadConfig") << "output must be \"none\", \"db\", or \"surveydb\"." << std::endl;
134  }
135 }
136 
138 
139 // ------------ method called to for each event ------------
140 void
142  if (!m_done) {
144 
145  if (m_input == std::string("ideal")) {
146  MuonAlignmentInputMethod inputMethod;
147  muonAlignment = new MuonAlignment(iSetup, inputMethod);
148  muonAlignment->fillGapsInSurvey(0., 0.);
149  }
150 
151  else if (m_input == std::string("db")) {
153  muonAlignment = new MuonAlignment(iSetup, inputMethod);
154  if (m_getAPEs) {
156  }
157  }
158 
159  else if (m_input == std::string("surveydb")) {
161  muonAlignment = new MuonAlignment(iSetup, inputMethod);
162  muonAlignment->copySurveyToAlignment();
163  }
164 
165  else if (m_input == std::string("scenario")) {
166  MuonAlignmentInputMethod inputMethod;
167  muonAlignment = new MuonAlignment(iSetup, inputMethod);
168 
169  MuonScenarioBuilder muonScenarioBuilder(muonAlignment->getAlignableMuon());
170  muonScenarioBuilder.applyScenario(m_misalignmentScenario);
172  }
173 
174  else if (m_input == std::string("xml")) {
175  MuonAlignmentInputXML inputMethod(m_fileName);
176  muonAlignment = new MuonAlignment(iSetup, inputMethod);
177  muonAlignment->fillGapsInSurvey(m_shiftErr, m_angleErr);
178  }
179 
181 
182  if (muonAlignment) {
183 
184  if (m_output == std::string("none")) {}
185 
186  else if (m_output == std::string("db")) {
187  muonAlignment->saveToDB();
188  }
189 
190  else if (m_output == std::string("surveydb")) {
191  muonAlignment->saveSurveyToDB();
192  }
193 
194  else if (m_output == std::string("xml")) {
195  muonAlignment->writeXML(m_outputXML, iSetup);
196  }
197 
198  delete muonAlignment;
199 
200  }
201 
202  m_done = true;
203  } // end if not done
204  else {
205  throw cms::Exception("BadConfig") << "Set maxEvents.input to 1. (Your output is okay.)" << std::endl;
206  }
207 }
208 
209 //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)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
#define NULL
Definition: scimark2.h:8
void copySurveyToAlignment()
MuonGeometryDBConverter(const edm::ParameterSet &)
void saveSurveyToDB()
int iEvent
Definition: GenABIO.cc:243
AlignableMuon * getAlignableMuon()
Definition: MuonAlignment.h:30
void fillGapsInSurvey(double shiftErr, double angleErr)
void writeXML(const edm::ParameterSet &iConfig, const edm::EventSetup &iSetup)
volatile std::atomic< bool > shutdown_flag false
void applyScenario(const edm::ParameterSet &scenario)
Apply misalignment scenario to the Muon.
edm::ParameterSet m_misalignmentScenario
virtual void analyze(const edm::Event &, const edm::EventSetup &) override