From 304696be3c8451963221ef7d9896a0a5304a94ff Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 31 Mar 2017 17:25:38 +0200 Subject: [PATCH 01/18] update consumer code to read thresholds from DB --- .../MillePedeAlignmentAlgorithm/BuildFile.xml | 1 + .../interface/MillePedeFileReader.h | 24 ++---- .../plugins/MillePedeAlignmentAlgorithm.cc | 19 ++++- .../plugins/MillePedeAlignmentAlgorithm.h | 2 + .../plugins/MillePedeDQMModule.cc | 14 +++- .../python/MillePedeDQMModule_cff.py | 2 +- .../python/MillePedeFileReader_cfi.py | 15 ---- .../src/MillePedeFileReader.cc | 83 ++++++++++++------- 8 files changed, 97 insertions(+), 63 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/BuildFile.xml b/Alignment/MillePedeAlignmentAlgorithm/BuildFile.xml index cb6c3679742f2..b9a340d0a65dc 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/BuildFile.xml +++ b/Alignment/MillePedeAlignmentAlgorithm/BuildFile.xml @@ -4,6 +4,7 @@ + diff --git a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h index 4ecfe56473677..f07eb8978d7a0 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h +++ b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h @@ -10,7 +10,7 @@ /*** Alignment ***/ #include "Alignment/MillePedeAlignmentAlgorithm/interface/PedeLabelerBase.h" - +#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" class MillePedeFileReader { @@ -18,7 +18,9 @@ class MillePedeFileReader { public: //==================================================================== explicit MillePedeFileReader(const edm::ParameterSet&, - const std::shared_ptr&); + const std::shared_ptr&, + const std::shared_ptr&); + virtual ~MillePedeFileReader() = default; void read(); @@ -57,6 +59,7 @@ class MillePedeFileReader { void readMillePedeLogFile(); void readMillePedeResultFile(); PclHLS getHLS(const Alignable*); + std::string getStringFromHLS(PclHLS HLS); //========================== PRIVATE DATA ==================================== //============================================================================ @@ -64,19 +67,13 @@ class MillePedeFileReader { // pede labeler plugin const std::shared_ptr pedeLabeler_; + // thresholds from DB + const std::shared_ptr theThresholds_; + // file-names const std::string millePedeLogFile_; const std::string millePedeResFile_; - - // signifiance of movement must be above - const double sigCut_; - // cutoff in micro-meter & micro-rad - const double Xcut_, tXcut_; - const double Ycut_, tYcut_; - const double Zcut_, tZcut_; - // maximum movement in micro-meter/rad - const double maxMoveCut_, maxErrorCut_; - + // conversion factors: cm to um & rad to urad static constexpr std::array multiplier_ = {{ 10000., // X 10000., // Y @@ -85,9 +82,6 @@ class MillePedeFileReader { 1000000., // tY 1000000. }}; // tZ - const std::array cutoffs_ = {{ Xcut_, Ycut_, Zcut_, - tXcut_, tYcut_, tZcut_}}; - bool updateDB_{false}; int Nrec_{0}; diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc index bccd1cc3f55a2..51242235d0fb0 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc @@ -60,6 +60,9 @@ #include "Geometry/Records/interface/TrackerTopologyRcd.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" +#include "CondFormats/DataRecord/interface/AlignPCLThresholdsRcd.h" + #include "DataFormats/TrackerRecHit2D/interface/ProjectedSiStripRecHit2D.h" #include @@ -195,6 +198,15 @@ void MillePedeAlignmentAlgorithm::initialize(const edm::EventSetup &setup, setup.get().get(tTopoHandle); const TrackerTopology* const tTopo = tTopoHandle.product(); + //Retrieve the thresolds cuts from DB for the PCL + if (runAtPCL_) { + edm::ESHandle thresholdHandle; + setup.get().get(thresholdHandle); + theThresholds = thresholdHandle.product(); + } else { + theThresholds = new AlignPCLThresholds(); + } + theAlignableNavigator = std::make_unique(extras, tracker, muon); theAlignmentParameterStore = store; theAlignables = theAlignmentParameterStore->alignables(); @@ -328,8 +340,13 @@ bool MillePedeAlignmentAlgorithm::storeAlignments() { if (isMode(myPedeRunBit)) { if (runAtPCL_) { + + auto myThresholds = new AlignPCLThresholds(); + myThresholds->setAlignPCLThresholds(theThresholds->getNrecords(),theThresholds->getThreshold_Map()); + MillePedeFileReader mpReader(theConfig.getParameter("MillePedeFileReader"), - thePedeLabels); + thePedeLabels, + std::shared_ptr(myThresholds)); mpReader.read(); return mpReader.storeAlignments(); } else { diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h index 88f3282c5e590..7ac7310b9a11e 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h @@ -20,6 +20,7 @@ #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h" #include "Alignment/ReferenceTrajectories/interface/ReferenceTrajectoryBase.h" +#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" #include #include @@ -262,6 +263,7 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase std::unique_ptr thePedeSteer; std::unique_ptr theTrajectoryFactory; std::vector theCalibrations; + const AlignPCLThresholds* theThresholds; unsigned int theMinNumHits; double theMaximalCor2D; /// maximal correlation allowed for 2D hit in TID/TEC. /// If larger, the 2D measurement gets diagonalized!!! diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc index 56bf7a63a922b..5f53413695065 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc @@ -28,7 +28,9 @@ #include "Alignment/MillePedeAlignmentAlgorithm/interface/PedeLabelerPluginFactory.h" #include "Alignment/TrackerAlignment/interface/AlignableTracker.h" - +/*** Thresholds from DB ***/ +#include "CondFormats/DataRecord/interface/AlignPCLThresholdsRcd.h" + MillePedeDQMModule ::MillePedeDQMModule(const edm::ParameterSet& config) : @@ -108,6 +110,13 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { edm::ESHandle ptp; setup.get().get(ptp); + edm::ESHandle thresholdHandle; + setup.get().get(thresholdHandle); + const AlignPCLThresholds* theThresholds = thresholdHandle.product(); + + auto myThresholds = new AlignPCLThresholds(); + myThresholds->setAlignPCLThresholds(theThresholds->getNrecords(),theThresholds->getThreshold_Map()); + TrackerGeomBuilderFromGeometricDet builder; const auto trackerGeometry = builder.build(&(*geometricDet), *ptp, &(*tTopo)); @@ -125,7 +134,8 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { labelerConfig) }; - mpReader_ = std::make_unique(mpReaderConfig_, pedeLabeler); + mpReader_ = std::make_unique(mpReaderConfig_, pedeLabeler, std::shared_ptr(myThresholds)); + } diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeDQMModule_cff.py b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeDQMModule_cff.py index 0f9e16e2c136f..9f10331855fd4 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeDQMModule_cff.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeDQMModule_cff.py @@ -4,4 +4,4 @@ SiPixelAliDQMModule = cms.EDAnalyzer("MillePedeDQMModule", MillePedeFileReader = cms.PSet(MillePedeFileReader_cfi.MillePedeFileReader.clone()) - ) + ) diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py index ccc747996eb32..b4b0547fea968 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py @@ -3,19 +3,4 @@ MillePedeFileReader = cms.PSet( millePedeLogFile = cms.string('millepede.log'), millePedeResFile = cms.string('millepede.res'), - - # signifiance of movement must be above - sigCut = cms.double(2.5), - - # cutoff in micro-meter & micro-rad - Xcut = cms.double( 5.0), - tXcut = cms.double(30.0), # thetaX - Ycut = cms.double(10.0), - tYcut = cms.double(30.0), # thetaY - Zcut = cms.double(15.0), - tZcut = cms.double(30.0), # thetaZ - - # maximum movement in micro-meter/rad - maxMoveCut = cms.double(200.0), - maxErrorCut = cms.double( 10.0) ) diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc index 8987d217bf50f..03efeadd7e885 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc @@ -18,20 +18,12 @@ MillePedeFileReader ::MillePedeFileReader(const edm::ParameterSet& config, - const std::shared_ptr& pedeLabeler) : + const std::shared_ptr& pedeLabeler, + const std::shared_ptr& theThresholds) : pedeLabeler_(pedeLabeler), + theThresholds_(theThresholds), millePedeLogFile_(config.getParameter("millePedeLogFile")), - millePedeResFile_(config.getParameter("millePedeResFile")), - - sigCut_ (config.getParameter("sigCut")), - Xcut_ (config.getParameter("Xcut")), - tXcut_ (config.getParameter("tXcut")), - Ycut_ (config.getParameter("Ycut")), - tYcut_ (config.getParameter("tYcut")), - Zcut_ (config.getParameter("Zcut")), - tZcut_ (config.getParameter("tZcut")), - maxMoveCut_ (config.getParameter("maxMoveCut")), - maxErrorCut_(config.getParameter("maxErrorCut")) + millePedeResFile_(config.getParameter("millePedeResFile")) { } @@ -70,7 +62,7 @@ ::readMillePedeLogFile() std::string trash; iss >> trash >> trash >> Nrec_; - if (Nrec_ < 25000) { + if (Nrec_ < theThresholds_->getNrecords() ) { updateDB_ = false; } } @@ -87,6 +79,22 @@ ::readMillePedeLogFile() void MillePedeFileReader ::readMillePedeResultFile() { + + // cutoffs by coordinate and by alignable + + std::map > cutoffs_; + std::map > significances_; + std::map > thresholds_; + std::map > errors_; + + std::vector alignables_ = theThresholds_->getAlignableList(); + for (auto ali : alignables_){ + cutoffs_[ali] = theThresholds_->getCut(ali); + significances_[ali] = theThresholds_->getSigCut(ali); + thresholds_[ali] = theThresholds_->getMaxMoveCut(ali); + errors_[ali] = theThresholds_->getMaxErrorCut(ali); + } + updateDB_ = false; std::ifstream resFile; resFile.open(millePedeResFile_.c_str()); @@ -116,49 +124,51 @@ ::readMillePedeResultFile() double ObsErr = std::stof(tokens[4]) * multiplier_[alignableIndex]; auto det = getHLS(alignable); + int detIndex = static_cast(det); + std::string detLabel = getStringFromHLS(det); if (det != PclHLS::NotInPCL) { switch (alignableIndex) { case 0: - Xobs_[static_cast(det)] = ObsMove; - XobsErr_[static_cast(det)] = ObsErr; + Xobs_[detIndex] = ObsMove; + XobsErr_[detIndex] = ObsErr; break; case 1: - Yobs_[static_cast(det)] = ObsMove; - YobsErr_[static_cast(det)] = ObsErr; + Yobs_[detIndex] = ObsMove; + YobsErr_[detIndex] = ObsErr; break; case 2: - Zobs_[static_cast(det)] = ObsMove; - ZobsErr_[static_cast(det)] = ObsErr; + Zobs_[detIndex] = ObsMove; + ZobsErr_[detIndex] = ObsErr; break; case 3: - tXobs_[static_cast(det)] = ObsMove; - tXobsErr_[static_cast(det)] = ObsErr; + tXobs_[detIndex] = ObsMove; + tXobsErr_[detIndex] = ObsErr; break; case 4: - tYobs_[static_cast(det)] = ObsMove; - tYobsErr_[static_cast(det)] = ObsErr; + tYobs_[detIndex] = ObsMove; + tYobsErr_[detIndex] = ObsErr; break; case 5: - tZobs_[static_cast(det)] = ObsMove; - tZobsErr_[static_cast(det)] = ObsErr; + tZobs_[detIndex] = ObsMove; + tZobsErr_[detIndex] = ObsErr; break; } } else { continue; } - if (std::abs(ObsMove) > maxMoveCut_) { + if (std::abs(ObsMove) > thresholds_[detLabel][alignableIndex]) { updateDB_ = false; break; - } else if (std::abs(ObsMove) > cutoffs_[alignableIndex]) { + } else if (std::abs(ObsMove) > cutoffs_[detLabel][alignableIndex]) { - if (std::abs(ObsErr) > maxErrorCut_) { + if (std::abs(ObsErr) > errors_[detLabel][alignableIndex]) { updateDB_ = false; break; } else { - if (std::abs(ObsMove/ObsErr) < sigCut_) { + if (std::abs(ObsMove/ObsErr) < significances_[detLabel][alignableIndex]) { continue; } } @@ -224,6 +234,21 @@ ::getHLS(const Alignable* alignable) { } } +std::string +MillePedeFileReader::getStringFromHLS(MillePedeFileReader::PclHLS HLS){ + switch (HLS) + { + case PclHLS::TPBHalfBarrelXminus : return "TPBHalfBarrelXminus"; + case PclHLS::TPBHalfBarrelXplus : return "TPBHalfBarrelXplus"; + case PclHLS::TPEHalfCylinderXminusZminus : return "TPEHalfCylinderXminusZminus"; + case PclHLS::TPEHalfCylinderXplusZminus : return "TPEHalfCylinderXplusZminus"; + case PclHLS::TPEHalfCylinderXminusZplus : return "TPEHalfCylinderXminusZplus"; + case PclHLS::TPEHalfCylinderXplusZplus : return "TPEHalfCylinderXplusZplus"; + default: return "None"; + } +} + + //============================================================================= //=== STATIC CONST MEMBER DEFINITION === //============================================================================= From 564bfcb49f981e86a52dc2efa952df1786d8942d Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 3 Apr 2017 09:55:23 +0200 Subject: [PATCH 02/18] transient changes to make the test work --- .../ALCARECOPromptCalibProdSiPixelAli_cff.py | 11 +++++++++++ .../python/AlcaSiPixelAliHarvester_cff.py | 12 +++++++++++- .../python/MillePedeFileReader_cfi.py | 15 +++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py index 8c461ba03cbfa..27cd9a7b64bef 100644 --- a/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py +++ b/Alignment/CommonAlignmentProducer/python/ALCARECOPromptCalibProdSiPixelAli_cff.py @@ -12,6 +12,17 @@ from Alignment.CommonAlignmentProducer.LSNumberFilter_cfi import * +# Ugly as hell, but that's life +from CondCore.CondDB.CondDB_cfi import * +CondDB.connect = cms.string('frontier://FrontierPrep/CMS_CONDITIONS') +PoolDBESSource = cms.ESSource("PoolDBESSource", + CondDB, + toGet = cms.VPSet(cms.PSet(record = cms.string('AlignPCLThresholdsRcd'), + tag = cms.string('SiPixelAliThresholds_test_v0') + ) + ) + ) + # Ingredient: offlineBeamSpot from RecoVertex.BeamSpotProducer.BeamSpot_cfi import offlineBeamSpot diff --git a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py index 8527d65e7b845..ccaf2f5fbbd18 100644 --- a/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py +++ b/Alignment/CommonAlignmentProducer/python/AlcaSiPixelAliHarvester_cff.py @@ -9,6 +9,17 @@ # 0000, 0001, 0002,... outputBinaryFile = cms.string('pedeBinary%04d.dat')) +# Ugly as hell, but that's life +from CondCore.CondDB.CondDB_cfi import * +CondDB.connect = cms.string('frontier://FrontierPrep/CMS_CONDITIONS') +PoolDBESSource = cms.ESSource("PoolDBESSource", + CondDB, + toGet = cms.VPSet(cms.PSet(record = cms.string('AlignPCLThresholdsRcd'), + tag = cms.string('SiPixelAliThresholds_test_v0') + ) + ) + ) + from Alignment.MillePedeAlignmentAlgorithm.MillePedeAlignmentAlgorithm_cfi import * from Alignment.CommonAlignmentProducer.TrackerAlignmentProducerForPCL_cff import AlignmentProducer SiPixelAliPedeAlignmentProducer = copy.deepcopy(AlignmentProducer) @@ -25,7 +36,6 @@ SiPixelAliPedeAlignmentProducer.doMisalignmentScenario = False #True - SiPixelAliPedeAlignmentProducer.checkDbAlignmentValidity = False SiPixelAliPedeAlignmentProducer.applyDbAlignment = True SiPixelAliPedeAlignmentProducer.tjTkAssociationMapTag = 'TrackRefitter2' diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py index b4b0547fea968..a2b42cb32ab84 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py @@ -3,4 +3,19 @@ MillePedeFileReader = cms.PSet( millePedeLogFile = cms.string('millepede.log'), millePedeResFile = cms.string('millepede.res'), + + # signifiance of movement must be above + sigCut = cms.double(2.5), + + # cutoff in micro-meter & micro-rad + Xcut = cms.double( 5.0), + tXcut = cms.double(30.0), # thetaX + Ycut = cms.double(10.0), + tYcut = cms.double(30.0), # thetaY + Zcut = cms.double(15.0), + tZcut = cms.double(30.0), # thetaZ + + # maximum movement in micro-meter/rad + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double( 10.0) ) From 1ec44dada8dfd034f1e37a6e24bb65a438ae2921 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 3 Apr 2017 10:21:30 +0200 Subject: [PATCH 03/18] Handle memory --- .../plugins/MillePedeAlignmentAlgorithm.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc index 51242235d0fb0..6316ac1819be6 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc @@ -129,6 +129,7 @@ MillePedeAlignmentAlgorithm::MillePedeAlignmentAlgorithm(const edm::ParameterSet //____________________________________________________ MillePedeAlignmentAlgorithm::~MillePedeAlignmentAlgorithm() { + delete theThresholds; } // Call at beginning of job --------------------------------------------------- @@ -205,6 +206,7 @@ void MillePedeAlignmentAlgorithm::initialize(const edm::EventSetup &setup, theThresholds = thresholdHandle.product(); } else { theThresholds = new AlignPCLThresholds(); + edm::LogInfo("MillePedeAlignmentAlgorithm")<<"Creating a fake AlignPCLThresholds objects. Irrelevant since the running mode is not PCL"<(extras, tracker, muon); @@ -341,12 +343,12 @@ bool MillePedeAlignmentAlgorithm::storeAlignments() if (isMode(myPedeRunBit)) { if (runAtPCL_) { - auto myThresholds = new AlignPCLThresholds(); + auto myThresholds = std::unique_ptr(new AlignPCLThresholds()); myThresholds->setAlignPCLThresholds(theThresholds->getNrecords(),theThresholds->getThreshold_Map()); MillePedeFileReader mpReader(theConfig.getParameter("MillePedeFileReader"), thePedeLabels, - std::shared_ptr(myThresholds)); + std::shared_ptr(myThresholds.get())); mpReader.read(); return mpReader.storeAlignments(); } else { From dc02821bdfe119f62d03a701618b81fd208fcbc2 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 3 Apr 2017 15:33:40 +0200 Subject: [PATCH 04/18] Improve memory handling --- .../interface/MillePedeFileReader.h | 5 ++++- .../plugins/MillePedeAlignmentAlgorithm.cc | 4 +++- .../MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h index f07eb8978d7a0..a729bab37914b 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h +++ b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h @@ -40,6 +40,9 @@ class MillePedeFileReader { const std::array& getZobsErr() const { return ZobsErr_; } const std::array& getTZobs() const { return tZobs_; } const std::array& getTZobsErr() const { return tZobsErr_; } + + const AlignPCLThresholds::threshold_map& getTheThresolds() const { return theThresholds_.get()->getThreshold_Map(); } + private: //========================= PRIVATE ENUMS ==================================== @@ -99,7 +102,7 @@ class MillePedeFileReader { std::array ZobsErr_ = {{0.,0.,0.,0.,0.,0.}}; std::array tZobs_ = {{0.,0.,0.,0.,0.,0.}}; std::array tZobsErr_ = {{0.,0.,0.,0.,0.,0.}}; - + }; #endif /* ALIGNMENT_MILLEPEDEALIGNMENTALGORITHM_INTERFACE_MILLEPEDEFILEREADER_H_ */ diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc index 6316ac1819be6..2ab9d769c7d69 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc @@ -129,7 +129,6 @@ MillePedeAlignmentAlgorithm::MillePedeAlignmentAlgorithm(const edm::ParameterSet //____________________________________________________ MillePedeAlignmentAlgorithm::~MillePedeAlignmentAlgorithm() { - delete theThresholds; } // Call at beginning of job --------------------------------------------------- @@ -357,6 +356,9 @@ bool MillePedeAlignmentAlgorithm::storeAlignments() } else { return false; } + + delete theThresholds; + } //____________________________________________________ diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc index 03efeadd7e885..56663f6cfae6e 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc @@ -81,12 +81,11 @@ ::readMillePedeResultFile() { // cutoffs by coordinate and by alignable - std::map > cutoffs_; std::map > significances_; std::map > thresholds_; std::map > errors_; - + std::vector alignables_ = theThresholds_->getAlignableList(); for (auto ali : alignables_){ cutoffs_[ali] = theThresholds_->getCut(ali); From 9c46749165dad4789c69b6c750a27c83afe81a44 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 3 Apr 2017 15:34:00 +0200 Subject: [PATCH 05/18] introduce changes in the DQM module --- .../plugins/MillePedeDQMModule.cc | 134 ++++++++++++++---- .../plugins/MillePedeDQMModule.h | 23 +-- 2 files changed, 115 insertions(+), 42 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc index 5f53413695065..3b35fba41b14b 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc @@ -36,17 +36,7 @@ MillePedeDQMModule ::MillePedeDQMModule(const edm::ParameterSet& config) : mpReaderConfig_( config.getParameter("MillePedeFileReader") - ), - - sigCut_ (mpReaderConfig_.getParameter("sigCut")), - Xcut_ (mpReaderConfig_.getParameter("Xcut")), - tXcut_ (mpReaderConfig_.getParameter("tXcut")), - Ycut_ (mpReaderConfig_.getParameter("Ycut")), - tYcut_ (mpReaderConfig_.getParameter("tYcut")), - Zcut_ (mpReaderConfig_.getParameter("Zcut")), - tZcut_ (mpReaderConfig_.getParameter("tZcut")), - maxMoveCut_ (mpReaderConfig_.getParameter("maxMoveCut")), - maxErrorCut_ (mpReaderConfig_.getParameter("maxErrorCut")) + ) { } @@ -114,7 +104,7 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { setup.get().get(thresholdHandle); const AlignPCLThresholds* theThresholds = thresholdHandle.product(); - auto myThresholds = new AlignPCLThresholds(); + auto myThresholds = std::unique_ptr(new AlignPCLThresholds()); myThresholds->setAlignPCLThresholds(theThresholds->getNrecords(),theThresholds->getThreshold_Map()); TrackerGeomBuilderFromGeometricDet builder; @@ -134,7 +124,7 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { labelerConfig) }; - mpReader_ = std::make_unique(mpReaderConfig_, pedeLabeler, std::shared_ptr(myThresholds)); + mpReader_ = std::make_unique(mpReaderConfig_, pedeLabeler, std::shared_ptr(myThresholds.get())); } @@ -142,35 +132,102 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { void MillePedeDQMModule ::fillExpertHistos() { + std::array Xcut_, sigXcut_, maxMoveXcut_, maxErrorXcut_; + std::array tXcut_, sigtXcut_, maxMovetXcut_, maxErrortXcut_; + + std::array Ycut_, sigYcut_, maxMoveYcut_, maxErrorYcut_; + std::array tYcut_, sigtYcut_, maxMovetYcut_, maxErrortYcut_; + + std::array Zcut_, sigZcut_, maxMoveZcut_, maxErrorZcut_; + std::array tZcut_, sigtZcut_, maxMovetZcut_, maxErrortZcut_; + + auto myMap = mpReader_->getTheThresolds(); + + std::vector alignablesList; + for(auto it = myMap.begin(); it != myMap.end() ; ++it){ + alignablesList.push_back(it->first); + } + + for (auto &alignable : alignablesList){ + + int detIndex = getIndexFromString(alignable); + + Xcut_[detIndex] = myMap[alignable].getXcut() ; + sigXcut_[detIndex] = myMap[alignable].getSigXcut() ; + maxMoveXcut_[detIndex] = myMap[alignable].getMaxMoveXcut() ; + maxErrorXcut_[detIndex] = myMap[alignable].getErrorXcut() ; + + Ycut_[detIndex] = myMap[alignable].getYcut() ; + sigYcut_[detIndex] = myMap[alignable].getSigYcut() ; + maxMoveYcut_[detIndex] = myMap[alignable].getMaxMoveYcut() ; + maxErrorYcut_[detIndex] = myMap[alignable].getErrorYcut() ; + + Zcut_[detIndex] = myMap[alignable].getZcut() ; + sigZcut_[detIndex] = myMap[alignable].getSigZcut() ; + maxMoveZcut_[detIndex] = myMap[alignable].getMaxMoveZcut() ; + maxErrorZcut_[detIndex] = myMap[alignable].getErrorZcut() ; + + tXcut_[detIndex] = myMap[alignable].getThetaXcut() ; + sigtXcut_[detIndex] = myMap[alignable].getSigThetaXcut() ; + maxMovetXcut_[detIndex] = myMap[alignable].getMaxMoveThetaXcut() ; + maxErrortXcut_[detIndex] = myMap[alignable].getErrorThetaXcut() ; + + tYcut_[detIndex] = myMap[alignable].getThetaYcut() ; + sigtYcut_[detIndex] = myMap[alignable].getSigThetaYcut() ; + maxMovetYcut_[detIndex] = myMap[alignable].getMaxMoveThetaYcut() ; + maxErrortYcut_[detIndex] = myMap[alignable].getErrorThetaYcut() ; + + tZcut_[detIndex] = myMap[alignable].getThetaZcut() ; + sigtZcut_[detIndex] = myMap[alignable].getSigThetaYcut() ; + maxMovetZcut_[detIndex] = myMap[alignable].getMaxMoveThetaYcut() ; + maxErrortZcut_[detIndex] = myMap[alignable].getErrorThetaYcut() ; + + } - fillExpertHisto(h_xPos, Xcut_, sigCut_, maxMoveCut_, maxErrorCut_, mpReader_->getXobs(), mpReader_->getXobsErr()); - fillExpertHisto(h_xRot, tXcut_, sigCut_, maxMoveCut_, maxErrorCut_, mpReader_->getTXobs(), mpReader_->getTXobsErr()); + fillExpertHisto(h_xPos, Xcut_, sigXcut_, maxMoveXcut_, maxErrorXcut_, mpReader_->getXobs(), mpReader_->getXobsErr()); + fillExpertHisto(h_xRot, tXcut_, sigtXcut_, maxMovetXcut_, maxErrortXcut_, mpReader_->getTXobs(), mpReader_->getTXobsErr()); - fillExpertHisto(h_yPos, Ycut_, sigCut_, maxMoveCut_, maxErrorCut_, mpReader_->getYobs(), mpReader_->getYobsErr()); - fillExpertHisto(h_yRot, tYcut_, sigCut_, maxMoveCut_, maxErrorCut_, mpReader_->getTYobs(), mpReader_->getTYobsErr()); + fillExpertHisto(h_yPos, Ycut_, sigYcut_, maxMoveYcut_, maxErrorYcut_, mpReader_->getYobs(), mpReader_->getYobsErr()); + fillExpertHisto(h_yRot, tYcut_, sigtYcut_, maxMovetYcut_, maxErrortYcut_, mpReader_->getTYobs(), mpReader_->getTYobsErr()); - fillExpertHisto(h_zPos, Zcut_, sigCut_, maxMoveCut_, maxErrorCut_, mpReader_->getZobs(), mpReader_->getZobsErr()); - fillExpertHisto(h_zRot, tZcut_, sigCut_, maxMoveCut_, maxErrorCut_, mpReader_->getTZobs(), mpReader_->getTZobsErr()); + fillExpertHisto(h_zPos, Zcut_, sigZcut_, maxMoveZcut_, maxErrorZcut_, mpReader_->getZobs(), mpReader_->getZobsErr()); + fillExpertHisto(h_zRot, tZcut_, sigtZcut_, maxMovetZcut_, maxErrortZcut_, mpReader_->getTZobs(), mpReader_->getTZobsErr()); } void MillePedeDQMModule -::fillExpertHisto(MonitorElement* histo, const double cut, const double sigCut, const double maxMoveCut, const double maxErrorCut, +::fillExpertHisto(MonitorElement* histo, + std::array cut, std::array sigCut, + std::array maxMoveCut, std::array maxErrorCut, std::array obs, std::array obsErr) { TH1F* histo_0 = histo->getTH1F(); - histo_0->SetMinimum(-(maxMoveCut_)); - histo_0->SetMaximum( maxMoveCut_); + double max_ = *std::max_element(maxMoveCut.begin(),maxMoveCut.end()); + + histo_0->SetMinimum(-(max_)); + histo_0->SetMaximum( max_); for (size_t i = 0; i < obs.size(); ++i) { histo_0->SetBinContent(i+1, obs[i]); histo_0->SetBinError(i+1, obsErr[i]); } - histo_0->SetBinContent(8,cut); - histo_0->SetBinContent(9,sigCut); - histo_0->SetBinContent(10,maxMoveCut); - histo_0->SetBinContent(11,maxErrorCut); + + for (size_t i = obs.size(); i < obs.size()*2; ++i) { + histo_0->SetBinContent(i+1, cut[i]); + } + + for (size_t i = obs.size()*2; i < obs.size()*3; ++i) { + histo_0->SetBinContent(i+1, sigCut[i]); + } + + for (size_t i = obs.size()*3; i < obs.size()*4; ++i) { + histo_0->SetBinContent(i+1, maxMoveCut[i]); + } + + for (size_t i = obs.size()*4; i < obs.size()*5; ++i) { + histo_0->SetBinContent(i+1, maxErrorCut[i]); + } } @@ -185,3 +242,28 @@ ::setupChanged(const edm::EventSetup& setup) return changed; } + + +int MillePedeDQMModule +::getIndexFromString(const std::string& alignableId) +{ + + if(alignableId == "TPBHalfBarrelXminus"){ + return 3; + } else if(alignableId == "TPBHalfBarrelXplus"){ + return 2; + } else if(alignableId == "TPEHalfCylinderXminusZminus") { + return 1; + } else if(alignableId == "TPEHalfCylinderXplusZminus") { + return 0; + } else if(alignableId == "TPEHalfCylinderXminusZplus") { + return 5; + } else if(alignableId == "TPEHalfCylinderXplusZplus") { + return 4; + } else{ + throw cms::Exception("LogicError") + << "@SUB=MillePedeDQMModule::getIndexFromString\n" + << "Retrieving conversion for not supported Alignable partition" + << alignableId; + } +} diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h index 2ec2d565afbdf..fb86f27f2ccc2 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h @@ -65,17 +65,18 @@ class MillePedeDQMModule : public DQMEDHarvester { void fillExpertHistos(); void fillExpertHisto(MonitorElement* histo, - const double cut, - const double sigCut, - const double maxMoveCut, - const double maxErrorCut, + std::array cut, + std::array sigCut, + std::array maxMoveCut, + std::array maxErrorCut, std::array obs, std::array obsErr); bool setupChanged(const edm::EventSetup&); + int getIndexFromString(const std::string& alignableId); - //========================== PRIVATE DATA ==================================== - //============================================================================ + //========================== PRIVATE DATA ==================================== + //============================================================================ const edm::ParameterSet mpReaderConfig_; std::unique_ptr tracker_; @@ -85,16 +86,6 @@ class MillePedeDQMModule : public DQMEDHarvester { edm::ESWatcher watchIdealGeometryRcd_; edm::ESWatcher watchPTrackerParametersRcd_; - // Signifiance of movement must be above - double sigCut_; - // Cutoff in micro-meter & micro-rad - double Xcut_, tXcut_; - double Ycut_, tYcut_; - double Zcut_, tZcut_; - // maximum movement in micro-meter/rad - double maxMoveCut_; - double maxErrorCut_; - // Histograms MonitorElement* h_xPos; MonitorElement* h_xRot; From 346f96a875061427f104a071582ba477d493e8de Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 3 Apr 2017 18:00:45 +0200 Subject: [PATCH 06/18] Miscellaneous fixes in histogram binning and memory handlings --- .../plugins/MillePedeAlignmentAlgorithm.cc | 7 ++-- .../plugins/MillePedeDQMModule.cc | 36 +++++++++++-------- .../plugins/MillePedeDQMModule.h | 5 +-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc index 2ab9d769c7d69..7243154e3a0ea 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc @@ -342,12 +342,12 @@ bool MillePedeAlignmentAlgorithm::storeAlignments() if (isMode(myPedeRunBit)) { if (runAtPCL_) { - auto myThresholds = std::unique_ptr(new AlignPCLThresholds()); + auto myThresholds = new AlignPCLThresholds(); myThresholds->setAlignPCLThresholds(theThresholds->getNrecords(),theThresholds->getThreshold_Map()); MillePedeFileReader mpReader(theConfig.getParameter("MillePedeFileReader"), thePedeLabels, - std::shared_ptr(myThresholds.get())); + std::shared_ptr(myThresholds)); mpReader.read(); return mpReader.storeAlignments(); } else { @@ -356,9 +356,6 @@ bool MillePedeAlignmentAlgorithm::storeAlignments() } else { return false; } - - delete theThresholds; - } //____________________________________________________ diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc index 3b35fba41b14b..969e122a6579d 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc @@ -43,6 +43,7 @@ ::MillePedeDQMModule(const edm::ParameterSet& config) : MillePedeDQMModule ::~MillePedeDQMModule() { + delete theThresholds; } //============================================================================= @@ -57,12 +58,12 @@ ::bookHistograms(DQMStore::IBooker& booker) booker.cd(); booker.setCurrentFolder("AlCaReco/SiPixelAli/"); - h_xPos = booker.book1D("Xpos", "#Delta X;;#mu m", 10, 0, 10.); - h_xRot = booker.book1D("Xrot", "#Delta #theta_{X};;#mu rad", 10, 0, 10.); - h_yPos = booker.book1D("Ypos", "#Delta Y;;#mu m", 10, 0., 10.); - h_yRot = booker.book1D("Yrot", "#Delta #theta_{Y};;#mu rad", 10, 0, 10.); - h_zPos = booker.book1D("Zpos", "#Delta Z;;#mu m", 10, 0., 10.); - h_zRot = booker.book1D("Zrot", "#Delta #theta_{Z};;#mu rad", 10, 0, 10.); + h_xPos = booker.book1D("Xpos", "#Delta X;;#mu m", 30, 0., 30.); + h_xRot = booker.book1D("Xrot", "#Delta #theta_{X};;#mu rad", 30, 0., 30.); + h_yPos = booker.book1D("Ypos", "#Delta Y;;#mu m", 30, 0., 30.); + h_yRot = booker.book1D("Yrot", "#Delta #theta_{Y};;#mu rad", 30, 0., 30.); + h_zPos = booker.book1D("Zpos", "#Delta Z;;#mu m", 30, 0., 30.); + h_zRot = booker.book1D("Zrot", "#Delta #theta_{Z};;#mu rad", 30, 0., 30.); booker.cd(); } @@ -102,9 +103,9 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { edm::ESHandle thresholdHandle; setup.get().get(thresholdHandle); - const AlignPCLThresholds* theThresholds = thresholdHandle.product(); + theThresholds = thresholdHandle.product(); - auto myThresholds = std::unique_ptr(new AlignPCLThresholds()); + auto myThresholds = new AlignPCLThresholds(); myThresholds->setAlignPCLThresholds(theThresholds->getNrecords(),theThresholds->getThreshold_Map()); TrackerGeomBuilderFromGeometricDet builder; @@ -124,7 +125,8 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { labelerConfig) }; - mpReader_ = std::make_unique(mpReaderConfig_, pedeLabeler, std::shared_ptr(myThresholds.get())); + + mpReader_ = std::make_unique(mpReaderConfig_, pedeLabeler, std::shared_ptr(myThresholds)); } @@ -132,6 +134,7 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { void MillePedeDQMModule ::fillExpertHistos() { + std::array Xcut_, sigXcut_, maxMoveXcut_, maxErrorXcut_; std::array tXcut_, sigtXcut_, maxMovetXcut_, maxErrortXcut_; @@ -141,7 +144,10 @@ ::fillExpertHistos() std::array Zcut_, sigZcut_, maxMoveZcut_, maxErrorZcut_; std::array tZcut_, sigtZcut_, maxMovetZcut_, maxErrortZcut_; - auto myMap = mpReader_->getTheThresolds(); + auto myMap = theThresholds->getThreshold_Map(); ; + + //auto myMap = mpReader_-> getTheThresolds(); + theThresholds->printAll(); std::vector alignablesList; for(auto it = myMap.begin(); it != myMap.end() ; ++it){ @@ -210,23 +216,23 @@ ::fillExpertHisto(MonitorElement* histo, for (size_t i = 0; i < obs.size(); ++i) { histo_0->SetBinContent(i+1, obs[i]); - histo_0->SetBinError(i+1, obsErr[i]); + histo_0->SetBinError(i+1, obsErr[i]); } for (size_t i = obs.size(); i < obs.size()*2; ++i) { - histo_0->SetBinContent(i+1, cut[i]); + histo_0->SetBinContent(i+1, cut[i-obs.size()]); } for (size_t i = obs.size()*2; i < obs.size()*3; ++i) { - histo_0->SetBinContent(i+1, sigCut[i]); + histo_0->SetBinContent(i+1, sigCut[i-obs.size()*2]); } for (size_t i = obs.size()*3; i < obs.size()*4; ++i) { - histo_0->SetBinContent(i+1, maxMoveCut[i]); + histo_0->SetBinContent(i+1, maxMoveCut[i-obs.size()*3]); } for (size_t i = obs.size()*4; i < obs.size()*5; ++i) { - histo_0->SetBinContent(i+1, maxErrorCut[i]); + histo_0->SetBinContent(i+1, maxErrorCut[i-obs.size()*4]); } } diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h index fb86f27f2ccc2..5003ae2bb65d6 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h @@ -49,10 +49,6 @@ class MillePedeDQMModule : public DQMEDHarvester { MillePedeDQMModule(const edm::ParameterSet&); virtual ~MillePedeDQMModule(); - - - - virtual void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override; //========================= PRIVATE METHODS ================================== @@ -78,6 +74,7 @@ class MillePedeDQMModule : public DQMEDHarvester { //========================== PRIVATE DATA ==================================== //============================================================================ + const AlignPCLThresholds* theThresholds; const edm::ParameterSet mpReaderConfig_; std::unique_ptr tracker_; std::unique_ptr mpReader_; From 1f708766073897796bed7a0e679a4824fd2dc720 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 3 Apr 2017 18:27:22 +0200 Subject: [PATCH 07/18] Finalize DQM class --- .../interface/MillePedeFileReader.h | 3 --- .../plugins/MillePedeDQMModule.cc | 13 +++++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h index a729bab37914b..b1f8d3f89c319 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h +++ b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h @@ -40,9 +40,6 @@ class MillePedeFileReader { const std::array& getZobsErr() const { return ZobsErr_; } const std::array& getTZobs() const { return tZobs_; } const std::array& getTZobsErr() const { return tZobsErr_; } - - const AlignPCLThresholds::threshold_map& getTheThresolds() const { return theThresholds_.get()->getThreshold_Map(); } - private: //========================= PRIVATE ENUMS ==================================== diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc index 969e122a6579d..90fb97b7c1fb7 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc @@ -101,6 +101,7 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { edm::ESHandle ptp; setup.get().get(ptp); + // take the thresholds from DB edm::ESHandle thresholdHandle; setup.get().get(thresholdHandle); theThresholds = thresholdHandle.product(); @@ -145,8 +146,6 @@ ::fillExpertHistos() std::array tZcut_, sigtZcut_, maxMovetZcut_, maxErrortZcut_; auto myMap = theThresholds->getThreshold_Map(); ; - - //auto myMap = mpReader_-> getTheThresolds(); theThresholds->printAll(); std::vector alignablesList; @@ -214,23 +213,33 @@ ::fillExpertHisto(MonitorElement* histo, histo_0->SetMinimum(-(max_)); histo_0->SetMaximum( max_); + // first 6 bins for movements + for (size_t i = 0; i < obs.size(); ++i) { histo_0->SetBinContent(i+1, obs[i]); histo_0->SetBinError(i+1, obsErr[i]); } + // next 6 bins for cutoffs + for (size_t i = obs.size(); i < obs.size()*2; ++i) { histo_0->SetBinContent(i+1, cut[i-obs.size()]); } + // next 6 bins for significances + for (size_t i = obs.size()*2; i < obs.size()*3; ++i) { histo_0->SetBinContent(i+1, sigCut[i-obs.size()*2]); } + // next 6 bins for maximum movements + for (size_t i = obs.size()*3; i < obs.size()*4; ++i) { histo_0->SetBinContent(i+1, maxMoveCut[i-obs.size()*3]); } + // final 6 bins for maximum errors + for (size_t i = obs.size()*4; i < obs.size()*5; ++i) { histo_0->SetBinContent(i+1, maxErrorCut[i-obs.size()*4]); } From b559f4c8e5a8546e29d64125cc8bd7e8bf75cf34 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 3 Apr 2017 18:27:47 +0200 Subject: [PATCH 08/18] remove unused configuration in MillePede DQM class --- .../python/MillePedeFileReader_cfi.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py index a2b42cb32ab84..9f05d34ab15a0 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py +++ b/Alignment/MillePedeAlignmentAlgorithm/python/MillePedeFileReader_cfi.py @@ -3,19 +3,4 @@ MillePedeFileReader = cms.PSet( millePedeLogFile = cms.string('millepede.log'), millePedeResFile = cms.string('millepede.res'), - - # signifiance of movement must be above - sigCut = cms.double(2.5), - - # cutoff in micro-meter & micro-rad - Xcut = cms.double( 5.0), - tXcut = cms.double(30.0), # thetaX - Ycut = cms.double(10.0), - tYcut = cms.double(30.0), # thetaY - Zcut = cms.double(15.0), - tZcut = cms.double(30.0), # thetaZ - - # maximum movement in micro-meter/rad - maxMoveCut = cms.double(200.0), - maxErrorCut = cms.double( 10.0) -) + ) From 546b591a22d7d7f68dafda59d1c734f3a5df3955 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 3 Apr 2017 22:54:50 +0200 Subject: [PATCH 09/18] add logInfo for degug --- .../src/MillePedeFileReader.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc index 56663f6cfae6e..6262899605c00 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc @@ -63,6 +63,7 @@ ::readMillePedeLogFile() iss >> trash >> trash >> Nrec_; if (Nrec_ < theThresholds_->getNrecords() ) { + edm::LogInfo("MillePedeFileReader")<<"Number of records used "<getNrecords()< thresholds_[detLabel][alignableIndex]) { updateDB_ = false; break; From 2882cdb7a819c2f19668c8b164dc9ec6bb90311b Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 4 Apr 2017 13:19:56 +0200 Subject: [PATCH 10/18] Improve I/O and readability --- .../interface/MillePedeFileReader.h | 7 ++++ .../src/MillePedeFileReader.cc | 41 ++++++++++++------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h index b1f8d3f89c319..4df91e6b50edd 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h +++ b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h @@ -102,4 +102,11 @@ class MillePedeFileReader { }; +#include +const std::array coord_str = {{"X", "Y", "Z", "theta_X", "theta_Y", "theta_Z", "extra_DOF", "none"}}; +inline std::ostream & operator<<(std::ostream & os, const AlignPCLThresholds::coordType& c) { + if (c >= AlignPCLThresholds::endOfTypes || c < 0) return os << "unrecongnized coordinate"; + return os << coord_str[c]; +} + #endif /* ALIGNMENT_MILLEPEDEALIGNMENTALGORITHM_INTERFACE_MILLEPEDEFILEREADER_H_ */ diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc index 6262899605c00..edcff8c2ebd4d 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc @@ -125,55 +125,64 @@ ::readMillePedeResultFile() auto det = getHLS(alignable); int detIndex = static_cast(det); + auto coord = static_cast(alignableIndex); std::string detLabel = getStringFromHLS(det); if (det != PclHLS::NotInPCL) { - switch (alignableIndex) { - case 0: + switch (coord) { + case AlignPCLThresholds::X: Xobs_[detIndex] = ObsMove; XobsErr_[detIndex] = ObsErr; break; - case 1: + case AlignPCLThresholds::Y: Yobs_[detIndex] = ObsMove; YobsErr_[detIndex] = ObsErr; break; - case 2: + case AlignPCLThresholds::Z: Zobs_[detIndex] = ObsMove; ZobsErr_[detIndex] = ObsErr; break; - case 3: + case AlignPCLThresholds::theta_X: tXobs_[detIndex] = ObsMove; tXobsErr_[detIndex] = ObsErr; break; - case 4: + case AlignPCLThresholds::theta_Y: tYobs_[detIndex] = ObsMove; tYobsErr_[detIndex] = ObsErr; break; - case 5: + case AlignPCLThresholds::theta_Z: tZobs_[detIndex] = ObsMove; tZobsErr_[detIndex] = ObsErr; break; + default: + edm::LogError("MillePedeFileReader") << "Currently not able to handle DOF " << coord + << std::endl; + break; } } else { continue; } - edm::LogVerbatim("MillePedeFileReader")<<" alignableLabel: "<< alignableLabel <<" with index "< thresholds_[detLabel][alignableIndex]) { + edm::LogWarning("MillePedeFileReader")<<"Aborting payload creation." + <<" Exceeding maximum thresholds for movement: "< cutoffs_[detLabel][alignableIndex]) { if (std::abs(ObsErr) > errors_[detLabel][alignableIndex]) { + edm::LogWarning("MillePedeFileReader")<<"Aborting payload creation." + <<" Exceeding maximum thresholds for error: "< MillePedeFileReader::multiplier_; + + + From 6347a3cbe97cb84809c74d4cf88042df549d5e92 Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 4 Apr 2017 15:08:49 +0200 Subject: [PATCH 11/18] Specify in the logs which partition and coordinate is triggering the update --- .../MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc index edcff8c2ebd4d..abc3e0ea8706a 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc @@ -191,7 +191,7 @@ ::readMillePedeResultFile() } } updateDB_ = true; - edm::LogWarning("MillePedeFileReader")<<"This correction will trigger a new payload!"; + edm::LogWarning("MillePedeFileReader")<<"This correction: "< Date: Tue, 4 Apr 2017 17:07:13 +0200 Subject: [PATCH 12/18] Improve booking of histograms --- .../plugins/MillePedeDQMModule.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc index 90fb97b7c1fb7..9cd577f53d466 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc @@ -58,12 +58,12 @@ ::bookHistograms(DQMStore::IBooker& booker) booker.cd(); booker.setCurrentFolder("AlCaReco/SiPixelAli/"); - h_xPos = booker.book1D("Xpos", "#Delta X;;#mu m", 30, 0., 30.); - h_xRot = booker.book1D("Xrot", "#Delta #theta_{X};;#mu rad", 30, 0., 30.); - h_yPos = booker.book1D("Ypos", "#Delta Y;;#mu m", 30, 0., 30.); - h_yRot = booker.book1D("Yrot", "#Delta #theta_{Y};;#mu rad", 30, 0., 30.); - h_zPos = booker.book1D("Zpos", "#Delta Z;;#mu m", 30, 0., 30.); - h_zRot = booker.book1D("Zrot", "#Delta #theta_{Z};;#mu rad", 30, 0., 30.); + h_xPos = booker.book1D("Xpos", "Alignment fit #DeltaX;;#mum", 30, 0., 30.); + h_xRot = booker.book1D("Xrot", "Alignment fit #Delta#theta_{X};;#murad", 30, 0., 30.); + h_yPos = booker.book1D("Ypos", "Alignment fit #DeltaY;;#mum", 30, 0., 30.); + h_yRot = booker.book1D("Yrot", "Alignment fit #Delta#theta_{Y};;#murad", 30, 0., 30.); + h_zPos = booker.book1D("Zpos", "Alignment fit #DeltaZ;;#mum", 30, 0., 30.); + h_zRot = booker.book1D("Zrot", "Alignment fit #Delta#theta_{Z};;#murad", 30, 0., 30.); booker.cd(); } From 842a221a911b8b922f2ae037377aa91d8c0dce09 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 5 Apr 2017 16:39:41 +0200 Subject: [PATCH 13/18] first round of fixes from code review --- .../interface/MillePedeFileReader.h | 2 +- .../plugins/MillePedeDQMModule.cc | 6 +++--- .../plugins/MillePedeDQMModule.h | 12 ++++++------ .../src/MillePedeFileReader.cc | 9 ++++++--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h index 4df91e6b50edd..ccce58e4f07be 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h +++ b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h @@ -4,6 +4,7 @@ /*** system includes ***/ #include #include +#include /*** core framework functionality ***/ #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -102,7 +103,6 @@ class MillePedeFileReader { }; -#include const std::array coord_str = {{"X", "Y", "Z", "theta_X", "theta_Y", "theta_Z", "extra_DOF", "none"}}; inline std::ostream & operator<<(std::ostream & os, const AlignPCLThresholds::coordType& c) { if (c >= AlignPCLThresholds::endOfTypes || c < 0) return os << "unrecongnized coordinate"; diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc index 9cd577f53d466..855c837fbf66b 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc @@ -202,9 +202,9 @@ ::fillExpertHistos() void MillePedeDQMModule ::fillExpertHisto(MonitorElement* histo, - std::array cut, std::array sigCut, - std::array maxMoveCut, std::array maxErrorCut, - std::array obs, std::array obsErr) + const std::array& cut, const std::array& sigCut, + const std::array& maxMoveCut,const std::array& maxErrorCut, + const std::array& obs,const std::array& obsErr) { TH1F* histo_0 = histo->getTH1F(); diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h index 5003ae2bb65d6..2552a3df0c00b 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h @@ -61,12 +61,12 @@ class MillePedeDQMModule : public DQMEDHarvester { void fillExpertHistos(); void fillExpertHisto(MonitorElement* histo, - std::array cut, - std::array sigCut, - std::array maxMoveCut, - std::array maxErrorCut, - std::array obs, - std::array obsErr); + const std::array& cut, + const std::array& sigCut, + const std::array& maxMoveCut, + const std::array& maxErrorCut, + const std::array& obs, + const std::array& obsErr); bool setupChanged(const edm::EventSetup&); int getIndexFromString(const std::string& alignableId); diff --git a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc index abc3e0ea8706a..9f2bb81b03f1f 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeFileReader.cc @@ -88,7 +88,7 @@ ::readMillePedeResultFile() std::map > errors_; std::vector alignables_ = theThresholds_->getAlignableList(); - for (auto ali : alignables_){ + for (auto &ali : alignables_){ cutoffs_[ali] = theThresholds_->getCut(ali); significances_[ali] = theThresholds_->getSigCut(ali); thresholds_[ali] = theThresholds_->getMaxMoveCut(ali); @@ -191,7 +191,7 @@ ::readMillePedeResultFile() } } updateDB_ = true; - edm::LogWarning("MillePedeFileReader")<<"This correction: "< Date: Wed, 5 Apr 2017 18:12:43 +0200 Subject: [PATCH 14/18] remove useless clause --- .../plugins/MillePedeAlignmentAlgorithm.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc index 7243154e3a0ea..c3654a81e0e4c 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc @@ -203,10 +203,7 @@ void MillePedeAlignmentAlgorithm::initialize(const edm::EventSetup &setup, edm::ESHandle thresholdHandle; setup.get().get(thresholdHandle); theThresholds = thresholdHandle.product(); - } else { - theThresholds = new AlignPCLThresholds(); - edm::LogInfo("MillePedeAlignmentAlgorithm")<<"Creating a fake AlignPCLThresholds objects. Irrelevant since the running mode is not PCL"<(extras, tracker, muon); theAlignmentParameterStore = store; From cd22bfb5312a7b14eb7f23d939eb88b384ac8c65 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 5 Apr 2017 18:13:39 +0200 Subject: [PATCH 15/18] comply with class naming convention --- .../plugins/MillePedeDQMModule.cc | 9 ++++----- .../plugins/MillePedeDQMModule.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc index 855c837fbf66b..ffa760e60e9de 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc @@ -43,7 +43,6 @@ ::MillePedeDQMModule(const edm::ParameterSet& config) : MillePedeDQMModule ::~MillePedeDQMModule() { - delete theThresholds; } //============================================================================= @@ -104,10 +103,10 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { // take the thresholds from DB edm::ESHandle thresholdHandle; setup.get().get(thresholdHandle); - theThresholds = thresholdHandle.product(); + thresholds_ = thresholdHandle.product(); auto myThresholds = new AlignPCLThresholds(); - myThresholds->setAlignPCLThresholds(theThresholds->getNrecords(),theThresholds->getThreshold_Map()); + myThresholds->setAlignPCLThresholds(thresholds_->getNrecords(),thresholds_->getThreshold_Map()); TrackerGeomBuilderFromGeometricDet builder; @@ -145,8 +144,8 @@ ::fillExpertHistos() std::array Zcut_, sigZcut_, maxMoveZcut_, maxErrorZcut_; std::array tZcut_, sigtZcut_, maxMovetZcut_, maxErrortZcut_; - auto myMap = theThresholds->getThreshold_Map(); ; - theThresholds->printAll(); + auto myMap = thresholds_->getThreshold_Map(); ; + thresholds_->printAll(); std::vector alignablesList; for(auto it = myMap.begin(); it != myMap.end() ; ++it){ diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h index 2552a3df0c00b..26c384238c6bd 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h @@ -74,7 +74,7 @@ class MillePedeDQMModule : public DQMEDHarvester { //========================== PRIVATE DATA ==================================== //============================================================================ - const AlignPCLThresholds* theThresholds; + const AlignPCLThresholds* thresholds_; const edm::ParameterSet mpReaderConfig_; std::unique_ptr tracker_; std::unique_ptr mpReader_; From 83550c915c282dd40b67990e8ba73ef2bc5a48ec Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 5 Apr 2017 21:47:54 +0200 Subject: [PATCH 16/18] fix handling of AlignPCLThresholds objects in MillePedeAlignmentAlgorithm --- .../plugins/MillePedeAlignmentAlgorithm.cc | 17 ++++++++++++----- .../plugins/MillePedeAlignmentAlgorithm.h | 4 +++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc index c3654a81e0e4c..8237c70c36220 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc @@ -202,7 +202,9 @@ void MillePedeAlignmentAlgorithm::initialize(const edm::EventSetup &setup, if (runAtPCL_) { edm::ESHandle thresholdHandle; setup.get().get(thresholdHandle); - theThresholds = thresholdHandle.product(); + auto th = thresholdHandle.product(); + theThresholds = std::make_shared(); + storeThresholds(th->getNrecords(),th->getThreshold_Map()); } theAlignableNavigator = std::make_unique(extras, tracker, muon); @@ -323,6 +325,13 @@ bool MillePedeAlignmentAlgorithm::addCalibrations(const std::vectorsetAlignPCLThresholds(nRecords,thresholdMap); + return true; +} + //_____________________________________________________________________________ bool MillePedeAlignmentAlgorithm::processesEvents() { @@ -339,12 +348,10 @@ bool MillePedeAlignmentAlgorithm::storeAlignments() if (isMode(myPedeRunBit)) { if (runAtPCL_) { - auto myThresholds = new AlignPCLThresholds(); - myThresholds->setAlignPCLThresholds(theThresholds->getNrecords(),theThresholds->getThreshold_Map()); - MillePedeFileReader mpReader(theConfig.getParameter("MillePedeFileReader"), thePedeLabels, - std::shared_ptr(myThresholds)); + theThresholds + ); mpReader.read(); return mpReader.storeAlignments(); } else { diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h index 7ac7310b9a11e..ff77c3aa5bec5 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.h @@ -73,6 +73,8 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase /// Pass integrated calibrations to Millepede (they are not owned by Millepede!) virtual bool addCalibrations(const std::vector &iCals) override; + virtual bool storeThresholds(const int & nRecords,const AlignPCLThresholds::threshold_map & thresholdMap); + /// Called at end of job virtual void terminate(const edm::EventSetup& iSetup) override; /// Called at end of job @@ -263,7 +265,7 @@ class MillePedeAlignmentAlgorithm : public AlignmentAlgorithmBase std::unique_ptr thePedeSteer; std::unique_ptr theTrajectoryFactory; std::vector theCalibrations; - const AlignPCLThresholds* theThresholds; + std::shared_ptr theThresholds; unsigned int theMinNumHits; double theMaximalCor2D; /// maximal correlation allowed for 2D hit in TID/TEC. /// If larger, the 2D measurement gets diagonalized!!! From 3d6d7f26eb5b5955b1b7596386c24c1380c901dd Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 5 Apr 2017 22:18:09 +0200 Subject: [PATCH 17/18] fix handling of AlignPCLThresholds objects in MillePedeDQMModule --- .../interface/MillePedeFileReader.h | 2 ++ .../plugins/MillePedeDQMModule.cc | 7 +++---- .../plugins/MillePedeDQMModule.h | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h index ccce58e4f07be..f1aa0050408b7 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h +++ b/Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h @@ -42,6 +42,8 @@ class MillePedeFileReader { const std::array& getTZobs() const { return tZobs_; } const std::array& getTZobsErr() const { return tZobsErr_; } + const AlignPCLThresholds::threshold_map getThresholdMap() const {return theThresholds_.get()->getThreshold_Map (); } + private: //========================= PRIVATE ENUMS ==================================== //============================================================================ diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc index ffa760e60e9de..fc4eba2dd20f2 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc @@ -103,9 +103,9 @@ ::beginRun(const edm::Run&, const edm::EventSetup& setup) { // take the thresholds from DB edm::ESHandle thresholdHandle; setup.get().get(thresholdHandle); - thresholds_ = thresholdHandle.product(); + auto thresholds_ = thresholdHandle.product(); - auto myThresholds = new AlignPCLThresholds(); + auto myThresholds = std::make_shared(); myThresholds->setAlignPCLThresholds(thresholds_->getNrecords(),thresholds_->getThreshold_Map()); TrackerGeomBuilderFromGeometricDet builder; @@ -144,8 +144,7 @@ ::fillExpertHistos() std::array Zcut_, sigZcut_, maxMoveZcut_, maxErrorZcut_; std::array tZcut_, sigtZcut_, maxMovetZcut_, maxErrortZcut_; - auto myMap = thresholds_->getThreshold_Map(); ; - thresholds_->printAll(); + auto myMap = mpReader_->getThresholdMap(); std::vector alignablesList; for(auto it = myMap.begin(); it != myMap.end() ; ++it){ diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h index 26c384238c6bd..d2d082b478bb8 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.h @@ -74,7 +74,6 @@ class MillePedeDQMModule : public DQMEDHarvester { //========================== PRIVATE DATA ==================================== //============================================================================ - const AlignPCLThresholds* thresholds_; const edm::ParameterSet mpReaderConfig_; std::unique_ptr tracker_; std::unique_ptr mpReader_; From 9495d8e4ced1f1054d141c5693dd408907d1a92e Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 6 Apr 2017 10:16:43 +0200 Subject: [PATCH 18/18] ensure backward compatibility with old format of DQM output --- .../plugins/MillePedeDQMModule.cc | 62 +++++++++---------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc index fc4eba2dd20f2..da682450bde9b 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeDQMModule.cc @@ -57,12 +57,12 @@ ::bookHistograms(DQMStore::IBooker& booker) booker.cd(); booker.setCurrentFolder("AlCaReco/SiPixelAli/"); - h_xPos = booker.book1D("Xpos", "Alignment fit #DeltaX;;#mum", 30, 0., 30.); - h_xRot = booker.book1D("Xrot", "Alignment fit #Delta#theta_{X};;#murad", 30, 0., 30.); - h_yPos = booker.book1D("Ypos", "Alignment fit #DeltaY;;#mum", 30, 0., 30.); - h_yRot = booker.book1D("Yrot", "Alignment fit #Delta#theta_{Y};;#murad", 30, 0., 30.); - h_zPos = booker.book1D("Zpos", "Alignment fit #DeltaZ;;#mum", 30, 0., 30.); - h_zRot = booker.book1D("Zrot", "Alignment fit #Delta#theta_{Z};;#murad", 30, 0., 30.); + h_xPos = booker.book1D("Xpos", "Alignment fit #DeltaX;;#mum", 36, 0., 36.); + h_xRot = booker.book1D("Xrot", "Alignment fit #Delta#theta_{X};;#murad", 36, 0., 36.); + h_yPos = booker.book1D("Ypos", "Alignment fit #DeltaY;;#mum", 36, 0., 36.); + h_yRot = booker.book1D("Yrot", "Alignment fit #Delta#theta_{Y};;#murad", 36, 0., 36.); + h_zPos = booker.book1D("Zpos", "Alignment fit #DeltaZ;;#mum", 36, 0., 36.); + h_zRot = booker.book1D("Zrot", "Alignment fit #Delta#theta_{Z};;#murad", 36, 0., 36.); booker.cd(); } @@ -211,37 +211,35 @@ ::fillExpertHisto(MonitorElement* histo, histo_0->SetMinimum(-(max_)); histo_0->SetMaximum( max_); - // first 6 bins for movements + // Schematics of the bin contents + // + // XX XX XX XX XX XX OO OO OO OO II II II II + // |--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--| + // | 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|17| ... + // + // |-----------------| |-----------| |-----------| + // |observed movement| |thresholds1| |thresholds2| for (size_t i = 0; i < obs.size(); ++i) { + + // fist obs.size() bins for observed movements histo_0->SetBinContent(i+1, obs[i]); histo_0->SetBinError(i+1, obsErr[i]); + + // then at bin 8,8+5,8+10,... for cutoffs + // 5 bins is the space allocated for the 4 other thresholds + 1 empty separation bin + histo_0->SetBinContent(8+i*5 , cut[i]); + + // then at bin 9,9+5,9+10,... for significances + histo_0->SetBinContent(9+i*5 , sigCut[i]); + + // then at bin 10,10+5,10+10,... for maximum movements + histo_0->SetBinContent(10+i*5, maxMoveCut[i]); + + // then at bin 11,11+5,11+10,... for maximum errors + histo_0->SetBinContent(11+i*5, maxErrorCut[i]); + } - - // next 6 bins for cutoffs - - for (size_t i = obs.size(); i < obs.size()*2; ++i) { - histo_0->SetBinContent(i+1, cut[i-obs.size()]); - } - - // next 6 bins for significances - - for (size_t i = obs.size()*2; i < obs.size()*3; ++i) { - histo_0->SetBinContent(i+1, sigCut[i-obs.size()*2]); - } - - // next 6 bins for maximum movements - - for (size_t i = obs.size()*3; i < obs.size()*4; ++i) { - histo_0->SetBinContent(i+1, maxMoveCut[i-obs.size()*3]); - } - - // final 6 bins for maximum errors - - for (size_t i = obs.size()*4; i < obs.size()*5; ++i) { - histo_0->SetBinContent(i+1, maxErrorCut[i-obs.size()*4]); - } - } bool MillePedeDQMModule