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

Moving esConsumes statement from the analyze method into the constructor #37650

Merged
merged 3 commits into from
Apr 22, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CondTools/Hcal/interface/BoostIODBReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ class BoostIODBReader : public edm::one::EDAnalyzer<> {
private:
void analyze(const edm::Event&, const edm::EventSetup&) override;

std::string outputFile_;
const std::string outputFile_;
const edm::ESGetToken<DataType, RecordType> tok_;
};

template <class DataType, class RecordType>
BoostIODBReader<DataType, RecordType>::BoostIODBReader(const edm::ParameterSet& ps)
: outputFile_(ps.getParameter<std::string>("outputFile")) {}
: outputFile_(ps.getParameter<std::string>("outputFile")), tok_(esConsumes<DataType, RecordType>()) {}

template <class DataType, class RecordType>
void BoostIODBReader<DataType, RecordType>::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
edm::ESGetToken<DataType, RecordType> tok = esConsumes<DataType, RecordType>();
const DataType* p = &iSetup.getData(tok);
const DataType* p = &iSetup.getData(tok_);

std::ofstream of(outputFile_.c_str(), std::ios_base::binary);
if (!of.is_open())
Expand Down
5 changes: 5 additions & 0 deletions CondTools/Hcal/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<lib name="PMTParams"/>
</bin>

<bin file="HFPhase1PMTParams_unittest.cc">
<flags TEST_RUNNER_ARGS = "/bin/bash CondTools/Hcal/test testHFPhase1PMTParams.sh"/>
<use name="FWCore/Utilities"/>
</bin>

<library file="HcalConditionsTest.cc" name="testCondToolsConTHcal">
<flags EDM_PLUGIN="1"/>
</library>
2 changes: 2 additions & 0 deletions CondTools/Hcal/test/HFPhase1PMTParams_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "FWCore/Utilities/interface/TestHelper.h"
RUNTEST()
15 changes: 15 additions & 0 deletions CondTools/Hcal/test/testHFPhase1PMTParams.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

function die { echo $1: status $2 ; exit $2; }

echo "TESTING HFPhase1PMTParams generation code ..."
${CMSSW_BASE}/test/${SCRAM_ARCH}/write_HFPhase1PMTParams 1 HFPhase1PMTParams_V00_mc.bbin || die "Failure running write_HFPhase1PMTParams" $?

echo "TESTING HFPhase1PMTParams database creation code ..."
cmsRun ${LOCAL_TEST_DIR}/HFPhase1PMTParamsDBWriter_cfg.py || die "Failure running HFPhase1PMTParamsDBWriter_cfg.py" $?

echo "TESTING HFPhase1PMTParams database reading code ..."
cmsRun ${LOCAL_TEST_DIR}/HFPhase1PMTParamsDBReader_cfg.py || die "Failure running HFPhase1PMTParamsDBReader_cfg.py" $?

echo "TESTING that we can restore HFPhase1PMTParams from the database ..."
diff HFPhase1PMTParams_V00_mc.bbin dbread.bbin || die "Database contents differ from the original" $?