1
0
Fork 0
mirror of https://github.com/gwm17/PunchTable.git synced 2024-11-22 18:28:52 -05:00

Added capability to query table for the projectile and material used

This commit is contained in:
Gordon McCann 2022-06-17 11:32:08 -04:00
parent 9bb87e999e
commit 0333103ef1
6 changed files with 48 additions and 14 deletions

View File

@ -34,10 +34,16 @@ namespace PunchTable {
double value; double value;
std::vector<double> energyLoss, energyFinal; std::vector<double> energyLoss, energyFinal;
std::getline(input, junk); input>>junk>>junk>>m_projectileString;
while(junk != "---------------------------------") input>>junk>>junk;
while(input>>junk)
{ {
std::getline(input, junk); if(junk == "---------------------------------")
break;
input>>junk;
m_materialString += junk;
input>>junk;
} }
input>>junk>>m_thetaMin>>junk>>m_thetaMax>>junk>>m_thetaStep; input>>junk>>m_thetaMin>>junk>>m_thetaMax>>junk>>m_thetaStep;
std::getline(input, junk); std::getline(input, junk);

View File

@ -21,11 +21,16 @@ namespace PunchTable {
~ElossTable(); ~ElossTable();
void ReadFile(const std::string& filename); void ReadFile(const std::string& filename);
std::string GetProjectile() { return m_projectileString; }
std::string GetMaterial() { return m_materialString; }
double GetEnergyLoss(double thetaIncident, double finalEnergy); double GetEnergyLoss(double thetaIncident, double finalEnergy);
inline const bool IsValid() const { return m_isValid; } inline const bool IsValid() const { return m_isValid; }
private: private:
std::string m_projectileString;
std::string m_materialString;
std::vector<CubicSpline> m_splines; std::vector<CubicSpline> m_splines;
double m_thetaStep, m_thetaMin, m_thetaMax; double m_thetaStep, m_thetaMin, m_thetaMax;

View File

@ -106,18 +106,21 @@ namespace PunchTable {
} }
output<<std::setprecision(5); output<<std::setprecision(5);
output<<"Materials: "<<std::endl;; output<<"---------------------------------"<<std::endl;
output<<"Projectile: "<<masses.FindSymbol(params.projectileZ, params.projectileA)<<std::endl;
output<<"---------------------------------"<<std::endl;
output<<"Materials: "<<std::endl;
for(size_t i=0; i<depLayer; i++) for(size_t i=0; i<depLayer; i++)
{ {
output<<"\tGoing through: "; output<<"\tGoingThrough: ";
for(size_t j=0; j<params.targetZ[i].size(); j++) for(size_t j=0; j<params.targetZ[i].size(); j++)
output<<masses.FindSymbol(params.targetZ[i][j], params.targetA[i][j])<<params.targetS[i][j]; output<<masses.FindSymbol(params.targetZ[i][j], params.targetA[i][j])<<params.targetS[i][j];
output<<" ("<<params.targetThickness[i]<<" ug/cm2)"<<std::endl; output<<" ("<<params.targetThickness[i]<<"ug/cm2)"<<std::endl;
} }
output<<"\tDeposting into: "; output<<"\tDepostingInto: ";
for(size_t i=0; i<params.targetZ[depLayer].size(); i++) for(size_t i=0; i<params.targetZ[depLayer].size(); i++)
output<<masses.FindSymbol(params.targetZ[depLayer][i], params.targetA[depLayer][i])<<params.targetS[depLayer][i]; output<<masses.FindSymbol(params.targetZ[depLayer][i], params.targetA[depLayer][i])<<params.targetS[depLayer][i];
output<<" ("<<params.targetThickness[depLayer]<<" ug/cm2)"<<std::endl; output<<" ("<<params.targetThickness[depLayer]<<"ug/cm2)"<<std::endl;
output<<"---------------------------------"<<std::endl; output<<"---------------------------------"<<std::endl;
output<<"IncidentAngleRange(deg): "<<params.minTheta<<" to "<<params.maxTheta<<" stepSize: "<<params.stepTheta<<std::endl; output<<"IncidentAngleRange(deg): "<<params.minTheta<<" to "<<params.maxTheta<<" stepSize: "<<params.stepTheta<<std::endl;
@ -232,13 +235,16 @@ namespace PunchTable {
} }
output<<std::setprecision(5); output<<std::setprecision(5);
output<<"---------------------------------"<<std::endl;
output<<"Projectile: "<<masses.FindSymbol(params.projectileZ, params.projectileA)<<std::endl;
output<<"---------------------------------"<<std::endl;
output<<"Materials: "<<std::endl;; output<<"Materials: "<<std::endl;;
for(size_t i=0; i<nlayers; i++) for(size_t i=0; i<nlayers; i++)
{ {
output<<"\tGoing through: "; output<<"\tGoingThrough: ";
for(size_t j=0; j<params.targetZ[i].size(); j++) for(size_t j=0; j<params.targetZ[i].size(); j++)
output<<masses.FindSymbol(params.targetZ[i][j], params.targetA[i][j])<<params.targetS[i][j]; output<<masses.FindSymbol(params.targetZ[i][j], params.targetA[i][j])<<params.targetS[i][j];
output<<" ("<<params.targetThickness[i]<<" ug/cm2)"<<std::endl; output<<" ("<<params.targetThickness[i]<<"ug/cm2)"<<std::endl;
} }
output<<"---------------------------------"<<std::endl; output<<"---------------------------------"<<std::endl;
output<<"IncidentAngleRange(deg): "<<params.minTheta<<" to "<<params.maxTheta<<" stepSize: "<<params.stepTheta<<std::endl; output<<"IncidentAngleRange(deg): "<<params.minTheta<<" to "<<params.maxTheta<<" stepSize: "<<params.stepTheta<<std::endl;

View File

@ -33,11 +33,18 @@ namespace PunchTable {
double value; double value;
std::vector<double> energyIn, energyDep; std::vector<double> energyIn, energyDep;
std::getline(input, junk); input>>junk>>junk>>m_projectileString;
while(junk != "---------------------------------") input>>junk>>junk;
while(input>>junk)
{ {
std::getline(input, junk); if(junk == "---------------------------------")
break;
input>>junk;
m_materialString += junk;
input>>junk;
} }
input>>junk>>m_thetaMin>>junk>>m_thetaMax>>junk>>m_thetaStep; input>>junk>>m_thetaMin>>junk>>m_thetaMax>>junk>>m_thetaStep;
std::getline(input, junk); std::getline(input, junk);
std::getline(input, junk); std::getline(input, junk);

View File

@ -13,11 +13,17 @@ namespace PunchTable {
PunchTable(); PunchTable();
PunchTable(const std::string& filename); PunchTable(const std::string& filename);
~PunchTable(); ~PunchTable();
void ReadFile(const std::string& filename); void ReadFile(const std::string& filename);
std::string GetProjectile() { return m_projectileString; }
std::string GetMaterial() { return m_materialString; }
double GetInitialKineticEnergy(double theta_incident, double e_deposited); //radians, MeV double GetInitialKineticEnergy(double theta_incident, double e_deposited); //radians, MeV
inline bool IsValid() const { return m_validFlag; } inline bool IsValid() const { return m_validFlag; }
private: private:
std::string m_projectileString;
std::string m_materialString;
std::vector<CubicSpline> m_splines; std::vector<CubicSpline> m_splines;
double m_thetaStep, m_thetaMin, m_thetaMax; double m_thetaStep, m_thetaMin, m_thetaMax;

View File

@ -43,6 +43,8 @@ int main(int argc, char** argv)
std::cout<<"-------------Testing---------"<<std::endl; std::cout<<"-------------Testing---------"<<std::endl;
PunchTable::PunchTable table(params.filename); PunchTable::PunchTable table(params.filename);
std::cout<<"Is the table valid? "<<table.IsValid()<<std::endl; std::cout<<"Is the table valid? "<<table.IsValid()<<std::endl;
std::cout<<"Table Projectile: "<<table.GetProjectile()<<std::endl;
std::cout<<"Table Material: "<<table.GetMaterial()<<std::endl;
double ke_test = 14.5; //MeV double ke_test = 14.5; //MeV
double theta_test = 35.5*M_PI/180.0; double theta_test = 35.5*M_PI/180.0;
double ke_dep = PunchTable::GetEnergyDeposited(params, theta_test, ke_test); double ke_dep = PunchTable::GetEnergyDeposited(params, theta_test, ke_test);
@ -58,6 +60,8 @@ int main(int argc, char** argv)
std::cout<<"-------------Testing---------"<<std::endl; std::cout<<"-------------Testing---------"<<std::endl;
PunchTable::ElossTable table(params.filename); PunchTable::ElossTable table(params.filename);
std::cout<<"Is the table valid? "<<table.IsValid()<<std::endl; std::cout<<"Is the table valid? "<<table.IsValid()<<std::endl;
std::cout<<"Table Projectile: "<<table.GetProjectile()<<std::endl;
std::cout<<"Table Material: "<<table.GetMaterial()<<std::endl;
double ke_test = 0.5; //MeV double ke_test = 0.5; //MeV
double theta_test = 35.5*M_PI/180.0; double theta_test = 35.5*M_PI/180.0;
double eloss = table.GetEnergyLoss(theta_test, ke_test); double eloss = table.GetEnergyLoss(theta_test, ke_test);