diff --git a/Alignment/CommonAlignment/interface/AlignableObjectId.h b/Alignment/CommonAlignment/interface/AlignableObjectId.h index c785bb91b763d..73f26c14d6125 100644 --- a/Alignment/CommonAlignment/interface/AlignableObjectId.h +++ b/Alignment/CommonAlignment/interface/AlignableObjectId.h @@ -7,6 +7,7 @@ class TrackerGeometry; class DTGeometry; class CSCGeometry; +class GEMGeometry; /// Allows conversion between type and name, and vice-versa class AlignableObjectId { @@ -15,7 +16,7 @@ class AlignableObjectId { enum class Geometry { RunI, PhaseI, PhaseII, General, Unspecified }; AlignableObjectId(Geometry); - AlignableObjectId(const TrackerGeometry*, const DTGeometry*, const CSCGeometry*); + AlignableObjectId(const TrackerGeometry*, const DTGeometry*, const CSCGeometry*, const GEMGeometry*); AlignableObjectId(const AlignableObjectId&) = default; AlignableObjectId& operator=(const AlignableObjectId&) = default; AlignableObjectId(AlignableObjectId&&) = default; @@ -43,7 +44,7 @@ class AlignableObjectId { private: static Geometry trackerGeometry(const TrackerGeometry*); - static Geometry muonGeometry(const DTGeometry*, const CSCGeometry*); + static Geometry muonGeometry(const DTGeometry*, const CSCGeometry*, const GEMGeometry*); const entry* entries_{nullptr}; Geometry geometry_{Geometry::Unspecified}; diff --git a/Alignment/CommonAlignment/interface/StructureType.h b/Alignment/CommonAlignment/interface/StructureType.h index b916d1bf587e9..e6a413b658235 100644 --- a/Alignment/CommonAlignment/interface/StructureType.h +++ b/Alignment/CommonAlignment/interface/StructureType.h @@ -81,6 +81,12 @@ namespace align { AlignableCSCRing, AlignableCSCChamber, AlignableCSCLayer, // = 110 + AlignableGEMEndcap, + AlignableGEMStation, + AlignableGEMRing, + AlignableGEMSuperChamber, + AlignableGEMChamber, + AlignableGEMEtaPartition, AlignableMuon, Detector, // = 112 (what for?) diff --git a/Alignment/CommonAlignment/src/AlignableCompositeBuilder.cc b/Alignment/CommonAlignment/src/AlignableCompositeBuilder.cc index 17199a0aa0a33..e092bf7dac7a4 100644 --- a/Alignment/CommonAlignment/src/AlignableCompositeBuilder.cc +++ b/Alignment/CommonAlignment/src/AlignableCompositeBuilder.cc @@ -18,7 +18,7 @@ AlignableCompositeBuilder ::AlignableCompositeBuilder(const TrackerTopology* tra const TrackerGeometry* trackerGeometry, const AlignableIndexer& alignableIndexer) : trackerTopology_(trackerTopology), - alignableObjectId_(trackerGeometry, nullptr, nullptr), + alignableObjectId_(trackerGeometry, nullptr, nullptr, nullptr), alignableIndexer_(alignableIndexer) {} //_____________________________________________________________________________ diff --git a/Alignment/CommonAlignment/src/AlignableObjectId.cc b/Alignment/CommonAlignment/src/AlignableObjectId.cc index b4ee89195bd9f..a2f4ae904db84 100644 --- a/Alignment/CommonAlignment/src/AlignableObjectId.cc +++ b/Alignment/CommonAlignment/src/AlignableObjectId.cc @@ -135,6 +135,12 @@ namespace { {align::AlignableCSCRing, "CSCRing"}, {align::AlignableCSCChamber, "CSCChamber"}, {align::AlignableCSCLayer, "CSCLayer"}, + {align::AlignableGEMEndcap, "GEMEndcap"}, + {align::AlignableGEMStation, "GEMStation"}, + {align::AlignableGEMRing, "GEMRing"}, + {align::AlignableGEMSuperChamber, "GEMSuperChamber"}, + {align::AlignableGEMChamber, "GEMChamber"}, + {align::AlignableGEMEtaPartition, "GEMEtaPartition"}, {align::AlignableMuon, "Muon"}, {align::BeamSpot, "BeamSpot"}, @@ -201,6 +207,12 @@ namespace { {align::AlignableCSCRing, "CSCRing"}, {align::AlignableCSCChamber, "CSCChamber"}, {align::AlignableCSCLayer, "CSCLayer"}, + {align::AlignableGEMEndcap, "GEMEndcap"}, + {align::AlignableGEMStation, "GEMStation"}, + {align::AlignableGEMRing, "GEMRing"}, + {align::AlignableGEMSuperChamber, "GEMSuperChamber"}, + {align::AlignableGEMChamber, "GEMChamber"}, + {align::AlignableGEMEtaPartition, "GEMEtaPartition"}, {align::AlignableMuon, "Muon"}, {align::BeamSpot, "BeamSpot"}, @@ -246,8 +258,9 @@ AlignableObjectId ::AlignableObjectId(AlignableObjectId::Geometry geometry) : ge //_____________________________________________________________________________ AlignableObjectId ::AlignableObjectId(const TrackerGeometry *tracker, const DTGeometry *muonDt, - const CSCGeometry *muonCsc) - : AlignableObjectId(commonGeometry(trackerGeometry(tracker), muonGeometry(muonDt, muonCsc))) {} + const CSCGeometry *muonCsc, + const GEMGeometry *muonGem) + : AlignableObjectId(commonGeometry(trackerGeometry(tracker), muonGeometry(muonDt, muonCsc, muonGem))) {} //_____________________________________________________________________________ align::StructureType AlignableObjectId::nameToType(const std::string &name) const { return stringToId(name.c_str()); } @@ -299,7 +312,9 @@ AlignableObjectId::Geometry AlignableObjectId ::trackerGeometry(const TrackerGeo } } -AlignableObjectId::Geometry AlignableObjectId ::muonGeometry(const DTGeometry *, const CSCGeometry *) { +AlignableObjectId::Geometry AlignableObjectId ::muonGeometry(const DTGeometry *, + const CSCGeometry *, + const GEMGeometry *) { // muon alignment structure types are identical for all kinds of geometries return Geometry::General; } diff --git a/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorAsAnalyzer.cc b/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorAsAnalyzer.cc index 5110c25217cf0..1f880d9574d14 100644 --- a/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorAsAnalyzer.cc +++ b/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorAsAnalyzer.cc @@ -39,6 +39,7 @@ #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/Records/interface/TrackerTopologyRcd.h" #include "Geometry/CommonTopologies/interface/GeometryAligner.h" #include "CondFormats/GeometryObjects/interface/PTrackerParameters.h" @@ -50,6 +51,8 @@ #include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h" #include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/GEMAlignmentRcd.h" +#include "CondFormats/AlignmentRecord/interface/GEMAlignmentErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" #include "CondFormats/Alignment/interface/DetectorGlobalPosition.h" @@ -81,7 +84,16 @@ class AlignmentMonitorAsAnalyzer : public edm::EDAnalyzer { std::unique_ptr m_alignmentParameterStore; std::vector> m_monitors; - std::string idealGeometryLabel; + edm::ESGetToken esTokenDT_; + edm::ESGetToken esTokenCSC_; + edm::ESGetToken esTokenGEM_; + edm::ESGetToken esTokenGPR_; + edm::ESGetToken esTokenDTAl_; + edm::ESGetToken esTokenDTAPE_; + edm::ESGetToken esTokenCSCAl_; + edm::ESGetToken esTokenCSCAPE_; + edm::ESGetToken esTokenGEMAl_; + edm::ESGetToken esTokenGEMAPE_; bool m_firstEvent; }; @@ -99,7 +111,9 @@ class AlignmentMonitorAsAnalyzer : public edm::EDAnalyzer { AlignmentMonitorAsAnalyzer::AlignmentMonitorAsAnalyzer(const edm::ParameterSet& iConfig) : m_tjTag(iConfig.getParameter("tjTkAssociationMapTag")), m_aliParamStoreCfg(iConfig.getParameter("ParameterStore")), - idealGeometryLabel("idealForAlignmentMonitorAsAnalyzer") { + esTokenDT_(esConsumes(edm::ESInputTag("", "idealForAlignmentMonitorAsAnalyzer"))), + esTokenCSC_(esConsumes(edm::ESInputTag("", "idealForAlignmentMonitorAsAnalyzer"))), + esTokenGEM_(esConsumes(edm::ESInputTag("", "idealForAlignmentMonitorAsAnalyzer"))) { std::vector monitors = iConfig.getUntrackedParameter>("monitors"); for (auto const& mon : monitors) { @@ -129,13 +143,11 @@ void AlignmentMonitorAsAnalyzer::analyze(const edm::Event& iEvent, const edm::Ev TrackerGeomBuilderFromGeometricDet trackerBuilder; std::shared_ptr theTracker(trackerBuilder.build(&(*theGeometricDet), *ptp, tTopo)); - edm::ESHandle theMuonDT; - edm::ESHandle theMuonCSC; - iSetup.get().get(idealGeometryLabel, theMuonDT); - iSetup.get().get(idealGeometryLabel, theMuonCSC); + edm::ESHandle theMuonDT = iSetup.getHandle(esTokenDT_); + edm::ESHandle theMuonCSC = iSetup.getHandle(esTokenCSC_); + edm::ESHandle theMuonGEM = iSetup.getHandle(esTokenGEM_); - edm::ESHandle globalPositionRcd; - iSetup.get().get(globalPositionRcd); + edm::ESHandle globalPositionRcd = iSetup.getHandle(esTokenGPR_); edm::ESHandle alignments; iSetup.get().get(alignments); @@ -146,29 +158,33 @@ void AlignmentMonitorAsAnalyzer::analyze(const edm::Event& iEvent, const edm::Ev &(*alignmentErrors), align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Tracker))); - edm::ESHandle dtAlignments; - iSetup.get().get(dtAlignments); - edm::ESHandle dtAlignmentErrorsExtended; - iSetup.get().get(dtAlignmentErrorsExtended); + edm::ESHandle dtAlignments = iSetup.getHandle(esTokenDTAl_); + ; + edm::ESHandle dtAlignmentErrorsExtended = iSetup.getHandle(esTokenDTAPE_); aligner.applyAlignments(&(*theMuonDT), &(*dtAlignments), &(*dtAlignmentErrorsExtended), align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); - edm::ESHandle cscAlignments; - iSetup.get().get(cscAlignments); - edm::ESHandle cscAlignmentErrorsExtended; - iSetup.get().get(cscAlignmentErrorsExtended); + edm::ESHandle cscAlignments = iSetup.getHandle(esTokenCSCAl_); + edm::ESHandle cscAlignmentErrorsExtended = iSetup.getHandle(esTokenCSCAPE_); aligner.applyAlignments(&(*theMuonCSC), &(*cscAlignments), &(*cscAlignmentErrorsExtended), align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); + edm::ESHandle gemAlignments = iSetup.getHandle(esTokenGEMAl_); + edm::ESHandle gemAlignmentErrorsExtended = iSetup.getHandle(esTokenGEMAPE_); + aligner.applyAlignments(&(*theMuonGEM), + &(*gemAlignments), + &(*gemAlignmentErrorsExtended), + align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); + // within an analyzer, modules can't expect to see any selected alignables! align::Alignables empty_alignables; m_alignableTracker = std::make_unique(&(*theTracker), tTopo); - m_alignableMuon = std::make_unique(&(*theMuonDT), &(*theMuonCSC)); + m_alignableMuon = std::make_unique(&(*theMuonDT), &(*theMuonCSC), &(*theMuonGEM)); m_alignmentParameterStore = std::make_unique(empty_alignables, m_aliParamStoreCfg); for (auto const& monitor : m_monitors) { diff --git a/Alignment/CommonAlignmentProducer/interface/AlignmentProducerBase.h b/Alignment/CommonAlignmentProducer/interface/AlignmentProducerBase.h index 15b5fdf527bc0..4bc728a74daf0 100644 --- a/Alignment/CommonAlignmentProducer/interface/AlignmentProducerBase.h +++ b/Alignment/CommonAlignmentProducer/interface/AlignmentProducerBase.h @@ -51,6 +51,7 @@ #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/CommonTopologies/interface/GeometryAligner.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" @@ -114,6 +115,7 @@ class AlignmentProducerBase { std::shared_ptr trackerGeometry_; edm::ESHandle muonDTGeometry_; edm::ESHandle muonCSCGeometry_; + edm::ESHandle muonGEMGeometry_; const bool doTracker_, doMuon_, useExtras_; /// Map with tracks/trajectories diff --git a/Alignment/CommonAlignmentProducer/src/AlignmentProducerBase.cc b/Alignment/CommonAlignmentProducer/src/AlignmentProducerBase.cc index 0edb49e973333..cb4743488dd62 100644 --- a/Alignment/CommonAlignmentProducer/src/AlignmentProducerBase.cc +++ b/Alignment/CommonAlignmentProducer/src/AlignmentProducerBase.cc @@ -425,6 +425,7 @@ void AlignmentProducerBase::createGeometries(const edm::EventSetup& iSetup, cons if (doMuon_) { iSetup.get().get(idealGeometryLabel, muonDTGeometry_); iSetup.get().get(idealGeometryLabel, muonCSCGeometry_); + iSetup.get().get(idealGeometryLabel, muonGEMGeometry_); } } @@ -452,6 +453,9 @@ void AlignmentProducerBase::applyAlignmentsToDB(const edm::EventSetup& setup) { applyDB( &*muonCSCGeometry_, setup, align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Muon))); + + applyDB( + &*muonGEMGeometry_, setup, align::DetectorGlobalPosition(*globalPositions_, DetId(DetId::Muon))); } } } @@ -468,9 +472,9 @@ void AlignmentProducerBase::createAlignables(const TrackerTopology* tTopo, bool if (doMuon_) { if (update) { - alignableMuon_->update(&*muonDTGeometry_, &*muonCSCGeometry_); + alignableMuon_->update(&*muonDTGeometry_, &*muonCSCGeometry_, &*muonGEMGeometry_); } else { - alignableMuon_ = std::make_unique(&*muonDTGeometry_, &*muonCSCGeometry_); + alignableMuon_ = std::make_unique(&*muonDTGeometry_, &*muonCSCGeometry_, &*muonGEMGeometry_); } } @@ -646,12 +650,15 @@ void AlignmentProducerBase::applyAlignmentsToGeometry() { std::unique_ptr dtAlignments{alignableMuon_->dtAlignments()}; std::unique_ptr cscAlignments{alignableMuon_->cscAlignments()}; + std::unique_ptr gemAlignments{alignableMuon_->gemAlignments()}; std::unique_ptr dtAlignmentErrExt{alignableMuon_->dtAlignmentErrorsExtended()}; std::unique_ptr cscAlignmentErrExt{alignableMuon_->cscAlignmentErrorsExtended()}; + std::unique_ptr gemAlignmentErrExt{alignableMuon_->gemAlignmentErrorsExtended()}; aligner.applyAlignments(&*muonDTGeometry_, dtAlignments.get(), dtAlignmentErrExt.get(), AlignTransform()); aligner.applyAlignments(&*muonCSCGeometry_, cscAlignments.get(), cscAlignmentErrExt.get(), AlignTransform()); + aligner.applyAlignments(&*muonGEMGeometry_, gemAlignments.get(), gemAlignmentErrExt.get(), AlignTransform()); } } diff --git a/Alignment/MuonAlignment/BuildFile.xml b/Alignment/MuonAlignment/BuildFile.xml index 5d86f492501ad..5b2b355dc9328 100644 --- a/Alignment/MuonAlignment/BuildFile.xml +++ b/Alignment/MuonAlignment/BuildFile.xml @@ -5,6 +5,7 @@ + diff --git a/Alignment/MuonAlignment/interface/AlignableGEMChamber.h b/Alignment/MuonAlignment/interface/AlignableGEMChamber.h new file mode 100644 index 0000000000000..e7dc8e2194b4c --- /dev/null +++ b/Alignment/MuonAlignment/interface/AlignableGEMChamber.h @@ -0,0 +1,27 @@ +#ifndef Alignment_MuonAlignment_AlignableGEMChamber_H +#define Alignment_MuonAlignment_AlignableGEMChamber_H + +/* \class AlignableGEMChamber + * \author Hyunyong Kim - TAMU + */ + +#include +#include +#include + +#include "Alignment/CommonAlignment/interface/StructureType.h" +#include "Alignment/CommonAlignment/interface/AlignableDet.h" + +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Alignment/CommonAlignment/interface/AlignableComposite.h" + +class AlignableGEMChamber : public AlignableDet { +public: + friend std::ostream& operator<<(std::ostream&, const AlignableGEMChamber&); + + AlignableGEMChamber(const GeomDet* geomDet); + + void update(const GeomDet* geomDet); +}; + +#endif diff --git a/Alignment/MuonAlignment/interface/AlignableGEMEndcap.h b/Alignment/MuonAlignment/interface/AlignableGEMEndcap.h new file mode 100644 index 0000000000000..88ab2474f3a8e --- /dev/null +++ b/Alignment/MuonAlignment/interface/AlignableGEMEndcap.h @@ -0,0 +1,42 @@ +#ifndef Alignment_MuonAlignment_AlignableGEMEndcap_H +#define Alignment_MuonAlignment_AlignableGEMEndcap_H + +/* \class AlignableGEMEndcap + * \author Hyunyong Kim - TAMU + */ + +#include "Alignment/CommonAlignment/interface/Utilities.h" +#include "Alignment/CommonAlignment/interface/AlignableComposite.h" +#include "Alignment/CommonAlignment/interface/AlignableSurface.h" + +#include "Alignment/MuonAlignment/interface/AlignableGEMStation.h" + +#include + +class GeomDet; + +class AlignableGEMEndcap : public AlignableComposite { +public: + AlignableGEMEndcap(const std::vector& GEMStations); + + PositionType computePosition(); + + RotationType computeOrientation(); + + AlignableSurface computeSurface(); + + AlignableGEMStation& station(int i); + + friend std::ostream& operator<<(std::ostream&, const AlignableGEMEndcap&); + + void dump(void) const override; + + Alignments* alignments() const override; + + AlignmentErrorsExtended* alignmentErrors() const override; + +private: + std::vector theGEMStations; +}; + +#endif diff --git a/Alignment/MuonAlignment/interface/AlignableGEMRing.h b/Alignment/MuonAlignment/interface/AlignableGEMRing.h new file mode 100644 index 0000000000000..91cf235b627a1 --- /dev/null +++ b/Alignment/MuonAlignment/interface/AlignableGEMRing.h @@ -0,0 +1,36 @@ +#ifndef Alignment_MuonAlignment_AlignableGEMRing_H +#define Alignment_MuonAlignment_AlignableGEMRing_H + +/* \class AlignableGEMRing + * \author Hyunyong Kim - TAMU + */ + +#include "Alignment/CommonAlignment/interface/Utilities.h" +#include "Alignment/CommonAlignment/interface/AlignableComposite.h" +#include "Alignment/CommonAlignment/interface/AlignableSurface.h" +#include "Alignment/MuonAlignment/interface/AlignableGEMSuperChamber.h" +#include + +class GeomDet; + +class AlignableGEMRing : public AlignableComposite { +public: + AlignableGEMRing(const std::vector& GEMSuperChambers); + + PositionType computePosition(); + + RotationType computeOrientation(); + + AlignableSurface computeSurface(); + + AlignableGEMSuperChamber& superChamber(int i); + + friend std::ostream& operator<<(std::ostream&, const AlignableGEMRing&); + + void dump(void) const override; + +private: + std::vector theGEMSuperChambers; +}; + +#endif diff --git a/Alignment/MuonAlignment/interface/AlignableGEMStation.h b/Alignment/MuonAlignment/interface/AlignableGEMStation.h new file mode 100644 index 0000000000000..a8f025112d1b3 --- /dev/null +++ b/Alignment/MuonAlignment/interface/AlignableGEMStation.h @@ -0,0 +1,39 @@ +#ifndef Alignment_MuonAlignment_AlignableGEMStation_H +#define Alignment_MuonAlignment_AlignableGEMStation_H + +/* \class AlignableGEMRing + * \author Hyunyong Kim - TAMU + */ + +#include "Alignment/CommonAlignment/interface/Utilities.h" +#include "Alignment/CommonAlignment/interface/AlignableComposite.h" +#include "Alignment/CommonAlignment/interface/AlignableSurface.h" + +#include "Alignment/MuonAlignment/interface/AlignableGEMRing.h" + +#include + +class GeomDet; +class AlignableGEMRing; + +class AlignableGEMStation : public AlignableComposite { +public: + AlignableGEMStation(const std::vector& GEMRings); + + PositionType computePosition(); + + RotationType computeOrientation(); + + AlignableSurface computeSurface(); + + AlignableGEMRing& ring(int i); + + friend std::ostream& operator<<(std::ostream&, const AlignableGEMStation&); + + void dump(void) const override; + +private: + std::vector theGEMRings; +}; + +#endif diff --git a/Alignment/MuonAlignment/interface/AlignableGEMSuperChamber.h b/Alignment/MuonAlignment/interface/AlignableGEMSuperChamber.h new file mode 100644 index 0000000000000..8c2bb1986ff22 --- /dev/null +++ b/Alignment/MuonAlignment/interface/AlignableGEMSuperChamber.h @@ -0,0 +1,27 @@ +#ifndef Alignment_MuonAlignment_AlignableGEMSuperChamber_H +#define Alignment_MuonAlignment_AlignableGEMSuperChamber_H + +/* \class AlignableGEMSuperChamber + * \author Hyunyong Kim - TAMU + */ + +#include +#include +#include + +#include "Alignment/CommonAlignment/interface/StructureType.h" +#include "Alignment/CommonAlignment/interface/AlignableDet.h" + +#include "Geometry/CommonDetUnit/interface/GeomDet.h" +#include "Alignment/CommonAlignment/interface/AlignableComposite.h" + +class AlignableGEMSuperChamber : public AlignableDet { +public: + friend std::ostream& operator<<(std::ostream&, const AlignableGEMSuperChamber&); + + AlignableGEMSuperChamber(const GeomDet* geomDet); + + void update(const GeomDet* geomDet); +}; + +#endif diff --git a/Alignment/MuonAlignment/interface/AlignableMuon.h b/Alignment/MuonAlignment/interface/AlignableMuon.h index 9821bd2d256f7..7f5099fba0176 100644 --- a/Alignment/MuonAlignment/interface/AlignableMuon.h +++ b/Alignment/MuonAlignment/interface/AlignableMuon.h @@ -17,6 +17,7 @@ #include "Alignment/CommonAlignment/interface/AlignableObjectId.h" class CSCGeometry; +class GEMGeometry; // Classes that will be used to construct the muon class AlignableDTBarrel; @@ -27,20 +28,24 @@ class AlignableCSCEndcap; class AlignableCSCStation; class AlignableCSCRing; class AlignableCSCChamber; +class AlignableGEMEndcap; +class AlignableGEMStation; +class AlignableGEMRing; +class AlignableGEMSuperChamber; /// Constructor of the full muon geometry. class AlignableMuon : public AlignableComposite { public: /// Constructor from geometries - AlignableMuon(const DTGeometry*, const CSCGeometry*); + AlignableMuon(const DTGeometry*, const CSCGeometry*, const GEMGeometry*); /// Destructor ~AlignableMuon() override; /// Updater using DTGeometry and CSCGeometry. /// The given geometries have to match the current ones. - void update(const DTGeometry*, const CSCGeometry*); + void update(const DTGeometry*, const CSCGeometry*, const GEMGeometry*); /// Return all components const align::Alignables& components() const final { return theMuonComponents; } @@ -60,6 +65,12 @@ class AlignableMuon : public AlignableComposite { align::Alignables CSCStations(); align::Alignables CSCRings(); align::Alignables CSCEndcaps(); + align::Alignables GEMEtaPartitions(); + align::Alignables GEMChambers(); + align::Alignables GEMSuperChambers(); + align::Alignables GEMStations(); + align::Alignables GEMRings(); + align::Alignables GEMEndcaps(); /// Get DT alignments sorted by DetId Alignments* dtAlignments(); @@ -70,9 +81,13 @@ class AlignableMuon : public AlignableComposite { /// Get CSC alignments sorted by DetId Alignments* cscAlignments(); + Alignments* gemAlignments(); + /// Get CSC alignment errors sorted by DetId AlignmentErrorsExtended* cscAlignmentErrorsExtended(); + AlignmentErrorsExtended* gemAlignmentErrorsExtended(); + /// Return muon alignable object ID provider derived from the muon system geometry const AlignableObjectId& objectIdProvider() const { return alignableObjectId_; } @@ -100,6 +115,8 @@ class AlignableMuon : public AlignableComposite { /// Build muon end caps void buildCSCEndcap(const CSCGeometry*, bool update = false); + void buildGEMEndcap(const GEMGeometry*, bool update = false); + /// Set mothers recursively void recursiveSetMothers(Alignable* alignable); @@ -117,6 +134,11 @@ class AlignableMuon : public AlignableComposite { std::vector theCSCRings; std::vector theCSCEndcaps; + std::vector theGEMSuperChambers; + std::vector theGEMStations; + std::vector theGEMRings; + std::vector theGEMEndcaps; + align::Alignables theMuonComponents; }; diff --git a/Alignment/MuonAlignment/interface/MuonAlignment.h b/Alignment/MuonAlignment/interface/MuonAlignment.h index c29ee34f4c29e..ec70e349ca87f 100644 --- a/Alignment/MuonAlignment/interface/MuonAlignment.h +++ b/Alignment/MuonAlignment/interface/MuonAlignment.h @@ -13,9 +13,10 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Alignment/MuonAlignment/interface/AlignableMuon.h" -#include +#include "FWCore/Framework/interface/Frameworkfwd.h" #include "Alignment/CommonAlignment/interface/AlignableNavigator.h" #include "Alignment/MuonAlignment/interface/MuonAlignmentInputMethod.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" class MuonAlignment { public: @@ -52,6 +53,7 @@ class MuonAlignment { void saveDTtoDB(); void saveCSCtoDB(); + void saveGEMtoDB(); void saveToDB(); private: @@ -60,9 +62,14 @@ class MuonAlignment { std::string theDTAlignRecordName, theDTErrorRecordName; std::string theCSCAlignRecordName, theCSCErrorRecordName; + std::string theGEMAlignRecordName, theGEMErrorRecordName; std::string theDTSurveyRecordName, theDTSurveyErrorRecordName; std::string theCSCSurveyRecordName, theCSCSurveyErrorRecordName; + edm::ESGetToken esTokenDT_; + edm::ESGetToken esTokenCSC_; + edm::ESGetToken esTokenGEM_; + align::Scalars displacements; align::Scalars rotations; diff --git a/Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h b/Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h index c6ad85431d7b3..7cd459cbd8531 100644 --- a/Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h +++ b/Alignment/MuonAlignment/interface/MuonAlignmentInputDB.h @@ -29,7 +29,8 @@ class MuonAlignmentInputDB : public MuonAlignmentInputMethod { public: MuonAlignmentInputDB(); - MuonAlignmentInputDB(std::string dtLabel, std::string cscLabel, std::string idealLabel, bool getAPEs); + MuonAlignmentInputDB( + std::string dtLabel, std::string cscLabel, std::string gemLabel, std::string idealLabel, bool getAPEs); ~MuonAlignmentInputDB() override; // ---------- const member functions --------------------- @@ -47,7 +48,7 @@ class MuonAlignmentInputDB : public MuonAlignmentInputMethod { // ---------- member data -------------------------------- - std::string m_dtLabel, m_cscLabel, idealGeometryLabel; + std::string m_dtLabel, m_cscLabel, m_gemLabel, idealGeometryLabel; bool m_getAPEs; }; diff --git a/Alignment/MuonAlignment/interface/MuonScenarioBuilder.h b/Alignment/MuonAlignment/interface/MuonScenarioBuilder.h index d8c4e0bd35e1d..07f503f6aec05 100644 --- a/Alignment/MuonAlignment/interface/MuonScenarioBuilder.h +++ b/Alignment/MuonAlignment/interface/MuonScenarioBuilder.h @@ -33,6 +33,8 @@ class MuonScenarioBuilder : public MisalignmentScenarioBuilder { /// this special method allows to move a CSCsector by a same amount void moveCSCSectors(const edm::ParameterSet& scenario); + void moveGEMSectors(const edm::ParameterSet& scenario); + /// this special method allows to move the complete muon system by a same amount void moveMuon(const edm::ParameterSet& scenario); diff --git a/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc b/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc index 8e61794fa1511..5afd04cf3f02f 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc +++ b/Alignment/MuonAlignment/plugins/MuonGeometryDBConverter.cc @@ -54,7 +54,7 @@ class MuonGeometryDBConverter : public edm::one::EDAnalyzer<> { bool m_done; std::string m_input, m_output; - std::string m_dtLabel, m_cscLabel; + std::string m_dtLabel, m_cscLabel, m_gemLabel; double m_shiftErr, m_angleErr; std::string m_fileName; bool m_getAPEs; @@ -101,6 +101,7 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi else if (m_input == std::string("db")) { m_dtLabel = iConfig.getParameter("dtLabel"); m_cscLabel = iConfig.getParameter("cscLabel"); + m_gemLabel = iConfig.getParameter("gemLabel"); m_shiftErr = iConfig.getParameter("shiftErr"); m_angleErr = iConfig.getParameter("angleErr"); m_getAPEs = iConfig.getParameter("getAPEs"); @@ -109,6 +110,7 @@ MuonGeometryDBConverter::MuonGeometryDBConverter(const edm::ParameterSet &iConfi 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")) { @@ -159,7 +161,7 @@ void MuonGeometryDBConverter::analyze(const edm::Event &iEvent, const edm::Event } else if (m_input == std::string("db")) { - MuonAlignmentInputDB inputMethod(m_dtLabel, m_cscLabel, idealGeometryLabelForInputDB, m_getAPEs); + MuonAlignmentInputDB inputMethod(m_dtLabel, m_cscLabel, m_gemLabel, idealGeometryLabelForInputDB, m_getAPEs); muonAlignment = new MuonAlignment(iSetup, inputMethod); if (m_getAPEs) { muonAlignment->copyAlignmentToSurvey(m_shiftErr, m_angleErr); @@ -222,6 +224,7 @@ void MuonGeometryDBConverter::fillDescriptions(edm::ConfigurationDescriptions &d desc.add("input", "ideal"); desc.add("dtLabel", ""); desc.add("cscLabel", ""); + desc.add("gemLabel", ""); desc.add("shiftErr", 1000.0); desc.add("angleErr", 6.28); desc.add("getAPEs", true); diff --git a/Alignment/MuonAlignment/plugins/MuonMisalignedProducer.cc b/Alignment/MuonAlignment/plugins/MuonMisalignedProducer.cc index 4bda51a0360d8..ae2b1e1872b0b 100644 --- a/Alignment/MuonAlignment/plugins/MuonMisalignedProducer.cc +++ b/Alignment/MuonAlignment/plugins/MuonMisalignedProducer.cc @@ -26,6 +26,7 @@ #include "Alignment/MuonAlignment/interface/AlignableMuon.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Alignment/MuonAlignment/interface/MuonScenarioBuilder.h" #include "Alignment/CommonAlignment/interface/Alignable.h" #include "Geometry/CommonTopologies/interface/GeometryAligner.h" @@ -33,6 +34,8 @@ #include +#include + class MuonMisalignedProducer : public edm::one::EDAnalyzer<> { public: /// Constructor @@ -52,12 +55,18 @@ class MuonMisalignedProducer : public edm::one::EDAnalyzer<> { std::string theDTAlignRecordName, theDTErrorRecordName; std::string theCSCAlignRecordName, theCSCErrorRecordName; - std::string theIdealGeometryLabel; + std::string theGEMAlignRecordName, theGEMErrorRecordName; + + edm::ESGetToken esTokenDT_; + edm::ESGetToken esTokenCSC_; + edm::ESGetToken esTokenGEM_; Alignments* dt_Alignments; AlignmentErrorsExtended* dt_AlignmentErrorsExtended; Alignments* csc_Alignments; AlignmentErrorsExtended* csc_AlignmentErrorsExtended; + Alignments* gem_Alignments; + AlignmentErrorsExtended* gem_AlignmentErrorsExtended; }; //__________________________________________________________________________________________________ @@ -68,7 +77,11 @@ MuonMisalignedProducer::MuonMisalignedProducer(const edm::ParameterSet& p) theDTErrorRecordName("DTAlignmentErrorExtendedRcd"), theCSCAlignRecordName("CSCAlignmentRcd"), theCSCErrorRecordName("CSCAlignmentErrorExtendedRcd"), - theIdealGeometryLabel("idealForMuonMisalignedProducer") {} + theGEMAlignRecordName("GEMAlignmentRcd"), + theGEMErrorRecordName("GEMAlignmentErrorExtendedRcd"), + esTokenDT_(esConsumes(edm::ESInputTag("", "idealForMuonMisalignedProducer"))), + esTokenCSC_(esConsumes(edm::ESInputTag("", "idealForMuonMisalignedProducer"))), + esTokenGEM_(esConsumes(edm::ESInputTag("", "idealForMuonMisalignedProducer"))) {} //__________________________________________________________________________________________________ MuonMisalignedProducer::~MuonMisalignedProducer() {} @@ -77,13 +90,12 @@ MuonMisalignedProducer::~MuonMisalignedProducer() {} void MuonMisalignedProducer::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) { edm::LogInfo("MisalignedMuon") << "Producer called"; // Create the Muon geometry from ideal geometry - edm::ESHandle theDTGeometry; - edm::ESHandle theCSCGeometry; - eventSetup.get().get(theIdealGeometryLabel, theDTGeometry); - eventSetup.get().get(theIdealGeometryLabel, theCSCGeometry); + edm::ESHandle theDTGeometry = eventSetup.getHandle(esTokenDT_); + edm::ESHandle theCSCGeometry = eventSetup.getHandle(esTokenCSC_); + edm::ESHandle theGEMGeometry = eventSetup.getHandle(esTokenGEM_); // Create the alignable hierarchy - AlignableMuon* theAlignableMuon = new AlignableMuon(&(*theDTGeometry), &(*theCSCGeometry)); + AlignableMuon* theAlignableMuon = new AlignableMuon(&(*theDTGeometry), &(*theCSCGeometry), &(*theGEMGeometry)); // Create misalignment scenario MuonScenarioBuilder scenarioBuilder(theAlignableMuon); @@ -94,14 +106,17 @@ void MuonMisalignedProducer::analyze(const edm::Event& event, const edm::EventSe dt_AlignmentErrorsExtended = theAlignableMuon->dtAlignmentErrorsExtended(); csc_Alignments = theAlignableMuon->cscAlignments(); csc_AlignmentErrorsExtended = theAlignableMuon->cscAlignmentErrorsExtended(); + gem_Alignments = theAlignableMuon->gemAlignments(); + gem_AlignmentErrorsExtended = theAlignableMuon->gemAlignmentErrorsExtended(); // Misalign the EventSetup geometry - GeometryAligner aligner; - + /* GeometryAligner aligner; aligner.applyAlignments(&(*theDTGeometry), dt_Alignments, dt_AlignmentErrorsExtended, AlignTransform()); aligner.applyAlignments( &(*theCSCGeometry), csc_Alignments, csc_AlignmentErrorsExtended, AlignTransform()); - + aligner.applyAlignments( + &(*theGEMGeometry), gem_Alignments, gem_AlignmentErrorsExtended, AlignTransform()); + */ // Write alignments to DB if (theSaveToDB) this->saveToDB(); @@ -125,6 +140,9 @@ void MuonMisalignedProducer::saveToDB(void) { poolDbService->writeOne(&(*csc_Alignments), poolDbService->beginOfTime(), theCSCAlignRecordName); poolDbService->writeOne( &(*csc_AlignmentErrorsExtended), poolDbService->beginOfTime(), theCSCErrorRecordName); + poolDbService->writeOne(&(*gem_Alignments), poolDbService->beginOfTime(), theGEMAlignRecordName); + poolDbService->writeOne( + &(*gem_AlignmentErrorsExtended), poolDbService->beginOfTime(), theGEMErrorRecordName); } //____________________________________________________________________________________________ DEFINE_FWK_MODULE(MuonMisalignedProducer); diff --git a/Alignment/MuonAlignment/src/AlignableGEMChamber.cc b/Alignment/MuonAlignment/src/AlignableGEMChamber.cc new file mode 100644 index 0000000000000..d7e89a088449d --- /dev/null +++ b/Alignment/MuonAlignment/src/AlignableGEMChamber.cc @@ -0,0 +1,41 @@ +/* AlignableGEMChamber + * \author Hyunyong Kim - TAMU + */ +#include "Alignment/MuonAlignment/interface/AlignableGEMChamber.h" + +AlignableGEMChamber::AlignableGEMChamber(const GeomDet* geomDet) : AlignableDet(geomDet) { + theStructureType = align::AlignableGEMChamber; + theSurface = geomDet->surface(); +} + +void AlignableGEMChamber::update(const GeomDet* geomDet) { + AlignableDet::update(geomDet); + theSurface = geomDet->surface(); +} + +std::ostream& operator<<(std::ostream& os, const AlignableGEMChamber& r) { + const auto& theDets = r.components(); + + os << " This GEMChamber contains " << theDets.size() << " units" << std::endl; + os << " position = " << r.globalPosition() << std::endl; + os << " (phi, r, z)= (" << r.globalPosition().phi() << "," << r.globalPosition().perp() << "," + << r.globalPosition().z(); + os << "), orientation:" << std::endl << r.globalRotation() << std::endl; + + os << " total displacement and rotation: " << r.displacement() << std::endl; + os << r.rotation() << std::endl; + + for (const auto& idet : theDets) { + const auto& comp = idet->components(); + + for (unsigned int i = 0; i < comp.size(); ++i) { + os << " Det position, phi, r: " << comp[i]->globalPosition() << " , " << comp[i]->globalPosition().phi() + << " , " << comp[i]->globalPosition().perp() << std::endl; + os << " local position, phi, r: " << r.surface().toLocal(comp[i]->globalPosition()) << " , " + << r.surface().toLocal(comp[i]->globalPosition()).phi() << " , " + << r.surface().toLocal(comp[i]->globalPosition()).perp() << std::endl; + } + } + + return os; +} diff --git a/Alignment/MuonAlignment/src/AlignableGEMEndcap.cc b/Alignment/MuonAlignment/src/AlignableGEMEndcap.cc new file mode 100644 index 0000000000000..a2681d3a1f265 --- /dev/null +++ b/Alignment/MuonAlignment/src/AlignableGEMEndcap.cc @@ -0,0 +1,92 @@ +/* AlignableGEMEndcap + * \author Hyunyong Kim - TAMU + */ +#include + +#include "Alignment/MuonAlignment/interface/AlignableGEMEndcap.h" +#include "CondFormats/Alignment/interface/Alignments.h" +#include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +AlignableGEMEndcap::AlignableGEMEndcap(const std::vector& GEMStations) + : AlignableComposite(GEMStations[0]->id(), align::AlignableGEMEndcap) { + theGEMStations.insert(theGEMStations.end(), GEMStations.begin(), GEMStations.end()); + + for (const auto& station : GEMStations) { + const auto mother = station->mother(); + this->addComponent(station); + station->setMother(mother); + } + + setSurface(computeSurface()); + compConstraintType_ = Alignable::CompConstraintType::POSITION_Z; +} + +AlignableGEMStation& AlignableGEMEndcap::station(int i) { + if (i >= size()) + throw cms::Exception("LogicError") << "Station index (" << i << ") out of range"; + + return *theGEMStations[i]; +} + +AlignableSurface AlignableGEMEndcap::computeSurface() { + return AlignableSurface(computePosition(), computeOrientation()); +} + +AlignableGEMEndcap::PositionType AlignableGEMEndcap::computePosition() { + float zz = 0.; + + for (std::vector::iterator ilayer = theGEMStations.begin(); ilayer != theGEMStations.end(); + ilayer++) + zz += (*ilayer)->globalPosition().z(); + + zz /= static_cast(theGEMStations.size()); + + return PositionType(0.0, 0.0, zz); +} + +AlignableGEMEndcap::RotationType AlignableGEMEndcap::computeOrientation() { return RotationType(); } + +std::ostream& operator<<(std::ostream& os, const AlignableGEMEndcap& b) { + os << "This EndCap contains " << b.theGEMStations.size() << " GEM stations" << std::endl; + os << "(phi, r, z) = (" << b.globalPosition().phi() << "," << b.globalPosition().perp() << "," + << b.globalPosition().z(); + os << "), orientation:" << std::endl << b.globalRotation() << std::endl; + return os; +} + +void AlignableGEMEndcap::dump(void) const { + edm::LogInfo("AlignableDump") << (*this); + for (std::vector::const_iterator iLayer = theGEMStations.begin(); + iLayer != theGEMStations.end(); + iLayer++) + (*iLayer)->dump(); +} + +Alignments* AlignableGEMEndcap::alignments(void) const { + Alignments* m_alignments = new Alignments(); + + for (const auto& i : this->components()) { + std::unique_ptr tmpAlignments{i->alignments()}; + std::copy(tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(), std::back_inserter(m_alignments->m_align)); + } + + std::sort(m_alignments->m_align.begin(), m_alignments->m_align.end()); + + return m_alignments; +} + +AlignmentErrorsExtended* AlignableGEMEndcap::alignmentErrors(void) const { + AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended(); + + for (const auto& i : this->components()) { + std::unique_ptr tmpAlignmentErrorsExtended{i->alignmentErrors()}; + std::copy(tmpAlignmentErrorsExtended->m_alignError.begin(), + tmpAlignmentErrorsExtended->m_alignError.end(), + std::back_inserter(m_alignmentErrors->m_alignError)); + } + + std::sort(m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end()); + + return m_alignmentErrors; +} diff --git a/Alignment/MuonAlignment/src/AlignableGEMRing.cc b/Alignment/MuonAlignment/src/AlignableGEMRing.cc new file mode 100644 index 0000000000000..008220d3e79c8 --- /dev/null +++ b/Alignment/MuonAlignment/src/AlignableGEMRing.cc @@ -0,0 +1,61 @@ +/* AlignableGEMRing + * \author Hyunyong Kim - TAMU + */ +#include "Alignment/MuonAlignment/interface/AlignableGEMRing.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +AlignableGEMRing::AlignableGEMRing(const std::vector& GEMSuperChambers) + : AlignableComposite(GEMSuperChambers[0]->id(), align::AlignableGEMRing) { + theGEMSuperChambers.insert(theGEMSuperChambers.end(), GEMSuperChambers.begin(), GEMSuperChambers.end()); + + for (const auto& chamber : GEMSuperChambers) { + const auto mother = chamber->mother(); + this->addComponent(chamber); + chamber->setMother(mother); + } + + setSurface(computeSurface()); + compConstraintType_ = Alignable::CompConstraintType::POSITION_Z; +} + +AlignableGEMSuperChamber& AlignableGEMRing::superChamber(int i) { + if (i >= size()) + throw cms::Exception("LogicError") << "GEM Super Chamber index (" << i << ") out of range"; + + return *theGEMSuperChambers[i]; +} + +AlignableSurface AlignableGEMRing::computeSurface() { + return AlignableSurface(computePosition(), computeOrientation()); +} + +AlignableGEMRing::PositionType AlignableGEMRing::computePosition() { + float zz = 0.; + + for (std::vector::iterator ichamber = theGEMSuperChambers.begin(); + ichamber != theGEMSuperChambers.end(); + ichamber++) + zz += (*ichamber)->globalPosition().z(); + + zz /= static_cast(theGEMSuperChambers.size()); + + return PositionType(0.0, 0.0, zz); +} + +AlignableGEMRing::RotationType AlignableGEMRing::computeOrientation() { return RotationType(); } + +std::ostream& operator<<(std::ostream& os, const AlignableGEMRing& b) { + os << "This GEM Ring contains " << b.theGEMSuperChambers.size() << " GEM Super chambers" << std::endl; + os << "(phi, r, z) = (" << b.globalPosition().phi() << "," << b.globalPosition().perp() << "," + << b.globalPosition().z(); + os << "), orientation:" << std::endl << b.globalRotation() << std::endl; + return os; +} + +void AlignableGEMRing::dump(void) const { + edm::LogInfo("AlignableDump") << (*this); + for (std::vector::const_iterator iChamber = theGEMSuperChambers.begin(); + iChamber != theGEMSuperChambers.end(); + iChamber++) + edm::LogInfo("AlignableDump") << (**iChamber); +} diff --git a/Alignment/MuonAlignment/src/AlignableGEMStation.cc b/Alignment/MuonAlignment/src/AlignableGEMStation.cc new file mode 100644 index 0000000000000..91cefa4a550b3 --- /dev/null +++ b/Alignment/MuonAlignment/src/AlignableGEMStation.cc @@ -0,0 +1,57 @@ +/* AlignableGEMStation + * \author Hyunyong Kim - TAMU + */ +#include "Alignment/MuonAlignment/interface/AlignableGEMStation.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +AlignableGEMStation::AlignableGEMStation(const std::vector& GEMRings) + : AlignableComposite(GEMRings[0]->id(), align::AlignableGEMStation) { + theGEMRings.insert(theGEMRings.end(), GEMRings.begin(), GEMRings.end()); + + for (const auto& ring : GEMRings) { + const auto mother = ring->mother(); + this->addComponent(ring); + ring->setMother(mother); + } + + setSurface(computeSurface()); + compConstraintType_ = Alignable::CompConstraintType::POSITION_Z; +} + +AlignableGEMRing& AlignableGEMStation::ring(int i) { + if (i >= size()) + throw cms::Exception("LogicError") << "GEM Ring index (" << i << ") out of range"; + + return *theGEMRings[i]; +} + +AlignableSurface AlignableGEMStation::computeSurface() { + return AlignableSurface(computePosition(), computeOrientation()); +} + +AlignableGEMStation::PositionType AlignableGEMStation::computePosition() { + float zz = 0.; + + for (std::vector::iterator ilayer = theGEMRings.begin(); ilayer != theGEMRings.end(); ilayer++) + zz += (*ilayer)->globalPosition().z(); + + zz /= static_cast(theGEMRings.size()); + + return PositionType(0.0, 0.0, zz); +} + +AlignableGEMStation::RotationType AlignableGEMStation::computeOrientation() { return RotationType(); } + +std::ostream& operator<<(std::ostream& os, const AlignableGEMStation& b) { + os << "This GEM Station contains " << b.theGEMRings.size() << " GEM rings" << std::endl; + os << "(phi, r, z) = (" << b.globalPosition().phi() << "," << b.globalPosition().perp() << "," + << b.globalPosition().z(); + os << "), orientation:" << std::endl << b.globalRotation() << std::endl; + return os; +} + +void AlignableGEMStation::dump(void) const { + edm::LogInfo("AlignableDump") << (*this); + for (std::vector::const_iterator iRing = theGEMRings.begin(); iRing != theGEMRings.end(); iRing++) + edm::LogInfo("AlignableDump") << (**iRing); +} diff --git a/Alignment/MuonAlignment/src/AlignableGEMSuperChamber.cc b/Alignment/MuonAlignment/src/AlignableGEMSuperChamber.cc new file mode 100644 index 0000000000000..3f9a223168ae6 --- /dev/null +++ b/Alignment/MuonAlignment/src/AlignableGEMSuperChamber.cc @@ -0,0 +1,46 @@ +/* AlignableGEMSuperChamber + * \author Hyunyong Kim - TAMU + */ +#include "Alignment/MuonAlignment/interface/AlignableGEMSuperChamber.h" +#include "Alignment/MuonAlignment/interface/AlignableGEMChamber.h" + +AlignableGEMSuperChamber::AlignableGEMSuperChamber(const GeomDet* geomDet) : AlignableDet(geomDet, false) { + theStructureType = align::AlignableGEMSuperChamber; + const std::vector& geomDets = geomDet->components(); + for (std::vector::const_iterator idet = geomDets.begin(); idet != geomDets.end(); ++idet) { + addComponent(new AlignableGEMChamber(*idet)); + } + this->theSurface = geomDet->surface(); +} + +void AlignableGEMSuperChamber::update(const GeomDet* geomDet) { + AlignableDet::update(geomDet); + theSurface = geomDet->surface(); +} + +std::ostream& operator<<(std::ostream& os, const AlignableGEMSuperChamber& r) { + const auto& theDets = r.components(); + + os << " This GEMSuperChamber contains " << theDets.size() << " units" << std::endl; + os << " position = " << r.globalPosition() << std::endl; + os << " (phi, r, z)= (" << r.globalPosition().phi() << "," << r.globalPosition().perp() << "," + << r.globalPosition().z(); + os << "), orientation:" << std::endl << r.globalRotation() << std::endl; + + os << " total displacement and rotation: " << r.displacement() << std::endl; + os << r.rotation() << std::endl; + + for (const auto& idet : theDets) { + const auto& comp = idet->components(); + + for (unsigned int i = 0; i < comp.size(); ++i) { + os << " Det position, phi, r: " << comp[i]->globalPosition() << " , " << comp[i]->globalPosition().phi() + << " , " << comp[i]->globalPosition().perp() << std::endl; + os << " local position, phi, r: " << r.surface().toLocal(comp[i]->globalPosition()) << " , " + << r.surface().toLocal(comp[i]->globalPosition()).phi() << " , " + << r.surface().toLocal(comp[i]->globalPosition()).perp() << std::endl; + } + } + + return os; +} diff --git a/Alignment/MuonAlignment/src/AlignableMuon.cc b/Alignment/MuonAlignment/src/AlignableMuon.cc index faea5591ead99..032b8dbd80f44 100644 --- a/Alignment/MuonAlignment/src/AlignableMuon.cc +++ b/Alignment/MuonAlignment/src/AlignableMuon.cc @@ -11,29 +11,39 @@ #include "Alignment/MuonAlignment/interface/AlignableMuon.h" #include "Geometry/DTGeometry/interface/DTChamber.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include #include "CondFormats/Alignment/interface/Alignments.h" #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h" - +#include "Geometry/CommonDetUnit/interface/GeomDet.h" // Muon components -#include "Alignment/MuonAlignment/interface/AlignableDTChamber.h" -#include "Alignment/MuonAlignment/interface/AlignableCSCChamber.h" +#include "Alignment/MuonAlignment/interface/AlignableDTBarrel.h" #include "Alignment/MuonAlignment/interface/AlignableDTStation.h" -#include "Geometry/CommonDetUnit/interface/GeomDet.h" -#include "Alignment/MuonAlignment/interface/AlignableCSCStation.h" #include "Alignment/MuonAlignment/interface/AlignableDTWheel.h" -#include "Alignment/MuonAlignment/interface/AlignableDTBarrel.h" +#include "Alignment/MuonAlignment/interface/AlignableDTChamber.h" #include "Alignment/MuonAlignment/interface/AlignableCSCEndcap.h" +#include "Alignment/MuonAlignment/interface/AlignableCSCStation.h" +#include "Alignment/MuonAlignment/interface/AlignableCSCRing.h" +#include "Alignment/MuonAlignment/interface/AlignableCSCChamber.h" +#include "Alignment/MuonAlignment/interface/AlignableGEMEndcap.h" +#include "Alignment/MuonAlignment/interface/AlignableGEMStation.h" +#include "Alignment/MuonAlignment/interface/AlignableGEMRing.h" +#include "Alignment/MuonAlignment/interface/AlignableGEMSuperChamber.h" + +#include //-------------------------------------------------------------------------------------------------- -AlignableMuon::AlignableMuon(const DTGeometry* dtGeometry, const CSCGeometry* cscGeometry) +AlignableMuon::AlignableMuon(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry) : AlignableComposite(0, align::AlignableMuon), // cannot yet set id, use 0 - alignableObjectId_(nullptr, dtGeometry, cscGeometry) { + alignableObjectId_(nullptr, dtGeometry, cscGeometry, gemGeometry) { // Build the muon barrel buildDTBarrel(dtGeometry); // Build the muon end caps buildCSCEndcap(cscGeometry); + buildGEMEndcap(gemGeometry); // Set links to mothers recursively recursiveSetMothers(this); @@ -52,12 +62,15 @@ AlignableMuon::~AlignableMuon() { } //------------------------------------------------------------------------------ -void AlignableMuon::update(const DTGeometry* dtGeometry, const CSCGeometry* cscGeometry) { +void AlignableMuon::update(const DTGeometry* dtGeometry, + const CSCGeometry* cscGeometry, + const GEMGeometry* gemGeometry) { // update the muon barrel buildDTBarrel(dtGeometry, /* update = */ true); // update the muon end caps buildCSCEndcap(cscGeometry, /* update = */ true); + buildGEMEndcap(gemGeometry, /* update = */ true); edm::LogInfo("Alignment") << "@SUB=AlignableMuon::update" << "Updating alignable muon objects DONE"; @@ -266,6 +279,63 @@ void AlignableMuon::buildCSCEndcap(const CSCGeometry* pCSC, bool update) { } } +//-------------------------------------------------------------------------------------------------- +void AlignableMuon::buildGEMEndcap(const GEMGeometry* pGEM, bool update) { + LogDebug("Position") << "Constructing AlignableGEMEndcap"; + std::vector tmpGEMStationsInEndcap; + for (int iec = -1; iec < 2; iec = iec + 2) { + std::vector tmpGEMRingsInStation; + + for (int ist = 0; ist < 3; ist++) { + if (ist == 0) + continue; //Run3 GEM dosen't have ME0 + if (ist == 2) + continue; //Run3 GEM dosen't have GE2/1 + std::vector tmpGEMSuperChambersInRing; + int iri = 1; + int iChamber{0}; + auto vc = pGEM->superChambers(); + for (const auto& det : vc) { + GEMDetId gemId = det->id(); + int ec = gemId.region(); + int st = gemId.station(); + int ri = gemId.ring(); + + if (iec == ec && ist == st && iri == ri) { + if (update) { + theGEMEndcaps[iec == -1 ? 0 : 1]->station(ist - 1).ring(iri - 1).superChamber(iChamber).update(det); + } else { + AlignableGEMSuperChamber* tmpGEMSuperChamber = new AlignableGEMSuperChamber(det); + tmpGEMSuperChambersInRing.push_back(tmpGEMSuperChamber); + } + ++iChamber; + } + } + if (!update) { + if (!tmpGEMSuperChambersInRing.empty()) { + theGEMSuperChambers.insert( + theGEMSuperChambers.end(), tmpGEMSuperChambersInRing.begin(), tmpGEMSuperChambersInRing.end()); + AlignableGEMRing* tmpGEMRing = new AlignableGEMRing(tmpGEMSuperChambersInRing); + tmpGEMRingsInStation.push_back(tmpGEMRing); + tmpGEMSuperChambersInRing.clear(); + } + } + if (!update) { + AlignableGEMStation* tmpGEMStation = new AlignableGEMStation(tmpGEMRingsInStation); + theGEMRings.insert(theGEMRings.end(), tmpGEMRingsInStation.begin(), tmpGEMRingsInStation.end()); + tmpGEMStationsInEndcap.push_back(tmpGEMStation); + tmpGEMRingsInStation.clear(); + } + } + if (!update) { + AlignableGEMEndcap* tmpEndcap = new AlignableGEMEndcap(tmpGEMStationsInEndcap); + theGEMStations.insert(theGEMStations.end(), tmpGEMStationsInEndcap.begin(), tmpGEMStationsInEndcap.end()); + theGEMEndcaps.push_back(tmpEndcap); + tmpGEMStationsInEndcap.clear(); + } + } +} + //-------------------------------------------------------------------------------------------------- align::Alignables AlignableMuon::DTLayers() { align::Alignables result; @@ -372,6 +442,71 @@ align::Alignables AlignableMuon::CSCEndcaps() { return result; } +//__________________________________________________________________________________________________ +align::Alignables AlignableMuon::GEMEtaPartitions() { + align::Alignables result; + align::Alignables superChambers = GEMSuperChambers(); + for (align::Alignables::const_iterator superChamberIter = superChambers.begin(); + superChamberIter != superChambers.end(); + ++superChamberIter) { + align::Alignables chambers = (*superChamberIter)->components(); + for (align::Alignables::const_iterator chamberIter = chambers.begin(); chamberIter != chambers.end(); + ++chamberIter) { + align::Alignables etaPartitions = (*chamberIter)->components(); + for (align::Alignables::const_iterator etaPartitionIter = etaPartitions.begin(); + etaPartitionIter != etaPartitions.end(); + ++etaPartitionIter) { + result.push_back(*etaPartitionIter); + } + } + } + return result; +} + +//__________________________________________________________________________________________________ +align::Alignables AlignableMuon::GEMChambers() { + align::Alignables result; + align::Alignables superChambers = GEMSuperChambers(); + for (align::Alignables::const_iterator superChamberIter = superChambers.begin(); + superChamberIter != superChambers.end(); + ++superChamberIter) { + align::Alignables chambers = (*superChamberIter)->components(); + for (align::Alignables::const_iterator chamberIter = chambers.begin(); chamberIter != chambers.end(); + ++chamberIter) { + result.push_back(*chamberIter); + } + } + return result; +} + +//__________________________________________________________________________________________________ +align::Alignables AlignableMuon::GEMSuperChambers() { + align::Alignables result; + copy(theGEMSuperChambers.begin(), theGEMSuperChambers.end(), back_inserter(result)); + return result; +} + +//__________________________________________________________________________________________________ +align::Alignables AlignableMuon::GEMRings() { + align::Alignables result; + copy(theGEMRings.begin(), theGEMRings.end(), back_inserter(result)); + return result; +} + +//__________________________________________________________________________________________________ +align::Alignables AlignableMuon::GEMStations() { + align::Alignables result; + copy(theGEMStations.begin(), theGEMStations.end(), back_inserter(result)); + return result; +} + +//-------------------------------------------------------------------------------------------------- +align::Alignables AlignableMuon::GEMEndcaps() { + align::Alignables result; + copy(theGEMEndcaps.begin(), theGEMEndcaps.end(), back_inserter(result)); + return result; +} + //__________________________________________________________________________________________________ void AlignableMuon::recursiveSetMothers(Alignable* alignable) { for (const auto& iter : alignable->components()) { @@ -457,3 +592,32 @@ AlignmentErrorsExtended* AlignableMuon::cscAlignmentErrorsExtended(void) { return tmpAlignmentErrorsExtended; } + +//__________________________________________________________________________________________________ +Alignments* AlignableMuon::gemAlignments(void) { + Alignments* gemEndCap1 = this->GEMEndcaps().front()->alignments(); + Alignments* gemEndCap2 = this->GEMEndcaps().back()->alignments(); + Alignments* tmpAlignments = new Alignments(); + std::copy(gemEndCap1->m_align.begin(), gemEndCap1->m_align.end(), back_inserter(tmpAlignments->m_align)); + std::copy(gemEndCap2->m_align.begin(), gemEndCap2->m_align.end(), back_inserter(tmpAlignments->m_align)); + std::sort(tmpAlignments->m_align.begin(), tmpAlignments->m_align.end()); + + return tmpAlignments; +} +//__________________________________________________________________________________________________ +AlignmentErrorsExtended* AlignableMuon::gemAlignmentErrorsExtended(void) { + // Retrieve muon endcaps alignment errors + AlignmentErrorsExtended* gemEndCap1Errors = this->GEMEndcaps().front()->alignmentErrors(); + AlignmentErrorsExtended* gemEndCap2Errors = this->GEMEndcaps().back()->alignmentErrors(); + AlignmentErrorsExtended* tmpAlignmentErrorsExtended = new AlignmentErrorsExtended(); + + std::copy(gemEndCap1Errors->m_alignError.begin(), + gemEndCap1Errors->m_alignError.end(), + back_inserter(tmpAlignmentErrorsExtended->m_alignError)); + std::copy(gemEndCap2Errors->m_alignError.begin(), + gemEndCap2Errors->m_alignError.end(), + back_inserter(tmpAlignmentErrorsExtended->m_alignError)); + std::sort(tmpAlignmentErrorsExtended->m_alignError.begin(), tmpAlignmentErrorsExtended->m_alignError.end()); + + return tmpAlignmentErrorsExtended; +} diff --git a/Alignment/MuonAlignment/src/MuonAlignment.cc b/Alignment/MuonAlignment/src/MuonAlignment.cc index 5c47ca195a1f2..2458e49befb2b 100644 --- a/Alignment/MuonAlignment/src/MuonAlignment.cc +++ b/Alignment/MuonAlignment/src/MuonAlignment.cc @@ -9,9 +9,6 @@ #include "FWCore/ServiceRegistry/interface/Service.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" -// Muon geom -#include "Geometry/Records/interface/MuonGeometryRecord.h" - // Alignment #include "CondFormats/Alignment/interface/Alignments.h" #include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h" @@ -33,6 +30,8 @@ void MuonAlignment::init() { theDTErrorRecordName = "DTAlignmentErrorExtendedRcd"; theCSCAlignRecordName = "CSCAlignmentRcd"; theCSCErrorRecordName = "CSCAlignmentErrorExtendedRcd"; + theGEMAlignRecordName = "GEMAlignmentRcd"; + theGEMErrorRecordName = "GEMAlignmentErrorExtendedRcd"; theDTSurveyRecordName = "DTSurveyRcd"; theDTSurveyErrorRecordName = "DTSurveyErrorExtendedRcd"; theCSCSurveyRecordName = "CSCSurveyRcd"; @@ -44,12 +43,11 @@ void MuonAlignment::init() { MuonAlignment::MuonAlignment(const edm::EventSetup& iSetup) { init(); - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - iSetup.get().get(dtGeometry); - iSetup.get().get(cscGeometry); + edm::ESHandle dtGeometry = iSetup.getHandle(esTokenDT_); + edm::ESHandle cscGeometry = iSetup.getHandle(esTokenCSC_); + edm::ESHandle gemGeometry = iSetup.getHandle(esTokenGEM_); - theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry)); + theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); theAlignableNavigator = new AlignableNavigator(theAlignableMuon); } @@ -135,10 +133,12 @@ void MuonAlignment::copyAlignmentToSurvey(double shiftErr, double angleErr) { std::map alignableMap; recursiveMap(theAlignableMuon->DTBarrel(), alignableMap); recursiveMap(theAlignableMuon->CSCEndcaps(), alignableMap); + recursiveMap(theAlignableMuon->GEMEndcaps(), alignableMap); // Set the survey error to the alignable error, expanding the matrix as needed AlignmentErrorsExtended* dtAlignmentErrorsExtended = theAlignableMuon->dtAlignmentErrorsExtended(); AlignmentErrorsExtended* cscAlignmentErrorsExtended = theAlignableMuon->cscAlignmentErrorsExtended(); + AlignmentErrorsExtended* gemAlignmentErrorsExtended = theAlignableMuon->gemAlignmentErrorsExtended(); std::vector alignmentErrors; std::copy(dtAlignmentErrorsExtended->m_alignError.begin(), dtAlignmentErrorsExtended->m_alignError.end(), @@ -146,6 +146,9 @@ void MuonAlignment::copyAlignmentToSurvey(double shiftErr, double angleErr) { std::copy(cscAlignmentErrorsExtended->m_alignError.begin(), cscAlignmentErrorsExtended->m_alignError.end(), std::back_inserter(alignmentErrors)); + std::copy(gemAlignmentErrorsExtended->m_alignError.begin(), + gemAlignmentErrorsExtended->m_alignError.end(), + std::back_inserter(alignmentErrors)); for (std::vector::const_iterator alignmentError = alignmentErrors.begin(); alignmentError != alignmentErrors.end(); @@ -342,7 +345,24 @@ void MuonAlignment::saveCSCtoDB(void) { &(*csc_AlignmentErrorsExtended), poolDbService->currentTime(), theCSCErrorRecordName); } +void MuonAlignment::saveGEMtoDB(void) { + // Call service + edm::Service poolDbService; + if (!poolDbService.isAvailable()) // Die if not available + throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; + + // Get alignments and errors + Alignments* gem_Alignments = theAlignableMuon->gemAlignments(); + AlignmentErrorsExtended* gem_AlignmentErrorsExtended = theAlignableMuon->gemAlignmentErrorsExtended(); + + // Store CSC alignments and errors + poolDbService->writeOne(&(*gem_Alignments), poolDbService->currentTime(), theGEMAlignRecordName); + poolDbService->writeOne( + &(*gem_AlignmentErrorsExtended), poolDbService->currentTime(), theGEMErrorRecordName); +} + void MuonAlignment::saveToDB(void) { saveDTtoDB(); saveCSCtoDB(); + saveGEMtoDB(); } diff --git a/Alignment/MuonAlignment/src/MuonAlignmentInputDB.cc b/Alignment/MuonAlignment/src/MuonAlignmentInputDB.cc index 263cc7e913e1b..e64b4183ad60b 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentInputDB.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentInputDB.cc @@ -20,10 +20,12 @@ #include "CondFormats/AlignmentRecord/interface/DTAlignmentErrorExtendedRcd.h" #include "CondFormats/AlignmentRecord/interface/CSCAlignmentRcd.h" #include "CondFormats/AlignmentRecord/interface/CSCAlignmentErrorExtendedRcd.h" +#include "CondFormats/AlignmentRecord/interface/GEMAlignmentRcd.h" +#include "CondFormats/AlignmentRecord/interface/GEMAlignmentErrorExtendedRcd.h" #include "Geometry/CommonTopologies/interface/GeometryAligner.h" #include "CondFormats/Alignment/interface/DetectorGlobalPosition.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" - +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" // // constants, enums and typedefs // @@ -36,13 +38,15 @@ // constructors and destructor // MuonAlignmentInputDB::MuonAlignmentInputDB() - : m_dtLabel(""), m_cscLabel(""), idealGeometryLabel("idealForInputDB"), m_getAPEs(false) {} + : m_dtLabel(""), m_cscLabel(""), m_gemLabel(""), idealGeometryLabel("idealForInputDB"), m_getAPEs(false) {} -MuonAlignmentInputDB::MuonAlignmentInputDB(std::string dtLabel, - std::string cscLabel, - std::string idealLabel, - bool getAPEs) - : m_dtLabel(dtLabel), m_cscLabel(cscLabel), idealGeometryLabel(idealLabel), m_getAPEs(getAPEs) {} +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 MuonAlignmentInputDB& rhs) // { @@ -70,22 +74,28 @@ MuonAlignmentInputDB::~MuonAlignmentInputDB() {} 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); 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), @@ -96,8 +106,13 @@ AlignableMuon* MuonAlignmentInputDB::newAlignableMuon(const edm::EventSetup& iSe &(*cscAlignments), &(*cscAlignmentErrorsExtended), align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); + aligner.applyAlignments(&(*gemGeometry), + &(*gemAlignments), + &(*gemAlignmentErrorsExtended), + align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); + } else { - AlignmentErrorsExtended dtAlignmentErrorsExtended2, cscAlignmentErrorsExtended2; + AlignmentErrorsExtended dtAlignmentErrorsExtended2, cscAlignmentErrorsExtended2, gemAlignmentErrorsExtended2; for (std::vector::const_iterator i = dtAlignments->m_align.begin(); i != dtAlignments->m_align.end(); @@ -113,6 +128,13 @@ AlignableMuon* MuonAlignmentInputDB::newAlignableMuon(const edm::EventSetup& iSe 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(); + ++i) { + CLHEP::HepSymMatrix empty_matrix(3, 0); + AlignTransformErrorExtended empty_error(empty_matrix, i->rawId()); + gemAlignmentErrorsExtended2.m_alignError.push_back(empty_error); + } GeometryAligner aligner; aligner.applyAlignments(&(*dtGeometry), @@ -123,9 +145,13 @@ AlignableMuon* MuonAlignmentInputDB::newAlignableMuon(const edm::EventSetup& iSe &(*cscAlignments), &(cscAlignmentErrorsExtended2), align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); + aligner.applyAlignments(&(*gemGeometry), + &(*gemAlignments), + &(gemAlignmentErrorsExtended2), + align::DetectorGlobalPosition(*globalPositionRcd, DetId(DetId::Muon))); } - return new AlignableMuon(&(*dtGeometry), &(*cscGeometry)); + return new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); } // diff --git a/Alignment/MuonAlignment/src/MuonAlignmentInputMethod.cc b/Alignment/MuonAlignment/src/MuonAlignmentInputMethod.cc index 6944835fb106c..903baa50cc933 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentInputMethod.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentInputMethod.cc @@ -62,9 +62,11 @@ MuonAlignmentInputMethod::~MuonAlignmentInputMethod() {} 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); - return new AlignableMuon(&(*dtGeometry), &(*cscGeometry)); + iSetup.get().get(idealGeometryLabel, gemGeometry); + return new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); } // diff --git a/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc b/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc index 186b0e049e868..eb0dacf2e2916 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentInputSurveyDB.cc @@ -68,8 +68,10 @@ MuonAlignmentInputSurveyDB::~MuonAlignmentInputSurveyDB() {} 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; @@ -80,7 +82,7 @@ AlignableMuon* MuonAlignmentInputSurveyDB::newAlignableMuon(const edm::EventSetu iSetup.get().get(m_cscLabel, cscSurvey); iSetup.get().get(m_cscLabel, cscSurveyError); - AlignableMuon* output = new AlignableMuon(&(*dtGeometry), &(*cscGeometry)); + AlignableMuon* output = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); unsigned int theSurveyIndex = 0; const Alignments* theSurveyValues = &*dtSurvey; diff --git a/Alignment/MuonAlignment/src/MuonAlignmentInputXML.cc b/Alignment/MuonAlignment/src/MuonAlignmentInputXML.cc index f92ee9797b5f8..855317c929157 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentInputXML.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentInputXML.cc @@ -256,15 +256,17 @@ 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)); + 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()); - AlignableMuon *ideal_alignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry)); + AlignableMuon *ideal_alignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); std::map ideal_alignableNavigator; // real AlignableNavigators don't have const methods recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->DTBarrel()); recursiveGetId(ideal_alignableNavigator, ideal_alignableMuon->CSCEndcaps()); diff --git a/Alignment/MuonAlignment/src/MuonAlignmentOutputXML.cc b/Alignment/MuonAlignment/src/MuonAlignmentOutputXML.cc index f630ea5fe678a..df148df1efc7e 100644 --- a/Alignment/MuonAlignment/src/MuonAlignmentOutputXML.cc +++ b/Alignment/MuonAlignment/src/MuonAlignmentOutputXML.cc @@ -121,10 +121,12 @@ void MuonAlignmentOutputXML::write(AlignableMuon *alignableMuon, const edm::Even 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)); + AlignableMuon ideal_alignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); align::Alignables ideal_barrels = ideal_alignableMuon.DTBarrel(); align::Alignables ideal_endcaps = ideal_alignableMuon.CSCEndcaps(); diff --git a/Alignment/MuonAlignment/src/MuonScenarioBuilder.cc b/Alignment/MuonAlignment/src/MuonScenarioBuilder.cc index 9e11bdf393a8a..5715d4f4104cd 100644 --- a/Alignment/MuonAlignment/src/MuonScenarioBuilder.cc +++ b/Alignment/MuonAlignment/src/MuonScenarioBuilder.cc @@ -21,10 +21,12 @@ #include "Alignment/CommonAlignment/interface/Alignable.h" #include "DataFormats/MuonDetId/interface/CSCTriggerNumbering.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" + //__________________________________________________________________________________________________ MuonScenarioBuilder::MuonScenarioBuilder(Alignable* alignable) : // muon alignable IDs are (currently) independent of the geometry - MisalignmentScenarioBuilder(AlignableObjectId::Geometry::General) { + MisalignmentScenarioBuilder(AlignableObjectId::Geometry::PhaseI) { theAlignableMuon = dynamic_cast(alignable); if (!theAlignableMuon) @@ -46,12 +48,15 @@ void MuonScenarioBuilder::applyScenario(const edm::ParameterSet& scenario) { // DT Barrel const auto& dtBarrel = theAlignableMuon->DTBarrel(); this->decodeMovements_(theScenario, dtBarrel, "DTBarrel"); - // CSC Endcap + // Endcap const auto& cscEndcaps = theAlignableMuon->CSCEndcaps(); this->decodeMovements_(theScenario, cscEndcaps, "CSCEndcap"); + const auto& gemEndcaps = theAlignableMuon->GEMEndcaps(); + this->decodeMovements_(theScenario, gemEndcaps, "GEMEndcap"); this->moveDTSectors(theScenario); this->moveCSCSectors(theScenario); + this->moveGEMSectors(theScenario); this->moveMuon(theScenario); edm::LogInfo("TrackerScenarioBuilder") << "Applied modifications to " << theModifierCounter << " alignables"; @@ -318,9 +323,60 @@ void MuonScenarioBuilder::moveCSCSectors(const edm::ParameterSet& pSet) { } //______________________________________________________________________________________________________ +void MuonScenarioBuilder::moveGEMSectors(const edm::ParameterSet& pSet) { + const auto& GEMSuperChambers = theAlignableMuon->GEMSuperChambers(); + //Take Parameters + align::Scalars param = this->extractParameters(pSet, "GEMSectors"); + double scale_ = param[0]; + double scaleError_ = param[1]; + double phiX_ = param[2]; + double phiY_ = param[3]; + double phiZ_ = param[4]; + double dX_ = param[5]; + double dY_ = param[6]; + double dZ_ = param[7]; + + double dx = scale_ * dX_; + double dy = scale_ * dY_; + double dz = scale_ * dZ_; + double phix = scale_ * phiX_; + double phiy = scale_ * phiY_; + double phiz = scale_ * phiZ_; + double errorx = scaleError_ * dX_; + double errory = scaleError_ * dY_; + double errorz = scaleError_ * dZ_; + double errorphix = scaleError_ * phiX_; + double errorphiy = scaleError_ * phiY_; + double errorphiz = scaleError_ * phiZ_; + align::Scalars errorDisp; + errorDisp.push_back(errorx); + errorDisp.push_back(errory); + errorDisp.push_back(errorz); + align::Scalars errorRotation; + errorRotation.push_back(errorphix); + errorRotation.push_back(errorphiy); + errorRotation.push_back(errorphiz); + + //Create an index for the chambers in the alignable vector + for (const auto& iter : GEMSuperChambers) { + align::Scalars disp; + align::Scalars rotation; + const std::vector disp_ = theMuonModifier.gaussianRandomVector(dx, dy, dz); + disp.push_back(disp_[0]); + disp.push_back(disp_[1]); + disp.push_back(disp_[2]); + const std::vector rotation_ = theMuonModifier.flatRandomVector(phix, phiy, phiz); + rotation.push_back(rotation_[0]); + rotation.push_back(rotation_[1]); + rotation.push_back(rotation_[2]); + this->moveChamberInSector(iter, disp, rotation, errorDisp, errorRotation); + } +} + void MuonScenarioBuilder::moveMuon(const edm::ParameterSet& pSet) { const auto& DTbarrel = theAlignableMuon->DTBarrel(); const auto& CSCendcaps = theAlignableMuon->CSCEndcaps(); + const auto& GEMendcaps = theAlignableMuon->GEMEndcaps(); //Take Parameters align::Scalars param = this->extractParameters(pSet, "Muon"); double scale_ = param[0]; @@ -385,6 +441,12 @@ void MuonScenarioBuilder::moveMuon(const edm::ParameterSet& pSet) { theMuonModifier.addAlignmentPositionError(iter, errorx, errory, errorz); theMuonModifier.addAlignmentPositionErrorFromRotation(iter, errorphix, errorphiy, errorphiz); } + for (const auto& iter : GEMendcaps) { + theMuonModifier.moveAlignable(iter, false, true, disp[0], disp[1], disp[2]); + theMuonModifier.rotateAlignable(iter, false, true, rotation[0], rotation[1], rotation[2]); + theMuonModifier.addAlignmentPositionError(iter, errorx, errory, errorz); + theMuonModifier.addAlignmentPositionErrorFromRotation(iter, errorphix, errorphiy, errorphiz); + } } //______________________________________________________________________________________________________ diff --git a/Alignment/MuonAlignment/test/TestMuonHierarchy.cpp b/Alignment/MuonAlignment/test/TestMuonHierarchy.cpp index 1f2a25e87e641..6e2360a419706 100644 --- a/Alignment/MuonAlignment/test/TestMuonHierarchy.cpp +++ b/Alignment/MuonAlignment/test/TestMuonHierarchy.cpp @@ -46,16 +46,19 @@ class TestMuonHierarchy : public edm::EDAnalyzer { std::unique_ptr alignableMuon_; std::string leaders_, blank_, filled_; + + edm::ESGetToken esTokenDT_; + edm::ESGetToken esTokenCSC_; + edm::ESGetToken esTokenGEM_; }; void TestMuonHierarchy::analyze(const edm::Event&, const edm::EventSetup& setup) { edm::LogInfo("MuonHierarchy") << "Starting!"; - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - setup.get().get(dtGeometry); - setup.get().get(cscGeometry); + edm::ESHandle dtGeometry = setup.getHandle(esTokenDT_); + edm::ESHandle cscGeometry = setup.getHandle(esTokenCSC_); + edm::ESHandle gemGeometry = setup.getHandle(esTokenGEM_); - alignableMuon_ = std::make_unique(&(*dtGeometry), &(*cscGeometry)); + alignableMuon_ = std::make_unique(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); leaders_ = ""; blank_ = " "; // These two... diff --git a/Alignment/MuonAlignment/test/TestReader.cpp b/Alignment/MuonAlignment/test/TestReader.cpp index 09f7fa10d6683..ba4b9a43633c2 100644 --- a/Alignment/MuonAlignment/test/TestReader.cpp +++ b/Alignment/MuonAlignment/test/TestReader.cpp @@ -59,7 +59,10 @@ class TestMuonReader : public edm::EDAnalyzer { TFile* theFile; float x, y, z, phi, theta, length, thick, width; TRotMatrix* rot; - std::string idealGeometryLabel; + + edm::ESGetToken esTokenDT_; + edm::ESGetToken esTokenCSC_; + edm::ESGetToken esTokenGEM_; }; // @@ -77,7 +80,9 @@ TestMuonReader::TestMuonReader(const edm::ParameterSet& iConfig) thick(0.), width(0.), rot(0), - idealGeometryLabel("idealForTestReader") {} + esTokenDT_(esConsumes(edm::ESInputTag("", "idealForTestReader"))), + esTokenCSC_(esConsumes(edm::ESInputTag("", "idealForTestReader"))), + esTokenGEM_(esConsumes(edm::ESInputTag("", "idealForTestReader"))) {} TestMuonReader::~TestMuonReader() {} @@ -105,12 +110,11 @@ align::EulerAngles TestMuonReader::toPhiXYZ(const align::RotationType& rot) { void TestMuonReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { // first, get chamber alignables from ideal geometry: - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - iSetup.get().get(idealGeometryLabel, dtGeometry); - iSetup.get().get(idealGeometryLabel, cscGeometry); + edm::ESHandle dtGeometry = iSetup.getHandle(esTokenDT_); + edm::ESHandle cscGeometry = iSetup.getHandle(esTokenCSC_); + edm::ESHandle gemGeometry = iSetup.getHandle(esTokenGEM_); - AlignableMuon ideal_alignableMuon(&(*dtGeometry), &(*cscGeometry)); + AlignableMuon ideal_alignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); const auto& ideal_barrels = ideal_alignableMuon.DTBarrel(); const auto& ideal_endcaps = ideal_alignableMuon.CSCEndcaps(); diff --git a/Alignment/MuonAlignment/test/TestRotation.cpp b/Alignment/MuonAlignment/test/TestRotation.cpp index 60dd4ca792dfa..51a9294b20513 100644 --- a/Alignment/MuonAlignment/test/TestRotation.cpp +++ b/Alignment/MuonAlignment/test/TestRotation.cpp @@ -52,8 +52,9 @@ class TestRotation : public edm::EDAnalyzer { float x, y, z, phi, theta, length, thick, width; TRotMatrix* dir; - // typedef Surface::RotationType RotationType; - // typedef Surface::PositionType PositionType; + edm::ESGetToken esTokenDT_; + edm::ESGetToken esTokenCSC_; + edm::ESGetToken esTokenGEM_; }; // @@ -105,12 +106,11 @@ void TestRotation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet // // Retrieve ideal geometry from event setup // - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - iSetup.get().get(dtGeometry); - iSetup.get().get(cscGeometry); + edm::ESHandle dtGeometry = iSetup.getHandle(esTokenDT_); + edm::ESHandle cscGeometry = iSetup.getHandle(esTokenCSC_); + edm::ESHandle gemGeometry = iSetup.getHandle(esTokenGEM_); - AlignableMuon* theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry)); + AlignableMuon* theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); // Apply alignment diff --git a/Alignment/MuonAlignment/test/TestTranslation.cpp b/Alignment/MuonAlignment/test/TestTranslation.cpp index 893989583c075..758d445308924 100644 --- a/Alignment/MuonAlignment/test/TestTranslation.cpp +++ b/Alignment/MuonAlignment/test/TestTranslation.cpp @@ -109,10 +109,12 @@ void TestTranslation::analyze(const edm::Event& iEvent, const edm::EventSetup& i // edm::ESHandle dtGeometry; edm::ESHandle cscGeometry; + edm::ESHandle gemGeometry; iSetup.get().get(dtGeometry); iSetup.get().get(cscGeometry); + iSetup.get().get(gemGeometry); - AlignableMuon* theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry)); + AlignableMuon* theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); // Apply alignment for (const auto& iter : theAlignableMuon->DTChambers()) diff --git a/Alignment/MuonAlignment/test/convertSQLitetoXML_cfg.py b/Alignment/MuonAlignment/test/convertSQLitetoXML_cfg.py new file mode 100644 index 0000000000000..3a3ac8ee39380 --- /dev/null +++ b/Alignment/MuonAlignment/test/convertSQLitetoXML_cfg.py @@ -0,0 +1,127 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("CONVERT") +process.source = cms.Source("EmptySource") +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1)) + +process.load("Configuration.Geometry.GeometryIdeal_cff") +process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi") +process.load('Configuration.Geometry.GeometryExtended2021_cff') + +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.load("CondCore.DBCommon.CondDBSetup_cfi") +process.PoolDBESSource = cms.ESSource("PoolDBESSource", + process.CondDBSetup, + connect = cms.string("sqlite_file:Alignments.db"), + toGet = cms.VPSet(cms.PSet( + record = cms.string('DTAlignmentRcd'), + tag = cms.string('DT100InversepbScenario') + ), + cms.PSet( + record = cms.string('DTAlignmentErrorExtendedRcd'), + tag = cms.string('DT100InversepbScenarioErrors') + ), + cms.PSet( + record = cms.string('CSCAlignmentRcd'), + tag = cms.string('CSC100InversepbScenario') + ), + cms.PSet( + record = cms.string('CSCAlignmentErrorExtendedRcd'), + tag = cms.string('CSC100InversepbScenarioErrors') + ), + cms.PSet( + record = cms.string('GEMAlignmentRcd'), + tag = cms.string('GEM') + ), + cms.PSet( + record = cms.string('GEMAlignmentErrorExtendedRcd'), + tag = cms.string('test') + ))) +process.inertGlobalPositionRcd = cms.ESSource("PoolDBESSource", + process.CondDBSetup, + connect = cms.string("sqlite_file:inertGlobalPositionRcd.StdTags.746p3.DBv2.db"), + toGet = cms.VPSet(cms.PSet(record = cms.string("GlobalPositionRcd"), tag = cms.string("inertGlobalPositionRcd")))) +process.MuonGeometryDBConverter = cms.EDAnalyzer("MuonGeometryDBConverter", + input = cms.string("db"), + dtLabel = cms.string(""), + cscLabel = cms.string(""), + gemLabel = cms.string(""), + shiftErr = cms.double(1000.), + angleErr = cms.double(6.28), + getAPEs = cms.bool(True), + output = cms.string("xml"), + outputXML = cms.PSet( + fileName = cms.string("REPLACEME.xml"), + relativeto = cms.string("ideal"), + survey = cms.bool(False), + rawIds = cms.bool(False), + eulerAngles = cms.bool(False), + precision = cms.int32(10), + suppressDTBarrel = cms.untracked.bool(True), + suppressDTWheels = cms.untracked.bool(True), + suppressDTStations = cms.untracked.bool(True), + suppressDTChambers = cms.untracked.bool(False), + suppressDTSuperLayers = cms.untracked.bool(False), + suppressDTLayers = cms.untracked.bool(False), + suppressCSCEndcaps = cms.untracked.bool(True), + suppressCSCStations = cms.untracked.bool(True), + suppressCSCRings = cms.untracked.bool(True), + suppressCSCChambers = cms.untracked.bool(False), + suppressCSCLayers = cms.untracked.bool(False))) + +process.Path = cms.Path(process.MuonGeometryDBConverter) diff --git a/Alignment/MuonAlignment/test/muonGeometryDBConverter_cfg.py b/Alignment/MuonAlignment/test/muonGeometryDBConverter_cfg.py index 84f0fcedbba19..c3aa0073be6eb 100644 --- a/Alignment/MuonAlignment/test/muonGeometryDBConverter_cfg.py +++ b/Alignment/MuonAlignment/test/muonGeometryDBConverter_cfg.py @@ -28,7 +28,8 @@ # setting up the process process = cms.Process("CONVERT") process.load("Configuration.StandardSequences.MagneticField_cff") -process.load("Configuration.Geometry.GeometryIdeal_cff") +process.load("Geometry.MuonCommonData.muonIdealGeometryXML_cfi") +process.load('Configuration.Geometry.GeometryExtended2021_cff') process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi") process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") process.load("Alignment.MuonAlignment.muonGeometryDBConverter_cfi") @@ -53,6 +54,14 @@ 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), @@ -73,6 +82,14 @@ 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), @@ -93,6 +110,14 @@ 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), @@ -113,8 +138,13 @@ 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 @@ -135,7 +165,13 @@ tag = cms.string("CSCAlignmentRcd")), cms.PSet(connect = cms.string("sqlite_file:"+options.inputFile), record = cms.string("CSCAlignmentErrorExtendedRcd"), - tag = cms.string("CSCAlignmentErrorExtendedRcd")) + tag = cms.string("CSCAlignmentErrorExtendedRcd")), + cms.PSet(connect = cms.string("sqlite_file:"+options.inputFile), + record = cms.string("GEMAlignmentRcd"), + tag = cms.string("GEMAlignmentRcd")), + cms.PSet(connect = cms.string("sqlite_file:"+options.inputFile), + record = cms.string("GEMAlignmentErrorExtendedRcd"), + tag = cms.string("GEMAlignmentErrorExtendedRcd")) ]) elif options.input == "xml": process.muonGeometryDBConverter.fileName = options.inputFile @@ -154,6 +190,10 @@ 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")) ) ) process.PoolDBOutputService.connect = "sqlite_file:"+options.outputFile diff --git a/Alignment/MuonAlignment/test/test-misalign_cfg.py b/Alignment/MuonAlignment/test/test-misalign_cfg.py index 48bd4608056fd..89ca87c3b2824 100644 --- a/Alignment/MuonAlignment/test/test-misalign_cfg.py +++ b/Alignment/MuonAlignment/test/test-misalign_cfg.py @@ -4,10 +4,9 @@ # -- Load default module/services configurations -- // # Message logger service process.load("FWCore.MessageService.MessageLogger_cfi") - -# Ideal DT & CSC geometry process.load("Geometry.MuonCommonData.muonIdealGeometryXML_cfi") process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi") +process.load('Configuration.Geometry.GeometryExtended2021_cff') # Misalignment example scenario producer import Alignment.MuonAlignment.Scenarios_cff as _MuonScenarios @@ -20,11 +19,6 @@ saveToDbase = cms.untracked.bool(True) ) -# or standard stuff -# Reco geometry producer -#process.load("Geometry.DTGeometry.dtGeometry_cfi") -#process.load("Geometry.CSCGeometry.cscGeometry_cfi") - process.MisalignedMuon.scenario = _MuonScenarios.Muon100InversepbScenario process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) @@ -52,6 +46,14 @@ fromDD4hep = cms.bool(False) ) +process.GEMGeometryMisalignedMuonProducer = cms.ESProducer("GEMGeometryESModule", + appendToDataLabel = cms.string('idealForMuonMisalignedProducer'), + fromDDD = cms.bool(True), + fromDD4Hep = cms.bool(False), + alignmentsLabel = cms.string(''), + applyAlignment = cms.bool(False) +) + # Database output service if you want to store soemthing in MisalignedMuon from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup @@ -72,7 +74,16 @@ cms.PSet( record = cms.string('CSCAlignmentErrorExtendedRcd'), tag = cms.string('CSC100InversepbScenarioErrors') + ), + cms.PSet( + record = cms.string('GEMAlignmentRcd'), + tag = cms.string('GEM') + ), + cms.PSet( + record = cms.string('GEMAlignmentErrorExtendedRcd'), + tag = cms.string('test') )), + connect = cms.string('sqlite_file:Alignments.db') ) @@ -80,7 +91,8 @@ fileName = cms.untracked.string('misaligment.root') ) -process.p1 = cms.Path(process.MisalignedMuon+process.prod) +#process.p1 = cms.Path(process.MisalignedMuon+process.prod) +process.p1 = cms.Path(process.MisalignedMuon) process.MessageLogger.cout = cms.untracked.PSet( threshold = cms.untracked.string('INFO'), default = cms.untracked.PSet( diff --git a/Alignment/SurveyAnalysis/plugins/SurveyInputCSCfromPins.cc b/Alignment/SurveyAnalysis/plugins/SurveyInputCSCfromPins.cc index 376226d86e32e..6aebc19aa4871 100644 --- a/Alignment/SurveyAnalysis/plugins/SurveyInputCSCfromPins.cc +++ b/Alignment/SurveyAnalysis/plugins/SurveyInputCSCfromPins.cc @@ -162,10 +162,12 @@ void SurveyInputCSCfromPins::analyze(const edm::Event &, const edm::EventSetup & edm::ESHandle dtGeometry; edm::ESHandle cscGeometry; + edm::ESHandle gemGeometry; iSetup.get().get(dtGeometry); iSetup.get().get(cscGeometry); + iSetup.get().get(gemGeometry); - AlignableMuon *theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry)); + AlignableMuon *theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); AlignableNavigator *theAlignableNavigator = new AlignableNavigator(theAlignableMuon); const auto &theEndcaps = theAlignableMuon->CSCEndcaps(); diff --git a/Alignment/TrackerAlignment/src/AlignableTracker.cc b/Alignment/TrackerAlignment/src/AlignableTracker.cc index 4483f98f4e312..6dede7a0398ed 100644 --- a/Alignment/TrackerAlignment/src/AlignableTracker.cc +++ b/Alignment/TrackerAlignment/src/AlignableTracker.cc @@ -16,7 +16,7 @@ AlignableTracker ::AlignableTracker(const TrackerGeometry* trackerGeometry, cons AlignableComposite(0, align::Tracker, RotationType()), tTopo_(trackerTopology), trackerNameSpace_(trackerTopology), - alignableObjectId_(trackerGeometry, nullptr, nullptr) { + alignableObjectId_(trackerGeometry, nullptr, nullptr, nullptr) { AlignableTrackerBuilder builder(trackerGeometry, trackerTopology); builder.buildAlignables(this); trackerNameSpace_ = builder.trackerNameSpace(); diff --git a/Alignment/TrackerAlignment/src/AlignableTrackerBuilder.cc b/Alignment/TrackerAlignment/src/AlignableTrackerBuilder.cc index 0ce45578acc58..de9c47766e6bd 100644 --- a/Alignment/TrackerAlignment/src/AlignableTrackerBuilder.cc +++ b/Alignment/TrackerAlignment/src/AlignableTrackerBuilder.cc @@ -25,7 +25,7 @@ AlignableTrackerBuilder ::AlignableTrackerBuilder(const TrackerGeometry* tracker const TrackerTopology* trackerTopology) : trackerGeometry_(trackerGeometry), trackerTopology_(trackerTopology), - alignableObjectId_(trackerGeometry, nullptr, nullptr), + alignableObjectId_(trackerGeometry, nullptr, nullptr, nullptr), alignableMap_(nullptr), trackerAlignmentLevelBuilder_(trackerTopology, trackerGeometry) { std::ostringstream ss; diff --git a/Alignment/TrackerAlignment/src/TrackerAlignmentLevelBuilder.cc b/Alignment/TrackerAlignment/src/TrackerAlignmentLevelBuilder.cc index fd016725dba2f..402618272ef91 100644 --- a/Alignment/TrackerAlignment/src/TrackerAlignmentLevelBuilder.cc +++ b/Alignment/TrackerAlignment/src/TrackerAlignmentLevelBuilder.cc @@ -17,7 +17,7 @@ TrackerAlignmentLevelBuilder ::TrackerAlignmentLevelBuilder(const TrackerTopology* trackerTopology, const TrackerGeometry* trackerGeometry) : trackerTopology_(trackerTopology), - alignableObjectId_(trackerGeometry, nullptr, nullptr), + alignableObjectId_(trackerGeometry, nullptr, nullptr, nullptr), trackerNameSpace_(trackerTopology) {} //_____________________________________________________________________________ diff --git a/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.cc b/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.cc index 9a34a7985af39..5dc9d448e6478 100644 --- a/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.cc +++ b/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.cc @@ -78,7 +78,7 @@ void TrackerGeometryAnalyzer ::setTrackerGeometry(const edm::EventSetup& setup) TrackerGeomBuilderFromGeometricDet trackerGeometryBuilder; trackerGeometry = trackerGeometryBuilder.build(&(*geometricDet), *trackerParams, trackerTopology); - alignableObjectId_ = AlignableObjectId{trackerGeometry, nullptr, nullptr}; + alignableObjectId_ = AlignableObjectId{trackerGeometry, nullptr, nullptr, nullptr}; } //_____________________________________________________________________________