|
ATLAS Offline Software
|
Go to the documentation of this file.
64 result <<
"SampleHandler with " <<
obj.size() <<
" files";
79 void swap (SampleHandler&
a, SampleHandler&
b)
81 swap (
a.m_samples,
b.m_samples);
82 swap (
a.m_named,
b.m_named);
105 : TObject (that), m_samples (that.m_samples), m_named (that.m_named)
134 SamplePtr mysample (
sample);
161 RCU_THROW_MSG (
"can't add sample of name " +
sample->name() +
"\na sample with that name already exists\nold sample:\n" +
dbg (*
m_named.find (
sample->name())->second, 9999) +
"\nnew sample:\n" +
dbg (*
sample, 9999));
166 if (!
sample->name().empty())
186 add (
const SampleHandler&
sh)
192 iter != end2; ++ iter)
207 iter != end2; ++ iter)
209 std::unique_ptr<Sample>
sample (
dynamic_cast<Sample*
>((*iter)->Clone ()));
239 if (nameIter->second.get() !=
sample)
243 iter != end2; ++ iter)
261 return iter->second.get();
267 get (
const std::string&
name)
const
273 return iter->second.get();
280 find (
const std::string&
tags)
const
300 end =
tags.end(); !use && iter !=
end; ++ iter)
301 use = (*sample)->tags().has (*iter);
315 std::vector<Sample*>
result;
325 message <<
"multiple samples have " <<
name <<
" as a source:";
326 for (std::vector<Sample*>::const_iterator
sample =
result.begin(),
328 message <<
" " << (*sample)->name();
358 std::cout <<
dbg (*
this, 9999) << std::endl;
379 gSystem->MakeDirectory (
directory.c_str());
383 TFile
file ((
directory +
"/" + (*iter)->name() +
".root").c_str(),
"RECREATE");
384 (*iter)->Write (
"sample");
398 const std::string
file =
mydir.fileName();
400 if (
file.size() > 5 &&
401 file.rfind (
".root") ==
file.size() - 5)
403 TFile myfile (
mydir.path().c_str(),
"READ");
404 Sample *
const sample =
dynamic_cast<Sample*
>(myfile.Get (
"sample"));
421 (*sample)->updateLocation (from,
to);
434 const std::string
name
436 const Sample *
const mysource =
source.get (
name);
438 (*sample)->meta()->fetch (*mysource->meta());
452 const std::string
name
454 const Sample *
const mysource =
source.get (
name);
456 (*sample)->meta()->fetchDefaults (*mysource->meta());
467 std::set<std::string>
names;
477 if (
names.find ((*sample)->name()) ==
names.end())
493 (*sample)->meta()->setDouble (
name,
value);
507 (*sample)->meta()->setString (
name,
value);
525 (*sample)->meta()->setDouble (
name,
value);
533 const std::string&
value)
543 (*sample)->meta()->setString (
name,
value);
595 void SampleHandler ::
596 Streamer (TBuffer&
b)
604 for (ULong_t iter = 0; iter !=
count; ++ iter)
void addWithPrefix(const SampleHandler &sh, const std::string &prefix)
add all samples from the given SampleHandler to this one, with prefix prepended to their name
Sample * findBySource(const std::string &name) const
find a sample by the name in the source sample handler
void fetchDefaults(const SampleHandler &source)
fetch the meta-data for all that samples that don't have it in this sample.
std::vector< Sample * >::const_iterator iterator
the iterator to use
ClassImp(SH::SampleHandler) namespace SH
std::map< std::string, SH::SamplePtr >::iterator NamedIter
the iterator for m_named
Sample * at(std::size_t index) const
the sample with the given index
void add(Sample *sample)
add a sample to the handler
std::vector< SH::Sample * >::iterator SamplesMIter
the mutable iterator for m_samples
~SampleHandler()
standard destructor
std::string dbg(const Meta &, unsigned)
void updateLocation(const std::string &from, const std::string &to)
update all file references starting with from to to
SampleHandler & operator=(const SampleHandler &that)
standard assignment operator
SampleHandler find(const TagList &tags) const
find all samples which have at least one of the given tags.
std::vector< SH::Sample * > m_samples
the list of samples managed
iterator end() const
the end iterator to use
void printContent() const
print the debugging output to the screen
std::size_t size() const
the number of samples contained
void print() const
print the debugging output to the screen
void save(const std::string &directory) const
save the list of samples to the given directory
void setMetaDouble(const std::string &name, double value)
set the meta-data double with the given name for all samples.
void testInvariant() const
test the invariant of this object
std::vector< std::string > tags
#define RCU_REQUIRE_SOFT(x)
bool match_expr(const boost::regex &expr, const std::string &str)
returns: whether we can match the entire string with the regular expression guarantee: strong failure...
std::string dbg(const SampleHandler &obj, unsigned verbosity=0)
the debugging info of this object
SampleHandler()
standard constructor
void load(const std::string &directory)
load all the samples from the given directory
bool check_complete(const SampleHandler &source) const
whether we have all samples from the source SampleHandler.
iterator begin() const
the begin iterator to use
std::set< std::string >::const_iterator iterator
the iterator to use
void setMetaString(const std::string &name, const std::string &value)
set the meta-data string with the given name for all samples.
std::map< std::string, SH::SamplePtr > m_named
the list of samples by name
SampleHandler findByName(const std::string &pattern) const
find samples by pattern on the name
void check_root_version()
effects: check whether we are using a consistent root version guarantee: strong failures: version mis...
#define RCU_DESTROY_INVARIANT(x)
Sample * operator[](std::size_t index) const
the sample with the given index
#define RCU_CHANGE_INVARIANT(x)
friend void swap(SampleHandler &a, SampleHandler &b)
std::map< std::string, SH::SamplePtr >::iterator NamedMIter
the mutable iterator for m_named
void remove(const std::string &name)
remove the given sample
A class that manages a list of Sample objects.
This module provides a lot of global definitions, forward declarations and includes that are used by ...
#define RCU_THROW_MSG(message)
void fetch(const SampleHandler &source)
fetch the meta-data for all samples that are also in the source sample handler.
Sample * get(const std::string &name)
get the sample with the given name
std::vector< SH::Sample * >::const_iterator SamplesIter
the iterator for m_samples
#define RCU_READ_INVARIANT(x)
#define RCU_NEW_INVARIANT(x)