From 4b20456775f20d3b29e556528e362098de1044cf Mon Sep 17 00:00:00 2001 From: Tamas Date: Sun, 26 Sep 2021 17:16:43 +0200 Subject: [PATCH] Modernize SiPixel CPE object code in CondTools/SiPixel Move used CPE object code under plugins Change cout to LogPrint Migrate away from ES get Migrate away from ES get Modernize destructor Modernize EDAnalyzers Add back BuildFile Merge headers Add back FakeReader cfgs Remove commented code Fix BuildFile Modernize Fake DB readers Minor fix in Log msg Code checks Register plugins in fwk --- CondTools/SiPixel/plugins/BuildFile.xml | 6 + .../SiPixel2DTemplateDBObjectReader.cc | 177 ++++++++++------ .../SiPixel2DTemplateDBObjectUploader.cc | 130 +++++++----- .../SiPixelFakeGenErrorDBSourceReader.cc | 48 +++++ .../SiPixelFakeTemplateDBSourceReader.cc | 48 +++++ .../SiPixelGenErrorDBObjectReader.cc | 190 +++++++++++------- .../SiPixelGenErrorDBObjectUploader.cc | 133 +++++++----- .../SiPixelTemplateDBObjectReader.cc | 150 +++++++++----- .../SiPixelTemplateDBObjectUploader.cc | 138 ++++++++----- CondTools/SiPixel/test/SealModules.cc | 26 --- .../test/SiPixel2DTemplateDBObjectReader.h | 41 ---- .../test/SiPixel2DTemplateDBObjectUploader.h | 41 ---- .../test/SiPixelCPEGenericErrorParmReader.cc | 38 ---- .../test/SiPixelCPEGenericErrorParmReader.h | 29 --- .../SiPixelCPEGenericErrorParmReader_cfg.py | 37 ---- .../SiPixelCPEGenericErrorParmUploader.cc | 39 ---- .../test/SiPixelCPEGenericErrorParmUploader.h | 27 --- .../SiPixelCPEGenericErrorParmUploader_cfg.py | 41 ---- ...ixelFakeCPEGenericErrorParmSourceReader.cc | 25 --- ...PixelFakeCPEGenericErrorParmSourceReader.h | 30 --- ...FakeCPEGenericErrorParmSourceReader_cfg.py | 22 -- .../test/SiPixelFakeGenErrorDBSourceReader.cc | 23 --- .../test/SiPixelFakeGenErrorDBSourceReader.h | 30 --- .../test/SiPixelFakeTemplateDBSourceReader.cc | 23 --- .../test/SiPixelFakeTemplateDBSourceReader.h | 30 --- .../test/SiPixelGenErrorDBObjectReader.h | 39 ---- .../test/SiPixelGenErrorDBObjectUploader.h | 41 ---- .../test/SiPixelTemplateDBObjectReader.h | 41 ---- .../test/SiPixelTemplateDBObjectUploader.h | 41 ---- 29 files changed, 674 insertions(+), 1010 deletions(-) rename CondTools/SiPixel/{test => plugins}/SiPixel2DTemplateDBObjectReader.cc (60%) rename CondTools/SiPixel/{test => plugins}/SiPixel2DTemplateDBObjectUploader.cc (70%) create mode 100644 CondTools/SiPixel/plugins/SiPixelFakeGenErrorDBSourceReader.cc create mode 100644 CondTools/SiPixel/plugins/SiPixelFakeTemplateDBSourceReader.cc rename CondTools/SiPixel/{test => plugins}/SiPixelGenErrorDBObjectReader.cc (59%) rename CondTools/SiPixel/{test => plugins}/SiPixelGenErrorDBObjectUploader.cc (70%) rename CondTools/SiPixel/{test => plugins}/SiPixelTemplateDBObjectReader.cc (64%) rename CondTools/SiPixel/{test => plugins}/SiPixelTemplateDBObjectUploader.cc (69%) delete mode 100644 CondTools/SiPixel/test/SiPixel2DTemplateDBObjectReader.h delete mode 100644 CondTools/SiPixel/test/SiPixel2DTemplateDBObjectUploader.h delete mode 100644 CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader.cc delete mode 100644 CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader.h delete mode 100644 CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader_cfg.py delete mode 100644 CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader.cc delete mode 100644 CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader.h delete mode 100644 CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader_cfg.py delete mode 100644 CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader.cc delete mode 100644 CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader.h delete mode 100644 CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader_cfg.py delete mode 100644 CondTools/SiPixel/test/SiPixelFakeGenErrorDBSourceReader.cc delete mode 100644 CondTools/SiPixel/test/SiPixelFakeGenErrorDBSourceReader.h delete mode 100644 CondTools/SiPixel/test/SiPixelFakeTemplateDBSourceReader.cc delete mode 100644 CondTools/SiPixel/test/SiPixelFakeTemplateDBSourceReader.h delete mode 100644 CondTools/SiPixel/test/SiPixelGenErrorDBObjectReader.h delete mode 100644 CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader.h delete mode 100644 CondTools/SiPixel/test/SiPixelTemplateDBObjectReader.h delete mode 100644 CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader.h diff --git a/CondTools/SiPixel/plugins/BuildFile.xml b/CondTools/SiPixel/plugins/BuildFile.xml index 8b6c28ff1f2d3..c802e507d358e 100644 --- a/CondTools/SiPixel/plugins/BuildFile.xml +++ b/CondTools/SiPixel/plugins/BuildFile.xml @@ -1,4 +1,10 @@ + + + + + + diff --git a/CondTools/SiPixel/test/SiPixel2DTemplateDBObjectReader.cc b/CondTools/SiPixel/plugins/SiPixel2DTemplateDBObjectReader.cc similarity index 60% rename from CondTools/SiPixel/test/SiPixel2DTemplateDBObjectReader.cc rename to CondTools/SiPixel/plugins/SiPixel2DTemplateDBObjectReader.cc index 751f2e6f3b19c..c5e626349ab9c 100644 --- a/CondTools/SiPixel/test/SiPixel2DTemplateDBObjectReader.cc +++ b/CondTools/SiPixel/plugins/SiPixel2DTemplateDBObjectReader.cc @@ -1,46 +1,86 @@ -#include "CondTools/SiPixel/test/SiPixel2DTemplateDBObjectReader.h" #include #include #include #include +#include #include "FWCore/ParameterSet/interface/FileInPath.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESWatcher.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" + #include "MagneticField/Engine/interface/MagneticField.h" +#include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h" +#include "CondFormats/DataRecord/interface/SiPixel2DTemplateDBObjectRcd.h" +#include "CalibTracker/Records/interface/SiPixel2DTemplateDBObjectESProducerRcd.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" + +class SiPixel2DTemplateDBObjectReader : public edm::one::EDAnalyzer<> { +public: + explicit SiPixel2DTemplateDBObjectReader(const edm::ParameterSet&); + ~SiPixel2DTemplateDBObjectReader() override; + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + edm::ESWatcher SiPix2DTemplDBObjectWatcher_; + edm::ESWatcher SiPix2DTemplDBObjWatcher_; + + std::string the2DTemplateCalibrationLocation; + bool theDetailed2DTemplateDBErrorOutput; + bool theFull2DTemplateDBOutput; + bool testGlobalTag; + bool hasTriggeredWatcher; + edm::ESGetToken magneticFieldToken_; + edm::ESGetToken the2DTemplateESProdToken_; + edm::ESGetToken the2DTemplateToken_; +}; SiPixel2DTemplateDBObjectReader::SiPixel2DTemplateDBObjectReader(const edm::ParameterSet& iConfig) : the2DTemplateCalibrationLocation(iConfig.getParameter("siPixel2DTemplateCalibrationLocation")), theDetailed2DTemplateDBErrorOutput(iConfig.getParameter("wantDetailed2DTemplateDBErrorOutput")), theFull2DTemplateDBOutput(iConfig.getParameter("wantFull2DTemplateDBOutput")), testGlobalTag(iConfig.getParameter("TestGlobalTag")), - hasTriggeredWatcher(false) {} + hasTriggeredWatcher(false), + magneticFieldToken_(esConsumes()), + the2DTemplateESProdToken_(esConsumes()), + the2DTemplateToken_(esConsumes()) {} -SiPixel2DTemplateDBObjectReader::~SiPixel2DTemplateDBObjectReader() {} +SiPixel2DTemplateDBObjectReader::~SiPixel2DTemplateDBObjectReader() = default; void SiPixel2DTemplateDBObjectReader::beginJob() {} -void SiPixel2DTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm::EventSetup& setup) { +void SiPixel2DTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //To test with the ESProducer + SiPixel2DTemplateDBObject dbobject; if (testGlobalTag) { - edm::ESHandle magfield; - setup.get().get(magfield); + // Get magnetic field GlobalPoint center(0.0, 0.0, 0.0); + edm::ESHandle magfield = iSetup.getHandle(magneticFieldToken_); float theMagField = magfield.product()->inTesla(center).mag(); - std::cout << "\nTesting global tag at magfield = " << theMagField << std::endl; - if (SiPix2DTemplDBObjWatcher_.check(setup)) { - edm::ESHandle generrorH; - setup.get().get(generrorH); - dbobject = *generrorH.product(); + edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "\nTesting global tag at magnetic field = " << theMagField; + if (SiPix2DTemplDBObjWatcher_.check(iSetup)) { + edm::LogPrint("SiPixel2DTemplateDBObjectESProducerRcd") << "With record SiPixel2DTemplateDBObjectESProducerRcd"; + dbobject = *&iSetup.getData(the2DTemplateESProdToken_); hasTriggeredWatcher = true; } } else { - std::cout << "\nLoading from file " << std::endl; - if (SiPix2DTemplDBObjWatcher_.check(setup)) { - edm::ESHandle generrorH; - setup.get().get(generrorH); - dbobject = *generrorH.product(); + edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "\nLoading from file " << std::endl; + if (SiPix2DTemplDBObjWatcher_.check(iSetup)) { + edm::LogPrint("SiPixelTemplateDBObjectReader") << "With record SiPixel2DTemplateDBObjectRcd"; + dbobject = *&iSetup.getData(the2DTemplateToken_); hasTriggeredWatcher = true; } } @@ -48,31 +88,32 @@ void SiPixel2DTemplateDBObjectReader::analyze(const edm::Event& iEvent, const ed if (hasTriggeredWatcher) { std::vector tempMapId; - /*hp - if(theFull2DTemplateDBOutput) std::cout << "Map info" << std::endl; - std::map templMap=dbobject.get2DTemplateIDs(); - for(std::map::const_iterator it=templMap.begin(); it!=templMap.end();++it) { - if(tempMapId.size()==0) tempMapId.push_back(it->second); - for(unsigned int i=0; isecond) continue; - else if(i==tempMapId.size()-1) { - tempMapId.push_back(it->second); - break; - } - } - if(theFull2DTemplateDBOutput) - std::cout<< "DetId: "<< it->first<<" 2DTemplateID: "<< it->second<<"\n"; - } -hp*/ - - std::cout << "\nMap stores 2DTemplate Id(s): "; + if (theFull2DTemplateDBOutput) { + edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "Map info" << std::endl; + std::map templMap = dbobject.getTemplateIDs(); + for (std::map::const_iterator it = templMap.begin(); it != templMap.end(); ++it) { + if (tempMapId.empty()) + tempMapId.push_back(it->second); + for (unsigned int i = 0; i < tempMapId.size(); ++i) { + if (tempMapId[i] == it->second) + continue; + else if (i == tempMapId.size() - 1) { + tempMapId.push_back(it->second); + break; + } + } + edm::LogPrint("SiPixel2DTemplateDBObjectReader") + << "DetId: " << it->first << " 2DTemplateID: " << it->second << "\n"; + } + } + + edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "\nMap stores 2DTemplate Id(s): "; for (unsigned int vindex = 0; vindex < tempMapId.size(); ++vindex) - std::cout << tempMapId[vindex] << " "; - std::cout << std::endl; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") << tempMapId[vindex] << " "; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") << std::endl; //local variables const char* tempfile; - char c; int numOfTempl = dbobject.numOfTempl(); int index = 0; float tempnum = 0, diff = 0; @@ -80,15 +121,17 @@ hp*/ bool error = false, givenErrorMsg = false; ; - std::cout << "\nChecking 2DTemplate DB object version " << dbobject.version() << " containing " << numOfTempl - << " calibration(s) at " << dbobject.sVector()[index + 22] << "T\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") + << "\nChecking 2DTemplate DB object version " << dbobject.version() << " containing " << numOfTempl + << " calibration(s) at " << dbobject.sVector()[index + 22] << "T\n"; for (int i = 0; i < numOfTempl; ++i) { //Removes header in db object from diff index += 20; //Tell the person viewing the output what the 2DTemplate ID and version are -- note that version is only valid for >=13 - std::cout << "Calibration " << i + 1 << " of " << numOfTempl << ", with 2DTemplate ID " - << dbobject.sVector()[index] << "\tand Version " << dbobject.sVector()[index + 1] << "\t-------- "; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") + << "Calibration " << i + 1 << " of " << numOfTempl << ", with 2DTemplate ID " << dbobject.sVector()[index] + << "\tand Version " << dbobject.sVector()[index + 1] << "\t-------- "; //Opening the text-based 2DTemplate calibration std::ostringstream tout; @@ -102,9 +145,6 @@ hp*/ if (in_file.is_open()) { //Removes header in textfile from diff - for (int header = 0; (c = in_file.get()) != '\n'; ++header) { - } - //First read in from the text file -- this will be compared with index = 20 in_file >> tempnum; @@ -117,14 +157,15 @@ hp*/ if (diff > tol) { //We have the if statement to output the message only once if (!givenErrorMsg) - std::cout << "does NOT match\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "does NOT match\n"; //If there is an error we want to display a message upon completion error = true; givenErrorMsg = true; //Do we want more detailed output? if (theDetailed2DTemplateDBErrorOutput) { - std::cout << "from file = " << tempnum << "\t from dbobject = " << dbobject.sVector()[index] - << "\tdiff = " << diff << "\t db index = " << index << std::endl; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") + << "from file = " << tempnum << "\t from dbobject = " << dbobject.sVector()[index] + << "\tdiff = " << diff << "\t db index = " << index << std::endl; } } //Go to the next entries @@ -133,22 +174,23 @@ hp*/ } //There were no errors, the two files match. if (!givenErrorMsg) - std::cout << "MATCHES\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "MATCHES\n"; } //end current file in_file.close(); givenErrorMsg = false; } //end loop over all files if (error && !theDetailed2DTemplateDBErrorOutput) - std::cout << "\nThe were differences found between the files and the database.\n" - << "If you would like more detailed information please set\n" - << "wantDetailedOutput = True in the cfg file. If you would like a\n" - << "full output of the contents of the database file please set\n" - << "wantFullOutput = True. Make sure that you pipe the output to a\n" - << "log file. This could take a few minutes.\n\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") + << "\nThe were differences found between the files and the database.\n" + << "If you would like more detailed information please set\n" + << "wantDetailedOutput = True in the cfg file. If you would like a\n" + << "full output of the contents of the database file please set\n" + << "wantFullOutput = True. Make sure that you pipe the output to a\n" + << "log file. This could take a few minutes.\n\n"; if (theFull2DTemplateDBOutput) - std::cout << dbobject << std::endl; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") << dbobject << std::endl; } } @@ -167,25 +209,30 @@ std::ostream& operator<<(std::ostream& s, const SiPixel2DTemplateDBObject& dbobj //!-changes the size of the 2DTemplates based on the version int sizeSetter = 0, generrorVersion = 0; - std::cout << "\n\nDBobject version: " << dbobject.version() << std::endl; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "\n\nDBobject version: " << dbobject.version() << std::endl; for (m = 0; m < dbobject.numOfTempl(); ++m) { //To change the size of the output based on which 2DTemplate version we are using" generrorVersion = (int)dbobject.sVector_[index + 21]; if (generrorVersion <= 10) { - std::cout << "*****WARNING***** This code will not format this 2DTemplate version properly *****WARNING*****\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") + << "*****WARNING***** This code will not format this 2DTemplate version properly *****WARNING*****\n"; sizeSetter = 0; } else if (generrorVersion <= 16) sizeSetter = 1; else - std::cout << "*****WARNING***** This code has not been tested at formatting this version *****WARNING*****\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") + << "*****WARNING***** This code has not been tested at formatting this version *****WARNING*****\n"; - std::cout << "\n\n*********************************************************************************************" - << std::endl; - std::cout << "*************** Reading 2DTemplate ID " << dbobject.sVector_[index + 20] << "\t(" - << m + 1 << "/" << dbobject.numOfTempl_ << ") ***************" << std::endl; - std::cout << "*********************************************************************************************\n\n" - << std::endl; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") + << "\n\n*********************************************************************************************" + << std::endl; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") + << "*************** Reading 2DTemplate ID " << dbobject.sVector_[index + 20] << "\t(" << m + 1 + << "/" << dbobject.numOfTempl_ << ") ***************" << std::endl; + edm::LogPrint("SiPixel2DTemplateDBObjectReader") + << "*********************************************************************************************\n\n" + << std::endl; //Header Title SiPixel2DTemplateDBObject::char2float temp; @@ -341,3 +388,5 @@ std::ostream& operator<<(std::ostream& s, const SiPixel2DTemplateDBObject& dbobj } return s; } + +DEFINE_FWK_MODULE(SiPixel2DTemplateDBObjectReader); diff --git a/CondTools/SiPixel/test/SiPixel2DTemplateDBObjectUploader.cc b/CondTools/SiPixel/plugins/SiPixel2DTemplateDBObjectUploader.cc similarity index 70% rename from CondTools/SiPixel/test/SiPixel2DTemplateDBObjectUploader.cc rename to CondTools/SiPixel/plugins/SiPixel2DTemplateDBObjectUploader.cc index 763894b13acab..c361b9f1cc37f 100644 --- a/CondTools/SiPixel/test/SiPixel2DTemplateDBObjectUploader.cc +++ b/CondTools/SiPixel/plugins/SiPixel2DTemplateDBObjectUploader.cc @@ -1,5 +1,10 @@ -#include "CondTools/SiPixel/test/SiPixel2DTemplateDBObjectUploader.h" +#include +#include +#include +#include + #include "CondFormats/DataRecord/interface/SiPixel2DTemplateDBObjectRcd.h" +#include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" #include "FWCore/ServiceRegistry/interface/Service.h" @@ -15,9 +20,42 @@ #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h" #include "DataFormats/TrackerCommon/interface/PixelEndcapName.h" -#include -#include -#include +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" + +class SiPixel2DTemplateDBObjectUploader : public edm::one::EDAnalyzer<> { +public: + explicit SiPixel2DTemplateDBObjectUploader(const edm::ParameterSet&); + ~SiPixel2DTemplateDBObjectUploader() override; + + typedef std::vector vstring; + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + vstring theTemplateCalibrations; + std::string theTemplateBaseString; + float theVersion; + float theMagField; + std::vector theDetIds; + vstring theBarrelLocations; + vstring theEndcapLocations; + std::vector theBarrelTemplateIds; + std::vector theEndcapTemplateIds; + bool useVectorIndices; + edm::ESGetToken trackerGeometryToken_; + edm::ESGetToken trackerTopologyToken_; +}; SiPixel2DTemplateDBObjectUploader::SiPixel2DTemplateDBObjectUploader(const edm::ParameterSet& iConfig) : theTemplateCalibrations(iConfig.getParameter("siPixelTemplateCalibrations")), @@ -28,13 +66,15 @@ SiPixel2DTemplateDBObjectUploader::SiPixel2DTemplateDBObjectUploader(const edm:: theEndcapLocations(iConfig.getParameter >("endcapLocations")), theBarrelTemplateIds(iConfig.getParameter >("barrelTemplateIds")), theEndcapTemplateIds(iConfig.getParameter >("endcapTemplateIds")), - useVectorIndices(iConfig.getUntrackedParameter("useVectorIndices", false)) {} + useVectorIndices(iConfig.getUntrackedParameter("useVectorIndices", false)), + trackerGeometryToken_(esConsumes()), + trackerTopologyToken_(esConsumes()) {} -SiPixel2DTemplateDBObjectUploader::~SiPixel2DTemplateDBObjectUploader() {} +SiPixel2DTemplateDBObjectUploader::~SiPixel2DTemplateDBObjectUploader() = default; void SiPixel2DTemplateDBObjectUploader::beginJob() {} -void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const edm::EventSetup& es) { +void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //--- Make the POOL-ORA object to store the database object SiPixel2DTemplateDBObject* obj = new SiPixel2DTemplateDBObject; @@ -95,15 +135,12 @@ void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const } } - //get the event setup - edm::ESHandle pDD; - es.get().get(pDD); - const TrackerGeometry* tGeo = pDD.product(); + //get TrackerGeometry from the event setup + const edm::ESHandle pDD = iSetup.getHandle(trackerGeometryToken_); + const TrackerGeometry* tGeo = &iSetup.getData(trackerGeometryToken_); // Use the TrackerTopology class for layer/disk etc. number - edm::ESHandle tTopoHandle; - es.get().get(tTopoHandle); - const TrackerTopology* tTopo = tTopoHandle.product(); + const TrackerTopology* tTopo = &iSetup.getData(trackerTopologyToken_); // Check if we are using Phase-1 or Phase-2 geometry int phase = 0; @@ -112,7 +149,7 @@ void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const } else if (pDD->isThere(GeomDetEnumerators::P2PXB) && pDD->isThere(GeomDetEnumerators::P2PXEC) == true) { phase = 2; } - std::cout << "Phase-" << phase << " geometry is used" << std::endl; + edm::LogPrint("SiPixel2DTemplateDBObjectUploader") << "Phase-" << phase << " geometry is used" << std::endl; //Loop over the detector elements and put template IDs in place for (const auto& it : pDD->detUnits()) { @@ -120,8 +157,7 @@ void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const // Here is the actual looping step over all DetIds: DetId detid = it->geographicalId(); unsigned int layer = 0, ladder = 0, disk = 0, side = 0, blade = 0, panel = 0, module = 0; - // Some extra variables that can be used for Phase 1 - comment in if needed - // unsigned int shl=0, sec=0, half=0, flipped=0, ring=0; + short thisID = 10000; unsigned int iter; @@ -129,21 +165,13 @@ void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const //Barrel Pixels first if ((phase == 1 && detid.subdetId() == static_cast(PixelSubdetector::PixelBarrel)) || (phase == 2 && tGeo->geomDetSubDetector(detid.subdetId()) == GeomDetEnumerators::P2PXB)) { - std::cout << "--- IN THE BARREL ---\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectUploader") << "--- IN THE BARREL ---\n"; //Get the layer, ladder, and module corresponding to this detID layer = tTopo->pxbLayer(detid.rawId()); ladder = tTopo->pxbLadder(detid.rawId()); module = tTopo->pxbModule(detid.rawId()); - /* - // Comment these in if needed - PixelBarrelName pbn(detid, tTopo, phase); - shl = pbn.shell(); - sec = pbn.sectorName(); - half = pbn.isHalfModule(); - // This tells if we are on a flipped ladder (in the inner radius, closer to beam) - flipped = (phase ? layer==4 : layer%2) ? ladder%2==0 : ladder%2==1; - */ + if (useVectorIndices) { --layer; --ladder; @@ -156,8 +184,8 @@ void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const //get the string of this barrel location std::string loc_string = theBarrelLocations[iter]; //find where the delimiters are - unsigned int first_delim_pos = loc_string.find("_"); - unsigned int second_delim_pos = loc_string.find("_", first_delim_pos + 1); + unsigned int first_delim_pos = loc_string.find('_'); + unsigned int second_delim_pos = loc_string.find('_', first_delim_pos + 1); //get the layer, ladder, and module as unsigned ints unsigned int checklayer = (unsigned int)stoi(loc_string.substr(0, first_delim_pos)); unsigned int checkladder = @@ -170,28 +198,25 @@ void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const } if (thisID == 10000 || (!(*obj).putTemplateID(detid.rawId(), thisID))) - std::cout << " Could not fill barrel layer " << layer << ", module " << module << "\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectUploader") + << " Could not fill barrel layer " << layer << ", module " << module << "\n"; // ----- debug: - std::cout << "This is a barrel element with: layer " << layer << ", ladder " << ladder << " and module " - << module << ".\n"; //Uncomment to read out exact position of each element. - // ----- + edm::LogPrint("SiPixel2DTemplateDBObjectUploader") + << "This is a barrel element with: layer " << layer << ", ladder " << ladder << " and module " << module + << ".\n"; //Uncomment to read out exact position of each element. + // ----- } //Now endcaps else if ((phase == 1 && detid.subdetId() == static_cast(PixelSubdetector::PixelEndcap)) || (phase == 2 && tGeo->geomDetSubDetector(detid.subdetId()) == GeomDetEnumerators::P2PXEC)) { - std::cout << "--- IN AN ENDCAP ---\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectUploader") << "--- IN AN ENDCAP ---\n"; //Get the DetId's disk, blade, side, panel, and module disk = tTopo->pxfDisk(detid.rawId()); //1,2,3 blade = tTopo->pxfBlade(detid.rawId()); //1-56 (Ring 1 is 1-22, Ring 2 is 23-56) side = tTopo->pxfSide(detid.rawId()); //side=1 for -z, 2 for +z panel = tTopo->pxfPanel(detid.rawId()); //panel=1,2 - /* - // Comment these in if needed - PixelEndcapName pen(detid, tTopo, phase); - shl = pen.halfCylinder(); - ring = pen.ringName(); //1,2 This is for Phase I - */ + if (useVectorIndices) { --disk; --blade; @@ -206,9 +231,9 @@ void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const //get the string of this barrel location std::string loc_string = theEndcapLocations[iter]; //find where the delimiters are - unsigned int first_delim_pos = loc_string.find("_"); - unsigned int second_delim_pos = loc_string.find("_", first_delim_pos + 1); - unsigned int third_delim_pos = loc_string.find("_", second_delim_pos + 1); + unsigned int first_delim_pos = loc_string.find('_'); + unsigned int second_delim_pos = loc_string.find('_', first_delim_pos + 1); + unsigned int third_delim_pos = loc_string.find('_', second_delim_pos + 1); //get the disk, blade, side, panel, and module as unsigned ints unsigned int checkdisk = (unsigned int)stoi(loc_string.substr(0, first_delim_pos)); unsigned int checkblade = @@ -223,21 +248,24 @@ void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const } if (thisID == 10000 || (!(*obj).putTemplateID(detid.rawId(), thisID))) - std::cout << " Could not fill endcap det unit" << side << ", disk " << disk << ", blade " << blade - << ", and panel " << panel << ".\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectUploader") + << " Could not fill endcap det unit" << side << ", disk " << disk << ", blade " << blade << ", and panel " + << panel << ".\n"; // ----- debug: - std::cout << "This is an endcap element with: side " << side << ", disk " << disk << ", blade " << blade - << ", and panel " << panel << ".\n"; //Uncomment to read out exact position of each element. - // ----- + edm::LogPrint("SiPixel2DTemplateDBObjectUploader") + << "This is an endcap element with: side " << side << ", disk " << disk << ", blade " << blade + << ", and panel " << panel << ".\n"; //Uncomment to read out exact position of each element. + // ----- } else { continue; } //Print out the assignment of this detID short mapnum; - std::cout << "checking map:\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectUploader") << "checking map:\n"; mapnum = (*obj).getTemplateID(detid.rawId()); - std::cout << "The DetID: " << detid.rawId() << " is mapped to the template: " << mapnum << ".\n\n"; + edm::LogPrint("SiPixel2DTemplateDBObjectUploader") + << "The DetID: " << detid.rawId() << " is mapped to the template: " << mapnum << ".\n\n"; } } @@ -252,3 +280,5 @@ void SiPixel2DTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const } void SiPixel2DTemplateDBObjectUploader::endJob() {} + +DEFINE_FWK_MODULE(SiPixel2DTemplateDBObjectUploader); diff --git a/CondTools/SiPixel/plugins/SiPixelFakeGenErrorDBSourceReader.cc b/CondTools/SiPixel/plugins/SiPixelFakeGenErrorDBSourceReader.cc new file mode 100644 index 0000000000000..ee58efd5a853a --- /dev/null +++ b/CondTools/SiPixel/plugins/SiPixelFakeGenErrorDBSourceReader.cc @@ -0,0 +1,48 @@ +#include +#include + +#include "CondFormats/SiPixelObjects/interface/SiPixelGenErrorDBObject.h" +#include "CondFormats/DataRecord/interface/SiPixelGenErrorDBObjectRcd.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/EventSetup.h" + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESWatcher.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class SiPixelFakeGenErrorDBSourceReader : public edm::one::EDAnalyzer<> { +public: + explicit SiPixelFakeGenErrorDBSourceReader(const edm::ParameterSet&); + ~SiPixelFakeGenErrorDBSourceReader() override; + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + edm::ESWatcher SiPixelGenErrorDBObjectWatcher_; + edm::ESGetToken genErrToken_; +}; + +SiPixelFakeGenErrorDBSourceReader::SiPixelFakeGenErrorDBSourceReader(const edm::ParameterSet& iConfig) + : genErrToken_(esConsumes()) {} + +SiPixelFakeGenErrorDBSourceReader::~SiPixelFakeGenErrorDBSourceReader() = default; + +void SiPixelFakeGenErrorDBSourceReader::beginJob() {} + +void SiPixelFakeGenErrorDBSourceReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + if (SiPixelGenErrorDBObjectWatcher_.check(iSetup)) { + edm::LogPrint("SiPixelFakeGenErrorDBSourceReader") << *&iSetup.getData(genErrToken_) << std::endl; + } +} + +void SiPixelFakeGenErrorDBSourceReader::endJob() {} + +DEFINE_FWK_MODULE(SiPixelFakeGenErrorDBSourceReader); diff --git a/CondTools/SiPixel/plugins/SiPixelFakeTemplateDBSourceReader.cc b/CondTools/SiPixel/plugins/SiPixelFakeTemplateDBSourceReader.cc new file mode 100644 index 0000000000000..9086506bad713 --- /dev/null +++ b/CondTools/SiPixel/plugins/SiPixelFakeTemplateDBSourceReader.cc @@ -0,0 +1,48 @@ +#include +#include + +#include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h" +#include "CondFormats/DataRecord/interface/SiPixelTemplateDBObjectRcd.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/EventSetup.h" + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESWatcher.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class SiPixelFakeTemplateDBSourceReader : public edm::one::EDAnalyzer<> { +public: + explicit SiPixelFakeTemplateDBSourceReader(const edm::ParameterSet&); + ~SiPixelFakeTemplateDBSourceReader() override; + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + edm::ESWatcher SiPixelTemplateDBObjectWatcher_; + edm::ESGetToken the1DTemplateToken_; +}; + +SiPixelFakeTemplateDBSourceReader::SiPixelFakeTemplateDBSourceReader(const edm::ParameterSet& iConfig) + : the1DTemplateToken_(esConsumes()) {} + +SiPixelFakeTemplateDBSourceReader::~SiPixelFakeTemplateDBSourceReader() = default; + +void SiPixelFakeTemplateDBSourceReader::beginJob() {} + +void SiPixelFakeTemplateDBSourceReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + if (SiPixelTemplateDBObjectWatcher_.check(iSetup)) { + edm::LogPrint("SiPixelFakeTemplateDBSourceReader") << *&iSetup.getData(the1DTemplateToken_) << std::endl; + } +} + +void SiPixelFakeTemplateDBSourceReader::endJob() {} + +DEFINE_FWK_MODULE(SiPixelFakeTemplateDBSourceReader); diff --git a/CondTools/SiPixel/test/SiPixelGenErrorDBObjectReader.cc b/CondTools/SiPixel/plugins/SiPixelGenErrorDBObjectReader.cc similarity index 59% rename from CondTools/SiPixel/test/SiPixelGenErrorDBObjectReader.cc rename to CondTools/SiPixel/plugins/SiPixelGenErrorDBObjectReader.cc index 0873f02686fe8..a59af508f23f2 100644 --- a/CondTools/SiPixel/test/SiPixelGenErrorDBObjectReader.cc +++ b/CondTools/SiPixel/plugins/SiPixelGenErrorDBObjectReader.cc @@ -6,37 +6,68 @@ #include #include #include +#include #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "CondFormats/SiPixelTransient/interface/SiPixelGenError.h" -#include "CondTools/SiPixel/test/SiPixelGenErrorDBObjectReader.h" -using namespace std; +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESWatcher.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" + +#include "CondFormats/SiPixelObjects/interface/SiPixelGenErrorDBObject.h" +#include "CondFormats/DataRecord/interface/SiPixelGenErrorDBObjectRcd.h" +#include "CalibTracker/Records/interface/SiPixelGenErrorDBObjectESProducerRcd.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" + +class SiPixelGenErrorDBObjectReader : public edm::one::EDAnalyzer<> { +public: + explicit SiPixelGenErrorDBObjectReader(const edm::ParameterSet&); + ~SiPixelGenErrorDBObjectReader() override; + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + std::string theGenErrorCalibrationLocation; + bool theDetailedGenErrorDBErrorOutput; + bool theFullGenErrorDBOutput; + + edm::ESGetToken genErrToken_; +}; SiPixelGenErrorDBObjectReader::SiPixelGenErrorDBObjectReader(const edm::ParameterSet& iConfig) : theGenErrorCalibrationLocation(iConfig.getParameter("siPixelGenErrorCalibrationLocation")), theDetailedGenErrorDBErrorOutput(iConfig.getParameter("wantDetailedGenErrorDBErrorOutput")), - theFullGenErrorDBOutput(iConfig.getParameter("wantFullGenErrorDBOutput")) {} + theFullGenErrorDBOutput(iConfig.getParameter("wantFullGenErrorDBOutput")), + genErrToken_(esConsumes()) {} -SiPixelGenErrorDBObjectReader::~SiPixelGenErrorDBObjectReader() {} +SiPixelGenErrorDBObjectReader::~SiPixelGenErrorDBObjectReader() = default; void SiPixelGenErrorDBObjectReader::beginJob() {} -void SiPixelGenErrorDBObjectReader::analyze(const edm::Event& iEvent, const edm::EventSetup& setup) { - std::cout << "\nLoading ... " << std::endl; +void SiPixelGenErrorDBObjectReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + edm::LogPrint("SiPixelGenErrorDBObjectReader") << "\nLoading ... " << std::endl; - edm::ESHandle generrorH; - setup.get().get(generrorH); - dbobject = *generrorH.product(); - const SiPixelGenErrorDBObject* db = generrorH.product(); + SiPixelGenErrorDBObject dbobject = *&iSetup.getData(genErrToken_); + const SiPixelGenErrorDBObject* db = &iSetup.getData(genErrToken_); // these seem to be the only variables I can get directly from the object class - cout << " DBObject version " << dbobject.version() << " index " << dbobject.index() << " max " << dbobject.maxIndex() - << " fail " << dbobject.fail() << " numOfTeml " << dbobject.numOfTempl() << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << " DBObject version " << dbobject.version() << " index " << dbobject.index() << " max " << dbobject.maxIndex() + << " fail " << dbobject.fail() << " numOfTeml " << dbobject.numOfTempl() << std::endl; if (theFullGenErrorDBOutput) { - std::cout << "Map info" << std::endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << "Map info" << std::endl; std::vector tempMapId; std::map templMap = dbobject.getGenErrorIDs(); for (std::map::const_iterator it = templMap.begin(); it != templMap.end(); ++it) { @@ -51,32 +82,32 @@ void SiPixelGenErrorDBObjectReader::analyze(const edm::Event& iEvent, const edm: } } - std::cout << "DetId: " << it->first << " GenErrorID: " << it->second << "\n"; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << "DetId: " << it->first << " GenErrorID: " << it->second << "\n"; } - std::cout << "\nMap stores GenError Id(s): "; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << "\nMap stores GenError Id(s): "; for (unsigned int vindex = 0; vindex < tempMapId.size(); ++vindex) - std::cout << tempMapId[vindex] << " "; - std::cout << std::endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << tempMapId[vindex] << " "; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << std::endl; } // if the dircetory is an empty string ignore file comparison if (theGenErrorCalibrationLocation.empty()) { - cout << " no file for camparison defined, comparison will be skipped " << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << " no file for camparison defined, comparison will be skipped " << std::endl; } else { // do the file comparision - //if(compareWithFile) { bool error = false; - char c; int numOfTempl = dbobject.numOfTempl(); int index = 0; float tempnum = 0, diff = 0; float tol = 1.0E-23; bool givenErrorMsg = false; - std::cout << "\nChecking GenError DB object version " << dbobject.version() << " containing " << numOfTempl - << " calibration(s) at " << dbobject.sVector()[index + 22] << "T\n"; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << "\nChecking GenError DB object version " << dbobject.version() << " containing " << numOfTempl + << " calibration(s) at " << dbobject.sVector()[index + 22] << "T\n"; for (int i = 0; i < numOfTempl; ++i) { //Removes header in db object from diff @@ -84,26 +115,23 @@ void SiPixelGenErrorDBObjectReader::analyze(const edm::Event& iEvent, const edm: //Tell the person viewing the output what the GenError ID and version are -- note that version is only valid for >=13 // Does not work correctly for data - std::cout << "Calibration " << i + 1 << " of " << numOfTempl << ", with GenError ID " << dbobject.sVector()[index] - << "\tand Version " << dbobject.sVector()[index + 1] << "\t-------- " << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << "Calibration " << i + 1 << " of " << numOfTempl << ", with GenError ID " << dbobject.sVector()[index] + << "\tand Version " << dbobject.sVector()[index + 1] << "\t-------- " << std::endl; //Opening the text-based GenError calibration std::ostringstream tout; tout << theGenErrorCalibrationLocation.c_str() << "generror_summary_zp" << std::setw(4) << std::setfill('0') << std::right << dbobject.sVector()[index] << ".out" << std::ends; - //edm::FileInPath file( tout.str()); - //tempfile = (file.fullPath()).c_str(); - string temp = tout.str(); + std::string temp = tout.str(); std::ifstream in_file(temp.c_str(), std::ios::in); - cout << " open file " << tout.str() << " " << in_file.is_open() << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << " open file " << tout.str() << " " << in_file.is_open() << std::endl; if (in_file.is_open()) { //Removes header in textfile from diff - for (int header = 0; (c = in_file.get()) != '\n'; ++header) { - } - //First read in from the text file -- this will be compared with index = 20 in_file >> tempnum; @@ -116,14 +144,15 @@ void SiPixelGenErrorDBObjectReader::analyze(const edm::Event& iEvent, const edm: if (diff > tol) { //We have the if statement to output the message only once if (!givenErrorMsg) - std::cout << "does NOT match\n"; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << "does NOT match\n"; //If there is an error we want to display a message upon completion error = true; givenErrorMsg = true; //Do we want more detailed output? if (theDetailedGenErrorDBErrorOutput) { - std::cout << "from file = " << tempnum << "\t from dbobject = " << dbobject.sVector()[index] - << "\tdiff = " << diff << "\t db index = " << index << std::endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << "from file = " << tempnum << "\t from dbobject = " << dbobject.sVector()[index] + << "\tdiff = " << diff << "\t db index = " << index << std::endl; } } //Go to the next entries @@ -132,9 +161,10 @@ void SiPixelGenErrorDBObjectReader::analyze(const edm::Event& iEvent, const edm: } //There were no errors, the two files match. if (!givenErrorMsg) - std::cout << "MATCHES\n"; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << "MATCHES\n"; } else { //end current file - cout << " ERROR: cannot open file, comparison will be stopped" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << " ERROR: cannot open file, comparison will be stopped" << std::endl; break; } in_file.close(); @@ -143,27 +173,30 @@ void SiPixelGenErrorDBObjectReader::analyze(const edm::Event& iEvent, const edm: } //end loop over all files if (error && !theDetailedGenErrorDBErrorOutput) - cout << "\nThe were differences found between the files and the database.\n" - << "If you would like more detailed information please set\n" - << "wantDetailedOutput = True in the cfg file. If you would like a\n" - << "full output of the contents of the database file please set\n" - << "wantFullOutput = True. Make sure that you pipe the output to a\n" - << "log file. This could take a few minutes.\n\n"; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << "\nThe were differences found between the files and the database.\n" + << "If you would like more detailed information please set\n" + << "wantDetailedOutput = True in the cfg file. If you would like a\n" + << "full output of the contents of the database file please set\n" + << "wantFullOutput = True. Make sure that you pipe the output to a\n" + << "log file. This could take a few minutes.\n\n"; } // if compare // Try to interpret the object - vector thePixelGenError; - //const SiPixelGenErrorDBObject * ge = &dbobject; + std::vector thePixelGenError; bool status = SiPixelGenError::pushfile(*db, thePixelGenError); - cout << " status = " << status << " size = " << thePixelGenError.size() << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << " status = " << status << " size = " << thePixelGenError.size() << std::endl; SiPixelGenError genError(thePixelGenError); // these are all 0 because qbin() was not run. - cout << " some values " << genError.lorxwidth() << " " << genError.lorywidth() << " " << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << " some values " << genError.lorxwidth() << " " << genError.lorywidth() << " " << std::endl; // Print the full object, I think it does not work, the print is for templates. - //if(theFullGenErrorDBOutput) std::cout << dbobject << std::endl; + if (theFullGenErrorDBOutput) + edm::LogPrint("SiPixelGenErrorDBObjectReader") << dbobject << std::endl; } void SiPixelGenErrorDBObjectReader::endJob() {} @@ -183,31 +216,36 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec //!-changes the size of the GenErrors based on the version int sizeSetter = 1, generrorVersion = 0; - std::cout << "\n\nDBobject version: " << dbobject.version() << std::endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << "\n\nDBobject version: " << dbobject.version() << std::endl; for (m = 0; m < dbobject.numOfTempl(); ++m) { //To change the size of the output based on which GenError version we are using" generrorVersion = (int)dbobject.sVector_[index + 21]; - cout << " GenError version " << generrorVersion << " " << m << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " GenError version " << generrorVersion << " " << m << std::endl; if (generrorVersion <= 10) { - std::cout << "*****WARNING***** This code will not format this GenError version properly *****WARNING*****\n"; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << "*****WARNING***** This code will not format this GenError version properly *****WARNING*****\n"; sizeSetter = 0; } else if (generrorVersion <= 16) sizeSetter = 1; else - std::cout << "*****WARNING***** This code has not been tested at formatting this version *****WARNING*****\n"; - - std::cout << "\n\n*********************************************************************************************" - << std::endl; - std::cout << "*************** Reading GenError ID " << dbobject.sVector_[index + 20] << "\t(" - << m + 1 << "/" << dbobject.numOfTempl_ << ") ***************" << std::endl; - std::cout << "*********************************************************************************************\n\n" - << std::endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << "*****WARNING***** This code has not been tested at formatting this version *****WARNING*****\n"; + + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << "\n\n*********************************************************************************************" + << std::endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << "*************** Reading GenError ID " << dbobject.sVector_[index + 20] << "\t(" << m + 1 + << "/" << dbobject.numOfTempl_ << ") ***************" << std::endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") + << "*********************************************************************************************\n\n" + << std::endl; //Header Title - cout << " Header Title" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " Header Title" << std::endl; SiPixelGenErrorDBObject::char2float temp; for (n = 0; n < 20; ++n) { temp.f = dbobject.sVector_[index]; @@ -219,7 +257,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec entries[1] = (int)(dbobject.sVector_[index + 4] * dbobject.sVector_[index + 5]); // X //Header - cout << " Header " << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " Header " << std::endl; s << dbobject.sVector_[index] << "\t" << dbobject.sVector_[index + 1] << "\t" << dbobject.sVector_[index + 2] << "\t" << dbobject.sVector_[index + 3] << "\t" << dbobject.sVector_[index + 4] << "\t" << dbobject.sVector_[index + 5] << "\t" << dbobject.sVector_[index + 6] << "\t" << dbobject.sVector_[index + 7] @@ -230,7 +268,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec index += 17; //Loop over By,Bx,Fy,Fx - cout << " ByBxFyFx" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " ByBxFyFx" << std::endl; for (entry_it = 0; entry_it < 4; ++entry_it) { //Run,costrk,qavg,...,clslenx for (i = 0; i < entries[entry_it]; ++i) { @@ -246,7 +284,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec << dbobject.sVector_[index + 18] << std::endl; index += 19; //YPar - cout << " YPar" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " YPar" << std::endl; for (j = 0; j < 2; ++j) { for (k = 0; k < 5; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -255,7 +293,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //YTemp - cout << " YTemp" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " YTemp" << std::endl; for (j = 0; j < 9; ++j) { for (k = 0; k < tysize[sizeSetter]; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -264,7 +302,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //XPar - cout << " XPar" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " XPar" << std::endl; for (j = 0; j < 2; ++j) { for (k = 0; k < 5; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -273,7 +311,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //XTemp - cout << " Xtemp" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " Xtemp" << std::endl; for (j = 0; j < 9; ++j) { for (k = 0; k < txsize[sizeSetter]; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -282,7 +320,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //Y average reco params - cout << " Y average reco params " << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " Y average reco params " << std::endl; for (j = 0; j < 4; ++j) { for (k = 0; k < 4; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -291,7 +329,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //Yflpar - cout << " Yflar " << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " Yflar " << std::endl; for (j = 0; j < 4; ++j) { for (k = 0; k < 6; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -300,7 +338,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //X average reco params - cout << " X average reco params" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " X average reco params" << std::endl; for (j = 0; j < 4; ++j) { for (k = 0; k < 4; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -309,7 +347,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //Xflpar - cout << " Xflar" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " Xflar" << std::endl; for (j = 0; j < 4; ++j) { for (k = 0; k < 6; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -318,7 +356,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //Chi2X,Y - cout << " XY chi2" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " XY chi2" << std::endl; for (j = 0; j < 4; ++j) { for (k = 0; k < 2; ++k) { for (l = 0; l < 2; ++l) { @@ -329,7 +367,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //Y average Chi2 params - cout << " Y chi2" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " Y chi2" << std::endl; for (j = 0; j < 4; ++j) { for (k = 0; k < 4; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -338,7 +376,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //X average Chi2 params - cout << " X chi2" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " X chi2" << std::endl; for (j = 0; j < 4; ++j) { for (k = 0; k < 4; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -347,7 +385,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //Y average reco params for CPE Generic - cout << " Y reco params for generic" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " Y reco params for generic" << std::endl; for (j = 0; j < 4; ++j) { for (k = 0; k < 4; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -356,7 +394,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //X average reco params for CPE Generic - cout << " X reco params for generic" << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " X reco params for generic" << std::endl; for (j = 0; j < 4; ++j) { for (k = 0; k < 4; ++k) { s << dbobject.sVector_[index] << "\t"; @@ -365,7 +403,7 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec s << std::endl; } //SpareX,Y - cout << " Spare " << endl; + edm::LogPrint("SiPixelGenErrorDBObjectReader") << " Spare " << std::endl; for (j = 0; j < 20; ++j) { s << dbobject.sVector_[index] << "\t"; ++index; @@ -377,3 +415,5 @@ std::ostream& operator<<(std::ostream& s, const SiPixelGenErrorDBObject& dbobjec } return s; } + +DEFINE_FWK_MODULE(SiPixelGenErrorDBObjectReader); diff --git a/CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader.cc b/CondTools/SiPixel/plugins/SiPixelGenErrorDBObjectUploader.cc similarity index 70% rename from CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader.cc rename to CondTools/SiPixel/plugins/SiPixelGenErrorDBObjectUploader.cc index 794f29ced38f9..27eddce36590c 100644 --- a/CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader.cc +++ b/CondTools/SiPixel/plugins/SiPixelGenErrorDBObjectUploader.cc @@ -1,5 +1,10 @@ -#include "CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader.h" +#include +#include +#include +#include + #include "CondFormats/DataRecord/interface/SiPixelGenErrorDBObjectRcd.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelGenErrorDBObject.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" #include "FWCore/ServiceRegistry/interface/Service.h" @@ -14,9 +19,42 @@ #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h" #include "DataFormats/TrackerCommon/interface/PixelEndcapName.h" -#include -#include -#include +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" + +class SiPixelGenErrorDBObjectUploader : public edm::one::EDAnalyzer<> { +public: + explicit SiPixelGenErrorDBObjectUploader(const edm::ParameterSet&); + ~SiPixelGenErrorDBObjectUploader() override; + + typedef std::vector vstring; + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + vstring theGenErrorCalibrations; + std::string theGenErrorBaseString; + float theVersion; + float theMagField; + std::vector theDetIds; + vstring theBarrelLocations; + vstring theEndcapLocations; + std::vector theBarrelGenErrIds; + std::vector theEndcapGenErrIds; + bool useVectorIndices; + edm::ESGetToken trackerGeometryToken_; + edm::ESGetToken trackerTopologyToken_; +}; SiPixelGenErrorDBObjectUploader::SiPixelGenErrorDBObjectUploader(const edm::ParameterSet& iConfig) : theGenErrorCalibrations(iConfig.getParameter("siPixelGenErrorCalibrations")), @@ -27,13 +65,15 @@ SiPixelGenErrorDBObjectUploader::SiPixelGenErrorDBObjectUploader(const edm::Para theEndcapLocations(iConfig.getParameter >("endcapLocations")), theBarrelGenErrIds(iConfig.getParameter >("barrelGenErrIds")), theEndcapGenErrIds(iConfig.getParameter >("endcapGenErrIds")), - useVectorIndices(iConfig.getUntrackedParameter("useVectorIndices", false)) {} + useVectorIndices(iConfig.getUntrackedParameter("useVectorIndices", false)), + trackerGeometryToken_(esConsumes()), + trackerTopologyToken_(esConsumes()) {} -SiPixelGenErrorDBObjectUploader::~SiPixelGenErrorDBObjectUploader() {} +SiPixelGenErrorDBObjectUploader::~SiPixelGenErrorDBObjectUploader() = default; void SiPixelGenErrorDBObjectUploader::beginJob() {} -void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const edm::EventSetup& es) { +void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //--- Make the POOL-ORA object to store the database object SiPixelGenErrorDBObject* obj = new SiPixelGenErrorDBObject; @@ -86,9 +126,10 @@ void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const ed if ((title_char[k] == '@') && (title_char[k - 1] == 'T')) { double localMagField = (((int)title_char[k - 4]) - 48) * 10 + ((int)title_char[k - 2]) - 48; if (theMagField != localMagField) { - std::cout << "\n -------- WARNING -------- \n Magnetic field in the cfg is " << theMagField - << "T while it is " << title_char[k - 4] << title_char[k - 2] << title_char[k - 1] - << " in the header \n ------------------------- \n " << std::endl; + edm::LogPrint("SiPixelGenErrorDBObjectUploader") + << "\n -------- WARNING -------- \n Magnetic field in the cfg is " << theMagField << "T while it is " + << title_char[k - 4] << title_char[k - 2] << title_char[k - 1] + << " in the header \n ------------------------- \n " << std::endl; } } } @@ -108,15 +149,12 @@ void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const ed } } - //Get the event setup - edm::ESHandle pDD; - es.get().get(pDD); - const TrackerGeometry* tGeo = pDD.product(); + //get TrackerGeometry from the event setup + const edm::ESHandle pDD = iSetup.getHandle(trackerGeometryToken_); + const TrackerGeometry* tGeo = &iSetup.getData(trackerGeometryToken_); // Use the TrackerTopology class for layer/disk etc. number - edm::ESHandle tTopoHandle; - es.get().get(tTopoHandle); - const TrackerTopology* tTopo = tTopoHandle.product(); + const TrackerTopology* tTopo = &iSetup.getData(trackerTopologyToken_); // Check if we are using Phase-1 or Phase-2 geometry int phase = 0; @@ -125,7 +163,7 @@ void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const ed } else if (pDD->isThere(GeomDetEnumerators::P2PXB) && pDD->isThere(GeomDetEnumerators::P2PXEC) == true) { phase = 2; } - std::cout << "Phase-" << phase << " geometry is used" << std::endl; + edm::LogPrint("SiPixelGenErrorDBObjectUploader") << "Phase-" << phase << " geometry is used" << std::endl; //Loop over the detector elements and put the GenError IDs in place for (const auto& it : pDD->detUnits()) { @@ -142,21 +180,13 @@ void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const ed //Barrel Pixels first if ((phase == 1 && detid.subdetId() == static_cast(PixelSubdetector::PixelBarrel)) || (phase == 2 && tGeo->geomDetSubDetector(detid.subdetId()) == GeomDetEnumerators::P2PXB)) { - std::cout << "--- IN THE BARREL ---\n"; + edm::LogPrint("SiPixelGenErrorDBObjectUploader") << "--- IN THE BARREL ---\n"; //Get the layer, ladder, and module corresponding to this DetID layer = tTopo->pxbLayer(detid.rawId()); ladder = tTopo->pxbLadder(detid.rawId()); module = tTopo->pxbModule(detid.rawId()); - /* - // Comment these in if needed - PixelBarrelName pbn(detid, tTopo, phase); - shl = pbn.shell(); - sec = pbn.sectorName(); - half = pbn.isHalfModule(); - // This tells if we are on a flipped ladder (in the inner radius, closer to beam) - flipped = (phase ? layer==4 : layer%2) ? ladder%2==0 : ladder%2==1; - */ + if (useVectorIndices) { --layer; --ladder; @@ -169,8 +199,8 @@ void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const ed //get the string of this barrel location std::string loc_string = theBarrelLocations[iter]; //find where the delimiters are - unsigned int first_delim_pos = loc_string.find("_"); - unsigned int second_delim_pos = loc_string.find("_", first_delim_pos + 1); + unsigned int first_delim_pos = loc_string.find('_'); + unsigned int second_delim_pos = loc_string.find('_', first_delim_pos + 1); //get the layer, ladder, and module as unsigned ints unsigned int checklayer = (unsigned int)stoi(loc_string.substr(0, first_delim_pos)); unsigned int checkladder = @@ -183,28 +213,25 @@ void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const ed } if (thisID == 10000 || (!(*obj).putGenErrorID(detid.rawId(), thisID))) - std::cout << " Could not fill barrel layer " << layer << ", module " << module << "\n"; + edm::LogPrint("SiPixelGenErrorDBObjectUploader") + << " Could not fill barrel layer " << layer << ", module " << module << "\n"; // ----- debug: - std::cout << "This is a barrel element with: layer " << layer << ", ladder " << ladder << " and module " - << module << ".\n"; //Uncomment to read out exact position of each element. - // ----- + edm::LogPrint("SiPixelGenErrorDBObjectUploader") + << "This is a barrel element with: layer " << layer << ", ladder " << ladder << " and module " << module + << ".\n"; //Uncomment to read out exact position of each element. + // ----- } //Now endcaps else if ((phase == 1 && detid.subdetId() == static_cast(PixelSubdetector::PixelEndcap)) || (phase == 2 && tGeo->geomDetSubDetector(detid.subdetId()) == GeomDetEnumerators::P2PXEC)) { - std::cout << "--- IN AN ENDCAP ---\n"; + edm::LogPrint("SiPixelGenErrorDBObjectUploader") << "--- IN AN ENDCAP ---\n"; //Get the DetID's disk, blade, side, panel, and module disk = tTopo->pxfDisk(detid.rawId()); //1,2,3 blade = tTopo->pxfBlade(detid.rawId()); //1-56 (Ring 1 is 1-22, Ring 2 is 23-56) side = tTopo->pxfSide(detid.rawId()); //side=1 for -z, 2 for +z panel = tTopo->pxfPanel(detid.rawId()); //panel=1,2 - /* - // Comment these in if needed - PixelEndcapName pen(detid, tTopo, phase); - shl = pen.halfCylinder(); - ring = pen.ringName(); //1,2 This is for Phase I - */ + if (useVectorIndices) { --disk; --blade; @@ -218,9 +245,9 @@ void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const ed //get the string of this barrel location std::string loc_string = theEndcapLocations[iter]; //find where the delimiters are - unsigned int first_delim_pos = loc_string.find("_"); - unsigned int second_delim_pos = loc_string.find("_", first_delim_pos + 1); - unsigned int third_delim_pos = loc_string.find("_", second_delim_pos + 1); + unsigned int first_delim_pos = loc_string.find('_'); + unsigned int second_delim_pos = loc_string.find('_', first_delim_pos + 1); + unsigned int third_delim_pos = loc_string.find('_', second_delim_pos + 1); //get the disk, blade, side, panel, and module as unsigned ints unsigned int checkdisk = (unsigned int)stoi(loc_string.substr(0, first_delim_pos)); unsigned int checkblade = @@ -235,21 +262,23 @@ void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const ed } if (thisID == 10000 || (!(*obj).putGenErrorID(detid.rawId(), thisID))) - std::cout << " Could not fill endcap det unit" << side << ", disk " << disk << ", blade " << blade - << ", panel " << panel << ".\n"; + edm::LogPrint("SiPixelGenErrorDBObjectUploader") + << " Could not fill endcap det unit" << side << ", disk " << disk << ", blade " << blade << ", panel " + << panel << ".\n"; // ----- debug: - std::cout << "This is an endcap element with: side " << side << ", disk " << disk << ", blade " << blade - << ", panel " << panel << ".\n"; //Uncomment to read out exact position of each element. - // ----- + edm::LogPrint("SiPixelGenErrorDBObjectUploader") + << "This is an endcap element with: side " << side << ", disk " << disk << ", blade " << blade << ", panel " + << panel << ".\n"; //Uncomment to read out exact position of each element. } else { continue; } //Print out the assignment of this DetID short mapnum; - std::cout << "checking map:\n"; + edm::LogPrint("SiPixelGenErrorDBObjectUploader") << "checking map:\n"; mapnum = (*obj).getGenErrorID(detid.rawId()); - std::cout << "The DetID: " << detid.rawId() << " is mapped to the template: " << mapnum << ".\n\n"; + edm::LogPrint("SiPixelGenErrorDBObjectUploader") + << "The DetID: " << detid.rawId() << " is mapped to the template: " << mapnum << ".\n\n"; } } @@ -264,3 +293,5 @@ void SiPixelGenErrorDBObjectUploader::analyze(const edm::Event& iEvent, const ed } void SiPixelGenErrorDBObjectUploader::endJob() {} + +DEFINE_FWK_MODULE(SiPixelGenErrorDBObjectUploader); diff --git a/CondTools/SiPixel/test/SiPixelTemplateDBObjectReader.cc b/CondTools/SiPixel/plugins/SiPixelTemplateDBObjectReader.cc similarity index 64% rename from CondTools/SiPixel/test/SiPixelTemplateDBObjectReader.cc rename to CondTools/SiPixel/plugins/SiPixelTemplateDBObjectReader.cc index f3ae14594f4a1..579fa915173b9 100644 --- a/CondTools/SiPixel/test/SiPixelTemplateDBObjectReader.cc +++ b/CondTools/SiPixel/plugins/SiPixelTemplateDBObjectReader.cc @@ -1,46 +1,87 @@ -#include "CondTools/SiPixel/test/SiPixelTemplateDBObjectReader.h" #include #include #include #include +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESWatcher.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" + +#include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h" +#include "CondFormats/DataRecord/interface/SiPixelTemplateDBObjectRcd.h" +#include "CalibTracker/Records/interface/SiPixelTemplateDBObjectESProducerRcd.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "MagneticField/Engine/interface/MagneticField.h" #include "FWCore/ParameterSet/interface/FileInPath.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "MagneticField/Engine/interface/MagneticField.h" + +class SiPixelTemplateDBObjectReader : public edm::one::EDAnalyzer<> { +public: + explicit SiPixelTemplateDBObjectReader(const edm::ParameterSet&); + ~SiPixelTemplateDBObjectReader() override; + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + edm::ESWatcher SiPixTemplDBObjectWatcher_; + edm::ESWatcher SiPixTemplDBObjWatcher_; + + std::string theTemplateCalibrationLocation; + bool theDetailedTemplateDBErrorOutput; + bool theFullTemplateDBOutput; + bool testGlobalTag; + bool hasTriggeredWatcher; + edm::ESGetToken magneticFieldToken_; + edm::ESGetToken the1DTemplateESProdToken_; + edm::ESGetToken the1DTemplateToken_; +}; SiPixelTemplateDBObjectReader::SiPixelTemplateDBObjectReader(const edm::ParameterSet& iConfig) : theTemplateCalibrationLocation(iConfig.getParameter("siPixelTemplateCalibrationLocation")), theDetailedTemplateDBErrorOutput(iConfig.getParameter("wantDetailedTemplateDBErrorOutput")), theFullTemplateDBOutput(iConfig.getParameter("wantFullTemplateDBOutput")), testGlobalTag(iConfig.getParameter("TestGlobalTag")), - hasTriggeredWatcher(false) {} + hasTriggeredWatcher(false), + magneticFieldToken_(esConsumes()), + the1DTemplateESProdToken_(esConsumes()), + the1DTemplateToken_(esConsumes()) {} -SiPixelTemplateDBObjectReader::~SiPixelTemplateDBObjectReader() {} +SiPixelTemplateDBObjectReader::~SiPixelTemplateDBObjectReader() = default; void SiPixelTemplateDBObjectReader::beginJob() {} -void SiPixelTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm::EventSetup& setup) { +void SiPixelTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //To test with the ESProducer + SiPixelTemplateDBObject dbobject; if (testGlobalTag) { - edm::ESHandle magfield; - setup.get().get(magfield); + // Get magnetic field GlobalPoint center(0.0, 0.0, 0.0); + edm::ESHandle magfield = iSetup.getHandle(magneticFieldToken_); float theMagField = magfield.product()->inTesla(center).mag(); - std::cout << "\nTesting global tag at magfield = " << theMagField << std::endl; - if (SiPixTemplDBObjWatcher_.check(setup)) { - edm::ESHandle templateH; - setup.get().get(templateH); - dbobject = *templateH.product(); + edm::LogPrint("SiPixelTemplateDBObjectReader") << "\nTesting global tag at magfield = " << theMagField; + if (SiPixTemplDBObjWatcher_.check(iSetup)) { + edm::LogPrint("SiPixelTemplateDBObjectReader") << "With record SiPixelTemplateDBObjectESProducerRcd"; + dbobject = *&iSetup.getData(the1DTemplateESProdToken_); hasTriggeredWatcher = true; } } else { - std::cout << "\nLoading from file " << std::endl; - if (SiPixTemplDBObjWatcher_.check(setup)) { - edm::ESHandle templateH; - setup.get().get(templateH); - dbobject = *templateH.product(); + edm::LogPrint("SiPixelTemplateDBObjectReader") << "\nLoading from file " << std::endl; + if (SiPixTemplDBObjWatcher_.check(iSetup)) { + edm::LogPrint("SiPixelTemplateDBObjectReader") << "With record SiPixelTemplateDBObjectRcd"; + dbobject = *&iSetup.getData(the1DTemplateToken_); hasTriggeredWatcher = true; } } @@ -49,7 +90,7 @@ void SiPixelTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm: std::vector tempMapId; if (theFullTemplateDBOutput) - std::cout << "Map info" << std::endl; + edm::LogPrint("SiPixelTemplateDBObjectReader") << "Map info" << std::endl; std::map templMap = dbobject.getTemplateIDs(); for (std::map::const_iterator it = templMap.begin(); it != templMap.end(); ++it) { if (tempMapId.empty()) @@ -63,33 +104,34 @@ void SiPixelTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm: } } if (theFullTemplateDBOutput) - std::cout << "DetId: " << it->first << " TemplateID: " << it->second << "\n"; + edm::LogPrint("SiPixelTemplateDBObjectReader") + << "DetId: " << it->first << " TemplateID: " << it->second << "\n"; } - std::cout << "\nMap stores template Id(s): "; + edm::LogPrint("SiPixelTemplateDBObjectReader") << "\nMap stores template Id(s): "; for (unsigned int vindex = 0; vindex < tempMapId.size(); ++vindex) - std::cout << tempMapId[vindex] << " "; - std::cout << std::endl; + edm::LogPrint("SiPixelTemplateDBObjectReader") << tempMapId[vindex] << " "; + edm::LogPrint("SiPixelTemplateDBObjectReader") << std::endl; //local variables const char* tempfile; - char c; int numOfTempl = dbobject.numOfTempl(); int index = 0; float tempnum = 0, diff = 0; float tol = 1.0E-23; bool error = false, givenErrorMsg = false; - ; - std::cout << "\nChecking Template DB object version " << dbobject.version() << " containing " << numOfTempl - << " calibration(s) at " << dbobject.sVector()[index + 22] << "T\n"; + edm::LogPrint("SiPixelTemplateDBObjectReader") + << "\nChecking Template DB object version " << dbobject.version() << " containing " << numOfTempl + << " calibration(s) at " << dbobject.sVector()[index + 22] << "T\n"; for (int i = 0; i < numOfTempl; ++i) { //Removes header in db object from diff index += 20; //Tell the person viewing the output what the template ID and version are -- note that version is only valid for >=13 - std::cout << "Calibration " << i + 1 << " of " << numOfTempl << ", with Template ID " << dbobject.sVector()[index] - << "\tand Version " << dbobject.sVector()[index + 1] << "\t-------- "; + edm::LogPrint("SiPixelTemplateDBObjectReader") + << "Calibration " << i + 1 << " of " << numOfTempl << ", with Template ID " << dbobject.sVector()[index] + << "\tand Version " << dbobject.sVector()[index + 1] << "\t-------- "; //Opening the text-based template calibration std::ostringstream tout; @@ -102,9 +144,6 @@ void SiPixelTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm: if (in_file.is_open()) { //Removes header in textfile from diff - for (int header = 0; (c = in_file.get()) != '\n'; ++header) { - } - //First read in from the text file -- this will be compared with index = 20 in_file >> tempnum; @@ -117,14 +156,15 @@ void SiPixelTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm: if (diff > tol) { //We have the if statement to output the message only once if (!givenErrorMsg) - std::cout << "does NOT match\n"; + edm::LogPrint("SiPixelTemplateDBObjectReader") << "does NOT match\n"; //If there is an error we want to display a message upon completion error = true; givenErrorMsg = true; //Do we want more detailed output? if (theDetailedTemplateDBErrorOutput) { - std::cout << "from file = " << tempnum << "\t from dbobject = " << dbobject.sVector()[index] - << "\tdiff = " << diff << "\t db index = " << index << std::endl; + edm::LogPrint("SiPixelTemplateDBObjectReader") + << "from file = " << tempnum << "\t from dbobject = " << dbobject.sVector()[index] + << "\tdiff = " << diff << "\t db index = " << index << std::endl; } } //Go to the next entries @@ -133,22 +173,23 @@ void SiPixelTemplateDBObjectReader::analyze(const edm::Event& iEvent, const edm: } //There were no errors, the two files match. if (!givenErrorMsg) - std::cout << "MATCHES\n"; + edm::LogPrint("SiPixelTemplateDBObjectReader") << "MATCHES\n"; } //end current file in_file.close(); givenErrorMsg = false; } //end loop over all files if (error && !theDetailedTemplateDBErrorOutput) - std::cout << "\nThe were differences found between the files and the database.\n" - << "If you would like more detailed information please set\n" - << "wantDetailedOutput = True in the cfg file. If you would like a\n" - << "full output of the contents of the database file please set\n" - << "wantFullOutput = True. Make sure that you pipe the output to a\n" - << "log file. This could take a few minutes.\n\n"; + edm::LogPrint("SiPixelTemplateDBObjectReader") + << "\nThe were differences found between the files and the database.\n" + << "If you would like more detailed information please set\n" + << "wantDetailedOutput = True in the cfg file. If you would like a\n" + << "full output of the contents of the database file please set\n" + << "wantFullOutput = True. Make sure that you pipe the output to a\n" + << "log file. This could take a few minutes.\n\n"; if (theFullTemplateDBOutput) - std::cout << dbobject << std::endl; + edm::LogPrint("SiPixelTemplateDBObjectReader") << dbobject << std::endl; } } @@ -167,25 +208,30 @@ std::ostream& operator<<(std::ostream& s, const SiPixelTemplateDBObject& dbobjec //!-changes the size of the templates based on the version int sizeSetter = 0, templateVersion = 0; - std::cout << "\n\nDBobject version: " << dbobject.version() << std::endl; + edm::LogPrint("SiPixelTemplateDBObjectReader") << "\n\nDBobject version: " << dbobject.version() << std::endl; for (m = 0; m < dbobject.numOfTempl(); ++m) { //To change the size of the output based on which template version we are using" templateVersion = (int)dbobject.sVector_[index + 21]; if (templateVersion <= 10) { - std::cout << "*****WARNING***** This code will not format this template version properly *****WARNING*****\n"; + edm::LogPrint("SiPixelTemplateDBObjectReader") + << "*****WARNING***** This code will not format this template version properly *****WARNING*****\n"; sizeSetter = 0; } else if (templateVersion <= 16) sizeSetter = 1; else - std::cout << "*****WARNING***** This code has not been tested at formatting this version *****WARNING*****\n"; + edm::LogPrint("SiPixelTemplateDBObjectReader") + << "*****WARNING***** This code has not been tested at formatting this version *****WARNING*****\n"; - std::cout << "\n\n*********************************************************************************************" - << std::endl; - std::cout << "*************** Reading Template ID " << dbobject.sVector_[index + 20] << "\t(" - << m + 1 << "/" << dbobject.numOfTempl_ << ") ***************" << std::endl; - std::cout << "*********************************************************************************************\n\n" - << std::endl; + edm::LogPrint("SiPixelTemplateDBObjectReader") + << "\n\n*********************************************************************************************" + << std::endl; + edm::LogPrint("SiPixelTemplateDBObjectReader") + << "*************** Reading Template ID " << dbobject.sVector_[index + 20] << "\t(" << m + 1 + << "/" << dbobject.numOfTempl_ << ") ***************" << std::endl; + edm::LogPrint("SiPixelTemplateDBObjectReader") + << "*********************************************************************************************\n\n" + << std::endl; //Header Title SiPixelTemplateDBObject::char2float temp; @@ -341,3 +387,5 @@ std::ostream& operator<<(std::ostream& s, const SiPixelTemplateDBObject& dbobjec } return s; } + +DEFINE_FWK_MODULE(SiPixelTemplateDBObjectReader); diff --git a/CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader.cc b/CondTools/SiPixel/plugins/SiPixelTemplateDBObjectUploader.cc similarity index 69% rename from CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader.cc rename to CondTools/SiPixel/plugins/SiPixelTemplateDBObjectUploader.cc index 1740153b3833b..9a2c0892e938e 100644 --- a/CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader.cc +++ b/CondTools/SiPixel/plugins/SiPixelTemplateDBObjectUploader.cc @@ -1,5 +1,10 @@ -#include "CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader.h" +#include +#include +#include +#include + #include "CondFormats/DataRecord/interface/SiPixelTemplateDBObjectRcd.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" #include "FWCore/ServiceRegistry/interface/Service.h" @@ -15,9 +20,42 @@ #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h" #include "DataFormats/TrackerCommon/interface/PixelEndcapName.h" -#include -#include -#include +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" + +class SiPixelTemplateDBObjectUploader : public edm::one::EDAnalyzer<> { +public: + explicit SiPixelTemplateDBObjectUploader(const edm::ParameterSet&); + ~SiPixelTemplateDBObjectUploader() override; + + typedef std::vector vstring; + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + vstring theTemplateCalibrations; + std::string theTemplateBaseString; + float theVersion; + float theMagField; + std::vector theDetIds; + vstring theBarrelLocations; + vstring theEndcapLocations; + std::vector theBarrelTemplateIds; + std::vector theEndcapTemplateIds; + bool useVectorIndices; + edm::ESGetToken trackerGeometryToken_; + edm::ESGetToken trackerTopologyToken_; +}; SiPixelTemplateDBObjectUploader::SiPixelTemplateDBObjectUploader(const edm::ParameterSet& iConfig) : theTemplateCalibrations(iConfig.getParameter("siPixelTemplateCalibrations")), @@ -28,13 +66,15 @@ SiPixelTemplateDBObjectUploader::SiPixelTemplateDBObjectUploader(const edm::Para theEndcapLocations(iConfig.getParameter >("endcapLocations")), theBarrelTemplateIds(iConfig.getParameter >("barrelTemplateIds")), theEndcapTemplateIds(iConfig.getParameter >("endcapTemplateIds")), - useVectorIndices(iConfig.getUntrackedParameter("useVectorIndices", false)) {} + useVectorIndices(iConfig.getUntrackedParameter("useVectorIndices", false)), + trackerGeometryToken_(esConsumes()), + trackerTopologyToken_(esConsumes()) {} -SiPixelTemplateDBObjectUploader::~SiPixelTemplateDBObjectUploader() {} +SiPixelTemplateDBObjectUploader::~SiPixelTemplateDBObjectUploader() = default; void SiPixelTemplateDBObjectUploader::beginJob() {} -void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const edm::EventSetup& es) { +void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //--- Make the POOL-ORA object to store the database object SiPixelTemplateDBObject obj; @@ -50,7 +90,7 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed auto tempfile = (file.fullPath()); std::ifstream in_file(tempfile.c_str(), std::ios::in); if (in_file.is_open()) { - edm::LogInfo("Template Info") << "Opened Template File: " << file.fullPath().c_str(); + edm::LogInfo("SiPixelTemplateDBObjectUploader") << "Opened Template File: " << file.fullPath().c_str(); // Local variables char title_char[80], c; @@ -82,9 +122,10 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed if ((title_char[k] == '@') && (title_char[k - 1] == 'T')) { double localMagField = (((int)title_char[k - 4]) - 48) * 10 + ((int)title_char[k - 2]) - 48; if (theMagField != localMagField) { - std::cout << "\n -------- WARNING -------- \n Magnetic field in the cfg is " << theMagField - << "T while it is " << title_char[k - 4] << title_char[k - 2] << title_char[k - 1] - << " in the header \n ------------------------- \n " << std::endl; + edm::LogPrint("SiPixelTemplateDBObjectUploader") + << "\n -------- WARNING -------- \n Magnetic field in the cfg is " << theMagField << "T while it is " + << title_char[k - 4] << title_char[k - 2] << title_char[k - 1] + << " in the header \n ------------------------- \n " << std::endl; } } } @@ -104,15 +145,12 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed } } - // Get the event setup - edm::ESHandle pDD; - es.get().get(pDD); - const TrackerGeometry* tGeo = pDD.product(); + //get TrackerGeometry from the event setup + const edm::ESHandle pDD = iSetup.getHandle(trackerGeometryToken_); + const TrackerGeometry* tGeo = &iSetup.getData(trackerGeometryToken_); // Use the TrackerTopology class for layer/disk etc. number - edm::ESHandle tTopoHandle; - es.get().get(tTopoHandle); - const TrackerTopology* tTopo = tTopoHandle.product(); + const TrackerTopology* tTopo = &iSetup.getData(trackerTopologyToken_); // Check if we are using Phase-1 or Phase-2 geometry int phase = 0; @@ -121,7 +159,7 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed } else if (pDD->isThere(GeomDetEnumerators::P2PXB) && pDD->isThere(GeomDetEnumerators::P2PXEC) == true) { phase = 2; } - std::cout << "Phase-" << phase << " geometry is used \n" << std::endl; + edm::LogPrint("SiPixelTemplateDBObjectUploader") << "Phase-" << phase << " geometry is used \n" << std::endl; //Loop over the detector elements and put template IDs in place for (const auto& it : pDD->detUnits()) { @@ -129,8 +167,6 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed // Here is the actual looping step over all DetIds: DetId detid = it->geographicalId(); unsigned int layer = 0, ladder = 0, disk = 0, side = 0, blade = 0, panel = 0, module = 0; - // Some extra variables that can be used for Phase 1 - comment in if needed - // unsigned int shl=0, sec=0, half=0, flipped=0, ring=0; short thisID = 10000; unsigned int iter; @@ -138,21 +174,13 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed //Barrel Pixels first if ((phase == 1 && detid.subdetId() == static_cast(PixelSubdetector::PixelBarrel)) || (phase == 2 && tGeo->geomDetSubDetector(detid.subdetId()) == GeomDetEnumerators::P2PXB)) { - std::cout << "--- IN THE BARREL ---\n"; + edm::LogPrint("SiPixelTemplateDBObjectUploader") << "--- IN THE BARREL ---\n"; //Get the layer, ladder, and module corresponding to this detID layer = tTopo->pxbLayer(detid.rawId()); ladder = tTopo->pxbLadder(detid.rawId()); module = tTopo->pxbModule(detid.rawId()); - /* - // Comment these in if needed - PixelBarrelName pbn(detid, tTopo, phase); - shl = pbn.shell(); - sec = pbn.sectorName(); - half = pbn.isHalfModule(); - // This tells if we are on a flipped ladder (in the inner radius, closer to beam) - flipped = (phase ? layer==4 : layer%2) ? ladder%2==0 : ladder%2==1; - */ + if (useVectorIndices) { --layer; --ladder; @@ -165,8 +193,8 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed //get the string of this barrel location std::string loc_string = theBarrelLocations[iter]; //find where the delimiters are - unsigned int first_delim_pos = loc_string.find("_"); - unsigned int second_delim_pos = loc_string.find("_", first_delim_pos + 1); + unsigned int first_delim_pos = loc_string.find('_'); + unsigned int second_delim_pos = loc_string.find('_', first_delim_pos + 1); //get the layer, ladder, and module as unsigned ints unsigned int checklayer = (unsigned int)stoi(loc_string.substr(0, first_delim_pos)); unsigned int checkladder = @@ -179,28 +207,25 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed } if (thisID == 10000 || (!obj.putTemplateID(detid.rawId(), thisID))) - std::cout << " Could not fill barrel layer " << layer << ", module " << module << "\n"; + edm::LogPrint("SiPixelTemplateDBObjectUploader") + << " Could not fill barrel layer " << layer << ", module " << module << "\n"; // ----- debug: - std::cout << "This is a barrel element with: layer " << layer << ", ladder " << ladder << " and module " - << module << ".\n"; //Uncomment to read out exact position of each element. - // ----- + edm::LogPrint("SiPixelTemplateDBObjectUploader") + << "This is a barrel element with: layer " << layer << ", ladder " << ladder << " and module " << module + << ".\n"; //Uncomment to read out exact position of each element. + // ----- } //Now endcaps else if ((phase == 1 && detid.subdetId() == static_cast(PixelSubdetector::PixelEndcap)) || (phase == 2 && tGeo->geomDetSubDetector(detid.subdetId()) == GeomDetEnumerators::P2PXEC)) { - std::cout << "--- IN AN ENDCAP ---\n"; + edm::LogPrint("SiPixelTemplateDBObjectUploader") << "--- IN AN ENDCAP ---\n"; //Get the DetId's disk, blade, side, panel, and module disk = tTopo->pxfDisk(detid.rawId()); //1,2,3 blade = tTopo->pxfBlade(detid.rawId()); //1-56 (Ring 1 is 1-22, Ring 2 is 23-56) side = tTopo->pxfSide(detid.rawId()); //side=1 for -z, 2 for +z panel = tTopo->pxfPanel(detid.rawId()); //panel=1,2 - /* - // Comment these in if needed - PixelEndcapName pen(detid, tTopo, phase); - shl = pen.halfCylinder(); - ring = pen.ringName(); //1,2 This is for Phase I - */ + if (useVectorIndices) { --disk; --blade; @@ -209,15 +234,14 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed } //Assign IDs - //Loop over all the endcap locations for (iter = 0; iter < theEndcapLocations.size(); ++iter) { //get the string of this barrel location std::string loc_string = theEndcapLocations[iter]; //find where the delimiters are - unsigned int first_delim_pos = loc_string.find("_"); - unsigned int second_delim_pos = loc_string.find("_", first_delim_pos + 1); - unsigned int third_delim_pos = loc_string.find("_", second_delim_pos + 1); + unsigned int first_delim_pos = loc_string.find('_'); + unsigned int second_delim_pos = loc_string.find('_', first_delim_pos + 1); + unsigned int third_delim_pos = loc_string.find('_', second_delim_pos + 1); //get the disk, blade, side, panel, and module as unsigned ints unsigned int checkdisk = (unsigned int)stoi(loc_string.substr(0, first_delim_pos)); unsigned int checkblade = @@ -232,21 +256,23 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed } if (thisID == 10000 || (!obj.putTemplateID(detid.rawId(), thisID))) - std::cout << " Could not fill endcap det unit" << side << ", disk " << disk << ", blade " << blade - << ", and panel " << panel << ".\n"; + edm::LogPrint("SiPixelTemplateDBObjectUploader") + << " Could not fill endcap det unit" << side << ", disk " << disk << ", blade " << blade << ", and panel " + << panel << ".\n"; // ----- debug: - std::cout << "This is an endcap element with: side " << side << ", disk " << disk << ", blade " << blade - << ", and panel " << panel << ".\n"; //Uncomment to read out exact position of each element. - // ----- + edm::LogPrint("SiPixelTemplateDBObjectUploader") + << "This is an endcap element with: side " << side << ", disk " << disk << ", blade " << blade + << ", and panel " << panel << ".\n"; //Uncomment to read out exact position of each element. } else { continue; } //Print out the assignment of this detID short mapnum; - std::cout << "checking map:\n"; + edm::LogPrint("SiPixelTemplateDBObjectUploader") << "checking map:\n"; mapnum = obj.getTemplateID(detid.rawId()); - std::cout << "The DetID: " << detid.rawId() << " is mapped to the template: " << mapnum << ".\n\n"; + edm::LogPrint("SiPixelTemplateDBObjectUploader") + << "The DetID: " << detid.rawId() << " is mapped to the template: " << mapnum << ".\n\n"; } } @@ -261,3 +287,5 @@ void SiPixelTemplateDBObjectUploader::analyze(const edm::Event& iEvent, const ed } void SiPixelTemplateDBObjectUploader::endJob() {} + +DEFINE_FWK_MODULE(SiPixelTemplateDBObjectUploader); diff --git a/CondTools/SiPixel/test/SealModules.cc b/CondTools/SiPixel/test/SealModules.cc index 1bfeae7957096..45a15b4007869 100644 --- a/CondTools/SiPixel/test/SealModules.cc +++ b/CondTools/SiPixel/test/SealModules.cc @@ -26,21 +26,6 @@ #include "CondTools/SiPixel/test/SiPixelPerformanceSummaryBuilder.h" #include "CondTools/SiPixel/test/SiPixelPerformanceSummaryReader.h" -#include "CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader.h" -#include "CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader.h" -#include "CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader.h" - -#include "CondTools/SiPixel/test/SiPixelFakeTemplateDBSourceReader.h" -#include "CondTools/SiPixel/test/SiPixelTemplateDBObjectReader.h" -#include "CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader.h" - -#include "CondTools/SiPixel/test/SiPixel2DTemplateDBObjectReader.h" -#include "CondTools/SiPixel/test/SiPixel2DTemplateDBObjectUploader.h" - -#include "CondTools/SiPixel/test/SiPixelFakeGenErrorDBSourceReader.h" -#include "CondTools/SiPixel/test/SiPixelGenErrorDBObjectReader.h" -#include "CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader.h" - #include "CondFormats/DataRecord/interface/PixelDCSRcds.h" #include "CondFormats/SiPixelObjects/interface/PixelDCSObject.h" #include "CondTools/SiPixel/test/PixelDCSObjectReader.h" @@ -74,15 +59,4 @@ DEFINE_FWK_MODULE(SiPixelBadModuleByHandBuilder); DEFINE_FWK_MODULE(SiPixelBadModuleReader); DEFINE_FWK_MODULE(SiPixelGainCalibrationReadDQMFile); DEFINE_FWK_MODULE(SiPixelGainCalibrationRejectNoisyAndDead); -DEFINE_FWK_MODULE(SiPixelCPEGenericErrorParmReader); -DEFINE_FWK_MODULE(SiPixelCPEGenericErrorParmUploader); -DEFINE_FWK_MODULE(SiPixelFakeCPEGenericErrorParmSourceReader); -DEFINE_FWK_MODULE(SiPixelTemplateDBObjectReader); -DEFINE_FWK_MODULE(SiPixelTemplateDBObjectUploader); -DEFINE_FWK_MODULE(SiPixelFakeTemplateDBSourceReader); -DEFINE_FWK_MODULE(SiPixel2DTemplateDBObjectUploader); -DEFINE_FWK_MODULE(SiPixel2DTemplateDBObjectReader); -DEFINE_FWK_MODULE(SiPixelGenErrorDBObjectReader); -DEFINE_FWK_MODULE(SiPixelGenErrorDBObjectUploader); -DEFINE_FWK_MODULE(SiPixelFakeGenErrorDBSourceReader); DEFINE_FWK_MODULE(PixelDCSObjectReader); diff --git a/CondTools/SiPixel/test/SiPixel2DTemplateDBObjectReader.h b/CondTools/SiPixel/test/SiPixel2DTemplateDBObjectReader.h deleted file mode 100644 index f8c74f2aad5ef..0000000000000 --- a/CondTools/SiPixel/test/SiPixel2DTemplateDBObjectReader.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixel2DTemplateDBObjectReader_h -#define CondTools_SiPixel_SiPixel2DTemplateDBObjectReader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESWatcher.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h" -#include "CondFormats/DataRecord/interface/SiPixel2DTemplateDBObjectRcd.h" -#include "CalibTracker/Records/interface/SiPixel2DTemplateDBObjectESProducerRcd.h" - -class SiPixel2DTemplateDBObjectReader : public edm::EDAnalyzer { -public: - explicit SiPixel2DTemplateDBObjectReader(const edm::ParameterSet&); - ~SiPixel2DTemplateDBObjectReader(); - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - - edm::ESWatcher SiPix2DTemplDBObjectWatcher_; - edm::ESWatcher SiPix2DTemplDBObjWatcher_; - - std::string the2DTemplateCalibrationLocation; - bool theDetailed2DTemplateDBErrorOutput; - bool theFull2DTemplateDBOutput; - bool testGlobalTag; - - SiPixel2DTemplateDBObject dbobject; - bool hasTriggeredWatcher; -}; - -#endif diff --git a/CondTools/SiPixel/test/SiPixel2DTemplateDBObjectUploader.h b/CondTools/SiPixel/test/SiPixel2DTemplateDBObjectUploader.h deleted file mode 100644 index 9637bb0101fef..0000000000000 --- a/CondTools/SiPixel/test/SiPixel2DTemplateDBObjectUploader.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixel2DTemplateDBObjectUploader_h -#define CondTools_SiPixel_SiPixel2DTemplateDBObjectUploader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h" - -class SiPixel2DTemplateDBObjectUploader : public edm::EDAnalyzer { -public: - explicit SiPixel2DTemplateDBObjectUploader(const edm::ParameterSet&); - ~SiPixel2DTemplateDBObjectUploader(); - - typedef std::vector vstring; - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - - vstring theTemplateCalibrations; - std::string theTemplateBaseString; - float theVersion; - float theMagField; - std::vector theDetIds; - vstring theBarrelLocations; - vstring theEndcapLocations; - std::vector theBarrelTemplateIds; - std::vector theEndcapTemplateIds; - bool useVectorIndices; -}; - -#endif diff --git a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader.cc b/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader.cc deleted file mode 100644 index 6ac14b6fc3ef9..0000000000000 --- a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader.cc +++ /dev/null @@ -1,38 +0,0 @@ -#include "CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader.h" -#include "CondFormats/SiPixelObjects/interface/SiPixelCPEGenericErrorParm.h" -#include "CalibTracker/SiPixelESProducers/interface/SiPixelCPEGenericDBErrorParametrization.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include - -SiPixelCPEGenericErrorParmReader::SiPixelCPEGenericErrorParmReader(const edm::ParameterSet& iConfig) {} - -SiPixelCPEGenericErrorParmReader::~SiPixelCPEGenericErrorParmReader() {} - -void SiPixelCPEGenericErrorParmReader::beginJob() {} - -void SiPixelCPEGenericErrorParmReader::analyze(const edm::Event& iEvent, const edm::EventSetup& setup) { - if (SiPixelCPEGenericErrorParmWatcher_.check(setup)) { - edm::ESHandle errorsH; - setup.get().get(errorsH); - - std::cout << *errorsH.product(); - - //uncomment to test random access - /* SiPixelCPEGenericDBErrorParametrization theErrorGetter; - theErrorGetter.setDBAccess(setup); - std::pair dbentry; - - dbentry = theErrorGetter.getError(GeomDetEnumerators::PixelBarrel, 3, 3, 1.57, 2.72, true, true); - - std::cout << "\n\n\n---------------------------------------------------------------------\n\n" - << "This test was written for version 1.3. We are using version: " << (*errorsH.product()).version() - << "\n\nFor Barrel, size x = 3, size y = 3, alpha = 1.57, beta = 2.72\n" - << "By hand the indices should be for bx and by respectively: 346, 99\n" - << "And the errors should be 0.000289 and 0.003431\nThey are: " - << dbentry.first << " " << dbentry.second << std::endl; - */ - } -} - -void SiPixelCPEGenericErrorParmReader::endJob() {} diff --git a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader.h b/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader.h deleted file mode 100644 index 132169b1c9dda..0000000000000 --- a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixelCPEGenericErrorParmReader_h -#define CondTools_SiPixel_SiPixelCPEGenericErrorParmReader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESWatcher.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "CondFormats/DataRecord/interface/SiPixelCPEGenericErrorParmRcd.h" - -class SiPixelCPEGenericErrorParmReader : public edm::EDAnalyzer { -public: - explicit SiPixelCPEGenericErrorParmReader(const edm::ParameterSet&); - ~SiPixelCPEGenericErrorParmReader(); - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - - edm::ESWatcher SiPixelCPEGenericErrorParmWatcher_; -}; - -#endif diff --git a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader_cfg.py b/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader_cfg.py deleted file mode 100644 index 3ee8fa63da0e0..0000000000000 --- a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmReader_cfg.py +++ /dev/null @@ -1,37 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("SiPixelCPEGenericErrorParmReaderTest") -process.load("CondCore.DBCommon.CondDBSetup_cfi") -process.load("FWCore.MessageService.MessageLogger_cfi") - -process.source = cms.Source("EmptySource") - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1) - ) - -#Uncomment these two lines to get from the global tag -#process.load('Configuration/StandardSequences/FrontierConditions_GlobalTag_cff') -#process.GlobalTag.globaltag = 'IDEAL_30X::All' - -process.PoolDBESSource = cms.ESSource("PoolDBESSource", - process.CondDBSetup, - loadAll = cms.bool(True), - toGet = cms.VPSet(cms.PSet( - record = cms.string('SiPixelCPEGenericErrorParmRcd'), - tag = cms.string('SiPixelCPEGenericErrorParm') - )), - DBParameters = cms.PSet( - messageLevel = cms.untracked.int32(0), - authenticationPath = cms.untracked.string('.') - ), - catalog = cms.untracked.string('file:PoolFileCatalog.xml'), - timetype = cms.string('runnumber'), - connect = cms.string('sqlite_file:siPixelCPEGenericErrorParm.db') - ) - -process.reader = cms.EDAnalyzer("SiPixelCPEGenericErrorParmReader") - -process.myprint = cms.OutputModule("AsciiOutputModule") - -process.p = cms.Path(process.reader) diff --git a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader.cc b/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader.cc deleted file mode 100644 index 1d1997cb91167..0000000000000 --- a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader.cc +++ /dev/null @@ -1,39 +0,0 @@ -#include "CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader.h" -#include "CondFormats/SiPixelObjects/interface/SiPixelCPEGenericErrorParm.h" - -#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" -#include "FWCore/ServiceRegistry/interface/Service.h" - -#include - -SiPixelCPEGenericErrorParmUploader::SiPixelCPEGenericErrorParmUploader(const edm::ParameterSet& iConfig) - : theFileName(iConfig.getParameter("fileName")), - theVersion(iConfig.getParameter("version")) {} - -SiPixelCPEGenericErrorParmUploader::~SiPixelCPEGenericErrorParmUploader() {} - -void SiPixelCPEGenericErrorParmUploader::beginJob() {} - -void SiPixelCPEGenericErrorParmUploader::analyze(const edm::Event& iEvent, const edm::EventSetup& setup) {} - -void SiPixelCPEGenericErrorParmUploader::endJob() { - //--- Make the POOL-ORA thingy to store the vector of error structs (DbEntry) - SiPixelCPEGenericErrorParm* obj = new SiPixelCPEGenericErrorParm; - obj->fillCPEGenericErrorParm(theVersion, theFileName.fullPath()); - // std::cout << *obj << std::endl; - - //--- Create a new IOV - edm::Service poolDbService; - - if (poolDbService.isAvailable()) { - if (poolDbService->isNewTagRequest("SiPixelCPEGenericErrorParmRcd")) - poolDbService->createNewIOV( - obj, poolDbService->beginOfTime(), poolDbService->endOfTime(), "SiPixelCPEGenericErrorParmRcd"); - else - poolDbService->appendSinceTime( - obj, poolDbService->currentTime(), "SiPixelCPEGenericErrorParmRcd"); - } else { - std::cout << "Pool Service Unavailable" << std::endl; - // &&& throw an exception??? - } -} diff --git a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader.h b/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader.h deleted file mode 100644 index 205b9694aca7e..0000000000000 --- a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixelCPEGenericErrorParmUploader_h -#define CondTools_SiPixel_SiPixelCPEGenericErrorParmUploader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -class SiPixelCPEGenericErrorParmUploader : public edm::EDAnalyzer { -public: - explicit SiPixelCPEGenericErrorParmUploader(const edm::ParameterSet&); - ~SiPixelCPEGenericErrorParmUploader(); - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - edm::FileInPath theFileName; - double theVersion; -}; - -#endif diff --git a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader_cfg.py b/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader_cfg.py deleted file mode 100644 index a19e235490fa9..0000000000000 --- a/CondTools/SiPixel/test/SiPixelCPEGenericErrorParmUploader_cfg.py +++ /dev/null @@ -1,41 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("SiPixelCPEGenericErrorParmUploaderTest") -process.load("CondCore.DBCommon.CondDBCommon_cfi") -process.load("FWCore.MessageService.MessageLogger_cfi") - -process.source = cms.Source("EmptyIOVSource", - timetype = cms.string('runnumber'), - firstValue = cms.uint64(1), - lastValue = cms.uint64(1), - interval = cms.uint64(1) - ) - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1) - ) - -process.PoolDBOutputService = cms.Service("PoolDBOutputService", - DBParameters = cms.PSet( - messageLevel = cms.untracked.int32(0), - authenticationPath = cms.untracked.string('.') - ), - timetype = cms.untracked.string('runnumber'), - connect = cms.string('sqlite_file:siPixelCPEGenericErrorParm.db'), - toPut = cms.VPSet(cms.PSet( - record = cms.string('SiPixelCPEGenericErrorParmRcd'), - tag = cms.string('SiPixelCPEGenericErrorParm') - )) - ) - -process.uploader = cms.EDAnalyzer("SiPixelCPEGenericErrorParmUploader", - fileName = cms.FileInPath('RecoLocalTracker/SiPixelRecHits/data/residuals.dat'), - version=cms.double(1.3) -) - -process.myprint = cms.OutputModule("AsciiOutputModule") - -process.p = cms.Path(process.uploader) -process.CondDBCommon.connect = 'sqlite_file:siPixelCPEGenericErrorParm.db' -process.CondDBCommon.DBParameters.messageLevel = 0 -process.CondDBCommon.DBParameters.authenticationPath = './' diff --git a/CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader.cc b/CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader.cc deleted file mode 100644 index f157beae4103e..0000000000000 --- a/CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader.cc +++ /dev/null @@ -1,25 +0,0 @@ -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include "CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader.h" -#include "CondFormats/SiPixelObjects/interface/SiPixelCPEGenericErrorParm.h" -#include "CondFormats/DataRecord/interface/SiPixelCPEGenericErrorParmRcd.h" -#include - -SiPixelFakeCPEGenericErrorParmSourceReader::SiPixelFakeCPEGenericErrorParmSourceReader( - const edm::ParameterSet& iConfig) {} - -SiPixelFakeCPEGenericErrorParmSourceReader::~SiPixelFakeCPEGenericErrorParmSourceReader() {} - -void SiPixelFakeCPEGenericErrorParmSourceReader::beginJob() {} - -void SiPixelFakeCPEGenericErrorParmSourceReader::analyze(const edm::Event& iEvent, const edm::EventSetup& setup) { - if (SiPixelCPEGenericErrorParmWatcher_.check(setup)) { - edm::ESHandle errorsH; - setup.get().get(errorsH); - - std::cout << *errorsH << std::endl; - } -} - -void SiPixelFakeCPEGenericErrorParmSourceReader::endJob() {} diff --git a/CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader.h b/CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader.h deleted file mode 100644 index d3ecf8d4e75fc..0000000000000 --- a/CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixelFakeCPEGenericErrorParmSourceReader_h -#define CondTools_SiPixel_SiPixelFakeCPEGenericErrorParmSourceReader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESWatcher.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "CondFormats/DataRecord/interface/SiPixelCPEGenericErrorParmRcd.h" - -class SiPixelFakeCPEGenericErrorParmSourceReader : public edm::EDAnalyzer { -public: - explicit SiPixelFakeCPEGenericErrorParmSourceReader(const edm::ParameterSet&); - ~SiPixelFakeCPEGenericErrorParmSourceReader(); - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - - edm::ESWatcher SiPixelCPEGenericErrorParmWatcher_; -}; - -#endif diff --git a/CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader_cfg.py b/CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader_cfg.py deleted file mode 100644 index fae6188f78227..0000000000000 --- a/CondTools/SiPixel/test/SiPixelFakeCPEGenericErrorParmSourceReader_cfg.py +++ /dev/null @@ -1,22 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("SiPixelCPEFakeGenericErrorParmSourceReader") - -process.load("FWCore.MessageService.MessageLogger_cfi") - -process.load("CalibTracker.SiPixelESProducers.SiPixelFakeCPEGenericErrorParmESSource_cfi") - -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(2) ) - -process.source = cms.Source("PoolSource", - # replace 'myfile.root' with the source file you want to use - fileNames = cms.untracked.vstring( - '/store/relval/CMSSW_2_1_9/RelValSingleMuPt10/GEN-SIM-DIGI-RAW-HLTDEBUG-RECO/IDEAL_V9_v2/0000/2A00EECC-A185-DD11-93A9-000423D9517C.root' - ) -) - -process.reader = cms.EDAnalyzer('SiPixelFakeCPEGenericErrorParmSourceReader' -) - - -process.p = cms.Path(process.reader) diff --git a/CondTools/SiPixel/test/SiPixelFakeGenErrorDBSourceReader.cc b/CondTools/SiPixel/test/SiPixelFakeGenErrorDBSourceReader.cc deleted file mode 100644 index d94de600605ce..0000000000000 --- a/CondTools/SiPixel/test/SiPixelFakeGenErrorDBSourceReader.cc +++ /dev/null @@ -1,23 +0,0 @@ -#include "CondTools/SiPixel/test/SiPixelFakeGenErrorDBSourceReader.h" -#include "CondFormats/SiPixelObjects/interface/SiPixelGenErrorDBObject.h" - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include - -SiPixelFakeGenErrorDBSourceReader::SiPixelFakeGenErrorDBSourceReader(const edm::ParameterSet& iConfig) {} - -SiPixelFakeGenErrorDBSourceReader::~SiPixelFakeGenErrorDBSourceReader() {} - -void SiPixelFakeGenErrorDBSourceReader::beginJob() {} - -void SiPixelFakeGenErrorDBSourceReader::analyze(const edm::Event& iEvent, const edm::EventSetup& setup) { - if (SiPixelGenErrorDBObjectWatcher_.check(setup)) { - edm::ESHandle generrorH; - setup.get().get(generrorH); - - std::cout << *generrorH.product() << std::endl; - } -} - -void SiPixelFakeGenErrorDBSourceReader::endJob() {} diff --git a/CondTools/SiPixel/test/SiPixelFakeGenErrorDBSourceReader.h b/CondTools/SiPixel/test/SiPixelFakeGenErrorDBSourceReader.h deleted file mode 100644 index 3f2cac8e79c27..0000000000000 --- a/CondTools/SiPixel/test/SiPixelFakeGenErrorDBSourceReader.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixelFakeGenErrorDBSourceReader_h -#define CondTools_SiPixel_SiPixelFakeGenErrorDBSourceReader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESWatcher.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "CondFormats/DataRecord/interface/SiPixelGenErrorDBObjectRcd.h" - -class SiPixelFakeGenErrorDBSourceReader : public edm::EDAnalyzer { -public: - explicit SiPixelFakeGenErrorDBSourceReader(const edm::ParameterSet&); - ~SiPixelFakeGenErrorDBSourceReader(); - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - - edm::ESWatcher SiPixelGenErrorDBObjectWatcher_; -}; - -#endif diff --git a/CondTools/SiPixel/test/SiPixelFakeTemplateDBSourceReader.cc b/CondTools/SiPixel/test/SiPixelFakeTemplateDBSourceReader.cc deleted file mode 100644 index 78ab3eb61a6e7..0000000000000 --- a/CondTools/SiPixel/test/SiPixelFakeTemplateDBSourceReader.cc +++ /dev/null @@ -1,23 +0,0 @@ -#include "CondTools/SiPixel/test/SiPixelFakeTemplateDBSourceReader.h" -#include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h" - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include - -SiPixelFakeTemplateDBSourceReader::SiPixelFakeTemplateDBSourceReader(const edm::ParameterSet& iConfig) {} - -SiPixelFakeTemplateDBSourceReader::~SiPixelFakeTemplateDBSourceReader() {} - -void SiPixelFakeTemplateDBSourceReader::beginJob() {} - -void SiPixelFakeTemplateDBSourceReader::analyze(const edm::Event& iEvent, const edm::EventSetup& setup) { - if (SiPixelTemplateDBObjectWatcher_.check(setup)) { - edm::ESHandle templateH; - setup.get().get(templateH); - - std::cout << *templateH.product() << std::endl; - } -} - -void SiPixelFakeTemplateDBSourceReader::endJob() {} diff --git a/CondTools/SiPixel/test/SiPixelFakeTemplateDBSourceReader.h b/CondTools/SiPixel/test/SiPixelFakeTemplateDBSourceReader.h deleted file mode 100644 index 36be290e8dc55..0000000000000 --- a/CondTools/SiPixel/test/SiPixelFakeTemplateDBSourceReader.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixelFakeTemplateDBSourceReader_h -#define CondTools_SiPixel_SiPixelFakeTemplateDBSourceReader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESWatcher.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "CondFormats/DataRecord/interface/SiPixelTemplateDBObjectRcd.h" - -class SiPixelFakeTemplateDBSourceReader : public edm::EDAnalyzer { -public: - explicit SiPixelFakeTemplateDBSourceReader(const edm::ParameterSet&); - ~SiPixelFakeTemplateDBSourceReader(); - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - - edm::ESWatcher SiPixelTemplateDBObjectWatcher_; -}; - -#endif diff --git a/CondTools/SiPixel/test/SiPixelGenErrorDBObjectReader.h b/CondTools/SiPixel/test/SiPixelGenErrorDBObjectReader.h deleted file mode 100644 index 3809b58cd6f89..0000000000000 --- a/CondTools/SiPixel/test/SiPixelGenErrorDBObjectReader.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixelGenErrorDBObjectReader_h -#define CondTools_SiPixel_SiPixelGenErrorDBObjectReader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESWatcher.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "CondFormats/SiPixelObjects/interface/SiPixelGenErrorDBObject.h" -#include "CondFormats/DataRecord/interface/SiPixelGenErrorDBObjectRcd.h" -#include "CalibTracker/Records/interface/SiPixelGenErrorDBObjectESProducerRcd.h" - -class SiPixelGenErrorDBObjectReader : public edm::EDAnalyzer { -public: - explicit SiPixelGenErrorDBObjectReader(const edm::ParameterSet&); - ~SiPixelGenErrorDBObjectReader(); - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - - //edm::ESWatcher SiPixGenerDBObjectWatcher_; - //edm::ESWatcher SiPixGenerDBObjWatcher_; - - std::string theGenErrorCalibrationLocation; - bool theDetailedGenErrorDBErrorOutput; - bool theFullGenErrorDBOutput; - //bool testGlobalTag; - SiPixelGenErrorDBObject dbobject; - //bool hasTriggeredWatcher; -}; -#endif diff --git a/CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader.h b/CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader.h deleted file mode 100644 index 83106121a1b04..0000000000000 --- a/CondTools/SiPixel/test/SiPixelGenErrorDBObjectUploader.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixelGenErrorDBObjectUploader_h -#define CondTools_SiPixel_SiPixelGenErrorDBObjectUploader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "CondFormats/SiPixelObjects/interface/SiPixelGenErrorDBObject.h" - -class SiPixelGenErrorDBObjectUploader : public edm::EDAnalyzer { -public: - explicit SiPixelGenErrorDBObjectUploader(const edm::ParameterSet&); - ~SiPixelGenErrorDBObjectUploader(); - - typedef std::vector vstring; - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - - vstring theGenErrorCalibrations; - std::string theGenErrorBaseString; - float theVersion; - float theMagField; - std::vector theDetIds; - vstring theBarrelLocations; - vstring theEndcapLocations; - std::vector theBarrelGenErrIds; - std::vector theEndcapGenErrIds; - bool useVectorIndices; -}; - -#endif diff --git a/CondTools/SiPixel/test/SiPixelTemplateDBObjectReader.h b/CondTools/SiPixel/test/SiPixelTemplateDBObjectReader.h deleted file mode 100644 index 295d17283c9f2..0000000000000 --- a/CondTools/SiPixel/test/SiPixelTemplateDBObjectReader.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixelTemplateDBObjectReader_h -#define CondTools_SiPixel_SiPixelTemplateDBObjectReader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/Framework/interface/ESWatcher.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h" -#include "CondFormats/DataRecord/interface/SiPixelTemplateDBObjectRcd.h" -#include "CalibTracker/Records/interface/SiPixelTemplateDBObjectESProducerRcd.h" - -class SiPixelTemplateDBObjectReader : public edm::EDAnalyzer { -public: - explicit SiPixelTemplateDBObjectReader(const edm::ParameterSet&); - ~SiPixelTemplateDBObjectReader(); - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - - edm::ESWatcher SiPixTemplDBObjectWatcher_; - edm::ESWatcher SiPixTemplDBObjWatcher_; - - std::string theTemplateCalibrationLocation; - bool theDetailedTemplateDBErrorOutput; - bool theFullTemplateDBOutput; - bool testGlobalTag; - - SiPixelTemplateDBObject dbobject; - bool hasTriggeredWatcher; -}; - -#endif diff --git a/CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader.h b/CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader.h deleted file mode 100644 index 5bcd2dc826078..0000000000000 --- a/CondTools/SiPixel/test/SiPixelTemplateDBObjectUploader.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef CondTools_SiPixel_SiPixelTemplateDBObjectUploader_h -#define CondTools_SiPixel_SiPixelTemplateDBObjectUploader_h - -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h" - -class SiPixelTemplateDBObjectUploader : public edm::EDAnalyzer { -public: - explicit SiPixelTemplateDBObjectUploader(const edm::ParameterSet&); - ~SiPixelTemplateDBObjectUploader(); - - typedef std::vector vstring; - -private: - virtual void beginJob(); - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob(); - - vstring theTemplateCalibrations; - std::string theTemplateBaseString; - float theVersion; - float theMagField; - std::vector theDetIds; - vstring theBarrelLocations; - vstring theEndcapLocations; - std::vector theBarrelTemplateIds; - std::vector theEndcapTemplateIds; - bool useVectorIndices; -}; - -#endif