ATLAS Offline Software
ScanDir.h
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 #ifndef SAMPLE_HANDLER__SCAN_DIR_H
9 #define SAMPLE_HANDLER__SCAN_DIR_H
10 
11 
12 #include <SampleHandler/Global.h>
13 
15 #include <map>
16 #include <vector>
17 
18 namespace SH
19 {
36 
37  struct ScanDir
38  {
39  //
40  // public interface
41  //
42 
48  public:
49  ScanDir ();
50 
51 
61  public:
62  const ScanDir& scan (SampleHandler& sh, const std::string& dir) const;
63 
64 
74  public:
75  const ScanDir& scanEOS (SampleHandler& sh, const std::string& eosDir) const;
76 
77 
79  public:
80  const ScanDir& scan (SampleHandler& sh, DiskList& list) const;
81 
82 
89  public:
90  ScanDir& sampleDepth (int val_sampleDepth);
91 
99  public:
100  ScanDir& absSampleDepth (int val_absSampleDepth);
101 
104  public:
105  ScanDir& sampleName (const std::string& val_sampleName);
106 
108  public:
109  ScanDir& minDepth (std::size_t val_minDepth);
110 
112  public:
113  ScanDir& maxDepth (std::size_t val_maxDepth);
114 
117  public:
118  ScanDir& filePattern (const std::string& val_filePattern);
119 
122  public:
123  ScanDir& fileRegex (const std::string& val_fileRegex);
124 
127  public:
128  ScanDir& directoryPattern (const std::string& val_directoryPattern);
129 
132  public:
133  ScanDir& directoryRegex (const std::string& val_directoryRegex);
134 
136  public:
137  ScanDir& samplePattern (const std::string& val_samplePattern);
138 
141  public:
142  ScanDir& samplePostfix (const std::string& val_samplePostfix);
143 
145  public:
146  ScanDir& sampleRename (const std::string& pattern, const std::string& name);
147 
151  public:
152  ScanDir& extraNameComponent (int val_relSampleDepth);
153 
154 
155 
156  //
157  // private interface
158  //
159 
162  private:
164 
168  private:
170 
172  private:
173  std::string m_sampleName;
174 
176  private:
177  std::size_t m_minDepth;
178 
180  private:
181  std::size_t m_maxDepth;
182 
185  private:
187 
190  private:
192 
195  private:
197 
200  private:
202 
205  private:
207 
209  private:
210  typedef std::vector<std::pair<boost::regex,std::string> >::const_iterator SampleRenameIter;
211  std::vector<std::pair<boost::regex,std::string> > m_sampleRename;
212 
214  private:
216 
217 
224  private:
225  void recurse (std::map<std::string,SamplePtr>& samples, DiskList& list,
226  const std::vector<std::string>& hierarchy) const;
227 
228 
235  private:
236  void addSampleFile (std::map<std::string,SamplePtr>& samples,
237  const std::vector<std::string>& hierarchy,
238  const std::string& path) const;
239 
240 
247  private:
248  std::string
249  findPathComponent (const std::vector<std::string>& hierarchy,
250  int absSampleDepth,
251  int relSampleDepth) const;
252  };
253 }
254 
255 #endif
mergePhysValFiles.pattern
pattern
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:26
SH::ScanDir
the class used for scanning local directories and file servers for samples
Definition: ScanDir.h:38
SH::ScanDir::m_samplePattern
boost::regex m_samplePattern
the value set by samplePattern, converted to a regular expression
Definition: ScanDir.h:196
SH::ScanDir::sampleRename
ScanDir & sampleRename(const std::string &pattern, const std::string &name)
rename any sample matching pattern to name
Definition: ScanDir.cxx:149
SH::ScanDir::directoryRegex
ScanDir & directoryRegex(const std::string &val_directoryRegex)
the regular expression for directories to be visited
Definition: ScanDir.cxx:121
SH::ScanDir::SampleRenameIter
std::vector< std::pair< boost::regex, std::string > >::const_iterator SampleRenameIter
the list of entries from sampleRename
Definition: ScanDir.h:210
SH::ScanDir::maxDepth
ScanDir & maxDepth(std::size_t val_maxDepth)
the maximum depth for files to make it into the sample
Definition: ScanDir.cxx:85
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
SH::ScanDir::m_filePattern
boost::regex m_filePattern
the value set by filePattern, converted to a regular expression
Definition: ScanDir.h:186
SH::ScanDir::m_samplePostfix
boost::regex m_samplePostfix
the value set by samplePostfix, converted to a regular expression
Definition: ScanDir.h:201
SH::ScanDir::m_minDepth
std::size_t m_minDepth
the value set by minDepth
Definition: ScanDir.h:177
SH::ScanDir::m_samplePostfixEmpty
bool m_samplePostfixEmpty
whether samplePostfix has been set to the empty string
Definition: ScanDir.h:206
SH::ScanDir::m_directoryPattern
boost::regex m_directoryPattern
the value set by directoryPattern, converted to a regular expression
Definition: ScanDir.h:191
SH::ScanDir::findPathComponent
std::string findPathComponent(const std::vector< std::string > &hierarchy, int absSampleDepth, int relSampleDepth) const
find the path component at the given depth
Definition: ScanDir.cxx:329
SH::ScanDir::m_sampleName
std::string m_sampleName
the value set by sampleName
Definition: ScanDir.h:173
StringUtil.h
SH::ScanDir::samplePattern
ScanDir & samplePattern(const std::string &val_samplePattern)
the pattern for samples to be accepted
Definition: ScanDir.cxx:130
SH::ScanDir::directoryPattern
ScanDir & directoryPattern(const std::string &val_directoryPattern)
the pattern for directories to be visited
Definition: ScanDir.cxx:112
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
SH::ScanDir::samplePostfix
ScanDir & samplePostfix(const std::string &val_samplePostfix)
the pattern for the postfix to be stripped from the sampleName
Definition: ScanDir.cxx:139
SH::ScanDir::m_relSampleDepth
int m_relSampleDepth
if this is negative it is the depth at which we take the sample name, counting from the end
Definition: ScanDir.h:163
SH::ScanDir::sampleDepth
ScanDir & sampleDepth(int val_sampleDepth)
the index of the file hierarchy at which we gather the sample name.
Definition: ScanDir.cxx:47
RCU::Shell
Definition: ShellExec.cxx:28
01SubmitToGrid.samples
samples
Definition: 01SubmitToGrid.py:58
SH::DiskList
an interface for listing directory contents, locally or on a file server
Definition: DiskList.h:32
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
SH::ScanDir::absSampleDepth
ScanDir & absSampleDepth(int val_absSampleDepth)
the index of the file hierarchy at which we gather the sample name.
Definition: ScanDir.cxx:57
SH::ScanDir::extraNameComponent
ScanDir & extraNameComponent(int val_relSampleDepth)
attach an extra name component to the sample based on a second component of the path
Definition: ScanDir.cxx:158
beamspotman.dir
string dir
Definition: beamspotman.py:623
SH::ScanDir::m_sampleRename
std::vector< std::pair< boost::regex, std::string > > m_sampleRename
Definition: ScanDir.h:211
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SH::ScanDir::fileRegex
ScanDir & fileRegex(const std::string &val_fileRegex)
the regular expression for files to be accepted
Definition: ScanDir.cxx:103
SH::ScanDir::m_absSampleDepth
int m_absSampleDepth
if m_relSampleDepth is not negative, it is the depth at which we take the sample name,...
Definition: ScanDir.h:169
SH::ScanDir::scan
const ScanDir & scan(SampleHandler &sh, const std::string &dir) const
scan the given directory and put the created samples into the sample handler
Definition: ScanDir.cxx:168
SH::ScanDir::m_maxDepth
std::size_t m_maxDepth
the value set by maxDepth
Definition: ScanDir.h:181
SH::ScanDir::scanEOS
const ScanDir & scanEOS(SampleHandler &sh, const std::string &eosDir) const
scan the given directory in EOS and put the created samples into the sample handler
Definition: ScanDir.cxx:178
SH::ScanDir::sampleName
ScanDir & sampleName(const std::string &val_sampleName)
a single sample name into which all found files should be placed.
Definition: ScanDir.cxx:67
SH::ScanDir::filePattern
ScanDir & filePattern(const std::string &val_filePattern)
the pattern for files to be accepted
Definition: ScanDir.cxx:94
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
Global.h
SH::ScanDir::m_extraNameComponent
int m_extraNameComponent
the depth set with extraNameComponent, or 0 otherwise
Definition: ScanDir.h:215
SH::ScanDir::addSampleFile
void addSampleFile(std::map< std::string, SamplePtr > &samples, const std::vector< std::string > &hierarchy, const std::string &path) const
add the given file to the sample based on the hierarchy, creating the sample if necessary
Definition: ScanDir.cxx:255
SH::ScanDir::ScanDir
ScanDir()
standard constructor
Definition: ScanDir.cxx:33
SH::ScanDir::recurse
void recurse(std::map< std::string, SamplePtr > &samples, DiskList &list, const std::vector< std::string > &hierarchy) const
perform the recursive scanning of the directory tree
Definition: ScanDir.cxx:210
SH::ScanDir::minDepth
ScanDir & minDepth(std::size_t val_minDepth)
the minimum depth for files to make it into the sample
Definition: ScanDir.cxx:76