diff --git a/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorAsAnalyzer.cc b/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorAsAnalyzer.cc index a0bf71c27d2c3..1f880d9574d14 100644 --- a/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorAsAnalyzer.cc +++ b/Alignment/CommonAlignmentMonitor/plugins/AlignmentMonitorAsAnalyzer.cc @@ -84,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; }; @@ -102,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) { @@ -132,15 +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; - edm::ESHandle theMuonGEM; - iSetup.get().get(idealGeometryLabel, theMuonDT); - iSetup.get().get(idealGeometryLabel, theMuonCSC); - iSetup.get().get(idealGeometryLabel, theMuonGEM); + 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); @@ -151,28 +158,23 @@ 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.get().get(gemAlignments); - edm::ESHandle gemAlignmentErrorsExtended; - iSetup.get().get(gemAlignmentErrorsExtended); + edm::ESHandle gemAlignments = iSetup.getHandle(esTokenGEMAl_); + edm::ESHandle gemAlignmentErrorsExtended = iSetup.getHandle(esTokenGEMAPE_); aligner.applyAlignments(&(*theMuonGEM), &(*gemAlignments), &(*gemAlignmentErrorsExtended), diff --git a/Alignment/MuonAlignment/interface/MuonAlignment.h b/Alignment/MuonAlignment/interface/MuonAlignment.h index aa234de67e16e..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: @@ -65,6 +66,10 @@ class MuonAlignment { 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/plugins/MuonMisalignedProducer.cc b/Alignment/MuonAlignment/plugins/MuonMisalignedProducer.cc index 986ac87b1d200..34021bffcde5f 100644 --- a/Alignment/MuonAlignment/plugins/MuonMisalignedProducer.cc +++ b/Alignment/MuonAlignment/plugins/MuonMisalignedProducer.cc @@ -56,7 +56,10 @@ class MuonMisalignedProducer : public edm::one::EDAnalyzer<> { std::string theDTAlignRecordName, theDTErrorRecordName; std::string theCSCAlignRecordName, theCSCErrorRecordName; std::string theGEMAlignRecordName, theGEMErrorRecordName; - std::string theIdealGeometryLabel; + + edm::ESGetToken esTokenDT_; + edm::ESGetToken esTokenCSC_; + edm::ESGetToken esTokenGEM_; Alignments* dt_Alignments; AlignmentErrorsExtended* dt_AlignmentErrorsExtended; @@ -76,7 +79,9 @@ MuonMisalignedProducer::MuonMisalignedProducer(const edm::ParameterSet& p) theCSCErrorRecordName("CSCAlignmentErrorExtendedRcd"), theGEMAlignRecordName("GEMAlignmentRcd"), theGEMErrorRecordName("GEMAlignmentErrorExtendedRcd"), - theIdealGeometryLabel("idealForMuonMisalignedProducer") {} + esTokenDT_(esConsumes(edm::ESInputTag("", "idealForMuonMisalignedProducer"))), + esTokenCSC_(esConsumes(edm::ESInputTag("", "idealForMuonMisalignedProducer"))), + esTokenGEM_(esConsumes(edm::ESInputTag("", "idealForMuonMisalignedProducer"))) {} //__________________________________________________________________________________________________ MuonMisalignedProducer::~MuonMisalignedProducer() {} @@ -85,12 +90,9 @@ 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; - edm::ESHandle theGEMGeometry; - eventSetup.get().get(theIdealGeometryLabel, theDTGeometry); - eventSetup.get().get(theIdealGeometryLabel, theCSCGeometry); - eventSetup.get().get(theIdealGeometryLabel, theGEMGeometry); + 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), &(*theGEMGeometry)); diff --git a/Alignment/MuonAlignment/src/MuonAlignment.cc b/Alignment/MuonAlignment/src/MuonAlignment.cc index 547e816ff912c..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" @@ -46,12 +43,9 @@ void MuonAlignment::init() { MuonAlignment::MuonAlignment(const edm::EventSetup& iSetup) { init(); - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - iSetup.get().get(dtGeometry); - iSetup.get().get(cscGeometry); - iSetup.get().get(gemGeometry); + edm::ESHandle dtGeometry = iSetup.getHandle(esTokenDT_); + edm::ESHandle cscGeometry = iSetup.getHandle(esTokenCSC_); + edm::ESHandle gemGeometry = iSetup.getHandle(esTokenGEM_); theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); theAlignableNavigator = new AlignableNavigator(theAlignableMuon); diff --git a/Alignment/MuonAlignment/test/Alignments.db b/Alignment/MuonAlignment/test/Alignments.db new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/Alignment/MuonAlignment/test/TestMuonHierarchy.cpp b/Alignment/MuonAlignment/test/TestMuonHierarchy.cpp index ad113aba45275..6e2360a419706 100644 --- a/Alignment/MuonAlignment/test/TestMuonHierarchy.cpp +++ b/Alignment/MuonAlignment/test/TestMuonHierarchy.cpp @@ -46,16 +46,17 @@ 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; - edm::ESHandle gemGeometry; - setup.get().get(dtGeometry); - setup.get().get(cscGeometry); - setup.get().get(gemGeometry); + edm::ESHandle dtGeometry = setup.getHandle(esTokenDT_); + edm::ESHandle cscGeometry = setup.getHandle(esTokenCSC_); + edm::ESHandle gemGeometry = setup.getHandle(esTokenGEM_); alignableMuon_ = std::make_unique(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); diff --git a/Alignment/MuonAlignment/test/TestReader.cpp b/Alignment/MuonAlignment/test/TestReader.cpp index 1e30e6bb39044..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,9 @@ 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; - edm::ESHandle gemGeometry; - iSetup.get().get(idealGeometryLabel, dtGeometry); - iSetup.get().get(idealGeometryLabel, cscGeometry); - iSetup.get().get(idealGeometryLabel, gemGeometry); + edm::ESHandle dtGeometry = iSetup.getHandle(esTokenDT_); + edm::ESHandle cscGeometry = iSetup.getHandle(esTokenCSC_); + edm::ESHandle gemGeometry = iSetup.getHandle(esTokenGEM_); AlignableMuon ideal_alignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); diff --git a/Alignment/MuonAlignment/test/TestRotation.cpp b/Alignment/MuonAlignment/test/TestRotation.cpp index 952be250df2f5..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,9 @@ void TestRotation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet // // Retrieve ideal geometry from event setup // - edm::ESHandle dtGeometry; - edm::ESHandle cscGeometry; - edm::ESHandle gemGeometry; - iSetup.get().get(dtGeometry); - iSetup.get().get(cscGeometry); - iSetup.get().get(gemGeometry); + edm::ESHandle dtGeometry = iSetup.getHandle(esTokenDT_); + edm::ESHandle cscGeometry = iSetup.getHandle(esTokenCSC_); + edm::ESHandle gemGeometry = iSetup.getHandle(esTokenGEM_); AlignableMuon* theAlignableMuon = new AlignableMuon(&(*dtGeometry), &(*cscGeometry), &(*gemGeometry)); diff --git a/Geometry/CommonTopologies/interface/GeometryAligner.h b/Geometry/CommonTopologies/interface/GeometryAligner.h index bc412977603cb..c785c13c6a6f9 100644 --- a/Geometry/CommonTopologies/interface/GeometryAligner.h +++ b/Geometry/CommonTopologies/interface/GeometryAligner.h @@ -70,18 +70,21 @@ void GeometryAligner::applyAlignments(const C* geometry, const AlignTransform::Rotation inverseGlobalRotation = globalRotation.inverse(); // Parallel loop on alignments, alignment errors and geomdets + std::vector::const_iterator iAlign = alignments->m_align.begin(); std::vector::const_iterator iAlignError = alignmentErrors->m_alignError.begin(); //copy geometry->theMap to a real map to order it.... std::map theMap; std::copy(geometry->theMap.begin(), geometry->theMap.end(), std::inserter(theMap, theMap.begin())); unsigned int nAPE = 0; - for (auto iAlign = alignments->m_align.begin(); iAlign != alignments->m_align.end(); ++iAlign, ++iAlignError) { + for (auto iPair = theMap.begin(); iPair != theMap.end(); ++iPair, ++iAlign, ++iAlignError) { // Check DetIds - if (theMap.find((*iAlign).rawId()) == theMap.end()) - throw cms::Exception("GeometryMismatch") << "Can't find rawId=" << (*iAlign).rawId(); + if ((*iPair).first != (*iAlign).rawId()) + throw cms::Exception("GeometryMismatch") << "DetId mismatch between geometry (rawId=" << (*iPair).first + << ") and alignments (rawId=" << (*iAlign).rawId(); - if (theMap.find((*iAlignError).rawId()) == theMap.end()) - throw cms::Exception("GeometryMismatch") << "Can't find rawId=" << (*iAlignError).rawId(); + if ((*iPair).first != (*iAlignError).rawId()) + throw cms::Exception("GeometryMismatch") << "DetId mismatch between geometry (rawId=" << (*iPair).first + << ") and alignment errors (rawId=" << (*iAlignError).rawId(); // Apply global correction CLHEP::Hep3Vector positionHep = globalRotation * CLHEP::Hep3Vector((*iAlign).translation()) + globalShift; @@ -98,7 +101,7 @@ void GeometryAligner::applyAlignments(const C* geometry, rotationHep.zx(), rotationHep.zy(), rotationHep.zz()); - GeomDet* iGeomDet = const_cast(theMap[(*iAlign).rawId()]); + GeomDet* iGeomDet = const_cast((*iPair).second); this->setGeomDetPosition(*iGeomDet, position, rotation); // Alignment Position Error only if non-zero to save memory