|
ATLAS Offline Software
|
Go to the documentation of this file.
35 using namespace EL::msgEventLoop;
44 UnitTest (
const std::string& val_name, std::string val_base_path)
45 :
name (val_name), base_path (val_base_path), cleanup (true), testOutput (true), outputDisk (0),
46 testFileExecute (true)
49 base_path =
"$ROOTCOREBIN/data/EventLoop/";
57 std::vector<std::string>
files;
60 for (
unsigned iter = 0,
end = 3; iter !=
end; ++ iter)
62 std::ostringstream
path;
65 gSystem->ExpandPathName (
input);
67 std::unique_ptr<TFile>
file (TFile::Open (
input.Data(),
"READ"));
69 TH1 *
hist =
dynamic_cast<TH1*
>(
file->Get (
"hist_n"));
72 hist->SetDirectory (0);
74 std::string
tree (
"physics");
79 std::vector<std::unique_ptr<SH::Sample> > mysamples;
82 std::unique_ptr<SH::SampleGrid> mysample;
83 mysample.reset (
new SH::SampleGrid (
"user.krumnack:user.krumnack.EventLoopTest.2019-03-25.dataset0"));
86 mysamples.push_back (std::move (mysample));
87 mysample.reset (
new SH::SampleGrid (
"user.krumnack:user.krumnack.EventLoopTest.2019-03-25.dataset1"));
90 mysamples.push_back (std::move (mysample));
93 std::unique_ptr<SH::SampleLocal> mysample;
96 mysamples.push_back (std::move (mysample));
100 mysamples.push_back (std::move (mysample));
104 hist =
dynamic_cast<TH1*
>(
histos[0]->Clone (
"hist"));
105 mysamples[0]->meta()->addReplace (
hist);
107 hist =
dynamic_cast<TH1*
>(
histos[1]->Clone (
"hist"));
109 mysamples[1]->meta()->addReplace (
hist);
111 for (
auto& mysample : mysamples)
112 samples.
add (mysample.release());
118 for (
unsigned iter = 0,
end =
histos.size(); iter !=
end; ++ iter)
140 job.options()->setDouble (
"jobOpt", 42);
146 sh.setMetaString (
"mymeta",
"test");
147 job.sampleHandler (
sh);
166 for (std::size_t iter = 0,
end = samples.
size(); iter !=
end; ++ iter)
169 TH1 *ref_hist =
dynamic_cast<TH1*
>(samples[iter]->meta()->
get (
"hist"));
173 sh.load ((
output +
"/hist").c_str());
180 TH1 *file_executes =
dynamic_cast<TH1*
>(
sample->readHist (
"file_executes"));
182 ANA_MSG_INFO (
"file executes: " << file_executes->GetEntries() <<
" " << samples[iter]->makeFileList().
size());
186 TH1 *
hist =
dynamic_cast<TH1*
>(
sample->readHist (
"el_n"));
187 if (samples[iter]->getNumEntries() == 0)
197 if (
hist->GetNbinsX() != ref_hist->GetNbinsX())
201 if (
hist->GetBinContent (
bin) != ref_hist->GetBinContent (
bin))
203 std::ostringstream
str;
204 str <<
"bin content missmatch in bin " <<
bin
205 <<
" found " <<
hist->GetBinContent (
bin)
206 <<
" expected " << ref_hist->GetBinContent (
bin);
211 TH1 *
count =
dynamic_cast<TH1*
>(
sample->readHist (
"EventLoop_EventCount"));
212 if (samples[iter]->getNumEntries() > 0 &&
count == 0)
213 RCU_THROW_MSG (
"didn't find histogram EventLoop_EventCount");
215 if (
testOutput && samples[iter]->getNumEntries() > 0)
218 sh.load ((
output +
"/output-out").c_str());
223 if (ref_hist && samples[iter]->getNumEntries() != ref_hist->GetEntries())
225 std::ostringstream
str;
226 str <<
"tree entries missmatch found " << samples[iter]->getNumEntries()
227 <<
" expected " << ref_hist->GetEntries();
233 gSystem->Exec ((
"rm -rf " +
output).c_str());
237 std::cout <<
"exception caught in unit test: " <<
e.what() << std::endl;
239 }
catch (std::string&
e)
241 std::cout <<
"exception caught in unit test: " <<
e << std::endl;
245 std::cout <<
"unknown exception caught in unit test" << std::endl;
path
python interpreter configuration --------------------------------------—
void add(Sample *sample)
add a sample to the handler
bool testFileExecute
whether to test the fileExecute method
std::string name
description: the name of the unit test
the base class for the various EventLoop drivers that allow to run jobs on different backends
std::size_t size() const
the number of samples contained
std::string base_path
description: the base path for the data files
bool gridInput
whether to use the inputs from the grid dataset
void print() const
print the debugging output to the screen
std::string location
description: the location for the unit test
UnitTest(const std::string &val_name, std::string base_path="")
effects: standard constructor guarantee: storng failures: out of memory II
#define RCU_ASSERT_SOFT(x)
void scanNEvents(SampleHandler &sh)
effects: scan each sample in the sample handler and store the number of entries per file in the meta-...
This class implements a Sample located on the grid.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
MetaObject * meta()
the meta-information for this sample
SH::DiskOutput * outputDisk
description: the output disk
a base class that manages a set of files belonging to a particular data set and the associated meta-d...
A smart pointer class that holds a single Sample object.
void setMetaString(const std::string &name, const std::string &value)
set the meta-data string with the given name for all samples.
bool cleanup
description: whether we clean up the submit directory afterwards
int run(const Driver &driver) const
effects: perform a unit test with the given driver returns: EXIT_SUCCESS on success,...
A Sample based on a simple file list.
A class that manages a list of Sample objects.
bool scanNEvents
whether to scan for number of events
static const std::string optSubmitDirMode
the submit-dir mode (allowed values: "no-clobber", "overwrite", "unique", "unique-link")
#define RCU_THROW_MSG(message)
Sample * get(const std::string &name)
get the sample with the given name
bool testOutput
description: whether to test creating output n-tuples
void add(const std::string &file)
add a file to the list