Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:42

0001 #include "Fireworks/Core/interface/fwPaths.h"
0002 #include "Fireworks/Core/interface/fwLog.h"
0003 #include "TString.h"
0004 #include "TSystem.h"
0005 #include "TPRegexp.h"
0006 #include <iostream>
0007 #include <fstream>
0008 
0009 namespace fireworks {
0010 
0011   const TString datadir("/src/Fireworks/Core/");
0012   const TString p1 = gSystem->Getenv("CMSSW_BASE") + datadir;
0013   const TString p2 = gSystem->Getenv("CMSSW_RELEASE_BASE") + datadir;
0014 
0015   void setPath(TString& v) {
0016     if (gSystem->AccessPathName(p1 + v) == kFALSE) {
0017       v.Prepend(p1);
0018       return;
0019     }
0020 
0021     v.Prepend(p2);
0022     if (gSystem->AccessPathName(v))
0023       fwLog(fwlog::kError) << "Can't access path " << v << std::endl;
0024   }
0025 
0026   void getDecomposedVersion(const TString& s, int* out) {
0027     TPMERegexp re("CMSSW_(\\d+)_(\\d+)_");
0028     re.Match(s);
0029     if (re.NMatches() > 2) {
0030       out[0] = re[1].Atoi();
0031       out[1] = re[2].Atoi();
0032     }
0033   }
0034 
0035   int* supportedDataFormatsVersion() {
0036     static int mm[] = {0, 0, 0};
0037 
0038     if (!mm[0]) {
0039       TString v;
0040       if (gSystem->Getenv("CMSSW_VERSION")) {
0041         v = gSystem->Getenv("CMSSW_VERSION");
0042 
0043       } else {
0044         TString versionFileName = gSystem->Getenv("CMSSW_BASE");
0045         versionFileName += "/src/Fireworks/Core/data/version.txt";
0046         std::ifstream fs(versionFileName);
0047         TString infoText;
0048         infoText.ReadLine(fs);
0049         infoText.ReadLine(fs);
0050         fs.close();
0051         v = &infoText[13];
0052       }
0053 
0054       getDecomposedVersion(v, &mm[0]);
0055     }
0056 
0057     return &mm[0];
0058   }
0059 
0060   bool acceptDataFormatsVersion(TString& processConfigurationVersion) {
0061     int data[] = {0, 0, 0};
0062     getDecomposedVersion(processConfigurationVersion, data);
0063 
0064     int* running = supportedDataFormatsVersion();
0065     if ((data[0] == 6 && running[0] == 5 && running[1] > 1) || (data[0] == 5 && data[1] > 1 && running[0] == 6))
0066       return true;
0067     else
0068       return data[0] == running[0];
0069   }
0070 
0071 }  // namespace fireworks