ATLAS Offline Software
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 
5 #ifndef SAMPLE_HANDLER_SAMPLE_HANDLER_HH
6 #define SAMPLE_HANDLER_SAMPLE_HANDLER_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 
18 #include <SampleHandler/Global.h>
20 
21 #include <memory>
22 #include <iosfwd>
23 #include <map>
24 #include <vector>
25 #include <TObject.h>
26 
27 namespace SH
28 {
40  std::string dbg (const SampleHandler& obj, unsigned verbosity = 0);
41 
42 
49 
50 
51 
59  class SampleHandler : public TObject
60  {
61  //
62  // public interface
63  //
64 
69  public:
70  void testInvariant () const;
71 
72 
79  public:
81 
82 
89  public:
91 
92 
97  public:
99 
100 
107  public:
109 
110 
119  public:
120  void add (Sample *sample);
121 
122 
132  public:
133  void add (std::unique_ptr<Sample> sample);
134 
135 
145  public:
147 
148 
158  public:
159  void add (SamplePtr&& sample);
160 
161 
170  public:
171  void add (const SampleHandler& sh);
172 
173 
182  public:
183  void addWithPrefix (const SampleHandler& sh, const std::string& prefix);
184 
185 
193  public:
194  void remove (const std::string& name);
195 
196 
205  public:
206  void remove (const Sample *sample);
207 
208 
217  public:
218  Sample *get (const std::string& name);
219 
220 
229  public:
230  const Sample *get (const std::string& name) const;
231 
232 
241  public:
242  SampleHandler find (const TagList& tags) const;
243 
244 
255  public:
256  SampleHandler find (const std::string& tags) const;
257 
258 
270  public:
271  Sample *findBySource (const std::string& name) const;
272 
273 
283  public:
284  SampleHandler findByName (const std::string& pattern) const;
285 
286 
294  public:
295  void print () const;
296 
297 
307  public:
308  void printContent () const;
309 
310 
322  public:
323  void save (const std::string& directory) const;
324 
325 
337  public:
338  void load (const std::string& directory);
339 
340 
354  public:
355  void updateLocation (const std::string& from, const std::string& to);
356 
357 
369  public:
370  void fetch (const SampleHandler& source);
371 
372 
382  public:
384 
385 
399  public:
400  bool check_complete (const SampleHandler& source) const;
401 
402 
415  public:
416  void setMetaDouble (const std::string& name, double value);
417 
418 
431  public:
432  void setMetaString (const std::string& name, const std::string& value);
433 
434 
449  public:
450  void setMetaDouble (const std::string& pattern, const std::string& name,
451  double value);
452 
453 
468  public:
469  void setMetaString (const std::string& pattern, const std::string& name,
470  const std::string& value);
471 
472 
474  public:
475  typedef std::vector<Sample*>::const_iterator iterator;
476 
477 
482  public:
483  iterator begin () const;
484 
485 
490  public:
491  iterator end () const;
492 
493 
498  public:
499  std::size_t size () const;
500 
501 
507  public:
508  Sample *operator [] (std::size_t index) const;
509 
510 
516  public:
517  Sample *at (std::size_t index) const;
518 
519 
520 
521  //
522  // private interface
523  //
524 
525  friend void swap (SampleHandler& a, SampleHandler& b);
526 
528  private:
529  std::vector<SH::Sample*> m_samples;
530 
532  private:
533  typedef std::vector<SH::Sample*>::const_iterator SamplesIter;
534 
536  private:
538 
540  private:
541  std::map<std::string,SH::SamplePtr> m_named;
542 
544  private:
546 
548  private:
550 
551  ClassDef (SampleHandler, 1)
552  };
553 }
554 
555 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SH::SampleHandler::addWithPrefix
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
mergePhysValFiles.pattern
pattern
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:26
SH::SampleHandler::findBySource
Sample * findBySource(const std::string &name) const
find a sample by the name in the source sample handler
SH::SampleHandler::add
void add(std::unique_ptr< Sample > sample)
add a sample to the handler
SH::SampleHandler::fetchDefaults
void fetchDefaults(const SampleHandler &source)
fetch the meta-data for all that samples that don't have it in this sample.
SH::SampleHandler::iterator
std::vector< Sample * >::const_iterator iterator
the iterator to use
Definition: SampleHandler.h:475
SH::SampleHandler::NamedIter
std::map< std::string, SH::SamplePtr >::iterator NamedIter
the iterator for m_named
Definition: SampleHandler.h:545
SH::SampleHandler::at
Sample * at(std::size_t index) const
the sample with the given index
SH::TagList
A class that manages a list of tags for identifying samples.
Definition: TagList.h:48
SH::SampleHandler::add
void add(Sample *sample)
add a sample to the handler
SH::SampleHandler::find
SampleHandler find(const std::string &tags) const
find all samples which have at least one of the given tags.
SH::SampleHandler::SamplesMIter
std::vector< SH::Sample * >::iterator SamplesMIter
the mutable iterator for m_samples
Definition: SampleHandler.h:537
SH::SampleHandler::~SampleHandler
~SampleHandler()
standard destructor
SH::SampleHandler::add
void add(SamplePtr &sample)
add a sample to the handler
index
Definition: index.py:1
SH::SampleHandler::updateLocation
void updateLocation(const std::string &from, const std::string &to)
update all file references starting with from to to
SH::SampleHandler::operator=
SampleHandler & operator=(const SampleHandler &that)
standard assignment operator
SH::SampleHandler::find
SampleHandler find(const TagList &tags) const
find all samples which have at least one of the given tags.
SH::SampleHandler::add
void add(SamplePtr &&sample)
add a sample to the handler
SH::SampleHandler::m_samples
std::vector< SH::Sample * > m_samples
the list of samples managed
Definition: SampleHandler.h:529
SH::SampleHandler::end
iterator end() const
the end iterator to use
athena.value
value
Definition: athena.py:124
SH::SampleHandler::SampleHandler
SampleHandler(const SampleHandler &that)
standard copy constructor
SH::SampleHandler::printContent
void printContent() const
print the debugging output to the screen
SH::SampleHandler::size
std::size_t size() const
the number of samples contained
SH::SampleHandler::print
void print() const
print the debugging output to the screen
SH::SampleHandler::setMetaString
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.
SH::SampleHandler::save
void save(const std::string &directory) const
save the list of samples to the given directory
SH::SampleHandler::get
const Sample * get(const std::string &name) const
get the sample with the given name
SH::SampleHandler::setMetaDouble
void setMetaDouble(const std::string &name, double value)
set the meta-data double with the given name for all samples.
SH::SampleHandler::testInvariant
void testInvariant() const
test the invariant of this object
SamplePtr.h
tags
std::vector< std::string > tags
Definition: hcg.cxx:102
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:116
DeMoScan.directory
string directory
Definition: DeMoScan.py:80
SH::SampleHandler::setMetaDouble
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.
RCU::Shell
Definition: ShellExec.cxx:28
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
SH::SampleHandler::dbg
std::string dbg(const SampleHandler &obj, unsigned verbosity=0)
the debugging info of this object
SH::Sample
a base class that manages a set of files belonging to a particular data set and the associated meta-d...
Definition: Sample.h:54
SH::SampleHandler::SampleHandler
SampleHandler()
standard constructor
SH::SampleHandler::load
void load(const std::string &directory)
load all the samples from the given directory
SH::SampleHandler::check_complete
bool check_complete(const SampleHandler &source) const
whether we have all samples from the source SampleHandler.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
SH::SampleHandler::begin
iterator begin() const
the begin iterator to use
covarianceTool.verbosity
verbosity
Definition: covarianceTool.py:513
SH::SamplePtr
A smart pointer class that holds a single Sample object.
Definition: SamplePtr.h:35
SH::SampleHandler::setMetaString
void setMetaString(const std::string &name, const std::string &value)
set the meta-data string with the given name for all samples.
SH::SampleHandler::m_named
std::map< std::string, SH::SamplePtr > m_named
the list of samples by name
Definition: SampleHandler.h:541
CxxUtils::to
CONT to(RANGE &&r)
Definition: ranges.h:39
SH::SampleHandler::findByName
SampleHandler findByName(const std::string &pattern) const
find samples by pattern on the name
a
TList * a
Definition: liststreamerinfos.cxx:10
SH::SampleHandler::add
void add(const SampleHandler &sh)
add all samples from the given SampleHandler to this one
SH::SampleHandler::operator[]
Sample * operator[](std::size_t index) const
the sample with the given index
SH::SampleHandler::swap
void swap(SampleHandler &a, SampleHandler &b)
standard swap
SH::SampleHandler::NamedMIter
std::map< std::string, SH::SamplePtr >::iterator NamedMIter
the mutable iterator for m_named
Definition: SampleHandler.h:549
SH::SampleHandler::remove
void remove(const std::string &name)
remove the given sample
copySelective.source
string source
Definition: copySelective.py:32
SH::SampleHandler
A class that manages a list of Sample objects.
Definition: SampleHandler.h:60
SH
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition: PrunDriver.h:15
SH::SampleHandler::remove
void remove(const Sample *sample)
remove the given sample
SH::SampleHandler::fetch
void fetch(const SampleHandler &source)
fetch the meta-data for all samples that are also in the source sample handler.
SH::SampleHandler::get
Sample * get(const std::string &name)
get the sample with the given name
SH::SampleHandler::SamplesIter
std::vector< SH::Sample * >::const_iterator SamplesIter
the iterator for m_samples
Definition: SampleHandler.h:533
python.PyAthena.obj
obj
Definition: PyAthena.py:132
Global.h