Skip to content

Commit

Permalink
Merge branch 'master' into jgalan_sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
jgalan authored Apr 8, 2024
2 parents da5b3e4 + 75b29bb commit 2cae8bf
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 62 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ endif ()
set(external_include_dirs)
set(external_libs)

if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(external_include_dirs ${external_include_dirs} "/usr/local/include/")
message(STATUS "Adding BREW include directory: /usr/local/include")
endif (CMAKE_SYSTEM_NAME MATCHES "Darwin")

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${DECAY_PATH}/cmake
${CMAKE_MODULE_PATH})
set(CMAKE_MACOSX_RPATH 1)
Expand Down Expand Up @@ -356,7 +361,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin") # we must call library install here in
endif ()

# Copy pcm files
if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "Windows")
if (CMAKE_SYSTEM_NAME MATCHES "Windows")

# Copy pcm files to bin
install(
Expand Down
2 changes: 1 addition & 1 deletion cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
execute_process(
"${CMAKE_COMMAND}" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
Expand Down
84 changes: 56 additions & 28 deletions macros/REST_ListMacros.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,21 @@ using namespace std;
//*** Lists all the official macros together with its documentation
//***
//*******************************************************************************************************
Int_t REST_ListMacros() {
Int_t REST_ListMacros(int details = 0, std::string onlyThisMacro = "") {
string macrosPath = (string)getenv("REST_PATH") + "/macros";
vector<string> directories = TRestTools::GetSubdirectories(macrosPath);

cout << "Directory : " << macrosPath << endl;
cout << endl;
cout << "Entering directory : " << macrosPath << endl;
vector<string> main_files = TRestTools::GetFilesMatchingPattern(macrosPath + "/REST_*.C");
for (int m = 0; m < main_files.size(); m++) {
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << " ++ "
<< " Macro : " << TRestTools::SeparatePathAndName(main_files[m]).second << endl;
std::ifstream t(main_files[m]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());

std::vector<string> lines = REST_StringHelper::Split(str, "\n");

cout << " ++ " << endl;
for (int l = 0; l < lines.size(); l++)
if (lines[l].find("//*** ") != string::npos)
cout << " ++ " << lines[l].substr(6, -1) << endl;
cout << " ++ " << endl;
}
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;

for (int n = 0; n < directories.size(); n++) {
cout << "Directory : " << directories[n] << endl;
if (directories[n].find("pipeline") != string::npos) continue;
if (directories[n].find("/macros/mac/") != string::npos) continue;
vector<string> files = TRestTools::GetFilesMatchingPattern(directories[n] + "/REST_*.C");

for (int m = 0; m < files.size(); m++) {
if (details) {
for (int m = 0; m < main_files.size(); m++) {
std::string macro = TRestTools::SeparatePathAndName(main_files[m]).second;
if (!onlyThisMacro.empty() && onlyThisMacro != macro) continue;
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << " ++ "
<< " Macro : " << TRestTools::SeparatePathAndName(files[m]).second << endl;
std::ifstream t(files[m]);
<< " Macro : " << macro << endl;
std::ifstream t(main_files[m]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());

std::vector<string> lines = REST_StringHelper::Split(str, "\n");
Expand All @@ -58,6 +39,53 @@ Int_t REST_ListMacros() {
cout << " ++ " << endl;
}
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
} else {
for (int m = 0; m < main_files.size(); m++) {
cout << " + " << TRestTools::SeparatePathAndName(main_files[m]).second << endl;
}
}

for (int n = 0; n < directories.size(); n++) {
cout << endl;
cout << "Entering directory : " << directories[n] << endl;
if (directories[n].find("pipeline") != string::npos) continue;
if (directories[n].find("/macros/mac/") != string::npos) continue;
vector<string> files = TRestTools::GetFilesMatchingPattern(directories[n] + "/REST_*.C");

if (details) {
for (int m = 0; m < files.size(); m++) {
std::string macro = TRestTools::SeparatePathAndName(files[m]).second;
if (!onlyThisMacro.empty() && onlyThisMacro != macro) continue;
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
<< endl;
cout << " ++ Macro : " << macro << endl;
std::ifstream t(files[m]);
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());

std::vector<string> lines = REST_StringHelper::Split(str, "\n");

cout << " ++ " << endl;
for (int l = 0; l < lines.size(); l++)
if (lines[l].find("//*** ") != string::npos)
cout << " ++ " << lines[l].substr(6, -1) << endl;
cout << " ++ " << endl;
}
cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
} else {
for (int m = 0; m < files.size(); m++) {
cout << " + " << TRestTools::SeparatePathAndName(files[m]).second << endl;
}
std::cout << std::endl;
std::cout << " ------- " << std::endl;
std::cout << "IMPORTANT. To get a more detailed macro documentation enable the details argument:"
<< std::endl;
std::cout << "Execute: restListMacros 1" << std::endl;
std::cout << "OR if you want to show only the documentation of a given macro, add the macro.C "
"filename as argument"
<< std::endl;
std::cout << "Execute: restListMacros 1 REST_CheckValidRuns.C" << std::endl;
std::cout << " ------- " << std::endl;
}
}
return 0;
}
4 changes: 4 additions & 0 deletions source/framework/core/inc/TRestMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ class TRestMetadata : public TNamed {

inline Bool_t isCleanState() const { return fCleanState; }

UInt_t GetVersionMajor() const;
UInt_t GetVersionMinor() const;
UInt_t GetVersionPatch() const;

Int_t GetVersionCode();
/// Returns a std::string with the path used for data storage
inline TString GetDataPath() {
Expand Down
8 changes: 7 additions & 1 deletion source/framework/core/src/TRestEvent.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

#include "TRestEvent.h"

#include "TRestRun.h"

using namespace std;

ClassImp(TRestEvent);
Expand Down Expand Up @@ -170,7 +172,11 @@ void TRestEvent::RestartPad(Int_t nElements) {

void TRestEvent::InitializeWithMetadata(TRestRun* run) { Initialize(); }

void TRestEvent::InitializeReferences(TRestRun* run) { fRun = run; }
void TRestEvent::InitializeReferences(TRestRun* run) {
fRun = run;
SetRunOrigin(fRun->GetRunNumber());
SetSubRunOrigin(fRun->GetSubRunNumber());
}

//////////////////////////////////////////////////////////////////////////
/// Run to print event data info on console
Expand Down
17 changes: 16 additions & 1 deletion source/framework/core/src/TRestMetadata.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ void TRestMetadata::ExpandIncludeFile(TiXmlElement* e) {
url = _filename;
}

filename = TRestTools::DownloadRemoteFile(url);
filename = TRestTools::DownloadRemoteFile(url, true);
} else {
filename = SearchFile(_filename);
}
Expand Down Expand Up @@ -2702,3 +2702,18 @@ void TRestMetadata::Merge(const TRestMetadata& metadata) {
fName = metadata.GetName();
}
}

UInt_t TRestMetadata::GetVersionMajor() const {
TString major = fVersion(0, fVersion.First('.'));
return major.Atoi();
}

UInt_t TRestMetadata::GetVersionMinor() const {
TString minor = fVersion(fVersion.First('.') + 1, fVersion.Last('.'));
return minor.Atoi();
}

UInt_t TRestMetadata::GetVersionPatch() const {
TString patch = fVersion(fVersion.Last('.') + 1, fVersion.Length());
return patch.Atoi();
}
8 changes: 4 additions & 4 deletions source/framework/tools/inc/TRestPhysics.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ TVector3 GetPlaneVectorIntersection(const TVector3& pos, const TVector3& dir, TV
TVector3 const& a);

TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha,
const Double_t R3, const Double_t lMirr);
const Double_t R3);

TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha,
const Double_t R3, const Double_t lMirr, const Double_t focal);
TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t beta,
const Double_t R3, const Double_t focal);

TVector3 GetConeNormal(const TVector3& pos, const Double_t alpha, const Double_t R = 0);

TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3);

TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3,
TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t beta, const Double_t R3,
const Double_t focal);

TMatrixD GetConeMatrix(const TVector3& d, const Double_t cosTheta);
Expand Down
2 changes: 1 addition & 1 deletion source/framework/tools/inc/TRestTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class TRestTools {

static std::string Execute(std::string cmd);

static std::string DownloadRemoteFile(const std::string& remoteFile);
static std::string DownloadRemoteFile(const std::string& remoteFile, bool pidPrefix = false);
static int DownloadRemoteFile(std::string remoteFile, std::string localFile);
static int UploadToServer(std::string localFile, std::string remoteFile, std::string methodUrl = "");

Expand Down
47 changes: 25 additions & 22 deletions source/framework/tools/src/TRestPhysics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ TVector3 GetPlaneVectorIntersection(const TVector3& pos, const TVector3& dir, co

//////////////////////////////////////////////
/// This method will find the intersection between a vector and a parabolic shape where `alpha` is the angle
/// between the optical axis and the paraboloid at the plane where the paraboloid has a radius of `R3`.
/// The paraboloid is rotationally symmetric around the optical axis. `alpha` in rad.
/// The region in which the intersection can happen here is between `-lMirr` and 0 on the z (optical) axis
/// between the z-axis and the paraboloid at the plane where the paraboloid has a radius of `R3`.
/// The paraboloid is rotationally symmetric around the z-axis. `alpha` in rad.
/// The region in which the intersection can happen here is in negative direction on the z-axis.
///
/// In case no intersection is found this method returns the unmodified input position
/// In case no intersection is found this method returns the unmodified input position.
///
TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha,
const Double_t R3, const Double_t lMirr) {
const Double_t R3) {
Double_t e = 2 * R3 * TMath::Tan(alpha);
Double_t a = dir.X() * dir.X() + dir.Y() * dir.Y();
Double_t b = 2 * (pos.X() * dir.X() + pos.Y() * dir.Y()) + e * dir.Z();
Expand All @@ -101,9 +101,11 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir
if (a != 0) {
Double_t root1 = (-half_b - TMath::Sqrt(half_b * half_b - a * c)) / a;
Double_t root2 = (-half_b + TMath::Sqrt(half_b * half_b - a * c)) / a;
if (pos.Z() + root1 * dir.Z() > -lMirr and pos.Z() + root1 * dir.Z() < 0) {
Double_t int1 = pos.Z() + root1 * dir.Z();
Double_t int2 = pos.Z() + root2 * dir.Z();
if (int1 < 0 and int2 < 0 and int1 > int2) {
return pos + root1 * dir;
} else if (pos.Z() + root2 * dir.Z() > -lMirr and pos.Z() + root2 * dir.Z() < 0) {
} else if (int1 < 0 and int2 < 0 and int1 < int2) {
return pos + root2 * dir;
}
return pos;
Expand All @@ -112,17 +114,17 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir
}

//////////////////////////////////////////////
/// This method will find the intersection between a vector and a hyperbolic shape where 3 * `alpha` is the
/// angle between the optical axis and the hyperboloid at the plane where the hyperboloid has a radius of
/// `R3`. The hyperboloid is rotationally symmetric around the optical axis. `alpha` in rad. The region in
/// which the intersection can happen here is between 0 and `lMirr` on the `z` (optical) axis
/// This method will find the intersection between a vector and a hyperbolic shape where beta = 3 * `alpha` is
/// the angle between the z-axis and the hyperboloid at the plane where the hyperboloid has a radius of `R3`.
/// The hyperboloid is rotationally symmetric around the z-axis. `alpha` in rad. The region in which the
/// intersection can happen here is in positive direction on the z-axis.
///
/// In case no intersection is found this method returns the unmodified input position
/// In case no intersection is found this method returns the unmodified input position.
///
TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha,
const Double_t R3, const Double_t lMirr, const Double_t focal) {
Double_t beta = 3 * alpha;
TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t beta,
const Double_t R3, const Double_t focal) {
Double_t e = 2 * R3 * TMath::Tan(beta);
Double_t alpha = beta / 3;
/// Just replaced here *TMath::Cot by /TMath::Tan to fix compilation issues
Double_t g = 2 * R3 * TMath::Tan(beta) / (focal + R3 / TMath::Tan(2 * alpha));
Double_t a = dir.X() * dir.X() + dir.Y() * dir.Y() - g * dir.Z() * dir.Z();
Expand All @@ -131,12 +133,13 @@ TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& di
Double_t c = pos.X() * pos.X() + pos.Y() * pos.Y() - R3 * R3 + e * pos.Z() - g * pos.Z() * pos.Z();
Double_t root1 = (-half_b - TMath::Sqrt(half_b * half_b - a * c)) / a;
Double_t root2 = (-half_b + TMath::Sqrt(half_b * half_b - a * c)) / a;
if (pos.Z() + root1 * dir.Z() > 0 and pos.Z() + root1 * dir.Z() < lMirr) {
Double_t int1 = pos.Z() + root1 * dir.Z();
Double_t int2 = pos.Z() + root2 * dir.Z();
if (int1 > 0 and int2 > 0 and int1 < int2) {
return pos + root1 * dir;
} else if (pos.Z() + root2 * dir.Z() > 0 and pos.Z() + root2 * dir.Z() < lMirr) {
} else if (int1 > 0 and int2 > 0 and int1 > int2) {
return pos + root2 * dir;
}

return pos;
}

Expand Down Expand Up @@ -199,7 +202,7 @@ TVector3 GetConeNormal(const TVector3& pos, const Double_t alpha, const Double_t
///////////////////////////////////////////////
/// \brief This method returns the normal vector on a parabolic surface pointing towards the inside
/// of the paraboloid. `pos` is the origin point of the normal vector on the parabolic plane and
/// `alpha` is the angle between the paraboloid and the optical (z) axis at the plane where the
/// `alpha` is the angle between the paraboloid and the z-axis at the plane where the
/// paraboloid has the radius `R3`.
///
TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3) {
Expand All @@ -214,13 +217,13 @@ TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Dou
///////////////////////////////////////////////
/// \brief This method returns the normal vector on a hyperbolic surface pointing towards the inside
/// of the hyperboloid. `pos` is the origin point of the normal vector on the hyperbolic plane and
/// `beta` is the angle between the hyperboloid and the optical (z) axis at the plane where the
/// `beta` is the angle between the hyperboloid and the z-axis at the plane where the
/// hyperboloid has the radius `R3`.
///
TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3,
TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t beta, const Double_t R3,
const Double_t focal) {
TVector3 normalVec = pos;
Double_t beta = 3 * alpha;
Double_t alpha = beta / 3;
/// Just replaced here *TMath::Cot by /TMath::Tan to fix compilation issues
Double_t m = 1 / (R3 * TMath::Tan(beta) * (1 - 2 * pos.Z() / (focal + R3 / TMath::Tan(2 * alpha))) /
TMath::Sqrt(R3 * R3 - R3 * 2 * TMath::Tan(beta) * pos.Z() *
Expand Down
6 changes: 3 additions & 3 deletions source/framework/tools/src/TRestTools.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ std::istream& TRestTools::GetLine(std::istream& is, std::string& t) {
/// will be used, including scp, wget. Downloads to REST_USER_PATH + "/download/" + filename
/// by default.
///
std::string TRestTools::DownloadRemoteFile(const string& url) {
std::string TRestTools::DownloadRemoteFile(const string& url, bool pidPrefix) {
string pureName = TRestTools::GetPureFileName(url);
if (pureName.empty()) {
RESTWarning << "error! (TRestTools::DownloadRemoteFile): url is not a file!" << RESTendl;
Expand All @@ -1133,7 +1133,8 @@ std::string TRestTools::DownloadRemoteFile(const string& url) {
if (url.find("local:") == 0) {
return Replace(url, "local:", "");
} else {
string fullpath = REST_USER_PATH + "/download/" + pureName;
string fullpath =
REST_USER_PATH + "/download/" + (pidPrefix ? "PID_" + ToString(getpid()) + "_" : "") + pureName;
int out;
int attempts = 10;
do {
Expand All @@ -1153,7 +1154,6 @@ std::string TRestTools::DownloadRemoteFile(const string& url) {
return "";
}
}
return "";
}

///////////////////////////////////////////////
Expand Down

0 comments on commit 2cae8bf

Please sign in to comment.