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
6
7#ifndef SAMPLE_HANDLER_SAMPLE_HH
8#define SAMPLE_HANDLER_SAMPLE_HH
9
11
12#include <memory>
13#include <string>
14#include <vector>
15#include <TObject.h>
17
18class TChain;
19class TCollection;
20
21namespace SH
22{
23 class SampleLocal;
24
25
37 std::string dbg (const Sample& obj, unsigned verbosity = 0);
38
39
40
48 class Sample : public TObject
49 {
50 //
51 // public interface
52 //
53
58 public:
59 void testInvariant () const;
60
61
66 public:
67 virtual ~Sample ();
68
69
74 const std::string& name () const;
75
88 public:
89 void name (std::string val_name);
90
91
100 public:
101 void lockName ();
102
103
108 public:
109 std::size_t numFiles () const;
110
111
122 public:
123 std::string fileName (std::size_t index) const;
124
125
137 public:
138 std::unique_ptr<SampleLocal> makeLocal () const;
139
140
145 public:
146 const TagList& tags () const;
147
148
155 public:
156 void tags (const TagList& tags);
157
158
165 public:
166 void addTag (const std::string& tag);
167
168
182 public:
183 void updateLocation (const std::string& from, const std::string& to);
184
185
191 public:
193
194
196 public:
197 const MetaObject *meta () const;
198
199
207 public:
208 std::vector<std::string> makeFileList () const;
209
210
219 public:
220 TChain *makeTChain () const;
221
222
232 public:
233 TObject *readHist (const std::string& name) const;
234
235
248 public:
249 bool contains (const std::string& name) const;
250
251
262 public:
263 void addSamples (SampleHandler& result, const std::shared_ptr<Sample>& self);
264
265
274 public:
275 void print () const;
276
277
281 public:
282 void printContent () const;
283
284
290 public:
291 Long64_t getNumEntries () const;
292
293
294
295 //
296 // legacy interface
297 //
298
306 public:
307 [[deprecated("use meta() instead, or (preferably) access of meta-data by name")]]
308 TCollection *metaDataList ();
309
310
312 public:
313 [[deprecated("use meta() instead, or (preferably) access of meta-data by name")]]
314 const TCollection *metaDataList () const;
315
316
318 public:
319 [[deprecated("use meta() instead")]]
320 void removeMeta (const std::string& name);
321
322
324 public:
325 [[deprecated("use meta() instead")]]
326 void addReplaceMeta (TNamed *meta_swallow);
327
328
330 public:
331 [[deprecated("use meta() instead")]]
332 TObject *getMeta (const std::string& name);
333
334
336 public:
337 [[deprecated("use meta() instead")]]
338 const TObject *getMeta (const std::string& name) const;
339
340
342 public:
343 [[deprecated("use meta() instead")]]
344 double getMetaDouble (const std::string& name, double def_val = 0) const;
345
346
348 public:
349 [[deprecated("use meta() instead")]]
350 std::string getMetaString (const std::string& name, const std::string& def_val = "") const;
351
352
354 public:
355 [[deprecated("use meta() instead")]]
356 void setMetaDouble (const std::string& name, double value);
357
358
360 public:
361 [[deprecated("use meta() instead")]]
362 void setMetaString (const std::string& name, const std::string& value);
363
364
366 public:
367 [[deprecated("use meta() instead")]]
368 void fetchMeta (const Sample& source);
369
370
371
372 //
373 // protected interface
374 //
375
382 protected:
383 Sample (const std::string& name);
384
386 Sample (const Sample& that);
387
388
389
390 //
391 // virtual interface
392 //
393
397 protected:
398 virtual std::size_t getNumFiles () const = 0;
399
400
404 protected:
405 virtual std::string getFileName (std::size_t index) const = 0;
406
407
411 protected:
412 virtual std::unique_ptr<SampleLocal> doMakeLocal () const = 0;
413
414
418 protected:
419 virtual std::vector<std::string> doMakeFileList () const = 0;
420
421
425 protected:
426 virtual void
427 doUpdateLocation (const std::string& from, const std::string& to);
428
429
433 protected:
434 virtual TObject *doReadHist (const std::string& name) const;
435
436
440 protected:
441 virtual bool getContains (const std::string& name) const;
442
443
447 protected:
448 virtual void doAddSamples (SampleHandler& result,
449 const std::shared_ptr<Sample>& self);
450
451
452 //
453 // private interface
454 //
455
457 private:
458 std::string m_name;
459
461 private:
463
465 private:
467
473 private:
474 bool m_lockedName = false;
475
478 private:
479 Sample& operator = (const Sample& that) = delete;
480
482 };
483}
484
485#endif
A class that manages meta-data to be associated with an object.
Definition MetaObject.h:48
A class that manages a list of Sample objects.
A Sample based on a simple file list.
Definition SampleLocal.h:30
void name(std::string val_name)
set the value of name
void lockName()
prevent any further changes to 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()
std::unique_ptr< SampleLocal > makeLocal() const
Make this a local sample, i.e.
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
virtual void doAddSamples(SampleHandler &result, const std::shared_ptr< Sample > &self)
add all samples this sample corresponds to to the given sample handler
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
Sample & operator=(const Sample &that)=delete
transient
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:466
TagList m_tags
the tag list we are using
Definition Sample.h:462
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
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
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
Sample(const std::string &name)
standard constructor
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 std::unique_ptr< SampleLocal > doMakeLocal() const =0
Make this a local sample, i.e.
virtual ~Sample()
standard destructor
void addSamples(SampleHandler &result, const std::shared_ptr< Sample > &self)
add all samples this sample corresponds to to the given sample handler
std::string m_name
the name of the sample we are using
Definition Sample.h:458
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()
virtual TObject * doReadHist(const std::string &name) const
read an object from a histogram file
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
bool m_lockedName
whether name may still be changed; set by lockName
Definition Sample.h:474
A class that manages a list of tags for identifying samples.
Definition TagList.h:39
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15
Definition index.py:1