35{
36 std::string
dbg (
const Sample& obj,
unsigned verbosity)
37 {
40 if (dynamic_cast<const SampleGrid*>(&obj))
41 {
42 if (verbosity % 10 > 0)
43 {
44 result +=
"\n " + MetaFields::gridName +
"="+
obj.meta()->castString(MetaFields::gridName);
45 result +=
"\n " + MetaFields::gridFilter +
"="+
obj.meta()->castString(MetaFields::gridFilter);
46 };
47 } else
48 {
49 if (verbosity % 10 > 0)
51 if (verbosity % 10 > 1)
52 {
54 for (std::size_t iter = 0, end =
obj.numFiles();
55 iter != end; ++ iter)
57 };
58 };
60 }
61
62
63
64 void Sample ::
65 testInvariant () const
66 {
68 }
69
70
71
72 Sample ::
73 ~Sample ()
74 {
76
77 delete m_meta;
78 }
79
80
81
82 const std::string& Sample ::
83 name () const
84 {
87 }
88
89
90
91 void Sample ::
92 name (std::string val_name)
93 {
95 if (m_lockedName)
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)");
100 m_meta->setString (MetaNames::sampleName(), val_name);
101 m_name = std::move (val_name);
102
103 }
104
105
106
107 void Sample ::
108 lockName ()
109 {
111 m_lockedName = true;
112 }
113
114
115
116 std::size_t Sample ::
117 numFiles () const
118 {
120 return getNumFiles();
121 }
122
123
124
125 std::string Sample ::
126 fileName (
const std::size_t
index)
const
127 {
130
132
135 }
136
137
138
139 std::unique_ptr<SampleLocal> Sample ::
140 makeLocal () const
141 {
143 return doMakeLocal ();
144 }
145
146
147
148 const TagList& Sample ::
149 tags () const
150 {
152 return m_tags;
153 }
154
155
156
157 void Sample ::
158 tags (
const TagList&
tags)
159 {
162 }
163
164
165
166 void Sample ::
167 addTag (const std::string& tag)
168 {
170 m_tags.add (tag);
171 }
172
173
174
175 void Sample ::
176 updateLocation (const std::string& from, const std::string& to)
177 {
179 doUpdateLocation (from, to);
180 }
181
182
183
184 MetaObject *Sample ::
185 meta ()
186 {
188 return m_meta;
189 }
190
191
192
193 const MetaObject *Sample ::
194 meta () const
195 {
197 return m_meta;
198 }
199
200
201
202 std::vector<std::string> Sample ::
203 makeFileList () const
204 {
206 return doMakeFileList ();
207 }
208
209
210
211 TChain *Sample ::
212 makeTChain () const
213 {
214
215
216 std::vector<std::string>
files = makeFileList ();
217
218 const std::string
treeName (
meta()->castString (MetaFields::treeName, MetaFields::treeName_default));
222 for (std::vector<std::string>::const_iterator
file =
files.begin(),
226 }
227
228
229
230 void Sample ::
231 doUpdateLocation (const std::string& , const std::string& )
232 {
234 }
235
236
237
238 TObject *Sample ::
239 readHist (const std::string& name) const
240 {
242 return doReadHist (name);
243 }
244
245
246
247 bool Sample ::
248 contains (const std::string& name) const
249 {
251 if (m_name == name)
252 return true;
253 return false;
254 }
255
256
257
258 void Sample ::
259 addSamples (SampleHandler& result, const std::shared_ptr<Sample>& self)
260 {
263 doAddSamples (result, self);
264 }
265
266
267
268 void Sample ::
269 print () const
270 {
272 std::cout <<
dbg (*
this, 9999) << std::endl;
273 }
274
275
276
277 void Sample ::
278 printContent () const
279 {
280
282 }
283
284
285
286 Long64_t Sample ::
287 getNumEntries () const
288 {
290
292 =
meta()->castString (MetaFields::treeName, MetaFields::treeName_default);
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)
297 {
298 std::unique_ptr<TFile>
file (TFile::Open (
fileName->c_str(),
"READ"));
304 }
306 }
307
308
309
310 TCollection *Sample ::
311 metaDataList ()
312 {
313
315 }
316
317
318
319 const TCollection *Sample ::
320 metaDataList () const
321 {
322
324 }
325
326
327
328 void Sample ::
329 removeMeta (const std::string& name)
330 {
331
332 meta()->remove (name);
333 }
334
335
336
337 void Sample ::
338 addReplaceMeta (TNamed *meta_swallow)
339 {
340 std::unique_ptr<TNamed> mymeta (meta_swallow);
341
342
344
345 meta()->addReplace (mymeta.release());
346 }
347
348
349
350 TObject *Sample ::
351 getMeta (const std::string& name)
352 {
353
354 return meta()->get (name);
355 }
356
357
358
359 const TObject *Sample ::
360 getMeta (const std::string& name) const
361 {
362
363 return meta()->get (name);
364 }
365
366
367
368 double Sample ::
369 getMetaDouble (const std::string& name, double def_val) const
370 {
371
372 return meta()->castDouble (name, def_val, MetaObject::CAST_NOCAST_DEFAULT);
373 }
374
375
376
377 std::string Sample ::
378 getMetaString (const std::string& name, const std::string& def_val) const
379 {
380
381 return meta()->castString (name, def_val, MetaObject::CAST_NOCAST_DEFAULT);
382 }
383
384
385
386 void Sample ::
387 setMetaDouble (const std::string& name, double value)
388 {
389
390 meta()->setDouble (name, value);
391 }
392
393
394
395 void Sample ::
396 setMetaString (const std::string& name, const std::string& value)
397 {
398
399 meta()->setString (name, value);
400 }
401
402
403
404 void Sample ::
405 fetchMeta (const Sample& source)
406 {
407
409 }
410
411
412
413 Sample ::
414 Sample (const std::string& name)
416 {
417 m_meta->setString (MetaNames::sampleName(), name);
418
420 }
421
422
423
424 Sample ::
425 Sample (const Sample& that)
427 m_tags (that.m_tags), m_meta (
new MetaObject (*that.m_meta))
428 {
430 }
431
432
433
434 TObject *Sample ::
435 doReadHist (const std::string& name) const
436 {
438 std::vector<std::string>
fileList (makeFileList());
440 RCU_THROW_MSG (
"reading histgrams from samples with multiple files is not (yet) implemented");
442 return nullptr;
443 std::unique_ptr<TFile>
file (TFile::Open (fileList[0].c_str(),
"READ"));
446
447 TObject *
object =
file->Get (
name.c_str());
448 if (object != nullptr)
451 }
452
453
454
455 bool Sample ::
456 getContains (const std::string& ) const
457 {
459 return false;
460 }
461
462
463
464 void Sample ::
465 doAddSamples (SampleHandler& result, const std::shared_ptr<Sample>& self)
466 {
469 }
470}
#define RCU_DESTROY_INVARIANT(x)
#define RCU_CHANGE_INVARIANT(x)
#define RCU_NEW_INVARIANT(x)
#define RCU_REQUIRE_SOFT(x)
#define RCU_READ_INVARIANT(x)
#define RCU_THROW_MSG(message)
void print(char *figname, TCanvas *c1)
std::vector< std::string > files
file names and file pointers
std::vector< std::string > tags
std::string m_name
The primary name part of this expression.
bool SetDirectory(TObject *object, TDirectory *directory)
effects: set the directory this object is associated with returns: whether the object type actively k...
getFileName(name, sep='#')