From d489fa6b7fecd4782c25b74e06cf1be546200eb3 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 26 Nov 2018 12:58:50 +0100 Subject: [PATCH 01/30] Introduce SiPixelFEDChannelContainer and SiPixelQualityProbabilities CondFormats in view of using them in stuckTBM simulation --- CondCore/SiPixelPlugins/src/plugin.cc | 6 + CondCore/Utilities/plugins/Module_2XML.cc | 2 + CondCore/Utilities/src/CondDBFetch.cc | 2 + CondCore/Utilities/src/CondDBImport.cc | 2 + CondCore/Utilities/src/CondFormats.h | 2 + .../SiPixelStatusScenarioProbabilityRcd.h | 19 ++ .../interface/SiPixelStatusScenariosRcd.h | 19 ++ .../SiPixelStatusScenarioProbabilityRcd.cc | 13 + .../src/SiPixelStatusScenariosRcd.cc | 13 + .../External/interface/PixelFEDChannel.h | 69 ++++++ .../test/testSerializationExternal.cpp | 2 + .../interface/SiPixelFEDChannelContainer.h | 45 ++++ .../interface/SiPixelQualityProbabilities.h | 39 +++ .../src/SiPixelFEDChannelContainer.cc | 78 ++++++ .../src/SiPixelQualityProbabilities.cc | 52 ++++ ...T_EventSetup_SiPixelFEDChannelContainer.cc | 7 + ..._EventSetup_SiPixelQualityProbabilities.cc | 5 + CondFormats/SiPixelObjects/src/classes.h | 6 + .../SiPixelObjects/src/classes_def.xml | 7 + CondFormats/SiPixelObjects/src/headers.h | 3 + .../SiPixelFEDChannelContainerTestReader.cc | 110 +++++++++ ...iPixelFEDChannelContainerTestReader_cfg.py | 62 +++++ .../SiPixelFEDChannelContainerTestWriter.cc | 228 ++++++++++++++++++ ...iPixelFEDChannelContainerTestWriter_cfg.py | 69 ++++++ ...iPixelFEDChannelContainerWriteFromASCII.cc | 170 +++++++++++++ ...elFEDChannelContainerWriteFromASCII_cfg.py | 70 ++++++ .../SiPixelQualityProbabilitiesTestReader.cc | 103 ++++++++ ...PixelQualityProbabilitiesTestReader_cfg.py | 62 +++++ .../SiPixelQualityProbabilitiesTestWriter.cc | 167 +++++++++++++ ...PixelQualityProbabilitiesTestWriter_cfg.py | 60 +++++ .../test/testSerializationSiPixelObjects.cpp | 4 + 31 files changed, 1496 insertions(+) create mode 100644 CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h create mode 100644 CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h create mode 100644 CondFormats/DataRecord/src/SiPixelStatusScenarioProbabilityRcd.cc create mode 100644 CondFormats/DataRecord/src/SiPixelStatusScenariosRcd.cc create mode 100644 CondFormats/External/interface/PixelFEDChannel.h create mode 100644 CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h create mode 100644 CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h create mode 100644 CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc create mode 100644 CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc create mode 100644 CondFormats/SiPixelObjects/src/T_EventSetup_SiPixelFEDChannelContainer.cc create mode 100644 CondFormats/SiPixelObjects/src/T_EventSetup_SiPixelQualityProbabilities.cc create mode 100644 CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader.cc create mode 100644 CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader_cfg.py create mode 100644 CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter.cc create mode 100644 CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter_cfg.py create mode 100644 CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerWriteFromASCII.cc create mode 100644 CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerWriteFromASCII_cfg.py create mode 100644 CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader.cc create mode 100644 CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader_cfg.py create mode 100644 CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestWriter.cc create mode 100644 CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestWriter_cfg.py diff --git a/CondCore/SiPixelPlugins/src/plugin.cc b/CondCore/SiPixelPlugins/src/plugin.cc index ec115267b7c92..338ac89920939 100644 --- a/CondCore/SiPixelPlugins/src/plugin.cc +++ b/CondCore/SiPixelPlugins/src/plugin.cc @@ -19,6 +19,10 @@ #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" #include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h" #include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" +#include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h" +#include "CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h" #include "CondFormats/SiPixelObjects/interface/SiPixelCPEGenericErrorParm.h" #include "CondFormats/DataRecord/interface/SiPixelCPEGenericErrorParmRcd.h" @@ -61,6 +65,8 @@ REGISTER_PLUGIN(SiPixelDynamicInefficiencyRcd,SiPixelDynamicInefficiency); REGISTER_PLUGIN(SiPixelCalibConfigurationRcd,SiPixelCalibConfiguration); REGISTER_PLUGIN(SiPixelPerformanceSummaryRcd,SiPixelPerformanceSummary); REGISTER_PLUGIN(SiPixelQualityFromDbRcd,SiPixelQuality); +REGISTER_PLUGIN(SiPixelStatusScenariosRcd,SiPixelFEDChannelContainer); +REGISTER_PLUGIN(SiPixelStatusScenarioProbabilityRcd,SiPixelQualityProbabilities); REGISTER_PLUGIN(SiPixelCPEGenericErrorParmRcd,SiPixelCPEGenericErrorParm); REGISTER_PLUGIN(SiPixelTemplateDBObjectRcd,SiPixelTemplateDBObject); REGISTER_PLUGIN(SiPixelTemplateDBObject38TRcd,SiPixelTemplateDBObject); diff --git a/CondCore/Utilities/plugins/Module_2XML.cc b/CondCore/Utilities/plugins/Module_2XML.cc index 1dc07f23ad0bd..a9de48b269022 100644 --- a/CondCore/Utilities/plugins/Module_2XML.cc +++ b/CondCore/Utilities/plugins/Module_2XML.cc @@ -245,6 +245,8 @@ PAYLOAD_2XML_MODULE( pluginUtilities_payload2xml ){ PAYLOAD_2XML_CLASS( SiPixelGenErrorDBObject ); PAYLOAD_2XML_CLASS( SiPixelLorentzAngle ); PAYLOAD_2XML_CLASS( SiPixelQuality ); + PAYLOAD_2XML_CLASS( SiPixelFEDChannelContainer ); + PAYLOAD_2XML_CLASS( SiPixelQualityProbabilities ); PAYLOAD_2XML_CLASS( SiPixelTemplateDBObject ); PAYLOAD_2XML_CLASS( SiStripApvGain ); PAYLOAD_2XML_CLASS( SiStripBackPlaneCorrection ); diff --git a/CondCore/Utilities/src/CondDBFetch.cc b/CondCore/Utilities/src/CondDBFetch.cc index ae5589f9af04b..30ee6e1ffd280 100644 --- a/CondCore/Utilities/src/CondDBFetch.cc +++ b/CondCore/Utilities/src/CondDBFetch.cc @@ -276,6 +276,8 @@ namespace cond { FETCH_PAYLOAD_CASE( SiPixelLorentzAngle ) FETCH_PAYLOAD_CASE( SiPixelDynamicInefficiency ) FETCH_PAYLOAD_CASE( SiPixelQuality ) + FETCH_PAYLOAD_CASE( SiPixelFEDChannelContainer ) + FETCH_PAYLOAD_CASE( SiPixelQualityProbabilities ) FETCH_PAYLOAD_CASE( SiPixelTemplateDBObject ) FETCH_PAYLOAD_CASE( SiPixel2DTemplateDBObject ) FETCH_PAYLOAD_CASE( SiStripApvGain ) diff --git a/CondCore/Utilities/src/CondDBImport.cc b/CondCore/Utilities/src/CondDBImport.cc index 4d9a91ab575e6..eb6f2ec56d0bf 100644 --- a/CondCore/Utilities/src/CondDBImport.cc +++ b/CondCore/Utilities/src/CondDBImport.cc @@ -296,6 +296,8 @@ namespace cond { IMPORT_PAYLOAD_CASE( SiPixelLorentzAngle ) IMPORT_PAYLOAD_CASE( SiPixelDynamicInefficiency ) IMPORT_PAYLOAD_CASE( SiPixelQuality ) + IMPORT_PAYLOAD_CASE( SiPixelFEDChannelContainer ) + IMPORT_PAYLOAD_CASE( SiPixelQualityProbabilities ) IMPORT_PAYLOAD_CASE( SiPixelTemplateDBObject ) IMPORT_PAYLOAD_CASE( SiPixel2DTemplateDBObject ) IMPORT_PAYLOAD_CASE( SiStripApvGain ) diff --git a/CondCore/Utilities/src/CondFormats.h b/CondCore/Utilities/src/CondFormats.h index 413d3f4fd731d..ccac5e19c7389 100644 --- a/CondCore/Utilities/src/CondFormats.h +++ b/CondCore/Utilities/src/CondFormats.h @@ -138,6 +138,8 @@ #include "CondFormats/SiPixelObjects/interface/SiPixelLorentzAngle.h" #include "CondFormats/SiPixelObjects/interface/SiPixelDynamicInefficiency.h" #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h" #include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h" #include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h" #include "CondFormats/SiPixelObjects/interface/SiPixelGenErrorDBObject.h" diff --git a/CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h b/CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h new file mode 100644 index 0000000000000..62114a993a971 --- /dev/null +++ b/CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h @@ -0,0 +1,19 @@ +#ifndef SiPixelStatusScenarioProbabilityRcd_SiPixelStatusScenarioProbabilityRcd_h +#define SiPixelStatusScenarioProbabilityRcd_SiPixelStatusScenarioProbabilityRcd_h +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : SiPixelStatusScenarioProbabilityRcd +// +/**\class SiPixelStatusScenarioProbabilityRcd SiPixelStatusScenarioProbabilityRcd.h CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h + Description: [one line class summary] + Usage: + +*/ +// +// Author: Marco Musich +// Created: Wed, 30 Nov 2018 11:44:30 GMT +// +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" +class SiPixelStatusScenarioProbabilityRcd : public edm::eventsetup::EventSetupRecordImplementation {}; +#endif diff --git a/CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h b/CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h new file mode 100644 index 0000000000000..4c59ddaaaebed --- /dev/null +++ b/CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h @@ -0,0 +1,19 @@ +#ifndef SiPixelStatusScenariosRcd_SiPixelStatusScenariosRcd_h +#define SiPixelStatusScenariosRcd_SiPixelStatusScenariosRcd_h +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : SiPixelStatusScenariosRcd +// +/**\class SiPixelStatusScenariosRcd SiPixelStatusScenariosRcd.h CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h + Description: [one line class summary] + Usage: + +*/ +// +// Author: Marco Musich +// Created: Wed, 28 Nov 2018 10:31:30 GMT +// +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" +class SiPixelStatusScenariosRcd : public edm::eventsetup::EventSetupRecordImplementation {}; +#endif diff --git a/CondFormats/DataRecord/src/SiPixelStatusScenarioProbabilityRcd.cc b/CondFormats/DataRecord/src/SiPixelStatusScenarioProbabilityRcd.cc new file mode 100644 index 0000000000000..875b13c09e826 --- /dev/null +++ b/CondFormats/DataRecord/src/SiPixelStatusScenarioProbabilityRcd.cc @@ -0,0 +1,13 @@ +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : SiPixelStatusScenarioProbabilityRcd +// +// Implementation: +// [Notes on implementation] +// +// Author: Marco Musich +// Created: Wed, 22 Feb 2017 10:31:30 GMT +#include "CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" +EVENTSETUP_RECORD_REG(SiPixelStatusScenarioProbabilityRcd); diff --git a/CondFormats/DataRecord/src/SiPixelStatusScenariosRcd.cc b/CondFormats/DataRecord/src/SiPixelStatusScenariosRcd.cc new file mode 100644 index 0000000000000..72441c447d201 --- /dev/null +++ b/CondFormats/DataRecord/src/SiPixelStatusScenariosRcd.cc @@ -0,0 +1,13 @@ +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : SiPixelStatusScenariosRcd +// +// Implementation: +// [Notes on implementation] +// +// Author: Marco Musich +// Created: Wed, 22 Feb 2017 10:31:30 GMT +#include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" +EVENTSETUP_RECORD_REG(SiPixelStatusScenariosRcd); diff --git a/CondFormats/External/interface/PixelFEDChannel.h b/CondFormats/External/interface/PixelFEDChannel.h new file mode 100644 index 0000000000000..ec84227b97611 --- /dev/null +++ b/CondFormats/External/interface/PixelFEDChannel.h @@ -0,0 +1,69 @@ +#ifndef CondFormats_External_PIXELFEDCHANNEL_H +#define CondFormats_External_PIXELFEDCHANNEL_H + +#include +#include +#include + +#include +#include +#include + +#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" + +// struct PixelFEDChannel { +// unsigned int fed, link, roc_first, roc_last; +// }; + +namespace boost { + namespace serialization { + + /* + * Note regarding object tracking: all autos used here + * must resolve to untracked types, since we use local + * variables in the stack which could end up with the same + * address. For the moment, all types resolved by auto here + * are primitive types, which are untracked by default + * by Boost Serialization. + */ + + template + void save(Archive & ar, const PixelFEDChannel & obj, const unsigned int) + { + auto fed = obj.fed; + auto link = obj.link; + auto roc_first = obj.roc_first; + auto roc_last = obj.roc_last; + ar & boost::serialization::make_nvp("fed_" , fed ); + ar & boost::serialization::make_nvp("link_" , link ); + ar & boost::serialization::make_nvp("roc_first_" , roc_first ); + ar & boost::serialization::make_nvp("roc_last_" , roc_last ); + } + + template + void load(Archive & ar, PixelFEDChannel & obj, const unsigned int) + { + unsigned int fed_; + unsigned int link_; + unsigned int roc_first_; + unsigned int roc_last_; + + ar & boost::serialization::make_nvp("fed_" , fed_ ); + ar & boost::serialization::make_nvp("link_" , link_ ); + ar & boost::serialization::make_nvp("roc_first_" , roc_first_ ); + ar & boost::serialization::make_nvp("roc_last_" , roc_last_ ); + PixelFEDChannel tmp{fed_, link_, roc_first_, roc_last_}; + obj = tmp; + + } + + template + void serialize(Archive & ar, PixelFEDChannel & obj, const unsigned int v) + { + split_free(ar, obj, v); + } + + } // namespace serialization +} // namespace boost + +#endif diff --git a/CondFormats/External/test/testSerializationExternal.cpp b/CondFormats/External/test/testSerializationExternal.cpp index b56f3f88a6863..4cf38d6f77d8b 100644 --- a/CondFormats/External/test/testSerializationExternal.cpp +++ b/CondFormats/External/test/testSerializationExternal.cpp @@ -7,6 +7,7 @@ #include "CondFormats/External/interface/L1GtLogicParser.h" #include "CondFormats/External/interface/SMatrix.h" #include "CondFormats/External/interface/Timestamp.h" +#include "CondFormats/External/interface/PixelFEDChannel.h" int main() { @@ -19,6 +20,7 @@ int main() testSerialization(); testSerialization(); testSerialization>(); + testSerialization(); return 0; } diff --git a/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h b/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h new file mode 100644 index 0000000000000..037dec9ff73e3 --- /dev/null +++ b/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h @@ -0,0 +1,45 @@ +#ifndef CondFormats_SiPixelObjects_SiPixelFEDChannelContainer_h +#define CondFormats_SiPixelObjects_SiPixelFEDChannelContainer_h + +#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" +#include "CondFormats/Serialization/interface/Serializable.h" +#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" // N.B. a DataFormat is serialized here (need for dedicated serialization rules, see CondFormats/External/interface/PixelFEDChannel.h) + +#include +#include +#include + +class SiPixelFEDChannelContainer{ +public: + typedef std::map > SiPixelFEDChannelCollection; + typedef std::unordered_map SiPixelBadFEDChannelsScenarioMap; + + SiPixelFEDChannelContainer(){} + virtual ~SiPixelFEDChannelContainer(){} + + void setScenario(const std::string &theScenarioId, const SiPixelFEDChannelCollection &theBadFEDChannels); + void setScenario(const std::string &theScenarioId, const SiPixelQuality &theSiPixelQuality, const SiPixelFedCablingMap& theFedCabling); + + const SiPixelBadFEDChannelsScenarioMap& getScenarioMap () const {return m_scenarioMap;} + + SiPixelFEDChannelCollection getSiPixelBadFedChannels(const std::string &ScenarioId) const; + SiPixelFEDChannelCollection & getSiPixelBadFedChannels(const std::string &ScenarioId); + + std::vector& getSiPixelBadFedChannelsInDetId(const std::string &theScenarioId,DetId theDetId); + + std::unique_ptr getDetSetBadPixelFedChannels(const std::string &ScenarioId) const; + + double size()const {return m_scenarioMap.size();} + std::vector getScenarioList() const; + + void printAll() const; + +private: + + SiPixelBadFEDChannelsScenarioMap m_scenarioMap; + + COND_SERIALIZABLE; + +}; + +#endif diff --git a/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h b/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h new file mode 100644 index 0000000000000..8da2c6bbc608b --- /dev/null +++ b/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h @@ -0,0 +1,39 @@ +#ifndef CondFormats_SiPixelObjects_SiPixelQualityProbabilities_h +#define CondFormats_SiPixelObjects_SiPixelQualityProbabilities_h + +#include "CondFormats/Serialization/interface/Serializable.h" + +#include +#include +#include + +class SiPixelQualityProbabilities{ +public: + typedef std::vector > probabilityVec; + typedef std::map probabilityMap; + + SiPixelQualityProbabilities(){} + virtual ~SiPixelQualityProbabilities(){} + + void setProbabilities(const unsigned int &puBin, const probabilityVec &theProbabilities); + + const probabilityMap& getProbability_Map () const {return m_probabilities;} + + probabilityVec getProbabilities(const unsigned int &puBin) const; + probabilityVec & getProbabilities(const unsigned int &puBin); + + double size()const {return m_probabilities.size();} + double nelements(const int &puBin)const {return m_probabilities.at(puBin).size();} + std::vector getPileUpBins() const; + + void printAll() const; + +private: + + probabilityMap m_probabilities; + + COND_SERIALIZABLE; + +}; + +#endif diff --git a/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc b/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc new file mode 100644 index 0000000000000..04fc86e89af7d --- /dev/null +++ b/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc @@ -0,0 +1,78 @@ +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" +#include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include +#include // std::setw + +void SiPixelFEDChannelContainer::setScenario(const std::string &theScenarioId, const SiPixelFEDChannelCollection &theBadFEDChannels) { + m_scenarioMap.emplace(theScenarioId,theBadFEDChannels); +} + +//****************************************************************************// +SiPixelFEDChannelContainer::SiPixelFEDChannelCollection SiPixelFEDChannelContainer::getSiPixelBadFedChannels(const std::string &theScenarioId) const { + SiPixelBadFEDChannelsScenarioMap::const_iterator it = m_scenarioMap.find(theScenarioId); + + if (it != m_scenarioMap.end()){ + return it->second; + } else { + throw cms::Exception("SiPixelFEDChannelContainer")<< "No Bad Pixel FEDChannels defined for Scenario id: " << theScenarioId << "\n"; + } +} + +//****************************************************************************// +SiPixelFEDChannelContainer::SiPixelFEDChannelCollection& SiPixelFEDChannelContainer::getSiPixelBadFedChannels(const std::string &theScenarioId) { + return m_scenarioMap[theScenarioId]; +} + +//****************************************************************************// +std::vector& SiPixelFEDChannelContainer::getSiPixelBadFedChannelsInDetId(const std::string &theScenarioId,DetId theDetId) { + return (m_scenarioMap[theScenarioId])[theDetId]; +} + + +//****************************************************************************// +std::unique_ptr SiPixelFEDChannelContainer::getDetSetBadPixelFedChannels(const std::string &theScenarioId) const { + + std::unique_ptr disabled_channelcollection = std::make_unique >(); + auto SiPixelBadFedChannels = m_scenarioMap.at(theScenarioId); + for(const auto &entry : SiPixelBadFedChannels){ + disabled_channelcollection->insert(entry.first, entry.second.data(), entry.second.size()); + } + return disabled_channelcollection; +} + + +//****************************************************************************// +void SiPixelFEDChannelContainer::printAll() const { + + edm::LogVerbatim("SiPixelFEDChannelContainer")<<"SiPixelFEDChannelContainer::printAll()"; + edm::LogVerbatim("SiPixelFEDChannelContainer")<<" ==================================================================================================================="; + for(auto it = m_scenarioMap.begin(); it != m_scenarioMap.end() ; ++it){ + edm::LogVerbatim("SiPixelFEDChannelContainer")<< "run :"<< it->first << " \n "; + for (const auto& thePixelFEDChannel : it->second){ + + DetId detId = thePixelFEDChannel.first; + + edm::LogVerbatim("SiPixelFEDChannelContainer")<< "DetId :"<< detId << " \n "; + + for(const auto& entry: thePixelFEDChannel.second) { + //unsigned int fed, link, roc_first, roc_last; + edm::LogVerbatim("SiPixelFEDChannelContainer")<< " fed : "<< entry.fed + << " link : "<< entry.link + << " roc_first : "<< entry.roc_first + << " roc_last: : "<< entry.roc_last; + } + } + } +} + +//****************************************************************************// +std::vector SiPixelFEDChannelContainer::getScenarioList() const { + std::vector scenarios; + scenarios.reserve(m_scenarioMap.size()); + + for(auto it = m_scenarioMap.begin(); it != m_scenarioMap.end() ; ++it){ + scenarios.push_back(it->first); + } + return scenarios; +} diff --git a/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc b/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc new file mode 100644 index 0000000000000..e0b8bd26ae471 --- /dev/null +++ b/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc @@ -0,0 +1,52 @@ +#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h" +#include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include +#include // std::setw + +//****************************************************************************// +void SiPixelQualityProbabilities::setProbabilities(const unsigned int &puBin, const probabilityVec &theProbabilities) { + m_probabilities[puBin]=theProbabilities; +} + +//****************************************************************************// +SiPixelQualityProbabilities::probabilityVec SiPixelQualityProbabilities::getProbabilities(const unsigned int &puBin) const { + probabilityMap::const_iterator it = m_probabilities.find(puBin); + + if (it != m_probabilities.end()){ + return it->second; + } else { + throw cms::Exception("SiPixelQualityProbabilities")<< "No Probabilities are defined for PU bin " << puBin << "\n"; + } +} + +//****************************************************************************// +SiPixelQualityProbabilities::probabilityVec& SiPixelQualityProbabilities::getProbabilities(const unsigned int &puBin) { + return m_probabilities[puBin]; +} + + +//****************************************************************************// +void SiPixelQualityProbabilities::printAll() const { + + edm::LogVerbatim("SiPixelQualityProbabilities")<<"SiPixelQualityProbabilities::printAll()"; + edm::LogVerbatim("SiPixelQualityProbabilities")<<" ==================================================================================================================="; + for(auto it = m_probabilities.begin(); it != m_probabilities.end() ; ++it){ + edm::LogVerbatim("SiPixelQualityProbabilities")<< "PU :"<< it->first << " \n "; + for (const auto &entry : it->second){ + edm::LogVerbatim("SiPixelQualityProbabilities")<<"SiPixelQuality snapshot: " << entry.first << " |probability: " << entry.second << std::endl; + } + } + +} + +//****************************************************************************// +std::vector SiPixelQualityProbabilities::getPileUpBins() const { + std::vector bins; + bins.reserve(m_probabilities.size()); + + for(auto it = m_probabilities.begin(); it != m_probabilities.end() ; ++it){ + bins.push_back(it->first); + } + return bins; +} diff --git a/CondFormats/SiPixelObjects/src/T_EventSetup_SiPixelFEDChannelContainer.cc b/CondFormats/SiPixelObjects/src/T_EventSetup_SiPixelFEDChannelContainer.cc new file mode 100644 index 0000000000000..7a958accacd71 --- /dev/null +++ b/CondFormats/SiPixelObjects/src/T_EventSetup_SiPixelFEDChannelContainer.cc @@ -0,0 +1,7 @@ +// system include files + +// user include files +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(SiPixelFEDChannelContainer); diff --git a/CondFormats/SiPixelObjects/src/T_EventSetup_SiPixelQualityProbabilities.cc b/CondFormats/SiPixelObjects/src/T_EventSetup_SiPixelQualityProbabilities.cc new file mode 100644 index 0000000000000..30437db9e146f --- /dev/null +++ b/CondFormats/SiPixelObjects/src/T_EventSetup_SiPixelQualityProbabilities.cc @@ -0,0 +1,5 @@ +// system include files +// user include files +#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h" +#include "FWCore/Utilities/interface/typelookup.h" +TYPELOOKUP_DATA_REG(SiPixelQualityProbabilities); diff --git a/CondFormats/SiPixelObjects/src/classes.h b/CondFormats/SiPixelObjects/src/classes.h index 2b4e64b14ccfe..006eacf2c6ec0 100644 --- a/CondFormats/SiPixelObjects/src/classes.h +++ b/CondFormats/SiPixelObjects/src/classes.h @@ -15,6 +15,8 @@ #include "CondFormats/SiPixelObjects/interface/SiPixelPerformanceSummary.h" #include "CondFormats/SiPixelObjects/interface/SiPixelCalibConfiguration.h" #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" #include "CondFormats/SiPixelObjects/interface/PixelDCSObject.h" template struct PixelDCSObject; @@ -45,6 +47,10 @@ namespace CondFormats_SiPixelObjects { std::vector::iterator p9; std::vector::const_iterator p10; std::vector p11; + + std::map myProbabilityMap; + std::map myPixelFEDChannelCollection; + }; } diff --git a/CondFormats/SiPixelObjects/src/classes_def.xml b/CondFormats/SiPixelObjects/src/classes_def.xml index 83b85d209955f..50b75f035a0aa 100644 --- a/CondFormats/SiPixelObjects/src/classes_def.xml +++ b/CondFormats/SiPixelObjects/src/classes_def.xml @@ -67,6 +67,13 @@ + + + + + + + diff --git a/CondFormats/SiPixelObjects/src/headers.h b/CondFormats/SiPixelObjects/src/headers.h index ce8cc1a84704e..034eb6df5885b 100644 --- a/CondFormats/SiPixelObjects/src/headers.h +++ b/CondFormats/SiPixelObjects/src/headers.h @@ -16,7 +16,10 @@ #include "CondFormats/SiPixelObjects/interface/SiPixelPerformanceSummary.h" #include "CondFormats/SiPixelObjects/interface/SiPixelCalibConfiguration.h" #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" #include "CondFormats/SiPixelObjects/interface/PixelDCSObject.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h" #include "CondFormats/External/interface/DetID.h" +#include "CondFormats/External/interface/PixelFEDChannel.h" diff --git a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader.cc b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader.cc new file mode 100644 index 0000000000000..a07eae336e742 --- /dev/null +++ b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader.cc @@ -0,0 +1,110 @@ +#include +#include +#include +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" +#include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h" +#include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h" + +class SiPixelFEDChannelContainerTestReader : public edm::one::EDAnalyzer<> { +public: + explicit SiPixelFEDChannelContainerTestReader(edm::ParameterSet const& p); + ~SiPixelFEDChannelContainerTestReader(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + + virtual void analyze(const edm::Event& e, const edm::EventSetup& c) override; + + // ----------member data --------------------------- + const bool printdebug_; + const std::string formatedOutput_; + +}; + +SiPixelFEDChannelContainerTestReader::SiPixelFEDChannelContainerTestReader(edm::ParameterSet const& p): + printdebug_(p.getUntrackedParameter("printDebug",true)), + formatedOutput_(p.getUntrackedParameter("outputFile","")) +{ + edm::LogInfo("SiPixelFEDChannelContainerTestReader")<<"SiPixelFEDChannelContainerTestReader"< qualityCollectionHandle; + edm::LogInfo("SiPixelFEDChannelContainerTestReader") <<"got eshandle"<().get(qualityCollectionHandle); + edm::LogInfo("SiPixelFEDChannelContainerTestReader") <<"got context"<size() << std::endl; + edm::LogInfo("SiPixelFEDChannelContainerTestReader") <<"Content of myQuality_Map "<printAll(); + } + + FILE* pFile=NULL; + if(formatedOutput_!="")pFile=fopen(formatedOutput_.c_str(), "w"); + if(pFile){ + + fprintf(pFile,"SiPixelFEDChannelContainer::printAll() \n"); + fprintf(pFile," =================================================================================================================== \n"); + + SiPixelFEDChannelContainer::SiPixelBadFEDChannelsScenarioMap m_qualities = quality_map-> getScenarioMap(); + + for(auto it = m_qualities.begin(); it != m_qualities.end() ; ++it){ + fprintf(pFile," =================================================================================================================== \n"); + fprintf(pFile,"run : %s \n ",(it->first).c_str()); + for (const auto& thePixelFEDChannel : it->second){ + DetId detId = thePixelFEDChannel.first; + fprintf(pFile,"DetId : %i \n",detId.rawId()); + for(const auto& entry: thePixelFEDChannel.second) { + //unsigned int fed, link, roc_first, roc_last; + fprintf(pFile,"fed : %i | link : %i | roc_first : %i | roc_last: %i: \n",entry.fed, entry.link, entry.roc_first, entry.roc_last); + } + } + } + } +} + +void +SiPixelFEDChannelContainerTestReader::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment("Reads payloads of type SiPixelFEDChannelContainer"); + desc.addUntracked("printDebug",true); + desc.addUntracked("outputFile",""); + descriptions.add("SiPixelFEDChannelContainerTestReader",desc); +} + +DEFINE_FWK_MODULE(SiPixelFEDChannelContainerTestReader); diff --git a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader_cfg.py b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader_cfg.py new file mode 100644 index 0000000000000..3cb8fa676bf90 --- /dev/null +++ b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader_cfg.py @@ -0,0 +1,62 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("ProcessOne") + +## +## MessageLogger +## +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.categories.append("SiPixelFEDChannelContainerTestReader") +process.MessageLogger.categories.append("SiPixelFEDChannelContainer") +process.MessageLogger.destinations = cms.untracked.vstring("cout") +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string("INFO"), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), + reportEvery = cms.untracked.int32(1000) + ), + SiPixelFEDChannelContainerTestReader = cms.untracked.PSet( limit = cms.untracked.int32(-1)), + SiPixelFEDChannelContainer = cms.untracked.PSet( limit = cms.untracked.int32(-1)) + ) +process.MessageLogger.statistics.append('cout') + +## +## Empty Source +## +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(315708), + lastValue = cms.uint64(315708), + interval = cms.uint64(1) + ) +## +## Get the payload +## +from CondCore.CondDB.CondDB_cfi import * +CondDBQualityCollection = CondDB.clone(connect = cms.string("sqlite_file:SiPixelStatusScenarios_v1.db")) + +process.dbInput = cms.ESSource("PoolDBESSource", + CondDBQualityCollection, + toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenariosRcd'), + tag = cms.string('SiPixelFEDChannelContainer_StuckTBM_2018_v1_mc') # choose tag you want + ) + ) + ) +## +## Retrieve it and check it's available in the ES +## +process.get = cms.EDAnalyzer("EventSetupRecordDataGetter", + toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenariosRcd'), + data = cms.vstring('SiPixelFEDChannelContainer_StuckTBM_2018_v1_mc') + ) + ), + verbose = cms.untracked.bool(True) + ) +## +## Read it back +## +process.ReadDB = cms.EDAnalyzer("SiPixelFEDChannelContainerTestReader") +process.ReadDB.printDebug = cms.untracked.bool(True) +process.ReadDB.outputFile = cms.untracked.string('SiPixelFEDChannelContainer.log') + +process.p = cms.Path(process.get+process.ReadDB) diff --git a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter.cc b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter.cc new file mode 100644 index 0000000000000..b14000b838bae --- /dev/null +++ b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter.cc @@ -0,0 +1,228 @@ +// -*- C++ -*- +// +// Package: CondFormats/SiPixelObjects +// Class: SiPixelFEDChannelContainerTestWriter +// +/**\class SiPixelFEDChannelContainerTestWriter SiPixelFEDChannelContainerTestWriter.cc CondFormats/SiPixelObjects/plugins/SiPixelFEDChannelContainerTestWriter.cc + Description: class to build the SiPixelFEDChannelContainer payloads +*/ +// +// Original Author: Marco Musich +// Created: Wed, 27 Nov 2018 12:04:36 GMT +// +// + +// system include files +#include + +// user include files +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" +#include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h" +#include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h" +#include "CondFormats/SiPixelObjects/interface/CablingPathToDetUnit.h" +#include "CondFormats/SiPixelObjects/interface/PixelROC.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +// +// class declaration +// + +class SiPixelFEDChannelContainerTestWriter : public edm::one::EDAnalyzer<> { + public: + explicit SiPixelFEDChannelContainerTestWriter(const edm::ParameterSet&); + ~SiPixelFEDChannelContainerTestWriter(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + SiPixelFEDChannelContainer::SiPixelFEDChannelCollection createFromSiPixelQuality(const SiPixelQuality & theQuality, const SiPixelFedCablingMap& theFedCabling); + + private: + virtual void beginJob() override; + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override; + + // ----------member data --------------------------- + const std::string m_record; + const bool printdebug_; + SiPixelFEDChannelContainer* myQualities; + + int IOVcount_; + edm::ESWatcher SiPixelQualityWatcher_; + +}; + +// +// constructors and destructor +// +SiPixelFEDChannelContainerTestWriter::SiPixelFEDChannelContainerTestWriter(const edm::ParameterSet& iConfig): + m_record(iConfig.getParameter("record")), + printdebug_(iConfig.getUntrackedParameter("printDebug",false)) +{ + //now do what ever initialization is needed + myQualities = new SiPixelFEDChannelContainer(); +} + + +SiPixelFEDChannelContainerTestWriter::~SiPixelFEDChannelContainerTestWriter() +{ + delete myQualities; +} + +// +// member functions +// + +// ------------ method called for each event ------------ +void +SiPixelFEDChannelContainerTestWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace edm; + + unsigned int RunNumber_= iEvent.eventAuxiliary().run(); + unsigned int LuminosityBlockNumber_ = iEvent.eventAuxiliary().luminosityBlock(); + + bool hasQualityIOV = SiPixelQualityWatcher_.check(iSetup); + + if(hasQualityIOV){ + + //Retrieve the strip quality from conditions + edm::ESHandle siPixelQuality_; + iSetup.get().get(siPixelQuality_); + + edm::ESHandle cablingMapHandle; + iSetup.get().get(cablingMapHandle); + + std::string scenario = std::to_string(RunNumber_)+"_"+std::to_string(LuminosityBlockNumber_); + + edm::LogInfo("SiPixelFEDChannelContainerTestWriter")<<"Found IOV:" << RunNumber_ <<"("<< LuminosityBlockNumber_ <<")"<createFromSiPixelQuality(*(siPixelQuality_.product()),*(cablingMapHandle.product())); + myQualities->setScenario(scenario,theSiPixelFEDChannelCollection); + + IOVcount_++; + + } + + if(printdebug_){ + edm::LogInfo("SiPixelFEDChannelContainerTestWriter")<<"Content of SiPixelFEDChannelContainer "<printAll(); + } +} + +// ------------ method called once each job just before starting event loop ------------ +SiPixelFEDChannelContainer::SiPixelFEDChannelCollection +SiPixelFEDChannelContainerTestWriter::createFromSiPixelQuality(const SiPixelQuality & theQuality, const SiPixelFedCablingMap& theFedCabling) +{ + auto fedid_ = theFedCabling.det2fedMap(); + + SiPixelFEDChannelContainer::SiPixelFEDChannelCollection theBadChannelCollection; + + auto theDisabledModules = theQuality.getBadComponentList(); + for (const auto &mod : theDisabledModules){ + //mod.DetID, mod.errorType,mod.BadRocs + + int coded_badRocs = mod.BadRocs; + std::vector disabledChannelsDetSet; + std::vector path = theFedCabling.pathToDetUnit(mod.DetID); + auto cabling_ = theFedCabling.cablingTree(); + unsigned int nrocs_inLink(0); + if (path.size() != 0){ + const sipixelobjects::PixelFEDCabling * aFed = cabling_->fed(path.at(0).fed); + const sipixelobjects::PixelFEDLink * link = aFed->link(path.at(0).link); + nrocs_inLink = link->numberOfROCs(); + } + + std::bitset<16> bad_rocs(coded_badRocs); + unsigned int n_ch = bad_rocs.size()/nrocs_inLink; + + for (unsigned int i_roc = 0; i_roc < n_ch; ++i_roc){ + + unsigned int first_idx = nrocs_inLink*i_roc; + unsigned int sec_idx = nrocs_inLink*(i_roc+1)-1; + unsigned int mask = pow(2,nrocs_inLink)-1; + unsigned int n_setbits = (coded_badRocs >> (i_roc*nrocs_inLink)) & mask; + + if (n_setbits==0){ + continue; + } + + if(n_setbits != mask){ + edm::LogWarning("SiPixelFEDChannelContainerTestWriter") << "Mismatch! DetId: "<< mod.DetID << " " << n_setbits << " " << mask << std::endl; + continue; + } + + edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << "passed" << std::endl; + unsigned int link_id = 99999; + unsigned int fed_id = 99999; + + for (auto const& p: path){ + //std::cout << p.fed << " " << p.link << " " << p.roc << std::endl; + if (p.roc == bad_rocs[first_idx]){ + link_id = p.link; + fed_id = p.fed; + break; + } + } + + edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << " " << fed_id << " " << link_id << " " << first_idx << " " << sec_idx << std::endl; + + PixelFEDChannel ch = {fed_id, link_id, first_idx, sec_idx}; + disabledChannelsDetSet.push_back(ch); + edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << i_roc << " " << coded_badRocs << " " << first_idx << " " << sec_idx << std::endl; + edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << "=======================================" << std::endl; + } + + if (!disabledChannelsDetSet.empty()) { + theBadChannelCollection[mod.DetID] = disabledChannelsDetSet; + } + } + return theBadChannelCollection; +} + +void +SiPixelFEDChannelContainerTestWriter::beginJob() +{ + IOVcount_=0; +} + +// ------------ method called once each job just after ending the event loop ------------ +void +SiPixelFEDChannelContainerTestWriter::endJob() +{ + + edm::LogInfo("SiPixelFEDChannelContainerTestWriter")<<"Analyzed "<size() < poolDbService; + if( poolDbService.isAvailable() ){ + cond::Time_t valid_time = poolDbService->currentTime(); + // this writes the payload to begin in current run defined in cfg + poolDbService->writeOne(myQualities,valid_time, m_record); + } +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +SiPixelFEDChannelContainerTestWriter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment("Writes payloads of type SiPixelFEDChannelContainer"); + desc.addUntracked("printDebug",false); + desc.add("record","SiPixelStatusScenariosRcd"); + descriptions.add("SiPixelFEDChannelContainerTestWriter",desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(SiPixelFEDChannelContainerTestWriter); diff --git a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter_cfg.py b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter_cfg.py new file mode 100644 index 0000000000000..2d3b0c001a206 --- /dev/null +++ b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter_cfg.py @@ -0,0 +1,69 @@ +import FWCore.ParameterSet.Config as cms +process = cms.Process("ProcessOne") + +## +## MessageLogger +## +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.categories.append("SiPixelFEDChannelContainerTestWriter") +process.MessageLogger.categories.append("SiPixelFEDChannelContainer") +process.MessageLogger.destinations = cms.untracked.vstring("cout") +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string("INFO"), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), + reportEvery = cms.untracked.int32(100) + ), + SiPixelFEDChannelContainerTestWriter = cms.untracked.PSet( limit = cms.untracked.int32(-1)), + SiPixelFEDChannelContainer = cms.untracked.PSet( limit = cms.untracked.int32(-1)) + ) +process.MessageLogger.statistics.append('cout') + +## +## Empty source +## +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(315704), + numberEventsInRun = cms.untracked.uint32(2000), + firstLuminosityBlock = cms.untracked.uint32(1), + numberEventsInLuminosityBlock = cms.untracked.uint32(1), + ) + +#process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(25000000)) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10000)) + +## +## Database output service +## +process.load("CondCore.CondDB.CondDB_cfi") + +# DB input service: +process.CondDB.connect = "frontier://FrontierProd/CMS_CONDITIONS" +process.dbInput = cms.ESSource("PoolDBESSource", + process.CondDB, + toGet = cms.VPSet(cms.PSet(record = cms.string("SiPixelQualityFromDbRcd"), + tag = cms.string("SiPixelQuality_byPCL_stuckTBM_v1") + ), + cms.PSet(record = cms.string("SiPixelFedCablingMapRcd"), + tag = cms.string("SiPixelFedCablingMap_phase1_v7") + ) + ) + ) +## +## Output database (in this case local sqlite file) +## +process.CondDB.connect = 'sqlite_file:SiPixelStatusScenarios_v1.db' +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + timetype = cms.untracked.string('runnumber'), + toPut = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenariosRcd'), + tag = cms.string('SiPixelFEDChannelContainer_StuckTBM_2018_v1_mc') + ) + ) + ) + +process.WriteInDB = cms.EDAnalyzer("SiPixelFEDChannelContainerTestWriter", + record= cms.string('SiPixelStatusScenariosRcd'), + ) + +process.p = cms.Path(process.WriteInDB) diff --git a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerWriteFromASCII.cc b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerWriteFromASCII.cc new file mode 100644 index 0000000000000..404ec8a2770e0 --- /dev/null +++ b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerWriteFromASCII.cc @@ -0,0 +1,170 @@ +// -*- C++ -*- +// +// Package: CondFormats/SiPixelObjects +// Class: SiPixelFEDChannelContainerTestWriter +// +/**\class SiPixelFEDChannelContainerTestWriter SiPixelFEDChannelContainerTestWriter.cc CondFormats/SiPixelObjects/plugins/SiPixelFEDChannelContainerTestWriter.cc + Description: class to build the SiPixelFEDChannelContainer payloads +*/ +// +// Original Author: Marco Musich +// Created: Wed, 27 Nov 2018 12:04:36 GMT +// +// + +// system include files +#include +#include + +// user include files +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" +#include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h" +#include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +// +// class declaration +// + +class SiPixelFEDChannelContainerWriteFromASCII : public edm::one::EDAnalyzer<> { + public: + explicit SiPixelFEDChannelContainerWriteFromASCII(const edm::ParameterSet&); + ~SiPixelFEDChannelContainerWriteFromASCII(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + + private: + virtual void beginJob() override; + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override; + + // ----------member data --------------------------- + const std::string m_record; + const std::string m_SnapshotInputs; + const bool printdebug_; + SiPixelFEDChannelContainer* myQualities; + +}; + +// +// constructors and destructor +// +SiPixelFEDChannelContainerWriteFromASCII::SiPixelFEDChannelContainerWriteFromASCII(const edm::ParameterSet& iConfig): + m_record(iConfig.getParameter("record")), + m_SnapshotInputs(iConfig.getParameter("snapshots")), + printdebug_(iConfig.getUntrackedParameter("printDebug",false)) +{ + //now do what ever initialization is needed + myQualities = new SiPixelFEDChannelContainer(); +} + + +SiPixelFEDChannelContainerWriteFromASCII::~SiPixelFEDChannelContainerWriteFromASCII() +{ + delete myQualities; +} + +// +// member functions +// + +// ------------ method called for each event ------------ +void +SiPixelFEDChannelContainerWriteFromASCII::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace edm; + + std::ifstream mysnapshots(m_SnapshotInputs); + std::string line; + + std::string scenario =""; + unsigned int thedetid(0); + + SiPixelFEDChannelContainer::SiPixelFEDChannelCollection theBadFEDChannels; + + if(mysnapshots.is_open()){ + while (getline (mysnapshots, line)) { + //edm::LogVerbatim("SiPixelFEDChannelContainerWriteFromASCII") << line << std::endl; + std::istringstream iss (line); + unsigned int run, ls, detid, fed, link, roc_first, roc_last; + iss >> run >> ls >> detid >> fed >> link >> roc_first >> roc_last; + + PixelFEDChannel theBadChannel{fed,link,roc_first,roc_last}; + + auto newscenario=std::to_string(run)+"_"+std::to_string(ls); + if(newscenario!=scenario){ + edm::LogVerbatim("SiPixelFEDChannelContainerWriteFromASCII")<< "================================" << std::endl; + edm::LogVerbatim("SiPixelFEDChannelContainerWriteFromASCII")<< "found a new scenario: " << newscenario << std::endl; + if(scenario!=""){ + edm::LogVerbatim("SiPixelFEDChannelContainerWriteFromASCII")<< "size of the fed channel vector: " << theBadFEDChannels.size() << std::endl; + edm::LogVerbatim("SiPixelFEDChannelContainerWriteFromASCII")<< "================================" << std::endl; + myQualities->setScenario(scenario,theBadFEDChannels); + theBadFEDChannels.clear(); + } + scenario=newscenario; + } + + if(detid!=thedetid){ + if(printdebug_) edm::LogVerbatim("SiPixelFEDChannelContainerWriteFromASCII")<< "found a new detid!" << detid << std::endl; + thedetid=detid; + } + theBadFEDChannels[thedetid].push_back(theBadChannel); + } + } + + myQualities->setScenario(scenario,theBadFEDChannels); + + if(printdebug_){ + edm::LogInfo("SiPixelFEDChannelContainerWriteFromASCII")<<"Content of SiPixelFEDChannelContainer "<printAll(); + } +} + +// ------------ method called once each job just before starting event loop ------------ +void +SiPixelFEDChannelContainerWriteFromASCII::beginJob() +{ +} + +// ------------ method called once each job just after ending the event loop ------------ +void +SiPixelFEDChannelContainerWriteFromASCII::endJob() +{ + + edm::LogInfo("SiPixelFEDChannelContainerWriteFromASCII")<<"Size of SiPixelFEDChannelContainer object "<< myQualities->size() < poolDbService; + if( poolDbService.isAvailable() ){ + cond::Time_t valid_time = poolDbService->currentTime(); + // this writes the payload to begin in current run defined in cfg + poolDbService->writeOne(myQualities,valid_time, m_record); + } +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +SiPixelFEDChannelContainerWriteFromASCII::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment("Writes payloads of type SiPixelFEDChannelContainer from input ASCII files"); + desc.addUntracked("printDebug",true); + desc.add("snapshots",""); + desc.add("record","SiPixelStatusScenariosRcd"); + descriptions.add("SiPixelFEDChannelContainerWriteFromASCII",desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(SiPixelFEDChannelContainerWriteFromASCII); diff --git a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerWriteFromASCII_cfg.py b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerWriteFromASCII_cfg.py new file mode 100644 index 0000000000000..7a0437d682a53 --- /dev/null +++ b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerWriteFromASCII_cfg.py @@ -0,0 +1,70 @@ +import FWCore.ParameterSet.Config as cms +process = cms.Process("ProcessOne") + +## +## MessageLogger +## +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.categories.append("SiPixelFEDChannelContainerWriteFromASCII") +process.MessageLogger.categories.append("SiPixelFEDChannelContainer") +process.MessageLogger.destinations = cms.untracked.vstring("cout") +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string("INFO"), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), + reportEvery = cms.untracked.int32(100) + ), + SiPixelFEDChannelContainerWriteFromASCII = cms.untracked.PSet( limit = cms.untracked.int32(-1)), + SiPixelFEDChannelContainer = cms.untracked.PSet( limit = cms.untracked.int32(-1)) + ) +process.MessageLogger.statistics.append('cout') + +## +## Empty source +## +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(1), + numberEventsInRun = cms.untracked.uint32(1), + firstLuminosityBlock = cms.untracked.uint32(1), + numberEventsInLuminosityBlock = cms.untracked.uint32(1), + ) + +#process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(25000000)) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1)) + +## +## Database output service +## +process.load("CondCore.CondDB.CondDB_cfi") + +# DB input service: +process.CondDB.connect = "frontier://FrontierProd/CMS_CONDITIONS" +process.dbInput = cms.ESSource("PoolDBESSource", + process.CondDB, + toGet = cms.VPSet(cms.PSet(record = cms.string("SiPixelQualityFromDbRcd"), + tag = cms.string("SiPixelQuality_byPCL_stuckTBM_v1") + ), + cms.PSet(record = cms.string("SiPixelFedCablingMapRcd"), + tag = cms.string("SiPixelFedCablingMap_phase1_v7") + ) + ) + ) +## +## Output database (in this case local sqlite file) +## +process.CondDB.connect = 'sqlite_file:SiPixelStatusScenarios_fromFED25.db' +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + timetype = cms.untracked.string('runnumber'), + toPut = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenariosRcd'), + tag = cms.string('SiPixelFEDChannelContainer_StuckTBM_2018_v1_mc') + ) + ) + ) + +process.WriteInDB = cms.EDAnalyzer("SiPixelFEDChannelContainerWriteFromASCII", + record= cms.string('SiPixelStatusScenariosRcd'), + snapshots = cms.string('snapshots_fromFED25.txt') + ) + +process.p = cms.Path(process.WriteInDB) diff --git a/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader.cc b/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader.cc new file mode 100644 index 0000000000000..fe9c63dbe0e63 --- /dev/null +++ b/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader.cc @@ -0,0 +1,103 @@ +#include +#include +#include +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h" +#include "CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h" + +class SiPixelQualityProbabilitiesTestReader : public edm::one::EDAnalyzer<> { +public: + explicit SiPixelQualityProbabilitiesTestReader(edm::ParameterSet const& p); + ~SiPixelQualityProbabilitiesTestReader(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + + virtual void analyze(const edm::Event& e, const edm::EventSetup& c) override; + + // ----------member data --------------------------- + const bool printdebug_; + const std::string formatedOutput_; + +}; + +SiPixelQualityProbabilitiesTestReader::SiPixelQualityProbabilitiesTestReader(edm::ParameterSet const& p): + printdebug_(p.getUntrackedParameter("printDebug",true)), + formatedOutput_(p.getUntrackedParameter("outputFile","")) +{ + edm::LogInfo("SiPixelQualityProbabilitiesTestReader")<<"SiPixelQualityProbabilitiesTestReader"< scenarioProbabilityHandle; + edm::LogInfo("SiPixelQualityProbabilitiesTestReader") <<"got eshandle"<().get(scenarioProbabilityHandle); + edm::LogInfo("SiPixelQualityProbabilitiesTestReader") <<"got context"<size() << std::endl; + edm::LogInfo("SiPixelQualityProbabilitiesTestReader") <<"Content of my Probabilities "<printAll(); + } + + FILE* pFile=NULL; + if(formatedOutput_!="")pFile=fopen(formatedOutput_.c_str(), "w"); + if(pFile){ + + fprintf(pFile,"SiPixelQualityProbabilities::printAll() \n"); + fprintf(pFile," =================================================================================================================== \n"); + + SiPixelQualityProbabilities:: probabilityMap m_probabilities = myProbabilities->getProbability_Map(); + + for(auto it = m_probabilities.begin(); it != m_probabilities.end() ; ++it){ + fprintf(pFile," =================================================================================================================== \n"); + fprintf(pFile,"PU bin : %i \n ",(it->first)); + for (const auto &entry : it->second){ + fprintf(pFile,"Quality snapshot %s, probability %f \n",(entry.first).c_str(),entry.second); + } + } + } +} + +void +SiPixelQualityProbabilitiesTestReader::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment("Reads payloads of type SiPixelQualityProbabilities"); + desc.addUntracked("printDebug",true); + desc.addUntracked("outputFile",""); + descriptions.add("SiPixelQualityProbabilitiesTestReader",desc); +} + +DEFINE_FWK_MODULE(SiPixelQualityProbabilitiesTestReader); diff --git a/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader_cfg.py b/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader_cfg.py new file mode 100644 index 0000000000000..a68abe62d54b1 --- /dev/null +++ b/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader_cfg.py @@ -0,0 +1,62 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("ProcessOne") + +## +## MessageLogger +## +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.categories.append("SiPixelQualityProbabilitiesTestReader") +process.MessageLogger.categories.append("SiPixelQualityProbabilities") +process.MessageLogger.destinations = cms.untracked.vstring("cout") +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string("INFO"), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), + reportEvery = cms.untracked.int32(1000) + ), + SiPixelQualityProbabilitiesTestReader = cms.untracked.PSet( limit = cms.untracked.int32(-1)), + SiPixelQualityProbabilities = cms.untracked.PSet( limit = cms.untracked.int32(-1)) + ) +process.MessageLogger.statistics.append('cout') + +## +## Empty Source +## +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) + ) +## +## Get the payload +## +from CondCore.CondDB.CondDB_cfi import * +CondDBQualityProbabilities = CondDB.clone(connect = cms.string("sqlite_file:SiPixelStatusScenarioProbabilities.db")) + +process.dbInput = cms.ESSource("PoolDBESSource", + CondDBQualityProbabilities, + toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenarioProbabilityRcd'), + tag = cms.string('SiPixelQualityProbabilities_v0_mc') # choose tag you want + ) + ) + ) +## +## Retrieve it and check it's available in the ES +## +process.get = cms.EDAnalyzer("EventSetupRecordDataGetter", + toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenarioProbabilityRcd'), + data = cms.vstring('SiPixelQualityProbabilities_v0_mc') + ) + ), + verbose = cms.untracked.bool(True) + ) +## +## Read it back +## +process.ReadDB = cms.EDAnalyzer("SiPixelQualityProbabilitiesTestReader") +process.ReadDB.printDebug = cms.untracked.bool(True) +process.ReadDB.outputFile = cms.untracked.string('SiPixelQualityProbabilities.log') + +process.p = cms.Path(process.get+process.ReadDB) diff --git a/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestWriter.cc b/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestWriter.cc new file mode 100644 index 0000000000000..9e0393b9dece3 --- /dev/null +++ b/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestWriter.cc @@ -0,0 +1,167 @@ +// -*- C++ -*- +// +// Package: CondFormats/SiPixelObjects +// Class: SiPixelQualityProbabilitiesTestWriter +// +/**\class SiPixelQualityProbabilitiesTestWriter SiPixelQualityProbabilitiesTestWriter.cc CondFormats/SiPixelObjects/plugins/SiPixelQualityProbabilitiesTestWriter.cc + Description: class to build the SiPixel Quality probabilities +*/ +// +// Original Author: Marco Musich +// Created: Wed, 30 Nov 2018 13:22:00 GMT +// +// + +// system include files +#include +#include + +// user include files +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h" +#include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +// +// class declaration +// + +class SiPixelQualityProbabilitiesTestWriter : public edm::one::EDAnalyzer<> { + public: + explicit SiPixelQualityProbabilitiesTestWriter(const edm::ParameterSet&); + ~SiPixelQualityProbabilitiesTestWriter(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + + private: + virtual void beginJob() override; + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override; + + // ----------member data --------------------------- + const std::string m_ProbInputs; + const std::string m_SnapshotInputs; + const std::string m_record; + const bool printdebug_; + SiPixelQualityProbabilities* myProbabilities; + +}; + +// +// constructors and destructor +// +SiPixelQualityProbabilitiesTestWriter::SiPixelQualityProbabilitiesTestWriter(const edm::ParameterSet& iConfig): + m_ProbInputs(iConfig.getParameter("probabilities")), + m_SnapshotInputs(iConfig.getParameter("snapshots")), + m_record(iConfig.getParameter("record")), + printdebug_(iConfig.getUntrackedParameter("printDebug",false)) +{ + //now do what ever initialization is needed + myProbabilities = new SiPixelQualityProbabilities(); +} + + +SiPixelQualityProbabilitiesTestWriter::~SiPixelQualityProbabilitiesTestWriter() +{ + delete myProbabilities; +} + +// +// member functions +// + +// ------------ method called for each event ------------ +void +SiPixelQualityProbabilitiesTestWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace edm; + std::ifstream myfile(m_ProbInputs); + std::ifstream mysnapshots(m_SnapshotInputs); + std::string line1,line2; + std::map snapshotIdToString; + + if(mysnapshots.is_open()){ + while (getline (mysnapshots, line1)) { + //edm::LogInfo("SiPixelQualityProbabilitiesTestWriter") << line1 << std::endl; + std::istringstream iss (line1); + int id, run, ls; + iss >> id >> run >> ls; + snapshotIdToString[id]=std::to_string(run)+"_"+std::to_string(ls); + } + } + + SiPixelQualityProbabilities::probabilityVec myProbVector; + + if (myfile.is_open()){ + while (getline (myfile, line2)) { + edm::LogInfo("SiPixelQualityProbabilitiesTestWriter") << line2 << std::endl; + std::istringstream iss (line2); + int pileupBinId, nEntries; + iss >> pileupBinId >> nEntries; + edm::LogInfo("SiPixelQualityProbabilitiesTestWriter") << "PILEUP BIN/ENTRIES: " << pileupBinId << " " << nEntries << std::endl; + std::vector ids(nEntries, 0); + std::vector probs(nEntries, 0.0); + for (int i=0;i< nEntries; ++i){ + iss >> ids.at(i) >> probs.at(i); + //edm::LogInfo("SiPixelQualityProbabilitiesTestWriter") << ids.at(i) << " " << probs.at(i)<< std::endl; + auto idAndProb = std::make_pair(snapshotIdToString.at(ids.at(i)),probs.at(i)); + myProbVector.push_back(idAndProb); + } + if(nEntries>0) myProbabilities->setProbabilities(pileupBinId,myProbVector); + myProbVector.clear(); + } + myfile.close(); + } + + if(printdebug_){ + edm::LogInfo("SiPixelQualityProbabilitiesTestWriter")<<"Content of SiPixelQualityProbabilities "<printAll(); + } +} + +// ------------ method called once each job just before starting event loop ------------ +void +SiPixelQualityProbabilitiesTestWriter::beginJob() +{ +} + +// ------------ method called once each job just after ending the event loop ------------ +void +SiPixelQualityProbabilitiesTestWriter::endJob() +{ + + edm::LogInfo("SiPixelQualityProbabilitiesTestWriter")<<"Size of SiPixelQualityProbabilities object "<< myProbabilities->size() < poolDbService; + if( poolDbService.isAvailable() ){ + cond::Time_t valid_time = poolDbService->currentTime(); + // this writes the payload to begin in current run defined in cfg + poolDbService->writeOne(myProbabilities,valid_time, m_record); + } +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +SiPixelQualityProbabilitiesTestWriter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment("Writes payloads of type SiPixelQualityProbabilities"); + desc.addUntracked("printDebug",true); + desc.add("record","SiPixelStatusScenarioProbabilityRcd"); + desc.add("snapshots",""); + desc.add("probabilities",""); + descriptions.add("SiPixelQualityProbabilitiesTestWriter",desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(SiPixelQualityProbabilitiesTestWriter); diff --git a/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestWriter_cfg.py b/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestWriter_cfg.py new file mode 100644 index 0000000000000..2a6fdcb25743b --- /dev/null +++ b/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestWriter_cfg.py @@ -0,0 +1,60 @@ +import FWCore.ParameterSet.Config as cms +process = cms.Process("ProcessOne") + +## +## MessageLogger +## +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.categories.append("SiPixelQualityProbabilitiesTestWriter") +process.MessageLogger.categories.append("SiPixelQualityProbabilities") +process.MessageLogger.destinations = cms.untracked.vstring("cout") +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string("INFO"), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), + reportEvery = cms.untracked.int32(1000) + ), + SiPixelQualityProbabilitiesTestWriter = cms.untracked.PSet( limit = cms.untracked.int32(-1)), + SiPixelQualityProbabilities = cms.untracked.PSet( limit = cms.untracked.int32(-1)) + ) +process.MessageLogger.statistics.append('cout') + +## +## Empty source +## +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(1), + numberEventsInRun = cms.untracked.uint32(1), + firstLuminosityBlock = cms.untracked.uint32(1), + numberEventsInLuminosityBlock = cms.untracked.uint32(1), + ) + +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1)) + +## +## Database output service +## +process.load("CondCore.CondDB.CondDB_cfi") + +## +## Output database (in this case local sqlite file) +## +process.CondDB.connect = 'sqlite_file:SiPixelStatusScenarioProbabilities.db' +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + timetype = cms.untracked.string('runnumber'), + toPut = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenarioProbabilityRcd'), + tag = cms.string('SiPixelQualityProbabilities_v0_mc') + ) + ) + ) + + +process.WriteInDB = cms.EDAnalyzer("SiPixelQualityProbabilitiesTestWriter", + printDebug = cms.untracked.bool(True), + record = cms.string('SiPixelStatusScenarioProbabilityRcd'), + probabilities = cms.string('snapshotProb_322633.txt'), + snapshots = cms.string('snapshot_ids.txt') + ) + +process.p = cms.Path(process.WriteInDB) diff --git a/CondFormats/SiPixelObjects/test/testSerializationSiPixelObjects.cpp b/CondFormats/SiPixelObjects/test/testSerializationSiPixelObjects.cpp index c181ffe63df18..3ec997e20c421 100644 --- a/CondFormats/SiPixelObjects/test/testSerializationSiPixelObjects.cpp +++ b/CondFormats/SiPixelObjects/test/testSerializationSiPixelObjects.cpp @@ -28,7 +28,11 @@ int main() testSerialization(); testSerialization(); testSerialization(); + testSerialization(); + testSerialization(); + //testSerialization(); testSerialization(); + testSerialization(); testSerialization(); testSerialization(); testSerialization>(); From ea97bf3bd3d9292588813b912b6ae41a17cad82f Mon Sep 17 00:00:00 2001 From: Tatjana Date: Mon, 10 Dec 2018 10:46:21 +0100 Subject: [PATCH 02/30] Simulatoin of the pixel bad FED channels --- .../plugins/SiPixelRawToDigi.cc | 35 ++++-- .../plugins/SiPixelRawToDigi.h | 6 +- .../plugins/SiPixelDigitizer.cc | 15 ++- .../plugins/SiPixelDigitizerAlgorithm.cc | 109 ++++++++++++++++-- .../plugins/SiPixelDigitizerAlgorithm.h | 21 +++- 5 files changed, 158 insertions(+), 28 deletions(-) diff --git a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc index dc3c9e4c68f68..fcfa134dca536 100644 --- a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc +++ b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc @@ -48,7 +48,7 @@ SiPixelRawToDigi::SiPixelRawToDigi( const edm::ParameterSet& conf ) regions_(nullptr), hCPU(nullptr), hDigi(nullptr) { - + includeErrors = config_.getParameter("IncludeErrors"); useQuality = config_.getParameter("UseQualityInfo"); if (config_.exists("ErrorList")) { @@ -58,7 +58,8 @@ SiPixelRawToDigi::SiPixelRawToDigi( const edm::ParameterSet& conf ) usererrorlist = config_.getParameter > ("UserErrorList"); } tFEDRawDataCollection = consumes (config_.getParameter("InputLabel")); - + + theBadPixelFEDChannelsLabel = consumes(edm::InputTag("simSiPixelDigisPixelFEDChannelCollection")); //start counters ndigis = 0; nwords = 0; @@ -71,7 +72,7 @@ SiPixelRawToDigi::SiPixelRawToDigi( const edm::ParameterSet& conf ) produces("UserErrorModules"); produces >(); } - + // regions if (config_.exists("Regions")) { if(!config_.getParameter("Regions").getParameterNames().empty()) @@ -153,6 +154,7 @@ SiPixelRawToDigi::fillDescriptions(edm::ConfigurationDescriptions& descriptions) desc.add("CablingMapLabel","")->setComment("CablingMap label"); //Tav desc.addOptional("CheckPixelOrder"); // never used, kept for back-compatibility descriptions.add("siPixelRawToDigi",desc); + } // ----------------------------------------------------------------------------- @@ -184,7 +186,7 @@ void SiPixelRawToDigi::produce( edm::Event& ev, edm::LogError("SiPixelQualityNotPresent")<<" Configured to use SiPixelQuality, but SiPixelQuality not present"< buffers; ev.getByToken(tFEDRawDataCollection, buffers); @@ -288,11 +290,10 @@ void SiPixelRawToDigi::produce( edm::Event& ev, } } // loop on DetSet of errors - + if (!disabledChannelsDetSet.empty()) { disabled_channelcollection->insert(errordetid, disabledChannelsDetSet.data(), disabledChannelsDetSet.size()); - } - + } } // if error assigned to a real DetId } // loop on errors in event for this FED } // if errors to be included in the event @@ -314,17 +315,31 @@ void SiPixelRawToDigi::produce( edm::Event& ev, hCPU->Fill( theTimer->realTime() ); hDigi->Fill(formatter.nDigis()); } + + //------------------------------------ //send digis and errors back to framework + + edm::Handle pixelFEDChannelCollectionHandle; + std::unique_ptr PixelFEDChannelCollection_ = nullptr; + if (ev.getByToken(theBadPixelFEDChannelsLabel, pixelFEDChannelCollectionHandle)){ + const PixelFEDChannelCollection * pfcc= pixelFEDChannelCollectionHandle.product(); + PixelFEDChannelCollection_ = std::make_unique(*pfcc); + } + ev.put(std::move(collection)); if(includeErrors){ ev.put(std::move(errorcollection)); ev.put(std::move(tkerror_detidcollection)); - ev.put(std::move(usererror_detidcollection), "UserErrorModules"); - ev.put(std::move(disabled_channelcollection)); + ev.put(std::move(usererror_detidcollection), "UserErrorModules"); + if (PixelFEDChannelCollection_ == nullptr){ + ev.put(std::move(disabled_channelcollection)); + } + else{ + ev.put(std::move(PixelFEDChannelCollection_)); + } } } - // declare this as a framework plugin #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(SiPixelRawToDigi); diff --git a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.h b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.h index 8ab5a2647a563..a558ba872101f 100644 --- a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.h +++ b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.h @@ -16,6 +16,7 @@ #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/Utilities/interface/CPUTimer.h" +#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" class SiPixelFedCablingTree; class SiPixelFedCabling; @@ -38,13 +39,13 @@ class SiPixelRawToDigi : public edm::stream::EDProducer<> { void produce( edm::Event&, const edm::EventSetup& ) override; private: - + edm::ParameterSet config_; std::unique_ptr cabling_; const SiPixelQuality* badPixelInfo_; PixelUnpackingRegions* regions_; edm::EDGetTokenT tFEDRawDataCollection; - + edm::EDGetTokenT theBadPixelFEDChannelsLabel; TH1D *hCPU, *hDigi; std::unique_ptr theTimer; bool includeErrors; @@ -56,6 +57,7 @@ class SiPixelRawToDigi : public edm::stream::EDProducer<> { edm::ESWatcher recordWatcher; edm::ESWatcher qualityWatcher; edm::InputTag label; + int ndigis; int nwords; bool usePilotBlade; diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc index 314bed10f1d5a..4e4efd2495ccc 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc @@ -63,7 +63,7 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "SimGeneral/MixingModule/interface/PileUpEventPrincipal.h" - +#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" //Random Number #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/RandomNumberGenerator.h" @@ -102,6 +102,7 @@ namespace cms mixMod.produces >().setBranchAlias(alias); mixMod.produces >().setBranchAlias(alias + "siPixelDigiSimLink"); + mixMod.produces().setBranchAlias(alias + "PixelFEDChannelCollection"); for(auto const& trackerContainer : trackerContainers) { edm::InputTag tag(hitsProducer, trackerContainer); iC.consumes >(edm::InputTag(hitsProducer, trackerContainer)); @@ -250,14 +251,22 @@ namespace cms std::vector > theDigiVector; std::vector > theDigiLinkVector; - + if (firstFinalizeEvent_) { const unsigned int bunchspace = PileupInfo_->getMix_bunchSpacing(); _pixeldigialgo->init_DynIneffDB(iSetup, bunchspace); firstFinalizeEvent_ = false; } _pixeldigialgo->calculateInstlumiFactor(PileupInfo_.get()); - + + if (_pixeldigialgo->killBadFEDChannels()){ + std::unique_ptr PixelFEDChannelCollection_; + _pixeldigialgo->chooseScenario(PileupInfo_.get(), randomEngine_, PixelFEDChannelCollection_); + if (PixelFEDChannelCollection_ != nullptr){ + iEvent.put(std::move(PixelFEDChannelCollection_)); + } + } + for( const auto& iu : pDD->detUnits()) { if(iu->type().isTrackerPixel()) { diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index f1c19ea7c1b11..0e724a61aac0b 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -55,6 +55,7 @@ #include "FWCore/Utilities/interface/RandomNumberGenerator.h" #include "CLHEP/Random/RandGaussQ.h" #include "CLHEP/Random/RandFlat.h" +#include "CLHEP/Random/RandGeneral.h" //#include "PixelIndices.h" #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" @@ -76,7 +77,8 @@ #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h" #include "CondFormats/DataRecord/interface/SiPixelLorentzAngleSimRcd.h" #include "CondFormats/DataRecord/interface/SiPixelDynamicInefficiencyRcd.h" - +#include "CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h" +#include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h" #include "CondFormats/DataRecord/interface/SiPixel2DTemplateDBObjectRcd.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" @@ -89,7 +91,8 @@ #include "CondFormats/SiPixelObjects/interface/LocalPixel.h" #include "CondFormats/SiPixelObjects/interface/CablingPathToDetUnit.h" #include "CondFormats/SiPixelObjects/interface/SiPixelDynamicInefficiency.h" - +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h" #include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFrameReverter.h" @@ -106,8 +109,6 @@ #include "CondFormats/SiPixelObjects/interface/PixelROC.h" - - using namespace edm; using namespace sipixelobjects; @@ -127,6 +128,11 @@ void SiPixelDigitizerAlgorithm::init(const edm::EventSetup& es) { es.get().get(map_); es.get().get(geom_); + if (KillBadFEDChannels){ + es.get().get(scenarioProbabilityHandle); + es.get().get(qualityCollectionHandle); + } + // Read template files for charge reweighting if (UseReweighting){ edm::ESHandle SiPixel2DTemp_den; @@ -253,7 +259,8 @@ SiPixelDigitizerAlgorithm::SiPixelDigitizerAlgorithm(const edm::ParameterSet& co // Control the pixel inefficiency AddPixelInefficiency(conf.getParameter("AddPixelInefficiency")), - + KillBadFEDChannels(conf.exists("KillBadFEDChannels")?conf.getParameter("KillBadFEDChannels"):false), + // Add threshold gaussian smearing: addThresholdSmearing(conf.getParameter("AddThresholdSmearing")), @@ -778,6 +785,58 @@ void SiPixelDigitizerAlgorithm::calculateInstlumiFactor(const std::vector &PixelFEDChannelCollection_){ + + std::cout << "Choose Scenario" << std::endl; + //Determine snapshot to use for the current event based on pileup information + + if (puInfo) { + const std::vector& bunchCrossing = puInfo->getMix_bunchCrossing(); + const std::vector& TrueInteractionList = puInfo->getMix_TrueInteractions(); + //const std::vector& nInteractionsList = puInfo->getMix_Ninteractions(); + //const int bunchSpacing = puInfo->getMix_bunchSpacing(); + + int pui = 0, p = 0; + std::vector::const_iterator pu; + std::vector::const_iterator pu0 = bunchCrossing.end(); + + for (pu=bunchCrossing.begin(); pu!=bunchCrossing.end(); ++pu) { + if (*pu==0) { + pu0 = pu; + p = pui; + } + pui++; + } + + PixelFEDChannelCollection_ = nullptr; + pixelEfficiencies_.PixelFEDChannelCollection_ = nullptr; + + if (pu0!=bunchCrossing.end()) { + + unsigned int PUBin = TrueInteractionList.at(p); // case delta PU=1, fix me + auto theProbabilitiesPerScenario = scenarioProbabilityHandle.product()->getProbabilities(PUBin); + std::vector probabilities; + for (auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++){ + probabilities.push_back(it->second); + } + + CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size()); + double x = randGeneral.shoot(); + unsigned int index = x * probabilities.size() - 1; + const std::string scenario = theProbabilitiesPerScenario.at(index).first; + PixelFEDChannelCollection_ = qualityCollectionHandle.product()->getDetSetBadPixelFedChannels(scenario); + pixelEfficiencies_.PixelFEDChannelCollection_ = qualityCollectionHandle.product()->getDetSetBadPixelFedChannels(scenario); + + } + } +} + + //============================================================================ void SiPixelDigitizerAlgorithm::setSimAccumulator(const std::map >& signalMap) { for(const auto& det: signalMap) { @@ -1588,6 +1647,33 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, std::vector pixelEfficiencyROCStdPixels(16,1); std::vector pixelEfficiencyROCBigPixels(16,1); + std::unique_ptr pIndexConverter(new PixelIndices(numColumns,numRows)); + + std::vector badRocsFromFEDChannels(16,0); + if (eff.PixelFEDChannelCollection_ != nullptr){ + PixelFEDChannelCollection::const_iterator it = eff.PixelFEDChannelCollection_->find(detID); + if (it != eff.PixelFEDChannelCollection_->end()){ + for(const auto& ch: *it) { + for (unsigned int i_roc = ch.roc_first; i_roc <= ch.roc_last; ++i_roc){ + std::vector path = map_.product()->pathToDetUnit(detID); + typedef std::vector::const_iterator IT; + for (IT it = path.begin(); it != path.end(); ++it) { + const PixelROC* myroc = map_.product()->findItem(*it); + if( myroc->idInDetUnit() == static_cast(i_roc)) { + LocalPixel::RocRowCol local = {39, 25};//corresponding to center of ROC row,col + GlobalPixel global = myroc->toGlobal( LocalPixel(local) ); + int chipIndex, colROC, rowROC; + pIndexConverter->transformToROC(global.col,global.row,chipIndex,colROC,rowROC); + badRocsFromFEDChannels.at(chipIndex) = 1; + } + } + } + } // loop over channels + } // detID in PixelFEDChannelCollection_ + } // has PixelFEDChannelCollection_ + + + if (eff.FromConfig) { // setup the chip indices conversion if (pixdet->subDetector()==GeomDetEnumerators::SubDetector::PixelBarrel || @@ -1661,7 +1747,7 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, // Initilize the index converter //PixelIndices indexConverter(numColumns,numRows); - std::unique_ptr pIndexConverter(new PixelIndices(numColumns,numRows)); + //std::unique_ptr pIndexConverter(new PixelIndices(numColumns,numRows)); int chipIndex = 0; int rowROC = 0; @@ -1745,10 +1831,13 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, } // end if if (isPhase1){ if((pixelStd.count(chipIndex) && pixelStd[chipIndex] == 0) - || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0)) { - // make pixel amplitude =0, pixel will be lost at clusterization - i->second.set(0.); // reset amplitude, - } // end if + || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0) + || (badRocsFromFEDChannels.at(chipIndex) == 1)) + { + //==================================================================== + // make pixel amplitude =0, pixel will be lost at clusterization + i->second.set(0.); // reset amplitude, + } // end if } // is Phase 1 } // end pixel loop } // end pixel_indefficiency diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h index 9afd731c839f9..6a9d62f443ee9 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h @@ -17,6 +17,7 @@ #include "Geometry/CommonTopologies/interface/PixelTopology.h" #include "CondFormats/SiPixelTransient/interface/SiPixelTemplate2D.h" #include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h" +#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" #include "boost/multi_array.hpp" typedef boost::multi_array array_2d; @@ -47,6 +48,8 @@ class SiPixelQuality; class SiPixelDynamicInefficiency; class TrackerGeometry; class TrackerTopology; +class SiPixelFEDChannelContainer; +class SiPixelQualityProbabilities; class SiPixelDigitizerAlgorithm { public: @@ -81,6 +84,11 @@ class SiPixelDigitizerAlgorithm { void calculateInstlumiFactor(const std::vector &ps, int bunchSpacing); // TODO: try to remove the duplication of logic... void setSimAccumulator(const std::map >& signalMap); + void chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *, + std::unique_ptr &PixelFEDChannelCollection_); + + bool killBadFEDChannels(); + private: //Accessing Lorentz angle from DB: @@ -95,7 +103,11 @@ class SiPixelDigitizerAlgorithm { // Get Dynamic Inefficiency scale factors from DB edm::ESHandle SiPixelDynamicInefficiency_; - + + // For BadFEDChannel simulation + edm::ESHandle qualityCollectionHandle; + edm::ESHandle scenarioProbabilityHandle; + // Define internal classes // definition class @@ -268,7 +280,9 @@ class SiPixelDigitizerAlgorithm { enum shiftEnumerator {FPixRocIdShift = 3, BPixRocIdShift = 6}; static const int rocIdMaskBits = 0x1F; void init_from_db(const edm::ESHandle&, const edm::ESHandle&); - bool matches(const DetId&, const DetId&, const std::vector&); + bool matches(const DetId&, const DetId&, const std::vector&); + std::unique_ptr PixelFEDChannelCollection_; + }; // @@ -380,9 +394,10 @@ class SiPixelDigitizerAlgorithm { const bool addChargeVCALSmearing; const bool addNoisyPixels; const bool fluctuateCharge; + //-- pixel efficiency const bool AddPixelInefficiency; // bool to read in inefficiencies - + const bool KillBadFEDChannels; const bool addThresholdSmearing; //-- calibration smearing From 367c7fdb9998c13efd93984d3613ee0b0ed0b173 Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 10 Dec 2018 14:27:28 +0100 Subject: [PATCH 03/30] add print methods and overloads for << operators, add protection against missing scenarios in maps --- .../interface/SiPixelFEDChannelContainer.h | 13 +++-- .../interface/SiPixelQualityProbabilities.h | 8 ++- .../src/SiPixelFEDChannelContainer.cc | 55 +++++++++++++++++-- .../src/SiPixelQualityProbabilities.cc | 33 ++++++++++- 4 files changed, 99 insertions(+), 10 deletions(-) diff --git a/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h b/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h index 037dec9ff73e3..4359fd3ca3cd2 100644 --- a/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h +++ b/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h @@ -1,8 +1,8 @@ #ifndef CondFormats_SiPixelObjects_SiPixelFEDChannelContainer_h #define CondFormats_SiPixelObjects_SiPixelFEDChannelContainer_h -#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" #include "CondFormats/Serialization/interface/Serializable.h" +#include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" // N.B. a DataFormat is serialized here (need for dedicated serialization rules, see CondFormats/External/interface/PixelFEDChannel.h) #include @@ -15,11 +15,11 @@ class SiPixelFEDChannelContainer{ typedef std::unordered_map SiPixelBadFEDChannelsScenarioMap; SiPixelFEDChannelContainer(){} + SiPixelFEDChannelContainer( const SiPixelFEDChannelContainer& rhs ){ m_scenarioMap = rhs.getScenarioMap(); }; virtual ~SiPixelFEDChannelContainer(){} void setScenario(const std::string &theScenarioId, const SiPixelFEDChannelCollection &theBadFEDChannels); - void setScenario(const std::string &theScenarioId, const SiPixelQuality &theSiPixelQuality, const SiPixelFedCablingMap& theFedCabling); - + const SiPixelBadFEDChannelsScenarioMap& getScenarioMap () const {return m_scenarioMap;} SiPixelFEDChannelCollection getSiPixelBadFedChannels(const std::string &ScenarioId) const; @@ -34,6 +34,9 @@ class SiPixelFEDChannelContainer{ void printAll() const; + //dumping values on output stream + void print(std::stringstream & ss) const; + private: SiPixelBadFEDChannelsScenarioMap m_scenarioMap; @@ -42,4 +45,6 @@ class SiPixelFEDChannelContainer{ }; -#endif +std::ostream & operator<<( std::ostream &, SiPixelFEDChannelContainer FEDChannels); + +#endif //CondFormats_SiPixelObjects_SiPixelFEDChannelContainer_h diff --git a/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h b/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h index 8da2c6bbc608b..68604bb41695c 100644 --- a/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h +++ b/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h @@ -13,6 +13,7 @@ class SiPixelQualityProbabilities{ typedef std::map probabilityMap; SiPixelQualityProbabilities(){} + SiPixelQualityProbabilities( const SiPixelQualityProbabilities& rhs ){ m_probabilities = rhs.getProbability_Map(); }; virtual ~SiPixelQualityProbabilities(){} void setProbabilities(const unsigned int &puBin, const probabilityVec &theProbabilities); @@ -28,6 +29,9 @@ class SiPixelQualityProbabilities{ void printAll() const; + //dumping values on output stream + void print(std::stringstream & ss) const; + private: probabilityMap m_probabilities; @@ -36,4 +40,6 @@ class SiPixelQualityProbabilities{ }; -#endif +std::ostream & operator<<( std::ostream &, SiPixelQualityProbabilities theProbabilities); + +#endif //CondFormats_SiPixelObjects_SiPixelQualityProbabilities_h diff --git a/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc b/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc index 04fc86e89af7d..aaa6dbf3a428c 100644 --- a/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc +++ b/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc @@ -4,8 +4,14 @@ #include #include // std::setw +//****************************************************************************// void SiPixelFEDChannelContainer::setScenario(const std::string &theScenarioId, const SiPixelFEDChannelCollection &theBadFEDChannels) { - m_scenarioMap.emplace(theScenarioId,theBadFEDChannels); + if( m_scenarioMap.find(theScenarioId) != m_scenarioMap.end()){ + edm::LogWarning("SiPixelFEDChannelContainer") << "Scenario: " <& SiPixelFEDChannelContainer::getSiPixelBadFedChannelsInDetId(const std::string &theScenarioId,DetId theDetId) { - return (m_scenarioMap[theScenarioId])[theDetId]; -} + if(m_scenarioMap.find(theScenarioId) == m_scenarioMap.end()){ + throw cms::Exception("SiPixelFEDChannelContainer")<< "No Bad Pixel FEDChannels defined for Scenario id: " << theScenarioId << "\n"; + } else { + if(m_scenarioMap[theScenarioId].find(theDetId) == m_scenarioMap[theScenarioId].end()){ + throw cms::Exception("SiPixelFEDChannelContainer")<< "No Bad Pixel FEDChannels defined for DetId:" < SiPixelFEDChannelContainer::getDetSetBadPixelFedChannels(const std::string &theScenarioId) const { + if(m_scenarioMap.find(theScenarioId) == m_scenarioMap.end()){ + throw cms::Exception("SiPixelFEDChannelContainer")<< "No Bad Pixel FEDChannels defined for Scenario id: " << theScenarioId << "\n"; + } + std::unique_ptr disabled_channelcollection = std::make_unique >(); auto SiPixelBadFedChannels = m_scenarioMap.at(theScenarioId); for(const auto &entry : SiPixelBadFedChannels){ @@ -66,6 +87,24 @@ void SiPixelFEDChannelContainer::printAll() const { } } +//****************************************************************************// +void SiPixelFEDChannelContainer::print(std::stringstream & ss) const { + for(auto it = m_scenarioMap.begin(); it != m_scenarioMap.end() ; ++it){ + ss<< "run :"<< it->first << " \n "; + for (const auto& thePixelFEDChannel : it->second){ + + DetId detId = thePixelFEDChannel.first; + ss<< "DetId :"<< detId << " \n "; + for(const auto& entry: thePixelFEDChannel.second) { + ss<< " fed : "<< entry.fed + << " link : "<< entry.link + << " roc_first : "<< entry.roc_first + << " roc_last: : "<< entry.roc_last; + } + } + } +} + //****************************************************************************// std::vector SiPixelFEDChannelContainer::getScenarioList() const { std::vector scenarios; @@ -76,3 +115,11 @@ std::vector SiPixelFEDChannelContainer::getScenarioList() const { } return scenarios; } + +//****************************************************************************// +std::ostream & operator<<( std::ostream & os, SiPixelFEDChannelContainer FEDChannels) { + std::stringstream ss; + FEDChannels.print( ss ); + os << ss.str(); + return os; +} diff --git a/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc b/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc index e0b8bd26ae471..48a92e9fd6d58 100644 --- a/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc +++ b/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc @@ -6,7 +6,13 @@ //****************************************************************************// void SiPixelQualityProbabilities::setProbabilities(const unsigned int &puBin, const probabilityVec &theProbabilities) { - m_probabilities[puBin]=theProbabilities; + + if( m_probabilities.find(puBin) != m_probabilities.end()){ + edm::LogWarning("SiPixelQualityProbabilities") << "PU bin: " << puBin <<" is already in the map!"<first << " \n "; + for (const auto &entry : it->second){ + ss<<"SiPixelQuality snapshot: " << entry.first << " |probability: " << entry.second << std::endl; + } + } + +} + + //****************************************************************************// std::vector SiPixelQualityProbabilities::getPileUpBins() const { std::vector bins; @@ -50,3 +73,11 @@ std::vector SiPixelQualityProbabilities::getPileUpBins() const { } return bins; } + +//****************************************************************************// +std::ostream & operator<<( std::ostream & os, SiPixelQualityProbabilities theProbabilities) { + std::stringstream ss; + theProbabilities.print( ss ); + os << ss.str(); + return os; +} From 9bf8ff1b7a23c0af3594f128f516178fded84ce4 Mon Sep 17 00:00:00 2001 From: Tatjana Date: Mon, 10 Dec 2018 16:30:44 +0100 Subject: [PATCH 04/30] few fixes --- EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc | 6 +++++- SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc | 6 +++++- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc index fcfa134dca536..09a86039dc372 100644 --- a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc +++ b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc @@ -59,7 +59,10 @@ SiPixelRawToDigi::SiPixelRawToDigi( const edm::ParameterSet& conf ) } tFEDRawDataCollection = consumes (config_.getParameter("InputLabel")); - theBadPixelFEDChannelsLabel = consumes(edm::InputTag("simSiPixelDigisPixelFEDChannelCollection")); + //theBadPixelFEDChannelsLabel = consumes(edm::InputTag("simSiPixelDigis")); + theBadPixelFEDChannelsLabel = consumes(edm::InputTag("mix")); + + // theBadPixelFEDChannelsLabel = consumes(edm::InputTag("PixelFEDChannelCollection","simSiPixelDigis")); //start counters ndigis = 0; nwords = 0; @@ -323,6 +326,7 @@ void SiPixelRawToDigi::produce( edm::Event& ev, edm::Handle pixelFEDChannelCollectionHandle; std::unique_ptr PixelFEDChannelCollection_ = nullptr; if (ev.getByToken(theBadPixelFEDChannelsLabel, pixelFEDChannelCollectionHandle)){ + const PixelFEDChannelCollection * pfcc= pixelFEDChannelCollectionHandle.product(); PixelFEDChannelCollection_ = std::make_unique(*pfcc); } diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc index 4e4efd2495ccc..8e899065c24f9 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc @@ -102,7 +102,8 @@ namespace cms mixMod.produces >().setBranchAlias(alias); mixMod.produces >().setBranchAlias(alias + "siPixelDigiSimLink"); - mixMod.produces().setBranchAlias(alias + "PixelFEDChannelCollection"); + + for(auto const& trackerContainer : trackerContainers) { edm::InputTag tag(hitsProducer, trackerContainer); iC.consumes >(edm::InputTag(hitsProducer, trackerContainer)); @@ -116,6 +117,9 @@ namespace cms } _pixeldigialgo.reset(new SiPixelDigitizerAlgorithm(iConfig)); + if (_pixeldigialgo->killBadFEDChannels()){ + mixMod.produces().setBranchAlias(alias + "PixelFEDChannelCollection"); + } } SiPixelDigitizer::~SiPixelDigitizer(){ diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index 0e724a61aac0b..d9f94671ef53c 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -825,10 +825,12 @@ void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHE probabilities.push_back(it->second); } + CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size()); double x = randGeneral.shoot(); unsigned int index = x * probabilities.size() - 1; const std::string scenario = theProbabilitiesPerScenario.at(index).first; + PixelFEDChannelCollection_ = qualityCollectionHandle.product()->getDetSetBadPixelFedChannels(scenario); pixelEfficiencies_.PixelFEDChannelCollection_ = qualityCollectionHandle.product()->getDetSetBadPixelFedChannels(scenario); From 6d764b89dfa7351d0142bc15c178acc0d0d8afe2 Mon Sep 17 00:00:00 2001 From: Tatjana Date: Mon, 10 Dec 2018 22:59:50 +0100 Subject: [PATCH 05/30] remove few comment --- .../SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc | 2 -- .../plugins/SiPixelDigitizerAlgorithm.cc | 12 +++++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc index 09a86039dc372..d1e743913defc 100644 --- a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc +++ b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc @@ -59,10 +59,8 @@ SiPixelRawToDigi::SiPixelRawToDigi( const edm::ParameterSet& conf ) } tFEDRawDataCollection = consumes (config_.getParameter("InputLabel")); - //theBadPixelFEDChannelsLabel = consumes(edm::InputTag("simSiPixelDigis")); theBadPixelFEDChannelsLabel = consumes(edm::InputTag("mix")); - // theBadPixelFEDChannelsLabel = consumes(edm::InputTag("PixelFEDChannelCollection","simSiPixelDigis")); //start counters ndigis = 0; nwords = 0; diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index d9f94671ef53c..abbc67ee3f722 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -792,14 +792,11 @@ bool SiPixelDigitizerAlgorithm::killBadFEDChannels(){return KillBadFEDChannels;} void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *engine, std::unique_ptr &PixelFEDChannelCollection_){ - std::cout << "Choose Scenario" << std::endl; //Determine snapshot to use for the current event based on pileup information if (puInfo) { const std::vector& bunchCrossing = puInfo->getMix_bunchCrossing(); const std::vector& TrueInteractionList = puInfo->getMix_TrueInteractions(); - //const std::vector& nInteractionsList = puInfo->getMix_Ninteractions(); - //const int bunchSpacing = puInfo->getMix_bunchSpacing(); int pui = 0, p = 0; std::vector::const_iterator pu; @@ -825,7 +822,6 @@ void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHE probabilities.push_back(it->second); } - CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size()); double x = randGeneral.shoot(); unsigned int index = x * probabilities.size() - 1; @@ -838,7 +834,6 @@ void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHE } } - //============================================================================ void SiPixelDigitizerAlgorithm::setSimAccumulator(const std::map >& signalMap) { for(const auto& det: signalMap) { @@ -1836,11 +1831,14 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, || (pixelBig.count(chipIndex) && pixelBig[chipIndex] == 0) || (badRocsFromFEDChannels.at(chipIndex) == 1)) { - //==================================================================== + //============================================================ // make pixel amplitude =0, pixel will be lost at clusterization - i->second.set(0.); // reset amplitude, + i->second.set(0.); // reset amplitude, } // end if } // is Phase 1 + if (KillBadFEDChannels && badRocsFromFEDChannels.at(chipIndex) == 1){ + i->second.set(0.); + } } // end pixel loop } // end pixel_indefficiency From 1508af4095a356a10b6bc439107efb570a7ce4ee Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 10 Dec 2018 22:30:26 +0100 Subject: [PATCH 06/30] fix payload producer (SiPixelQuality->PixelFEDChannel conversion) --- .../SiPixelFEDChannelContainerTestWriter.cc | 53 +++++++++++++------ ...iPixelFEDChannelContainerTestWriter_cfg.py | 6 +-- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter.cc b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter.cc index b14000b838bae..90b1ea77beec0 100644 --- a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter.cc +++ b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter.cc @@ -54,6 +54,7 @@ class SiPixelFEDChannelContainerTestWriter : public edm::one::EDAnalyzer<> { // ----------member data --------------------------- const std::string m_record; const bool printdebug_; + const bool isMC_; SiPixelFEDChannelContainer* myQualities; int IOVcount_; @@ -66,7 +67,8 @@ class SiPixelFEDChannelContainerTestWriter : public edm::one::EDAnalyzer<> { // SiPixelFEDChannelContainerTestWriter::SiPixelFEDChannelContainerTestWriter(const edm::ParameterSet& iConfig): m_record(iConfig.getParameter("record")), - printdebug_(iConfig.getUntrackedParameter("printDebug",false)) + printdebug_(iConfig.getUntrackedParameter("printDebug",false)), + isMC_(iConfig.getUntrackedParameter("isMC",true)) { //now do what ever initialization is needed myQualities = new SiPixelFEDChannelContainer(); @@ -112,13 +114,6 @@ SiPixelFEDChannelContainerTestWriter::analyze(const edm::Event& iEvent, const ed IOVcount_++; } - - if(printdebug_){ - edm::LogInfo("SiPixelFEDChannelContainerTestWriter")<<"Content of SiPixelFEDChannelContainer "<printAll(); - } } // ------------ method called once each job just before starting event loop ------------ @@ -163,25 +158,37 @@ SiPixelFEDChannelContainerTestWriter::createFromSiPixelQuality(const SiPixelQual continue; } - edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << "passed" << std::endl; + if(printdebug_){ + edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << "passed" << std::endl; + } + unsigned int link_id = 99999; unsigned int fed_id = 99999; - for (auto const& p: path){ - //std::cout << p.fed << " " << p.link << " " << p.roc << std::endl; - if (p.roc == bad_rocs[first_idx]){ + for (auto const& p: path){ + const sipixelobjects::PixelFEDCabling * aFed = cabling_->fed(p.fed); + const sipixelobjects::PixelFEDLink * link = aFed->link(p.link); + const sipixelobjects::PixelROC * roc = link->roc(p.roc); + unsigned int first_roc = roc->idInDetUnit(); + + if (first_roc == first_idx){ link_id = p.link; fed_id = p.fed; break; } } - edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << " " << fed_id << " " << link_id << " " << first_idx << " " << sec_idx << std::endl; - + if(printdebug_){ + edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << " " << fed_id << " " << link_id << " " << first_idx << " " << sec_idx << std::endl; + } + PixelFEDChannel ch = {fed_id, link_id, first_idx, sec_idx}; disabledChannelsDetSet.push_back(ch); - edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << i_roc << " " << coded_badRocs << " " << first_idx << " " << sec_idx << std::endl; - edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << "=======================================" << std::endl; + + if(printdebug_){ + edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << i_roc << " " << coded_badRocs << " " << first_idx << " " << sec_idx << std::endl; + edm::LogVerbatim("SiPixelFEDChannelContainerTestWriter") << "=======================================" << std::endl; + } } if (!disabledChannelsDetSet.empty()) { @@ -205,12 +212,24 @@ SiPixelFEDChannelContainerTestWriter::endJob() edm::LogInfo("SiPixelFEDChannelContainerTestWriter")<<"Analyzed "<size() <printAll(); + } + // Form the data here edm::Service poolDbService; if( poolDbService.isAvailable() ){ cond::Time_t valid_time = poolDbService->currentTime(); // this writes the payload to begin in current run defined in cfg - poolDbService->writeOne(myQualities,valid_time, m_record); + if(!isMC_){ + poolDbService->writeOne(myQualities,valid_time, m_record); + } else { + // for MC IOV since=1 + poolDbService->writeOne(myQualities,1, m_record); + } } } diff --git a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter_cfg.py b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter_cfg.py index 2d3b0c001a206..576969b4c8a07 100644 --- a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter_cfg.py +++ b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestWriter_cfg.py @@ -12,7 +12,7 @@ threshold = cms.untracked.string("INFO"), default = cms.untracked.PSet(limit = cms.untracked.int32(0)), FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), - reportEvery = cms.untracked.int32(100) + reportEvery = cms.untracked.int32(1000) ), SiPixelFEDChannelContainerTestWriter = cms.untracked.PSet( limit = cms.untracked.int32(-1)), SiPixelFEDChannelContainer = cms.untracked.PSet( limit = cms.untracked.int32(-1)) @@ -29,8 +29,8 @@ numberEventsInLuminosityBlock = cms.untracked.uint32(1), ) -#process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(25000000)) -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10000)) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(25000000)) +#process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10000)) ## ## Database output service From 7dc0126bf8b090cde8cd44b0f63d48e0511f967d Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 11 Dec 2018 10:16:45 +0100 Subject: [PATCH 07/30] fix compilation warning in SiPixelDigitizerAlgorithm --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index abbc67ee3f722..65a57c757e193 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -1659,7 +1659,7 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, if( myroc->idInDetUnit() == static_cast(i_roc)) { LocalPixel::RocRowCol local = {39, 25};//corresponding to center of ROC row,col GlobalPixel global = myroc->toGlobal( LocalPixel(local) ); - int chipIndex, colROC, rowROC; + int chipIndex(0), colROC(0), rowROC(0); pIndexConverter->transformToROC(global.col,global.row,chipIndex,colROC,rowROC); badRocsFromFEDChannels.at(chipIndex) = 1; } From ca4254718ca149cb693a4224c05c2deed0f6d833 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 12 Dec 2018 09:14:01 +0100 Subject: [PATCH 08/30] Addressed comments on Condition Formats: avoided useless binary searches and uniformity of methods, return by const reference and print on std::ostream. --- .../interface/SiPixelFEDChannelContainer.h | 8 ++--- .../interface/SiPixelQualityProbabilities.h | 10 +++--- .../src/SiPixelFEDChannelContainer.cc | 35 ++++++++++++------- .../src/SiPixelQualityProbabilities.cc | 21 ++++++----- 4 files changed, 43 insertions(+), 31 deletions(-) diff --git a/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h b/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h index 4359fd3ca3cd2..3389b94009a3e 100644 --- a/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h +++ b/CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h @@ -22,10 +22,10 @@ class SiPixelFEDChannelContainer{ const SiPixelBadFEDChannelsScenarioMap& getScenarioMap () const {return m_scenarioMap;} - SiPixelFEDChannelCollection getSiPixelBadFedChannels(const std::string &ScenarioId) const; - SiPixelFEDChannelCollection & getSiPixelBadFedChannels(const std::string &ScenarioId); + SiPixelFEDChannelCollection getSiPixelBadFedChannels(const std::string &ScenarioId) const; + const SiPixelFEDChannelCollection & getSiPixelBadFedChannels(const std::string &ScenarioId); - std::vector& getSiPixelBadFedChannelsInDetId(const std::string &theScenarioId,DetId theDetId); + const std::vector& getSiPixelBadFedChannelsInDetId(const std::string &theScenarioId,DetId theDetId); std::unique_ptr getDetSetBadPixelFedChannels(const std::string &ScenarioId) const; @@ -35,7 +35,7 @@ class SiPixelFEDChannelContainer{ void printAll() const; //dumping values on output stream - void print(std::stringstream & ss) const; + void print(std::ostream & os) const; private: diff --git a/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h b/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h index 68604bb41695c..4bba6d54d1761 100644 --- a/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h +++ b/CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h @@ -16,21 +16,21 @@ class SiPixelQualityProbabilities{ SiPixelQualityProbabilities( const SiPixelQualityProbabilities& rhs ){ m_probabilities = rhs.getProbability_Map(); }; virtual ~SiPixelQualityProbabilities(){} - void setProbabilities(const unsigned int &puBin, const probabilityVec &theProbabilities); + void setProbabilities(const unsigned int puBin, const probabilityVec &theProbabilities); const probabilityMap& getProbability_Map () const {return m_probabilities;} - probabilityVec getProbabilities(const unsigned int &puBin) const; - probabilityVec & getProbabilities(const unsigned int &puBin); + probabilityVec getProbabilities(const unsigned int puBin) const; + const probabilityVec & getProbabilities(const unsigned int puBin); double size()const {return m_probabilities.size();} - double nelements(const int &puBin)const {return m_probabilities.at(puBin).size();} + double nelements(const int puBin)const {return m_probabilities.at(puBin).size();} std::vector getPileUpBins() const; void printAll() const; //dumping values on output stream - void print(std::stringstream & ss) const; + void print(std::ostream & os) const; private: diff --git a/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc b/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc index aaa6dbf3a428c..aeb233bc00ab9 100644 --- a/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc +++ b/CondFormats/SiPixelObjects/src/SiPixelFEDChannelContainer.cc @@ -26,36 +26,45 @@ SiPixelFEDChannelContainer::SiPixelFEDChannelCollection SiPixelFEDChannelContain } //****************************************************************************// -SiPixelFEDChannelContainer::SiPixelFEDChannelCollection& SiPixelFEDChannelContainer::getSiPixelBadFedChannels(const std::string &theScenarioId) { - if(m_scenarioMap.find(theScenarioId) != m_scenarioMap.end()){ - return m_scenarioMap[theScenarioId]; +const SiPixelFEDChannelContainer::SiPixelFEDChannelCollection& SiPixelFEDChannelContainer::getSiPixelBadFedChannels(const std::string &theScenarioId) { + SiPixelBadFEDChannelsScenarioMap::const_iterator it = m_scenarioMap.find(theScenarioId); + + if (it != m_scenarioMap.end()){ + return it->second; } else { throw cms::Exception("SiPixelFEDChannelContainer")<< "No Bad Pixel FEDChannels defined for Scenario id: " << theScenarioId << "\n"; } } //****************************************************************************// -std::vector& SiPixelFEDChannelContainer::getSiPixelBadFedChannelsInDetId(const std::string &theScenarioId,DetId theDetId) { +const std::vector& SiPixelFEDChannelContainer::getSiPixelBadFedChannelsInDetId(const std::string &theScenarioId,DetId theDetId) { + + SiPixelBadFEDChannelsScenarioMap::const_iterator it = m_scenarioMap.find(theScenarioId); - if(m_scenarioMap.find(theScenarioId) == m_scenarioMap.end()){ + if(it == m_scenarioMap.end()){ throw cms::Exception("SiPixelFEDChannelContainer")<< "No Bad Pixel FEDChannels defined for Scenario id: " << theScenarioId << "\n"; } else { - if(m_scenarioMap[theScenarioId].find(theDetId) == m_scenarioMap[theScenarioId].end()){ + + SiPixelFEDChannelCollection::const_iterator it2 = (it->second).find(theDetId); + + if(it2 == (it->second).end()){ throw cms::Exception("SiPixelFEDChannelContainer")<< "No Bad Pixel FEDChannels defined for DetId:" <second; } } //****************************************************************************// std::unique_ptr SiPixelFEDChannelContainer::getDetSetBadPixelFedChannels(const std::string &theScenarioId) const { - if(m_scenarioMap.find(theScenarioId) == m_scenarioMap.end()){ + SiPixelBadFEDChannelsScenarioMap::const_iterator it = m_scenarioMap.find(theScenarioId); + + if(it == m_scenarioMap.end()){ throw cms::Exception("SiPixelFEDChannelContainer")<< "No Bad Pixel FEDChannels defined for Scenario id: " << theScenarioId << "\n"; } std::unique_ptr disabled_channelcollection = std::make_unique >(); - auto SiPixelBadFedChannels = m_scenarioMap.at(theScenarioId); + auto SiPixelBadFedChannels = it->second; for(const auto &entry : SiPixelBadFedChannels){ disabled_channelcollection->insert(entry.first, entry.second.data(), entry.second.size()); } @@ -88,15 +97,15 @@ void SiPixelFEDChannelContainer::printAll() const { } //****************************************************************************// -void SiPixelFEDChannelContainer::print(std::stringstream & ss) const { +void SiPixelFEDChannelContainer::print(std::ostream & os) const { for(auto it = m_scenarioMap.begin(); it != m_scenarioMap.end() ; ++it){ - ss<< "run :"<< it->first << " \n "; + os<< "run :"<< it->first << " \n "; for (const auto& thePixelFEDChannel : it->second){ DetId detId = thePixelFEDChannel.first; - ss<< "DetId :"<< detId << " \n "; + os<< "DetId :"<< detId << " \n "; for(const auto& entry: thePixelFEDChannel.second) { - ss<< " fed : "<< entry.fed + os<< " fed : "<< entry.fed << " link : "<< entry.link << " roc_first : "<< entry.roc_first << " roc_last: : "<< entry.roc_last; diff --git a/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc b/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc index 48a92e9fd6d58..e4c90d898acec 100644 --- a/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc +++ b/CondFormats/SiPixelObjects/src/SiPixelQualityProbabilities.cc @@ -5,7 +5,7 @@ #include // std::setw //****************************************************************************// -void SiPixelQualityProbabilities::setProbabilities(const unsigned int &puBin, const probabilityVec &theProbabilities) { +void SiPixelQualityProbabilities::setProbabilities(const unsigned int puBin, const probabilityVec &theProbabilities) { if( m_probabilities.find(puBin) != m_probabilities.end()){ edm::LogWarning("SiPixelQualityProbabilities") << "PU bin: " << puBin <<" is already in the map!"<second; + } else { + throw cms::Exception("SiPixelQualityProbabilities")<< "No Probabilities are defined for PU bin " << puBin << "\n"; } - return m_probabilities[puBin]; + } @@ -51,12 +54,12 @@ void SiPixelQualityProbabilities::printAll() const { } //****************************************************************************// -void SiPixelQualityProbabilities::print(std::stringstream & ss) const { +void SiPixelQualityProbabilities::print(std::ostream & os) const { for(auto it = m_probabilities.begin(); it != m_probabilities.end() ; ++it){ - ss<< "PU :"<< it->first << " \n "; + os<< "PU :"<< it->first << " \n "; for (const auto &entry : it->second){ - ss<<"SiPixelQuality snapshot: " << entry.first << " |probability: " << entry.second << std::endl; + os<<"SiPixelQuality snapshot: " << entry.first << " |probability: " << entry.second << std::endl; } } From 8158047b2d541df82fecd54bdbbd0e2db7494fd5 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 12 Dec 2018 09:46:21 +0100 Subject: [PATCH 09/30] Update SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc Co-Authored-By: tsusa --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index 65a57c757e193..ddf1ca9d65c6b 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -816,7 +816,7 @@ void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHE if (pu0!=bunchCrossing.end()) { unsigned int PUBin = TrueInteractionList.at(p); // case delta PU=1, fix me - auto theProbabilitiesPerScenario = scenarioProbabilityHandle.product()->getProbabilities(PUBin); + const auto& theProbabilitiesPerScenario = scenarioProbabilityHandle->getProbabilities(PUBin); std::vector probabilities; for (auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++){ probabilities.push_back(it->second); From b200dd25d987fb0189a31c5b389b98cb3b1e69f9 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 12 Dec 2018 09:47:21 +0100 Subject: [PATCH 10/30] Update SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc Co-Authored-By: tsusa --- SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index ddf1ca9d65c6b..cc1c552933213 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -818,6 +818,7 @@ void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHE unsigned int PUBin = TrueInteractionList.at(p); // case delta PU=1, fix me const auto& theProbabilitiesPerScenario = scenarioProbabilityHandle->getProbabilities(PUBin); std::vector probabilities; + probabilities.reserve(theProbabilitiesPerScenario.size); for (auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++){ probabilities.push_back(it->second); } From a61776424fac5d275fbc77e955d8ab3d5951929a Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 12 Dec 2018 09:48:45 +0100 Subject: [PATCH 11/30] Update SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc Co-Authored-By: tsusa --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index cc1c552933213..4c8e58888019d 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -826,7 +826,7 @@ void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHE CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size()); double x = randGeneral.shoot(); unsigned int index = x * probabilities.size() - 1; - const std::string scenario = theProbabilitiesPerScenario.at(index).first; + const std::string& scenario = theProbabilitiesPerScenario.at(index).first; PixelFEDChannelCollection_ = qualityCollectionHandle.product()->getDetSetBadPixelFedChannels(scenario); pixelEfficiencies_.PixelFEDChannelCollection_ = qualityCollectionHandle.product()->getDetSetBadPixelFedChannels(scenario); From 38f7abe9d07dcbff33401db52475517426d3bb5c Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 12 Dec 2018 09:50:05 +0100 Subject: [PATCH 12/30] Update SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc Co-Authored-By: tsusa --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index 4c8e58888019d..e5c13a69aa7fa 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -787,7 +787,7 @@ void SiPixelDigitizerAlgorithm::calculateInstlumiFactor(const std::vector &PixelFEDChannelCollection_){ From 9edf5e37e335d6c98263d605b6342e1ce24f5850 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 12 Dec 2018 09:51:21 +0100 Subject: [PATCH 13/30] Update SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc Co-Authored-By: tsusa --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index e5c13a69aa7fa..9fde39572003e 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -828,7 +828,7 @@ void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHE unsigned int index = x * probabilities.size() - 1; const std::string& scenario = theProbabilitiesPerScenario.at(index).first; - PixelFEDChannelCollection_ = qualityCollectionHandle.product()->getDetSetBadPixelFedChannels(scenario); + PixelFEDChannelCollection_ = qualityCollectionHandle->getDetSetBadPixelFedChannels(scenario); pixelEfficiencies_.PixelFEDChannelCollection_ = qualityCollectionHandle.product()->getDetSetBadPixelFedChannels(scenario); } From 4f02e388b9f89ed26f6722d6c7f128d656ff62f4 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 12 Dec 2018 09:55:26 +0100 Subject: [PATCH 14/30] Update SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc Co-Authored-By: tsusa --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index 9fde39572003e..196ca24eaa98a 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -829,7 +829,7 @@ void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHE const std::string& scenario = theProbabilitiesPerScenario.at(index).first; PixelFEDChannelCollection_ = qualityCollectionHandle->getDetSetBadPixelFedChannels(scenario); - pixelEfficiencies_.PixelFEDChannelCollection_ = qualityCollectionHandle.product()->getDetSetBadPixelFedChannels(scenario); + pixelEfficiencies_.PixelFEDChannelCollection_ = qualityCollectionHandle->getDetSetBadPixelFedChannels(scenario); } } From c931969fa61bf1665f6e69a4465292e853671dc4 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 12 Dec 2018 09:56:59 +0100 Subject: [PATCH 15/30] Update SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc Co-Authored-By: tsusa --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index 196ca24eaa98a..6e79d6e98f19b 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -1653,7 +1653,7 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, if (it != eff.PixelFEDChannelCollection_->end()){ for(const auto& ch: *it) { for (unsigned int i_roc = ch.roc_first; i_roc <= ch.roc_last; ++i_roc){ - std::vector path = map_.product()->pathToDetUnit(detID); + std::vector path = map_->pathToDetUnit(detID); typedef std::vector::const_iterator IT; for (IT it = path.begin(); it != path.end(); ++it) { const PixelROC* myroc = map_.product()->findItem(*it); From 70903fe6cbc87d413cf9e7372bab0777b5da2e8c Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 12 Dec 2018 09:57:29 +0100 Subject: [PATCH 16/30] Update SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc Co-Authored-By: tsusa --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index 6e79d6e98f19b..a7f8359dc7a6d 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -1645,7 +1645,7 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, std::vector pixelEfficiencyROCStdPixels(16,1); std::vector pixelEfficiencyROCBigPixels(16,1); - std::unique_ptr pIndexConverter(new PixelIndices(numColumns,numRows)); + auto pIndexConverter = PixelIndices(numColumns,numRows); std::vector badRocsFromFEDChannels(16,0); if (eff.PixelFEDChannelCollection_ != nullptr){ From 4e7d064323224c1360e304764ba52857f643484c Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Wed, 12 Dec 2018 09:58:37 +0100 Subject: [PATCH 17/30] Update SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h Co-Authored-By: tsusa --- SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h index 6a9d62f443ee9..4c1537bffe538 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h @@ -87,7 +87,7 @@ class SiPixelDigitizerAlgorithm { void chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *, std::unique_ptr &PixelFEDChannelCollection_); - bool killBadFEDChannels(); + bool killBadFEDChannels() const; private: From e952c4dadf329e54a4789c91d7e05256a19b7509 Mon Sep 17 00:00:00 2001 From: Tatjana Date: Wed, 12 Dec 2018 15:38:09 +0100 Subject: [PATCH 18/30] Code improvements following Matti's comments --- .../python/SiPixelSimParameters_cfi.py | 3 +- .../plugins/SiPixelDigitizer.cc | 21 +++++---- .../plugins/SiPixelDigitizerAlgorithm.cc | 47 ++++++++++--------- .../plugins/SiPixelDigitizerAlgorithm.h | 7 ++- 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py index f097248d5f157..6f82a96d52e59 100644 --- a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py +++ b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py @@ -36,9 +36,10 @@ def _modifyPixelDigitizerForPhase1Pixel( digitizer ) : digitizer.ElectronsPerVcal_Offset = cms.double(-60) # L2-4: -60 +- 130 digitizer.ElectronsPerVcal_L1_Offset = cms.double(-670) # L1: -670 +- 220 digitizer.UseReweighting = cms.bool(True) - + SiPixelSimBlock = cms.PSet( + KillBadFEDChannels = cms.bool(False), UseReweighting = cms.bool(False), PrintClusters = cms.bool(False), PrintTemplates = cms.bool(False), diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc index 8e899065c24f9..5709f878cff4c 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc @@ -118,7 +118,7 @@ namespace cms _pixeldigialgo.reset(new SiPixelDigitizerAlgorithm(iConfig)); if (_pixeldigialgo->killBadFEDChannels()){ - mixMod.produces().setBranchAlias(alias + "PixelFEDChannelCollection"); + mixMod.produces(); } } @@ -126,7 +126,7 @@ namespace cms edm::LogInfo ("PixelDigitizer ") <<"Destruct the Pixel Digitizer"; } - + // // member functions // @@ -264,19 +264,20 @@ namespace cms _pixeldigialgo->calculateInstlumiFactor(PileupInfo_.get()); if (_pixeldigialgo->killBadFEDChannels()){ - std::unique_ptr PixelFEDChannelCollection_; - _pixeldigialgo->chooseScenario(PileupInfo_.get(), randomEngine_, PixelFEDChannelCollection_); - if (PixelFEDChannelCollection_ != nullptr){ - iEvent.put(std::move(PixelFEDChannelCollection_)); - } - } + std::unique_ptr PixelFEDChannelCollection_ = _pixeldigialgo->chooseScenario(PileupInfo_.get(), randomEngine_); + if (PixelFEDChannelCollection_ == nullptr){ + throw cms::Exception("NullPointerError") << "PixelFEDChannelCollection not set in chooseScenario function.\n"; + } + iEvent.put(std::move(PixelFEDChannelCollection_)); + } + for( const auto& iu : pDD->detUnits()) { if(iu->type().isTrackerPixel()) { - + // - + edm::DetSet collector(iu->geographicalId().rawId()); edm::DetSet linkcollector(iu->geographicalId().rawId()); diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index a7f8359dc7a6d..b339fdf60c572 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -259,7 +259,7 @@ SiPixelDigitizerAlgorithm::SiPixelDigitizerAlgorithm(const edm::ParameterSet& co // Control the pixel inefficiency AddPixelInefficiency(conf.getParameter("AddPixelInefficiency")), - KillBadFEDChannels(conf.exists("KillBadFEDChannels")?conf.getParameter("KillBadFEDChannels"):false), + KillBadFEDChannels(conf.getParameter("KillBadFEDChannels")), // Add threshold gaussian smearing: addThresholdSmearing(conf.getParameter("AddThresholdSmearing")), @@ -268,7 +268,7 @@ SiPixelDigitizerAlgorithm::SiPixelDigitizerAlgorithm(const edm::ParameterSet& co doMissCalibrate(conf.getParameter("MissCalibrate")), // Enable miss-calibration theGainSmearing(conf.getParameter("GainSmearing")), // sigma of the gain smearing theOffsetSmearing(conf.getParameter("OffsetSmearing")), //sigma of the offset smearing - + // Add pixel radiation damage for upgrade studies AddPixelAging(conf.getParameter("DoPixelAging")), UseReweighting(conf.getParameter("UseReweighting")), @@ -790,10 +790,13 @@ void SiPixelDigitizerAlgorithm::calculateInstlumiFactor(const std::vector &PixelFEDChannelCollection_){ - - //Determine snapshot to use for the current event based on pileup information +//void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *engine, std::unique_ptr &PixelFEDChannelCollect +std::unique_ptr SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *engine){ + //Determine scenario to use for the current event based on pileup information + + std::unique_ptr PixelFEDChannelCollection_ = nullptr; + pixelEfficiencies_.PixelFEDChannelCollection_ = nullptr; if (puInfo) { const std::vector& bunchCrossing = puInfo->getMix_bunchCrossing(); const std::vector& TrueInteractionList = puInfo->getMix_TrueInteractions(); @@ -810,15 +813,13 @@ void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHE pui++; } - PixelFEDChannelCollection_ = nullptr; - pixelEfficiencies_.PixelFEDChannelCollection_ = nullptr; - if (pu0!=bunchCrossing.end()) { unsigned int PUBin = TrueInteractionList.at(p); // case delta PU=1, fix me + PUBin = 27; const auto& theProbabilitiesPerScenario = scenarioProbabilityHandle->getProbabilities(PUBin); std::vector probabilities; - probabilities.reserve(theProbabilitiesPerScenario.size); + probabilities.reserve(theProbabilitiesPerScenario.size()); for (auto it = theProbabilitiesPerScenario.begin(); it != theProbabilitiesPerScenario.end(); it++){ probabilities.push_back(it->second); } @@ -826,13 +827,14 @@ void SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHE CLHEP::RandGeneral randGeneral(*engine, &(probabilities.front()), probabilities.size()); double x = randGeneral.shoot(); unsigned int index = x * probabilities.size() - 1; - const std::string& scenario = theProbabilitiesPerScenario.at(index).first; + const std::string& scenario = theProbabilitiesPerScenario.at(index).first; PixelFEDChannelCollection_ = qualityCollectionHandle->getDetSetBadPixelFedChannels(scenario); - pixelEfficiencies_.PixelFEDChannelCollection_ = qualityCollectionHandle->getDetSetBadPixelFedChannels(scenario); + pixelEfficiencies_.PixelFEDChannelCollection_ = qualityCollectionHandle->getDetSetBadPixelFedChannels(scenario); } } + return PixelFEDChannelCollection_; } //============================================================================ @@ -1648,20 +1650,20 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, auto pIndexConverter = PixelIndices(numColumns,numRows); std::vector badRocsFromFEDChannels(16,0); - if (eff.PixelFEDChannelCollection_ != nullptr){ + if (eff.PixelFEDChannelCollection_ != nullptr){ PixelFEDChannelCollection::const_iterator it = eff.PixelFEDChannelCollection_->find(detID); + if (it != eff.PixelFEDChannelCollection_->end()){ for(const auto& ch: *it) { for (unsigned int i_roc = ch.roc_first; i_roc <= ch.roc_last; ++i_roc){ std::vector path = map_->pathToDetUnit(detID); - typedef std::vector::const_iterator IT; - for (IT it = path.begin(); it != path.end(); ++it) { - const PixelROC* myroc = map_.product()->findItem(*it); + for(const auto p : path){ + const PixelROC* myroc = map_.product()->findItem(p); if( myroc->idInDetUnit() == static_cast(i_roc)) { LocalPixel::RocRowCol local = {39, 25};//corresponding to center of ROC row,col GlobalPixel global = myroc->toGlobal( LocalPixel(local) ); int chipIndex(0), colROC(0), rowROC(0); - pIndexConverter->transformToROC(global.col,global.row,chipIndex,colROC,rowROC); + pIndexConverter.transformToROC(global.col,global.row,chipIndex,colROC,rowROC); badRocsFromFEDChannels.at(chipIndex) = 1; } } @@ -1745,7 +1747,6 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, // Initilize the index converter //PixelIndices indexConverter(numColumns,numRows); - //std::unique_ptr pIndexConverter(new PixelIndices(numColumns,numRows)); int chipIndex = 0; int rowROC = 0; @@ -1762,10 +1763,10 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, int row = ip.first; // X in row int col = ip.second; // Y is in col //transform to ROC index coordinates - pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC); - int dColInChip = pIndexConverter->DColumn(colROC); // get ROC dcol from ROC col + pIndexConverter.transformToROC(col,row,chipIndex,colROC,rowROC); + int dColInChip = pIndexConverter.DColumn(colROC); // get ROC dcol from ROC col //dcol in mod - int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex); + int dColInDet = pIndexConverter.DColumnInModule(dColInChip,chipIndex); chips[chipIndex]++; columns[dColInDet]++; @@ -1813,10 +1814,10 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, int row = ip.first; // X in row int col = ip.second; // Y is in col //transform to ROC index coordinates - pIndexConverter->transformToROC(col,row,chipIndex,colROC,rowROC); - int dColInChip = pIndexConverter->DColumn(colROC); //get ROC dcol from ROC col + pIndexConverter.transformToROC(col,row,chipIndex,colROC,rowROC); + int dColInChip = pIndexConverter.DColumn(colROC); //get ROC dcol from ROC col //dcol in mod - int dColInDet = pIndexConverter->DColumnInModule(dColInChip,chipIndex); + int dColInDet = pIndexConverter.DColumnInModule(dColInChip,chipIndex); //float rand = RandFlat::shoot(); float rand = CLHEP::RandFlat::shoot(engine); diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h index 4c1537bffe538..0e995ed971d2c 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h @@ -84,9 +84,9 @@ class SiPixelDigitizerAlgorithm { void calculateInstlumiFactor(const std::vector &ps, int bunchSpacing); // TODO: try to remove the duplication of logic... void setSimAccumulator(const std::map >& signalMap); - void chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *, - std::unique_ptr &PixelFEDChannelCollection_); - + //void chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *, + // std::unique_ptr &PixelFEDChannelCollection_); + std::unique_ptr chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *); bool killBadFEDChannels() const; private: @@ -282,7 +282,6 @@ class SiPixelDigitizerAlgorithm { void init_from_db(const edm::ESHandle&, const edm::ESHandle&); bool matches(const DetId&, const DetId&, const std::vector&); std::unique_ptr PixelFEDChannelCollection_; - }; // From 459ff15a61f4aadab560e446a28bf47526d085d7 Mon Sep 17 00:00:00 2001 From: Tatjana Date: Wed, 12 Dec 2018 20:46:33 +0100 Subject: [PATCH 19/30] made InputTag configurable, set KillBadFEDChannels for premix_stage1 --- EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc | 5 +++-- EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py | 2 +- SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc index d1e743913defc..0f73c121743f8 100644 --- a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc +++ b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc @@ -58,8 +58,8 @@ SiPixelRawToDigi::SiPixelRawToDigi( const edm::ParameterSet& conf ) usererrorlist = config_.getParameter > ("UserErrorList"); } tFEDRawDataCollection = consumes (config_.getParameter("InputLabel")); - - theBadPixelFEDChannelsLabel = consumes(edm::InputTag("mix")); + // theBadPixelFEDChannelsLabel = consumes(edm::InputTag("mix")); + theBadPixelFEDChannelsLabel = consumes(config_.getParameter("BadPixelFEDChannelsInputLabel")); //start counters ndigis = 0; @@ -154,6 +154,7 @@ SiPixelRawToDigi::fillDescriptions(edm::ConfigurationDescriptions& descriptions) desc.add("UsePhase1",false)->setComment("## Use phase1"); desc.add("CablingMapLabel","")->setComment("CablingMap label"); //Tav desc.addOptional("CheckPixelOrder"); // never used, kept for back-compatibility + desc.add("BadPixelFEDChannelsInputLabel",edm::InputTag("mixData")); descriptions.add("siPixelRawToDigi",desc); } diff --git a/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py b/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py index fda0b69fa46a1..442e8fa3c483d 100644 --- a/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py +++ b/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py @@ -17,6 +17,6 @@ ## Empty Regions PSet means complete unpacking siPixelDigis.Regions = cms.PSet( ) siPixelDigis.CablingMapLabel = cms.string("") - +siPixelDigis.BadPixelFEDChannelsInputLabel = cms.InputTag("mixData") from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel phase1Pixel.toModify(siPixelDigis, UsePhase1=True) diff --git a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py index 6f82a96d52e59..dbc6de73422c1 100644 --- a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py +++ b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py @@ -108,6 +108,7 @@ def _modifyPixelDigitizerForPhase1Pixel( digitizer ) : AddNoise = True, AddNoisyPixels = False, AddPixelInefficiency = False, #done in second step + KillBadFEDChannels = False, #done in second step ) # Threshold in electrons are the Official CRAFT09 numbers: From b791d996ce58d6e6c9f545413113d3ade6ac2925 Mon Sep 17 00:00:00 2001 From: Tatjana Date: Wed, 12 Dec 2018 22:25:12 +0100 Subject: [PATCH 20/30] Access CablingPathToDetUnit outside the loops --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index b339fdf60c572..58b824bcacbdc 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -1654,9 +1654,9 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, PixelFEDChannelCollection::const_iterator it = eff.PixelFEDChannelCollection_->find(detID); if (it != eff.PixelFEDChannelCollection_->end()){ + const std::vector &path = map_->pathToDetUnit(detID); for(const auto& ch: *it) { for (unsigned int i_roc = ch.roc_first; i_roc <= ch.roc_last; ++i_roc){ - std::vector path = map_->pathToDetUnit(detID); for(const auto p : path){ const PixelROC* myroc = map_.product()->findItem(p); if( myroc->idInDetUnit() == static_cast(i_roc)) { @@ -1672,8 +1672,7 @@ void SiPixelDigitizerAlgorithm::pixel_inefficiency(const PixelEfficiencies& eff, } // detID in PixelFEDChannelCollection_ } // has PixelFEDChannelCollection_ - - + if (eff.FromConfig) { // setup the chip indices conversion if (pixdet->subDetector()==GeomDetEnumerators::SubDetector::PixelBarrel || From d14a25d8ab53daac686a058cc619e051e0a561fe Mon Sep 17 00:00:00 2001 From: Tatjana Date: Wed, 12 Dec 2018 22:40:06 +0100 Subject: [PATCH 21/30] Change default for BadPixelFEDChannelsInputLabel, add modifier for premix_stage2 --- EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc | 2 +- EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc index 0f73c121743f8..fa1f7bf1a58e6 100644 --- a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc +++ b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc @@ -154,7 +154,7 @@ SiPixelRawToDigi::fillDescriptions(edm::ConfigurationDescriptions& descriptions) desc.add("UsePhase1",false)->setComment("## Use phase1"); desc.add("CablingMapLabel","")->setComment("CablingMap label"); //Tav desc.addOptional("CheckPixelOrder"); // never used, kept for back-compatibility - desc.add("BadPixelFEDChannelsInputLabel",edm::InputTag("mixData")); + desc.add("BadPixelFEDChannelsInputLabel",edm::InputTag("mix")); descriptions.add("siPixelRawToDigi",desc); } diff --git a/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py b/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py index 442e8fa3c483d..d56f03a59d9e8 100644 --- a/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py +++ b/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py @@ -17,6 +17,8 @@ ## Empty Regions PSet means complete unpacking siPixelDigis.Regions = cms.PSet( ) siPixelDigis.CablingMapLabel = cms.string("") -siPixelDigis.BadPixelFEDChannelsInputLabel = cms.InputTag("mixData") + from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel phase1Pixel.toModify(siPixelDigis, UsePhase1=True) +from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 +premix_stage2.toModify(siPixelDigis, BadPixelFEDChannelsInputLabel = "mixData") From 45b3870cd2b77067276e628ee383688a82d466b4 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 13 Dec 2018 14:55:36 +0100 Subject: [PATCH 22/30] adding PixelFEDChannelCollectionProducer and SiPixelFEDChannelContainerESProducerRcd --- .../SiPixelFEDChannelContainerESProducerRcd.h | 11 ++ ...SiPixelFEDChannelContainerESProducerRcd.cc | 5 + .../PixelFEDChannelCollectionProducer.cc | 101 ++++++++++++++++++ .../PixelFEDChannelCollectionProducer_cfi.py | 3 + 4 files changed, 120 insertions(+) create mode 100644 CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h create mode 100644 CalibTracker/Records/src/SiPixelFEDChannelContainerESProducerRcd.cc create mode 100644 CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc create mode 100644 CalibTracker/SiPixelESProducers/python/PixelFEDChannelCollectionProducer_cfi.py diff --git a/CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h b/CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h new file mode 100644 index 0000000000000..d1d5cf5ec1749 --- /dev/null +++ b/CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h @@ -0,0 +1,11 @@ +#ifndef CALIBTRACKER_RECORDS_SIPIXELFEDCHANNELCONTAINERESPRODUCERRCD_H +#define CALIBTRACKER_RECORDS_SIPIXELFEDCHANNELCONTAINERESPRODUCERRCD_H + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" +#include "FWCore/Framework/interface/DependentRecordImplementation.h" +#include "boost/mpl/vector.hpp" +#include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h" + +class SiPixelFEDChannelContainerESProducerRcd : public edm::eventsetup::DependentRecordImplementation > {}; + +#endif diff --git a/CalibTracker/Records/src/SiPixelFEDChannelContainerESProducerRcd.cc b/CalibTracker/Records/src/SiPixelFEDChannelContainerESProducerRcd.cc new file mode 100644 index 0000000000000..2944bbb2a2541 --- /dev/null +++ b/CalibTracker/Records/src/SiPixelFEDChannelContainerESProducerRcd.cc @@ -0,0 +1,5 @@ +#include "CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" +#include "FWCore/Utilities/interface/typelookup.h" + +EVENTSETUP_RECORD_REG(SiPixelFEDChannelContainerESProducerRcd); diff --git a/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc b/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc new file mode 100644 index 0000000000000..798d44cb0d9e0 --- /dev/null +++ b/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc @@ -0,0 +1,101 @@ +// -*- C++ -*- +// +// Package: CalibTracker/PixelFEDChannelCollectionProducer +// Class: PixelFEDChannelCollectionProducer +// +/**\class PixelFEDChannelCollectionProducer + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Marco Musich +// Created: Thu, 13 Dec 2018 08:48:22 GMT +// +// + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/ModuleFactory.h" +#include "FWCore/Framework/interface/ESProducer.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" +#include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" +#include "CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h" + +// Need to add #include statements for definitions of +// the data type and record type here + +// +// class declaration +// + +class PixelFEDChannelCollectionProducer : public edm::ESProducer { + public: + PixelFEDChannelCollectionProducer(const edm::ParameterSet&); + ~PixelFEDChannelCollectionProducer(); + + typedef std::unordered_map PixelFEDChannelCollectionMap; + + using ReturnType = std::unique_ptr; + + ReturnType produce(const SiPixelFEDChannelContainerESProducerRcd &); + private: + // ----------member data --------------------------- +}; + + +PixelFEDChannelCollectionProducer::PixelFEDChannelCollectionProducer(const edm::ParameterSet& iConfig) +{ + //the following line is needed to tell the framework what + // data is being produced + setWhatProduced(this); + + //now do what ever other initialization is needed +} + + +PixelFEDChannelCollectionProducer::~PixelFEDChannelCollectionProducer() +{ + + // do anything here that needs to be done at destruction time + // (e.g. close files, deallocate resources etc.) + +} + +// +// member functions +// + +// ------------ method called to produce the data ------------ +PixelFEDChannelCollectionProducer::ReturnType +PixelFEDChannelCollectionProducer::produce(const SiPixelFEDChannelContainerESProducerRcd& iRecord) +{ + edm::ESHandle qualityCollectionHandle; + iRecord.getRecord().get(qualityCollectionHandle); + + PixelFEDChannelCollectionMap out; + + for(const auto& it : qualityCollectionHandle->getScenarioMap()){ + + std::string scenario = it.first; + PixelFEDChannelCollection disabled_channelcollection; + auto SiPixelBadFedChannels = it.second; + for(const auto &entry : SiPixelBadFedChannels){ + disabled_channelcollection.insert(entry.first, entry.second.data(), entry.second.size()); + } + out.emplace(scenario,disabled_channelcollection); + } + + auto product = std::make_unique(out); + return product; +} + +//define this as a plug-in +DEFINE_FWK_EVENTSETUP_MODULE(PixelFEDChannelCollectionProducer); diff --git a/CalibTracker/SiPixelESProducers/python/PixelFEDChannelCollectionProducer_cfi.py b/CalibTracker/SiPixelESProducers/python/PixelFEDChannelCollectionProducer_cfi.py new file mode 100644 index 0000000000000..0a63a5e34b5ef --- /dev/null +++ b/CalibTracker/SiPixelESProducers/python/PixelFEDChannelCollectionProducer_cfi.py @@ -0,0 +1,3 @@ +import FWCore.ParameterSet.Config as cms + +SiPixelFEDChannelContainerESProducer = cms.ESProducer("SiPixelFEDChannelContainerESProducer") From 53f5d505c3da1d33821d489860ddcc4db7984586 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 13 Dec 2018 17:36:55 +0100 Subject: [PATCH 23/30] fix to register the C++ type in the ES --- .../interface/SiPixelFEDChannelContainerESProducerRcd.h | 2 +- .../plugins/PixelFEDChannelCollectionProducer.cc | 3 +-- CalibTracker/SiPixelESProducers/src/module.cc | 6 ++++++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 CalibTracker/SiPixelESProducers/src/module.cc diff --git a/CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h b/CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h index d1d5cf5ec1749..9967db6231baf 100644 --- a/CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h +++ b/CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h @@ -6,6 +6,6 @@ #include "boost/mpl/vector.hpp" #include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h" -class SiPixelFEDChannelContainerESProducerRcd : public edm::eventsetup::DependentRecordImplementation > {}; +class SiPixelFEDChannelContainerESProducerRcd : public edm::eventsetup::DependentRecordImplementation > {}; #endif diff --git a/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc b/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc index 798d44cb0d9e0..bdfb6cf17df40 100644 --- a/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc +++ b/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc @@ -20,11 +20,11 @@ #include // user include files +#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ModuleFactory.h" #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/Framework/interface/ESHandle.h" -#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" #include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h" #include "CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h" @@ -42,7 +42,6 @@ class PixelFEDChannelCollectionProducer : public edm::ESProducer { ~PixelFEDChannelCollectionProducer(); typedef std::unordered_map PixelFEDChannelCollectionMap; - using ReturnType = std::unique_ptr; ReturnType produce(const SiPixelFEDChannelContainerESProducerRcd &); diff --git a/CalibTracker/SiPixelESProducers/src/module.cc b/CalibTracker/SiPixelESProducers/src/module.cc new file mode 100644 index 0000000000000..3cc237783e027 --- /dev/null +++ b/CalibTracker/SiPixelESProducers/src/module.cc @@ -0,0 +1,6 @@ +#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" +#include "FWCore/Utilities/interface/typelookup.h" + +typedef std::unordered_map PixelFEDChannelCollectionMap; + +TYPELOOKUP_DATA_REG(PixelFEDChannelCollectionMap); From 07bba0852785203c1e1efdd70d0ffea2043a244d Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 14 Dec 2018 12:32:26 +0100 Subject: [PATCH 24/30] fix cfi for PixelFEDChannelCollectionProducer and add reader test --- .../PixelFEDChannelCollectionProducer_cfi.py | 2 +- .../PixelFEDChannelCollectionMapTestReader.cc | 84 +++++++++++++++++++ ...elFEDChannelCollectionMapTestReader_cfg.py | 79 +++++++++++++++++ 3 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 CalibTracker/SiPixelESProducers/test/PixelFEDChannelCollectionMapTestReader.cc create mode 100644 CalibTracker/SiPixelESProducers/test/PixelFEDChannelCollectionMapTestReader_cfg.py diff --git a/CalibTracker/SiPixelESProducers/python/PixelFEDChannelCollectionProducer_cfi.py b/CalibTracker/SiPixelESProducers/python/PixelFEDChannelCollectionProducer_cfi.py index 0a63a5e34b5ef..284d2f5b060fd 100644 --- a/CalibTracker/SiPixelESProducers/python/PixelFEDChannelCollectionProducer_cfi.py +++ b/CalibTracker/SiPixelESProducers/python/PixelFEDChannelCollectionProducer_cfi.py @@ -1,3 +1,3 @@ import FWCore.ParameterSet.Config as cms -SiPixelFEDChannelContainerESProducer = cms.ESProducer("SiPixelFEDChannelContainerESProducer") +SiPixelFEDChannelContainerESProducer = cms.ESProducer("PixelFEDChannelCollectionProducer") diff --git a/CalibTracker/SiPixelESProducers/test/PixelFEDChannelCollectionMapTestReader.cc b/CalibTracker/SiPixelESProducers/test/PixelFEDChannelCollectionMapTestReader.cc new file mode 100644 index 0000000000000..1dd8e48b09e0a --- /dev/null +++ b/CalibTracker/SiPixelESProducers/test/PixelFEDChannelCollectionMapTestReader.cc @@ -0,0 +1,84 @@ +#include +#include +#include +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" +#include "CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h" + +class PixelFEDChannelCollectionMapTestReader : public edm::one::EDAnalyzer<> { +public: + + typedef std::unordered_map PixelFEDChannelCollectionMap; + explicit PixelFEDChannelCollectionMapTestReader(edm::ParameterSet const& p); + ~PixelFEDChannelCollectionMapTestReader(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + + virtual void analyze(const edm::Event& e, const edm::EventSetup& c) override; + + // ----------member data --------------------------- + const bool printdebug_; + const std::string formatedOutput_; + +}; + +PixelFEDChannelCollectionMapTestReader::PixelFEDChannelCollectionMapTestReader(edm::ParameterSet const& p): + printdebug_(p.getUntrackedParameter("printDebug",true)), + formatedOutput_(p.getUntrackedParameter("outputFile","")) +{ + edm::LogInfo("PixelFEDChannelCollectionMapTestReader")<<"PixelFEDChannelCollectionMapTestReader"< PixelFEDChannelCollectionMapHandle; + edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<"got eshandle"<().get(PixelFEDChannelCollectionMapHandle); + edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<"got context"<size() << std::endl; + edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<"Content of myQuality_Map "<("printDebug",true); + desc.addUntracked("outputFile",""); + descriptions.add("PixelFEDChannelCollectionMapTestReader",desc); +} + +DEFINE_FWK_MODULE(PixelFEDChannelCollectionMapTestReader); diff --git a/CalibTracker/SiPixelESProducers/test/PixelFEDChannelCollectionMapTestReader_cfg.py b/CalibTracker/SiPixelESProducers/test/PixelFEDChannelCollectionMapTestReader_cfg.py new file mode 100644 index 0000000000000..c00a534013e74 --- /dev/null +++ b/CalibTracker/SiPixelESProducers/test/PixelFEDChannelCollectionMapTestReader_cfg.py @@ -0,0 +1,79 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("ProcessOne") + +## +## MessageLogger +## +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.categories.append("SiPixelFEDChannelContainer") +process.MessageLogger.categories.append("PixelFEDChannelCollectionMapTestReader") +process.MessageLogger.destinations = cms.untracked.vstring("cout") +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string("INFO"), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), + reportEvery = cms.untracked.int32(1000) + ), + SiPixelFEDChannelContainer = cms.untracked.PSet( limit = cms.untracked.int32(-1)), + PixelFEDChannelCollectionMapTestReader = cms.untracked.PSet( limit = cms.untracked.int32(-1)) + ) +process.MessageLogger.statistics.append('cout') + +## +## Empty Source +## +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) + ) +## +## Get the payload +## +from CondCore.CondDB.CondDB_cfi import * +CondDBQualityCollection = CondDB.clone(connect = cms.string("sqlite_file:SiPixelStatusScenarios_v1.db")) + +process.dbInput = cms.ESSource("PoolDBESSource", + CondDBQualityCollection, + toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenariosRcd'), + tag = cms.string('SiPixelFEDChannelContainer_StuckTBM_2018_v1_mc') # choose tag you want + ) + ) + ) + +#from CalibTracker.SiPixelESProducers.PixelFEDChannelCollectionProducer_cfi import * +process.load("CalibTracker.SiPixelESProducers.PixelFEDChannelCollectionProducer_cfi") +#process.SiPixelFEDChannelContainerESProducer = cms.ESProducer("PixelFEDChannelCollectionProducer") + + +## Retrieve it and check it's available in the ES +## +process.get = cms.EDAnalyzer("EventSetupRecordDataGetter", + toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelFEDChannelContainerESProducerRcd'), + data = cms.vstring('PixelFEDChannelCollectionMap') + ) + ), + verbose = cms.untracked.bool(True) + ) + +## +## Retrieve it and check it's available in the ES +## +# process.get = cms.EDAnalyzer("EventSetupRecordDataGetter", +# toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenariosRcd'), +# data = cms.vstring('SiPixelFEDChannelContainer') +# ) +# ), +# verbose = cms.untracked.bool(True) +# ) + +## +## Read it back +## +process.ReadDB = cms.EDAnalyzer("PixelFEDChannelCollectionMapTestReader") +process.ReadDB.printDebug = cms.untracked.bool(True) +process.ReadDB.outputFile = cms.untracked.string('PixelFEDChannelCollectionMap.log') + +process.p = cms.Path(process.get+process.ReadDB) From cd3bbcb11ced7c07faa565667545b9c10cce2fbd Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 14 Dec 2018 12:33:30 +0100 Subject: [PATCH 25/30] correct reading tests for SiPixelFEDChannelContainer and SiPixelQualityProbabilities --- .../test/SiPixelFEDChannelContainerTestReader_cfg.py | 2 +- .../test/SiPixelQualityProbabilitiesTestReader_cfg.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader_cfg.py b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader_cfg.py index 3cb8fa676bf90..6cd08e5be9a09 100644 --- a/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader_cfg.py +++ b/CondFormats/SiPixelObjects/test/SiPixelFEDChannelContainerTestReader_cfg.py @@ -47,7 +47,7 @@ ## process.get = cms.EDAnalyzer("EventSetupRecordDataGetter", toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenariosRcd'), - data = cms.vstring('SiPixelFEDChannelContainer_StuckTBM_2018_v1_mc') + data = cms.vstring('SiPixelFEDChannelContainer') ) ), verbose = cms.untracked.bool(True) diff --git a/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader_cfg.py b/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader_cfg.py index a68abe62d54b1..c23b308f35527 100644 --- a/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader_cfg.py +++ b/CondFormats/SiPixelObjects/test/SiPixelQualityProbabilitiesTestReader_cfg.py @@ -47,7 +47,7 @@ ## process.get = cms.EDAnalyzer("EventSetupRecordDataGetter", toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenarioProbabilityRcd'), - data = cms.vstring('SiPixelQualityProbabilities_v0_mc') + data = cms.vstring('SiPixelQualityProbabilities') ) ), verbose = cms.untracked.bool(True) From b00d60b729e55590cfc0baa707e47b8f6342b32f Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 15 Dec 2018 15:52:16 +0100 Subject: [PATCH 26/30] implement code-checks suggestion --- .../plugins/PixelFEDChannelCollectionProducer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc b/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc index bdfb6cf17df40..584659d1db8ca 100644 --- a/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc +++ b/CalibTracker/SiPixelESProducers/plugins/PixelFEDChannelCollectionProducer.cc @@ -39,7 +39,7 @@ class PixelFEDChannelCollectionProducer : public edm::ESProducer { public: PixelFEDChannelCollectionProducer(const edm::ParameterSet&); - ~PixelFEDChannelCollectionProducer(); + ~PixelFEDChannelCollectionProducer() override; typedef std::unordered_map PixelFEDChannelCollectionMap; using ReturnType = std::unique_ptr; From 4c3cca1454c637237713824b9e8791e3de5cd022 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 15 Dec 2018 19:47:30 +0100 Subject: [PATCH 27/30] move the PixelFEDChannelCollectionMap ES declaration to DataFormats/SiPixelDetId --- DataFormats/SiPixelDetId/BuildFile.xml | 1 + .../SiPixelDetId/src/ES_PixelFEDChannelCollectionMap.cc | 0 2 files changed, 1 insertion(+) rename CalibTracker/SiPixelESProducers/src/module.cc => DataFormats/SiPixelDetId/src/ES_PixelFEDChannelCollectionMap.cc (100%) diff --git a/DataFormats/SiPixelDetId/BuildFile.xml b/DataFormats/SiPixelDetId/BuildFile.xml index b5789e0ef2a2a..1971f79b51625 100644 --- a/DataFormats/SiPixelDetId/BuildFile.xml +++ b/DataFormats/SiPixelDetId/BuildFile.xml @@ -1,4 +1,5 @@ + diff --git a/CalibTracker/SiPixelESProducers/src/module.cc b/DataFormats/SiPixelDetId/src/ES_PixelFEDChannelCollectionMap.cc similarity index 100% rename from CalibTracker/SiPixelESProducers/src/module.cc rename to DataFormats/SiPixelDetId/src/ES_PixelFEDChannelCollectionMap.cc From f8467314babb6a46c1ac1a75795fea1c013f8bac Mon Sep 17 00:00:00 2001 From: Tatjana Date: Sat, 15 Dec 2018 22:00:22 +0100 Subject: [PATCH 28/30] Use new ESProducer --- SimGeneral/MixingModule/python/pixelDigitizer_cfi.py | 1 + .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 8 ++++---- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h | 8 +++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py b/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py index af37a4d19d301..f6b64cac19a97 100644 --- a/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py +++ b/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py @@ -28,3 +28,4 @@ # imported also to DataMixer configuration, and the original version # is needed there in stage2. (premix_stage2 & phase2_tracker).toModify(pixelDigitizer, **_premixStage1ModifyDict) +from CalibTracker.SiPixelESProducers.PixelFEDChannelCollectionProducer_cfi import * diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index 58b824bcacbdc..90ad215aa8fe5 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -130,7 +130,8 @@ void SiPixelDigitizerAlgorithm::init(const edm::EventSetup& es) { if (KillBadFEDChannels){ es.get().get(scenarioProbabilityHandle); - es.get().get(qualityCollectionHandle); + es.get().get(PixelFEDChannelCollectionMapHandle); + quality_map = PixelFEDChannelCollectionMapHandle.product(); } // Read template files for charge reweighting @@ -829,9 +830,8 @@ std::unique_ptr SiPixelDigitizerAlgorithm::chooseScen unsigned int index = x * probabilities.size() - 1; const std::string& scenario = theProbabilitiesPerScenario.at(index).first; - PixelFEDChannelCollection_ = qualityCollectionHandle->getDetSetBadPixelFedChannels(scenario); - pixelEfficiencies_.PixelFEDChannelCollection_ = qualityCollectionHandle->getDetSetBadPixelFedChannels(scenario); - + PixelFEDChannelCollection_ = std::make_unique(quality_map->at(scenario)); + pixelEfficiencies_.PixelFEDChannelCollection_ = std::make_unique(quality_map->at(scenario)); } } return PixelFEDChannelCollection_; diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h index 0e995ed971d2c..b0a3b3caec335 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h @@ -18,6 +18,7 @@ #include "CondFormats/SiPixelTransient/interface/SiPixelTemplate2D.h" #include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h" #include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" +#include "CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h" #include "boost/multi_array.hpp" typedef boost::multi_array array_2d; @@ -88,7 +89,9 @@ class SiPixelDigitizerAlgorithm { // std::unique_ptr &PixelFEDChannelCollection_); std::unique_ptr chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *); bool killBadFEDChannels() const; - + typedef std::unordered_map PixelFEDChannelCollectionMap; + const PixelFEDChannelCollectionMap* quality_map; + private: //Accessing Lorentz angle from DB: @@ -105,9 +108,8 @@ class SiPixelDigitizerAlgorithm { edm::ESHandle SiPixelDynamicInefficiency_; // For BadFEDChannel simulation - edm::ESHandle qualityCollectionHandle; edm::ESHandle scenarioProbabilityHandle; - + edm::ESHandle PixelFEDChannelCollectionMapHandle; // Define internal classes // definition class From 5ea7ba40bfff3c3fc7216c826390b44ce807bc55 Mon Sep 17 00:00:00 2001 From: Tatjana Date: Sat, 15 Dec 2018 22:08:05 +0100 Subject: [PATCH 29/30] Remove test and commented lines --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc | 3 --- .../SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h | 2 -- 2 files changed, 5 deletions(-) diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc index 90ad215aa8fe5..8f6dde28a9b4f 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.cc @@ -790,8 +790,6 @@ void SiPixelDigitizerAlgorithm::calculateInstlumiFactor(const std::vector &PixelFEDChannelCollect std::unique_ptr SiPixelDigitizerAlgorithm::chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *engine){ //Determine scenario to use for the current event based on pileup information @@ -817,7 +815,6 @@ std::unique_ptr SiPixelDigitizerAlgorithm::chooseScen if (pu0!=bunchCrossing.end()) { unsigned int PUBin = TrueInteractionList.at(p); // case delta PU=1, fix me - PUBin = 27; const auto& theProbabilitiesPerScenario = scenarioProbabilityHandle->getProbabilities(PUBin); std::vector probabilities; probabilities.reserve(theProbabilitiesPerScenario.size()); diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h index b0a3b3caec335..87c1abbb00e0a 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizerAlgorithm.h @@ -85,8 +85,6 @@ class SiPixelDigitizerAlgorithm { void calculateInstlumiFactor(const std::vector &ps, int bunchSpacing); // TODO: try to remove the duplication of logic... void setSimAccumulator(const std::map >& signalMap); - //void chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *, - // std::unique_ptr &PixelFEDChannelCollection_); std::unique_ptr chooseScenario(PileupMixingContent* puInfo, CLHEP::HepRandomEngine *); bool killBadFEDChannels() const; typedef std::unordered_map PixelFEDChannelCollectionMap; From 9873103cc15472a4d64439d7a0f2bbd99442b263 Mon Sep 17 00:00:00 2001 From: Tatjana Date: Sun, 16 Dec 2018 12:14:35 +0100 Subject: [PATCH 30/30] Remove commented line --- EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc index fa1f7bf1a58e6..8f140bac095e8 100644 --- a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc +++ b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc @@ -58,7 +58,6 @@ SiPixelRawToDigi::SiPixelRawToDigi( const edm::ParameterSet& conf ) usererrorlist = config_.getParameter > ("UserErrorList"); } tFEDRawDataCollection = consumes (config_.getParameter("InputLabel")); - // theBadPixelFEDChannelsLabel = consumes(edm::InputTag("mix")); theBadPixelFEDChannelsLabel = consumes(config_.getParameter("BadPixelFEDChannelsInputLabel")); //start counters