ATLAS Offline Software
ToolsJoin.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 <memory>
24 
25 //
26 // method implementations
27 //
28 
29 namespace SH
30 {
31  void mergeSamples (SampleHandler& sh, const std::string& sampleName,
32  const std::string& pattern)
33  {
34  SampleHandler mysh;
35  std::unique_ptr<SampleLocal> mysample (new SampleLocal (sampleName));
36 
37  boost::regex mypattern (pattern.c_str());
38  for (SampleHandler::iterator sample = sh.begin(),
39  end = sh.end(); sample != end; ++ sample)
40  {
41  if (RCU::match_expr (mypattern, (*sample)->name()))
42  {
43  for (unsigned file = 0, end = (*sample)->numFiles();
44  file != end; ++ file)
45  {
46  mysample->add ((*sample)->fileName (file));
47  }
48  } else
49  {
50  mysh.add (*sample);
51  }
52  }
53  mysh.add (mysample.release());
54  swap (mysh, sh);
55  }
56 }
mergePhysValFiles.pattern
pattern
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:26
SH::SampleHandler::iterator
std::vector< Sample * >::const_iterator iterator
the iterator to use
Definition: SampleHandler.h:475
SH::SampleHandler::add
void add(Sample *sample)
add a sample to the handler
SampleHandler.h
StringUtil.h
SH::mergeSamples
void mergeSamples(SampleHandler &sh, const std::string &sampleName, const std::string &pattern)
effects: remove all samples matching the name pattern, and join them into a single sample named sampl...
Definition: ToolsJoin.cxx:31
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
SampleLocal.h
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:113
RCU::Shell
Definition: ShellExec.cxx:28
RCU::match_expr
bool match_expr(const boost::regex &expr, const std::string &str)
returns: whether we can match the entire string with the regular expression guarantee: strong failure...
Definition: StringUtil.cxx:40
file
TFile * file
Definition: tile_monitor.h:29
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
ToolsJoin.h
SH::SampleLocal
A Sample based on a simple file list.
Definition: SampleLocal.h:38
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
SH::SampleLocal::add
void add(const std::string &file)
add a file to the list