36 std::string
dbg (
const Sample& obj,
unsigned verbosity)
39 result +=
"Sample:name=" + obj.name();
40 if (
dynamic_cast<const SampleGrid*
>(&obj))
42 if (verbosity % 10 > 0)
49 if (verbosity % 10 > 0)
50 result +=
",tags=" +
dbg (obj.tags(), verbosity / 10);
51 if (verbosity % 10 > 1)
54 for (std::size_t iter = 0, end = obj.numFiles();
56 result += obj.fileName (iter) +
"\n";
65 testInvariant ()
const
82 const std::string& Sample ::
92 name (std::string val_name)
96 throw std::logic_error
97 (
"SH::Sample::name: cannot change name of sample \""
98 + m_name +
"\" after it has been registered in a SampleHandler"
99 " (or otherwise locked via lockName)");
101 m_name = std::move (val_name);
116 std::size_t Sample ::
120 return getNumFiles();
125 std::string Sample ::
126 fileName (
const std::size_t
index)
const
131 std::string result = getFileName (
index);
139 std::unique_ptr<SampleLocal> Sample ::
143 return doMakeLocal ();
148 const TagList& Sample ::
158 tags (
const TagList&
tags)
167 addTag (
const std::string& tag)
176 updateLocation (
const std::string& from,
const std::string& to)
179 doUpdateLocation (from, to);
184 MetaObject *Sample ::
193 const MetaObject *Sample ::
202 std::vector<std::string> Sample ::
203 makeFileList ()
const
206 return doMakeFileList ();
216 std::vector<std::string>
files = makeFileList ();
219 if (treeName.empty())
220 RCU_THROW_MSG (
"sample " + name() +
" does not have a tree name associated");
221 std::unique_ptr<TChain> result (
new TChain (treeName.c_str()));
222 for (std::vector<std::string>::const_iterator
file =
files.begin(),
224 result->AddFile (
file->c_str());
225 return result.release();
231 doUpdateLocation (
const std::string& ,
const std::string& )
239 readHist (
const std::string& name)
const
242 return doReadHist (name);
248 contains (
const std::string& name)
const
259 addSamples (SampleHandler& result,
const std::shared_ptr<Sample>& self)
263 doAddSamples (result, self);
272 std::cout <<
dbg (*
this, 9999) << std::endl;
278 printContent ()
const
287 getNumEntries ()
const
294 std::vector<std::string> fileList = makeFileList();
295 for (std::vector<std::string>::const_iterator fileName = fileList.begin(),
296 end = fileList.end(); fileName != end; ++ fileName)
298 std::unique_ptr<TFile>
file (TFile::Open (fileName->c_str(),
"READ"));
301 TTree *
tree =
dynamic_cast<TTree*
>(
file->Get (treeName.c_str()));
303 result +=
tree->GetEntries();
310 TCollection *Sample ::
319 const TCollection *Sample ::
320 metaDataList ()
const
329 removeMeta (
const std::string& name)
332 meta()->remove (name);
338 addReplaceMeta (TNamed *meta_swallow)
340 std::unique_ptr<TNamed> mymeta (meta_swallow);
345 meta()->addReplace (mymeta.release());
351 getMeta (
const std::string& name)
354 return meta()->get (name);
359 const TObject *Sample ::
360 getMeta (
const std::string& name)
const
363 return meta()->get (name);
369 getMetaDouble (
const std::string& name,
double def_val)
const
377 std::string Sample ::
378 getMetaString (
const std::string& name,
const std::string& def_val)
const
387 setMetaDouble (
const std::string& name,
double value)
390 meta()->setDouble (name, value);
396 setMetaString (
const std::string& name,
const std::string& value)
399 meta()->setString (name, value);
405 fetchMeta (
const Sample& source)
408 meta()->fetch (*source.meta());
414 Sample (
const std::string& name)
415 : m_name (name), m_meta (
new MetaObject)
425 Sample (
const Sample& that)
426 : TObject (that), m_name (that.m_name),
427 m_tags (that.m_tags), m_meta (
new MetaObject (*that.m_meta))
435 doReadHist (
const std::string& name)
const
438 std::vector<std::string> fileList (makeFileList());
439 if (fileList.size() > 1)
440 RCU_THROW_MSG (
"reading histgrams from samples with multiple files is not (yet) implemented");
441 if (fileList.size() == 0)
443 std::unique_ptr<TFile>
file (TFile::Open (fileList[0].c_str(),
"READ"));
447 TObject *
object =
file->Get (name.c_str());
448 if (
object !=
nullptr)
456 getContains (
const std::string& )
const
465 doAddSamples (SampleHandler& result,
const std::shared_ptr<Sample>& self)