Skip to content
Snippets Groups Projects
Commit 4096befc authored by matta's avatar matta
Browse files

* When running an Analysis, Calibration are now saved in a TAsciiFile in the RootOutput

parent 639d6e22
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,8 @@
* *
*****************************************************************************/
#include "CalibrationManager.h"
#include "TAsciiFile.h"
#include "RootOutput.h"
// STL
#include <cstdlib>
......@@ -106,6 +108,10 @@ void CalibrationManager::LoadParameterFromFile()
string DataBuffer ;
string LineBuffer ;
// Get pointer to the TAsciifile CalibrationFile in RootOuput
TAsciiFile* AcsiiCalibration = RootOutput::getInstance()->GetAsciiFileCalibration();
for(unsigned int i = 0 ; i < fFileList.size() ; i++)
{
CalibFile.open( fFileList[i].c_str() );
......@@ -118,40 +124,52 @@ void CalibrationManager::LoadParameterFromFile()
cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl ;
}
else while( !CalibFile.eof() )
{
// Read the file Line by line
getline(CalibFile, LineBuffer);
else
{
// Append the Calibration File to the RootOuput for Back-up
string comment = "%%% From File " + fFileList[i] + "%%%";
AcsiiCalibration->AppendLine(comment.c_str());
AcsiiCalibration->Append(fFileList[i].c_str());
while( !CalibFile.eof() )
{
// Read the file Line by line
getline(CalibFile, LineBuffer);
// Create a istringstream to manipulate the line easely
istringstream theLine (LineBuffer,istringstream::in);
theLine >> DataBuffer ;
// Create a istringstream to manipulate the line easely
istringstream theLine (LineBuffer,istringstream::in);
theLine >> DataBuffer ;
// Comment support, comment symbole is %
if(DataBuffer.compare(0, 1, "%") == 0) {
CalibFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );}
// Search word in the token list
it=fToken.find(DataBuffer);
// Comment support, comment symbole is %
if(DataBuffer.compare(0, 1, "%") == 0) {
CalibFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );}
// Search word in the token list
it=fToken.find(DataBuffer);
// if the word is find, values are read
if( it!=fToken.end() )
{
vector<double> Coeff ;
while( !theLine.eof() )
{
theLine >> DataBuffer ; Coeff.push_back( atof(DataBuffer.c_str()) ) ;
}
// if the word is find, values are read
if( it!=fToken.end() )
{
vector<double> Coeff ;
while( !theLine.eof() )
{
theLine >> DataBuffer ; Coeff.push_back( atof(DataBuffer.c_str()) ) ;
}
// Check this parameter is not already define
if( fCalibrationCoeff.find(it->second) != fCalibrationCoeff.end() )
cout << "WARNING: Parameter " << it->second << " Already found. It will be rewritted " << endl;
// Check this parameter is not already define
if( fCalibrationCoeff.find(it->second) != fCalibrationCoeff.end() )
cout << "WARNING: Parameter " << it->second << " Already found. It will be rewritted " << endl;
// Add the list of Coeff to the Coeff map using Parameter Path as index
fCalibrationCoeff[ it->second ] = Coeff ;
}
// Add the list of Coeff to the Coeff map using Parameter Path as index
fCalibrationCoeff[ it->second ] = Coeff ;
}
}
}
}
CalibFile.close() ;
}
}
......
......@@ -25,6 +25,7 @@
#include <limits>
#include <sys/stat.h>
#include <stdlib.h>
#include "RootInput.h"
#include "TAsciiFile.h"
......
......@@ -100,6 +100,10 @@ void RootOutput::InitAsciiFiles()
// Calibration files
pCalibrationFile = new TAsciiFile();
if (!OptionManager->IsDefault("Calibration")) {
TString fileNameCal = OptionManager->GetCalibrationFile();
pCalibrationFile->SetNameTitle("Calibration", fileNameCal.Data());
}
}
......
......@@ -44,7 +44,7 @@ NPOptionManager::NPOptionManager(int argc, char** argv)
fDefaultDetectorFileName = "defaultDetector.detector";
fDefaultOutputFileName = "myResult.root";
fDefaultRunToReadFileName = "defaultRunToTreat.txt";
fDefaultCalibrationFileName = "Calibration.txt";
fDefaultCalibrationFileName = "defaultCalibration.txt";
// Assigned values
fReactionFileName = fDefaultReactionFileName;
fDetectorFileName = fDefaultDetectorFileName;
......
......@@ -77,6 +77,13 @@ void TAsciiFile::Append(const char* inputAsciiFile)
}
void TAsciiFile::AppendLine(const char* AsciiLine)
{
string line = AsciiLine ;
fLines.push_back(line);
}
void TAsciiFile::WriteToFile(const char* outputAsciiFile) const
{
......
......@@ -44,6 +44,7 @@ class TAsciiFile : public TNamed {
virtual ~TAsciiFile();
void Append(const char* inputAsciiFile);
void AppendLine(const char* AsciiLine);
void WriteToFile(const char* outputAsciiFile) const;
void WriteToFile(const char* outputAsciiFile, UInt_t begin, UInt_t end) const;
void Print(const Option_t*) const {};
......
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