-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add SiPhase2OuterTrackerLorentzAngleReader and use it in unit tests
- Loading branch information
Showing
3 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
CondTools/SiPhase2Tracker/plugins/SiPhase2OuterTrackerLorentzAngleReader.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// user include files | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/one/EDAnalyzer.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/ServiceRegistry/interface/Service.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "CondFormats/DataRecord/interface/SiPhase2OuterTrackerLorentzAngleRcd.h" | ||
#include "CondFormats/SiPhase2TrackerObjects/interface/SiPhase2OuterTrackerLorentzAngle.h" | ||
|
||
// | ||
// | ||
// class decleration | ||
// | ||
class SiPhase2OuterTrackerLorentzAngleReader : public edm::one::EDAnalyzer<> { | ||
public: | ||
explicit SiPhase2OuterTrackerLorentzAngleReader(const edm::ParameterSet&); | ||
~SiPhase2OuterTrackerLorentzAngleReader() override = default; | ||
void analyze(const edm::Event&, const edm::EventSetup&) override; | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
||
private: | ||
uint32_t printdebug_; | ||
std::string label_; | ||
edm::ESGetToken<SiPhase2OuterTrackerLorentzAngle, SiPhase2OuterTrackerLorentzAngleRcd> laToken_; | ||
}; | ||
|
||
SiPhase2OuterTrackerLorentzAngleReader::SiPhase2OuterTrackerLorentzAngleReader(const edm::ParameterSet& iConfig) | ||
: printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug", 5)), | ||
label_(iConfig.getUntrackedParameter<std::string>("label", "")), | ||
laToken_(esConsumes(edm::ESInputTag{"", label_})) {} | ||
|
||
void SiPhase2OuterTrackerLorentzAngleReader::analyze(const edm::Event& e, const edm::EventSetup& iSetup) { | ||
const auto& lorentzAngles = iSetup.getData(laToken_); | ||
edm::LogInfo("SiPhase2OuterTrackerLorentzAngleReader") | ||
<< "[SiPhase2OuterTrackerLorentzAngleReader::analyze] End Reading SiPhase2OuterTrackerLorentzAngle with label " << label_ << std::endl; | ||
|
||
const auto& detid_la = lorentzAngles.getLorentzAngles(); | ||
std::unordered_map<unsigned int, float>::const_iterator it; | ||
size_t count = 0; | ||
for (it = detid_la.begin(); it != detid_la.end() && count < printdebug_; it++) { | ||
edm::LogInfo("SiPhase2OuterTrackerLorentzAngleReader") << "detid " << it->first << " \t" | ||
<< " Lorentz angle " << it->second; | ||
count++; | ||
} | ||
} | ||
|
||
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ | ||
void SiPhase2OuterTrackerLorentzAngleReader::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
desc.setComment("Module to read SiPhase2OuterTrackerLorentzAngle Payloads"); | ||
desc.addUntracked<uint32_t>("printDebug",5)->setComment("maximum amount of print-outs"); | ||
desc.addUntracked<std::string>("label", "")->setComment("label from which to read the payload"); | ||
descriptions.addWithDefaultLabel(desc); | ||
} | ||
|
||
//define this as a plug-in | ||
DEFINE_FWK_MODULE(SiPhase2OuterTrackerLorentzAngleReader); |
67 changes: 67 additions & 0 deletions
67
CondTools/SiPhase2Tracker/test/SiPhase2OuterTrackerLorentzAngleReader_cfg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#! /usr/bin/env cmsRun | ||
# Author: Marco Musich (October 2021) | ||
import FWCore.ParameterSet.Config as cms | ||
process = cms.Process("TEST") | ||
|
||
################################################################### | ||
# Messages | ||
################################################################### | ||
process.load('FWCore.MessageService.MessageLogger_cfi') | ||
process.MessageLogger.cerr.enable = False | ||
process.MessageLogger.SiPhase2OuterTrackerLorentzAngleReader=dict() | ||
process.MessageLogger.SiPhase2OuterTrackerLorentzAngle=dict() | ||
process.MessageLogger.cout = cms.untracked.PSet( | ||
enable = cms.untracked.bool(True), | ||
enableStatistics = cms.untracked.bool(True), | ||
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) | ||
), | ||
SiPhase2OuterTrackerLorentzAngleReader = cms.untracked.PSet( limit = cms.untracked.int32(-1)), | ||
SiPhase2OuterTrackerLorentzAngle = cms.untracked.PSet( limit = cms.untracked.int32(-1)), | ||
) | ||
|
||
################################################################### | ||
# Input data | ||
################################################################### | ||
tag = 'SiPhase2OuterTrackerLorentzAngle_T15' | ||
suffix = 'v0' | ||
inFile = tag+'_'+suffix+'.db' | ||
inDB = 'sqlite_file:'+inFile | ||
|
||
process.load("CondCore.CondDB.CondDB_cfi") | ||
# input database (in this case the local sqlite file) | ||
process.CondDB.connect = inDB | ||
|
||
process.PoolDBESSource = cms.ESSource("PoolDBESSource", | ||
process.CondDB, | ||
DumpStat=cms.untracked.bool(True), | ||
toGet = cms.VPSet(cms.PSet(record = cms.string(''), | ||
tag = cms.string(tag)) | ||
) | ||
) | ||
|
||
################################################################### | ||
# check the ES data getter | ||
################################################################### | ||
process.get = cms.EDAnalyzer("EventSetupRecordDataGetter", | ||
toGet = cms.VPSet(cms.PSet( | ||
record = cms.string(' SiPhase2OuterTrackerLorentzAngleRcd'), | ||
data = cms.vstring('SiPhase2OuterTrackerLorentzAngle') | ||
)), | ||
verbose = cms.untracked.bool(True) | ||
) | ||
|
||
################################################################### | ||
# Payload reader | ||
################################################################### | ||
import CondTools.SiPhase2Tracker.siPhase2OuterTrackerLorentzAngleReader_cfi.py as _mod | ||
process.LAPayloadReader = _mod.siPhase2OuterTrackerLorentzAngleReader.clone(printDebug = 10, | ||
label = "") | ||
|
||
################################################################### | ||
# Path | ||
################################################################### | ||
process.p = cms.Path(process.LAPayloadReader) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters