CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
spf::SherpackFetcher Class Reference

#include <SherpackFetcher.h>

Public Member Functions

const char * classname () const
 
int CopyFile (std::string pathstring)
 
int Fetch ()
 
 SherpackFetcher (edm::ParameterSet const &)
 
 ~SherpackFetcher ()
 

Private Attributes

bool FetchSherpack
 
std::string SherpackChecksum
 
std::string SherpackLocation
 
std::string SherpaPath
 
std::string SherpaProcess
 

Detailed Description

Definition at line 20 of file SherpackFetcher.h.

Constructor & Destructor Documentation

◆ SherpackFetcher()

spf::SherpackFetcher::SherpackFetcher ( edm::ParameterSet const &  pset)

Definition at line 5 of file SherpackFetcher.cc.

5  {
6  if (!pset.exists("SherpaProcess"))
7  SherpaProcess = "";
8  else
9  SherpaProcess = pset.getParameter<std::string>("SherpaProcess");
10  if (!pset.exists("SherpackLocation"))
11  SherpackLocation = "";
12  else
13  SherpackLocation = pset.getParameter<std::string>("SherpackLocation");
14  if (!pset.exists("SherpackChecksum"))
15  SherpackChecksum = "";
16  else
17  SherpackChecksum = pset.getParameter<std::string>("SherpackChecksum");
18  if (!pset.exists("FetchSherpack"))
19  FetchSherpack = false;
20  else
21  FetchSherpack = pset.getParameter<bool>("FetchSherpack");
22  if (!pset.exists("SherpaPath"))
23  SherpaPath = "";
24  else
25  SherpaPath = pset.getParameter<std::string>("SherpaPath");
26  }

References FetchSherpack, muonDTDigis_cfi::pset, SherpackChecksum, SherpackLocation, SherpaPath, SherpaProcess, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~SherpackFetcher()

spf::SherpackFetcher::~SherpackFetcher ( )

Definition at line 109 of file SherpackFetcher.cc.

109 {}

Member Function Documentation

◆ classname()

const char* spf::SherpackFetcher::classname ( ) const
inline

Definition at line 26 of file SherpackFetcher.h.

26 { return "SherpackFetcher"; }

◆ CopyFile()

int spf::SherpackFetcher::CopyFile ( std::string  pathstring)

Definition at line 94 of file SherpackFetcher.cc.

94  {
95  //No need to backwards compatibility with the FnFileGet method, throw exception if only the relative path is given
96  if ((pathstring.find("slc6_amd64_gcc") == 0) || (pathstring.find("slc5_amd64_gcc") == 0)) {
97  throw cms::Exception("SherpaInterface") << "Old method of sherpack retrieving used, please use /cvmfs to store "
98  "files and specify the full path to the sherpack directory";
99  }
100  std::cout << "Trying to copy file " << pathstring << std::endl;
101  std::string command = "cp " + pathstring + " .";
102  FILE *pipe = popen(command.c_str(), "r");
103  if (!pipe)
104  throw cms::Exception("SherpaInterface") << "failed to copy Sherpack ";
105  pclose(pipe);
106  return 1;
107  }

References mps_check::command, gather_cfg::cout, Exception, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by Fetch().

◆ Fetch()

int spf::SherpackFetcher::Fetch ( )

Definition at line 28 of file SherpackFetcher.cc.

28  {
29  std::string option = "-c";
30  std::string constr = "`cmsGetFnConnect frontier://smallfiles`";
31  std::string sherpack = "sherpa_" + SherpaProcess + "_MASTER.tgz";
32  std::string sherpackunzip = "sherpa_" + SherpaProcess + "_MASTER.tar";
33  std::string path = SherpackLocation + "/" + sherpack;
34 
35  if (FetchSherpack == true) {
36  std::cout << "SherpackFetcher: Trying to fetch the Sherpack " << sherpack << std::endl;
37  int res = -1;
38 
39  res = CopyFile(path);
40 
41  if (res != 1) {
42  throw cms::Exception("SherpaInterface")
43  << "SherpackFetcher: Fetching of Sherpack did not succeed, terminating" << std::endl;
44  return -1;
45  }
46  std::cout << "SherpackFetcher: Fetching successful" << std::endl;
47  }
48 
49  std::ifstream my_file(sherpack.c_str());
50  if (!my_file.good()) {
51  throw cms::Exception("SherpaInterface") << "SherpackFetcher: No Sherpack found" << std::endl;
52  return -2;
53  }
54  my_file.close();
55  std::cout << "SherpackFetcher: Sherpack found" << std::endl;
56 
57  if (!SherpackChecksum.empty()) {
58  char md5checksum[33];
59  spu::md5_File(sherpack, md5checksum);
60  for (int k = 0; k < 33; k++) {
61  if (md5checksum[k] != SherpackChecksum[k]) {
62  throw cms::Exception("SherpaInterface")
63  << "SherpackFetcher: failure, calculated and specified checksums differ!" << std::endl;
64  return -3;
65  }
66  }
67  std::cout << "SherpackFetcher: Calculated checksum of the Sherpack is " << md5checksum << " and matches"
68  << std::endl;
69  } else {
70  std::cout << "SherpackFetcher: Ignoring Checksum" << std::endl;
71  }
72 
73  std::cout << "SherpackFetcher: Trying to unzip the Sherpack" << std::endl;
74  int res = spu::Unzip(sherpack, sherpackunzip);
75  if (res != 0) {
76  throw cms::Exception("SherpaInterface") << "SherpackFetcher: Decompressing failed " << std::endl;
77  return -4;
78  }
79  std::cout << "SherpackFetcher: Decompressing successful " << std::endl;
80 
81  FILE *file = fopen(const_cast<char *>(sherpackunzip.c_str()), "r");
82  if (file) {
83  std::cout << "SherpackFetcher: Decompressed Sherpack exists with name " << sherpackunzip
84  << " starting to untar it" << std::endl;
85  spu::Untar(file, SherpaPath.c_str());
86  } else {
87  throw cms::Exception("SherpaInterface") << "SherpackFetcher: Could not open decompressed Sherpack" << std::endl;
88  return -5;
89  }
90  fclose(file);
91  return 0;
92  }

References CopyFile(), gather_cfg::cout, Exception, FetchSherpack, geometryDiff::file, dqmdumpme::k, spu::md5_File(), fileinputsource_cfi::option, castor_dqm_sourceclient_file_cfg::path, SherpackChecksum, SherpackLocation, SherpaPath, SherpaProcess, AlCaHLTBitMon_QueryRunRegistry::string, spu::Untar(), and spu::Unzip().

Referenced by SherpaHadronizer::SherpaHadronizer().

Member Data Documentation

◆ FetchSherpack

bool spf::SherpackFetcher::FetchSherpack
private

Definition at line 32 of file SherpackFetcher.h.

Referenced by Fetch(), and SherpackFetcher().

◆ SherpackChecksum

std::string spf::SherpackFetcher::SherpackChecksum
private

Definition at line 31 of file SherpackFetcher.h.

Referenced by Fetch(), and SherpackFetcher().

◆ SherpackLocation

std::string spf::SherpackFetcher::SherpackLocation
private

Definition at line 30 of file SherpackFetcher.h.

Referenced by Fetch(), and SherpackFetcher().

◆ SherpaPath

std::string spf::SherpackFetcher::SherpaPath
private

Definition at line 33 of file SherpackFetcher.h.

Referenced by Fetch(), and SherpackFetcher().

◆ SherpaProcess

std::string spf::SherpackFetcher::SherpaProcess
private

Definition at line 29 of file SherpackFetcher.h.

Referenced by Fetch(), and SherpackFetcher().

spu::md5_File
void md5_File(std::string, char *)
Definition: SherpackUtilities.cc:486
gather_cfg.cout
cout
Definition: gather_cfg.py:144
mps_check.command
list command
Definition: mps_check.py:25
spf::SherpackFetcher::SherpackLocation
std::string SherpackLocation
Definition: SherpackFetcher.h:30
fileinputsource_cfi.option
option
Definition: fileinputsource_cfi.py:94
spf::SherpackFetcher::FetchSherpack
bool FetchSherpack
Definition: SherpackFetcher.h:32
spu::Unzip
int Unzip(std::string, std::string)
Definition: SherpackUtilities.cc:153
spf::SherpackFetcher::SherpaProcess
std::string SherpaProcess
Definition: SherpackFetcher.h:29
spf::SherpackFetcher::CopyFile
int CopyFile(std::string pathstring)
Definition: SherpackFetcher.cc:94
dqmdumpme.k
k
Definition: dqmdumpme.py:60
pipe
Definition: pipe.py:1
geometryDiff.file
file
Definition: geometryDiff.py:13
res
Definition: Electron.h:6
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
spu::Untar
void Untar(FILE *, const char *)
Definition: SherpackUtilities.cc:268
Exception
Definition: hltDiff.cc:245
spf::SherpackFetcher::SherpackChecksum
std::string SherpackChecksum
Definition: SherpackFetcher.h:31
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
spf::SherpackFetcher::SherpaPath
std::string SherpaPath
Definition: SherpackFetcher.h:33
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27