1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#include "Fireworks/Core/interface/fwPaths.h"
#include "Fireworks/Core/interface/fwLog.h"
#include "TString.h"
#include "TSystem.h"
#include "TPRegexp.h"
#include <iostream>
#include <fstream>
namespace fireworks {
const TString datadir("/src/Fireworks/Core/");
const TString p1 = gSystem->Getenv("CMSSW_BASE") + datadir;
const TString p2 = gSystem->Getenv("CMSSW_RELEASE_BASE") + datadir;
void setPath(TString& v) {
if (gSystem->AccessPathName(p1 + v) == kFALSE) {
v.Prepend(p1);
return;
}
v.Prepend(p2);
if (gSystem->AccessPathName(v))
fwLog(fwlog::kError) << "Can't access path " << v << std::endl;
}
void getDecomposedVersion(const TString& s, int* out) {
TPMERegexp re("CMSSW_(\\d+)_(\\d+)_");
re.Match(s);
if (re.NMatches() > 2) {
out[0] = re[1].Atoi();
out[1] = re[2].Atoi();
}
}
int* supportedDataFormatsVersion() {
static int mm[] = {0, 0, 0};
if (!mm[0]) {
TString v;
if (gSystem->Getenv("CMSSW_VERSION")) {
v = gSystem->Getenv("CMSSW_VERSION");
} else {
TString versionFileName = gSystem->Getenv("CMSSW_BASE");
versionFileName += "/src/Fireworks/Core/data/version.txt";
std::ifstream fs(versionFileName);
TString infoText;
infoText.ReadLine(fs);
infoText.ReadLine(fs);
fs.close();
v = &infoText[13];
}
getDecomposedVersion(v, &mm[0]);
}
return &mm[0];
}
bool acceptDataFormatsVersion(TString& processConfigurationVersion) {
int data[] = {0, 0, 0};
getDecomposedVersion(processConfigurationVersion, data);
int* running = supportedDataFormatsVersion();
if ((data[0] == 6 && running[0] == 5 && running[1] > 1) || (data[0] == 5 && data[1] > 1 && running[0] == 6))
return true;
else
return data[0] == running[0];
}
} // namespace fireworks
|