From 4c7f78ac68a1fb87f24ec4935a505d3679bcfbc5 Mon Sep 17 00:00:00 2001 From: hyunyong Date: Tue, 19 Oct 2021 04:08:59 +0900 Subject: [PATCH 1/5] esConsumes migration for muon alignment --- .../MuonAlignment/interface/MuonAlignment.h | 13 +- .../interface/MuonAlignmentInputDB.h | 41 +++- .../interface/MuonAlignmentInputMethod.h | 15 +- .../interface/MuonAlignmentInputSurveyDB.h | 20 +- .../interface/MuonAlignmentInputXML.h | 31 ++- .../interface/MuonAlignmentOutputXML.h | 21 +- .../plugins/MuonGeometryArrange.cc | 52 ++++- .../plugins/MuonGeometryArrange.h | 16 ++ .../plugins/MuonGeometryDBConverter.cc | 142 ++++++++----- .../plugins/MuonGeometrySanityCheck.cc | 11 +- Alignment/MuonAlignment/src/MuonAlignment.cc | 20 +- .../MuonAlignment/src/MuonAlignmentInputDB.cc | 134 ++++++------- .../src/MuonAlignmentInputMethod.cc | 17 +- .../src/MuonAlignmentInputSurveyDB.cc | 51 ++--- .../src/MuonAlignmentInputXML.cc | 157 +++++++++++++-- .../src/MuonAlignmentOutputXML.cc | 115 ++++++++--- Alignment/MuonAlignment/test/TestAlign.cpp | 95 --------- .../test/muonGeometryDBConverter_cfg.py | 186 ++++++------------ .../test/test_MuonGeometryDBConverter.sh | 3 +- .../interface/SegmentToTrackAssociator.h | 6 +- .../plugins/CSCOverlapsTrackPreparation.cc | 17 +- .../src/SegmentToTrackAssociator.cc | 13 +- .../test/StandAloneTest.cc | 12 +- .../SurveyAnalysis/plugins/DTSurveyConvert.cc | 16 +- .../SurveyAnalysis/plugins/DTSurveyConvert.h | 4 + 25 files changed, 718 insertions(+), 490 deletions(-) delete mode 100644 Alignment/MuonAlignment/test/TestAlign.cpp diff --git a/Alignment/MuonAlignment/interface/MuonAlignment.h b/Alignment/MuonAlignment/interface/MuonAlignment.h index ec70e349ca87f..09bfcf08cb339 100644 --- a/Alignment/MuonAlignment/interface/MuonAlignment.h +++ b/Alignment/MuonAlignment/interface/MuonAlignment.h @@ -20,7 +20,7 @@ class MuonAlignment { public: - MuonAlignment(const edm::EventSetup& iSetup); + MuonAlignment(const DTGeometry* dtGeometry, const CSCGeometry* cscGeometry, const GEMGeometry* gemGeometry); MuonAlignment(const edm::EventSetup& iSetup, const MuonAlignmentInputMethod& input); @@ -45,7 +45,10 @@ class MuonAlignment { void fillGapsInSurvey(double shiftErr, double angleErr); void copySurveyToAlignment(); - void writeXML(const edm::ParameterSet& iConfig, const edm::EventSetup& iSetup); + void writeXML(const edm::ParameterSet& iConfig, + const DTGeometry* dtGeometryXML, + const CSCGeometry* cscGeometryXML, + const GEMGeometry* gemGeometryXML); void saveDTSurveyToDB(); void saveCSCSurveyToDB(); @@ -66,9 +69,9 @@ class MuonAlignment { std::string theDTSurveyRecordName, theDTSurveyErrorRecordName; std::string theCSCSurveyRecordName, theCSCSurveyErrorRecordName; - edm::ESGetToken esTokenDT_; - edm::ESGetToken esTokenCSC_; - edm::ESGetToken esTokenGEM_; + const DTGeometry* dtGeometry_; + const CSCGeometry* cscGeometry_; + const GEMGeometry* gemGeometry_; align::Scalars displacements; diff --git a/Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h b/Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h index 714e788b5b194..19db1d959c756 100644 --- a/Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h +++ b/Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h @@ -28,9 +28,23 @@ class MuonAlignmentInputDB : public MuonAlignmentInputMethod { public: - MuonAlignmentInputDB(); - MuonAlignmentInputDB( - std::string dtLabel, std::string cscLabel, std::string gemLabel, std::string idealLabel, bool getAPEs); + MuonAlignmentInputDB(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry, + const Alignments* dtAlignments, + const Alignments* cscAlignments, + const Alignments* gemAlignments, + const Alignments* globalPositionRcd); + MuonAlignmentInputDB(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry, + const Alignments* dtAlignments, + const Alignments* cscAlignments, + const Alignments* gemAlignments, + const Alignments* globalPositionRcd, + const AlignmentErrorsExtended* dtAlignmentErrorsExtended, + const AlignmentErrorsExtended* cscAlignmentErrorsExtended, + const AlignmentErrorsExtended* gemAlignmentErrorsExtended); ~MuonAlignmentInputDB() override; // ---------- const member functions --------------------- @@ -39,17 +53,26 @@ class MuonAlignmentInputDB : public MuonAlignmentInputMethod { // ---------- member functions --------------------------- - AlignableMuon *newAlignableMuon(const edm::EventSetup &iSetup) const override; + AlignableMuon* newAlignableMuon() const override; - MuonAlignmentInputDB(const MuonAlignmentInputDB &) = delete; // stop default + MuonAlignmentInputDB(const MuonAlignmentInputDB&) = delete; // stop default - const MuonAlignmentInputDB &operator=(const MuonAlignmentInputDB &) = delete; // stop default + const MuonAlignmentInputDB& operator=(const MuonAlignmentInputDB&) = delete; // stop default private: // ---------- member data -------------------------------- - - std::string m_dtLabel, m_cscLabel, m_gemLabel, idealGeometryLabel; - bool m_getAPEs; + const DTGeometry* dtGeometry_; + const CSCGeometry* cscGeometry_; + const GEMGeometry* gemGeometry_; + const Alignments* dtAlignments_; + const Alignments* cscAlignments_; + const Alignments* gemAlignments_; + const Alignments* globalPositionRcd_; + const AlignmentErrorsExtended* dtAlignmentErrorsExtended_; + const AlignmentErrorsExtended* cscAlignmentErrorsExtended_; + const AlignmentErrorsExtended* gemAlignmentErrorsExtended_; + + const bool m_getAPEs; }; #endif diff --git a/Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h b/Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h index 8beb005427983..3b5041d130df4 100644 --- a/Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h +++ b/Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h @@ -28,13 +28,16 @@ #include "Alignment/MuonAlignment/interface/AlignableMuon.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" // forward declarations class MuonAlignmentInputMethod { public: MuonAlignmentInputMethod(); - MuonAlignmentInputMethod(std::string idealLabel); + MuonAlignmentInputMethod(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry); virtual ~MuonAlignmentInputMethod(); // ---------- const member functions --------------------- @@ -43,15 +46,17 @@ class MuonAlignmentInputMethod { // ---------- member functions --------------------------- - virtual AlignableMuon *newAlignableMuon(const edm::EventSetup &iSetup) const; + virtual AlignableMuon* newAlignableMuon() const; - MuonAlignmentInputMethod(const MuonAlignmentInputMethod &) = delete; // stop default + MuonAlignmentInputMethod(const MuonAlignmentInputMethod&) = delete; // stop default - const MuonAlignmentInputMethod &operator=(const MuonAlignmentInputMethod &) = delete; // stop default + const MuonAlignmentInputMethod& operator=(const MuonAlignmentInputMethod&) = delete; // stop default private: // ---------- member data -------------------------------- - std::string idealGeometryLabel; + const DTGeometry* dtGeometry_; + const CSCGeometry* cscGeometry_; + const GEMGeometry* gemGeometry_; }; #endif diff --git a/Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h b/Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h index fda75deb7d61b..44062ce46fbf0 100644 --- a/Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h +++ b/Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h @@ -30,8 +30,13 @@ class MuonAlignmentInputSurveyDB : public MuonAlignmentInputMethod { public: - MuonAlignmentInputSurveyDB(); - MuonAlignmentInputSurveyDB(std::string dtLabel, std::string cscLabel, std::string idealLabel); + MuonAlignmentInputSurveyDB(const DTGeometry* DTGeometry, + const CSCGeometry* CSCGeometry, + const GEMGeometry* GEMGeometry, + const Alignments* dtSurvey, + const Alignments* cscSurvey, + const SurveyErrors* dtSurveyError, + const SurveyErrors* cscSurveyError); ~MuonAlignmentInputSurveyDB() override; // ---------- const member functions --------------------- @@ -40,7 +45,7 @@ class MuonAlignmentInputSurveyDB : public MuonAlignmentInputMethod { // ---------- member functions --------------------------- - AlignableMuon* newAlignableMuon(const edm::EventSetup& iSetup) const override; + AlignableMuon* newAlignableMuon() const override; MuonAlignmentInputSurveyDB(const MuonAlignmentInputSurveyDB&) = delete; // stop default @@ -53,8 +58,13 @@ class MuonAlignmentInputSurveyDB : public MuonAlignmentInputMethod { const SurveyErrors* theSurveyErrors) const; // ---------- member data -------------------------------- - - std::string m_dtLabel, m_cscLabel, idealGeometryLabel; + const DTGeometry* dtGeometry_; + const CSCGeometry* cscGeometry_; + const GEMGeometry* gemGeometry_; + const Alignments* dtSurvey_; + const Alignments* cscSurvey_; + const SurveyErrors* dtSurveyError_; + const SurveyErrors* cscSurveyError_; }; #endif diff --git a/Alignment/MuonAlignment/interface/MuonAlignmentInputXML.h b/Alignment/MuonAlignment/interface/MuonAlignmentInputXML.h index 044a31c4e0f0d..e0fee72f31e32 100644 --- a/Alignment/MuonAlignment/interface/MuonAlignmentInputXML.h +++ b/Alignment/MuonAlignment/interface/MuonAlignmentInputXML.h @@ -32,7 +32,13 @@ class MuonAlignmentInputXML : public MuonAlignmentInputMethod { public: - MuonAlignmentInputXML(const std::string &fileName, std::string idealLabel); + MuonAlignmentInputXML(const std::string &fileName, + const DTGeometry *dtGeometry, + const CSCGeometry *cscGeometry, + const GEMGeometry *gemGeometry, + const DTGeometry *dtGeometryIdeal, + const CSCGeometry *cscGeometryIdeal, + const GEMGeometry *gemGeometryIdeal); ~MuonAlignmentInputXML() override; // ---------- const member functions --------------------- @@ -41,7 +47,7 @@ class MuonAlignmentInputXML : public MuonAlignmentInputMethod { // ---------- member functions --------------------------- - AlignableMuon *newAlignableMuon(const edm::EventSetup &iSetup) const override; + AlignableMuon *newAlignableMuon() const override; MuonAlignmentInputXML(const MuonAlignmentInputXML &) = delete; // stop default @@ -66,6 +72,10 @@ class MuonAlignmentInputXML : public MuonAlignmentInputMethod { std::map &alignableNavigator, const XERCES_CPP_NAMESPACE::DOMElement *node, const AlignableObjectId &) const; + Alignable *getGEMnode(align::StructureType structureType, + std::map &alignableNavigator, + const XERCES_CPP_NAMESPACE::DOMElement *node, + const AlignableObjectId &) const; double parseDouble(const XMLCh *str, const char *attribute) const; void set_one_position(Alignable *ali, const align::PositionType &pos, const align::RotationType &rot) const; @@ -96,7 +106,14 @@ class MuonAlignmentInputXML : public MuonAlignmentInputMethod { std::map &alitoideal) const; // ---------- member data -------------------------------- - std::string m_fileName, idealGeometryLabel; + std::string m_fileName; + + const DTGeometry *dtGeometry_; + const CSCGeometry *cscGeometry_; + const GEMGeometry *gemGeometry_; + const DTGeometry *dtGeometryIdeal_; + const CSCGeometry *cscGeometryIdeal_; + const GEMGeometry *gemGeometryIdeal_; XMLCh *str_operation; XMLCh *str_collection; @@ -112,6 +129,12 @@ class MuonAlignmentInputXML : public MuonAlignmentInputMethod { XMLCh *str_CSCRing; XMLCh *str_CSCChamber; XMLCh *str_CSCLayer; + XMLCh *str_GEMEndcap; + XMLCh *str_GEMStation; + XMLCh *str_GEMRing; + XMLCh *str_GEMSuperChamber; + XMLCh *str_GEMChamber; + XMLCh *str_GEMEtaPartition; XMLCh *str_setposition; XMLCh *str_setape; XMLCh *str_setsurveyerr; @@ -130,6 +153,8 @@ class MuonAlignmentInputXML : public MuonAlignmentInputMethod { XMLCh *str_endcap; XMLCh *str_ring; XMLCh *str_chamber; + XMLCh *str_superChamber; + XMLCh *str_etaPartition; XMLCh *str_axisx; XMLCh *str_axisy; XMLCh *str_axisz; diff --git a/Alignment/MuonAlignment/interface/MuonAlignmentOutputXML.h b/Alignment/MuonAlignment/interface/MuonAlignmentOutputXML.h index 18d79608b1356..fb345393682f0 100644 --- a/Alignment/MuonAlignment/interface/MuonAlignmentOutputXML.h +++ b/Alignment/MuonAlignment/interface/MuonAlignmentOutputXML.h @@ -28,13 +28,18 @@ // user include files #include "Alignment/MuonAlignment/interface/AlignableMuon.h" #include "CondFormats/Alignment/interface/AlignTransformErrorExtended.h" - +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" // forward declarations class AlignableObjectId; class MuonAlignmentOutputXML { public: - MuonAlignmentOutputXML(const edm::ParameterSet &iConfig); + MuonAlignmentOutputXML(const edm::ParameterSet &iConfig, + const DTGeometry *dtGeometry, + const CSCGeometry *cscGeometry, + const GEMGeometry *gemGeometry); virtual ~MuonAlignmentOutputXML(); // ---------- const member functions --------------------- @@ -43,18 +48,19 @@ class MuonAlignmentOutputXML { // ---------- member functions --------------------------- - void write(AlignableMuon *alignableMuon, const edm::EventSetup &iSetup) const; + void write(AlignableMuon *alignableMuon) const; MuonAlignmentOutputXML(const MuonAlignmentOutputXML &) = delete; // stop default const MuonAlignmentOutputXML &operator=(const MuonAlignmentOutputXML &) = delete; // stop default private: + enum { doDT, doCSC, doGEM }; void writeComponents(align::Alignables &alignables, align::Alignables &ideals, std::map &errors, std::ofstream &outputFile, - bool DT, + const int doDet, const AlignableObjectId &) const; // ---------- member data -------------------------------- @@ -65,7 +71,12 @@ class MuonAlignmentOutputXML { bool m_suppressDTBarrel, m_suppressDTWheels, m_suppressDTStations, m_suppressDTChambers, m_suppressDTSuperLayers, m_suppressDTLayers; bool m_suppressCSCEndcaps, m_suppressCSCStations, m_suppressCSCRings, m_suppressCSCChambers, m_suppressCSCLayers; - std::string idealGeometryLabel; + bool m_suppressGEMEndcaps, m_suppressGEMStations, m_suppressGEMRings, m_suppressGEMSuperChambers, + m_suppressGEMChambers, m_suppressGEMEtaPartitions; + + const DTGeometry *dtGeometry_; + const CSCGeometry *cscGeometry_; + const GEMGeometry *gemGeometry_; }; #endif diff --git a/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc b/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc index 69dbe635bbb8d..95d0f0dfad4b4 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc +++ b/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc @@ -623,13 +623,59 @@ void MuonGeometryArrange::createROOTGeometry(const edm::EventSetup& iSetup) {} void MuonGeometryArrange::analyze(const edm::Event&, const edm::EventSetup& iSetup) { if (firstEvent_) { // My stuff - MuonAlignmentInputXML inputMethod1(_inputXMLCurrent, idealInputLabel1); + edm::ESHandle dtGeometry1; + edm::ESHandle cscGeometry1; + edm::ESHandle gemGeometry1; + dtGeometry1 = iSetup.getHandle(dtGeomToken1_); + cscGeometry1 = iSetup.getHandle(cscGeomToken1_); + gemGeometry1 = iSetup.getHandle(gemGeomToken1_); + + edm::ESHandle dtGeometry2; + edm::ESHandle cscGeometry2; + edm::ESHandle gemGeometry2; + dtGeometry2 = iSetup.getHandle(dtGeomToken2_); + cscGeometry2 = iSetup.getHandle(cscGeomToken2_); + gemGeometry2 = iSetup.getHandle(gemGeomToken2_); + + edm::ESHandle dtGeometry3; + edm::ESHandle cscGeometry3; + edm::ESHandle gemGeometry3; + dtGeometry3 = iSetup.getHandle(dtGeomToken3_); + cscGeometry3 = iSetup.getHandle(cscGeomToken3_); + gemGeometry3 = iSetup.getHandle(gemGeomToken3_); + + edm::ESHandle dtGeometryIdeal; + edm::ESHandle cscGeometryIdeal; + edm::ESHandle gemGeometryIdeal; + dtGeometryIdeal = iSetup.getHandle(dtGeomIdealToken_); + cscGeometryIdeal = iSetup.getHandle(cscGeomIdealToken_); + gemGeometryIdeal = iSetup.getHandle(gemGeomIdealToken_); + + MuonAlignmentInputXML inputMethod1(_inputXMLCurrent, + &*dtGeometry1, + &*cscGeometry1, + &*gemGeometry1, + &*dtGeometryIdeal, + &*cscGeometryIdeal, + &*gemGeometryIdeal); inputAlign1 = new MuonAlignment(iSetup, inputMethod1); inputAlign1->fillGapsInSurvey(0, 0); - MuonAlignmentInputXML inputMethod2(_inputXMLReference, idealInputLabel2); + MuonAlignmentInputXML inputMethod2(_inputXMLReference, + &*dtGeometry2, + &*cscGeometry2, + &*gemGeometry2, + &*dtGeometryIdeal, + &*cscGeometryIdeal, + &*gemGeometryIdeal); inputAlign2 = new MuonAlignment(iSetup, inputMethod2); inputAlign2->fillGapsInSurvey(0, 0); - MuonAlignmentInputXML inputMethod2a(_inputXMLReference, idealInputLabel2a); + MuonAlignmentInputXML inputMethod2a(_inputXMLReference, + &*dtGeometry3, + &*cscGeometry3, + &*gemGeometry3, + &*dtGeometryIdeal, + &*cscGeometryIdeal, + &*gemGeometryIdeal); inputAlign2a = new MuonAlignment(iSetup, inputMethod2a); inputAlign2a->fillGapsInSurvey(0, 0); diff --git a/Alignment/MuonAlignment/plugins/MuonGeometryArrange.h b/Alignment/MuonAlignment/plugins/MuonGeometryArrange.h index 0d0e0551d1f7a..530ba54e865cd 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometryArrange.h +++ b/Alignment/MuonAlignment/plugins/MuonGeometryArrange.h @@ -171,6 +171,22 @@ class MuonGeometryArrange : public edm::EDAnalyzer { bool firstEvent_; std::string idealInputLabel1, idealInputLabel2, idealInputLabel2a; + + const edm::ESGetToken dtGeomToken1_; + const edm::ESGetToken cscGeomToken1_; + const edm::ESGetToken gemGeomToken1_; + + const edm::ESGetToken dtGeomToken2_; + const edm::ESGetToken cscGeomToken2_; + const edm::ESGetToken gemGeomToken2_; + + const edm::ESGetToken dtGeomToken3_; + const edm::ESGetToken cscGeomToken3_; + const edm::ESGetToken gemGeomToken3_; + + const edm::ESGetToken dtGeomIdealToken_; + const edm::ESGetToken cscGeomIdealToken_; + const edm::ESGetToken gemGeomIdealToken_; }; #endif diff --git a/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc b/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc index 5afd04cf3f02f..b81e8b7f23f51 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc +++ b/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc @@ -34,6 +34,8 @@ #include "Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h" #include "Alignment/MuonAlignment/interface/MuonAlignmentInputXML.h" #include "Alignment/MuonAlignment/interface/MuonScenarioBuilder.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" // // class decleration @@ -61,8 +63,20 @@ class MuonGeometryDBConverter : public edm::one::EDAnalyzer<> { edm::ParameterSet m_misalignmentScenario; edm::ParameterSet m_outputXML; - std::string idealGeometryLabelForInputMethod, idealGeometryLabelForInputDB, idealGeometryLabelForInputXML, - idealGeometryLabelForInputSurveyDB; + const std::string idealGeometryLabelForInputXML, idealGeometryLabel; + + const edm::ESGetToken dtGeomIdealToken_; + const edm::ESGetToken cscGeomIdealToken_; + const edm::ESGetToken gemGeomIdealToken_; + + edm::ESGetToken dtGeomToken_; + edm::ESGetToken cscGeomToken_; + edm::ESGetToken gemGeomToken_; + + edm::ESGetToken dtAliToken_; + edm::ESGetToken cscAliToken_; + edm::ESGetToken gemAliToken_; + const edm::ESGetToken gprToken_; }; // @@ -83,10 +97,12 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi m_shiftErr(0.), m_angleErr(0.), m_getAPEs(false), - idealGeometryLabelForInputMethod("idealForInputMethod"), - idealGeometryLabelForInputDB("idealForInputDB"), idealGeometryLabelForInputXML("idealForInputXML"), - idealGeometryLabelForInputSurveyDB("idealForInputSurveyDB") { + idealGeometryLabel("idealGeometry"), + dtGeomIdealToken_(esConsumes(edm::ESInputTag("", idealGeometryLabel))), + cscGeomIdealToken_(esConsumes(edm::ESInputTag("", idealGeometryLabel))), + gemGeomIdealToken_(esConsumes(edm::ESInputTag("", idealGeometryLabel))), + gprToken_(esConsumes(edm::ESInputTag("", ""))) { //////////////////////////////////////////////////////////////////// // Version V02-03-02 and earlier of this module had support for // // "cfg" as an input/output format. It turns out that reading // @@ -105,6 +121,16 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi m_shiftErr = iConfig.getParameter("shiftErr"); m_angleErr = iConfig.getParameter("angleErr"); m_getAPEs = iConfig.getParameter("getAPEs"); + m_outputXML = iConfig.getParameter("outputXML"); + + dtAliToken_ = esConsumes(edm::ESInputTag("", m_dtLabel)); + cscAliToken_ = esConsumes(edm::ESInputTag("", m_cscLabel)); + gemAliToken_ = esConsumes(edm::ESInputTag("", m_gemLabel)); + + dtGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); + cscGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); + gemGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); + } else if (m_input == std::string("surveydb")) { @@ -123,6 +149,9 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi m_fileName = iConfig.getParameter("fileName"); m_shiftErr = iConfig.getParameter("shiftErr"); m_angleErr = iConfig.getParameter("angleErr"); + dtGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); + cscGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); + gemGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); } else { @@ -135,15 +164,12 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi else if (m_output == std::string("db")) { } - else if (m_output == std::string("surveydb")) { - } - else if (m_output == std::string("xml")) { m_outputXML = iConfig.getParameter("outputXML"); } else { - throw cms::Exception("BadConfig") << "output must be \"none\", \"db\", or \"surveydb\"." << std::endl; + throw cms::Exception("BadConfig") << "output must be \"none\", \"db \", \"xml\"." << std::endl; } } @@ -151,65 +177,81 @@ MuonGeometryDBConverter::~MuonGeometryDBConverter() {} // ------------ method called to for each event ------------ void MuonGeometryDBConverter::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { - if (!m_done) { - MuonAlignment *muonAlignment = nullptr; + edm::ESHandle dtGeometryIdeal; + edm::ESHandle cscGeometryIdeal; + edm::ESHandle gemGeometryIdeal; + dtGeometryIdeal = iSetup.getHandle(dtGeomIdealToken_); + cscGeometryIdeal = iSetup.getHandle(cscGeomIdealToken_); + gemGeometryIdeal = iSetup.getHandle(gemGeomIdealToken_); + if (!m_done) { if (m_input == std::string("ideal")) { - MuonAlignmentInputMethod inputMethod; - muonAlignment = new MuonAlignment(iSetup, inputMethod); + MuonAlignmentInputMethod inputMethod(&*dtGeometryIdeal, &*cscGeometryIdeal, &*gemGeometryIdeal); + MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod); muonAlignment->fillGapsInSurvey(0., 0.); + muonAlignment->saveToDB(); } else if (m_input == std::string("db")) { - MuonAlignmentInputDB inputMethod(m_dtLabel, m_cscLabel, m_gemLabel, idealGeometryLabelForInputDB, m_getAPEs); - muonAlignment = new MuonAlignment(iSetup, inputMethod); + edm::ESHandle dtAlignments; + edm::ESHandle cscAlignments; + edm::ESHandle gemAlignments; + edm::ESHandle globalPositionRcd; + dtAlignments = iSetup.getHandle(dtAliToken_); + cscAlignments = iSetup.getHandle(cscAliToken_); + gemAlignments = iSetup.getHandle(gemAliToken_); + globalPositionRcd = iSetup.getHandle(gprToken_); + edm::ESHandle dtGeometry; + edm::ESHandle cscGeometry; + edm::ESHandle gemGeometry; + dtGeometry = iSetup.getHandle(dtGeomToken_); + cscGeometry = iSetup.getHandle(cscGeomToken_); + gemGeometry = iSetup.getHandle(gemGeomToken_); + MuonAlignmentInputDB inputMethod(&*dtGeometryIdeal, + &*cscGeometryIdeal, + &*gemGeometryIdeal, + &*dtAlignments, + &*cscAlignments, + &*gemAlignments, + &*globalPositionRcd); + MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod); if (m_getAPEs) { muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr); } - } - - else if (m_input == std::string("surveydb")) { - MuonAlignmentInputSurveyDB inputMethod(m_dtLabel, m_cscLabel, idealGeometryLabelForInputSurveyDB); - muonAlignment = new MuonAlignment(iSetup, inputMethod); - muonAlignment->copySurveyToAlignment(); + muonAlignment->writeXML(m_outputXML, &*dtGeometry, &*cscGeometry, &*gemGeometry); } else if (m_input == std::string("scenario")) { - MuonAlignmentInputMethod inputMethod; - muonAlignment = new MuonAlignment(iSetup, inputMethod); + MuonAlignmentInputMethod inputMethod(&*dtGeometryIdeal, &*cscGeometryIdeal, &*gemGeometryIdeal); + MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod); MuonScenarioBuilder muonScenarioBuilder(muonAlignment->getAlignableMuon()); muonScenarioBuilder.applyScenario(m_misalignmentScenario); + muonAlignment->saveToDB(); muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr); } else if (m_input == std::string("xml")) { - MuonAlignmentInputXML inputMethod(m_fileName, idealGeometryLabelForInputXML); - muonAlignment = new MuonAlignment(iSetup, inputMethod); + edm::ESHandle dtGeometry; + edm::ESHandle cscGeometry; + edm::ESHandle gemGeometry; + edm::ESHandle globalPositionRcd; + dtGeometry = iSetup.getHandle(dtGeomToken_); + cscGeometry = iSetup.getHandle(cscGeomToken_); + gemGeometry = iSetup.getHandle(gemGeomToken_); + globalPositionRcd = iSetup.getHandle(gprToken_); + MuonAlignmentInputXML inputMethod(m_fileName, + &*dtGeometry, + &*cscGeometry, + &*gemGeometry, + &*dtGeometryIdeal, + &*cscGeometryIdeal, + &*gemGeometryIdeal); + MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod); + muonAlignment->saveToDB(); muonAlignment->fillGapsInSurvey(m_shiftErr, m_angleErr); } - ///////////// - - if (muonAlignment) { - if (m_output == std::string("none")) { - } - - else if (m_output == std::string("db")) { - muonAlignment->saveToDB(); - } - - else if (m_output == std::string("surveydb")) { - muonAlignment->saveSurveyToDB(); - } - - else if (m_output == std::string("xml")) { - muonAlignment->writeXML(m_outputXML, iSetup); - } - - delete muonAlignment; - } - m_done = true; } // end if not done else { @@ -233,8 +275,8 @@ void MuonGeometryDBConverter::fillDescriptions(edm::ConfigurationDescriptions &d edm::ParameterSetDescription outputXML; outputXML.add("fileName", "REPLACEME.xml"); outputXML.add("relativeto", "ideal"); - outputXML.add("survey", false); outputXML.add("rawIds", false); + outputXML.add("survey", false); outputXML.add("eulerAngles", false); outputXML.add("precision", 10); outputXML.addUntracked("suppressDTBarrel", true); @@ -248,6 +290,12 @@ void MuonGeometryDBConverter::fillDescriptions(edm::ConfigurationDescriptions &d outputXML.addUntracked("suppressCSCRings", true); outputXML.addUntracked("suppressCSCChambers", false); outputXML.addUntracked("suppressCSCLayers", false); + outputXML.addUntracked("suppressGEMEndcaps", true); + outputXML.addUntracked("suppressGEMStations", true); + outputXML.addUntracked("suppressGEMRings", true); + outputXML.addUntracked("suppressGEMSuperChambers", false); + outputXML.addUntracked("suppressGEMChambers", true); + outputXML.addUntracked("suppressGEMEtaPartitions", true); desc.add("outputXML", outputXML); descriptions.add("muonGeometryDBConverter", desc); } diff --git a/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc b/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc index 91db8d5f33c67..2beb719b3a73f 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc +++ b/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc @@ -94,6 +94,9 @@ class MuonGeometrySanityCheck : public edm::EDAnalyzer { std::string prefix; std::map m_frames; std::vector m_points; + + const edm::ESGetToken dtGeomToken_; + const edm::ESGetToken cscGeomToken_; }; // @@ -108,7 +111,8 @@ class MuonGeometrySanityCheck : public edm::EDAnalyzer { // constructors and destructor // -MuonGeometrySanityCheck::MuonGeometrySanityCheck(const edm::ParameterSet &iConfig) { +MuonGeometrySanityCheck::MuonGeometrySanityCheck(const edm::ParameterSet &iConfig) + : dtGeomToken_(esConsumes()), cscGeomToken_(esConsumes()) { printout = iConfig.getParameter("printout"); if (printout != std::string("all") && printout != std::string("bad")) { throw cms::Exception("BadConfig") << "Printout must be \"all\" or \"bad\"." << std::endl; @@ -581,10 +585,9 @@ std::string MuonGeometrySanityCheckPoint::detName() const { // ------------ method called to for each event ------------ void MuonGeometrySanityCheck::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { edm::ESHandle dtGeometry; - iSetup.get().get(dtGeometry); - edm::ESHandle cscGeometry; - iSetup.get().get(cscGeometry); + dtGeometry = iSetup.getHandle(dtGeomToken_); + cscGeometry = iSetup.getHandle(cscGeomToken_); int num_transformed = 0; int num_tested = 0; diff --git a/Alignment/MuonAlignment/src/MuonAlignment.cc b/Alignment/MuonAlignment/src/MuonAlignment.cc index 2458e49befb2b..c858af7398a84 100644 --- a/Alignment/MuonAlignment/src/MuonAlignment.cc +++ b/Alignment/MuonAlignment/src/MuonAlignment.cc @@ -40,21 +40,20 @@ void MuonAlignment::init() { theAlignableNavigator = nullptr; } -MuonAlignment::MuonAlignment(const edm::EventSetup& iSetup) { +MuonAlignment::MuonAlignment(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry) + : dtGeometry_(dtGeometry), cscGeometry_(cscGeometry), gemGeometry_(gemGeometry) { init(); - edm::ESHandle dtGeometry = iSetup.getHandle(esTokenDT_); - edm::ESHandle cscGeometry = iSetup.getHandle(esTokenCSC_); - edm::ESHandle gemGeometry = iSetup.getHandle(esTokenGEM_); - - theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); + theAlignableMuon = new AlignableMuon(&*dtGeometry_, &*cscGeometry_, &*gemGeometry_); theAlignableNavigator = new AlignableNavigator(theAlignableMuon); } MuonAlignment::MuonAlignment(const edm::EventSetup& iSetup, const MuonAlignmentInputMethod& input) { init(); - theAlignableMuon = input.newAlignableMuon(iSetup); + theAlignableMuon = input.newAlignableMuon(); theAlignableNavigator = new AlignableNavigator(theAlignableMuon); } @@ -238,8 +237,11 @@ void MuonAlignment::copySurveyToAlignment() { recursiveCopySurveyToAlignment(the //____________________________________________________________________________________ // Code needed to store alignments to DB -void MuonAlignment::writeXML(const edm::ParameterSet& iConfig, const edm::EventSetup& iSetup) { - MuonAlignmentOutputXML(iConfig).write(theAlignableMuon, iSetup); +void MuonAlignment::writeXML(const edm::ParameterSet& iConfig, + const DTGeometry* dtGeometryXML, + const CSCGeometry* cscGeometryXML, + const GEMGeometry* gemGeometryXML) { + MuonAlignmentOutputXML(iConfig, dtGeometryXML, cscGeometryXML, gemGeometryXML).write(theAlignableMuon); } void MuonAlignment::saveDTSurveyToDB(void) { diff --git a/Alignment/MuonAlignment/src/MuonAlignmentInputDB.cc b/Alignment/MuonAlignment/src/MuonAlignmentInputDB.cc index e64b4183ad60b..1986b68bbf6a3 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentInputDB.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentInputDB.cc @@ -37,16 +37,42 @@ // // constructors and destructor // -MuonAlignmentInputDB::MuonAlignmentInputDB() - : m_dtLabel(""), m_cscLabel(""), m_gemLabel(""), idealGeometryLabel("idealForInputDB"), m_getAPEs(false) {} - -MuonAlignmentInputDB::MuonAlignmentInputDB( - std::string dtLabel, std::string cscLabel, std::string gemLabel, std::string idealLabel, bool getAPEs) - : m_dtLabel(dtLabel), - m_cscLabel(cscLabel), - m_gemLabel(gemLabel), - idealGeometryLabel(idealLabel), - m_getAPEs(getAPEs) {} +MuonAlignmentInputDB::MuonAlignmentInputDB(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry, + const Alignments* dtAlignments, + const Alignments* cscAlignments, + const Alignments* gemAlignments, + const Alignments* globalPositionRcd) + : dtGeometry_(dtGeometry), + cscGeometry_(cscGeometry), + gemGeometry_(gemGeometry), + dtAlignments_(dtAlignments), + cscAlignments_(cscAlignments), + gemAlignments_(gemAlignments), + globalPositionRcd_(globalPositionRcd), + m_getAPEs(false) {} +MuonAlignmentInputDB::MuonAlignmentInputDB(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry, + const Alignments* dtAlignments, + const Alignments* cscAlignments, + const Alignments* gemAlignments, + const Alignments* globalPositionRcd, + const AlignmentErrorsExtended* dtAlignmentErrorsExtended, + const AlignmentErrorsExtended* cscAlignmentErrorsExtended, + const AlignmentErrorsExtended* gemAlignmentErrorsExtended) + : dtGeometry_(dtGeometry), + cscGeometry_(cscGeometry), + gemGeometry_(gemGeometry), + dtAlignments_(dtAlignments), + cscAlignments_(cscAlignments), + gemAlignments_(gemAlignments), + globalPositionRcd_(globalPositionRcd), + dtAlignmentErrorsExtended_(dtAlignmentErrorsExtended), + cscAlignmentErrorsExtended_(cscAlignmentErrorsExtended), + gemAlignmentErrorsExtended_(gemAlignmentErrorsExtended), + m_getAPEs(true) {} // MuonAlignmentInputDB::MuonAlignmentInputDB(const MuonAlignmentInputDB& rhs) // { @@ -71,65 +97,41 @@ MuonAlignmentInputDB::~MuonAlignmentInputDB() {} // member functions // -AlignableMuon* MuonAlignmentInputDB::newAlignableMuon(const edm::EventSetup& iSetup) const { - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - iSetup.get().get(idealGeometryLabel, dtGeometry); - iSetup.get().get(idealGeometryLabel, cscGeometry); - iSetup.get().get(idealGeometryLabel, gemGeometry); - - edm::ESHandle dtAlignments; - edm::ESHandle dtAlignmentErrorsExtended; - edm::ESHandle cscAlignments; - edm::ESHandle cscAlignmentErrorsExtended; - edm::ESHandle gemAlignments; - edm::ESHandle gemAlignmentErrorsExtended; - edm::ESHandle globalPositionRcd; - - iSetup.get().get(m_dtLabel, dtAlignments); - iSetup.get().get(m_cscLabel, cscAlignments); - iSetup.get().get(m_gemLabel, gemAlignments); - iSetup.get().get(globalPositionRcd); - +AlignableMuon* MuonAlignmentInputDB::newAlignableMuon() const { if (m_getAPEs) { - iSetup.get().get(m_dtLabel, dtAlignmentErrorsExtended); - iSetup.get().get(m_cscLabel, cscAlignmentErrorsExtended); - iSetup.get().get(m_gemLabel, gemAlignmentErrorsExtended); - GeometryAligner aligner; - aligner.applyAlignments(&(*dtGeometry), - &(*dtAlignments), - &(*dtAlignmentErrorsExtended), - align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); - aligner.applyAlignments(&(*cscGeometry), - &(*cscAlignments), - &(*cscAlignmentErrorsExtended), - align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); - aligner.applyAlignments(&(*gemGeometry), - &(*gemAlignments), - &(*gemAlignmentErrorsExtended), - align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); + aligner.applyAlignments(dtGeometry_, + dtAlignments_, + dtAlignmentErrorsExtended_, + align::DetectorGlobalPosition(*globalPositionRcd_, DetId(DetId::Muon))); + aligner.applyAlignments(cscGeometry_, + cscAlignments_, + cscAlignmentErrorsExtended_, + align::DetectorGlobalPosition(*globalPositionRcd_, DetId(DetId::Muon))); + aligner.applyAlignments(gemGeometry_, + gemAlignments_, + gemAlignmentErrorsExtended_, + align::DetectorGlobalPosition(*globalPositionRcd_, DetId(DetId::Muon))); } else { AlignmentErrorsExtended dtAlignmentErrorsExtended2, cscAlignmentErrorsExtended2, gemAlignmentErrorsExtended2; - for (std::vector::const_iterator i = dtAlignments->m_align.begin(); - i != dtAlignments->m_align.end(); + for (std::vector::const_iterator i = dtAlignments_->m_align.begin(); + i != dtAlignments_->m_align.end(); ++i) { CLHEP::HepSymMatrix empty_matrix(3, 0); AlignTransformErrorExtended empty_error(empty_matrix, i->rawId()); dtAlignmentErrorsExtended2.m_alignError.push_back(empty_error); } - for (std::vector::const_iterator i = cscAlignments->m_align.begin(); - i != cscAlignments->m_align.end(); + for (std::vector::const_iterator i = cscAlignments_->m_align.begin(); + i != cscAlignments_->m_align.end(); ++i) { CLHEP::HepSymMatrix empty_matrix(3, 0); AlignTransformErrorExtended empty_error(empty_matrix, i->rawId()); cscAlignmentErrorsExtended2.m_alignError.push_back(empty_error); } - for (std::vector::const_iterator i = gemAlignments->m_align.begin(); - i != gemAlignments->m_align.end(); + for (std::vector::const_iterator i = gemAlignments_->m_align.begin(); + i != gemAlignments_->m_align.end(); ++i) { CLHEP::HepSymMatrix empty_matrix(3, 0); AlignTransformErrorExtended empty_error(empty_matrix, i->rawId()); @@ -137,21 +139,21 @@ AlignableMuon* MuonAlignmentInputDB::newAlignableMuon(const edm::EventSetup& iSe } GeometryAligner aligner; - aligner.applyAlignments(&(*dtGeometry), - &(*dtAlignments), - &(dtAlignmentErrorsExtended2), - align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); - aligner.applyAlignments(&(*cscGeometry), - &(*cscAlignments), - &(cscAlignmentErrorsExtended2), - align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); - aligner.applyAlignments(&(*gemGeometry), - &(*gemAlignments), - &(gemAlignmentErrorsExtended2), - align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); + aligner.applyAlignments(dtGeometry_, + dtAlignments_, + &dtAlignmentErrorsExtended2, + align::DetectorGlobalPosition(*globalPositionRcd_, DetId(DetId::Muon))); + aligner.applyAlignments(cscGeometry_, + cscAlignments_, + &cscAlignmentErrorsExtended2, + align::DetectorGlobalPosition(*globalPositionRcd_, DetId(DetId::Muon))); + aligner.applyAlignments(gemGeometry_, + gemAlignments_, + &gemAlignmentErrorsExtended2, + align::DetectorGlobalPosition(*globalPositionRcd_, DetId(DetId::Muon))); } - return new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); + return new AlignableMuon(dtGeometry_, cscGeometry_, gemGeometry_); } // diff --git a/Alignment/MuonAlignment/src/MuonAlignmentInputMethod.cc b/Alignment/MuonAlignment/src/MuonAlignmentInputMethod.cc index 903baa50cc933..d087ad67b9b84 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentInputMethod.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentInputMethod.cc @@ -33,8 +33,11 @@ // // constructors and destructor // -MuonAlignmentInputMethod::MuonAlignmentInputMethod() : idealGeometryLabel("idealForInputMethod") {} -MuonAlignmentInputMethod::MuonAlignmentInputMethod(std::string idealLabel) : idealGeometryLabel(idealLabel) {} +MuonAlignmentInputMethod::MuonAlignmentInputMethod() {} +MuonAlignmentInputMethod::MuonAlignmentInputMethod(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry) + : dtGeometry_(dtGeometry), cscGeometry_(cscGeometry), gemGeometry_(gemGeometry) {} // MuonAlignmentInputMethod::MuonAlignmentInputMethod(const MuonAlignmentInputMethod& rhs) // { @@ -59,14 +62,8 @@ MuonAlignmentInputMethod::~MuonAlignmentInputMethod() {} // member functions // -AlignableMuon* MuonAlignmentInputMethod::newAlignableMuon(const edm::EventSetup& iSetup) const { - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - iSetup.get().get(idealGeometryLabel, dtGeometry); - iSetup.get().get(idealGeometryLabel, cscGeometry); - iSetup.get().get(idealGeometryLabel, gemGeometry); - return new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); +AlignableMuon* MuonAlignmentInputMethod::newAlignableMuon() const { + return new AlignableMuon(&*dtGeometry_, &*cscGeometry_, &*gemGeometry_); } // diff --git a/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc b/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc index eb0dacf2e2916..51184da7bd9af 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc @@ -34,18 +34,25 @@ // // constructors and destructor // -MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB() - : m_dtLabel(""), m_cscLabel(""), idealGeometryLabel("idealForInputSurveyDB") {} - -MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(std::string dtLabel, - std::string cscLabel, - std::string idealLabel) - : m_dtLabel(dtLabel), m_cscLabel(cscLabel), idealGeometryLabel(idealLabel) {} +MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(const DTGeometry* DTGeometry, + const CSCGeometry* CSCGeometry, + const GEMGeometry* GEMGeometry, + const Alignments* dtSurvey, + const Alignments* cscSurvey, + const SurveyErrors* dtSurveyError, + const SurveyErrors* cscSurveyError) + : dtGeometry_(DTGeometry), + cscGeometry_(CSCGeometry), + gemGeometry_(GEMGeometry), + dtSurvey_(dtSurvey), + cscSurvey_(cscSurvey), + dtSurveyError_(dtSurveyError), + cscSurveyError_(cscSurveyError) {} // MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(const MuonAlignmentInputSurveyDB& rhs) // { // // do actual copying here; -// } +// MuonAlignmentInputSurveyDB::~MuonAlignmentInputSurveyDB() {} @@ -65,36 +72,20 @@ MuonAlignmentInputSurveyDB::~MuonAlignmentInputSurveyDB() {} // member functions // -AlignableMuon* MuonAlignmentInputSurveyDB::newAlignableMuon(const edm::EventSetup& iSetup) const { - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - iSetup.get().get(idealGeometryLabel, dtGeometry); - iSetup.get().get(idealGeometryLabel, cscGeometry); - iSetup.get().get(idealGeometryLabel, gemGeometry); - - edm::ESHandle dtSurvey; - edm::ESHandle dtSurveyError; - edm::ESHandle cscSurvey; - edm::ESHandle cscSurveyError; - iSetup.get().get(m_dtLabel, dtSurvey); - iSetup.get().get(m_dtLabel, dtSurveyError); - iSetup.get().get(m_cscLabel, cscSurvey); - iSetup.get().get(m_cscLabel, cscSurveyError); - - AlignableMuon* output = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); +AlignableMuon* MuonAlignmentInputSurveyDB::newAlignableMuon() const { + AlignableMuon* output = new AlignableMuon(dtGeometry_, cscGeometry_, gemGeometry_); unsigned int theSurveyIndex = 0; - const Alignments* theSurveyValues = &*dtSurvey; - const SurveyErrors* theSurveyErrors = &*dtSurveyError; + const Alignments* theSurveyValues = dtSurvey_; + const SurveyErrors* theSurveyErrors = dtSurveyError_; const auto& barrels = output->DTBarrel(); for (const auto& iter : barrels) { addSurveyInfo_(iter, &theSurveyIndex, theSurveyValues, theSurveyErrors); } theSurveyIndex = 0; - theSurveyValues = &*cscSurvey; - theSurveyErrors = &*cscSurveyError; + theSurveyValues = cscSurvey_; + theSurveyErrors = cscSurveyError_; const auto& endcaps = output->CSCEndcaps(); for (const auto& iter : endcaps) { addSurveyInfo_(iter, &theSurveyIndex, theSurveyValues, theSurveyErrors); diff --git a/Alignment/MuonAlignment/src/MuonAlignmentInputXML.cc b/Alignment/MuonAlignment/src/MuonAlignmentInputXML.cc index 855317c929157..0aa9e0f16ab51 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentInputXML.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentInputXML.cc @@ -29,6 +29,7 @@ XERCES_CPP_NAMESPACE_USE #include "Alignment/CommonAlignment/interface/StructureType.h" #include "Alignment/CommonAlignment/interface/AlignableObjectId.h" #include "DataFormats/MuonDetId/interface/CSCDetId.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" #include "DataFormats/MuonDetId/interface/DTLayerId.h" #include "Alignment/CommonAlignment/interface/SurveyDet.h" #include "DataFormats/GeometryCommonDetAlgo/interface/AlignmentPositionError.h" @@ -45,8 +46,20 @@ XERCES_CPP_NAMESPACE_USE // // constructors and destructor // -MuonAlignmentInputXML::MuonAlignmentInputXML(const std::string &fileName, std::string idealLabel) - : m_fileName(fileName), idealGeometryLabel(idealLabel) { +MuonAlignmentInputXML::MuonAlignmentInputXML(const std::string &fileName, + const DTGeometry *dtGeometry, + const CSCGeometry *cscGeometry, + const GEMGeometry *gemGeometry, + const DTGeometry *dtGeometryIdeal, + const CSCGeometry *cscGeometryIdeal, + const GEMGeometry *gemGeometryIdeal) + : m_fileName(fileName), + dtGeometry_(dtGeometry), + cscGeometry_(cscGeometry), + gemGeometry_(gemGeometry), + dtGeometryIdeal_(dtGeometryIdeal), + cscGeometryIdeal_(cscGeometryIdeal), + gemGeometryIdeal_(gemGeometryIdeal) { cms::concurrency::xercesInitialize(); str_operation = XMLString::transcode("operation"); str_collection = XMLString::transcode("collection"); @@ -62,6 +75,12 @@ MuonAlignmentInputXML::MuonAlignmentInputXML(const std::string &fileName, std::s str_CSCRing = XMLString::transcode("CSCRing"); str_CSCChamber = XMLString::transcode("CSCChamber"); str_CSCLayer = XMLString::transcode("CSCLayer"); + str_GEMEndcap = XMLString::transcode("GEMEndcap"); + str_GEMStation = XMLString::transcode("GEMStation"); + str_GEMRing = XMLString::transcode("GEMRing"); + str_GEMSuperChamber = XMLString::transcode("GEMSuperChamber"); + str_GEMChamber = XMLString::transcode("GEMChamber"); + str_GEMEtaPartition = XMLString::transcode("GEMEtaPartition"); str_setposition = XMLString::transcode("setposition"); str_setape = XMLString::transcode("setape"); str_setsurveyerr = XMLString::transcode("setsurveyerr"); @@ -80,6 +99,8 @@ MuonAlignmentInputXML::MuonAlignmentInputXML(const std::string &fileName, std::s str_endcap = XMLString::transcode("endcap"); str_ring = XMLString::transcode("ring"); str_chamber = XMLString::transcode("chamber"); + str_superChamber = XMLString::transcode("SuperChamber"); + str_etaPartition = XMLString::transcode("etaPartition"); str_axisx = XMLString::transcode("axisx"); str_axisy = XMLString::transcode("axisy"); str_axisz = XMLString::transcode("axisz"); @@ -141,6 +162,12 @@ MuonAlignmentInputXML::~MuonAlignmentInputXML() { XMLString::release(&str_CSCRing); XMLString::release(&str_CSCChamber); XMLString::release(&str_CSCLayer); + XMLString::release(&str_GEMEndcap); + XMLString::release(&str_GEMStation); + XMLString::release(&str_GEMRing); + XMLString::release(&str_GEMSuperChamber); + XMLString::release(&str_GEMChamber); + XMLString::release(&str_GEMEtaPartition); XMLString::release(&str_setposition); XMLString::release(&str_setape); XMLString::release(&str_setsurveyerr); @@ -159,6 +186,8 @@ MuonAlignmentInputXML::~MuonAlignmentInputXML() { XMLString::release(&str_endcap); XMLString::release(&str_ring); XMLString::release(&str_chamber); + XMLString::release(&str_superChamber); + XMLString::release(&str_etaPartition); XMLString::release(&str_axisx); XMLString::release(&str_axisy); XMLString::release(&str_axisz); @@ -225,7 +254,10 @@ void MuonAlignmentInputXML::recursiveGetId(std::map & (*ali)->alignableObjectId() == align::AlignableDTSuperLayer || (*ali)->alignableObjectId() == align::AlignableDTLayer || (*ali)->alignableObjectId() == align::AlignableCSCChamber || - (*ali)->alignableObjectId() == align::AlignableCSCLayer) { + (*ali)->alignableObjectId() == align::AlignableCSCLayer || + (*ali)->alignableObjectId() == align::AlignableGEMSuperChamber || + (*ali)->alignableObjectId() == align::AlignableGEMChamber || + (*ali)->alignableObjectId() == align::AlignableGEMEtaPartition) { alignableNavigator[(*ali)->geomDetId().rawId()] = *ali; } recursiveGetId(alignableNavigator, (*ali)->components()); @@ -253,23 +285,18 @@ void MuonAlignmentInputXML::fillAliToIdeal(std::map &a } } -AlignableMuon *MuonAlignmentInputXML::newAlignableMuon(const edm::EventSetup &iSetup) const { - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - iSetup.get().get(idealGeometryLabel, dtGeometry); - iSetup.get().get(idealGeometryLabel, cscGeometry); - iSetup.get().get(idealGeometryLabel, gemGeometry); - - AlignableMuon *alignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); +AlignableMuon *MuonAlignmentInputXML::newAlignableMuon() const { + AlignableMuon *alignableMuon = new AlignableMuon(dtGeometry_, cscGeometry_, gemGeometry_); std::map alignableNavigator; // real AlignableNavigators don't have const methods recursiveGetId(alignableNavigator, alignableMuon->DTBarrel()); recursiveGetId(alignableNavigator, alignableMuon->CSCEndcaps()); + recursiveGetId(alignableNavigator, alignableMuon->GEMEndcaps()); - AlignableMuon *ideal_alignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); + AlignableMuon *ideal_alignableMuon = new AlignableMuon(dtGeometryIdeal_, cscGeometryIdeal_, gemGeometryIdeal_); std::map ideal_alignableNavigator; // real AlignableNavigators don't have const methods recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->DTBarrel()); recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->CSCEndcaps()); + recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->GEMEndcaps()); try { cms::concurrency::xercesInitialize(); @@ -304,6 +331,7 @@ AlignableMuon *MuonAlignmentInputXML::newAlignableMuon(const edm::EventSetup &iS std::map alitoideal; fillAliToIdeal(alitoideal, alignableMuon->DTBarrel(), ideal_alignableMuon->DTBarrel()); fillAliToIdeal(alitoideal, alignableMuon->CSCEndcaps(), ideal_alignableMuon->CSCEndcaps()); + fillAliToIdeal(alitoideal, alignableMuon->GEMEndcaps(), ideal_alignableMuon->GEMEndcaps()); const auto &alignableObjectId = alignableMuon->objectIdProvider(); std::map > alicollections; @@ -473,6 +501,18 @@ Alignable *MuonAlignmentInputXML::getNode(std::map &a return getCSCnode(align::AlignableCSCChamber, alignableNavigator, node, alignableObjectId); else if (XMLString::equals(node->getNodeName(), str_CSCLayer)) return getCSCnode(align::AlignableDetUnit, alignableNavigator, node, alignableObjectId); + else if (XMLString::equals(node->getNodeName(), str_GEMEndcap)) + return getGEMnode(align::AlignableGEMEndcap, alignableNavigator, node, alignableObjectId); + else if (XMLString::equals(node->getNodeName(), str_GEMStation)) + return getGEMnode(align::AlignableGEMStation, alignableNavigator, node, alignableObjectId); + else if (XMLString::equals(node->getNodeName(), str_GEMRing)) + return getGEMnode(align::AlignableGEMRing, alignableNavigator, node, alignableObjectId); + else if (XMLString::equals(node->getNodeName(), str_GEMSuperChamber)) + return getGEMnode(align::AlignableGEMSuperChamber, alignableNavigator, node, alignableObjectId); + else if (XMLString::equals(node->getNodeName(), str_GEMChamber)) + return getGEMnode(align::AlignableGEMChamber, alignableNavigator, node, alignableObjectId); + else if (XMLString::equals(node->getNodeName(), str_GEMEtaPartition)) + return getGEMnode(align::AlignableDetUnit, alignableNavigator, node, alignableObjectId); else return nullptr; } @@ -662,6 +702,97 @@ Alignable *MuonAlignmentInputXML::getCSCnode(align::StructureType structureType, return ali; } +Alignable *MuonAlignmentInputXML::getGEMnode(align::StructureType structureType, + std::map &alignableNavigator, + const XERCES_CPP_NAMESPACE::DOMElement *node, + const AlignableObjectId &alignableObjectId) const { + unsigned int rawId; + + DOMAttr *node_rawId = node->getAttributeNode(str_rawId); + if (node_rawId != nullptr) { + try { + rawId = XMLString::parseInt(node_rawId->getValue()); + } catch (const XMLException &toCatch) { + throw cms::Exception("XMLException") << "Value of \"rawId\" must be an integer" << std::endl; + } + } else { + int endcap, station, ring, superChamber, chamber; + endcap = station = ring = superChamber = chamber = 1; + + DOMAttr *node_endcap = node->getAttributeNode(str_endcap); + if (node_endcap == nullptr) + throw cms::Exception("XMLException") << "GEM node is missing required \"endcap\" attribute" << std::endl; + try { + endcap = XMLString::parseInt(node_endcap->getValue()); + } catch (const XMLException &toCatch) { + throw cms::Exception("XMLException") << "Value of \"endcap\" must be an integer" << std::endl; + } + + if (structureType != align::AlignableGEMEndcap) { + DOMAttr *node_station = node->getAttributeNode(str_station); + if (node_station == nullptr) + throw cms::Exception("XMLException") << "GEM node is missing required \"station\" attribute" << std::endl; + try { + station = XMLString::parseInt(node_station->getValue()); + } catch (const XMLException &toCatch) { + throw cms::Exception("XMLException") << "Value of \"station\" must be an integer" << std::endl; + } + + if (structureType != align::AlignableGEMStation) { + DOMAttr *node_ring = node->getAttributeNode(str_ring); + if (node_ring == nullptr) + throw cms::Exception("XMLException") << "GEM node is missing required \"ring\" attribute" << std::endl; + try { + ring = XMLString::parseInt(node_ring->getValue()); + } catch (const XMLException &toCatch) { + throw cms::Exception("XMLException") << "Value of \"ring\" must be an integer" << std::endl; + } + + if (structureType != align::AlignableGEMRing) { + DOMAttr *node_superChamber = node->getAttributeNode(str_chamber); + if (node_superChamber == nullptr) + throw cms::Exception("XMLException") + << "GEM node is missing required \"superChamber\" attribute" << std::endl; + try { + superChamber = XMLString::parseInt(node_superChamber->getValue()); + } catch (const XMLException &toCatch) { + throw cms::Exception("XMLException") << "Value of \"superChamber\" must be an integer" << std::endl; + } + + if (structureType != align::AlignableGEMSuperChamber) { + DOMAttr *node_chamber = node->getAttributeNode(str_chamber); + if (node_chamber == nullptr) + throw cms::Exception("XMLException") << "GEM node is missing required \"chamber\" attribute" << std::endl; + try { + chamber = XMLString::parseInt(node_chamber->getValue()); + } catch (const XMLException &toCatch) { + throw cms::Exception("XMLException") << "Value of \"chamber\" must be an integer" << std::endl; + } + + } // end if we need a layer number + } // end if we need a chamber number + } // end if we need a ring number + } // end if we need a station number + + GEMDetId chamberId(endcap, station, ring, 0, chamber, 0); + rawId = chamberId.rawId(); + } // end if it's specified by endcap, station, ring, chamber, layer + + Alignable *ali = alignableNavigator[rawId]; + if (ali == nullptr) + throw cms::Exception("XMLException") << "rawId \"" << rawId << "\" is not recognized" << std::endl; + + while (ali->alignableObjectId() != structureType) { + ali = ali->mother(); + + if (ali == nullptr) { + throw cms::Exception("XMLException") + << "rawId \"" << rawId << "\" is not a " << alignableObjectId.idToString(structureType) << std::endl; + } + } + return ali; +} + double MuonAlignmentInputXML::parseDouble(const XMLCh *str, const char *attribute) const { unsigned int len = XMLString::stringLen(str); char *cstr = XMLString::transcode(str); diff --git a/Alignment/MuonAlignment/src/MuonAlignmentOutputXML.cc b/Alignment/MuonAlignment/src/MuonAlignmentOutputXML.cc index df148df1efc7e..cdcdd656551a6 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentOutputXML.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentOutputXML.cc @@ -39,7 +39,10 @@ // // constructors and destructor // -MuonAlignmentOutputXML::MuonAlignmentOutputXML(const edm::ParameterSet &iConfig) +MuonAlignmentOutputXML::MuonAlignmentOutputXML(const edm::ParameterSet &iConfig, + const DTGeometry *dtGeometry, + const CSCGeometry *cscGeometry, + const GEMGeometry *gemGeometry) : m_fileName(iConfig.getParameter("fileName")), m_survey(iConfig.getParameter("survey")), m_rawIds(iConfig.getParameter("rawIds")), @@ -56,7 +59,15 @@ MuonAlignmentOutputXML::MuonAlignmentOutputXML(const edm::ParameterSet &iConfig) m_suppressCSCRings(iConfig.getUntrackedParameter("suppressCSCRings", false)), m_suppressCSCChambers(iConfig.getUntrackedParameter("suppressCSCChambers", false)), m_suppressCSCLayers(iConfig.getUntrackedParameter("suppressCSCLayers", false)), - idealGeometryLabel("idealForOutputXML") { + m_suppressGEMEndcaps(iConfig.getUntrackedParameter("suppressGEMEndcaps", false)), + m_suppressGEMStations(iConfig.getUntrackedParameter("suppressGEMStations", false)), + m_suppressGEMRings(iConfig.getUntrackedParameter("suppressGEMRings", false)), + m_suppressGEMSuperChambers(iConfig.getUntrackedParameter("suppressGEMSuperChambers", false)), + m_suppressGEMChambers(iConfig.getUntrackedParameter("suppressGEMChambers", false)), + m_suppressGEMEtaPartitions(iConfig.getUntrackedParameter("suppressGEMEtaPartitions", false)), + dtGeometry_(dtGeometry), + cscGeometry_(cscGeometry), + gemGeometry_(gemGeometry) { std::string str_relativeto = iConfig.getParameter("relativeto"); if (str_relativeto == std::string("none")) { @@ -93,7 +104,7 @@ MuonAlignmentOutputXML::~MuonAlignmentOutputXML() {} // member functions // -void MuonAlignmentOutputXML::write(AlignableMuon *alignableMuon, const edm::EventSetup &iSetup) const { +void MuonAlignmentOutputXML::write(AlignableMuon *alignableMuon) const { std::ofstream outputFile(m_fileName.c_str()); outputFile << std::setprecision(m_precision) << std::fixed; @@ -104,6 +115,7 @@ void MuonAlignmentOutputXML::write(AlignableMuon *alignableMuon, const edm::Even std::map errors; AlignmentErrorsExtended *dtErrors = alignableMuon->dtAlignmentErrorsExtended(); AlignmentErrorsExtended *cscErrors = alignableMuon->cscAlignmentErrorsExtended(); + AlignmentErrorsExtended *gemErrors = alignableMuon->gemAlignmentErrorsExtended(); for (std::vector::const_iterator dtError = dtErrors->m_alignError.begin(); dtError != dtErrors->m_alignError.end(); ++dtError) { @@ -114,30 +126,32 @@ void MuonAlignmentOutputXML::write(AlignableMuon *alignableMuon, const edm::Even ++cscError) { errors[cscError->rawId()] = cscError->matrix(); } + for (std::vector::const_iterator gemError = gemErrors->m_alignError.begin(); + gemError != gemErrors->m_alignError.end(); + ++gemError) { + errors[gemError->rawId()] = gemError->matrix(); + } align::Alignables barrels = alignableMuon->DTBarrel(); align::Alignables endcaps = alignableMuon->CSCEndcaps(); + align::Alignables endcaps_GEM = alignableMuon->GEMEndcaps(); if (m_relativeto == 1) { - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - iSetup.get().get(idealGeometryLabel, dtGeometry); - iSetup.get().get(idealGeometryLabel, cscGeometry); - iSetup.get().get(idealGeometryLabel, gemGeometry); - - AlignableMuon ideal_alignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); + AlignableMuon ideal_alignableMuon(dtGeometry_, cscGeometry_, gemGeometry_); align::Alignables ideal_barrels = ideal_alignableMuon.DTBarrel(); align::Alignables ideal_endcaps = ideal_alignableMuon.CSCEndcaps(); + align::Alignables ideal_endcaps_GEM = ideal_alignableMuon.GEMEndcaps(); - writeComponents(barrels, ideal_barrels, errors, outputFile, true, alignableMuon->objectIdProvider()); - writeComponents(endcaps, ideal_endcaps, errors, outputFile, false, alignableMuon->objectIdProvider()); + writeComponents(barrels, ideal_barrels, errors, outputFile, doDT, alignableMuon->objectIdProvider()); + writeComponents(endcaps, ideal_endcaps, errors, outputFile, doCSC, alignableMuon->objectIdProvider()); + writeComponents(endcaps_GEM, ideal_endcaps_GEM, errors, outputFile, doGEM, alignableMuon->objectIdProvider()); } else { - align::Alignables empty1, empty2; + align::Alignables empty1, empty2, empty3; - writeComponents(barrels, empty1, errors, outputFile, true, alignableMuon->objectIdProvider()); - writeComponents(endcaps, empty2, errors, outputFile, false, alignableMuon->objectIdProvider()); + writeComponents(barrels, empty1, errors, outputFile, doDT, alignableMuon->objectIdProvider()); + writeComponents(endcaps, empty2, errors, outputFile, doCSC, alignableMuon->objectIdProvider()); + writeComponents(endcaps_GEM, empty3, errors, outputFile, doGEM, alignableMuon->objectIdProvider()); } outputFile << "" << std::endl; @@ -147,13 +161,13 @@ void MuonAlignmentOutputXML::writeComponents(align::Alignables &alignables, align::Alignables &ideals, std::map &errors, std::ofstream &outputFile, - bool DT, + const int doDet, const AlignableObjectId &objectIdProvider) const { align::Alignables::const_iterator ideal = ideals.begin(); for (align::Alignables::const_iterator alignable = alignables.begin(); alignable != alignables.end(); ++alignable) { if (m_survey && (*alignable)->survey() == nullptr) { throw cms::Exception("Alignment") << "SurveyDets must all be defined when writing to XML" << std::endl; - } // now I can assume it's okay everywhere + } align::StructureType alignableObjectId = (*alignable)->alignableObjectId(); @@ -161,17 +175,26 @@ void MuonAlignmentOutputXML::writeComponents(align::Alignables &alignables, (alignableObjectId == align::AlignableDTWheel && !m_suppressDTWheels) || (alignableObjectId == align::AlignableDTStation && !m_suppressDTStations) || (alignableObjectId == align::AlignableDTChamber && !m_suppressDTChambers) || - (DT && alignableObjectId == align::AlignableDTSuperLayer && !m_suppressDTSuperLayers) || - (DT && alignableObjectId == align::AlignableDetUnit && !m_suppressDTLayers) || + (doDet == doDT && alignableObjectId == align::AlignableDTSuperLayer && !m_suppressDTSuperLayers) || + (doDet == doDT && alignableObjectId == align::AlignableDetUnit && !m_suppressDTLayers) || (alignableObjectId == align::AlignableCSCEndcap && !m_suppressCSCEndcaps) || (alignableObjectId == align::AlignableCSCStation && !m_suppressCSCStations) || (alignableObjectId == align::AlignableCSCRing && !m_suppressCSCRings) || (alignableObjectId == align::AlignableCSCChamber && !m_suppressCSCChambers) || - (!DT && alignableObjectId == align::AlignableDetUnit && !m_suppressCSCLayers)) { + (alignableObjectId == align::AlignableGEMEndcap && !m_suppressGEMEndcaps) || + (alignableObjectId == align::AlignableGEMStation && !m_suppressGEMStations) || + (alignableObjectId == align::AlignableGEMRing && !m_suppressGEMRings) || + (alignableObjectId == align::AlignableGEMSuperChamber && !m_suppressGEMSuperChambers) || + (alignableObjectId == align::AlignableGEMChamber && !m_suppressGEMChambers) || + (alignableObjectId == align::AlignableGEMEtaPartition && !m_suppressGEMEtaPartitions) || + (doDet != doDT && doDet != doGEM && doDet == doCSC && alignableObjectId == align::AlignableDetUnit && + !m_suppressCSCLayers) || + (doDet != doDT && doDet != doCSC && doDet == doGEM && alignableObjectId == align::AlignableDetUnit && + !m_suppressGEMEtaPartitions)) { unsigned int rawId = (*alignable)->geomDetId().rawId(); outputFile << "" << std::endl; - if (DT) { + if (doDet == doDT) { if (m_rawIds && rawId != 0) { std::string typeName = objectIdProvider.idToString(alignableObjectId); if (alignableObjectId == align::AlignableDTSuperLayer) @@ -193,9 +216,7 @@ void MuonAlignmentOutputXML::writeComponents(align::Alignables &alignables, DTChamberId id(rawId); outputFile << " " << std::endl; - } - - else { + } else { DTChamberId id((*alignable)->id()); if (alignableObjectId == align::AlignableDTStation) { outputFile << " " @@ -211,7 +232,7 @@ void MuonAlignmentOutputXML::writeComponents(align::Alignables &alignables, } // end if not rawId } // end if DT - else { // CSC + if (doDet == doCSC) { // CSC if (m_rawIds && rawId != 0) { std::string typeName = objectIdProvider.idToString(alignableObjectId); if (alignableObjectId == align::AlignableDetUnit) @@ -244,6 +265,39 @@ void MuonAlignmentOutputXML::writeComponents(align::Alignables &alignables, } // end if not rawId } // end if CSC + if (doDet == doGEM) { // GEM + if (m_rawIds && rawId != 0) { + std::string typeName = objectIdProvider.idToString(alignableObjectId); + if (alignableObjectId == align::AlignableDetUnit) + typeName = std::string("GEMChambers"); + outputFile << " <" << typeName << " rawId=\"" << rawId << "\" />" << std::endl; + } else { + if (alignableObjectId == align::AlignableDetUnit) { + GEMDetId id(rawId); + outputFile << " " << std::endl; + } else if (alignableObjectId == align::AlignableGEMSuperChamber) { + GEMDetId id(rawId); + outputFile << " " << std::endl; + } else { + GEMDetId id((*alignable)->id()); + if (alignableObjectId == align::AlignableGEMRing) { + outputFile << " " << std::endl; + } else if (alignableObjectId == align::AlignableGEMStation) { + outputFile << " " + << std::endl; + } else if (alignableObjectId == align::AlignableGEMEndcap) { + outputFile << " " << std::endl; + } else + throw cms::Exception("Alignment") << "Unknown GEM Alignable StructureType" << std::endl; + } + + } // end if not rawId + } // end if GEM + align::PositionType pos = (*alignable)->globalPosition(); align::RotationType rot = (*alignable)->globalRotation(); @@ -272,7 +326,7 @@ void MuonAlignmentOutputXML::writeComponents(align::Alignables &alignables, str_relativeto = std::string("ideal"); bool csc_debug = false; - if (csc_debug && !DT) { + if (csc_debug && doDet == doCSC) { CSCDetId id(rawId); if (id.endcap() == 1 && id.station() == 1 && id.ring() == 1 && id.chamber() == 33) { std::cout << " investigating " << id << std::endl @@ -325,7 +379,7 @@ void MuonAlignmentOutputXML::writeComponents(align::Alignables &alignables, else { // the angle convention originally used in alignment, also known as "non-standard Euler angles with a Z-Y-X convention" - // this also gets the sign convention right + // // this also gets the sign convention right double phix = atan2(rot.yz(), rot.zz()); double phiy = asin(-rot.xz()); double phiz = atan2(rot.xy(), rot.xx()); @@ -366,14 +420,13 @@ void MuonAlignmentOutputXML::writeComponents(align::Alignables &alignables, if (ideal != ideals.end()) { align::Alignables components = (*alignable)->components(); align::Alignables ideal_components = (*ideal)->components(); - writeComponents(components, ideal_components, errors, outputFile, DT, objectIdProvider); + writeComponents(components, ideal_components, errors, outputFile, doDet, objectIdProvider); ++ideal; // important for synchronization in the "for" loop! } else { align::Alignables components = (*alignable)->components(); align::Alignables dummy; - writeComponents(components, dummy, errors, outputFile, DT, objectIdProvider); + writeComponents(components, dummy, errors, outputFile, doDet, objectIdProvider); } - } // end loop over alignables } diff --git a/Alignment/MuonAlignment/test/TestAlign.cpp b/Alignment/MuonAlignment/test/TestAlign.cpp deleted file mode 100644 index 9261be996bd66..0000000000000 --- a/Alignment/MuonAlignment/test/TestAlign.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// -*- C++ -*- -// -// Package: TestAlign -// Class: TestAlign -// -// -// Description: Module to test the Alignment software -// -// -// system include files -#include - -// user include files -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "Alignment/MuonAlignment/interface/MuonAlignment.h" -#include "Alignment/MuonAlignment/interface/AlignableMuon.h" - -#include "DataFormats/GeometrySurface/interface/Surface.h" - -#include - -// -// -// class declaration -// - -class TestAlign : public edm::EDAnalyzer { -public: - explicit TestAlign(const edm::ParameterSet&); - - virtual ~TestAlign(); - - virtual void analyze(const edm::Event&, const edm::EventSetup&); - -private: - //typedef Surface::RotationType RotationType; - //typedef Surface::PositionType PositionType; -}; - -// -// constructors and destructor -// -TestAlign::TestAlign(const edm::ParameterSet& iConfig) { edm::LogInfo("MuonAlignment") << "Starting!"; } - -TestAlign::~TestAlign() { edm::LogInfo("MuonAlignment") << "Ending!"; } - -void TestAlign::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { - // Instantiate the helper class - MuonAlignment align(iSetup); - - // Get the AlignableMuon pointer - AlignableMuon* theAlignableMuon = align.getAlignableMuon(); - - // Apply alignment - std::vector displacement; - displacement.push_back(1.0); - displacement.push_back(0.0); - displacement.push_back(0.0); - - std::vector rotation; - rotation.push_back(0.0); - rotation.push_back(0.0); - rotation.push_back(1.64); - - // Loop over DT chamber to apply alignment corrections - for (const auto& iter : theAlignableMuon->DTChambers()) { - // Print inital position/orientation - align::GlobalPoint pos_i = iter->globalPosition(); - align::RotationType dir_i = iter->globalRotation(); - - std::cout << "Initial pos: x=" << pos_i.x() << ", y=" << pos_i.y() << ", z=" << pos_i.z() << std::endl; - std::cout << "Initial ori: x=" << dir_i.xx() << ", y=" << dir_i.yy() << ", z=" << dir_i.zz() << std::endl; - - // Move DT chamber - DetId detid = iter->geomDetId(); - align.moveAlignableGlobalCoord(detid, displacement, rotation); - - // Print final position/orientation - align::GlobalPoint pos_f = iter->globalPosition(); - align::RotationType dir_f = iter->globalRotation(); - - std::cout << "Final pos: x=" << pos_f.x() << ", y=" << pos_f.y() << ", z=" << pos_f.z() << std::endl; - std::cout << "Final ori: x=" << dir_f.xx() << ", y=" << dir_f.yy() << ", z=" << dir_f.zz() << std::endl; - std::cout << "------------------------" << std::endl; - } - - // Saves to DB - // align.saveToDB(); -} -//define this as a plug-in -DEFINE_FWK_MODULE(TestAlign); diff --git a/Alignment/MuonAlignment/test/muonGeometryDBConverter_cfg.py b/Alignment/MuonAlignment/test/muonGeometryDBConverter_cfg.py index c3aa0073be6eb..b5add71845553 100644 --- a/Alignment/MuonAlignment/test/muonGeometryDBConverter_cfg.py +++ b/Alignment/MuonAlignment/test/muonGeometryDBConverter_cfg.py @@ -34,124 +34,38 @@ process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") process.load("Alignment.MuonAlignment.muonGeometryDBConverter_cfi") -process.DTGeometryAlInputMethod = cms.ESProducer("DTGeometryESModule", - appendToDataLabel = cms.string('idealForInputMethod'), - applyAlignment = cms.bool(False), - alignmentsLabel = cms.string(''), - fromDDD = cms.bool(True) -) - -process.CSCGeometryAlInputMethod = cms.ESProducer("CSCGeometryESModule", - appendToDataLabel = cms.string('idealForInputMethod'), - debugV = cms.untracked.bool(False), - useGangedStripsInME1a = cms.bool(False), - alignmentsLabel = cms.string(''), - useOnlyWiresInME1a = cms.bool(False), - useRealWireGeometry = cms.bool(True), - useCentreTIOffsets = cms.bool(False), - applyAlignment = cms.bool(False), - fromDDD = cms.bool(True), - fromDD4hep = cms.bool(False) -) - -process.GEMGeometryAlInputMethod = cms.ESProducer("GEMGeometryESModule", - appendToDataLabel = cms.string('idealForInputMethod'), - fromDDD = cms.bool(True), - fromDD4Hep = cms.bool(False), - alignmentsLabel = cms.string(''), - applyAlignment = cms.bool(False) -) - -process.DTGeometryAlInputDB = cms.ESProducer("DTGeometryESModule", - appendToDataLabel = cms.string('idealForInputDB'), - applyAlignment = cms.bool(False), - alignmentsLabel = cms.string(''), - fromDDD = cms.bool(True) -) - -process.CSCGeometryAlInputDB = cms.ESProducer("CSCGeometryESModule", - appendToDataLabel = cms.string('idealForInputDB'), - debugV = cms.untracked.bool(False), - useGangedStripsInME1a = cms.bool(False), - alignmentsLabel = cms.string(''), - useOnlyWiresInME1a = cms.bool(False), - useRealWireGeometry = cms.bool(True), - useCentreTIOffsets = cms.bool(False), - applyAlignment = cms.bool(False), - fromDDD = cms.bool(True), - fromDD4hep = cms.bool(False) -) - -process.GEMGeometryAlInputDB = cms.ESProducer("GEMGeometryESModule", - appendToDataLabel = cms.string('idealForInputDB'), - fromDDD = cms.bool(True), - fromDD4Hep = cms.bool(False), - alignmentsLabel = cms.string(''), - applyAlignment = cms.bool(False) -) - -process.DTGeometryAlOutputXML = cms.ESProducer("DTGeometryESModule", - appendToDataLabel = cms.string('idealForOutputXML'), - applyAlignment = cms.bool(False), - alignmentsLabel = cms.string(''), - fromDDD = cms.bool(True) -) - -process.CSCGeometryAlOutputXML = cms.ESProducer("CSCGeometryESModule", - appendToDataLabel = cms.string('idealForOutputXML'), - debugV = cms.untracked.bool(False), - useGangedStripsInME1a = cms.bool(False), - alignmentsLabel = cms.string(''), - useOnlyWiresInME1a = cms.bool(False), - useRealWireGeometry = cms.bool(True), - useCentreTIOffsets = cms.bool(False), - applyAlignment = cms.bool(False), - fromDDD = cms.bool(True), - fromDD4hep = cms.bool(False) -) - -process.GEMGeometryAlOutputXML = cms.ESProducer("GEMGeometryESModule", - appendToDataLabel = cms.string('idealForOutputXML'), - fromDDD = cms.bool(True), - fromDD4Hep = cms.bool(False), - alignmentsLabel = cms.string(''), - applyAlignment = cms.bool(False) -) - -process.DTGeometryAlInputXML = cms.ESProducer("DTGeometryESModule", - appendToDataLabel = cms.string('idealForInputXML'), - applyAlignment = cms.bool(False), - alignmentsLabel = cms.string(''), - fromDDD = cms.bool(True) -) - -process.CSCGeometryAlInputXML = cms.ESProducer("CSCGeometryESModule", - appendToDataLabel = cms.string('idealForInputXML'), - debugV = cms.untracked.bool(False), - useGangedStripsInME1a = cms.bool(False), - alignmentsLabel = cms.string(''), - useOnlyWiresInME1a = cms.bool(False), - useRealWireGeometry = cms.bool(True), - useCentreTIOffsets = cms.bool(False), - applyAlignment = cms.bool(False), - fromDDD = cms.bool(True), - fromDD4hep = cms.bool(False) -) - -process.GEMGeometryAlInputXML = cms.ESProducer("GEMGeometryESModule", - appendToDataLabel = cms.string('idealForInputXML'), - fromDDD = cms.bool(True), - fromDD4Hep = cms.bool(False), - alignmentsLabel = cms.string(''), - applyAlignment = cms.bool(False) -) ################################################################################ # parameters to configure: from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, "auto:phase1_2017_design") +process.GlobalTag = GlobalTag(process.GlobalTag, "auto:phase1_2021_design") process.muonGeometryDBConverter.input = options.input process.muonGeometryDBConverter.output = options.output + +import Geometry.DTGeometryBuilder.dtGeometryDB_cfi +import Geometry.CSCGeometryBuilder.cscGeometryDB_cfi +import Geometry.GEMGeometryBuilder.gemGeometryDB_cfi +process.DTGeometryIdeal = Geometry.DTGeometryBuilder.dtGeometryDB_cfi.DTGeometryESModule.clone() +process.DTGeometryIdeal.appendToDataLabel = 'idealGeometry' +process.DTGeometryIdeal.applyAlignment = cms.bool(False) +process.CSCGeometryIdeal = Geometry.CSCGeometryBuilder.cscGeometryDB_cfi.CSCGeometryESModule.clone() +process.CSCGeometryIdeal.appendToDataLabel = 'idealGeometry' +process.CSCGeometryIdeal.applyAlignment = cms.bool(False) +process.GEMGeometryIdeal = Geometry.GEMGeometryBuilder.gemGeometryDB_cfi.GEMGeometryESModule.clone() +process.GEMGeometryIdeal.appendToDataLabel = 'idealGeometry' +process.GEMGeometryIdeal.applyAlignment = cms.bool(False) + +process.DTGeometryIdealForInputXML = Geometry.DTGeometryBuilder.dtGeometryDB_cfi.DTGeometryESModule.clone() +process.DTGeometryIdealForInputXML.appendToDataLabel = 'idealForInputXML' +process.DTGeometryIdealForInputXML.applyAlignment = cms.bool(False) +process.CSCGeometryIdealForInputXML = Geometry.CSCGeometryBuilder.cscGeometryDB_cfi.CSCGeometryESModule.clone() +process.CSCGeometryIdealForInputXML.appendToDataLabel = 'idealForInputXML' +process.CSCGeometryIdealForInputXML.applyAlignment = cms.bool(False) +process.GEMGeometryIdealForInputXML = Geometry.GEMGeometryBuilder.gemGeometryDB_cfi.GEMGeometryESModule.clone() +process.GEMGeometryIdealForInputXML.appendToDataLabel = 'idealForInputXML' +process.GEMGeometryIdealForInputXML.applyAlignment = cms.bool(False) + + if options.input == "db": process.GlobalTag.toGet.extend( [cms.PSet(connect = cms.string("sqlite_file:"+options.inputFile), @@ -177,26 +91,36 @@ process.muonGeometryDBConverter.fileName = options.inputFile if options.output == "db": - from CondCore.CondDB.CondDB_cfi import CondDB - process.PoolDBOutputService = cms.Service( - "PoolDBOutputService", - CondDB, - toPut = cms.VPSet( - cms.PSet(record = cms.string("DTAlignmentRcd"), - tag = cms.string("DTAlignmentRcd")), - cms.PSet(record = cms.string("DTAlignmentErrorExtendedRcd"), - tag = cms.string("DTAlignmentErrorExtendedRcd")), - cms.PSet(record = cms.string("CSCAlignmentRcd"), - tag = cms.string("CSCAlignmentRcd")), - cms.PSet(record = cms.string("CSCAlignmentErrorExtendedRcd"), - tag = cms.string("CSCAlignmentErrorExtendedRcd")), - cms.PSet(record = cms.string("GEMAlignmentRcd"), - tag = cms.string("GEMAlignmentRcd")), - cms.PSet(record = cms.string("GEMAlignmentErrorExtendedRcd"), - tag = cms.string("GEMAlignmentErrorExtendedRcd")) - ) + from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup + process.PoolDBOutputService = cms.Service("PoolDBOutputService", + CondDBSetup, + toPut = cms.VPSet(cms.PSet( + record = cms.string('DTAlignmentRcd'), + tag = cms.string('DTAlignmentRcd') + ), + cms.PSet( + record = cms.string('DTAlignmentErrorExtendedRcd'), + tag = cms.string('DTAlignmentErrorExtendedRcd') + ), + cms.PSet( + record = cms.string('CSCAlignmentRcd'), + tag = cms.string('CSCAlignmentRcd') + ), + cms.PSet( + record = cms.string('CSCAlignmentErrorExtendedRcd'), + tag = cms.string('CSCAlignmentErrorExtendedRcd') + ), + cms.PSet( + record = cms.string('GEMAlignmentRcd'), + tag = cms.string('GEMAlignmentRcd') + ), + cms.PSet( + record = cms.string('GEMAlignmentErrorExtendedRcd'), + tag = cms.string('GEMAlignmentErrorExtendedRcd') + )), + + connect = cms.string('sqlite_file:'+options.outputFile) ) - process.PoolDBOutputService.connect = "sqlite_file:"+options.outputFile elif options.output == "xml": process.muonGeometryDBConverter.outputXML.fileName = options.outputFile process.muonGeometryDBConverter.outputXML.suppressDTSuperLayers = True diff --git a/Alignment/MuonAlignment/test/test_MuonGeometryDBConverter.sh b/Alignment/MuonAlignment/test/test_MuonGeometryDBConverter.sh index 6812688034544..f7144de166356 100755 --- a/Alignment/MuonAlignment/test/test_MuonGeometryDBConverter.sh +++ b/Alignment/MuonAlignment/test/test_MuonGeometryDBConverter.sh @@ -18,6 +18,5 @@ mkdir -p ${TEST_DIR} check_for_success cmsRun ${TEST_CFG} input=ideal output=db outputFile=${TEST_DIR}/ideal.db check_for_success cmsRun ${TEST_CFG} input=db output=xml inputFile=${TEST_DIR}/ideal.db outputFile=${TEST_DIR}/ideal.xml -check_for_success cmsRun ${TEST_CFG} input=xml output=none inputFile=${TEST_DIR}/ideal.xml - +check_for_success cmsRun ${TEST_CFG} input=xml output=db inputFile=${TEST_DIR}/ideal.xml outputFile=${TEST_DIR}/idealXML.db clean_up diff --git a/Alignment/MuonAlignmentAlgorithms/interface/SegmentToTrackAssociator.h b/Alignment/MuonAlignmentAlgorithms/interface/SegmentToTrackAssociator.h index 88072b833d85b..f929407b367a0 100644 --- a/Alignment/MuonAlignmentAlgorithms/interface/SegmentToTrackAssociator.h +++ b/Alignment/MuonAlignmentAlgorithms/interface/SegmentToTrackAssociator.h @@ -19,6 +19,8 @@ #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "DataFormats/TrackReco/interface/Track.h" +#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h" namespace edm { class ParameterSet; @@ -31,7 +33,7 @@ class SegmentToTrackAssociator { typedef std::vector > intDVector; //constructor - SegmentToTrackAssociator(const edm::ParameterSet&); + SegmentToTrackAssociator(const edm::ParameterSet&, const GlobalTrackingGeometry* GlobalTrackingGeometry); //destructor virtual ~SegmentToTrackAssociator(); @@ -51,6 +53,8 @@ class SegmentToTrackAssociator { edm::InputTag theDTSegmentLabel; edm::InputTag theCSCSegmentLabel; + + const GlobalTrackingGeometry* globalTrackingGeometry_; }; #endif diff --git a/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc b/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc index 15fa7ffd608f7..ad1906547d93c 100644 --- a/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc +++ b/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc @@ -73,6 +73,10 @@ class CSCOverlapsTrackPreparation : public edm::EDProducer { // ----------member data --------------------------- edm::InputTag m_src; + + const edm::ESGetToken cscGeomToken_; + const edm::ESGetToken magneticFieldToken_; + const edm::ESGetToken globalGeomToken_; }; // @@ -87,7 +91,10 @@ class CSCOverlapsTrackPreparation : public edm::EDProducer { // constructors and destructor // CSCOverlapsTrackPreparation::CSCOverlapsTrackPreparation(const edm::ParameterSet& iConfig) - : m_src(iConfig.getParameter("src")) { + : m_src(iConfig.getParameter("src")), + cscGeomToken_(esConsumes()), + magneticFieldToken_(esConsumes()), + globalGeomToken_(esConsumes()) { produces>(); produces(); } @@ -107,13 +114,11 @@ void CSCOverlapsTrackPreparation::produce(edm::Event& iEvent, const edm::EventSe iEvent.getByLabel(m_src, tracks); edm::ESHandle cscGeometry; - iSetup.get().get(cscGeometry); - edm::ESHandle magneticField; - iSetup.get().get(magneticField); - edm::ESHandle globalGeometry; - iSetup.get().get(globalGeometry); + cscGeometry = iSetup.getHandle(cscGeomToken_); + magneticField = iSetup.getHandle(magneticFieldToken_); + globalGeometry = iSetup.getHandle(globalGeomToken_); MuonTransientTrackingRecHitBuilder muonTransBuilder; diff --git a/Alignment/MuonAlignmentAlgorithms/src/SegmentToTrackAssociator.cc b/Alignment/MuonAlignmentAlgorithms/src/SegmentToTrackAssociator.cc index 5c93ae36a0434..906d12d461b2b 100644 --- a/Alignment/MuonAlignmentAlgorithms/src/SegmentToTrackAssociator.cc +++ b/Alignment/MuonAlignmentAlgorithms/src/SegmentToTrackAssociator.cc @@ -32,7 +32,9 @@ #include -SegmentToTrackAssociator::SegmentToTrackAssociator(const edm::ParameterSet& iConfig) { +SegmentToTrackAssociator::SegmentToTrackAssociator(const edm::ParameterSet& iConfig, + const GlobalTrackingGeometry* GlobalTrackingGeometry) + : globalTrackingGeometry_(GlobalTrackingGeometry) { theDTSegmentLabel = iConfig.getParameter("segmentsDT"); theCSCSegmentLabel = iConfig.getParameter("segmentsCSC"); } @@ -55,9 +57,6 @@ MuonTransientTrackingRecHit::MuonRecHitContainer SegmentToTrackAssociator::assoc edm::Handle CSCSegments; iEvent.getByLabel(theCSCSegmentLabel, CSCSegments); - edm::ESHandle theTrackingGeometry; - iSetup.get().get(theTrackingGeometry); - MuonTransientTrackingRecHit::MuonRecHitContainer SelectedSegments; DTRecSegment4DCollection::const_iterator segmentDT; @@ -72,7 +71,7 @@ MuonTransientTrackingRecHit::MuonRecHitContainer SegmentToTrackAssociator::assoc TrackingRecHitRef myRef = track.recHit(counter); const TrackingRecHit* rechit = myRef.get(); - const GeomDet* geomDet = theTrackingGeometry->idToDet(rechit->geographicalId()); + const GeomDet* geomDet = globalTrackingGeometry_->idToDet(rechit->geographicalId()); //It's a DT Hit if (geomDet->subDetector() == GeomDetEnumerators::DT) { @@ -113,7 +112,7 @@ MuonTransientTrackingRecHit::MuonRecHitContainer SegmentToTrackAssociator::assoc myLayer.sector() == myChamber.sector()) { //push position of the segment and tracking rechit positionDT.push_back(NumberOfDTSegment); - const GeomDet* DTgeomDet = theTrackingGeometry->idToDet(myChamber); + const GeomDet* DTgeomDet = globalTrackingGeometry_->idToDet(myChamber); SelectedSegments.push_back( MuonTransientTrackingRecHit::specificBuild(DTgeomDet, (TrackingRecHit*)&*segmentDT)); @@ -158,7 +157,7 @@ MuonTransientTrackingRecHit::MuonRecHitContainer SegmentToTrackAssociator::assoc if (myLayer.chamberId() == myChamber.chamberId()) { //push positionCSC.push_back(NumberOfCSCSegment); - const GeomDet* CSCgeomDet = theTrackingGeometry->idToDet(myChamber); + const GeomDet* CSCgeomDet = globalTrackingGeometry_->idToDet(myChamber); SelectedSegments.push_back( MuonTransientTrackingRecHit::specificBuild(CSCgeomDet, (TrackingRecHit*)&*segmentCSC)); } diff --git a/Alignment/MuonAlignmentAlgorithms/test/StandAloneTest.cc b/Alignment/MuonAlignmentAlgorithms/test/StandAloneTest.cc index c7780c2c9b4b1..f5a377b8b161f 100644 --- a/Alignment/MuonAlignmentAlgorithms/test/StandAloneTest.cc +++ b/Alignment/MuonAlignmentAlgorithms/test/StandAloneTest.cc @@ -90,6 +90,9 @@ class StandAloneTest : public edm::one::EDAnalyzer { Float_t m_ttree_qoverpt; MuonAlignment *m_muonAlignment; + const edm::ESGetToken dtGeomToken_; + const edm::ESGetToken cscGeomToken_; + const edm::ESGetToken gemGeomToken_; }; // @@ -141,7 +144,14 @@ StandAloneTest::~StandAloneTest() { void StandAloneTest::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { // create a muon alignment object ONCE (not used for much, only a formalilty for MuonResidualsFromTrack) if (m_muonAlignment == NULL) { - m_muonAlignment = new MuonAlignment(iSetup); + edm::ESHandle dtGeometry; + edm::ESHandle cscGeometry; + edm::ESHandle gemGeometry; + dtGeometry = iSetup.getHandle(dtGeomToken_); + cscGeometry = iSetup.getHandle(cscGeomToken_); + gemGeometry = iSetup.getHandle(gemGeomToken_); + + m_muonAlignment = new MuonAlignment(&*dtGeometry, &*cscGeometry, &*gemGeometry); } // get tracks and refitted from the Event diff --git a/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.cc b/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.cc index f2fcf700bd87d..06c9fa3a26fd9 100644 --- a/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.cc +++ b/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.cc @@ -6,7 +6,11 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "Alignment/SurveyAnalysis/plugins/DTSurveyConvert.h" -DTSurveyConvert::DTSurveyConvert(const edm::ParameterSet &iConfig) : muonGeoToken_(esConsumes()) { +DTSurveyConvert::DTSurveyConvert(const edm::ParameterSet &iConfig) + : muonGeoToken_(esConsumes()), + dtGeomToken_(esConsumes()), + cscGeomToken_(esConsumes()), + gemGeomToken_(esConsumes()) { //now do what ever initialization is needed nameWheel_m2 = iConfig.getUntrackedParameter("nameWheel_m2"); nameWheel_m1 = iConfig.getUntrackedParameter("nameWheel_m1"); @@ -75,7 +79,15 @@ void DTSurveyConvert::analyze(const edm::Event &, const edm::EventSetup &iSetup) if (WriteToDB == true) { // Instantiate the helper class - MuonAlignment align(iSetup); + edm::ESHandle dtGeometry; + edm::ESHandle cscGeometry; + edm::ESHandle gemGeometry; + + dtGeometry = iSetup.getHandle(dtGeomToken_); + cscGeometry = iSetup.getHandle(cscGeomToken_); + gemGeometry = iSetup.getHandle(gemGeomToken_); + + MuonAlignment align(&*dtGeometry, &*cscGeometry, &*gemGeometry); std::ifstream inFile(outputFileName.c_str()); while (!inFile.eof()) { float dx, dy, dz, sigma_dx, sigma_dy, sigma_dz; diff --git a/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.h b/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.h index 0ef4dbf25907a..02f2d3c010cee 100644 --- a/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.h +++ b/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.h @@ -52,6 +52,10 @@ class DTSurveyConvert : public edm::one::EDAnalyzer<> { bool wheel_p1; bool wheel_p2; bool WriteToDB; + + const edm::ESGetToken dtGeomToken_; + const edm::ESGetToken cscGeomToken_; + const edm::ESGetToken gemGeomToken_; }; #endif From ebb99e8e6ac3747610857882aff3b7d77a0d49bc Mon Sep 17 00:00:00 2001 From: hyunyong Date: Tue, 19 Oct 2021 07:00:29 +0900 Subject: [PATCH 2/5] apply comments --- .../interface/MuonAlignmentInputSurveyDB.h | 6 +- .../plugins/MuonGeometryArrange.cc | 15 ++- .../plugins/MuonGeometryArrange.h | 6 +- .../src/MuonAlignmentInputSurveyDB.cc | 12 +- .../MuonAlignment/test/MuonGeometryArrange.py | 103 ++++++++---------- 5 files changed, 69 insertions(+), 73 deletions(-) diff --git a/Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h b/Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h index 44062ce46fbf0..bf67083744645 100644 --- a/Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h +++ b/Alignment/MuonAlignment/interface/MuonAlignmentInputSurveyDB.h @@ -30,9 +30,9 @@ class MuonAlignmentInputSurveyDB : public MuonAlignmentInputMethod { public: - MuonAlignmentInputSurveyDB(const DTGeometry* DTGeometry, - const CSCGeometry* CSCGeometry, - const GEMGeometry* GEMGeometry, + MuonAlignmentInputSurveyDB(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry, const Alignments* dtSurvey, const Alignments* cscSurvey, const SurveyErrors* dtSurveyError, diff --git a/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc b/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc index 95d0f0dfad4b4..d64644c02e22c 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc +++ b/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc @@ -47,7 +47,20 @@ MuonGeometryArrange::MuonGeometryArrange(const edm::ParameterSet& cfg) firstEvent_(true), idealInputLabel1("MuonGeometryArrangeLabel1"), idealInputLabel2("MuonGeometryArrangeLabel2"), - idealInputLabel2a("MuonGeometryArrangeLabel2a") { + idealInputLabel2a("MuonGeometryArrangeLabel2a"), + geomIdeal("MuonGeometryArrangeGeomIdeal"), + dtGeomToken1_(esConsumes(edm::ESInputTag("", idealInputLabel1))), + cscGeomToken1_(esConsumes(edm::ESInputTag("", idealInputLabel1))), + gemGeomToken1_(esConsumes(edm::ESInputTag("", idealInputLabel1))), + dtGeomToken2_(esConsumes(edm::ESInputTag("", idealInputLabel2))), + cscGeomToken2_(esConsumes(edm::ESInputTag("", idealInputLabel2))), + gemGeomToken2_(esConsumes(edm::ESInputTag("", idealInputLabel2))), + dtGeomToken3_(esConsumes(edm::ESInputTag("", idealInputLabel2a))), + cscGeomToken3_(esConsumes(edm::ESInputTag("", idealInputLabel2a))), + gemGeomToken3_(esConsumes(edm::ESInputTag("", idealInputLabel2a))), + dtGeomIdealToken_(esConsumes(edm::ESInputTag("", geomIdeal))), + cscGeomIdealToken_(esConsumes(edm::ESInputTag("", geomIdeal))), + gemGeomIdealToken_(esConsumes(edm::ESInputTag("", geomIdeal))) { referenceMuon = nullptr; currentMuon = nullptr; // Input is XML diff --git a/Alignment/MuonAlignment/plugins/MuonGeometryArrange.h b/Alignment/MuonAlignment/plugins/MuonGeometryArrange.h index 530ba54e865cd..c5ef393e841f9 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometryArrange.h +++ b/Alignment/MuonAlignment/plugins/MuonGeometryArrange.h @@ -19,7 +19,7 @@ * \author Nhan Tran */ -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Alignment/MuonAlignment/interface/AlignableMuon.h" #include "CondFormats/Alignment/interface/SurveyErrors.h" @@ -35,7 +35,7 @@ class MuonAlignment; class TGraph; class TH2F; -class MuonGeometryArrange : public edm::EDAnalyzer { +class MuonGeometryArrange : public edm::one::EDAnalyzer<> { public: typedef AlignTransform SurveyValue; typedef Alignments SurveyValues; @@ -170,7 +170,7 @@ class MuonGeometryArrange : public edm::EDAnalyzer { bool firstEvent_; - std::string idealInputLabel1, idealInputLabel2, idealInputLabel2a; + std::string idealInputLabel1, idealInputLabel2, idealInputLabel2a, geomIdeal; const edm::ESGetToken dtGeomToken1_; const edm::ESGetToken cscGeomToken1_; diff --git a/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc b/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc index 51184da7bd9af..55a6b133b0227 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc @@ -34,16 +34,16 @@ // // constructors and destructor // -MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(const DTGeometry* DTGeometry, - const CSCGeometry* CSCGeometry, - const GEMGeometry* GEMGeometry, +MuonAlignmentInputSurveyDB::MuonAlignmentInputSurveyDB(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry, const Alignments* dtSurvey, const Alignments* cscSurvey, const SurveyErrors* dtSurveyError, const SurveyErrors* cscSurveyError) - : dtGeometry_(DTGeometry), - cscGeometry_(CSCGeometry), - gemGeometry_(GEMGeometry), + : dtGeometry_(dtGeometry), + cscGeometry_(cscGeometry), + gemGeometry_(gemGeometry), dtSurvey_(dtSurvey), cscSurvey_(cscSurvey), dtSurveyError_(dtSurveyError), diff --git a/Alignment/MuonAlignment/test/MuonGeometryArrange.py b/Alignment/MuonAlignment/test/MuonGeometryArrange.py index dba3cf1182aec..c2395db06fede 100644 --- a/Alignment/MuonAlignment/test/MuonGeometryArrange.py +++ b/Alignment/MuonAlignment/test/MuonGeometryArrange.py @@ -3,70 +3,56 @@ #Ideal geometry process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi") -process.load("Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi") +process.load('Configuration.Geometry.GeometryExtended2021_cff') process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi") -process.load("Geometry.MuonNumbering.muonGeometryConstants_cff") +process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, "auto:phase1_2021_design") -process.DTGeometryMuonGeometryArrange1 = cms.ESProducer("DTGeometryESModule", - appendToDataLabel = cms.string('MuonGeometryArrangeLabel1'), - applyAlignment = cms.bool(False), - alignmentsLabel = cms.string(''), - fromDDD = cms.bool(True) -) +import Geometry.DTGeometryBuilder.dtGeometryDB_cfi +import Geometry.CSCGeometryBuilder.cscGeometryDB_cfi +import Geometry.GEMGeometryBuilder.gemGeometryDB_cfi -process.CSCGeometryMuonGeometryArrange1 = cms.ESProducer("CSCGeometryESModule", - appendToDataLabel = cms.string('MuonGeometryArrangeLabel1'), - debugV = cms.untracked.bool(False), - useGangedStripsInME1a = cms.bool(False), - alignmentsLabel = cms.string(''), - useOnlyWiresInME1a = cms.bool(False), - useRealWireGeometry = cms.bool(True), - useCentreTIOffsets = cms.bool(False), - applyAlignment = cms.bool(False), - fromDDD = cms.bool(True), - fromDD4hep = cms.bool(False) -) +process.DTGeometryIdeal = Geometry.DTGeometryBuilder.dtGeometryDB_cfi.DTGeometryESModule.clone() +process.DTGeometryIdeal.appendToDataLabel = 'MuonGeometryArrangeGeomIdeal' +process.DTGeometryIdeal.applyAlignment = cms.bool(False) +process.CSCGeometryIdeal = Geometry.CSCGeometryBuilder.cscGeometryDB_cfi.CSCGeometryESModule.clone() +process.CSCGeometryIdeal.appendToDataLabel = 'MuonGeometryArrangeGeomIdeal' +process.CSCGeometryIdeal.applyAlignment = cms.bool(False) +process.GEMGeometryIdeal = Geometry.GEMGeometryBuilder.gemGeometryDB_cfi.GEMGeometryESModule.clone() +process.GEMGeometryIdeal.appendToDataLabel = 'MuonGeometryArrangeGeomIdeal' +process.GEMGeometryIdeal.applyAlignment = cms.bool(False) -process.DTGeometryMuonGeometryArrange2 = cms.ESProducer("DTGeometryESModule", - appendToDataLabel = cms.string('MuonGeometryArrangeLabel2'), - applyAlignment = cms.bool(False), - alignmentsLabel = cms.string(''), - fromDDD = cms.bool(True) -) - -process.CSCGeometryMuonGeometryArrange2 = cms.ESProducer("CSCGeometryESModule", - appendToDataLabel = cms.string('MuonGeometryArrangeLabel2'), - debugV = cms.untracked.bool(False), - useGangedStripsInME1a = cms.bool(False), - alignmentsLabel = cms.string(''), - useOnlyWiresInME1a = cms.bool(False), - useRealWireGeometry = cms.bool(True), - useCentreTIOffsets = cms.bool(False), - applyAlignment = cms.bool(False), - fromDDD = cms.bool(True), - fromDD4hep = cms.bool(False) -) +process.DTGeometryMuonGeometryArrange1 = Geometry.DTGeometryBuilder.dtGeometryDB_cfi.DTGeometryESModule.clone() +process.DTGeometryMuonGeometryArrange1.appendToDataLabel = 'MuonGeometryArrangeLabel1' +process.DTGeometryMuonGeometryArrange1.applyAlignment = cms.bool(False) +process.CSCGeometryMuonGeometryArrange1 = Geometry.CSCGeometryBuilder.cscGeometryDB_cfi.CSCGeometryESModule.clone() +process.CSCGeometryMuonGeometryArrange1.appendToDataLabel = 'MuonGeometryArrangeLabel1' +process.CSCGeometryMuonGeometryArrange1.applyAlignment = cms.bool(False) +process.GEMGeometryMuonGeometryArrange1 = Geometry.GEMGeometryBuilder.gemGeometryDB_cfi.GEMGeometryESModule.clone() +process.GEMGeometryMuonGeometryArrange1.appendToDataLabel = 'MuonGeometryArrangeLabel1' +process.GEMGeometryMuonGeometryArrange1.applyAlignment = cms.bool(False) -process.DTGeometryMuonGeometryArrange2a = cms.ESProducer("DTGeometryESModule", - appendToDataLabel = cms.string('MuonGeometryArrangeLabel2a'), - applyAlignment = cms.bool(False), - alignmentsLabel = cms.string(''), - fromDDD = cms.bool(True) -) +process.DTGeometryMuonGeometryArrange2 = Geometry.DTGeometryBuilder.dtGeometryDB_cfi.DTGeometryESModule.clone() +process.DTGeometryMuonGeometryArrange2.appendToDataLabel = 'MuonGeometryArrangeLabel2' +process.DTGeometryMuonGeometryArrange2.applyAlignment = cms.bool(False) +process.CSCGeometryMuonGeometryArrange2 = Geometry.CSCGeometryBuilder.cscGeometryDB_cfi.CSCGeometryESModule.clone() +process.CSCGeometryMuonGeometryArrange2.appendToDataLabel = 'MuonGeometryArrangeLabel2' +process.CSCGeometryMuonGeometryArrange2.applyAlignment = cms.bool(False) +process.GEMGeometryMuonGeometryArrange2 = Geometry.GEMGeometryBuilder.gemGeometryDB_cfi.GEMGeometryESModule.clone() +process.GEMGeometryMuonGeometryArrange2.appendToDataLabel = 'MuonGeometryArrangeLabel2' +process.GEMGeometryMuonGeometryArrange2.applyAlignment = cms.bool(False) -process.CSCGeometryMuonGeometryArrange2a = cms.ESProducer("CSCGeometryESModule", - appendToDataLabel = cms.string('MuonGeometryArrangeLabel2a'), - debugV = cms.untracked.bool(False), - useGangedStripsInME1a = cms.bool(False), - alignmentsLabel = cms.string(''), - useOnlyWiresInME1a = cms.bool(False), - useRealWireGeometry = cms.bool(True), - useCentreTIOffsets = cms.bool(False), - applyAlignment = cms.bool(False), - fromDDD = cms.bool(True), - fromDD4hep = cms.bool(False) -) +process.DTGeometryMuonGeometryArrange2a = Geometry.DTGeometryBuilder.dtGeometryDB_cfi.DTGeometryESModule.clone() +process.DTGeometryMuonGeometryArrange2a.appendToDataLabel = 'MuonGeometryArrangeLabel2a' +process.DTGeometryMuonGeometryArrange2a.applyAlignment = cms.bool(False) +process.CSCGeometryMuonGeometryArrange2a = Geometry.CSCGeometryBuilder.cscGeometryDB_cfi.CSCGeometryESModule.clone() +process.CSCGeometryMuonGeometryArrange2a.appendToDataLabel = 'MuonGeometryArrangeLabel2a' +process.CSCGeometryMuonGeometryArrange2a.applyAlignment = cms.bool(False) +process.GEMGeometryMuonGeometryArrange2a = Geometry.GEMGeometryBuilder.gemGeometryDB_cfi.GEMGeometryESModule.clone() +process.GEMGeometryMuonGeometryArrange2a.appendToDataLabel = 'MuonGeometryArrangeLabel2a' +process.GEMGeometryMuonGeometryArrange2a.applyAlignment = cms.bool(False) process.MessageLogger = cms.Service("MessageLogger", cerr = cms.untracked.PSet( @@ -117,7 +103,4 @@ ) process.p = cms.Path( process.MuonGeometryCompare ) - - - From 687591e842d9ac21e0e92885750b659cb2b874e1 Mon Sep 17 00:00:00 2001 From: hyunyong Date: Wed, 20 Oct 2021 00:41:12 +0900 Subject: [PATCH 3/5] use edm::one class, remove intermediate ESHandle --- .../plugins/MuonGeometryArrange.cc | 65 ++--- .../plugins/MuonGeometryDBConverter.cc | 111 +++----- .../plugins/MuonGeometrySanityCheck.cc | 4 +- .../plugins/CSCOverlapsTrackPreparation.cc | 4 +- .../test/StandAloneTest.cc | 236 ------------------ 5 files changed, 52 insertions(+), 368 deletions(-) delete mode 100644 Alignment/MuonAlignmentAlgorithms/test/StandAloneTest.cc diff --git a/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc b/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc index d64644c02e22c..1139b2137121d 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc +++ b/Alignment/MuonAlignment/plugins/MuonGeometryArrange.cc @@ -635,60 +635,31 @@ void MuonGeometryArrange::createROOTGeometry(const edm::EventSetup& iSetup) {} ////////////////////////////////////////////////// void MuonGeometryArrange::analyze(const edm::Event&, const edm::EventSetup& iSetup) { if (firstEvent_) { - // My stuff - edm::ESHandle dtGeometry1; - edm::ESHandle cscGeometry1; - edm::ESHandle gemGeometry1; - dtGeometry1 = iSetup.getHandle(dtGeomToken1_); - cscGeometry1 = iSetup.getHandle(cscGeomToken1_); - gemGeometry1 = iSetup.getHandle(gemGeomToken1_); - - edm::ESHandle dtGeometry2; - edm::ESHandle cscGeometry2; - edm::ESHandle gemGeometry2; - dtGeometry2 = iSetup.getHandle(dtGeomToken2_); - cscGeometry2 = iSetup.getHandle(cscGeomToken2_); - gemGeometry2 = iSetup.getHandle(gemGeomToken2_); - - edm::ESHandle dtGeometry3; - edm::ESHandle cscGeometry3; - edm::ESHandle gemGeometry3; - dtGeometry3 = iSetup.getHandle(dtGeomToken3_); - cscGeometry3 = iSetup.getHandle(cscGeomToken3_); - gemGeometry3 = iSetup.getHandle(gemGeomToken3_); - - edm::ESHandle dtGeometryIdeal; - edm::ESHandle cscGeometryIdeal; - edm::ESHandle gemGeometryIdeal; - dtGeometryIdeal = iSetup.getHandle(dtGeomIdealToken_); - cscGeometryIdeal = iSetup.getHandle(cscGeomIdealToken_); - gemGeometryIdeal = iSetup.getHandle(gemGeomIdealToken_); - MuonAlignmentInputXML inputMethod1(_inputXMLCurrent, - &*dtGeometry1, - &*cscGeometry1, - &*gemGeometry1, - &*dtGeometryIdeal, - &*cscGeometryIdeal, - &*gemGeometryIdeal); + &iSetup.getData(dtGeomToken1_), + &iSetup.getData(cscGeomToken1_), + &iSetup.getData(gemGeomToken1_), + &iSetup.getData(dtGeomToken1_), + &iSetup.getData(cscGeomToken1_), + &iSetup.getData(gemGeomToken1_)); inputAlign1 = new MuonAlignment(iSetup, inputMethod1); inputAlign1->fillGapsInSurvey(0, 0); MuonAlignmentInputXML inputMethod2(_inputXMLReference, - &*dtGeometry2, - &*cscGeometry2, - &*gemGeometry2, - &*dtGeometryIdeal, - &*cscGeometryIdeal, - &*gemGeometryIdeal); + &iSetup.getData(dtGeomToken2_), + &iSetup.getData(cscGeomToken2_), + &iSetup.getData(gemGeomToken2_), + &iSetup.getData(dtGeomToken1_), + &iSetup.getData(cscGeomToken1_), + &iSetup.getData(gemGeomToken1_)); inputAlign2 = new MuonAlignment(iSetup, inputMethod2); inputAlign2->fillGapsInSurvey(0, 0); MuonAlignmentInputXML inputMethod2a(_inputXMLReference, - &*dtGeometry3, - &*cscGeometry3, - &*gemGeometry3, - &*dtGeometryIdeal, - &*cscGeometryIdeal, - &*gemGeometryIdeal); + &iSetup.getData(dtGeomToken3_), + &iSetup.getData(cscGeomToken3_), + &iSetup.getData(gemGeomToken3_), + &iSetup.getData(dtGeomToken1_), + &iSetup.getData(cscGeomToken1_), + &iSetup.getData(gemGeomToken1_)); inputAlign2a = new MuonAlignment(iSetup, inputMethod2a); inputAlign2a->fillGapsInSurvey(0, 0); diff --git a/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc b/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc index b81e8b7f23f51..580b99e1e4774 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc +++ b/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc @@ -112,9 +112,7 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi //////////////////////////////////////////////////////////////////// if (m_input == std::string("ideal")) { - } - - else if (m_input == std::string("db")) { + } else if (m_input == std::string("db")) { m_dtLabel = iConfig.getParameter("dtLabel"); m_cscLabel = iConfig.getParameter("cscLabel"); m_gemLabel = iConfig.getParameter("gemLabel"); @@ -130,45 +128,29 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi dtGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); cscGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); gemGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); - - } - - else if (m_input == std::string("surveydb")) { + } else if (m_input == std::string("surveydb")) { m_dtLabel = iConfig.getParameter("dtLabel"); m_cscLabel = iConfig.getParameter("cscLabel"); m_gemLabel = iConfig.getParameter("gemLabel"); - } - - else if (m_input == std::string("scenario")) { + } else if (m_input == std::string("scenario")) { m_misalignmentScenario = iConfig.getParameter("MisalignmentScenario"); m_shiftErr = iConfig.getParameter("shiftErr"); m_angleErr = iConfig.getParameter("angleErr"); - } - - else if (m_input == std::string("xml")) { + } else if (m_input == std::string("xml")) { m_fileName = iConfig.getParameter("fileName"); m_shiftErr = iConfig.getParameter("shiftErr"); m_angleErr = iConfig.getParameter("angleErr"); dtGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); cscGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); gemGeomToken_ = esConsumes(edm::ESInputTag("", idealGeometryLabelForInputXML)); - } - - else { + } else { throw cms::Exception("BadConfig") << "input must be \"ideal\", \"db\", \"surveydb\", or \"xml\"." << std::endl; } - if (m_output == std::string("none")) { - } - - else if (m_output == std::string("db")) { - } - - else if (m_output == std::string("xml")) { + } else if (m_output == std::string("db")) { + } else if (m_output == std::string("xml")) { m_outputXML = iConfig.getParameter("outputXML"); - } - - else { + } else { throw cms::Exception("BadConfig") << "output must be \"none\", \"db \", \"xml\"." << std::endl; } } @@ -177,81 +159,48 @@ MuonGeometryDBConverter::~MuonGeometryDBConverter() {} // ------------ method called to for each event ------------ void MuonGeometryDBConverter::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { - edm::ESHandle dtGeometryIdeal; - edm::ESHandle cscGeometryIdeal; - edm::ESHandle gemGeometryIdeal; - dtGeometryIdeal = iSetup.getHandle(dtGeomIdealToken_); - cscGeometryIdeal = iSetup.getHandle(cscGeomIdealToken_); - gemGeometryIdeal = iSetup.getHandle(gemGeomIdealToken_); - if (!m_done) { if (m_input == std::string("ideal")) { - MuonAlignmentInputMethod inputMethod(&*dtGeometryIdeal, &*cscGeometryIdeal, &*gemGeometryIdeal); + MuonAlignmentInputMethod inputMethod( + &iSetup.getData(dtGeomIdealToken_), &iSetup.getData(cscGeomIdealToken_), &iSetup.getData(gemGeomIdealToken_)); MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod); muonAlignment->fillGapsInSurvey(0., 0.); muonAlignment->saveToDB(); - } - - else if (m_input == std::string("db")) { - edm::ESHandle dtAlignments; - edm::ESHandle cscAlignments; - edm::ESHandle gemAlignments; - edm::ESHandle globalPositionRcd; - dtAlignments = iSetup.getHandle(dtAliToken_); - cscAlignments = iSetup.getHandle(cscAliToken_); - gemAlignments = iSetup.getHandle(gemAliToken_); - globalPositionRcd = iSetup.getHandle(gprToken_); - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - dtGeometry = iSetup.getHandle(dtGeomToken_); - cscGeometry = iSetup.getHandle(cscGeomToken_); - gemGeometry = iSetup.getHandle(gemGeomToken_); - MuonAlignmentInputDB inputMethod(&*dtGeometryIdeal, - &*cscGeometryIdeal, - &*gemGeometryIdeal, - &*dtAlignments, - &*cscAlignments, - &*gemAlignments, - &*globalPositionRcd); + } else if (m_input == std::string("db")) { + MuonAlignmentInputDB inputMethod(&iSetup.getData(dtGeomIdealToken_), + &iSetup.getData(cscGeomIdealToken_), + &iSetup.getData(gemGeomIdealToken_), + &iSetup.getData(dtAliToken_), + &iSetup.getData(cscAliToken_), + &iSetup.getData(gemAliToken_), + &iSetup.getData(gprToken_)); MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod); if (m_getAPEs) { muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr); } - muonAlignment->writeXML(m_outputXML, &*dtGeometry, &*cscGeometry, &*gemGeometry); - } - - else if (m_input == std::string("scenario")) { - MuonAlignmentInputMethod inputMethod(&*dtGeometryIdeal, &*cscGeometryIdeal, &*gemGeometryIdeal); + muonAlignment->writeXML( + m_outputXML, &iSetup.getData(dtGeomToken_), &iSetup.getData(cscGeomToken_), &iSetup.getData(gemGeomToken_)); + } else if (m_input == std::string("scenario")) { + MuonAlignmentInputMethod inputMethod( + &iSetup.getData(dtGeomIdealToken_), &iSetup.getData(cscGeomIdealToken_), &iSetup.getData(gemGeomIdealToken_)); MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod); MuonScenarioBuilder muonScenarioBuilder(muonAlignment->getAlignableMuon()); muonScenarioBuilder.applyScenario(m_misalignmentScenario); muonAlignment->saveToDB(); muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr); - } - - else if (m_input == std::string("xml")) { - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - edm::ESHandle globalPositionRcd; - dtGeometry = iSetup.getHandle(dtGeomToken_); - cscGeometry = iSetup.getHandle(cscGeomToken_); - gemGeometry = iSetup.getHandle(gemGeomToken_); - globalPositionRcd = iSetup.getHandle(gprToken_); + } else if (m_input == std::string("xml")) { MuonAlignmentInputXML inputMethod(m_fileName, - &*dtGeometry, - &*cscGeometry, - &*gemGeometry, - &*dtGeometryIdeal, - &*cscGeometryIdeal, - &*gemGeometryIdeal); + &iSetup.getData(dtGeomToken_), + &iSetup.getData(cscGeomToken_), + &iSetup.getData(gemGeomToken_), + &iSetup.getData(dtGeomIdealToken_), + &iSetup.getData(cscGeomIdealToken_), + &iSetup.getData(gemGeomIdealToken_)); MuonAlignment *muonAlignment = new MuonAlignment(iSetup, inputMethod); muonAlignment->saveToDB(); muonAlignment->fillGapsInSurvey(m_shiftErr, m_angleErr); } - m_done = true; } // end if not done else { diff --git a/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc b/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc index 2beb719b3a73f..a9c13b2d54f5c 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc +++ b/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc @@ -19,7 +19,7 @@ // system include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" @@ -81,7 +81,7 @@ class MuonGeometrySanityCheckPoint { int number(std::string s); }; -class MuonGeometrySanityCheck : public edm::EDAnalyzer { +class MuonGeometrySanityCheck : public edm::one::EDAnalyzer<> { public: explicit MuonGeometrySanityCheck(const edm::ParameterSet &iConfig); ~MuonGeometrySanityCheck() override; diff --git a/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc b/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc index ad1906547d93c..d1701d40e8d88 100644 --- a/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc +++ b/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc @@ -22,7 +22,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/one/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -59,7 +59,7 @@ // class decleration // -class CSCOverlapsTrackPreparation : public edm::EDProducer { +class CSCOverlapsTrackPreparation : public edm::one::EDProducer<> { public: explicit CSCOverlapsTrackPreparation(const edm::ParameterSet&); ~CSCOverlapsTrackPreparation() override; diff --git a/Alignment/MuonAlignmentAlgorithms/test/StandAloneTest.cc b/Alignment/MuonAlignmentAlgorithms/test/StandAloneTest.cc deleted file mode 100644 index f5a377b8b161f..0000000000000 --- a/Alignment/MuonAlignmentAlgorithms/test/StandAloneTest.cc +++ /dev/null @@ -1,236 +0,0 @@ -// -*- C++ -*- -// -// Package: StandAloneTest -// Class: StandAloneTest -// -/**\class StandAloneTest StandAloneTest.cc Dummy/StandAloneTest/src/StandAloneTest.cc - - Description: - - Implementation: - -*/ -// -// Original Author: Jim Pivarski -// Created: Sat Sep 26 02:50:24 CEST 2009 -// $Id: StandAloneTest.cc,v 1.2 2010/01/06 15:38:44 mussgill Exp $ -// -// - -// system include files -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" -#include "TTree.h" - -#include "DataFormats/TrackReco/interface/Track.h" -#include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h" -#include "DataFormats/DetId/interface/DetId.h" -#include "DataFormats/MuonDetId/interface/MuonSubdetId.h" -#include "DataFormats/MuonDetId/interface/CSCDetId.h" -#include "Geometry/CSCGeometry/interface/CSCGeometry.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" -#include "TrackingTools/PatternTools/interface/Trajectory.h" -#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h" -#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h" -#include "Alignment/MuonAlignment/interface/MuonAlignment.h" -#include "Alignment/MuonAlignmentAlgorithms/interface/MuonResidualsFromTrack.h" - -#include "TrackingTools/Records/interface/TrackingComponentsRecord.h" -#include "TrackingTools/Records/interface/DetIdAssociatorRecord.h" -#include "TrackingTools/GeomPropagators/interface/Propagator.h" -#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" -#include "MagneticField/Engine/interface/MagneticField.h" - -// -// class decleration -// - -class StandAloneTest : public edm::one::EDAnalyzer { -public: - explicit StandAloneTest(const edm::ParameterSet &); - ~StandAloneTest(); - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event &, const edm::EventSetup &); - virtual void endJob(); - - // ----------member data --------------------------- - - const edm::InputTag m_Tracks; - const edm::EDGetTokenT m_tracksToken; - const edm::EDGetTokenT m_trajtracksmapToken; - - const MuonResidualsFromTrack::BuilderToken m_builderToken; - const edm::ESGetToken m_globalGeometryToken; - const edm::ESGetToken m_cscGeometryToken; - const edm::ESGetToken m_propToken; - const edm::ESGetToken m_magneticFieldToken; - const edm::ESGetToken m_muonDetIdAssociatorToken; - - // declare the TTree - TTree *m_ttree; - Int_t m_ttree_station; - Int_t m_ttree_chamber; - Float_t m_ttree_resid; - Float_t m_ttree_residslope; - Float_t m_ttree_phi; - Float_t m_ttree_qoverpt; - - MuonAlignment *m_muonAlignment; - const edm::ESGetToken dtGeomToken_; - const edm::ESGetToken cscGeomToken_; - const edm::ESGetToken gemGeomToken_; -}; - -// -// constants, enums and typedefs -// - -// -// static data member definitions -// - -// -// constructors and destructor -// -StandAloneTest::StandAloneTest(const edm::ParameterSet &iConfig) - : m_Tracks(iConfig.getParameter("Tracks")), - m_tracksToken(consumes(m_Tracks)), - m_trajtracksmapToken(consumes(edm::InputTag("TrackRefitter", "Refitted"))), - m_builderToken(esConsumes(MuonResidualsFromTrack::builderESInputTag())), - m_globalGeometryToken(esConsumes()), - m_cscGeometryToken(esConsumes()), - m_propToken(esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))), - m_magneticFieldToken(esConsumes()), - m_muonDetIdAssociatorToken(esConsumes(edm::ESInputTag("", "MuonDetIdAssociator"))) { - edm::Service tFileService; - usesResource(TFileService::kSharedResource); - - // book the TTree - m_ttree = tFileService->make("ttree", "ttree"); - m_ttree->Branch("station", &m_ttree_station, "station/I"); - m_ttree->Branch("chamber", &m_ttree_chamber, "chamber/I"); - m_ttree->Branch("resid", &m_ttree_resid, "resid/F"); - m_ttree->Branch("residslope", &m_ttree_residslope, "residslope/F"); - m_ttree->Branch("phi", &m_ttree_phi, "phi/F"); - m_ttree->Branch("qoverpt", &m_ttree_qoverpt, "qoverpt/F"); - - m_muonAlignment = NULL; -} - -StandAloneTest::~StandAloneTest() { - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) -} - -// -// member functions -// - -// ------------ method called to for each event ------------ -void StandAloneTest::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { - // create a muon alignment object ONCE (not used for much, only a formalilty for MuonResidualsFromTrack) - if (m_muonAlignment == NULL) { - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - dtGeometry = iSetup.getHandle(dtGeomToken_); - cscGeometry = iSetup.getHandle(cscGeomToken_); - gemGeometry = iSetup.getHandle(gemGeomToken_); - - m_muonAlignment = new MuonAlignment(&*dtGeometry, &*cscGeometry, &*gemGeometry); - } - - // get tracks and refitted from the Event - edm::Handle tracks = iEvent.getHandle(m_tracksToken); - edm::Handle trajtracksmap = iEvent.getHandle(m_trajtracksmapToken); - - // get all tracking and CSC geometries from the EventSetup - edm::ESHandle globalGeometry = iSetup.getHandle(m_globalGeometryToken); - edm::ESHandle cscGeometry = iSetup.getHandle(m_cscGeometryToken); - - auto builder = iSetup.getHandle(m_builderToken); - edm::ESHandle prop = iSetup.getHandle(m_propToken); - edm::ESHandle magneticField = iSetup.getHandle(m_magneticFieldToken); - edm::ESHandle muonDetIdAssociator_ = iSetup.getHandle(m_muonDetIdAssociatorToken); - - // loop over tracks - for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) { - // find the corresponding refitted trajectory - const Trajectory *traj = NULL; - for (TrajTrackAssociationCollection::const_iterator iPair = trajtracksmap->begin(); iPair != trajtracksmap->end(); - ++iPair) { - if (&(*(iPair->val)) == &(*track)) { - traj = &(*(iPair->key)); - } - } - - // if good track, good trajectory - if (track->pt() > 20. && traj != NULL && traj->isValid()) { - // calculate all residuals on this track - MuonResidualsFromTrack muonResidualsFromTrack(builder, - magneticField, - globalGeometry, - muonDetIdAssociator_, - prop, - traj, - &(*track), - m_muonAlignment->getAlignableNavigator(), - 1000.); - std::vector chamberIds = muonResidualsFromTrack.chamberIds(); - - // if the tracker part of refit is okay - if (muonResidualsFromTrack.trackerNumHits() >= 10 && muonResidualsFromTrack.trackerRedChi2() < 10.) { - // loop over ALL chambers - for (std::vector::const_iterator chamberId = chamberIds.begin(); chamberId != chamberIds.end(); - ++chamberId) { - // if CSC - if (chamberId->det() == DetId::Muon && chamberId->subdetId() == MuonSubdetId::CSC) { - CSCDetId cscid(chamberId->rawId()); - int station = (cscid.endcap() == 1 ? 1 : -1) * (10 * cscid.station() + cscid.ring()); - MuonChamberResidual *csc = muonResidualsFromTrack.chamberResidual(*chamberId, MuonChamberResidual::kCSC); - - // if this segment is okay and has 6 hits - if (csc != NULL && csc->numHits() >= 6) { - // fill the TTree - m_ttree_station = station; - m_ttree_chamber = cscid.chamber(); - m_ttree_resid = csc->residual(); - m_ttree_residslope = csc->resslope(); - m_ttree_phi = csc->global_trackpos().phi(); - m_ttree_qoverpt = double(track->charge()) / track->pt(); - m_ttree->Fill(); - } // end if CSC is okay - - } // end if CSC - - } // end loop over all chambers - - } // end if tracker part of refit is okay - - } // end if good track, good track refit - - } // end loop over tracks -} - -// ------------ method called once each job just before starting event loop ------------ -void StandAloneTest::beginJob() {} - -// ------------ method called once each job just after ending the event loop ------------ -void StandAloneTest::endJob() {} - -//define this as a plug-in -DEFINE_FWK_MODULE(StandAloneTest); From 7e932816854d670c9d6868bd72fe69c380dea262 Mon Sep 17 00:00:00 2001 From: hyunyong Date: Wed, 20 Oct 2021 23:35:30 +0900 Subject: [PATCH 4/5] rebase --- .../plugins/MuonGeometrySanityCheck.cc | 6 +- .../plugins/CSCOverlapsTrackPreparation.cc | 9 +-- .../test/standAloneTest_cfg.py | 64 ------------------- .../SurveyAnalysis/plugins/DTSurveyConvert.cc | 10 +-- 4 files changed, 8 insertions(+), 81 deletions(-) delete mode 100644 Alignment/MuonAlignmentAlgorithms/test/standAloneTest_cfg.py diff --git a/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc b/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc index a9c13b2d54f5c..6010da76f0166 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc +++ b/Alignment/MuonAlignment/plugins/MuonGeometrySanityCheck.cc @@ -584,10 +584,8 @@ std::string MuonGeometrySanityCheckPoint::detName() const { // ------------ method called to for each event ------------ void MuonGeometrySanityCheck::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - dtGeometry = iSetup.getHandle(dtGeomToken_); - cscGeometry = iSetup.getHandle(cscGeomToken_); + const DTGeometry *dtGeometry = &iSetup.getData(dtGeomToken_); + const CSCGeometry *cscGeometry = &iSetup.getData(cscGeomToken_); int num_transformed = 0; int num_tested = 0; diff --git a/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc b/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc index d1701d40e8d88..88f21ed574ce2 100644 --- a/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc +++ b/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsTrackPreparation.cc @@ -113,12 +113,9 @@ void CSCOverlapsTrackPreparation::produce(edm::Event& iEvent, const edm::EventSe edm::Handle tracks; iEvent.getByLabel(m_src, tracks); - edm::ESHandle cscGeometry; - edm::ESHandle magneticField; - edm::ESHandle globalGeometry; - cscGeometry = iSetup.getHandle(cscGeomToken_); - magneticField = iSetup.getHandle(magneticFieldToken_); - globalGeometry = iSetup.getHandle(globalGeomToken_); + const CSCGeometry* cscGeometry = &iSetup.getData(cscGeomToken_); + const MagneticField* magneticField = &iSetup.getData(magneticFieldToken_); + const GlobalTrackingGeometry* globalGeometry = &iSetup.getData(globalGeomToken_); MuonTransientTrackingRecHitBuilder muonTransBuilder; diff --git a/Alignment/MuonAlignmentAlgorithms/test/standAloneTest_cfg.py b/Alignment/MuonAlignmentAlgorithms/test/standAloneTest_cfg.py deleted file mode 100644 index 5c331fcdc4511..0000000000000 --- a/Alignment/MuonAlignmentAlgorithms/test/standAloneTest_cfg.py +++ /dev/null @@ -1,64 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("TEST") -process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( - "/store/data/CRAFT09/Cosmics/RAW-RECO/GR09_31X_V5P_CSCSkim_BFieldStudies-332_v4/0021/FAF8A711-C297-DE11-A00E-001731AF66AF.root", - "/store/data/CRAFT09/Cosmics/RAW-RECO/GR09_31X_V5P_CSCSkim_BFieldStudies-332_v4/0021/FAB8A245-D996-DE11-A866-003048678A6A.root", - "/store/data/CRAFT09/Cosmics/RAW-RECO/GR09_31X_V5P_CSCSkim_BFieldStudies-332_v4/0021/F8D6CB8E-CD96-DE11-A8D2-003048678FFA.root", - "/store/data/CRAFT09/Cosmics/RAW-RECO/GR09_31X_V5P_CSCSkim_BFieldStudies-332_v4/0021/F8349AAD-C297-DE11-99E3-0030486792BA.root", - "/store/data/CRAFT09/Cosmics/RAW-RECO/GR09_31X_V5P_CSCSkim_BFieldStudies-332_v4/0021/F8251242-DA96-DE11-B26B-003048678FC6.root", - "/store/data/CRAFT09/Cosmics/RAW-RECO/GR09_31X_V5P_CSCSkim_BFieldStudies-332_v4/0021/F49C816C-D796-DE11-AC34-003048D15DDA.root", - "/store/data/CRAFT09/Cosmics/RAW-RECO/GR09_31X_V5P_CSCSkim_BFieldStudies-332_v4/0021/F288C73C-C297-DE11-9F00-001731AF684D.root", - "/store/data/CRAFT09/Cosmics/RAW-RECO/GR09_31X_V5P_CSCSkim_BFieldStudies-332_v4/0021/F0BBFDE1-D496-DE11-8E1B-003048678FE6.root", - "/store/data/CRAFT09/Cosmics/RAW-RECO/GR09_31X_V5P_CSCSkim_BFieldStudies-332_v4/0021/EE1592A7-C297-DE11-8679-0030486792AC.root", - "/store/data/CRAFT09/Cosmics/RAW-RECO/GR09_31X_V5P_CSCSkim_BFieldStudies-332_v4/0021/E2938851-CF96-DE11-8330-0017312B5651.root", - )) -process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(100)) - -process.StandAloneTest = cms.EDAnalyzer("StandAloneTest", Tracks = cms.InputTag("")) - -process.load("Configuration.StandardSequences.MagneticField_cff") -process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi") -process.load("Geometry.CommonTopologies.bareGlobalTrackingGeometry_cfi") -process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi") -process.load("Geometry.DTGeometry.dtGeometry_cfi") -process.load("Geometry.CSCGeometry.cscGeometry_cfi") -process.load("Geometry.RPCGeometry.rpcGeometry_cfi") -process.load("Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi") -process.load("Geometry.TrackerGeometryBuilder.trackerGeometry_cfi") - -### for cosmic rays (only use one) -process.load("TrackingTools.TrackRefitter.globalCosmicMuonTrajectories_cff") -process.TrackRefitter = process.globalCosmicMuons.clone() -process.TrackRefitter.Tracks = cms.InputTag("globalCosmicMuons") -process.StandAloneTest.Tracks = cms.InputTag("globalCosmicMuons") - -### for collisions (only use one) -# process.load("TrackingTools.TrackRefitter.globalMuonTrajectories_cff") -# process.TrackRefitter = process.globalCosmicMuons.clone() -# process.TrackRefitter.Tracks = cms.InputTag("globalMuons") -# process.StandAloneTest.Tracks = cms.InputTag("globalMuons") - -process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") -process.GlobalTag.globaltag = cms.string("CRAFT0831X_V1::All") - -process.load("CondCore.DBCommon.CondDBSetup_cfi") - -### for assigning a custom muon alignment -# process.MuonAlignment = cms.ESSource("PoolDBESSource", -# process.CondDBSetup, -# connect = cms.string("sqlite_file:customMuonAlignment.db"), -# toGet = cms.VPSet(cms.PSet(record = cms.string("DTAlignmentRcd"), tag = cms.string("DTAlignmentRcd")), -# cms.PSet(record = cms.string("CSCAlignmentRcd"), tag = cms.string("CSCAlignmentRcd")))) -# process.es_prefer_MuonAlignment = cms.ESPrefer("PoolDBESSource", "MuonAlignment") - -### it is important to refit with zero weights ("infinite" APEs) -process.MuonAlignmentErrorsExtended = cms.ESSource("PoolDBESSource", - process.CondDBSetup, - connect = cms.string("sqlite_file:APE1000cm.db"), - toGet = cms.VPSet(cms.PSet(record = cms.string("DTAlignmentErrorExtendedRcd"), tag = cms.string("DTAlignmentErrorExtendedRcd")), - cms.PSet(record = cms.string("CSCAlignmentErrorExtendedRcd"), tag = cms.string("CSCAlignmentErrorExtendedRcd")))) -process.es_prefer_MuonAlignmentErrorsExtended = cms.ESPrefer("PoolDBESSource", "MuonAlignmentErrorsExtended") - -process.TFileService = cms.Service("TFileService", fileName = cms.string("standAloneTest.root")) -process.Path = cms.Path(process.TrackRefitter * process.StandAloneTest) diff --git a/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.cc b/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.cc index 06c9fa3a26fd9..d8bd8511976d2 100644 --- a/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.cc +++ b/Alignment/SurveyAnalysis/plugins/DTSurveyConvert.cc @@ -79,13 +79,9 @@ void DTSurveyConvert::analyze(const edm::Event &, const edm::EventSetup &iSetup) if (WriteToDB == true) { // Instantiate the helper class - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - - dtGeometry = iSetup.getHandle(dtGeomToken_); - cscGeometry = iSetup.getHandle(cscGeomToken_); - gemGeometry = iSetup.getHandle(gemGeomToken_); + const DTGeometry *dtGeometry = &iSetup.getData(dtGeomToken_); + const CSCGeometry *cscGeometry = &iSetup.getData(cscGeomToken_); + const GEMGeometry *gemGeometry = &iSetup.getData(gemGeomToken_); MuonAlignment align(&*dtGeometry, &*cscGeometry, &*gemGeometry); std::ifstream inFile(outputFileName.c_str()); From 906a1fc11d2befd8bc277f9dfd51d1f6a01e1b58 Mon Sep 17 00:00:00 2001 From: hyunyong Date: Wed, 20 Oct 2021 23:57:11 +0900 Subject: [PATCH 5/5] remove BuildFile.xml --- .../MuonAlignmentAlgorithms/test/BuildFile.xml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 Alignment/MuonAlignmentAlgorithms/test/BuildFile.xml diff --git a/Alignment/MuonAlignmentAlgorithms/test/BuildFile.xml b/Alignment/MuonAlignmentAlgorithms/test/BuildFile.xml deleted file mode 100644 index 8adb25215f548..0000000000000 --- a/Alignment/MuonAlignmentAlgorithms/test/BuildFile.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - -