ATLAS Offline Software
SampleLocal.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 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>
22 #include <TSystem.h>
23 
24 //
25 // method implementations
26 //
27 
29 
30 namespace SH
31 {
32  void SampleLocal ::
33  testInvariant () const
34  {
35  for (FilesIter file = m_files.begin(),
36  end = m_files.end(); file != end; ++ file)
37  {
38  RCU_INVARIANT (!file->empty());
39  RCU_INVARIANT ((*file)[0]==0 || file->find (":/") != std::string::npos);
40  }
41  }
42 
43 
44 
46  SampleLocal ()
47  : Sample ("unnamed")
48  {
49  RCU_NEW_INVARIANT (this);
50  }
51 
52 
53 
55  SampleLocal (const std::string& name)
56  : Sample (name)
57  {
58  RCU_NEW_INVARIANT (this);
59  }
60 
61 
62 
63  void SampleLocal ::
64  add (const std::string& file)
65  {
66  RCU_CHANGE_INVARIANT (this);
67  RCU_REQUIRE_SOFT (!file.empty());
68 
69  std::string myfile = file;
70  if (myfile.find (":/") == std::string::npos)
71  {
72  if (myfile[0] != '/')
73  myfile = gSystem->WorkingDirectory() + ("/" + myfile);
74  myfile = "file://" + myfile;
75  }
76  m_files.push_back (myfile);
77  }
78 
79 
80 
81  std::size_t SampleLocal ::
82  getNumFiles () const
83  {
84  RCU_READ_INVARIANT (this);
85  return m_files.size();
86  }
87 
88 
89 
90  std::string SampleLocal ::
91  getFileName (const std::size_t index) const
92  {
93  RCU_READ_INVARIANT (this);
94 
95  RCU_INVARIANT (index < m_files.size());
96  return m_files[index];
97  }
98 
99 
100 
101  SamplePtr SampleLocal ::
102  doMakeLocal () const
103  {
104  RCU_READ_INVARIANT (this);
105  return SamplePtr (const_cast<SampleLocal*>(this));
106  }
107 
108 
109 
110  std::vector<std::string> SampleLocal ::
111  doMakeFileList () const
112  {
113  RCU_READ_INVARIANT (this);
114 
115  std::vector<std::string> result;
116  for (FilesIter file = m_files.begin(),
117  end = m_files.end(); file != end; ++ file)
118  result.push_back (*file);
119  return result;
120  }
121 
122 
123 
124  void SampleLocal ::
125  doUpdateLocation (const std::string& from, const std::string& to)
126  {
127  RCU_READ_INVARIANT (this);
128  for (FilesMIter file = m_files.begin(),
129  end = m_files.end(); file != end; ++ file)
130  {
131  if (strncmp (file->c_str(), from.c_str(), from.size()) == 0)
132  *file = to + "/" + file->substr (from.size());
133  }
134  }
135 }
SH::Sample::SamplePtr
friend class SamplePtr
Definition: Sample.h:448
get_generator_info.result
result
Definition: get_generator_info.py:21
index
Definition: index.py:1
SH::SampleLocal::getNumFiles
virtual std::size_t getNumFiles() const
the number of files in the sample
ClassImp
ClassImp(SH::SampleLocal) namespace SH
Definition: SampleLocal.cxx:28
SH::SampleLocal::doUpdateLocation
virtual void doUpdateLocation(const std::string &from, const std::string &to)
update all file references starting with from to to
Assert.h
SH::SampleLocal::FilesMIter
std::vector< std::string >::iterator FilesMIter
the mutable iterator for m_files
Definition: SampleLocal.h:125
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
SamplePtr.h
SH::SampleLocal::FilesIter
std::vector< std::string >::const_iterator FilesIter
the iterator for m_files
Definition: SampleLocal.h:121
SampleLocal.h
SH::SampleLocal::doMakeLocal
virtual SamplePtr doMakeLocal() const
Make this a local sample, i.e.
RCU_REQUIRE_SOFT
#define RCU_REQUIRE_SOFT(x)
Definition: Assert.h:153
SH::SampleLocal::m_files
std::vector< std::string > m_files
the list of files we use
Definition: SampleLocal.h:117
file
TFile * file
Definition: tile_monitor.h:29
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CxxUtils::to
CONT to(RANGE &&r)
Definition: ranges.h:39
SH::SampleLocal::testInvariant
void testInvariant() const
test the invariant of this object
SH::SampleLocal::doMakeFileList
virtual std::vector< std::string > doMakeFileList() const
make a list of all files, prestaging them if necessary
DeMoScan.index
string index
Definition: DeMoScan.py:364
SH::SampleLocal::SampleLocal
SampleLocal()
standard constructor
SH::SampleLocal
A Sample based on a simple file list.
Definition: SampleLocal.h:38
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231
SH
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition: PrunDriver.h:15
SH::SampleLocal::add
void add(const std::string &file)
add a file to the list
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233
SH::SampleLocal::getFileName
virtual std::string getFileName(std::size_t index) const
the name of the file with the given index