42 std::string
dbg (
const Sample& obj,
unsigned verbosity)
45 result +=
"Sample:name=" + obj.name();
46 if (
dynamic_cast<const SampleGrid*
>(&obj))
48 if (verbosity % 10 > 0)
55 if (verbosity % 10 > 0)
56 result +=
",tags=" +
dbg (obj.tags(), verbosity / 10);
57 if (verbosity % 10 > 1)
60 for (std::size_t iter = 0, end = obj.numFiles();
62 result += obj.fileName (iter) +
"\n";
71 testInvariant ()
const
88 const std::string& Sample ::
98 name (std::string val_name)
101 if (m_references > 0)
104 m_name = std::move (val_name);
110 std::size_t Sample ::
114 return getNumFiles();
119 std::string Sample ::
120 fileName (
const std::size_t
index)
const
137 return doMakeLocal ();
142 const TagList& Sample ::
152 tags (
const TagList&
tags)
161 addTag (
const std::string& tag)
170 updateLocation (
const std::string& from,
const std::string& to)
173 doUpdateLocation (from, to);
178 MetaObject *Sample ::
187 const MetaObject *Sample ::
196 std::vector<std::string> Sample ::
197 makeFileList ()
const
200 return doMakeFileList ();
210 std::vector<std::string>
files = makeFileList ();
213 if (treeName.empty())
214 RCU_THROW_MSG (
"sample " + name() +
" does not have a tree name associated");
215 std::unique_ptr<TChain>
result (
new TChain (treeName.c_str()));
216 for (std::vector<std::string>::const_iterator
file =
files.begin(),
225 doUpdateLocation (
const std::string& ,
const std::string& )
233 readHist (
const std::string& name)
const
236 return doReadHist (name);
242 contains (
const std::string& name)
const
253 addSamples (SampleHandler&
result)
265 std::cout <<
dbg (*
this, 9999) << std::endl;
271 printContent ()
const
280 getNumEntries ()
const
287 std::vector<std::string> fileList = makeFileList();
288 for (std::vector<std::string>::const_iterator fileName = fileList.begin(),
289 end = fileList.end(); fileName != end; ++ fileName)
291 std::unique_ptr<TFile>
file (TFile::Open (fileName->c_str(),
"READ"));
294 TTree *
tree =
dynamic_cast<TTree*
>(
file->Get (treeName.c_str()));
303 TCollection *Sample ::
312 const TCollection *Sample ::
313 metaDataList ()
const
322 removeMeta (
const std::string& name)
325 meta()->remove (name);
331 addReplaceMeta (TNamed *meta_swallow)
333 std::unique_ptr<TNamed> mymeta (meta_swallow);
338 meta()->addReplace (mymeta.release());
344 getMeta (
const std::string& name)
347 return meta()->get (name);
352 const TObject *Sample ::
353 getMeta (
const std::string& name)
const
356 return meta()->get (name);
362 getMetaDouble (
const std::string& name,
double def_val)
const
370 std::string Sample ::
371 getMetaString (
const std::string& name,
const std::string& def_val)
const
380 setMetaDouble (
const std::string& name,
double value)
383 meta()->setDouble (name, value);
389 setMetaString (
const std::string& name,
const std::string& value)
392 meta()->setString (name, value);
398 fetchMeta (
const Sample& source)
401 meta()->fetch (*source.meta());
407 Sample (
const std::string& name)
408 : m_name (name), m_meta (
new MetaObject),
419 doReadHist (
const std::string& name)
const
422 std::vector<std::string> fileList (makeFileList());
423 if (fileList.size() > 1)
424 RCU_THROW_MSG (
"reading histgrams from samples with multiple files is not (yet) implemented");
425 if (fileList.size() == 0)
427 std::unique_ptr<TFile>
file (TFile::Open (fileList[0].c_str(),
"READ"));
431 TObject *
object =
file->Get (name.c_str());
432 if (
object !=
nullptr)
440 getContains (
const std::string& )
const
449 doAddSamples (SampleHandler&
result)
472 unsigned refs = -- m_references;