diff --git a/CondCore/PCLConfigPlugins/BuildFile.xml b/CondCore/PCLConfigPlugins/BuildFile.xml new file mode 100644 index 0000000000000..7a58e90c85d44 --- /dev/null +++ b/CondCore/PCLConfigPlugins/BuildFile.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/CondCore/PCLConfigPlugins/src/plugin.cc b/CondCore/PCLConfigPlugins/src/plugin.cc new file mode 100644 index 0000000000000..097579cd61b2c --- /dev/null +++ b/CondCore/PCLConfigPlugins/src/plugin.cc @@ -0,0 +1,5 @@ +#include "CondCore/ESSources/interface/registration_macros.h" +#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" +#include "CondFormats/DataRecord/interface/AlignPCLThresholdsRcd.h" + +REGISTER_PLUGIN(AlignPCLThresholdsRcd,AlignPCLThresholds); diff --git a/CondCore/Utilities/BuildFile.xml b/CondCore/Utilities/BuildFile.xml index 7ef5b39a1cf6e..e282034d63699 100644 --- a/CondCore/Utilities/BuildFile.xml +++ b/CondCore/Utilities/BuildFile.xml @@ -31,6 +31,7 @@ + diff --git a/CondCore/Utilities/python/cond2xml.py b/CondCore/Utilities/python/cond2xml.py index 7ff0a1ee41a85..615964fc1a213 100644 --- a/CondCore/Utilities/python/cond2xml.py +++ b/CondCore/Utilities/python/cond2xml.py @@ -99,6 +99,7 @@ def ("%(plTypeSan)s2xml", %(plTypeSan)s2xml); + diff --git a/CondCore/Utilities/src/CondDBFetch.cc b/CondCore/Utilities/src/CondDBFetch.cc index 8184cd73e02b1..7a112bc832193 100644 --- a/CondCore/Utilities/src/CondDBFetch.cc +++ b/CondCore/Utilities/src/CondDBFetch.cc @@ -31,6 +31,7 @@ namespace cond { FETCH_PAYLOAD_CASE( AlignmentErrorsExtended ) FETCH_PAYLOAD_CASE( AlignmentSurfaceDeformations ) FETCH_PAYLOAD_CASE( Alignments ) + FETCH_PAYLOAD_CASE( AlignPCLThresholds ) FETCH_PAYLOAD_CASE( BeamSpotObjects ) FETCH_PAYLOAD_CASE( CSCBadChambers ) FETCH_PAYLOAD_CASE( CSCBadStrips ) diff --git a/CondCore/Utilities/src/CondDBImport.cc b/CondCore/Utilities/src/CondDBImport.cc index e11f845a7c6ba..61a16371a19bd 100644 --- a/CondCore/Utilities/src/CondDBImport.cc +++ b/CondCore/Utilities/src/CondDBImport.cc @@ -45,6 +45,7 @@ namespace cond { IMPORT_PAYLOAD_CASE( AlignmentErrorsExtended ) IMPORT_PAYLOAD_CASE( AlignmentSurfaceDeformations ) IMPORT_PAYLOAD_CASE( Alignments ) + IMPORT_PAYLOAD_CASE( AlignPCLThresholds ) IMPORT_PAYLOAD_CASE( BeamSpotObjects ) IMPORT_PAYLOAD_CASE( CSCBadChambers ) IMPORT_PAYLOAD_CASE( CSCBadStrips ) diff --git a/CondCore/Utilities/src/CondFormats.h b/CondCore/Utilities/src/CondFormats.h index 46017b37daa11..1845950439c25 100644 --- a/CondCore/Utilities/src/CondFormats.h +++ b/CondCore/Utilities/src/CondFormats.h @@ -249,6 +249,7 @@ #include "CondFormats/SiStripObjects/interface/SiStripPedestals.h" #include "CondFormats/BTauObjects/interface/TrackProbabilityCalibration.h" #include "CondFormats/MFObjects/interface/MagFieldConfig.h" +#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" #include "CondFormats/Common/interface/BaseKeyed.h" diff --git a/CondFormats/DataRecord/interface/AlignPCLThresholdsRcd.h b/CondFormats/DataRecord/interface/AlignPCLThresholdsRcd.h new file mode 100644 index 0000000000000..81e18c539ebcf --- /dev/null +++ b/CondFormats/DataRecord/interface/AlignPCLThresholdsRcd.h @@ -0,0 +1,25 @@ +#ifndef AlignPCLThresholdsRcd_AlignPCLThresholdsRcd_h +#define AlignPCLThresholdsRcd_AlignPCLThresholdsRcd_h +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : AlignPCLThresholdsRcd +// +/**\class AlignPCLThresholdsRcd AlignPCLThresholdsRcd.h CondFormats/DataRecord/interface/AlignPCLThresholdsRcd.h + + Description: [one line class summary] + + Usage: + + +*/ +// +// Author: Marco Musich +// Created: Wed, 22 Feb 2017 10:31:30 GMT +// + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" + +class AlignPCLThresholdsRcd : public edm::eventsetup::EventSetupRecordImplementation {}; + +#endif diff --git a/CondFormats/DataRecord/src/AlignPCLThresholdsRcd.cc b/CondFormats/DataRecord/src/AlignPCLThresholdsRcd.cc new file mode 100644 index 0000000000000..7f081e1ce226b --- /dev/null +++ b/CondFormats/DataRecord/src/AlignPCLThresholdsRcd.cc @@ -0,0 +1,15 @@ +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : AlignPCLThresholdsRcd +// +// Implementation: +// [Notes on implementation] +// +// Author: Marco Musich +// Created: Wed, 22 Feb 2017 10:31:30 GMT + +#include "CondFormats/DataRecord/interface/AlignPCLThresholdsRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(AlignPCLThresholdsRcd); diff --git a/CondFormats/PCLConfig/BuildFile.xml b/CondFormats/PCLConfig/BuildFile.xml new file mode 100644 index 0000000000000..8b7accba08566 --- /dev/null +++ b/CondFormats/PCLConfig/BuildFile.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/CondFormats/PCLConfig/interface/AlignPCLThreshold.h b/CondFormats/PCLConfig/interface/AlignPCLThreshold.h new file mode 100644 index 0000000000000..4cbfc28cdf0fe --- /dev/null +++ b/CondFormats/PCLConfig/interface/AlignPCLThreshold.h @@ -0,0 +1,92 @@ +#ifndef CondFormats_PCLConfig_AlignPCLThreshold_h +#define CondFormats_PCLConfig_AlignPCLThreshold_h + +#include "CondFormats/Serialization/interface/Serializable.h" + +class AlignPCLThreshold +{ +public: + + struct coordThresholds{ + coordThresholds(){ + m_Cut=5.; + m_sigCut=2.5; + m_errorCut=10.; + m_maxMoveCut=200; + m_label="default"; + } + ~coordThresholds(){} + void setThresholds(float theCut,float theSigCut,float theErrorCut,float theMaxMoveCut,const std::string &theLabel){ + m_Cut=theCut; + m_sigCut=theSigCut; + m_errorCut=theErrorCut; + m_maxMoveCut=theMaxMoveCut; + m_label=theLabel; + } + + float m_Cut; + float m_sigCut; + float m_errorCut; + float m_maxMoveCut; + std::string m_label; + + COND_SERIALIZABLE; + + }; + + virtual ~AlignPCLThreshold(){} + + AlignPCLThreshold(coordThresholds X=coordThresholds(),coordThresholds tX=coordThresholds(), + coordThresholds Y=coordThresholds(),coordThresholds tY=coordThresholds(), + coordThresholds Z=coordThresholds(),coordThresholds tZ=coordThresholds(), + std::vector< coordThresholds > extraDOF=std::vector< coordThresholds >() + ); + + float getXcut() const {return m_xCoord.m_Cut;} + float getYcut() const {return m_yCoord.m_Cut;} + float getZcut() const {return m_zCoord.m_Cut;} + float getThetaXcut() const {return m_thetaXCoord.m_Cut;} + float getThetaYcut() const {return m_thetaYCoord.m_Cut;} + float getThetaZcut() const {return m_thetaZCoord.m_Cut;} + + float getSigXcut() const {return m_xCoord.m_sigCut;} + float getSigYcut() const {return m_yCoord.m_sigCut;} + float getSigZcut() const {return m_zCoord.m_sigCut;} + float getSigThetaXcut() const {return m_thetaXCoord.m_sigCut;} + float getSigThetaYcut() const {return m_thetaYCoord.m_sigCut;} + float getSigThetaZcut() const {return m_thetaZCoord.m_sigCut;} + + float getErrorXcut() const {return m_xCoord.m_errorCut;} + float getErrorYcut() const {return m_yCoord.m_errorCut;} + float getErrorZcut() const {return m_zCoord.m_errorCut;} + float getErrorThetaXcut() const {return m_thetaXCoord.m_errorCut;} + float getErrorThetaYcut() const {return m_thetaYCoord.m_errorCut;} + float getErrorThetaZcut() const {return m_thetaZCoord.m_errorCut;} + + float getMaxMoveXcut() const {return m_xCoord.m_maxMoveCut;} + float getMaxMoveYcut() const {return m_yCoord.m_maxMoveCut;} + float getMaxMoveZcut() const {return m_zCoord.m_maxMoveCut;} + float getMaxMoveThetaXcut() const {return m_thetaXCoord.m_maxMoveCut;} + float getMaxMoveThetaYcut() const {return m_thetaYCoord.m_maxMoveCut;} + float getMaxMoveThetaZcut() const {return m_thetaZCoord.m_maxMoveCut;} + + bool hasExtraDOF() const {return (m_extraDOF.size()>0);} + unsigned int extraDOFSize() const {return m_extraDOF.size();} + std::array getExtraDOFCuts(const unsigned int i) const; + std::string getExtraDOFLabel(const unsigned int i) const; + +private: + + coordThresholds m_xCoord; + coordThresholds m_yCoord; + coordThresholds m_zCoord; + coordThresholds m_thetaXCoord; + coordThresholds m_thetaYCoord; + coordThresholds m_thetaZCoord; + std::vector< coordThresholds > m_extraDOF; + + COND_SERIALIZABLE; + +}; + +#endif diff --git a/CondFormats/PCLConfig/interface/AlignPCLThresholds.h b/CondFormats/PCLConfig/interface/AlignPCLThresholds.h new file mode 100644 index 0000000000000..867f2527431c3 --- /dev/null +++ b/CondFormats/PCLConfig/interface/AlignPCLThresholds.h @@ -0,0 +1,57 @@ +#ifndef CondFormats_PCLConfig_AlignPCLThresholds_h +#define CondFormats_PCLConfig_AlignPCLThresholds_h + +#include "CondFormats/PCLConfig/interface/AlignPCLThreshold.h" +#include "CondFormats/Serialization/interface/Serializable.h" + +#include +#include +#include + +class AlignPCLThresholds{ + public: + typedef std::map threshold_map; + enum coordType {X, Y, Z, theta_X, theta_Y, theta_Z, extra_DOF, endOfTypes}; + + AlignPCLThresholds(){} + virtual ~AlignPCLThresholds(){} + + void setAlignPCLThreshold(const std::string &AlignableId, const AlignPCLThreshold &Threshold); + void setAlignPCLThresholds(const int &Nrecords,const threshold_map &Thresholds); + void setNRecords(const int &Nrecords); + + const threshold_map& getThreshold_Map () const {return m_thresholds;} + const int& getNrecords() const {return m_nrecords;} + + AlignPCLThreshold getAlignPCLThreshold(const std::string &AlignableId) const; + AlignPCLThreshold & getAlignPCLThreshold(const std::string &AlignableId); + + float getSigCut (const std::string &AlignableId,const coordType &type) const; + float getCut (const std::string &AlignableId,const coordType &type) const; + float getMaxMoveCut (const std::string &AlignableId,const coordType &type) const; + float getMaxErrorCut(const std::string &AlignableId,const coordType &type) const; + + // overloaded methods to get all the coordinates + std::array getSigCut (const std::string &AlignableId) const; + std::array getCut (const std::string &AlignableId) const; + std::array getMaxMoveCut (const std::string &AlignableId) const; + std::array getMaxErrorCut(const std::string &AlignableId) const; + + std::array getExtraDOFCutsForAlignable(const std::string &AlignableId,const unsigned int i) const; + std::string getExtraDOFLabelForAlignable(const std::string &AlignableId,const unsigned int i) const; + + double size()const {return m_thresholds.size();} + std::vector getAlignableList() const; + + void printAll() const; + + private: + + threshold_map m_thresholds; + int m_nrecords; + + COND_SERIALIZABLE; + +}; + +#endif diff --git a/CondFormats/PCLConfig/plugins/AlignPCLThresholdsReader.cc b/CondFormats/PCLConfig/plugins/AlignPCLThresholdsReader.cc new file mode 100644 index 0000000000000..f77c98bd89a82 --- /dev/null +++ b/CondFormats/PCLConfig/plugins/AlignPCLThresholdsReader.cc @@ -0,0 +1,144 @@ +#include +#include +#include +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" +#include "CondFormats/DataRecord/interface/AlignPCLThresholdsRcd.h" + +namespace edmtest +{ + class AlignPCLThresholdsReader : public edm::one::EDAnalyzer<> { + public: + explicit AlignPCLThresholdsReader(edm::ParameterSet const& p); + ~AlignPCLThresholdsReader(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + + virtual void analyze(const edm::Event& e, const edm::EventSetup& c) override; + + // ----------member data --------------------------- + const bool printdebug_; + const std::string formatedOutput_; + + }; + + AlignPCLThresholdsReader::AlignPCLThresholdsReader(edm::ParameterSet const& p): + printdebug_(p.getUntrackedParameter("printDebug",true)), + formatedOutput_(p.getUntrackedParameter("outputFile","")) + { + edm::LogInfo("AlignPCLThresholdsReader")<<"AlignPCLThresholdsReader"< thresholdHandle; + edm::LogInfo("AlignPCLThresholdsReader") <<"got eshandle"<().get(thresholdHandle); + edm::LogInfo("AlignPCLThresholdsReader") <<"got context"<size() << std::endl; + edm::LogInfo("AlignPCLThresholdsReader") <<"Content of myThresholds "<printAll(); + } + + FILE* pFile=NULL; + if(formatedOutput_!="")pFile=fopen(formatedOutput_.c_str(), "w"); + if(pFile){ + + fprintf(pFile,"AlignPCLThresholds::printAll() \n"); + fprintf(pFile," =================================================================================================================== \n"); + fprintf(pFile,"N records cut: %i \n",thresholds->getNrecords()); + + AlignPCLThresholds::threshold_map m_thresholds = thresholds->getThreshold_Map(); + + for(auto it = m_thresholds.begin(); it != m_thresholds.end() ; ++it){ + fprintf(pFile," =================================================================================================================== \n"); + fprintf(pFile,"key : %s \n ",(it->first).c_str()); + fprintf(pFile,"- Xcut : %8.3f um ",(it->second).getXcut() ); + fprintf(pFile,"| sigXcut : %8.3f ",(it->second).getSigXcut() ); + fprintf(pFile,"| maxMoveXcut : %8.3f um ",(it->second).getMaxMoveXcut() ); + fprintf(pFile,"| ErrorXcut : %8.3f um\n ",(it->second).getErrorXcut() ); + + fprintf(pFile,"- thetaXcut : %8.3f urad ",(it->second).getThetaXcut() ); + fprintf(pFile,"| sigThetaXcut : %8.3f ",(it->second).getSigThetaXcut() ); + fprintf(pFile,"| maxMoveThetaXcut : %8.3f urad ",(it->second).getMaxMoveThetaXcut()); + fprintf(pFile,"| ErrorThetaXcut : %8.3f urad\n ",(it->second).getErrorThetaXcut() ); + + fprintf(pFile,"- Ycut : %8.3f um ",(it->second).getYcut() ); + fprintf(pFile,"| sigYcut : %8.3f ",(it->second).getSigXcut() ); + fprintf(pFile,"| maxMoveYcut : %8.3f um ",(it->second).getMaxMoveYcut() ); + fprintf(pFile,"| ErrorYcut : %8.3f um\n ",(it->second).getErrorYcut() ); + + fprintf(pFile,"- thetaYcut : %8.3f urad ",(it->second).getThetaYcut() ); + fprintf(pFile,"| sigThetaYcut : %8.3f ",(it->second).getSigThetaYcut() ); + fprintf(pFile,"| maxMoveThetaYcut : %8.3f urad ",(it->second).getMaxMoveThetaYcut()); + fprintf(pFile,"| ErrorThetaYcut : %8.3f urad\n ",(it->second).getErrorThetaYcut() ); + + fprintf(pFile,"- Zcut : %8.3f um ",(it->second).getZcut() ); + fprintf(pFile,"| sigZcut : %8.3f ",(it->second).getSigZcut() ); + fprintf(pFile,"| maxMoveZcut : %8.3f um ",(it->second).getMaxMoveZcut() ); + fprintf(pFile,"| ErrorZcut : %8.3f um\n ",(it->second).getErrorZcut() ); + + fprintf(pFile,"- thetaZcut : %8.3f urad ",(it->second).getThetaZcut() ); + fprintf(pFile,"| sigThetaZcut : %8.3f ",(it->second).getSigThetaZcut() ); + fprintf(pFile,"| maxMoveThetaZcut : %8.3f urad ",(it->second).getMaxMoveThetaZcut()); + fprintf(pFile,"| ErrorThetaZcut : %8.3f urad\n ",(it->second).getErrorThetaZcut() ); + + if((it->second).hasExtraDOF()){ + for (unsigned int j=0; j<(it->second).extraDOFSize(); j++){ + std::array extraDOFCuts = thresholds->getExtraDOFCutsForAlignable(it->first,j); + const char* theLabel = (thresholds->getExtraDOFLabelForAlignable(it->first,j)).c_str(); + fprintf(pFile,"Extra DOF: %i with label %s \n ",j,theLabel); + fprintf(pFile,"- cut : %8.3f " ,extraDOFCuts.at(0)); + fprintf(pFile,"| sigCut : %8.3f " ,extraDOFCuts.at(1)); + fprintf(pFile,"| maxMoveCut : %8.3f " ,extraDOFCuts.at(2)); + fprintf(pFile,"| maxErrorCut : %8.3f \n " ,extraDOFCuts.at(3)); + } + } + } + } + + } + + void + AlignPCLThresholdsReader::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment("Reads payloads of type AlignPCLThresholds"); + desc.addUntracked("printDebug",true); + desc.addUntracked("outputFile",""); + descriptions.add("AlignPCLThresholdsReader",desc); + } + + DEFINE_FWK_MODULE(AlignPCLThresholdsReader); +} diff --git a/CondFormats/PCLConfig/plugins/AlignPCLThresholdsWriter.cc b/CondFormats/PCLConfig/plugins/AlignPCLThresholdsWriter.cc new file mode 100644 index 0000000000000..67e4f3556bbdd --- /dev/null +++ b/CondFormats/PCLConfig/plugins/AlignPCLThresholdsWriter.cc @@ -0,0 +1,248 @@ +// -*- C++ -*- +// +// Package: CondFormats/PCLConfig +// Class: AlignPCLThresholdsWriter +// +/**\class AlignPCLThresholdsWriter AlignPCLThresholdsWriter.cc CondFormats/PCLConfig/plugins/AlignPCLThresholdsWriter.cc + + Description: class to build the SiPixelAli PCL thresholds + +*/ +// +// Original Author: Marco Musich +// Created: Wed, 22 Feb 2017 12:04:36 GMT +// +// + +// system include files +#include + +// user include files +#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/ParameterSet/interface/ParameterSet.h" +#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +// +// class declaration +// + +namespace DOFs { + enum dof{ + X, + Y, + Z, + thetaX, + thetaY, + thetaZ, + extraDOF + }; +} + +class AlignPCLThresholdsWriter : public edm::one::EDAnalyzer<> { + public: + explicit AlignPCLThresholdsWriter(const edm::ParameterSet&); + ~AlignPCLThresholdsWriter(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + + private: + virtual void beginJob() override; + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override; + DOFs::dof mapOntoEnum(std::string coord); + + // ----------member data --------------------------- + const std::string m_record; + const unsigned int m_minNrecords; + const std::vector m_parameters; + AlignPCLThresholds* myThresholds; + +}; + +// +// constructors and destructor +// +AlignPCLThresholdsWriter::AlignPCLThresholdsWriter(const edm::ParameterSet& iConfig): + m_record(iConfig.getParameter("record")), + m_minNrecords(iConfig.getParameter("minNRecords")), + m_parameters(iConfig.getParameter >("thresholds")) +{ + //now do what ever initialization is needed + myThresholds = new AlignPCLThresholds(); +} + + +AlignPCLThresholdsWriter::~AlignPCLThresholdsWriter() +{ + delete myThresholds; +} + +// +// member functions +// + +// ------------ method called for each event ------------ +void +AlignPCLThresholdsWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace edm; + + edm::LogInfo("AlignPCLThresholdsWriter")<<"Size of AlignPCLThresholds object "<< myThresholds->size() < mandatories = {{"X","Y","Z","thetaX","thetaY","thetaZ"}}; + std::vector alignables; + + // fill the list of alignables + for(auto& thePSet : m_parameters){ + const std::string alignableId(thePSet.getParameter("alignableId")); + // only if it is not yet in the list + if(std::find(alignables.begin(), alignables.end(), alignableId) == alignables.end()) { + alignables.push_back(alignableId); + } + } + + for (auto& alignable : alignables){ + + AlignPCLThreshold::coordThresholds my_X; + AlignPCLThreshold::coordThresholds my_Y; + AlignPCLThreshold::coordThresholds my_Z; + AlignPCLThreshold::coordThresholds my_tX; + AlignPCLThreshold::coordThresholds my_tY; + AlignPCLThreshold::coordThresholds my_tZ; + + std::vector presentDOF; + + // extra degrees of freedom + std::vector< AlignPCLThreshold::coordThresholds > extraDOFs = std::vector< AlignPCLThreshold::coordThresholds >(); + + for(auto& thePSet : m_parameters){ + + const std::string alignableId(thePSet.getParameter("alignableId")); + const std::string DOF(thePSet.getParameter("DOF")); + + const double cutoff(thePSet.getParameter("cut")); + const double sigCut(thePSet.getParameter("sigCut")); + const double maxMoveCut(thePSet.getParameter("maxMoveCut")); + const double maxErrorCut(thePSet.getParameter("maxErrorCut")); + + if (alignableId == alignable){ + presentDOF.push_back(DOF); + // create the objects + + switch( mapOntoEnum(DOF) ) + { + case DOFs::X: + my_X.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF); + break; + case DOFs::Y: + my_Y.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF); + break; + case DOFs::Z: + my_Z.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF); + break; + case DOFs::thetaX: + my_tX.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF); + break; + case DOFs::thetaY: + my_tY.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF); + break; + case DOFs::thetaZ: + my_tZ.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF); + break; + default: + edm::LogInfo("AlignPCLThresholdsWriter")<<"Appending Extra degree of freeedom: "<< DOF <<" " << mapOntoEnum(DOF) << std::endl; + AlignPCLThreshold::coordThresholds ExtraDOF; + ExtraDOF.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF); + extraDOFs.push_back(ExtraDOF); + } + + AlignPCLThreshold a(my_X,my_tX,my_Y,my_tY,my_Z,my_tZ,extraDOFs); + myThresholds->setAlignPCLThreshold(alignableId,a); + + } // if alignable is found in the PSet + } // loop on the PSets + + // checks if all mandatories are present + edm::LogInfo("AlignPCLThresholdsWriter")<<"Size of AlignPCLThresholds object "<size() <setNRecords(m_minNrecords); + edm::LogInfo("AlignPCLThresholdsWriter")<<"Content of AlignPCLThresholds "<printAll(); + + // Form the data here + edm::Service poolDbService; + if( poolDbService.isAvailable() ){ + cond::Time_t valid_time = poolDbService->currentTime(); + // this writes the payload to begin in current run defined in cfg + poolDbService->writeOne(myThresholds,valid_time, m_record); + } +} + +// ------------ method called once each job just before starting event loop ------------ +void +AlignPCLThresholdsWriter::beginJob() +{ +} + +// ------------ method called once each job just after ending the event loop ------------ +void +AlignPCLThresholdsWriter::endJob() +{ +} + +DOFs::dof AlignPCLThresholdsWriter::mapOntoEnum(std::string coord){ + if( coord=="X" ){ + return DOFs::X; + } + else if ( coord=="Y" ){ + return DOFs::Y; + } + else if ( coord=="Z" ){ + return DOFs::Z; + } + else if ( coord=="thetaX" ){ + return DOFs::thetaX; + } + else if ( coord=="thetaY" ){ + return DOFs::thetaY; + } + else if ( coord=="thetaZ" ){ + return DOFs::thetaZ; + } + else { + return DOFs::extraDOF; + } + +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +AlignPCLThresholdsWriter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(AlignPCLThresholdsWriter); diff --git a/CondFormats/PCLConfig/plugins/BuildFile.xml b/CondFormats/PCLConfig/plugins/BuildFile.xml new file mode 100644 index 0000000000000..e7820f90abcb1 --- /dev/null +++ b/CondFormats/PCLConfig/plugins/BuildFile.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/CondFormats/PCLConfig/python/Thresholds_cff.py b/CondFormats/PCLConfig/python/Thresholds_cff.py new file mode 100644 index 0000000000000..19163ea918a64 --- /dev/null +++ b/CondFormats/PCLConfig/python/Thresholds_cff.py @@ -0,0 +1,302 @@ +import FWCore.ParameterSet.Config as cms +import copy + +# ----------------------------------------------------------------------- +# Default configuration + +default = cms.VPSet( + #### Barrel Pixel HB X- + cms.PSet(alignableId = cms.string("TPBHalfBarrelXminus"), + DOF = cms.string("X"), + cut = cms.double(5.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPBHalfBarrelXminus"), + DOF = cms.string("thetaX"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPBHalfBarrelXminus"), + DOF = cms.string("Y"), + cut = cms.double(10.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPBHalfBarrelXminus"), + DOF = cms.string("thetaY"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPBHalfBarrelXminus"), + DOF = cms.string("Z"), + cut = cms.double(15.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPBHalfBarrelXminus"), + DOF = cms.string("thetaZ"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + ### Barrel Pixel HB X+ + cms.PSet(alignableId = cms.string("TPBHalfBarrelXplus"), + DOF = cms.string("X"), + cut = cms.double(5.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPBHalfBarrelXplus"), + DOF = cms.string("thetaX"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0), + ), + + cms.PSet(alignableId = cms.string("TPBHalfBarrelXplus"), + DOF = cms.string("Y"), + cut = cms.double(10.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPBHalfBarrelXplus"), + DOF = cms.string("thetaY"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPBHalfBarrelXplus"), + DOF = cms.string("Z"), + cut = cms.double(15.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPBHalfBarrelXplus"), + DOF = cms.string("thetaZ"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + ### Forward Pixel HC X-,Z- + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZminus"), + DOF = cms.string("X"), + cut = cms.double(5.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZminus"), + DOF = cms.string("thetaX"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZminus"), + DOF = cms.string("Y"), + cut = cms.double(10.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZminus"), + DOF = cms.string("thetaY"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZminus"), + DOF = cms.string("Z"), + cut = cms.double(15.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZminus"), + DOF = cms.string("thetaZ"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + ### Forward Pixel HC X+,Z- + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZminus"), + DOF = cms.string("X"), + cut = cms.double(5.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZminus"), + DOF = cms.string("thetaX"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZminus"), + DOF = cms.string("Y"), + cut = cms.double(10.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZminus"), + DOF = cms.string("thetaY"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZminus"), + DOF = cms.string("Z"), + cut = cms.double(15.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZminus"), + DOF = cms.string("thetaZ"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + ### Forward Pixel HC X-,Z+ + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZplus"), + DOF = cms.string("X"), + cut = cms.double(5.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZplus"), + DOF = cms.string("thetaX"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZplus"), + DOF = cms.string("Y"), + cut = cms.double(10.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZplus"), + DOF = cms.string("thetaY"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZplus"), + DOF = cms.string("Z"), + cut = cms.double(15.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXminusZplus"), + DOF = cms.string("thetaZ"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + ### Forward Pixel HC X+,Z+ + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZplus"), + DOF = cms.string("X"), + cut = cms.double(5.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZplus"), + DOF = cms.string("thetaX"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZplus"), + DOF = cms.string("Y"), + cut = cms.double(10.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZplus"), + DOF = cms.string("thetaY"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZplus"), + DOF = cms.string("Z"), + cut = cms.double(15.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ), + + cms.PSet(alignableId = cms.string("TPEHalfCylinderXplusZplus"), + DOF = cms.string("thetaZ"), + cut = cms.double(30.0), + sigCut = cms.double(2.5), + maxMoveCut = cms.double(200.0), + maxErrorCut = cms.double(10.0) + ) + ) + diff --git a/CondFormats/PCLConfig/src/AlignPCLThreshold.cc b/CondFormats/PCLConfig/src/AlignPCLThreshold.cc new file mode 100644 index 0000000000000..b5bc6d247ab0b --- /dev/null +++ b/CondFormats/PCLConfig/src/AlignPCLThreshold.cc @@ -0,0 +1,40 @@ +#include "CondFormats/PCLConfig/interface/AlignPCLThreshold.h" +#include "FWCore/Utilities/interface/Exception.h" + +AlignPCLThreshold:: AlignPCLThreshold(coordThresholds X, + coordThresholds tX, + coordThresholds Y, + coordThresholds tY, + coordThresholds Z, + coordThresholds tZ, + std::vector< coordThresholds > extraDOF + ){ + m_xCoord = X; + m_yCoord = Y; + m_zCoord = Z; + m_thetaXCoord = tX; + m_thetaYCoord = tY; + m_thetaZCoord = tZ; + m_extraDOF = extraDOF; + +}; + +//****************************************************************************// +std::array AlignPCLThreshold::getExtraDOFCuts(const unsigned int i) const { + + if(i +#include // std::setw + +//****************************************************************************// +void AlignPCLThresholds::setAlignPCLThreshold(const std::string &AlignableId, const AlignPCLThreshold & Threshold) { + m_thresholds[AlignableId]=Threshold; +} + +//****************************************************************************// +void AlignPCLThresholds::setAlignPCLThresholds(const int & Nrecords,const threshold_map & AlignPCLThresholds){ + m_nrecords=Nrecords; + m_thresholds=AlignPCLThresholds; +} + +//****************************************************************************// +void AlignPCLThresholds::setNRecords(const int &Nrecords){ + m_nrecords=Nrecords; +} + +//****************************************************************************// +AlignPCLThreshold AlignPCLThresholds::getAlignPCLThreshold(const std::string &AlignableId) const { + threshold_map::const_iterator it = m_thresholds.find(AlignableId); + + if (it != m_thresholds.end()){ + return it->second; + } else { + throw cms::Exception("AlignPCLThresholds")<< "No Thresholds defined for Alignable id " << AlignableId << "\n"; + } +} + +//****************************************************************************// +AlignPCLThreshold& AlignPCLThresholds::getAlignPCLThreshold(const std::string &AlignableId) { + return m_thresholds[AlignableId]; +} + +float AlignPCLThresholds::getSigCut(const std::string &AlignableId,const coordType &type) const { + AlignPCLThreshold a = getAlignPCLThreshold(AlignableId); + switch(type){ + case X: + return a.getSigXcut(); + case Y: + return a.getSigYcut(); + case Z: + return a.getSigZcut(); + case theta_X: + return a.getSigThetaXcut(); + case theta_Y: + return a.getSigThetaYcut(); + case theta_Z: + return a.getSigThetaZcut(); + default: + throw cms::Exception("AlignPCLThresholds")<<"Requested significance threshold for undefined coordinate"<< type << "\n"; + } +} + +//****************************************************************************// +// overloaded method +//****************************************************************************// +std::array AlignPCLThresholds::getSigCut(const std::string &AlignableId) const { + AlignPCLThreshold a = getAlignPCLThreshold(AlignableId); + return {{a.getSigXcut(),a.getSigYcut(), a.getSigZcut(), a.getSigThetaXcut(), a.getSigThetaYcut(),a.getSigThetaZcut()}}; +} + +float AlignPCLThresholds::getCut(const std::string &AlignableId,const coordType &type) const { + AlignPCLThreshold a = getAlignPCLThreshold(AlignableId); + switch(type){ + case X: + return a.getXcut(); + case Y: + return a.getYcut(); + case Z: + return a.getZcut(); + case theta_X: + return a.getThetaXcut(); + case theta_Y: + return a.getThetaYcut(); + case theta_Z: + return a.getThetaZcut(); + default: + throw cms::Exception("AlignPCLThresholds")<<"Requested significance threshold for undefined coordinate"<< type << "\n"; + } +} + +//****************************************************************************// +// overloaded method +//****************************************************************************// +std::array AlignPCLThresholds::getCut(const std::string &AlignableId) const { + AlignPCLThreshold a = getAlignPCLThreshold(AlignableId); + return {{a.getXcut(),a.getYcut(), a.getZcut(), a.getThetaXcut(), a.getThetaYcut(),a.getThetaZcut()}}; +} + +//****************************************************************************// +float AlignPCLThresholds::getMaxMoveCut(const std::string &AlignableId,const coordType &type) const { + AlignPCLThreshold a = getAlignPCLThreshold(AlignableId); + switch(type){ + case X: + return a.getMaxMoveXcut(); + case Y: + return a.getMaxMoveYcut(); + case Z: + return a.getMaxMoveZcut(); + case theta_X: + return a.getMaxMoveThetaXcut(); + case theta_Y: + return a.getMaxMoveThetaYcut(); + case theta_Z: + return a.getMaxMoveThetaZcut(); + default: + throw cms::Exception("AlignPCLThresholds")<<"Requested significance threshold for undefined coordinate"<< type << "\n"; + } +} + +//****************************************************************************// +// overloaded method +//****************************************************************************// +std::array AlignPCLThresholds::getMaxMoveCut(const std::string &AlignableId) const { + AlignPCLThreshold a = getAlignPCLThreshold(AlignableId); + return {{a.getMaxMoveXcut(),a.getMaxMoveYcut(), a.getMaxMoveZcut(), a.getMaxMoveThetaXcut(), a.getMaxMoveThetaYcut(),a.getMaxMoveThetaZcut()}}; +} + +//****************************************************************************// +float AlignPCLThresholds::getMaxErrorCut(const std::string &AlignableId,const coordType &type) const { + AlignPCLThreshold a = getAlignPCLThreshold(AlignableId); + switch(type){ + case X: + return a.getErrorXcut(); + case Y: + return a.getErrorYcut(); + case Z: + return a.getErrorZcut(); + case theta_X: + return a.getErrorThetaXcut(); + case theta_Y: + return a.getErrorThetaYcut(); + case theta_Z: + return a.getErrorThetaZcut(); + default: + throw cms::Exception("AlignPCLThresholds")<<"Requested significance threshold for undefined coordinate"<< type << "\n"; + } +} + +//****************************************************************************// +// overloaded method +//****************************************************************************// +std::array AlignPCLThresholds::getMaxErrorCut(const std::string &AlignableId) const { + AlignPCLThreshold a = getAlignPCLThreshold(AlignableId); + return {{a.getErrorXcut(),a.getErrorYcut(), a.getErrorZcut(), a.getErrorThetaXcut(), a.getErrorThetaYcut(),a.getErrorThetaZcut()}}; +} + +//****************************************************************************// +std::array AlignPCLThresholds::getExtraDOFCutsForAlignable(const std::string &AlignableId,const unsigned int i) const { + AlignPCLThreshold a = getAlignPCLThreshold(AlignableId); + return a.getExtraDOFCuts(i); +} + +//****************************************************************************// +std::string AlignPCLThresholds::getExtraDOFLabelForAlignable(const std::string &AlignableId,const unsigned int i) const +{ + AlignPCLThreshold a = getAlignPCLThreshold(AlignableId); + return a.getExtraDOFLabel(i); +} + +//****************************************************************************// +void AlignPCLThresholds::printAll() const { + + edm::LogVerbatim("AlignPCLThresholds")<<"AlignPCLThresholds::printAll()"; + edm::LogVerbatim("AlignPCLThresholds")<<" ==================================================================================================================="; + edm::LogVerbatim("AlignPCLThresholds")<<"N records cut: "<getNrecords(); + for(auto it = m_thresholds.begin(); it != m_thresholds.end() ; ++it){ + edm::LogVerbatim("AlignPCLThresholds")<<" ==================================================================================================================="; + edm::LogVerbatim("AlignPCLThresholds")<<"key : " << it->first <<" \n" + <<"- Xcut : " <second).getXcut() <second).getSigXcut() <second).getMaxMoveXcut() <second).getErrorXcut() <second).getThetaXcut() <second).getSigThetaXcut() <second).getMaxMoveThetaXcut()<second).getErrorThetaXcut() <second).getYcut() <second).getSigXcut() <second).getMaxMoveYcut() <second).getErrorYcut() <second).getThetaYcut() <second).getSigThetaYcut() <second).getMaxMoveThetaYcut()<second).getErrorThetaYcut() <second).getZcut() <second).getSigZcut() <second).getMaxMoveZcut() <second).getErrorZcut() <second).getThetaZcut() <second).getSigThetaZcut() <second).getMaxMoveThetaZcut()<second).getErrorThetaZcut() <second).hasExtraDOF()){ + for (unsigned int j=0; j<(it->second).extraDOFSize(); j++){ + std::array extraDOFCuts = getExtraDOFCutsForAlignable(it->first,j); + + edm::LogVerbatim("AlignPCLThresholds")<<"Extra DOF " << j << " with label: "<first,j); + edm::LogVerbatim("AlignPCLThresholds") <<"- cut : " << std::setw(4) << extraDOFCuts.at(0) << std::setw(5)<<" " + <<"| sigCut : " << std::setw(4) << extraDOFCuts.at(1) << std::setw(1)<<" " + <<"| maxMoveCut : " << std::setw(4) << extraDOFCuts.at(2) << std::setw(5)<<" " + <<"| maxErrorCut : " << std::setw(4) << extraDOFCuts.at(3) << std::setw(5)<<" "; + } + } + } +} + +//****************************************************************************// +std::vector AlignPCLThresholds::getAlignableList() const { + std::vector alignables_; + alignables_.reserve(m_thresholds.size()); + + for(auto it = m_thresholds.begin(); it != m_thresholds.end() ; ++it){ + alignables_.push_back(it->first); + } + return alignables_; +} diff --git a/CondFormats/PCLConfig/src/T_EventSetup_AlignPCLThresholds.cc b/CondFormats/PCLConfig/src/T_EventSetup_AlignPCLThresholds.cc new file mode 100644 index 0000000000000..56b38199626ee --- /dev/null +++ b/CondFormats/PCLConfig/src/T_EventSetup_AlignPCLThresholds.cc @@ -0,0 +1,4 @@ +#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(AlignPCLThresholds); diff --git a/CondFormats/PCLConfig/src/classes.h b/CondFormats/PCLConfig/src/classes.h new file mode 100644 index 0000000000000..5c3c07d48aabf --- /dev/null +++ b/CondFormats/PCLConfig/src/classes.h @@ -0,0 +1,7 @@ +#include "CondFormats/PCLConfig/src/headers.h" + +namespace CondFormats_AlignPCLThresholds{ + struct dictionary { + std::map mythresholdmap; + }; +} diff --git a/CondFormats/PCLConfig/src/classes_def.xml b/CondFormats/PCLConfig/src/classes_def.xml new file mode 100644 index 0000000000000..39195a5fe5e08 --- /dev/null +++ b/CondFormats/PCLConfig/src/classes_def.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/CondFormats/PCLConfig/src/headers.h b/CondFormats/PCLConfig/src/headers.h new file mode 100644 index 0000000000000..18b6ffff08c4a --- /dev/null +++ b/CondFormats/PCLConfig/src/headers.h @@ -0,0 +1 @@ +#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" diff --git a/CondFormats/PCLConfig/test/AlignPCLThresholdsReader_cfg.py b/CondFormats/PCLConfig/test/AlignPCLThresholdsReader_cfg.py new file mode 100644 index 0000000000000..af1810cf68061 --- /dev/null +++ b/CondFormats/PCLConfig/test/AlignPCLThresholdsReader_cfg.py @@ -0,0 +1,62 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("ProcessOne") + +## +## MessageLogger +## +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.categories.append("AlignPCLThresholdsReader") +process.MessageLogger.categories.append("AlignPCLThresholds") +process.MessageLogger.destinations = cms.untracked.vstring("cout") +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string("INFO"), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), + reportEvery = cms.untracked.int32(1000) + ), + AlignPCLThresholdsReader = cms.untracked.PSet( limit = cms.untracked.int32(-1)), + AlignPCLThresholds = cms.untracked.PSet( limit = cms.untracked.int32(-1)) + ) +process.MessageLogger.statistics.append('cout') + +## +## Empty Source +## +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) + ) +## +## Get the payload +## +from CondCore.CondDB.CondDB_cfi import * +CondDBThresholds = CondDB.clone(connect = cms.string("sqlite_file:mythresholds.db")) + +process.dbInput = cms.ESSource("PoolDBESSource", + CondDBThresholds, + toGet = cms.VPSet(cms.PSet(record = cms.string('AlignPCLThresholdsRcd'), + tag = cms.string('PCLThresholds_express_v0') # choose tag you want + ) + ) + ) +## +## Retrieve it and check it's available in the ES +## +process.get = cms.EDAnalyzer("EventSetupRecordDataGetter", + toGet = cms.VPSet(cms.PSet(record = cms.string('AlignPCLThresholdsRcd'), + data = cms.vstring('AlignPCLThresholds') + ) + ), + verbose = cms.untracked.bool(True) + ) +## +## Read it back +## +process.ReadDB = cms.EDAnalyzer("AlignPCLThresholdsReader") +process.ReadDB.printDebug = cms.untracked.bool(True) +process.ReadDB.outputFile = cms.untracked.string('AlignPCLThresholds.log') + +process.p = cms.Path(process.get+process.ReadDB) diff --git a/CondFormats/PCLConfig/test/AlignPCLThresholdsWriter_cfg.py b/CondFormats/PCLConfig/test/AlignPCLThresholdsWriter_cfg.py new file mode 100644 index 0000000000000..a6b677ce18790 --- /dev/null +++ b/CondFormats/PCLConfig/test/AlignPCLThresholdsWriter_cfg.py @@ -0,0 +1,82 @@ +import FWCore.ParameterSet.Config as cms +import copy + +process = cms.Process("ProcessOne") + +## +## MessageLogger +## +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.categories.append("AlignPCLThresholdsWriter") +process.MessageLogger.categories.append("AlignPCLThresholds") +process.MessageLogger.destinations = cms.untracked.vstring("cout") +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string("INFO"), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), + reportEvery = cms.untracked.int32(1000) + ), + AlignPCLThresholdsWriter = cms.untracked.PSet( limit = cms.untracked.int32(-1)), + AlignPCLThresholds = cms.untracked.PSet( limit = cms.untracked.int32(-1)) + ) +process.MessageLogger.statistics.append('cout') + +## +## Empty source +## +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) + ) +## +## Database output service +## +process.load("CondCore.CondDB.CondDB_cfi") + +## +## Output database (in this case local sqlite file) +## +process.CondDB.connect = 'sqlite_file:mythresholds.db' +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + timetype = cms.untracked.string('runnumber'), + toPut = cms.VPSet(cms.PSet(record = cms.string('AlignPCLThresholdsRcd'), + tag = cms.string('PCLThresholds_express_v0') + ) + ) + ) + +## +## Impot the thresholds configuration +## +import CondFormats.PCLConfig.Thresholds_cff as Thresholds + +## +## Example on how to add to the default extra degrees of freedom +## +AddSurfaceThresholds = copy.deepcopy(Thresholds.default) +BPixSurface= cms.VPSet( + cms.PSet(alignableId = cms.string("TPBModule"), + DOF = cms.string("Surface1"), + cut = cms.double(0.1), + sigCut = cms.double(0.1), + maxMoveCut = cms.double(0.1), + maxErrorCut = cms.double(10.0) + ) + ) + +DefaultPlusSurface = AddSurfaceThresholds+BPixSurface +#print DefaultPlusSurface.dumpPython() + +process.WriteInDB = cms.EDAnalyzer("AlignPCLThresholdsWriter", + record= cms.string('AlignPCLThresholdsRcd'), + ### minimum number of records found in pede output + minNRecords = cms.uint32(25000), + #thresholds = cms.VPSet() # empty object + #thresholds = DefaultPlusSurface # add extra deegree of freedom + thresholds = Thresholds.default # as a cms.VPset + ) + +process.p = cms.Path(process.WriteInDB) diff --git a/CondFormats/PCLConfig/test/BuildFile.xml b/CondFormats/PCLConfig/test/BuildFile.xml new file mode 100644 index 0000000000000..ac3a5afd29dd1 --- /dev/null +++ b/CondFormats/PCLConfig/test/BuildFile.xml @@ -0,0 +1,3 @@ + + + diff --git a/CondFormats/PCLConfig/test/testSerializationPCLConfig.cpp b/CondFormats/PCLConfig/test/testSerializationPCLConfig.cpp new file mode 100644 index 0000000000000..517b5baeb7d89 --- /dev/null +++ b/CondFormats/PCLConfig/test/testSerializationPCLConfig.cpp @@ -0,0 +1,11 @@ +#include "CondFormats/Serialization/interface/Test.h" + +#include "../src/headers.h" + +int main() +{ + testSerialization(); + testSerialization>(); + //testSerialization>(); + return 0; +}