Skip to content
Snippets Groups Projects
Commit 8c481ab0 authored by Greg's avatar Greg
Browse files

Merge branch 'NPTool.2.dev' of https://github.com/adrien-matta/nptool into NPTool.2.dev

parents 8a386634 447d45b1
Branches
No related tags found
No related merge requests found
Showing
with 609 additions and 370 deletions
File added
void EnergyLoss();
void Reaction();
TCanvas* c = new TCanvas("PhysicsBench","Physics Benchmark ",1000,500);
TCanvas* c = new TCanvas("PhysicsBench","Physics Benchmark ",1500,500);
////////////////////////////////////////////////////////////////////////////////
void physics(){
c->Divide(2,1);
c->Divide(3,1);
EnergyLoss();
Reaction();
}
......@@ -31,23 +31,51 @@ void EnergyLoss(){
}
////////////////////////////////////////////////////////////////////////////////
void Reaction() {
unsigned int cycles = 10000;
// test Random Ex generation
NPL::Reaction r2;
r2.ReadConfigurationFile("test.reaction");
TH1F* h2 = new TH1F("hE2","hE2",1000,-1,1);
double E4,T4,E3,T3,Ex,E;
r2.ShootRandomExcitationEnergy();
clock_t begin = clock();
for (unsigned int i = 0 ; i < cycles ; i++){
r2.ShootRandomExcitationEnergy();
Ex = r2.GetExcitation4();
r2.SetThetaCM(i*deg*180./cycles);
r2.KineRelativistic(T3,E3,T4,E4);
E = r2.ReconstructRelativistic(E3,T3)-Ex;
h2->Fill(E/eV);
}
clock_t end = clock();
double time = end-begin;
time = time/CLOCKS_PER_SEC;
cout << " ***** Reaction performance : " << cycles/time/1000. << " cycles per ms *****" << endl;
c->cd(3);
h2->Draw("");
h2->GetXaxis()->SetTitle("Excitation error on Generated/Reconstructed cycle (eV)");
// On fly declaration
cout << " Reaction declaration without input file / no Ex distribution" << endl;
NPL::Reaction r("28Si(d,p)29Si@280");
double E4,T4,E3,T3;
TH1F* h = new TH1F("hE","hE",1000,-1,1);
clock_t begin = clock();
for (unsigned int i = 0 ; i < 10000 ; i++){
r.SetThetaCM(i*deg*180./10000);
begin = clock();
for (unsigned int i = 0 ; i < cycles ; i++){
r.SetExcitation4(0);
Ex = r2.GetExcitation4();
r.SetThetaCM(i*deg*180./cycles);
r.KineRelativistic(T3,E3,T4,E4);
double E = r.ReconstructRelativistic(E3,T3);
E = r.ReconstructRelativistic(E3,T3);
h->Fill(E/eV);
}
clock_t end = clock();
double time = end-begin;
end = clock();
time = end-begin;
time = time/CLOCKS_PER_SEC;
cout << " ***** Reaction performance : 10000 cycle done in " << time*1000 << "ms *****" << endl;
cout << " ***** Reaction performance :" << cycles/time/1000. << " cycles per ms *****" << endl;
c->cd(2);
h->Draw("");
h->GetXaxis()->SetTitle("Excitation error on Generated/Reconstructed cycle (eV)");
}
......@@ -6,9 +6,9 @@
*****************************************************************************/
/*****************************************************************************
* Original Author: Adrien MATTA contact address: a.matta@surrey.ac.uk *
* Original Author: Adrien MATTA contact address: matta@lpccaen.in2p3.fr *
* *
* Creation Date : march 2025 *
* Creation Date : march 2015 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
......@@ -30,15 +30,17 @@ using namespace std;
////////////////////////////////////////////////////////////////////////////////
Analysis::Analysis(){
}
////////////////////////////////////////////////////////////////////////////////
Analysis::~Analysis(){
}
////////////////////////////////////////////////////////////////////////////////
void Analysis::Init(){
M2= (TMust2Physics*) m_DetectorManager->GetDetector("M2Telescope");
SSSD= (TSSSDPhysics*) m_DetectorManager->GetDetector("SSSD");
Initial=new TInitialConditions();
M2 = (TMust2Physics*) m_DetectorManager->GetDetector("M2Telescope");
SSSD = (TSSSDPhysics*) m_DetectorManager->GetDetector("SSSD");
Initial = new TInitialConditions();
ReactionConditions = new TReactionConditions();
InitOutputBranch();
InitInputBranch();
Rand = TRandom3();
......@@ -57,31 +59,50 @@ void Analysis::Init(){
E_M2 = 0;
Si_X_M2 = 0;
Si_Y_M2 = 0;
ZTarget = 0;
TargetThickness = m_DetectorManager->GetTargetThickness();
// Energy loss table: the G4Table are generated by the simulation
He3CD2 = EnergyLoss("Example/He3_CD2.G4table","G4Table",100 );
He3Al = EnergyLoss("Example/He3_Al.G4table","G4Table",10);
He3Si = EnergyLoss("Example/He3_Si.G4table","G4Table",10);
//Li11CD2 = EnergyLoss("ExampleLi11_CD2.G4table","G4Table",100);
He3CD2 = EnergyLoss("Example/He3_CD2.G4table","G4Table",100 );
He3Al = EnergyLoss("Example/He3_Al.G4table","G4Table",10);
He3Si = EnergyLoss("Example/He3_Si.G4table","G4Table",10);
Li11CD2 = EnergyLoss("Example/Li11_CD2.G4table","G4Table",100);
}
////////////////////////////////////////////////////////////////////////////////
void Analysis::TreatEvent(){
// Reinitiate calculated variable
ReInitValue();
// Get the Original condition for the record
OriginalELab = ReactionConditions->GetKineticEnergy(0);
OriginalThetaLab = ReactionConditions->GetTheta(0);
OriginalBeamEnergy = ReactionConditions->GetBeamEnergy();
// Get the Init information on beam position and energy
// and apply by hand the experimental resolution
// This is because the beam diagnosis are not simulated
// PPAC position resolution on target is assumed to be 1mm
double XTarget = Rand.Gaus(Initial->GetIncidentPositionX(),1);
double YTarget = Rand.Gaus(Initial->GetIncidentPositionY(),1);
double XTarget = Initial->GetIncidentPositionX();
double YTarget = Initial->GetIncidentPositionY();
double ZTarget = Initial->GetIncidentPositionZ();
// Get the beam direction and position at entrance of the world
TVector3 BeamDirection = Initial->GetBeamDirection();
// Beam energy is measured using F3 and F2 plastic TOF
double BeamEnergy = Rand.Gaus(Initial->GetIncidentInitialKineticEnergy(),4.5);
//BeamEnergy = Li11CD2.Slow(BeamEnergy,TargetThickness/2.,0);
TVector3 BeamPosition(XTarget,YTarget,ZTarget);
// Get the Beam position on Target
BeamPosition+=abs(ZTarget)*BeamDirection;
// Randomize beam position on target to simulate PPAC response
BeamPosition.SetX(Rand.Gaus(BeamPosition.X(),1));
BeamPosition.SetY(Rand.Gaus(BeamPosition.Y(),1));
BeamPosition.SetZ(0);
XTarget = BeamPosition.X();
YTarget = BeamPosition.Y();
ZTarget = 0;
// Beam energy is measured using F3 and F2 plastic TOF with 4.5 MeV Resolution
BeamEnergy = Rand.Gaus(Initial->GetIncidentInitialKineticEnergy(),4.5);
BeamEnergy = Li11CD2.Slow(BeamEnergy,TargetThickness*0.5,0);
He10Reaction->SetBeamEnergy(BeamEnergy);
//////////////////////////// LOOP on MUST2 + SSSD Hit //////////////////
for(unsigned int countSSSD = 0 ; countSSSD < SSSD->Energy.size() ; countSSSD++){
for(unsigned int countMust2 = 0 ; countMust2 < M2->Si_E.size() ; countMust2++){
......@@ -127,7 +148,7 @@ void Analysis::TreatEvent(){
/************************************************/
// Part 2 : Impact Energy
Energy = ELab = 0;
Energy = ELab = E_M2 = 0;
Si_E_M2 = M2->Si_E[countMust2];
CsI_E_M2= M2->CsI_E[countMust2];
E_SSSD = SSSD->Energy[countSSSD];
......@@ -135,7 +156,6 @@ void Analysis::TreatEvent(){
// if CsI
if(CsI_E_M2>0 ){
// The energy in CsI is calculate form dE/dx Table because
// 20um resolution is poor
Energy =
He3Si.EvaluateEnergyFromDeltaE(Si_E_M2,300*micrometer,
ThetaM2Surface, 0.01*MeV,
......@@ -149,11 +169,11 @@ void Analysis::TreatEvent(){
E_M2 += Si_E_M2;
// Evaluate energy using the thickness
ELab = He3Al.EvaluateInitialEnergy( Energy ,2*0.4*micrometer , ThetaM2Surface);
ELab = He3Si.EvaluateInitialEnergy( ELab ,20*micrometer , ThetaM2Surface);
ELab = He3Al.EvaluateInitialEnergy( ELab ,0.4*micrometer , ThetaM2Surface);
ELab = He3Al.EvaluateInitialEnergy( Energy , 2*0.4*micrometer , ThetaM2Surface);
ELab = He3Si.EvaluateInitialEnergy( ELab , 20*micrometer , ThetaM2Surface);
ELab = He3Al.EvaluateInitialEnergy( ELab , 0.4*micrometer , ThetaM2Surface);
// Target Correction
ELab = He3CD2.EvaluateInitialEnergy( ELab ,TargetThickness/2., ThetaNormalTarget);
ELab = He3CD2.EvaluateInitialEnergy( ELab ,TargetThickness*0.5, ThetaNormalTarget);
/************************************************/
/************************************************/
......@@ -183,6 +203,10 @@ void Analysis::InitOutputBranch() {
RootOutput::getInstance()->GetTree()->Branch("ELab",&ELab,"ELab/D");
RootOutput::getInstance()->GetTree()->Branch("ThetaLab",&ThetaLab,"ThetaLab/D");
RootOutput::getInstance()->GetTree()->Branch("ThetaCM",&ThetaCM,"ThetaCM/D");
RootOutput::getInstance()->GetTree()->Branch("BeamEnergy",&BeamEnergy,"BeamEnergy/D");
RootOutput::getInstance()->GetTree()->Branch("OriginalELab",&OriginalELab,"OriginalELab/D");
RootOutput::getInstance()->GetTree()->Branch("OriginalThetaLab",&OriginalThetaLab,"OriginalThetaLab/D");
RootOutput::getInstance()->GetTree()->Branch("OriginalBeamEnergy",&OriginalBeamEnergy,"OriginalBeamEnergy/D");
}
////////////////////////////////////////////////////////////////////////////////
......@@ -190,6 +214,9 @@ void Analysis::InitInputBranch(){
RootInput:: getInstance()->GetChain()->SetBranchStatus("InitialConditions",true );
RootInput:: getInstance()->GetChain()->SetBranchStatus("fIC_*",true );
RootInput:: getInstance()->GetChain()->SetBranchAddress("InitialConditions",&Initial);
RootInput:: getInstance()->GetChain()->SetBranchStatus("ReactionConditions",true );
RootInput:: getInstance()->GetChain()->SetBranchStatus("fRC_*",true );
RootInput:: getInstance()->GetChain()->SetBranchAddress("ReactionConditions",&ReactionConditions);
}
////////////////////////////////////////////////////////////////////////////////
......@@ -197,7 +224,11 @@ void Analysis::ReInitValue(){
Ex = -1000 ;
ELab = -1000;
ThetaLab = -1000;
BeamEnergy = -1000;
ThetaCM = -1000;
OriginalELab = -1000;
OriginalThetaLab = -1000;
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -8,9 +8,9 @@
*****************************************************************************/
/*****************************************************************************
* Original Author: Adrien MATTA contact address: a.matta@surrey.ac.uk *
* Original Author: Adrien MATTA contact address: matta@lpccaen.in2p3.fr *
* *
* Creation Date : march 2025 *
* Creation Date : march 2015 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
......@@ -21,13 +21,16 @@
* *
* *
*****************************************************************************/
#include"NPVAnalysis.h"
#include "NPVAnalysis.h"
#include "TMust2Physics.h"
#include "TSSSDPhysics.h"
#include "TInitialConditions.h"
#include "TReactionConditions.h"
#include "NPEnergyLoss.h"
#include "NPReaction.h"
#include "TRandom3.h"
#include"NPDetectorManager.h"
class Analysis: public NPL::VAnalysis{
public:
Analysis();
......@@ -47,6 +50,10 @@ class Analysis: public NPL::VAnalysis{
double ELab;
double ThetaLab;
double ThetaCM;
double BeamEnergy;
double OriginalELab;
double OriginalThetaLab;
double OriginalBeamEnergy;
NPL::Reaction* He10Reaction;
// intermediate variable
......@@ -64,7 +71,6 @@ class Analysis: public NPL::VAnalysis{
double E_M2 ;
double Si_X_M2;
double Si_Y_M2;
double ZTarget;
double TargetThickness;
NPL::EnergyLoss He3CD2 ;
......@@ -75,5 +81,6 @@ class Analysis: public NPL::VAnalysis{
TMust2Physics* M2;
TSSSDPhysics* SSSD;
TInitialConditions* Initial;
TReactionConditions* ReactionConditions;
};
#endif
......@@ -3,7 +3,6 @@
TCutG* ETOF=NULL;
TCutG* EDE=NULL;
TChain* chain=NULL ;
TCanvas* c1 = NULL;
////////////////////////////////////////////////////////////////////////////////
void LoadCuts(){
......@@ -25,23 +24,25 @@ void ShowResults(){
LoadChain();
LoadCuts();
c1 = new TCanvas("Example1","Example1",0,0,600,600);
TCanvas* c1 = new TCanvas("Detected","Detected",0,0,600,600);
c1->Divide(2,2);
// Light Particle ID //
// E-DE
c1->cd(1);
chain->Draw("SSSD.Energy:MUST2.Si_E>>hIDE(1000,0,35,1000,0,5)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5","colz");
EDE->Draw("same");
// E-TOF
c1->cd(2);
chain->Draw("-MUST2.Si_T:SSSD.Energy+MUST2.Si_E>>hIDT(1000,0,35,1000,-15,0)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5","colz");
chain->Draw("-MUST2.Si_T:SSSD.Energy+MUST2.Si_E>>hIDT(1000,0,35,1000,-30,0)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5","colz");
ETOF->Draw("same");
// Kinematical Line //
c1->cd(3);
//chain->Draw("ELab:ThetaLab>>hKine(500,0,45,400,0,40)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5 && EDE && ETOF","colz");
chain->Draw("ELab:ThetaLab>>h(1000,0,90,1000,0,30)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5 && EDE && ETOF","colz");
NPL::Reaction r("11Li(d,3He)10He@553");
......@@ -72,4 +73,25 @@ void ShowResults(){
f->SetLineColor(kOrange-3);
f->SetNpx(1000);
TCanvas* c2 = new TCanvas("Simulated","Simulated",600,0,600,600);
c2->Divide(2,2);
c2->cd(1);
chain->Draw("OriginalELab:OriginalThetaLab>>hS(1000,0,90,1000,0,30)","","col");
Kine->Draw("c");
c2->cd(2);
chain->Draw("OriginalELab:ELab>>hS2(1000,0,30,1000,0,30)","ELab>0","col");
TLine* lE = new TLine(0,0,30,30);
lE->Draw();
c2->cd(3);
chain->Draw("OriginalThetaLab:ThetaLab>>hS3(1000,0,90,1000,0,90)","ThetaLab>0","col");
TLine* lT = new TLine(0,0,90,90);
lT->Draw();
c2->cd(4);
chain->Draw("OriginalBeamEnergy:BeamEnergy>>hS4(1000,500,600,1000,500,600)","BeamEnergy>0","col");
TLine* lB = new TLine(500,500,600,600);
lB->Draw();
}
No preview for this file type
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Target
THICKNESS= 18 micrometer
RADIUS= 30 mm
MATERIAL= CD2
ANGLE= 0 deg
Thickness= 18 micrometer
Radius= 30 mm
Material= CD2
Angle= 0 deg
X= 0 mm
Y= 0 mm
Z= 0 mm
......
......@@ -2,7 +2,7 @@
%%%%%%%%% Reaction file for 11Li(d,3He)10He reaction %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Beam
Particle= 11Li
Particle= 10He
Energy= 553
SigmaEnergy= 20
SigmaThetaX= 0.6138
......
......@@ -30,9 +30,12 @@ TwoBodyReaction
ShootHeavy= 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%ParticleDecay 10He
% Daughter= 8He n n
% ExcitationEnergy= 0 0 0 MeV
% shoot= 1 1 1
Decay 10He
Daughter= 8He n n
ExcitationEnergy= 0 0 0 MeV
Threshold= 0 MeV
BranchingRatio= 0.5
LifeTime= 0 ns
Shoot= 1 1 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......@@ -4,13 +4,13 @@
% Energy are given in MeV , Position in mm %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Isotropic
EnergyLow= 5.5 MeV
EnergyHigh= 5.5 MeV
EnergyLow= 3.5 MeV
EnergyHigh= 3.5 MeV
HalfOpenAngleMin= 0 deg
HalfOpenAngleMax= 90 deg
HalfOpenAngleMax= 180 deg
x0= 0 mm
y0= 0 mm
z0= -110 mm
z0= 0 mm
Particle= alpha
ExcitationEnergy= 0 MeV
......
......@@ -2,7 +2,6 @@ cmake_minimum_required (VERSION 2.8)
include(CheckCXXCompilerFlag)
project(NPLib CXX)
set(CMAKE_BUILD_TYPE Release)
# Setting the policy to match Cmake version
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
......@@ -19,6 +18,23 @@ set(NPLIB_VERSION_DETA 45)
configure_file(Core/NPLibVersion.h.in Core/NPLibVersion.h @ONLY)
set(DETLIST ${ETLIST})
#activate Multithreading (on by default)
if(NOT DEFINED NPMULTITHREADING)
set(NPMULTITHREADING 1)
else()
set(NPMULTITHREADING ${NPMULTITHREADING})
endif()
if(NPMULTITHREADING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNPMULTITHREADING=1")
message("Building application with MultiThreading Support")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNPMULTITHREADING=0")
message("Building application with no MutilThreading Support")
endif()
string(COMPARE EQUAL "${DETLIST}" "" rdet)
if(rdet)
message("Building all detectors")
......
......@@ -13,4 +13,13 @@ Canvas
Histo= MM@Telescope_STRX_RAW_MULT MM@Telescope_STRY_RAW_MULT
Canvas
Path= test
Divide= 2 2
Histo= h1 h2
Canvas
Path= pipo
Divide= 2 2
Histo= h2 h1
......@@ -33,7 +33,7 @@
//////////////////////////////////////////////////////////////////
CalibrationManager* CalibrationManager::instance = 0;
CalibrationManager* CalibrationManager::getInstance(const string& configFileName){
CalibrationManager* CalibrationManager::getInstance(const std::string& configFileName){
// A new instance of CalibrationManager is created if it does not exist:
if (instance == 0) {
instance = new CalibrationManager(configFileName);
......@@ -44,28 +44,28 @@ CalibrationManager* CalibrationManager::getInstance(const string& configFileName
}
//////////////////////////////////////////////////////////////////
CalibrationManager::CalibrationManager(string configFileName){
CalibrationManager::CalibrationManager(std::string configFileName){
// Read configuration file Buffer
string lineBuffer, dataBuffer;
std::string lineBuffer, dataBuffer;
// Open file
ifstream inputConfigFile;
std::ifstream inputConfigFile;
inputConfigFile.open(configFileName.c_str());
if(!NPOptionManager::getInstance()->IsDefault("Calibration")){
cout << endl;
cout << "/////////// Calibration Information ///////////" << endl;
cout << "Getting list of calibration files" << endl;
std::cout << std::endl;
std::cout << "/////////// Calibration Information ///////////" << std::endl;
std::cout << "Getting list of calibration files" << std::endl;
}
if (!inputConfigFile) {
if(!NPOptionManager::getInstance()->IsDefault("Calibration"))
cout << "Calibration Path file: " << configFileName << " not found" << endl;
std::cout << "Calibration Path file: " << configFileName << " not found" << std::endl;
return;
}
else {
cout << "Reading list of files from: " << configFileName << endl;
std::cout << "Reading list of files from: " << configFileName << std::endl;
while (!inputConfigFile.eof()) {
getline(inputConfigFile, lineBuffer);
......@@ -81,13 +81,13 @@ CalibrationManager::CalibrationManager(string configFileName){
else if (!inputConfigFile.eof()) {
AddFile(dataBuffer);
cout << "Adding file " << dataBuffer << " to Calibration" << endl;
std::cout << "Adding file " << dataBuffer << " to Calibration" << std::endl;
}
}
}
}
}
cout << "/////////////////////////////////" << endl;
std::cout << "/////////////////////////////////" << std::endl;
}
//////////////////////////////////////////////////////////////////
......@@ -95,8 +95,8 @@ CalibrationManager::~CalibrationManager()
{}
//////////////////////////////////////////////////////////////////
bool CalibrationManager::AddParameter(string DetectorName , string ParameterName , string Token ){
string ParameterPath = DetectorName + "/" + ParameterName ;
bool CalibrationManager::AddParameter(std::string DetectorName , std::string ParameterName , std::string Token ){
std::string ParameterPath = DetectorName + "/" + ParameterName ;
fToken[Token] = ParameterPath ;
return true;
}
......@@ -107,16 +107,16 @@ void CalibrationManager::ClearCalibration(){
}
/////////////////////////////////////////////////////////////////
vector<double> CalibrationManager::GetCorrection(const string& ParameterPath) const {
vector<double> Coeff ;
map< string , vector<double> >::const_iterator it ;
std::vector<double> CalibrationManager::GetCorrection(const std::string& ParameterPath) const {
std::vector<double> Coeff ;
std::map< std::string , std::vector<double> >::const_iterator it ;
it = fCalibrationCoeff.find(ParameterPath) ;
if(it == fCalibrationCoeff.end() )
{
/* cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl ;
cout << " ERROR: PARAMETER " << ParameterPath << " IS NOT FOUND IN THE CALIBRATION DATA BASE " << endl ;
cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl ;*/
/* std::cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << std::endl ;
std::cout << " ERROR: PARAMETER " << ParameterPath << " IS NOT FOUND IN THE CALIBRATION DATA BASE " << std::endl ;
std::cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << std::endl ;*/
return Coeff ;
}
......@@ -129,9 +129,9 @@ vector<double> CalibrationManager::GetCorrection(const string& ParameterPath) co
//////////////////////////////////////////////////////////////////
void CalibrationManager::LoadParameterFromFile(){
ifstream CalibFile ;
string DataBuffer ;
string LineBuffer ;
std::ifstream CalibFile;
std::string DataBuffer;
std::string LineBuffer;
// Get pointer to the TAsciifile CalibrationFile in RootOuput
TAsciiFile* AcsiiCalibration = RootOutput::getInstance()->GetAsciiFileCalibration();
......@@ -140,17 +140,17 @@ void CalibrationManager::LoadParameterFromFile(){
unsigned int sizeF = fFileList.size();
for(unsigned int i = 0 ; i < sizeF ; i++){
CalibFile.open( fFileList[i].c_str() );
map<string,string>::iterator it ;
std::map<std::string,std::string>::iterator it ;
if(!CalibFile){
ostringstream message;
std::ostringstream message;
message << "file " << fFileList[i] << " is missing " ;
NPL::SendWarning ("NPL::CalibrationManager" , message.str());
}
else {
// Append the Calibration File to the RootOuput for Back-up
string comment = "%%% From File " + fFileList[i] + "%%%";
std::string comment = "%%% From File " + fFileList[i] + "%%%";
AcsiiCalibration->AppendLine(comment.c_str());
AcsiiCalibration->Append(fFileList[i].c_str());
......@@ -158,8 +158,8 @@ void CalibrationManager::LoadParameterFromFile(){
// Read the file Line by line
getline(CalibFile, LineBuffer);
// Create a istringstream to manipulate the line easely
istringstream theLine (LineBuffer,istringstream::in);
// Create a istd::stringstream to manipulate the line easely
std::istringstream theLine (LineBuffer,std::istringstream::in);
theLine >> DataBuffer ;
// Comment support, comment symbole is %
......@@ -170,16 +170,16 @@ void CalibrationManager::LoadParameterFromFile(){
it=fToken.find(DataBuffer);
// if the word is find, values are read
if( it!=fToken.end() ){
vector<double> Coeff ;
std::vector<double> Coeff ;
while( 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 overwritten. " << endl;
std::cout << "WARNING: Parameter " << it->second << " Already found. It will be overwritten. " << std::endl;
// Add the list of Coeff to the Coeff map using Parameter Path as index
// Add the list of Coeff to the Coeff std::map using Parameter Path as index
fCalibrationCoeff[ it->second ] = Coeff ;
}
}
......@@ -189,9 +189,9 @@ void CalibrationManager::LoadParameterFromFile(){
}
//////////////////////////////////////////////////////////////////
double CalibrationManager::ApplyCalibration(const string& ParameterPath , const double& RawValue) const {
map< string , vector<double> >::const_iterator it ;
static map< string , vector<double> >::const_iterator ite = fCalibrationCoeff.end();
double CalibrationManager::ApplyCalibration(const std::string& ParameterPath , const double& RawValue) const {
std::map< std::string , std::vector<double> >::const_iterator it ;
static std::map< std::string , std::vector<double> >::const_iterator ite = fCalibrationCoeff.end();
// Find the good parameter in the Map
// Using Find method of stl is the fastest way
......@@ -199,11 +199,11 @@ double CalibrationManager::ApplyCalibration(const string& ParameterPath , const
// If the find methods return the end iterator it's mean the parameter was not found
if(it == ite ){
//by Shuya 170222
//cout << ParameterPath << "!" << endl;
//std::cout << ParameterPath << "!" << std::endl;
return RawValue ;
}
// The vector size give the degree of calibration
// The std::vector size give the degree of calibration
// We just apply the coeff it->second and returned the calibrated value
double CalibratedValue = 0 ;
unsigned int mysize = it->second.size();
......@@ -215,9 +215,9 @@ double CalibrationManager::ApplyCalibration(const string& ParameterPath , const
}
//////////////////////////////////////////////////////////////////
double CalibrationManager::ApplyCalibrationDebug(const string& ParameterPath , const double& RawValue) const{
map< string , vector<double> >::const_iterator it ;
static map< string , vector<double> >::const_iterator ite = fCalibrationCoeff.end();
double CalibrationManager::ApplyCalibrationDebug(const std::string& ParameterPath , const double& RawValue) const{
std::map< std::string , std::vector<double> >::const_iterator it ;
static std::map< std::string , std::vector<double> >::const_iterator ite = fCalibrationCoeff.end();
// Find the good parameter in the Map
// Using Find method of stl is the fastest way
......@@ -225,30 +225,30 @@ double CalibrationManager::ApplyCalibrationDebug(const string& ParameterPath , c
// If the find methods return the end iterator it's mean the parameter was not found
if(it == ite ){
cout << " PARAMETER " << ParameterPath << " IS NOT FOUND IN THE CALIBRATION DATA BASE " << endl ;
std::cout << " PARAMETER " << ParameterPath << " IS NOT FOUND IN THE CALIBRATION DATA BASE " << std::endl ;
return RawValue ;
}
// Else we take the second part of the element (first is index, ie: parameter path)
// Second is the vector of Coeff
cout << it->first << " : raw = " << RawValue << " coeff = " ;
vector<double> Coeff = it->second ;
// Second is the std::vector of Coeff
std::cout << it->first << " : raw = " << RawValue << " coeff = " ;
std::vector<double> Coeff = it->second ;
// The vector size give the degree of calibration
// The std::vector size give the degree of calibration
// We just apply the coeff and returned the calibrated value
double CalibratedValue = 0 ;
for(unsigned int i = 0 ; i < Coeff.size() ; i++){
cout << Coeff[i] << " " ;
std::cout << Coeff[i] << " " ;
CalibratedValue += Coeff[i]*pow(RawValue, (double)i);
}
cout << "results = " << CalibratedValue << endl ;
std::cout << "results = " << CalibratedValue << std::endl ;
return CalibratedValue ;
}
////////////////////////////////////////////////////////////////////////////////
double CalibrationManager::ApplyResistivePositionCalibration(const string& ParameterPath , const double& DeltaRawValue) const{
map< string , vector<double> >::const_iterator it ;
static map< string , vector<double> >::const_iterator ite = fCalibrationCoeff.end();
double CalibrationManager::ApplyResistivePositionCalibration(const std::string& ParameterPath , const double& DeltaRawValue) const{
std::map< std::string , std::vector<double> >::const_iterator it ;
static std::map< std::string , std::vector<double> >::const_iterator ite = fCalibrationCoeff.end();
// Find the good parameter in the Map
// Using Find method of stl is the fastest way
......@@ -259,21 +259,19 @@ double CalibrationManager::ApplyResistivePositionCalibration(const string& Param
return DeltaRawValue ;
}
vector<double> Coeff = it->second ;
// Check that the number of coeff is ok
if(it->second.size()!=2)
return DeltaRawValue ;
double CalibratedValue = (DeltaRawValue-Coeff[0])/(Coeff[1]);
double CalibratedValue = (DeltaRawValue-it->second[0])/(it->second[1]);
return CalibratedValue ;
}
////////////////////////////////////////////////////////////////////////////////
double CalibrationManager::ApplyResistivePositionCalibrationDebug(const string& ParameterPath , const double& DeltaRawValue) const {
map< string , vector<double> >::const_iterator it ;
static map< string , vector<double> >::const_iterator ite = fCalibrationCoeff.end();
double CalibrationManager::ApplyResistivePositionCalibrationDebug(const std::string& ParameterPath , const double& DeltaRawValue) const {
std::map< std::string , std::vector<double> >::const_iterator it ;
static std::map< std::string , std::vector<double> >::const_iterator ite = fCalibrationCoeff.end();
// Find the good parameter in the Map
// Using Find method of stl is the fastest way
......@@ -281,30 +279,30 @@ double CalibrationManager::ApplyResistivePositionCalibrationDebug(const string&
// If the find methods return the end iterator it's mean the parameter was not found
if(it == ite ){
cout << " PARAMETER " << ParameterPath << " IS NOT FOUND IN THE CALIBRATION DATA BASE " << endl ;
std::cout << " PARAMETER " << ParameterPath << " IS NOT FOUND IN THE CALIBRATION DATA BASE " << std::endl ;
return DeltaRawValue ;
}
vector<double> Coeff = it->second ;
std::vector<double> Coeff = it->second ;
// Check that the number of coeff is ok
if(Coeff.size()!=2){
cout << " NUMBER OF COEFF " << Coeff.size() << " IS DIFFERENT THAN TWO " << endl ;
std::cout << " NUMBER OF COEFF " << Coeff.size() << " IS DIFFERENT THAN TWO " << std::endl ;
return DeltaRawValue ;
}
double CalibratedValue = (DeltaRawValue-Coeff[0])/(Coeff[1]);
cout << it->first << " : raw = " << DeltaRawValue << " coeff = " ;
cout << Coeff[0] << " " << Coeff[1] << endl ;
cout << "results = " << CalibratedValue << endl ;
std::cout << it->first << " : raw = " << DeltaRawValue << " coeff = " ;
std::cout << Coeff[0] << " " << Coeff[1] << std::endl ;
std::cout << "results = " << CalibratedValue << std::endl ;
return CalibratedValue ;
}
//////////////////////////////////////////////////////////////////
bool CalibrationManager::ApplyThreshold(const string& ParameterPath, const double& RawValue) const{
map< string , vector<double> >::const_iterator it ;
static map< string , vector<double> >::const_iterator ite = fCalibrationCoeff.end();
bool CalibrationManager::ApplyThreshold(const std::string& ParameterPath, const double& RawValue) const{
std::map< std::string , std::vector<double> >::const_iterator it ;
static std::map< std::string , std::vector<double> >::const_iterator ite = fCalibrationCoeff.end();
// Find the good parameter in the Map
// Using Find method of stl is the fastest way
......@@ -315,20 +313,16 @@ bool CalibrationManager::ApplyThreshold(const string& ParameterPath, const doubl
return false;
}
// Else we take the second part of the element (first is index, ie: parameter path)
// Second is the vector of Coeff
vector<double> Coeff = it->second ;
// The vector size give the degree of calibration
// The std::vector size give the degree of calibration
// We just apply the coeff and returned the calibrated value
double ThresholdValue = 0 ;
double ThresholdValue ;
if(Coeff.size()==2){ // CATS style
ThresholdValue = Coeff[0] + 3*Coeff[1];
if(it->second.size()==2){ // CATS style
ThresholdValue = it->second[0] + 3*it->second[1];
}
else{ // Standard Threshold
ThresholdValue = Coeff[0];
ThresholdValue = it->second[0];
}
......@@ -339,14 +333,14 @@ bool CalibrationManager::ApplyThreshold(const string& ParameterPath, const doubl
}
/////////////////////////////////////////////////////////////////////////////////////////////
double CalibrationManager::GetPedestal(const string& ParameterPath) const{
double CalibrationManager::GetPedestal(const std::string& ParameterPath) const{
return GetValue(ParameterPath,0);
}
/////////////////////////////////////////////////////////////////////////////////////////////
double CalibrationManager::GetValue(const string& ParameterPath,const unsigned int& order) const{
map< string , vector<double> >::const_iterator it ;
static map< string , vector<double> >::const_iterator ite = fCalibrationCoeff.end();
double CalibrationManager::GetValue(const std::string& ParameterPath,const unsigned int& order) const{
std::map< std::string , std::vector<double> >::const_iterator it ;
static std::map< std::string , std::vector<double> >::const_iterator ite = fCalibrationCoeff.end();
// Find the good parameter in the Map
// Using Find method of stl is the fastest way
......@@ -357,7 +351,7 @@ double CalibrationManager::GetValue(const string& ParameterPath,const unsigned i
return 0;
}
// The vector size give the degree of calibration
// The std::vector size give the degree of calibration
double Value = 0 ;
if(it->second.size()>order){
Value = it->second[order];
......
......@@ -28,44 +28,43 @@
#include<vector>
#include<map>
using namespace std ;
class CalibrationManager{
protected: // Constructor and Destructor are protected because the class is a singleton
CalibrationManager(string configFileName);
CalibrationManager(std::string configFileName);
~CalibrationManager();
public: // Accessor
// return a pointer to the calibration manager instance.
// if the instance does not exist it is created.
static CalibrationManager* getInstance(const string& configFileName="XXX");
static CalibrationManager* getInstance(const std::string& configFileName="XXX");
private: // the instance
// Hold a pointer on itself
static CalibrationManager* instance ;
public: // File Management
inline void AddFile(string Path) { fFileList.push_back(Path) ;} ;
inline void AddFile(std::string Path) { fFileList.push_back(Path) ;} ;
public: // Calibration Parameter Related
// call like : myCalibrationManager->AddParameter( "MUST2" ,"Telescope5_Si_X38_E", "T5_Si_X38_E" )
// return false if the token is not found in the file list
bool AddParameter(string DetectorName , string ParameterName , string Token) ;
bool AddParameter(std::string DetectorName , std::string ParameterName , std::string Token) ;
// call like : myCalibrationManager->ApplyCalibration( "MUST2/Telescope5_Si_X38_E" , RawEnergy )
// return the Calibrated value
double ApplyCalibration (const string& ParameterPath , const double& RawValue) const ;
double ApplyResistivePositionCalibration (const string& ParameterPath , const double& RawValue) const ;
double ApplyCalibration (const std::string& ParameterPath , const double& RawValue) const ;
double ApplyResistivePositionCalibration (const std::string& ParameterPath , const double& RawValue) const ;
// Same but with debug information outputs
double ApplyCalibrationDebug (const string& ParameterPath , const double& RawValue) const ;
double ApplyResistivePositionCalibrationDebug (const string& ParameterPath , const double& RawValue) const ;
double ApplyCalibrationDebug (const std::string& ParameterPath , const double& RawValue) const ;
double ApplyResistivePositionCalibrationDebug (const std::string& ParameterPath , const double& RawValue) const ;
bool ApplyThreshold (const string& ParameterPath, const double& RawValue) const ;
double GetPedestal (const string& ParameterPath) const ;
double GetValue (const string& ParameterPath,const unsigned int& order) const ;
bool ApplyThreshold (const std::string& ParameterPath, const double& RawValue) const ;
double GetPedestal (const std::string& ParameterPath) const ;
double GetValue (const std::string& ParameterPath,const unsigned int& order) const ;
public: // To be called after initialisation
// Loop over the file list and catch the file used for calibration
......@@ -74,18 +73,18 @@ class CalibrationManager{
public: //Clear calibration if we have some calibration files to read
void ClearCalibration();
public: //Get correction coefficient vector
vector<double> GetCorrection (const string& ParameterPath) const ;
public: //Get correction coefficient std::vector
std::vector<double> GetCorrection (const std::string& ParameterPath) const ;
private:
// This map hold a vector of the calibration coefficient. Index is the Parameter path, like "MUST2/Telescope5_Si_X38_E"
// This std::map hold a std::vector of the calibration coefficient. Index is the Parameter path, like "MUST2/Telescope5_Si_X38_E"
map< string , vector<double> > fCalibrationCoeff ;
std::map< std::string , std::vector<double> > fCalibrationCoeff ;
// Hold the path of all the registered file of coeff
vector<string> fFileList ;
std::vector<std::string> fFileList ;
// Hold The list of Token. Index is the Token, value the parameter path.
map< string , string > fToken ;
std::map< std::string , std::string > fToken ;
};
......
......@@ -21,6 +21,7 @@
*****************************************************************************/
#include "NPCore.h"
#include<iostream>
#include<string>
////////////////////////////////////////////////////////////////////////////////
void NPL::SendWarning(std::string Class, std::string Warning){
std::cerr << "\033[5;34m";
......@@ -44,3 +45,23 @@ void NPL::SendErrorAndExit(std::string Class , std::string Error){
std::cerr << std::endl;
exit(1);
}
////////////////////////////////////////////////////////////////////////////////
namespace NPL{
static std::string itoa_array[10000];
class itoa_proxy{
public:
itoa_proxy(){
char buffer[]="10000";
for(int i = 0 ; i < 10000 ; i++){
sprintf(buffer,"%d",i);
itoa_array[i] = buffer;
}
}
};
static itoa_proxy itoa_p ;
}
std::string NPL::itoa(const int& i){
return NPL::itoa_array[i];
}
......@@ -24,6 +24,7 @@
#include<string>
namespace NPL{
std::string itoa(const int&);
void SendWarning(std::string Class, std::string Warning);
void SendInformation(std::string Class, std::string Information);
void SendErrorAndExit(std::string Class,std::string Error);
......
......@@ -57,19 +57,19 @@ void NPL::DetectorFactory::ReadClassList(std::string FileList){
std::ifstream InFile(FileList.c_str());
if(!InFile.is_open()){
string error = "Detector Class List file " +FileList +" Not found";
std::string error = "Detector Class List file " +FileList +" Not found";
NPL::SendErrorAndExit("NPL::NPL::DetectorFactory",error);
exit(1);
}
string Token, LibName;
std::string Token, LibName;
while(InFile >> Token >> LibName)
m_TokenLib[Token] = LibName;
}
////////////////////////////////////////////////////////////////////////////////
void NPL::DetectorFactory::CreateClassList(std::string FileList){
ofstream outFile(FileList.c_str());
std::map<string,string>::iterator it;
std::ofstream outFile(FileList.c_str());
std::map<std::string,std::string>::iterator it;
for(it = m_TokenLib.begin();it!=m_TokenLib.end();it++){
outFile << it->first << " " << it->second << std::endl;
......
This diff is collapsed.
......@@ -29,17 +29,17 @@
// STL
#include <string>
#include <map>
#include <vector>
#include <iostream>
#if __cplusplus > 199711L
#include <thread>
#include <mutex>
#include <condition_variable>
#endif
using namespace std ;
typedef void(NPL::VDetector::*VDetector_FuncPtr)(void);
// This class manage a map of virtual detector
// This class manage a std::map of virtual detector
namespace NPL{
class DetectorManager{
public:
......@@ -47,19 +47,18 @@ namespace NPL{
~DetectorManager();
public:
void ReadConfigurationFile(string Path);
void ReadConfigurationFile(std::string Path);
void BuildPhysicalEvent();
void BuildSimplePhysicalEvent();
void InitializeRootInput();
void InitializeRootOutput();
void AddDetector(string,VDetector*);
VDetector* GetDetector(string);
void AddDetector(std::string,VDetector*);
VDetector* GetDetector(std::string);
void ClearEventPhysics();
void ClearEventData();
void InitSpectra();
void WriteSpectra();
vector< map< string, TH1* > > GetSpectra();
vector<string> GetDetectorList();
std::vector< std::map< std::string, TH1* > > GetSpectra();
std::vector<std::string> GetDetectorList();
public: // for online spectra server
void SetSpectraServer();
......@@ -69,9 +68,9 @@ namespace NPL{
NPL::SpectraServer* m_SpectraServer;
private:
// The map containning all detectors
// The std::map containning all detectors
// Using a Map one can access to any detector using its name
map<string,VDetector*> m_Detector;
std::map<std::string,VDetector*> m_Detector;
private: // Function pointer to accelerate the code execution
VDetector_FuncPtr m_BuildPhysicalPtr;
......@@ -80,51 +79,90 @@ namespace NPL{
VDetector_FuncPtr m_FillSpectra;
VDetector_FuncPtr m_CheckSpectra;
#if __cplusplus > 199711L
#if __cplusplus > 199711L && NPMULTITHREADING
private: // Thread Pool defined if C++11 is available
vector<std::thread> m_ThreadPool;
vector<bool> m_Ready;
std::vector<std::thread> m_ThreadPool;
std::vector<bool> m_Ready;
bool m_stop;
std::mutex m_ThreadMtx;
std::condition_variable m_CV;
public: // Init the Thread Pool
void StopThread();
void StartThread(NPL::VDetector*,unsigned int);
void InitThreadPool();
bool IsDone();
#endif
#endif
private: // Target property
double m_TargetThickness;
double m_TargetAngle;
double m_TargetRadius;
string m_TargetMaterial;
std::string m_TargetMaterial;
double m_TargetX;
double m_TargetY;
double m_TargetZ;
// Additional info for cryogenic target
double m_WindowsThickness;
string m_WindowsMaterial;
// Special treatment for the target for the moment
// If necessary we should change it to treat it as
// a full "detector"
// Additional info for cryogenic target
bool m_CryoTarget;
double m_TargetDensity;
double m_FrontDeformation;
double m_FrontThickness;
double m_FrontRadius;
std::string m_FrontMaterial;
double m_BackDeformation;
double m_BackRadius;
double m_BackThickness;
std::string m_BackMaterial;
double m_FrameRadius;
double m_FrameThickness;
double m_FrontCone;
double m_BackCone;
std::string m_FrameMaterial;
double m_ShieldInnerRadius;
double m_ShieldOuterRadius;
double m_ShieldBottomLength;
double m_ShieldTopLength;
double m_ShieldFrontRadius;
double m_ShieldBackRadius;
std::string m_ShieldMaterial;
double m_WindowsThickness;
std::string m_WindowsMaterial;
public: // those are define in cxx, otherwise the return value depend on context !?
bool IsCryogenic() const; // {return m_CryoTarget;};
double GetTargetThickness() const;//{return m_TargetThickness;};
double GetNominalTargetThickness() const; // {return m_TargetThickness;};
double GetTargetDensity() const; // {return m_TargetDensity;};
double GetFrontDeformation() const; // {return m_FrontDeformation;};
double GetFrontThickness() const; // {return m_FrontThickness;};
double GetFrontRadius() const; // {return m_FrontRadius;};
std::string GetFrontMaterial() const; // {return m_FrontMaterial;};
double GetBackDeformation() const; // {return m_BackDeformation;};
double GetBackRadius() const; // {return m_BackRadius;};
double GetBackThickness() const; // {return m_BackThickness;};
std::string GetBackMaterial() const; // {return m_BackMaterial;};
double GetFrameRadius() const; // {return m_FrameRadius;};
double GetFrameThickness() const; // {return m_FrameThickness;};
double GetFrontCone() const; // {return m_FrontCone;};
double GetBackCone() const; // {return m_BackCone;};
std::string GetFrameMaterial() const; // {return m_FrameMaterial;};
double GetShieldInnerRadius() const; // {return m_ShieldInnerRadius;};
double GetShieldOuterRadius() const; // {return m_ShieldOuterRadius;};
double GetShieldBottomLength() const; // {return m_ShieldBottomLength;};
double GetShieldTopLength() const; // {return m_ShieldTopLength;};
double GetShieldFrontRadius() const; // {return m_ShieldFrontRadius;};
double GetShieldBackRadius() const; // {return m_ShieldBackRadius;};
std::string GetShieldMaterial() const; // {return m_ShieldMaterial;};
std::string GetTargetMaterial() const; // {return m_TargetMaterial;};
double GetWindowsThickness() const; // {return m_WindowsThickness;};
std::string GetWindowsMaterial() const; // {return m_WindowsMaterial;};
double GetTargetRadius() const; // {return m_TargetRadius;};
double GetTargetAngle() const; // {return m_TargetAngle;};
double GetTargetX() const; // {return m_TargetX;};
double GetTargetY() const; // {return m_TargetY;};
double GetTargetZ() const; // {return m_TargetZ;};
public:
double GetTargetThickness() {return m_TargetThickness;}
string GetTargetMaterial() {return m_TargetMaterial;}
double GetWindowsThickness(){return m_WindowsThickness;}
string GetWindowsMaterial() {return m_WindowsMaterial;}
double GetTargetRadius() {return m_TargetRadius;}
double GetTargetAngle() {return m_TargetAngle;}
double GetTargetX() {return m_TargetX;}
double GetTargetY() {return m_TargetY;}
double GetTargetZ() {return m_TargetZ;}
};
};
}
#endif
......@@ -143,7 +143,7 @@ double NPL::InputBlock::GetDouble(std::string Token,std::string default_unit){
}
if(verbose)
cout << " " << Token << " (" <<default_unit << "): " << val/ApplyUnit(1,default_unit) << endl;
std::cout << " " << Token << " (" <<default_unit << "): " << val/ApplyUnit(1,default_unit) <<std::endl;
return val;
}
......@@ -155,7 +155,7 @@ int NPL::InputBlock::GetInt(std::string Token){
iss >> val ;
if(verbose)
cout << " " << Token << ": " << val << endl;
std::cout << " " << Token << ": " << val <<std::endl;
return val;
......@@ -164,7 +164,7 @@ int NPL::InputBlock::GetInt(std::string Token){
std::string NPL::InputBlock::GetString(std::string Token){
int verbose = NPOptionManager::getInstance()->GetVerboseLevel();
if(verbose)
cout << " " << Token << ": " << GetValue(Token) << endl;
std::cout << " " << Token << ": " << GetValue(Token) << std::endl;
return GetValue(Token);
}
......@@ -190,10 +190,10 @@ TVector3 NPL::InputBlock::GetTVector3(std::string Token,std::string default_uni
}
if(verbose)
cout << " " << Token << " (" <<default_unit << "): ("
std::cout << " " << Token << " (" <<default_unit << "): ("
<< x/ApplyUnit(1,default_unit) << " ; "
<< y/ApplyUnit(1,default_unit) << " ; "
<< z/ApplyUnit(1,default_unit) << ")" << endl;
<< z/ApplyUnit(1,default_unit) << ")" << std::endl;
return TVector3(x,y,z);
......@@ -211,10 +211,10 @@ std::vector<std::string> NPL::InputBlock::GetVectorString(std::string Token){
if(verbose){
cout << " " << Token << ": ";
std::cout << " " << Token << ": ";
for(unsigned int i = 0 ; i < val.size() ; i++)
cout << val[i] << " " ;
cout << endl;
std::cout << val[i] << " " ;
std::cout << std::endl;
}
return val;
}
......@@ -247,10 +247,10 @@ std::vector<double> NPL::InputBlock::GetVectorDouble(std::string Token,std::stri
}
if(verbose){
cout << " " << Token << " (" << default_unit << "): ";
std::cout << " " << Token << " (" << default_unit << "): ";
for(unsigned int i = 0 ; i < val.size() ; i++)
cout << val[i]/ApplyUnit(1,default_unit) << " " ;
cout << endl;
std::cout << val[i]/ApplyUnit(1,default_unit) << " " ;
std::cout << std::endl;
}
return val;
......@@ -267,10 +267,10 @@ std::vector<int> NPL::InputBlock::GetVectorInt(std::string Token){
val.push_back(buffer);
if(verbose){
cout << " " << Token << ": ";
std::cout << " " << Token << ": ";
for(unsigned int i = 0 ; i < val.size() ; i++)
cout << val[i] << " " ;
cout << endl;
std::cout << val[i] << " " ;
std::cout << std::endl;
}
......@@ -331,6 +331,18 @@ std::vector<std::string> NPL::InputParser::GetAllBlocksToken(){
return token;
}
////////////////////////////////////////////////////////////////////////////////
std::vector<std::string> NPL::InputParser::GetAllBlocksValues(std::string token){
std::vector<std::string> value;
std::vector<NPL::InputBlock*> blocks = GetAllBlocksWithToken(token);
unsigned int size = blocks.size();
for(unsigned int i = 0 ; i < size ; i++){
value.push_back(blocks[i]->GetMainValue());
}
return value;
}
////////////////////////////////////////////////////////////////////////////////
void NPL::InputParser::TreatAliases(){
......@@ -351,7 +363,7 @@ void NPL::InputParser::TreatAliases(){
int verbose = NPOptionManager::getInstance()->GetVerboseLevel();
if(verbose)
std::cout << "Using Alias : @" << alias[i]->GetMainValue() << endl;
std::cout << "Using Alias : @" << alias[i]->GetMainValue() << std::endl;
std::string name="@";
name += alias[i]->GetMainValue();
......@@ -398,7 +410,7 @@ void NPL::InputParser::TreatAliases(){
m_Block[b] = newBlock;
}
else{
vector<NPL::InputBlock*>::iterator it = m_Block.begin();
std::vector<NPL::InputBlock*>::iterator it = m_Block.begin();
m_Block.insert(it+b+a,newBlock);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment