ATLAS Offline Software
Loading...
Searching...
No Matches
Sample.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef SAMPLE_HANDLER_SAMPLE_HH
6#define SAMPLE_HANDLER_SAMPLE_HH
7
8//
9// Distributed under the Boost Software License, Version 1.0.
10// (See accompanying file LICENSE_1_0.txt or copy at
11// http://www.boost.org/LICENSE_1_0.txt)
12
13// Please feel free to contact me (krumnack@iastate.edu) for bug
14// reports, feature suggestions, praise and complaints.
15
16
17
19
20#include <string>
21#include <vector>
22#include <atomic>
23#include <TObject.h>
25
26class TChain;
27class TCollection;
28
29namespace SH
30{
42 std::string dbg (const Sample& obj, unsigned verbosity = 0);
43
44
45
53 class Sample : public TObject
54 {
55 //
56 // public interface
57 //
58
63 public:
64 void testInvariant () const;
65
66
71 public:
72 virtual ~Sample ();
73
74
79 const std::string& name () const;
80
96 public:
97 void name (std::string val_name);
98
99
104 public:
105 std::size_t numFiles () const;
106
107
118 public:
119 std::string fileName (std::size_t index) const;
120
121
133 public:
135
136
141 public:
142 const TagList& tags () const;
143
144
151 public:
152 void tags (const TagList& tags);
153
154
161 public:
162 void addTag (const std::string& tag);
163
164
178 public:
179 void updateLocation (const std::string& from, const std::string& to);
180
181
187 public:
189
190
192 public:
193 const MetaObject *meta () const;
194
195
203 public:
204 std::vector<std::string> makeFileList () const;
205
206
215 public:
216 TChain *makeTChain () const;
217
218
228 public:
229 TObject *readHist (const std::string& name) const;
230
231
244 public:
245 bool contains (const std::string& name) const;
246
247
257 public:
259
260
269 public:
270 void print () const;
271
272
276 public:
277 void printContent () const;
278
279
285 public:
286 Long64_t getNumEntries () const;
287
288
289
290 //
291 // legacy interface
292 //
293
301 public:
302 [[deprecated("use meta() instead, or (preferably) access of meta-data by name")]]
303 TCollection *metaDataList ();
304
305
307 public:
308 [[deprecated("use meta() instead, or (preferably) access of meta-data by name")]]
309 const TCollection *metaDataList () const;
310
311
313 public:
314 [[deprecated("use meta() instead")]]
315 void removeMeta (const std::string& name);
316
317
319 public:
320 [[deprecated("use meta() instead")]]
321 void addReplaceMeta (TNamed *meta_swallow);
322
323
325 public:
326 [[deprecated("use meta() instead")]]
327 TObject *getMeta (const std::string& name);
328
329
331 public:
332 [[deprecated("use meta() instead")]]
333 const TObject *getMeta (const std::string& name) const;
334
335
337 public:
338 [[deprecated("use meta() instead")]]
339 double getMetaDouble (const std::string& name, double def_val = 0) const;
340
341
343 public:
344 [[deprecated("use meta() instead")]]
345 std::string getMetaString (const std::string& name, const std::string& def_val = "") const;
346
347
349 public:
350 [[deprecated("use meta() instead")]]
351 void setMetaDouble (const std::string& name, double value);
352
353
355 public:
356 [[deprecated("use meta() instead")]]
357 void setMetaString (const std::string& name, const std::string& value);
358
359
361 public:
362 [[deprecated("use meta() instead")]]
363 void fetchMeta (const Sample& source);
364
365
366
367 //
368 // protected interface
369 //
370
377 protected:
378 Sample (const std::string& name);
379
380
381
382 //
383 // virtual interface
384 //
385
389 protected:
390 virtual std::size_t getNumFiles () const = 0;
391
392
396 protected:
397 virtual std::string getFileName (std::size_t index) const = 0;
398
399
403 protected:
404 virtual SamplePtr doMakeLocal () const = 0;
405
406
410 protected:
411 virtual std::vector<std::string> doMakeFileList () const = 0;
412
413
417 protected:
418 virtual void
419 doUpdateLocation (const std::string& from, const std::string& to);
420
421
425 protected:
426 virtual TObject *doReadHist (const std::string& name) const;
427
428
432 protected:
433 virtual bool getContains (const std::string& name) const;
434
435
439 protected:
441
442
443
444 //
445 // friend interface for SamplePtr
446 //
447
448 friend class SamplePtr;
449 private:
450
455 void alloc () const;
456
457
465 void release () const;
466
467
468
469 //
470 // private interface
471 //
472
474 private:
475 std::string m_name;
476
478 private:
480
482 private:
484
486 private:
487 mutable std::atomic<unsigned> m_references;
488
491 private:
492 Sample (const Sample& that);
493
496 private:
497 Sample& operator = (const Sample& that);
498
500 };
501}
502
503#endif
A class that manages meta-data to be associated with an object.
Definition MetaObject.h:56
A class that manages a list of Sample objects.
void name(std::string val_name)
set the value of name
const TCollection * metaDataList() const
get the meta-data list
void addReplaceMeta(TNamed *meta_swallow)
add a meta-data object and remove any existing meta-data with the same name
bool contains(const std::string &name) const
whether this sample contains a sample of the given name
virtual std::string getFileName(std::size_t index) const =0
the name of the file with the given index
void addTag(const std::string &tag)
add a tag to the content of tags()
virtual void doAddSamples(SampleHandler &result)
add all samples this sample corresponds to to the given sample handler
virtual bool getContains(const std::string &name) const
whether this sample contains a sample of the given name
const MetaObject * meta() const
the meta-information for this sample
void removeMeta(const std::string &name)
remove all meta-information with the given name
MetaObject * meta()
the meta-information for this sample
TCollection * metaDataList()
get the meta-data list
void fetchMeta(const Sample &source)
fetch the meta-data from the given sample.
const TObject * getMeta(const std::string &name) const
the meta-data object with the given name
void testInvariant() const
test the invariant of this object
TObject * readHist(const std::string &name) const
read an object from a histogram file
Long64_t getNumEntries() const
get the number of entries
MetaObject * m_meta
the meta-information for this sample
Definition Sample.h:483
TagList m_tags
the tag list we are using
Definition Sample.h:479
void print() const
print the debugging output to the screen
virtual void doUpdateLocation(const std::string &from, const std::string &to)
update all file references starting with from to to
virtual std::size_t getNumFiles() const =0
the number of files in the sample
friend class SamplePtr
Definition Sample.h:448
ClassDef(Sample, 2)
TObject * getMeta(const std::string &name)
the meta-data object with the given name
std::string getMetaString(const std::string &name, const std::string &def_val="") const
the meta-data string with the given name
double getMetaDouble(const std::string &name, double def_val=0) const
the meta-data double with the given name
Sample & operator=(const Sample &that)
void setMetaString(const std::string &name, const std::string &value)
set the meta-data string with the given name
TChain * makeTChain() const
create a TChain object, containing all these files
Sample(const Sample &that)
std::size_t numFiles() const
the number of files in the sample
virtual std::vector< std::string > doMakeFileList() const =0
make a list of all files, prestaging them if necessary
std::atomic< unsigned > m_references
the reference count
Definition Sample.h:487
Sample(const std::string &name)
standard constructor
SamplePtr makeLocal() const
Make this a local sample, i.e.
void setMetaDouble(const std::string &name, double value)
set the meta-data double with the given name
std::string dbg(const Sample &obj, unsigned verbosity=0)
the debugging info of this object
std::vector< std::string > makeFileList() const
make a list of all files, prestaging them if necessary
virtual ~Sample()
standard destructor
void addSamples(SampleHandler &result)
add all samples this sample corresponds to to the given sample handler
void release() const
decrease the reference count by one
std::string m_name
the name of the sample we are using
Definition Sample.h:475
const TagList & tags() const
the tag list we are using
std::string fileName(std::size_t index) const
the name of the file with the given index
void tags(const TagList &tags)
set the content of tags()
void alloc() const
increase the reference count by one
virtual TObject * doReadHist(const std::string &name) const
read an object from a histogram file
virtual SamplePtr doMakeLocal() const =0
Make this a local sample, i.e.
void printContent() const
print the debugging output to the screen
const std::string & name() const
the name of the sample we are using
void updateLocation(const std::string &from, const std::string &to)
update all file references starting with from to to
A class that manages a list of tags for identifying samples.
Definition TagList.h:48
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15
Definition index.py:1