Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "FWCore/Framework/interface/Frameworkfwd.h"
00023 #include "FWCore/Framework/interface/EDAnalyzer.h"
00024 #include "FWCore/Framework/interface/EventSetup.h"
00025 #include "FWCore/Framework/interface/ESHandle.h"
00026 #include "FWCore/Framework/interface/Event.h"
00027 #include "FWCore/Framework/interface/MakerMacros.h"
00028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00029 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00030
00031
00032 #include "Alignment/MuonAlignment/interface/MuonAlignment.h"
00033 #include "Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h"
00034 #include "Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h"
00035 #include "Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h"
00036 #include "Alignment/MuonAlignment/interface/MuonAlignmentInputXML.h"
00037 #include "Alignment/MuonAlignment/interface/MuonScenarioBuilder.h"
00038
00039
00040
00041
00042
00043 class MuonGeometryDBConverter : public edm::EDAnalyzer {
00044 public:
00045 explicit MuonGeometryDBConverter(const edm::ParameterSet&);
00046 ~MuonGeometryDBConverter();
00047
00048
00049 private:
00050 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00051
00052 bool m_done;
00053 std::string m_input, m_output;
00054
00055 std::string m_dtLabel, m_cscLabel;
00056 double m_shiftErr, m_angleErr;
00057 std::string m_fileName;
00058 bool m_getAPEs;
00059
00060 edm::ParameterSet m_misalignmentScenario;
00061 edm::ParameterSet m_outputXML;
00062 };
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfig)
00076 : m_done(false)
00077 , m_input(iConfig.getParameter<std::string>("input"))
00078 , m_output(iConfig.getParameter<std::string>("output"))
00079 {
00081
00082
00083
00084
00085
00087
00088 if (m_input == std::string("ideal")) {}
00089
00090 else if (m_input == std::string("db")) {
00091 m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
00092 m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
00093 m_shiftErr = iConfig.getParameter<double>("shiftErr");
00094 m_angleErr = iConfig.getParameter<double>("angleErr");
00095 m_getAPEs = iConfig.getParameter<bool>("getAPEs");
00096 }
00097
00098 else if (m_input == std::string("surveydb")) {
00099 m_dtLabel = iConfig.getParameter<std::string>("dtLabel");
00100 m_cscLabel = iConfig.getParameter<std::string>("cscLabel");
00101 }
00102
00103 else if (m_input == std::string("scenario")) {
00104 m_misalignmentScenario = iConfig.getParameter<edm::ParameterSet>("MisalignmentScenario");
00105 m_shiftErr = iConfig.getParameter<double>("shiftErr");
00106 m_angleErr = iConfig.getParameter<double>("angleErr");
00107 }
00108
00109 else if (m_input == std::string("xml")) {
00110 m_fileName = iConfig.getParameter<std::string>("fileName");
00111 m_shiftErr = iConfig.getParameter<double>("shiftErr");
00112 m_angleErr = iConfig.getParameter<double>("angleErr");
00113 }
00114
00115 else {
00116 throw cms::Exception("BadConfig") << "input must be \"ideal\", \"db\", \"surveydb\", or \"xml\"." << std::endl;
00117 }
00118
00119 if (m_output == std::string("none")) {}
00120
00121 else if (m_output == std::string("db")) {}
00122
00123 else if (m_output == std::string("surveydb")) {}
00124
00125 else if (m_output == std::string("xml")) {
00126 m_outputXML = iConfig.getParameter<edm::ParameterSet>("outputXML");
00127 }
00128
00129 else {
00130 throw cms::Exception("BadConfig") << "output must be \"none\", \"db\", or \"surveydb\"." << std::endl;
00131 }
00132 }
00133
00134 MuonGeometryDBConverter::~MuonGeometryDBConverter() { }
00135
00136
00137 void
00138 MuonGeometryDBConverter::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
00139 if (!m_done) {
00140 MuonAlignment *muonAlignment = NULL;
00141
00142 if (m_input == std::string("ideal")) {
00143 MuonAlignmentInputMethod inputMethod;
00144 muonAlignment = new MuonAlignment(iSetup, inputMethod);
00145 muonAlignment->fillGapsInSurvey(0., 0.);
00146 }
00147
00148 else if (m_input == std::string("db")) {
00149 MuonAlignmentInputDB inputMethod(m_dtLabel, m_cscLabel, m_getAPEs);
00150 muonAlignment = new MuonAlignment(iSetup, inputMethod);
00151 if (m_getAPEs) {
00152 muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr);
00153 }
00154 }
00155
00156 else if (m_input == std::string("surveydb")) {
00157 MuonAlignmentInputSurveyDB inputMethod(m_dtLabel, m_cscLabel);
00158 muonAlignment = new MuonAlignment(iSetup, inputMethod);
00159 muonAlignment->copySurveyToAlignment();
00160 }
00161
00162 else if (m_input == std::string("scenario")) {
00163 MuonAlignmentInputMethod inputMethod;
00164 muonAlignment = new MuonAlignment(iSetup, inputMethod);
00165
00166 MuonScenarioBuilder muonScenarioBuilder(muonAlignment->getAlignableMuon());
00167 muonScenarioBuilder.applyScenario(m_misalignmentScenario);
00168 muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr);
00169 }
00170
00171 else if (m_input == std::string("xml")) {
00172 MuonAlignmentInputXML inputMethod(m_fileName);
00173 muonAlignment = new MuonAlignment(iSetup, inputMethod);
00174 muonAlignment->fillGapsInSurvey(m_shiftErr, m_angleErr);
00175 }
00176
00178
00179 if (m_output == std::string("none")) {}
00180
00181 else if (m_output == std::string("db")) {
00182 muonAlignment->saveToDB();
00183 }
00184
00185 else if (m_output == std::string("surveydb")) {
00186 muonAlignment->saveSurveyToDB();
00187 }
00188
00189 else if (m_output == std::string("xml")) {
00190 muonAlignment->writeXML(m_outputXML, iSetup);
00191 }
00192
00193 delete muonAlignment;
00194
00195 m_done = true;
00196 }
00197 else {
00198 throw cms::Exception("BadConfig") << "Set maxEvents.input to 1. (Your output is okay.)" << std::endl;
00199 }
00200 }
00201
00202
00203 DEFINE_FWK_MODULE(MuonGeometryDBConverter);