Skip to content
Snippets Groups Projects
Commit 30cdbbe6 authored by matta's avatar matta
Browse files

* Modifing code of the Reaction and Detector Manager so you can also put...

* Modifing code of the Reaction and Detector Manager so you can also put absolute or relative path to the different file
 - Still support the use of environment path
 - Transparent for user, the two way are equivalent
parent 716512bd
No related branches found
No related tags found
No related merge requests found
......@@ -4,28 +4,16 @@ using namespace std;
int main(int argc,char** argv)
{
// if(argc!=4)
// {
// cout <<
// "you need to specify both a Reaction file and a Detector file such as : Analysis myReaction.reaction myDetector.detector runToRead.run"
// << endl;
// return 0;
// }
//
// string detectorfileName = argv[1] ;
// string calibrationfileName = argv[2] ;
// string runToReadfileName = argv[3] ;
NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv);
string detectorfileName = myOptionManager->GetDetectorFilePath() ;
string calibrationfileName = myOptionManager->GetCalibrationFilePath() ;
string runToReadfileName = myOptionManager->GetRunToReadFilePath() ;
NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv) ;
string detectorfileName = myOptionManager->GetDetectorFilePath() ;
string calibrationfileName = myOptionManager->GetCalibrationFilePath() ;
string runToReadfileName = myOptionManager->GetRunToReadFilePath() ;
// First of All instantiate RootInput and Output
// Detector will be attached later
RootInput:: getInstance(runToReadfileName) ;
RootOutput::getInstance("Analysis/10HeRiken_AnalyzedData", "AnalyzedTree") ;
RootOutput::getInstance("Analysis/10HeRiken_AnalyzedData", "AnalyzedTree") ;
// Instantiate some Reaction
NPL::Reaction* He10Reaction = new Reaction ;
......
......@@ -92,12 +92,20 @@ void Reaction::SetEveryThing(string name1, string name2, string name3, string na
///Read the differential cross section
string GlobalPath = getenv("NPTOOL");
Path = GlobalPath + "/Inputs/CrossSection/" + Path;
string StandardPath = GlobalPath + "/Inputs/CrossSection/" + Path;
ifstream CSFile;
CSFile.open( Path.c_str() );
CSFile.open( StandardPath.c_str() );
if(CSFile.is_open()) { cout << "Reading Cross Section File " << Path << endl;}
else {cout << "Cross Section File " << Path << " not found" << endl;return;}
if(CSFile.is_open()) cout << "Reading Cross Section File " << Path << endl;
// In case the file is not found in the standard path, the programm try to interpret the file name as an absolute or relative file path.
else
{
CSFile.open( Path.c_str() );
if(CSFile.is_open()) { cout << "Reading Cross Section File " << Path << endl;}
else {cout << "Cross Section File " << Path << " not found" << endl;return;}
}
double CSBuffer,AngleBuffer;
vector<double> CrossSectionBuffer ;
......@@ -262,15 +270,19 @@ void Reaction::ReadConfigurationFile(string Path)
//////////////////////////////////////////////////////////////////////////////////////////
ifstream ReactionFile;
string GlobalPath = getenv("NPTOOL");
Path = GlobalPath + "/Inputs/EventGenerator/" + Path;
ReactionFile.open(Path.c_str());
string StandardPath = GlobalPath + "/Inputs/EventGenerator/" + Path;
ReactionFile.open(StandardPath.c_str());
if (ReactionFile.is_open()) {cout << "Reading Reaction File " << Path << endl ;}
else
{
cout << "Reaction File " << Path << " not Found! " << endl ;
return;
}
// In case the file is not found in the standard path, the programm try to interpret the file name as an absolute or relative file path.
else
{
ReactionFile.open( Path.c_str() );
if(ReactionFile.is_open()) { cout << "Reading Reaction File " << Path << endl;}
else {cout << "Reaction File " << Path << " not found" << endl;return;}
}
while (!ReactionFile.eof()) {
//Pick-up next line
......
......@@ -49,18 +49,27 @@ void DetectorManager::ReadConfigurationFile(string Path)
//////////////////////////////////////////////////////////////////////////////////////////
string GlobalPath = getenv("NPTOOL");
Path = GlobalPath + "/Inputs/DetectorConfiguration/" + Path;
string StandardPath = GlobalPath + "/Inputs/DetectorConfiguration/" + Path;
ifstream ConfigFile;
ConfigFile.open(Path.c_str());
ConfigFile.open(StandardPath.c_str());
if (ConfigFile.is_open()) {
if (ConfigFile.is_open())
{
cout << "/////////////////////////////" << endl;
cout << " Configuration file " << Path << " loading " << endl;
}
else {
cout << " Error, no configuration file" << Path << " found" << endl;
return;
}
Path = StandardPath;
}
else
{
ConfigFile.open( Path.c_str() );
if(ConfigFile.is_open()) {
cout << "/////////////////////////////" << endl;
cout << " Configuration file " << Path << " loading " << endl;
}
else {cout << "Configuration File " << Path << " not found" << endl;return;}
}
while (!ConfigFile.eof()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment