Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added integration test for edm::soa::Table<> as a data product
- Loading branch information
Showing
8 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<use name="DataFormats/Common"/> | ||
<flags GENREFLEX_FAILES_ON_WARNS="0"/> | ||
<export> | ||
<lib name="1"/> | ||
</export> |
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,42 @@ | ||
#ifndef DataFormats_TestObjects_TableTest_h | ||
#define DataFormats_TestObjects_TableTest_h | ||
// -*- C++ -*- | ||
// | ||
// Package: DataFormats/TestObjects | ||
// Class : TableTest | ||
// | ||
/**\class TableTest TableTest.h "DataFormats/TestObjects/interface/TableTest.h" | ||
Description: [one line class summary] | ||
Usage: | ||
<usage> | ||
*/ | ||
// | ||
// Original Author: Christopher Jones | ||
// Created: Thu, 31 Aug 2017 15:09:27 GMT | ||
// | ||
|
||
// system include files | ||
#include <string> | ||
|
||
// user include files | ||
#include "FWCore/SOA/interface/Column.h" | ||
#include "FWCore/SOA/interface/Table.h" | ||
|
||
// forward declarations | ||
namespace edmtest { | ||
//In an actual use of edm::soa::Table one would | ||
// define the columns in a place that allows sharing | ||
// of the definitions across many Tables | ||
|
||
SOA_DECLARE_COLUMN(AnInt, int, "anInt"); | ||
SOA_DECLARE_COLUMN(AFloat, float, "aFloat"); | ||
SOA_DECLARE_COLUMN(AString, std::string, "aString"); | ||
|
||
using TableTest = edm::soa::Table<AnInt,AFloat,AString>; | ||
} | ||
|
||
|
||
#endif |
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
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
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
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,84 @@ | ||
#include "FWCore/Framework/interface/global/EDProducer.h" | ||
#include "FWCore/Framework/interface/global/EDAnalyzer.h" | ||
#include "DataFormats/TestObjects/interface/TableTest.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/LuminosityBlock.h" | ||
#include "FWCore/Framework/interface/Run.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
|
||
namespace { | ||
std::vector<float> doublesToFloats(std::vector<double> const& iDoubles) { | ||
std::vector<float> t; | ||
t.reserve(iDoubles.size()); | ||
for(double d: iDoubles) { t.push_back( static_cast<float>(d) ); } | ||
return t; | ||
} | ||
} | ||
|
||
namespace edmtest { | ||
|
||
class TableTestProducer : public edm::global::EDProducer<> { | ||
public: | ||
TableTestProducer(edm::ParameterSet const& iConfig): | ||
anInts_(iConfig.getParameter<std::vector<int>>("anInts")), | ||
aFloats_(doublesToFloats(iConfig.getParameter<std::vector<double>>("aFloats"))), | ||
aStrings_(iConfig.getParameter<std::vector<std::string>>("aStrings")) { | ||
produces<edmtest::TableTest>(); | ||
} | ||
|
||
void produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const final { | ||
iEvent.put( std::make_unique<TableTest>(anInts_,aFloats_,aStrings_) ); | ||
} | ||
private: | ||
const std::vector<int> anInts_; | ||
const std::vector<float> aFloats_; | ||
const std::vector<std::string> aStrings_; | ||
}; | ||
|
||
class TableTestAnalyzer : public edm::global::EDAnalyzer<> { | ||
public: | ||
TableTestAnalyzer(edm::ParameterSet const& iConfig): | ||
anInts_(iConfig.getUntrackedParameter<std::vector<int>>("anInts")), | ||
aFloats_(doublesToFloats(iConfig.getUntrackedParameter<std::vector<double>>("aFloats"))), | ||
aStrings_(iConfig.getUntrackedParameter<std::vector<std::string>>("aStrings")) | ||
{ | ||
tableToken_ = consumes<edmtest::TableTest>(iConfig.getUntrackedParameter<edm::InputTag>("table")); | ||
if(anInts_.size() != aFloats_.size() or anInts_.size() != aStrings_.size()) { | ||
throw cms::Exception("Configuration")<<"anInts_, aFloats_, and aStrings_ must have the same length"; | ||
} | ||
} | ||
|
||
void analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const&) const final { | ||
edm::Handle<edmtest::TableTest> h; | ||
iEvent.getByToken(tableToken_, h); | ||
|
||
auto size = h->size(); | ||
if(size != anInts_.size()) { | ||
throw cms::Exception("RuntimeError")<<"Table size ("<<size<<") does not equal expected size ("<<anInts_.size()<<")"; | ||
} | ||
|
||
unsigned int index=0; | ||
for(auto const& row : *h) { | ||
if( anInts_[index] != row.get<edmtest::AnInt>() ) { | ||
throw cms::Exception("RuntimeError")<<"index "<<index<<" anInt ="<<row.get<edmtest::AnInt>()<<" expected "<<anInts_[index]; | ||
} | ||
if( aFloats_[index] != row.get<edmtest::AFloat>() ) { | ||
throw cms::Exception("RuntimeError")<<"index "<<index<<" aFloat ="<<row.get<edmtest::AFloat>()<<" expected "<<aFloats_[index]; | ||
} | ||
if( aStrings_[index] != row.get<edmtest::AString>() ) { | ||
throw cms::Exception("RuntimeError")<<"index "<<index<<" aString ="<<row.get<edmtest::AString>()<<" expected "<<aStrings_[index]; | ||
} | ||
++index; | ||
} | ||
} | ||
|
||
private: | ||
const std::vector<int> anInts_; | ||
const std::vector<float> aFloats_; | ||
const std::vector<std::string> aStrings_; | ||
edm::EDGetTokenT<edmtest::TableTest> tableToken_; | ||
}; | ||
} | ||
DEFINE_FWK_MODULE(edmtest::TableTestProducer); | ||
DEFINE_FWK_MODULE(edmtest::TableTestAnalyzer); |
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,31 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
process = cms.Process("TABLETEST") | ||
|
||
process.source = cms.Source("EmptySource") | ||
|
||
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(2)) | ||
|
||
anInts = [1,2,3] | ||
aFloats = [4.,5., 6.] | ||
aStrings =["einie", "meanie", "meinie"] | ||
|
||
process.tableTest = cms.EDProducer("edmtest::TableTestProducer", | ||
anInts = cms.vint32(*anInts), | ||
aFloats = cms.vdouble(*aFloats), | ||
aStrings = cms.vstring(*aStrings) ) | ||
|
||
process.checkTable = cms.EDAnalyzer("edmtest::TableTestAnalyzer", | ||
table = cms.untracked.InputTag("tableTest"), | ||
anInts = cms.untracked.vint32(*anInts), | ||
aFloats = cms.untracked.vdouble(*aFloats), | ||
aStrings = cms.untracked.vstring(*aStrings) ) | ||
|
||
process.eventContent = cms.EDAnalyzer("EventContentAnalyzer") | ||
|
||
process.p = cms.Path(process.checkTable, cms.Task(process.tableTest) ) | ||
#process.p = cms.Path(process.tableTest+process.eventContent+process.checkTable) | ||
|
||
#process.add_(cms.Service("Tracer", dumpPathsAndConsumes= cms.untracked.bool(True) ) ) | ||
|
||
#process.add_(cms.Service("InitRootHandlers", DebugLevel = cms.untracked.int32(10))) |
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,5 @@ | ||
#!/bin/sh | ||
|
||
function die { echo $1: status $2 ; exit $2; } | ||
|
||
cmsRun ${LOCAL_TEST_DIR}/testTableTest_cfg.py || die 'Failed in testTableTest_cfg.py' $? |
c972def
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there, after this PR there are new warnings in the IBs listed here https://cmssdt.cern.ch/SDT/cgi-bin/showBuildLogs.py/slc6_amd64_gcc700/www/tue/9.4-tue-11/CMSSW_9_4_X_2017-09-12-1100, could you provide a fix or suggestion how to deal with them ?
Thanks
c972def
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid the problem is with ROOT. The ROOT team is working on a fix but there is no telling how long it will take.