update code for Mac

This commit is contained in:
Ryan@MBA2024 2024-07-04 18:37:46 -04:00
parent e944682888
commit f7d23a53ab
2 changed files with 19 additions and 13 deletions

1
.gitignore vendored
View File

@ -31,3 +31,4 @@ Cleopatra/SimTransfer_single
Cleopatra/Cleopatra Cleopatra/Cleopatra
__pycache__ __pycache__
*.DS_Store

View File

@ -27,13 +27,14 @@
* ********************************************************************/ * ********************************************************************/
#include <fstream> #include <fstream>
#include <stdlib.h> /* atof */
#include <cmath> #include <cmath>
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <cstdlib>
#include <sstream>
#include <TROOT.h> #include <TROOT.h>
#include <TFile.h> #include <TFile.h>
#include <TString.h> #include <TString.h>
@ -42,8 +43,6 @@
#include <TApplication.h> #include <TApplication.h>
#include "PlotTGraphTObjArray.h" #include "PlotTGraphTObjArray.h"
using namespace std;
int main (int argc, char *argv[]) { //TODO add angle range int main (int argc, char *argv[]) { //TODO add angle range
printf("=================================================================\n"); printf("=================================================================\n");
@ -60,7 +59,7 @@ int main (int argc, char *argv[]) { //TODO add angle range
} }
//================= read infile. extract the reactions, write pptolemy infile for each reaction //================= read infile. extract the reactions, write pptolemy infile for each reaction
string readFile = argv[1]; std::string readFile = argv[1];
double angMin = 0.; double angMin = 0.;
double angMax = 180.; double angMax = 180.;
double angStep = 1.; double angStep = 1.;
@ -72,19 +71,25 @@ int main (int argc, char *argv[]) { //TODO add angle range
angStep = atof(argv[4]); angStep = atof(argv[4]);
} }
string ptolemyInFileName = argv[1]; std::string ptolemyInFileName = argv[1];
ptolemyInFileName += ".in"; ptolemyInFileName += ".in";
printf("=================== Create InFile\n"); printf("=================== Create InFile\n");
InFileCreator( readFile, ptolemyInFileName, angMin, angMax, angStep); InFileCreator( readFile, ptolemyInFileName, angMin, angMax, angStep);
//================= run ptolemy //================= run ptolemy
char command[200]; std::string ptolemyOutFileName = ptolemyInFileName + ".out";
string ptolemyOutFileName = argv[1]; std::ostringstream commandStream;
ptolemyOutFileName += ".out"; commandStream << "../Cleopatra/ptolemy <" << ptolemyInFileName << " " << ptolemyOutFileName;
sprintf(command, "../Cleopatra/ptolemy <%s> %s", ptolemyInFileName.c_str(), ptolemyOutFileName.c_str()); std::string command = commandStream.str();
printf("=================== Run Ptolemy\n"); printf("=================== Run Ptolemy\n");
printf("%s \n", command); printf("%s \n", command.c_str());
system(command);
int result = std::system(command.c_str());
if (result == -1) {
std::cerr << "Error executing system command." << std::endl;
return 1;
}
//================= extract the Xsec and save as txt and root //================= extract the Xsec and save as txt and root
printf("=================== Extract Cross-section\n"); printf("=================== Extract Cross-section\n");
@ -92,7 +97,7 @@ int main (int argc, char *argv[]) { //TODO add angle range
//================= Call root to plot the d.s.c. //================= Call root to plot the d.s.c.
printf("=================== Plot Result using ROOT.\n"); printf("=================== Plot Result using ROOT.\n");
string rootFileName = argv[1]; std::string rootFileName = argv[1];
rootFileName += ".root"; rootFileName += ".root";
TApplication app ("app", &argc, argv); TApplication app ("app", &argc, argv);
PlotTGraphTObjArray(rootFileName); PlotTGraphTObjArray(rootFileName);