ATLAS Offline Software
Loading...
Searching...
No Matches
SampleHandler.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#ifndef SAMPLE_HANDLER_SAMPLE_HANDLER_HH
8#define SAMPLE_HANDLER_SAMPLE_HANDLER_HH
9
11
12#include <boost/iterator/transform_iterator.hpp>
13#include <memory>
14#include <iosfwd>
15#include <map>
16#include <span>
17#include <vector>
18#include <TObject.h>
19
20namespace SH
21{
33 std::string dbg (const SampleHandler& obj, unsigned verbosity = 0);
34
35
42
43
44
52 class SampleHandler : public TObject
53 {
54 //
55 // public interface
56 //
57
62 public:
63 void testInvariant () const;
64
65
72 public:
74
75
82 public:
84
85
90 public:
92
93
100 public:
102
103
112 public:
113 void add (const Sample& sample);
114
115
125 public:
126 void add (std::shared_ptr<Sample> sample);
127
128
137 public:
138 void add (const SampleHandler& sh);
139
140
149 public:
150 void addWithPrefix (const SampleHandler& sh, const std::string& prefix);
151
152
160 public:
161 void remove (const std::string& name);
162
163
172 public:
173 void remove (const Sample *sample);
174
175
184 public:
185 Sample *get (const std::string& name);
186
187
196 public:
197 const Sample *get (const std::string& name) const;
198
199
208 public:
210
211
222 public:
223 SampleHandler find (const std::string& tags) const;
224
225
237 public:
238 Sample *findBySource (const std::string& name) const;
239
240
250 public:
251 SampleHandler findByName (const std::string& pattern) const;
252
253
261 public:
262 void print () const;
263
264
274 public:
275 void printContent () const;
276
277
289 public:
290 void save (const std::string& directory) const;
291
292
304 public:
305 void load (const std::string& directory);
306
307
321 public:
322 void updateLocation (const std::string& from, const std::string& to);
323
324
336 public:
337 void fetch (const SampleHandler& source);
338
339
349 public:
350 void fetchDefaults (const SampleHandler& source);
351
352
366 public:
367 bool check_complete (const SampleHandler& source) const;
368
369
382 public:
383 void setMetaDouble (const std::string& name, double value);
384
385
398 public:
399 void setMetaString (const std::string& name, const std::string& value);
400
401
416 public:
417 void setMetaDouble (const std::string& pattern, const std::string& name,
418 double value);
419
420
435 public:
436 void setMetaString (const std::string& pattern, const std::string& name,
437 const std::string& value);
438
439
446 private:
448 {
449 Sample *operator () (const std::shared_ptr<Sample>& p) const;
450 };
451
452
454 public:
455 typedef boost::transform_iterator<
457 std::vector<std::shared_ptr<Sample>>::const_iterator> iterator;
458
459
464 public:
465 iterator begin () const;
466
467
472 public:
473 iterator end () const;
474
475
480 public:
481 std::size_t size () const;
482
483
489 public:
490 Sample *operator [] (std::size_t index) const;
491
492
498 public:
499 Sample *at (std::size_t index) const;
500
501
503 public:
504 std::span<std::shared_ptr<Sample>> samples ();
505
506
507
508 //
509 // private interface
510 //
511
512 friend void swap (SampleHandler& a, SampleHandler& b);
513
515 private:
516 std::vector<std::shared_ptr<Sample>> m_samples;
517
519 private:
520 std::map<std::string,std::shared_ptr<Sample>> m_named;
521
522 ClassDef (SampleHandler, 1)
523 };
524}
525
526#endif
static Double_t a
void save(const std::string &directory) const
save the list of samples to the given directory
void swap(SampleHandler &a, SampleHandler &b)
standard swap
void add(const Sample &sample)
add a copy of the sample to the handler
void remove(const Sample *sample)
remove the given sample
void setMetaString(const std::string &name, const std::string &value)
set the meta-data string with the given name for all samples.
void printContent() const
print the debugging output to the screen
iterator begin() const
the begin iterator to use
void testInvariant() const
test the invariant of this object
std::size_t size() const
the number of samples contained
Sample * get(const std::string &name)
get the sample with the given name
Sample * at(std::size_t index) const
the sample with the given index
boost::transform_iterator< SamplePtrToRawSample, std::vector< std::shared_ptr< Sample > >::const_iterator > iterator
the iterator to use
SampleHandler find(const std::string &tags) const
find all samples which have at least one of the given tags.
SampleHandler()
standard constructor
bool check_complete(const SampleHandler &source) const
whether we have all samples from the source SampleHandler.
~SampleHandler()
standard destructor
SampleHandler findByName(const std::string &pattern) const
find samples by pattern on the name
Sample * findBySource(const std::string &name) const
find a sample by the name in the source sample handler
Sample * operator[](std::size_t index) const
the sample with the given index
void print() const
print the debugging output to the screen
void setMetaString(const std::string &pattern, const std::string &name, const std::string &value)
set the meta-data double with the given name for samples matching a pattern.
std::span< std::shared_ptr< Sample > > samples()
the samples accessed via smart pointer
SampleHandler & operator=(const SampleHandler &that)
standard assignment operator
void addWithPrefix(const SampleHandler &sh, const std::string &prefix)
add all samples from the given SampleHandler to this one, with prefix prepended to their name
void remove(const std::string &name)
remove the given sample
void setMetaDouble(const std::string &name, double value)
set the meta-data double with the given name for all samples.
std::vector< std::shared_ptr< Sample > > m_samples
the list of samples managed
void updateLocation(const std::string &from, const std::string &to)
update all file references starting with from to to
void setMetaDouble(const std::string &pattern, const std::string &name, double value)
set the meta-data double with the given name for samples matching a pattern.
const Sample * get(const std::string &name) const
get the sample with the given name
iterator end() const
the end iterator to use
void load(const std::string &directory)
load all the samples from the given directory
SampleHandler find(const TagList &tags) const
find all samples which have at least one of the given tags.
void add(std::shared_ptr< Sample > sample)
add a sample to the handler
std::string dbg(const SampleHandler &obj, unsigned verbosity=0)
the debugging info of this object
void fetchDefaults(const SampleHandler &source)
fetch the meta-data for all that samples that don't have it in this sample.
SampleHandler(const SampleHandler &that)
standard copy constructor
void fetch(const SampleHandler &source)
fetch the meta-data for all samples that are also in the source sample handler.
void add(const SampleHandler &sh)
add all samples from the given SampleHandler to this one
std::map< std::string, std::shared_ptr< Sample > > m_named
the list of samples by name
a base class that manages a set of files belonging to a particular data set and the associated meta-d...
Definition Sample.h:49
A class that manages a list of tags for identifying samples.
Definition TagList.h:39
std::vector< std::string > tags
Definition hcg.cxx:107
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15
Definition index.py:1
functor mapping a shared_ptr<Sample> to the raw Sample* it points to.
Sample * operator()(const std::shared_ptr< Sample > &p) const