Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTPPS conditions database layout #18359

Merged
merged 6 commits into from May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions CondCore/CTPPSPlugins/BuildFile.xml
@@ -0,0 +1,10 @@
<use name="FWCore/Framework"/>
<use name="FWCore/PluginManager"/>
<use name="CondCore/ESSources"/>
<use name="CondFormats/CTPPSReadoutObjects"/>
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/Serialization"/>
<use name="root"/>
<use name="boost"/>
<use name="boost_serialization"/>
<flags EDM_PLUGIN="1"/>
9 changes: 9 additions & 0 deletions CondCore/CTPPSPlugins/src/plugin.cc
@@ -0,0 +1,9 @@
#include "CondCore/ESSources/interface/registration_macros.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelDAQMapping.h"
#include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelAnalysisMask.h"
#include "CondFormats/DataRecord/interface/CTPPSPixelAnalysisMaskRcd.h"


REGISTER_PLUGIN(CTPPSPixelDAQMappingRcd,CTPPSPixelDAQMapping);
REGISTER_PLUGIN(CTPPSPixelAnalysisMaskRcd,CTPPSPixelAnalysisMask);
1 change: 1 addition & 0 deletions CondCore/Utilities/BuildFile.xml
Expand Up @@ -32,6 +32,7 @@
<use name="CondFormats/BTauObjects"/>
<use name="CondFormats/MFObjects"/>
<use name="CondFormats/PCLConfig"/>
<use name="CondFormats/CTPPSReadoutObjects"/>
<export>
<lib name="1"/>
</export>
2 changes: 2 additions & 0 deletions CondCore/Utilities/src/CondDBFetch.cc
Expand Up @@ -50,6 +50,8 @@ namespace cond {
FETCH_PAYLOAD_CASE( CSCDDUMap )
FETCH_PAYLOAD_CASE( CSCL1TPParameters )
FETCH_PAYLOAD_CASE( CSCRecoDigiParameters )
FETCH_PAYLOAD_CASE( CTPPSPixelDAQMapping )
FETCH_PAYLOAD_CASE( CTPPSPixelAnalysisMask )
FETCH_PAYLOAD_CASE( CastorChannelQuality )
FETCH_PAYLOAD_CASE( CastorElectronicsMap )
FETCH_PAYLOAD_CASE( CastorGainWidths )
Expand Down
2 changes: 2 additions & 0 deletions CondCore/Utilities/src/CondDBImport.cc
Expand Up @@ -64,6 +64,8 @@ namespace cond {
IMPORT_PAYLOAD_CASE( CSCDDUMap )
IMPORT_PAYLOAD_CASE( CSCL1TPParameters )
IMPORT_PAYLOAD_CASE( CSCRecoDigiParameters )
IMPORT_PAYLOAD_CASE( CTPPSPixelDAQMapping )
IMPORT_PAYLOAD_CASE( CTPPSPixelAnalysisMask )
IMPORT_PAYLOAD_CASE( CastorChannelQuality )
IMPORT_PAYLOAD_CASE( CastorElectronicsMap )
IMPORT_PAYLOAD_CASE( CastorGainWidths )
Expand Down
2 changes: 2 additions & 0 deletions CondCore/Utilities/src/CondFormats.h
Expand Up @@ -26,6 +26,8 @@
#include "CondFormats/CSCObjects/interface/CSCDBPedestals.h"
#include "CondFormats/CSCObjects/interface/CSCDDUMap.h"
#include "CondFormats/CSCObjects/interface/CSCL1TPParameters.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelDAQMapping.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelAnalysisMask.h"
#include "CondFormats/DTObjects/interface/DTCCBConfig.h"
#include "CondFormats/DTObjects/interface/DTDeadFlag.h"
#include "CondFormats/DTObjects/interface/DTHVStatus.h"
Expand Down
7 changes: 7 additions & 0 deletions CondTools/CTPPS/BuildFile.xml
@@ -0,0 +1,7 @@
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/CTPPSReadoutObjects"/>
<use name="CondCore/DBOutputService"/>
<use name="FWCore/ServiceRegistry"/>
<use name="root"/>
<use name="rootcore"/>
<flags EDM_PLUGIN="1"/>
10 changes: 10 additions & 0 deletions CondTools/CTPPS/plugins/BuildFile.xml
@@ -0,0 +1,10 @@
<use name="CondFormats/CTPPSReadoutObjects"/>
<use name="CondCore/PopCon"/>
<use name="CondCore/CondDB"/>
<use name="CondCore/DBOutputService"/>
<use name="FWCore/Framework"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/ParameterSet"/>
<use name="CondFormats/DataRecord"/>
<flags EDM_PLUGIN="1"/>
80 changes: 80 additions & 0 deletions CondTools/CTPPS/plugins/CTPPSPixelDAQMappingAnalyzer.cc
@@ -0,0 +1,80 @@
// system include files
#include <memory>

#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 "CondCore/CondDB/interface/Time.h"

#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelDAQMapping.h"
#include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelAnalysisMask.h"
#include "CondFormats/DataRecord/interface/CTPPSPixelAnalysisMaskRcd.h"

using namespace std;

class CTPPSPixelDAQMappingAnalyzer : public edm::EDAnalyzer {
public:

string label_;
cond::Time_t daqmappingiov_;
cond::Time_t analysismaskiov_;

explicit CTPPSPixelDAQMappingAnalyzer(edm::ParameterSet const& iConfig):
label_(iConfig.getUntrackedParameter<string>("label", "RPix")),
daqmappingiov_(iConfig.getParameter<unsigned long long>("daqmappingiov")),
analysismaskiov_(iConfig.getParameter<unsigned long long>("analysismaskiov"))
{}
explicit CTPPSPixelDAQMappingAnalyzer(int i) {}
virtual ~CTPPSPixelDAQMappingAnalyzer() {}
virtual void analyze(const edm::Event& e, const edm::EventSetup& c) override;
};


void
CTPPSPixelDAQMappingAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context){

using namespace edm;

/*edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("CTPPSPixelDAQMappingRcd"));
if( recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
//record not found
std::cout <<"Record \"CTPPSPixelDAQMappingRcd"<<"\" does not exist "<<std::endl;
}*/


//this part gets the handle of the event source and the record (i.e. the Database)
if (e.id().run() == daqmappingiov_){
ESHandle<CTPPSPixelDAQMapping> mapping;
context.get<CTPPSPixelDAQMappingRcd>().get("RPix", mapping);

// print mapping
/*printf("* DAQ mapping\n");
for (const auto &p : mapping->ROCMapping)
std::cout << " " << p.first << " -> " << p.second << std::endl;*/
}

//edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("CTPPSPixelAnalysisMaskRcd"));
//if( recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
//record not found
//std::cout <<"Record \"CTPPSPixelAnalysisMaskRcd"<<"\" does not exist "<<std::endl;
//}

if (e.id().run() == analysismaskiov_){
// get analysis mask to mask channels
ESHandle<CTPPSPixelAnalysisMask> analysisMask;
context.get<CTPPSPixelAnalysisMaskRcd>().get(label_, analysisMask);

// print mask
/*printf("* mask\n");
for (const auto &p : analysisMask->analysisMask)
cout << " " << p.first
<< ": fullMask=" << p.second.fullMask
<< ", number of masked channels " << p.second.maskedPixels.size() << endl;
*/
}

}
DEFINE_FWK_MODULE(CTPPSPixelDAQMappingAnalyzer);
87 changes: 87 additions & 0 deletions CondTools/CTPPS/src/WriteCTPPSPixelAnalysisMask.cc
@@ -0,0 +1,87 @@
/****************************************************************************
*
* Offline analyzer for writing CTPPS Analysis Mask sqlite file
* H. Malbouisson
* based on TOTEM code from Jan Kašpar (jan.kaspar@gmail.com)
*
****************************************************************************/

#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "CondCore/CondDB/interface/Time.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"

#include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h"
#include "CondFormats/DataRecord/interface/CTPPSPixelAnalysisMaskRcd.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelDAQMapping.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelAnalysisMask.h"

#include <stdint.h>

//----------------------------------------------------------------------------------------------------

/**
*\brief Prints the Analysis Mask loaded by TotemDAQMappingESSourceXML.
**/
class WriteCTPPSPixelAnalysisMask : public edm::one::EDAnalyzer<>
{
public:
WriteCTPPSPixelAnalysisMask(const edm::ParameterSet &ps);
~WriteCTPPSPixelAnalysisMask() {}

private:
virtual void analyze(const edm::Event &e, const edm::EventSetup &es) override;
cond::Time_t analysismaskiov_;
std::string record_;
std::string label_;
};

using namespace std;
using namespace edm;

//----------------------------------------------------------------------------------------------------

WriteCTPPSPixelAnalysisMask::WriteCTPPSPixelAnalysisMask(const edm::ParameterSet &ps) :
analysismaskiov_(ps.getParameter<unsigned long long>("analysismaskiov")),
record_(ps.getParameter<string>("record")),
label_(ps.getParameter<string>("label"))
{}


void WriteCTPPSPixelAnalysisMask::analyze(const edm::Event&, edm::EventSetup const& es)
{

// get analysis mask to mask channels
ESHandle<CTPPSPixelAnalysisMask> analysisMask;
es.get<CTPPSPixelAnalysisMaskRcd>().get(label_, analysisMask);

/*// print analysisMask
printf("* mask\n");
for (const auto &p : analysisMask->analysisMask)
cout << " " << p.first
<< ": fullMask=" << p.second.fullMask
<< ", number of masked channels " << p.second.maskedPixels.size() << endl;
*/

// Write Analysis Mask to sqlite file:
const CTPPSPixelAnalysisMask* pCTPPSPixelAnalysisMask = analysisMask.product(); // Analysis Mask
edm::Service<cond::service::PoolDBOutputService> poolDbService;
if( poolDbService.isAvailable() ){
poolDbService->writeOne( pCTPPSPixelAnalysisMask, analysismaskiov_, /*m_record*/ record_ );
}


}

//----------------------------------------------------------------------------------------------------

DEFINE_FWK_MODULE(WriteCTPPSPixelAnalysisMask);
86 changes: 86 additions & 0 deletions CondTools/CTPPS/src/WriteCTPPSPixelDAQMapping.cc
@@ -0,0 +1,86 @@
/****************************************************************************
*
* Offline analyzer for writing CTPPS DAQ Mapping sqlite file
* H. Malbouisson
* based on TOTEM code from Jan Kašpar (jan.kaspar@gmail.com)
*
****************************************************************************/


#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "CondCore/CondDB/interface/Time.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"

#include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h"
#include "CondFormats/DataRecord/interface/CTPPSPixelAnalysisMaskRcd.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelDAQMapping.h"
#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelAnalysisMask.h"

#include <stdint.h>

//----------------------------------------------------------------------------------------------------

/**
*\brief Prints the DAQ mapping loaded by TotemDAQMappingESSourceXML.
**/
class WriteCTPPSPixelDAQMapping : public edm::one::EDAnalyzer<>
{
public:
WriteCTPPSPixelDAQMapping(const edm::ParameterSet &ps);
~WriteCTPPSPixelDAQMapping() {}

private:
virtual void analyze(const edm::Event &e, const edm::EventSetup &es) override;
cond::Time_t daqmappingiov_;
std::string record_;
std::string label_;
};

using namespace std;
using namespace edm;

//----------------------------------------------------------------------------------------------------

WriteCTPPSPixelDAQMapping::WriteCTPPSPixelDAQMapping(const edm::ParameterSet &ps) :
daqmappingiov_(ps.getParameter<unsigned long long>("daqmappingiov")),
record_(ps.getParameter<string>("record")),
label_(ps.getParameter<string>("label"))
{}


void WriteCTPPSPixelDAQMapping::analyze(const edm::Event&, edm::EventSetup const& es)
{

// get DAQ mapping
edm::ESHandle<CTPPSPixelDAQMapping> mapping;
es.get<CTPPSPixelDAQMappingRcd>().get(label_, mapping);

// print mapping
/*printf("* DAQ mapping\n");
for (const auto &p : mapping->ROCMapping)
cout << " " << p.first << " -> " << p.second << endl;
*/

// Write DAQ Mapping to sqlite file:
const CTPPSPixelDAQMapping* pCTPPSPixelDAQMapping = mapping.product(); // DAQ Mapping
edm::Service<cond::service::PoolDBOutputService> poolDbService;
if( poolDbService.isAvailable() ){
poolDbService->writeOne( pCTPPSPixelDAQMapping, daqmappingiov_, /*m_record*/ record_ );
}


}

//----------------------------------------------------------------------------------------------------

DEFINE_FWK_MODULE(WriteCTPPSPixelDAQMapping);
45 changes: 45 additions & 0 deletions CondTools/CTPPS/test/retrieve-sqlite-daqmap-analysismask_cfg.py
@@ -0,0 +1,45 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("ProcessOne")

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")
# input database (in this case local sqlite file)
process.CondDB.connect = 'sqlite_file:CTPPSPixel_DAQMapping_AnalysisMask.db'
##process.CondDB.connect = 'sqlite_file:test.db'

process.PoolDBESSource = cms.ESSource("PoolDBESSource",
process.CondDB,
DumpStat=cms.untracked.bool(True),
toGet = cms.VPSet(
cms.PSet(
record = cms.string('CTPPSPixelDAQMappingRcd'),
tag = cms.string("PixelDAQMapping"),
label = cms.untracked.string("RPix")
),
cms.PSet(
record = cms.string('CTPPSPixelAnalysisMaskRcd'),
tag = cms.string("PixelAnalysisMask"),
label = cms.untracked.string("RPix")
)
)
)



process.readSqlite = cms.EDAnalyzer("CTPPSPixelDAQMappingAnalyzer",
cms.PSet(
analysismaskiov = cms.uint64(1),
daqmappingiov = cms.uint64(1),
label = cms.untracked.string("RPix")
)
)

process.p = cms.Path(process.readSqlite)