41{
42 std::string
dbg (
const Sample& obj,
unsigned verbosity)
43 {
46 if (dynamic_cast<const SampleGrid*>(&obj))
47 {
48 if (verbosity % 10 > 0)
49 {
50 result +=
"\n " + MetaFields::gridName +
"="+
obj.meta()->castString(MetaFields::gridName);
51 result +=
"\n " + MetaFields::gridFilter +
"="+
obj.meta()->castString(MetaFields::gridFilter);
52 };
53 } else
54 {
55 if (verbosity % 10 > 0)
57 if (verbosity % 10 > 1)
58 {
60 for (std::size_t iter = 0, end =
obj.numFiles();
61 iter != end; ++ iter)
63 };
64 };
66 }
67
68
69
70 void Sample ::
71 testInvariant () const
72 {
74 }
75
76
77
78 Sample ::
79 ~Sample ()
80 {
82
83 delete m_meta;
84 }
85
86
87
88 const std::string& Sample ::
89 name () const
90 {
92 return m_name;
93 }
94
95
96
97 void Sample ::
98 name (std::string val_name)
99 {
101 if (m_references > 0)
103 m_meta->setString (MetaNames::sampleName(), val_name);
104 m_name = std::move (val_name);
105
106 }
107
108
109
110 std::size_t Sample ::
111 numFiles () const
112 {
114 return getNumFiles();
115 }
116
117
118
119 std::string Sample ::
120 fileName (
const std::size_t
index)
const
121 {
124
126
129 }
130
131
132
133 SamplePtr Sample ::
134 makeLocal () const
135 {
137 return doMakeLocal ();
138 }
139
140
141
142 const TagList& Sample ::
143 tags () const
144 {
146 return m_tags;
147 }
148
149
150
151 void Sample ::
152 tags (
const TagList&
tags)
153 {
156 }
157
158
159
160 void Sample ::
161 addTag (const std::string& tag)
162 {
164 m_tags.add (tag);
165 }
166
167
168
169 void Sample ::
170 updateLocation (const std::string& from, const std::string& to)
171 {
173 doUpdateLocation (from, to);
174 }
175
176
177
178 MetaObject *Sample ::
179 meta ()
180 {
182 return m_meta;
183 }
184
185
186
187 const MetaObject *Sample ::
188 meta () const
189 {
191 return m_meta;
192 }
193
194
195
196 std::vector<std::string> Sample ::
197 makeFileList () const
198 {
200 return doMakeFileList ();
201 }
202
203
204
205 TChain *Sample ::
206 makeTChain () const
207 {
208
209
210 std::vector<std::string>
files = makeFileList ();
211
212 const std::string
treeName (
meta()->castString (MetaFields::treeName, MetaFields::treeName_default));
216 for (std::vector<std::string>::const_iterator
file =
files.begin(),
220 }
221
222
223
224 void Sample ::
225 doUpdateLocation (const std::string& , const std::string& )
226 {
228 }
229
230
231
232 TObject *Sample ::
233 readHist (const std::string& name) const
234 {
236 return doReadHist (name);
237 }
238
239
240
241 bool Sample ::
242 contains (const std::string& name) const
243 {
245 if (m_name == name)
246 return true;
247 return false;
248 }
249
250
251
252 void Sample ::
253 addSamples (SampleHandler&
result)
254 {
257 }
258
259
260
261 void Sample ::
262 print () const
263 {
265 std::cout <<
dbg (*
this, 9999) << std::endl;
266 }
267
268
269
270 void Sample ::
271 printContent () const
272 {
273
275 }
276
277
278
279 Long64_t Sample ::
280 getNumEntries () const
281 {
283
285 =
meta()->castString (MetaFields::treeName, MetaFields::treeName_default);
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)
290 {
291 std::unique_ptr<TFile>
file (TFile::Open (
fileName->c_str(),
"READ"));
297 }
299 }
300
301
302
303 TCollection *Sample ::
304 metaDataList ()
305 {
306
308 }
309
310
311
312 const TCollection *Sample ::
313 metaDataList () const
314 {
315
317 }
318
319
320
321 void Sample ::
322 removeMeta (const std::string& name)
323 {
324
325 meta()->remove (name);
326 }
327
328
329
330 void Sample ::
331 addReplaceMeta (TNamed *meta_swallow)
332 {
333 std::unique_ptr<TNamed> mymeta (meta_swallow);
334
335
337
338 meta()->addReplace (mymeta.release());
339 }
340
341
342
343 TObject *Sample ::
344 getMeta (const std::string& name)
345 {
346
347 return meta()->get (name);
348 }
349
350
351
352 const TObject *Sample ::
353 getMeta (const std::string& name) const
354 {
355
356 return meta()->get (name);
357 }
358
359
360
361 double Sample ::
362 getMetaDouble (const std::string& name, double def_val) const
363 {
364
365 return meta()->castDouble (name, def_val, MetaObject::CAST_NOCAST_DEFAULT);
366 }
367
368
369
370 std::string Sample ::
371 getMetaString (const std::string& name, const std::string& def_val) const
372 {
373
374 return meta()->castString (name, def_val, MetaObject::CAST_NOCAST_DEFAULT);
375 }
376
377
378
379 void Sample ::
380 setMetaDouble (const std::string& name, double value)
381 {
382
383 meta()->setDouble (name, value);
384 }
385
386
387
388 void Sample ::
389 setMetaString (const std::string& name, const std::string& value)
390 {
391
392 meta()->setString (name, value);
393 }
394
395
396
397 void Sample ::
398 fetchMeta (const Sample& source)
399 {
400
402 }
403
404
405
406 Sample ::
407 Sample (const std::string& name)
408 : m_name (
name), m_meta (
new MetaObject),
409 m_references (0)
410 {
411 m_meta->setString (MetaNames::sampleName(), name);
412
414 }
415
416
417
418 TObject *Sample ::
419 doReadHist (const std::string& name) const
420 {
422 std::vector<std::string>
fileList (makeFileList());
424 RCU_THROW_MSG (
"reading histgrams from samples with multiple files is not (yet) implemented");
426 return nullptr;
427 std::unique_ptr<TFile>
file (TFile::Open (fileList[0].c_str(),
"READ"));
430
431 TObject *
object =
file->Get (
name.c_str());
432 if (object != nullptr)
435 }
436
437
438
439 bool Sample ::
440 getContains (const std::string& ) const
441 {
443 return false;
444 }
445
446
447
448 void Sample ::
449 doAddSamples (SampleHandler&
result)
450 {
453 }
454
455
456
457 void Sample ::
458 alloc () const
459 {
461 ++ m_references;
462 }
463
464
465
466 void Sample ::
467 release () const
468 {
471
472 unsigned refs = -- m_references;
473 if (refs == 0)
474 delete this;
475 }
476}
#define RCU_REQUIRE2(x, y)
#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
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='#')