ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7//
8// includes
9//
10
12
19#include <memory>
20
21//
22// method implementations
23//
24
26
27namespace SH
28{
29 void SampleGrid ::
30 testInvariant () const
31 {
32 }
33
34
35
36 SampleGrid ::
37 SampleGrid ()
38 : Sample ("unnamed")
39 {
40 RCU_NEW_INVARIANT (this);
41 }
42
43
44
45 SampleGrid ::
46 SampleGrid (const std::string& name)
47 : Sample (name)
48 {
49 RCU_NEW_INVARIANT (this);
50 }
51
52
53
54 std::size_t SampleGrid ::
55 getNumFiles () const
56 {
57 RCU_READ_INVARIANT (this);
58 RCU_THROW_MSG ("Sample::numFiles not supported for SampleGrid");
59 return 0; // compiler dummy
60 }
61
62
63
64 std::string SampleGrid ::
65 getFileName (const std::size_t /*index*/) const
66 {
67 RCU_READ_INVARIANT (this);
68 RCU_THROW_MSG ("Sample::fileName not supported for SampleGrid");
69 return ""; // compiler dummy
70 }
71
72
73
74 std::unique_ptr<SampleLocal> SampleGrid ::
75 doMakeLocal () const
76 {
77 RCU_READ_INVARIANT (this);
78
79 std::unique_ptr<SampleLocal> result (new SampleLocal (name()));
80 for (auto& file : makeFileList ())
81 result->add (file.c_str());
82 return result;
83 }
84
85
86
87 std::vector<std::string> SampleGrid ::
88 doMakeFileList () const
89 {
90 RCU_READ_INVARIANT (this);
91 using namespace msgGridTools;
92
93 const char *downloadDir = getenv (downloadStageEnvVar().c_str());
94
95 const std::string sampleName
96 = meta()->castString (MetaFields::gridName, name());
97 const std::string fileFilter
99
100 if (downloadDir)
101 {
102 ANA_MSG_DEBUG ("download dir set, trying download");
103 if (downloadDir[0] != '/')
104 throw std::runtime_error ("rucio download path in variable " + downloadStageEnvVar() + " should start with /");
105 return rucioCacheDatasetGlob (downloadDir, sampleName, fileFilter);
106 } else
107 {
108 ANA_MSG_DEBUG ("download dir not set, trying direct access");
109 const std::string sourceOptions
110 = meta()->castString (MetaFields::gridSourceOptions);
111 return rucioDirectAccessGlob (sampleName, fileFilter, sourceOptions);
112 }
113 }
114}
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:228
#define RCU_READ_INVARIANT(x)
Definition Assert.h:224
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:53
ClassImp(SH::SampleGrid) namespace SH
This class implements a Sample located on the grid.
Definition SampleGrid.h:36
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15
const std::string & downloadStageEnvVar()
the name of the environment variable containing the directory for staging files from the grid
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
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 (...
-diff
static const std::string gridFilter
the field containing the file filter for the dataset on the grid
Definition MetaFields.h:30
static const std::string gridName
the field containing the name of the dataset on the grid
Definition MetaFields.h:26
static const std::string gridSourceOptions
the field containing the source options for datasets on the grid
Definition MetaFields.h:37
static const std::string gridFilter_default
the default value for gridFilter
Definition MetaFields.h:33
TFile * file