ATLAS Offline Software
SampleGrid.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 
10 // Please feel free to contact me (krumnack@iastate.edu) for bug
11 // reports, feature suggestions, praise and complaints.
12 
13 
14 //
15 // includes
16 //
17 
19 
20 #include <RootCoreUtils/Assert.h>
21 #include <RootCoreUtils/ThrowMsg.h>
27 #include <memory>
28 
29 //
30 // method implementations
31 //
32 
34 
35 namespace SH
36 {
37  void SampleGrid ::
38  testInvariant () const
39  {
40  }
41 
42 
43 
45  SampleGrid ()
46  : Sample ("unnamed")
47  {
48  RCU_NEW_INVARIANT (this);
49  }
50 
51 
52 
54  SampleGrid (const std::string& name)
55  : Sample (name)
56  {
57  RCU_NEW_INVARIANT (this);
58  }
59 
60 
61 
62  std::size_t SampleGrid ::
63  getNumFiles () const
64  {
65  RCU_READ_INVARIANT (this);
66  RCU_THROW_MSG ("Sample::numFiles not supported for SampleGrid");
67  return 0; // compiler dummy
68  }
69 
70 
71 
72  std::string SampleGrid ::
73  getFileName (const std::size_t /*index*/) const
74  {
75  RCU_READ_INVARIANT (this);
76  RCU_THROW_MSG ("Sample::fileName not supported for SampleGrid");
77  return ""; // compiler dummy
78  }
79 
80 
81 
82  SamplePtr SampleGrid ::
83  doMakeLocal () const
84  {
85  RCU_READ_INVARIANT (this);
86 
87  std::unique_ptr<SampleLocal> result (new SampleLocal (name()));
88  for (auto& file : makeFileList ())
89  result->add (file.c_str());
90  return SamplePtr (result.release());
91  }
92 
93 
94 
95  std::vector<std::string> SampleGrid ::
96  doMakeFileList () const
97  {
98  RCU_READ_INVARIANT (this);
99  using namespace msgGridTools;
100 
101  const char *downloadDir = getenv (downloadStageEnvVar().c_str());
102 
103  const std::string sampleName
105  const std::string fileFilter
107 
108  if (downloadDir)
109  {
110  ANA_MSG_DEBUG ("download dir set, trying download");
111  if (downloadDir[0] != '/')
112  throw std::runtime_error ("rucio download path in variable " + downloadStageEnvVar() + " should start with /");
113  return rucioCacheDatasetGlob (downloadDir, sampleName, fileFilter);
114  } else
115  {
116  ANA_MSG_DEBUG ("download dir not set, trying direct access");
117  const std::string sourceOptions
119  return rucioDirectAccessGlob (sampleName, fileFilter, sourceOptions);
120  }
121  }
122 }
SH::SampleGrid::getNumFiles
virtual std::size_t getNumFiles() const
the number of files in the sample
SH::Sample::SamplePtr
friend class SamplePtr
Definition: Sample.h:448
get_generator_info.result
result
Definition: get_generator_info.py:21
SH::MetaFields::gridFilter_default
static const std::string gridFilter_default
the default value for gridFilter
Definition: MetaFields.h:41
SH::rucioDirectAccessGlob
std::vector< std::string > rucioDirectAccessGlob(const std::string &name, const std::string &filter, const std::string &selectOptions)
list the rucio URLs for all the files in the dataset or dataset container matching the given filter (...
Definition: GridTools.cxx:281
Assert.h
SamplePtr.h
SampleLocal.h
MetaObject.h
SH::SampleGrid::doMakeLocal
virtual SamplePtr doMakeLocal() const
Make this a local sample, i.e.
SH::Sample::makeFileList
std::vector< std::string > makeFileList() const
make a list of all files, prestaging them if necessary
GridTools.h
file
TFile * file
Definition: tile_monitor.h:29
SH::SampleGrid
This class implements a Sample located on the grid.
Definition: SampleGrid.h:44
SH::SampleGrid::doMakeFileList
virtual std::vector< std::string > doMakeFileList() const
make a list of all files, prestaging them if necessary
SH::MetaFields::gridFilter
static const std::string gridFilter
the field containing the file filter for the dataset on the grid
Definition: MetaFields.h:38
SH::MetaObject::castString
std::string castString(const std::string &name, const std::string &def_val="", CastMode mode=CAST_ERROR_THROW) const
the meta-data string with the given name
SH::Sample::meta
MetaObject * meta()
the meta-information for this sample
SH::Sample::name
const std::string & name() const
the name of the sample we are using
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MetaFields.h
ThrowMsg.h
SH::rucioCacheDatasetGlob
std::vector< std::string > rucioCacheDatasetGlob(const std::string &location, const std::string &dataset, const std::string &fileGlob)
download the dataset, and return a list matching the pattern
Definition: GridTools.cxx:535
SH::MetaFields::gridSourceOptions
static const std::string gridSourceOptions
the field containing the source options for datasets on the grid
Definition: MetaFields.h:45
SampleGrid.h
SH::SampleGrid::testInvariant
void testInvariant() const
test the invariant of this object
SCT_ConditionsAlgorithms::CoveritySafe::getenv
std::string getenv(const std::string &variableName)
get an environment variable
Definition: SCT_ConditionsUtilities.cxx:17
SH::MetaFields::gridName
static const std::string gridName
the field containing the name of the dataset on the grid
Definition: MetaFields.h:34
SH::downloadStageEnvVar
const std::string & downloadStageEnvVar()
the name of the environment variable containing the directory for staging files from the grid
Definition: GridTools.cxx:198
SH::SampleGrid::SampleGrid
SampleGrid()
standard constructor
SH
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition: PrunDriver.h:15
RCU_THROW_MSG
#define RCU_THROW_MSG(message)
Definition: PrintMsg.h:58
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
ClassImp
ClassImp(SH::SampleGrid) namespace SH
Definition: SampleGrid.cxx:33
SH::SampleGrid::getFileName
virtual std::string getFileName(std::size_t index) const
the name of the file with the given index
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233