diff --git a/CalibTracker/SiStripCommon/interface/TkDetMap.h b/CalibTracker/SiStripCommon/interface/TkDetMap.h index fa0335078733f..1c21c12a857f2 100644 --- a/CalibTracker/SiStripCommon/interface/TkDetMap.h +++ b/CalibTracker/SiStripCommon/interface/TkDetMap.h @@ -1,5 +1,5 @@ -#ifndef CalibTracker_SiStripCommon_TKHistoMap_h -#define CalibTracker_SiStripCommon_TKHistoMap_h +#ifndef CalibTracker_SiStripCommon_TkDetMap_h +#define CalibTracker_SiStripCommon_TkDetMap_h #include #include "DataFormats/SiStripDetId/interface/SiStripDetId.h" diff --git a/CalibTracker/SiStripLorentzAngle/plugins/SiStripLorentzAnglePCLHarvester.cc b/CalibTracker/SiStripLorentzAngle/plugins/SiStripLorentzAnglePCLHarvester.cc index 36dd0357bc864..148db5be79083 100644 --- a/CalibTracker/SiStripLorentzAngle/plugins/SiStripLorentzAnglePCLHarvester.cc +++ b/CalibTracker/SiStripLorentzAngle/plugins/SiStripLorentzAnglePCLHarvester.cc @@ -24,10 +24,12 @@ // user includes #include "CalibTracker/Records/interface/SiStripDependentRecords.h" +#include "CalibTracker/SiStripCommon/interface/TkDetMap.h" #include "CalibTracker/SiStripLorentzAngle/interface/SiStripLorentzAngleCalibrationHelpers.h" #include "CalibTracker/SiStripLorentzAngle/interface/SiStripLorentzAngleCalibrationStruct.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" #include "CondFormats/SiStripObjects/interface/SiStripLorentzAngle.h" +#include "DQM/SiStripCommon/interface/TkHistoMap.h" #include "DQMServices/Core/interface/DQMEDHarvester.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -59,6 +61,8 @@ class SiStripLorentzAnglePCLHarvester : public DQMEDHarvester { // es tokens const edm::ESGetToken geomEsToken_; const edm::ESGetToken topoEsTokenBR_, topoEsTokenER_; + const edm::ESGetToken tkDetMapTokenER_; + const edm::ESGetToken latencyToken_; const edm::ESGetToken siStripLAEsToken_; const edm::ESGetToken magneticFieldToken_; @@ -81,6 +85,32 @@ class SiStripLorentzAnglePCLHarvester : public DQMEDHarvester { const SiStripLorentzAngle* currentLorentzAngle_; std::unique_ptr theTrackerTopology_; + std::unique_ptr tkDetMap_; + + // ancillary struct to store the input / output LA + struct LATkMap { + LATkMap() : hInputLA(nullptr), hOutputLA(nullptr) {} + LATkMap(std::unique_ptr&& input, std::unique_ptr&& output) + : hInputLA(std::move(input)), hOutputLA(std::move(output)) {} + + void fill(uint32_t id, float inputLA, float outputLA) { + hInputLA->fill(id, inputLA); + hOutputLA->fill(id, outputLA); + } + + void beautify() { + const auto& allInputMaps = hInputLA->getAllMaps(); + // set colz + for (size_t i = 1; i < allInputMaps.size(); i++) { + hInputLA->getMap(i)->setOption("colz"); + hOutputLA->getMap(i)->setOption("colz"); + } + } + + std::unique_ptr hInputLA, hOutputLA; + }; + + LATkMap h_modulesLA; }; //------------------------------------------------------------------------------ @@ -88,6 +118,7 @@ SiStripLorentzAnglePCLHarvester::SiStripLorentzAnglePCLHarvester(const edm::Para : geomEsToken_(esConsumes()), topoEsTokenBR_(esConsumes()), topoEsTokenER_(esConsumes()), + tkDetMapTokenER_(esConsumes()), latencyToken_(esConsumes()), siStripLAEsToken_(esConsumes()), magneticFieldToken_(esConsumes()), @@ -165,6 +196,9 @@ void SiStripLorentzAnglePCLHarvester::endRun(edm::Run const& run, edm::EventSetu if (!theTrackerTopology_) { theTrackerTopology_ = std::make_unique(isetup.getData(topoEsTokenER_)); } + if (!tkDetMap_) { + tkDetMap_ = std::make_unique(isetup.getData(tkDetMapTokenER_)); + } } //------------------------------------------------------------------------------ @@ -383,15 +417,19 @@ void SiStripLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS treatedIndices.emplace_back(index2D); // Check if the delta is different from zero - // if none of the locations has a non-zero diff + // and if the output LA is not zero (during B=0T running) + // If none of the locations has a non-zero diff // will not write out the payload. - if (deltaMuHoverMuH != 0.f) { + if (deltaMuHoverMuH != 0.f && outputLA != 0.f) { isPayloadChanged = true; LogDebug("SiStripLorentzAnglePCLHarvester") << "accepted " << loc.first << " : " << loc.second << " bin (" << index2D.first << "," << index2D.second << ") " << deltaMuHoverMuH; + } else { + edm::LogWarning("SiStripLorentzAnglePCLHarvester") + << "Discarded " << loc.first << " : " << loc.second << " bin (" << index2D.first << "," << index2D.second + << ") | delta muH/muH = " << deltaMuHoverMuH << " [1/T], output muH = " << outputLA << " [1/T]"; } - } // if the index has not been treated already } else { throw cms::Exception("SiStripLorentzAnglePCLHarvester") @@ -399,6 +437,23 @@ void SiStripLorentzAnglePCLHarvester::dqmEndJob(DQMStore::IBooker& iBooker, DQMS } // } // ends loop on location types + // book the TkDetMaps + const auto tkDetMapFolderIn = (fmt::format("{}Harvesting/TkDetMaps_LAInput", dqmDir_)); + const auto tkDetMapFolderOut = (fmt::format("{}Harvesting/TkDetMaps_LAOutput", dqmDir_)); + h_modulesLA = LATkMap( + std::make_unique(tkDetMap_.get(), iBooker, tkDetMapFolderIn, "inputLorentzAngle", 0, false, true), + std::make_unique(tkDetMap_.get(), iBooker, tkDetMapFolderOut, "outputLorentzAngle", 0, false, true)); + + // fill the TkDetMaps + for (const auto& loc : iHists_.moduleLocationType_) { + const auto& outputLA = OutLorentzAngle->getLorentzAngle(loc.first); + const auto& inputLA = currentLorentzAngle_->getLorentzAngle(loc.first); + h_modulesLA.fill(loc.first, inputLA, outputLA); + } + + // set colz to the output maps + h_modulesLA.beautify(); + if (isPayloadChanged) { // fill the DB object record edm::Service mydbservice;