mirror of
https://github.com/gwm17/Mask.git
synced 2024-11-22 10:18:50 -05:00
Changed name of Kinematics class to MaskApp, better enforced use of scoped RxnType across all applications (see new RxnType.h)
This commit is contained in:
parent
6c21c214b4
commit
d50a48190e
|
@ -30,7 +30,7 @@ private:
|
|||
DetectorResult IsRing2(Mask::Nucleus& nucleus);
|
||||
DetectorResult IsQQQ(Mask::Nucleus& nucleus);
|
||||
DetectorResult IsAnasen(Mask::Nucleus& nucleus);
|
||||
void CountCoincidences(const Mask::MaskFileData& data, std::vector<int>& counts, int rxn_type);
|
||||
void CountCoincidences(const Mask::MaskFileData& data, std::vector<int>& counts, Mask::RxnType rxn_type);
|
||||
|
||||
std::vector<StripDetector> m_Ring1, m_Ring2;
|
||||
std::vector<QQQDetector> m_forwardQQQs;
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
#ifndef KINEMATICS_H
|
||||
#define KINEMATICS_H
|
||||
|
||||
#include "ReactionSystem.h"
|
||||
#include "DecaySystem.h"
|
||||
#include "OneStepSystem.h"
|
||||
#include "TwoStepSystem.h"
|
||||
#include "ThreeStepSystem.h"
|
||||
|
||||
namespace Mask {
|
||||
|
||||
class Kinematics {
|
||||
public:
|
||||
Kinematics();
|
||||
~Kinematics();
|
||||
bool LoadConfig(const std::string& filename);
|
||||
bool SaveConfig(const std::string& filename);
|
||||
inline int GetNumberOfSamples() { return m_nsamples; };
|
||||
inline const std::string GetSystemName() { return sys == nullptr ? "" : sys->GetSystemEquation(); };
|
||||
inline const std::string GetOutputName() { return m_outfile_name; };
|
||||
inline const int GetReactionType() { return m_rxn_type; };
|
||||
void Run();
|
||||
|
||||
enum RxnType {
|
||||
ONESTEP_DECAY,
|
||||
ONESTEP_RXN,
|
||||
TWOSTEP,
|
||||
THREESTEP
|
||||
};
|
||||
|
||||
private:
|
||||
void RunOneStepRxn();
|
||||
void RunOneStepDecay();
|
||||
void RunTwoStep();
|
||||
void RunThreeStep();
|
||||
|
||||
ReactionSystem* sys;
|
||||
|
||||
std::string m_outfile_name;
|
||||
|
||||
int m_rxn_type, m_nsamples;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
42
include/MaskApp.h
Normal file
42
include/MaskApp.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
#ifndef MASKAPP_H
|
||||
#define MASKAPP_H
|
||||
|
||||
#include "ReactionSystem.h"
|
||||
#include "DecaySystem.h"
|
||||
#include "OneStepSystem.h"
|
||||
#include "TwoStepSystem.h"
|
||||
#include "ThreeStepSystem.h"
|
||||
#include "RxnType.h"
|
||||
|
||||
namespace Mask {
|
||||
|
||||
class MaskApp {
|
||||
public:
|
||||
MaskApp();
|
||||
~MaskApp();
|
||||
bool LoadConfig(const std::string& filename);
|
||||
bool SaveConfig(const std::string& filename);
|
||||
inline int GetNumberOfSamples() const { return m_nsamples; };
|
||||
inline const std::string GetSystemName() const { return sys == nullptr ? "" : sys->GetSystemEquation(); };
|
||||
inline const std::string GetOutputName() const { return m_outfile_name; };
|
||||
inline const RxnType GetReactionType() const { return m_rxn_type; };
|
||||
void Run();
|
||||
|
||||
private:
|
||||
void RunOneStepRxn();
|
||||
void RunOneStepDecay();
|
||||
void RunTwoStep();
|
||||
void RunThreeStep();
|
||||
|
||||
ReactionSystem* sys;
|
||||
|
||||
std::string m_outfile_name;
|
||||
|
||||
RxnType m_rxn_type;
|
||||
uint64_t m_nsamples;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -6,11 +6,12 @@
|
|||
#include <vector>
|
||||
|
||||
#include "Nucleus.h"
|
||||
#include "RxnType.h"
|
||||
|
||||
namespace Mask {
|
||||
|
||||
struct MaskFileHeader {
|
||||
int rxn_type = -1;
|
||||
RxnType rxn_type = RxnType::None;
|
||||
int nsamples = -1;
|
||||
};
|
||||
|
||||
|
@ -36,7 +37,7 @@ namespace Mask {
|
|||
inline bool IsOpen() { return file.is_open(); }
|
||||
void Close();
|
||||
|
||||
void WriteHeader(int rxn_type, int nsamples);
|
||||
void WriteHeader(RxnType rxn_type, int nsamples);
|
||||
void WriteData(std::vector<Nucleus>& data);
|
||||
void WriteData(MaskFileData& data);
|
||||
MaskFileHeader ReadHeader();
|
||||
|
@ -51,7 +52,7 @@ namespace Mask {
|
|||
unsigned int buffer_position;
|
||||
unsigned int buffer_end;
|
||||
unsigned int data_size;
|
||||
int m_rxn_type;
|
||||
RxnType m_rxn_type;
|
||||
int buffersize_bytes;
|
||||
|
||||
std::fstream file;
|
||||
|
|
58
include/RxnType.h
Normal file
58
include/RxnType.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
#ifndef RXNTYPE_H
|
||||
#define RXNTYPE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Mask {
|
||||
|
||||
enum class RxnType
|
||||
{
|
||||
PureDecay=0,
|
||||
OneStepRxn=1,
|
||||
TwoStepRxn=2,
|
||||
ThreeStepRxn=3,
|
||||
None=4
|
||||
};
|
||||
|
||||
static RxnType GetRxnTypeFromString(const std::string& type_str)
|
||||
{
|
||||
if (type_str == "PureDecay")
|
||||
return RxnType::PureDecay;
|
||||
else if (type_str == "OneStepRxn")
|
||||
return RxnType::OneStepRxn;
|
||||
else if (type_str == "TwoStepRxn")
|
||||
return RxnType::TwoStepRxn;
|
||||
else if (type_str == "ThreeStepRxn")
|
||||
return RxnType::ThreeStepRxn;
|
||||
else
|
||||
return RxnType::None;
|
||||
}
|
||||
|
||||
static std::string GetStringFromRxnType(RxnType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case RxnType::PureDecay: return "PureDecay";
|
||||
case RxnType::OneStepRxn: return "OneStepRxn";
|
||||
case RxnType::TwoStepRxn: return "TwoStepRxn";
|
||||
case RxnType::ThreeStepRxn: return "ThreeStepRxn";
|
||||
}
|
||||
|
||||
return "None";
|
||||
}
|
||||
|
||||
static RxnType GetRxnTypeFromInt(uint32_t value)
|
||||
{
|
||||
return static_cast<RxnType>(value);
|
||||
}
|
||||
|
||||
static uint32_t GetIntFromRxnType(RxnType type)
|
||||
{
|
||||
return static_cast<uint32_t>(type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,9 +1,7 @@
|
|||
----------Data Information----------
|
||||
OutputFile: /media/gordon/ANASENData/MaskData/Kinematics/7Bedp_870keV_beam_50CD2.mask
|
||||
SaveTree: yes
|
||||
SavePlots: yes
|
||||
OutputFile: /media/gordon/ANASENData/MaskData/Kinematics/7Bedp_870keV_beam_50CD2_test.mask
|
||||
----------Reaction Information----------
|
||||
ReactionType: 2
|
||||
ReactionType: TwoStepRxn
|
||||
Z A (order is target, projectile, ejectile, break1, break3(if pure decay is target, ejectile))
|
||||
1 2
|
||||
4 7
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "AnasenEfficiency.h"
|
||||
#include "Kinematics.h"
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
@ -321,16 +320,16 @@ DetectorResult AnasenEfficiency::IsAnasen(Mask::Nucleus& nucleus) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void AnasenEfficiency::CountCoincidences(const Mask::MaskFileData& data, std::vector<int>& counts, int rxn_type) {
|
||||
if (rxn_type == 0 && data.detect_flag[1] && data.detect_flag[2])
|
||||
void AnasenEfficiency::CountCoincidences(const Mask::MaskFileData& data, std::vector<int>& counts, Mask::RxnType rxn_type) {
|
||||
if (rxn_type == Mask::RxnType::PureDecay && data.detect_flag[1] && data.detect_flag[2])
|
||||
{
|
||||
counts[0]++;
|
||||
}
|
||||
else if (rxn_type == 1 && data.detect_flag[2] && data.detect_flag[3])
|
||||
else if (rxn_type == Mask::RxnType::OneStepRxn && data.detect_flag[2] && data.detect_flag[3])
|
||||
{
|
||||
counts[0]++;
|
||||
}
|
||||
else if(rxn_type == 2)
|
||||
else if(rxn_type == Mask::RxnType::TwoStepRxn)
|
||||
{
|
||||
if(data.detect_flag[2] && data.detect_flag[4])
|
||||
{
|
||||
|
@ -349,7 +348,7 @@ void AnasenEfficiency::CountCoincidences(const Mask::MaskFileData& data, std::ve
|
|||
counts[3]++;
|
||||
}
|
||||
}
|
||||
else if(rxn_type == 3)
|
||||
else if(rxn_type == Mask::RxnType::ThreeStepRxn)
|
||||
{
|
||||
if(data.detect_flag[2] && data.detect_flag[4])
|
||||
{
|
||||
|
@ -418,25 +417,25 @@ void AnasenEfficiency::CalculateEfficiency(const std::string& inputname, const s
|
|||
std::vector<int> counts;
|
||||
std::vector<int> coinc_counts;
|
||||
switch(header.rxn_type) {
|
||||
case 0:
|
||||
case Mask::RxnType::PureDecay:
|
||||
counts.resize(3, 0);
|
||||
coinc_counts.resize(1, 0);
|
||||
break;
|
||||
case 1:
|
||||
case Mask::RxnType::OneStepRxn:
|
||||
counts.resize(4, 0);
|
||||
coinc_counts.resize(1, 0);
|
||||
break;
|
||||
case 2:
|
||||
case Mask::RxnType::TwoStepRxn:
|
||||
counts.resize(6, 0);
|
||||
coinc_counts.resize(4, 0);
|
||||
break;
|
||||
case 3:
|
||||
case Mask::RxnType::ThreeStepRxn:
|
||||
counts.resize(8, 0);
|
||||
coinc_counts.resize(11, 0);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
std::cerr<<"Bad reaction type at AnasenEfficiency::CalculateEfficiency (given value: "<<header.rxn_type<<"). Quiting..."<<std::endl;
|
||||
std::cerr<<"Bad reaction type at AnasenEfficiency::CalculateEfficiency (given value: "<<GetStringFromRxnType(header.rxn_type)<<"). Quiting..."<<std::endl;
|
||||
input.Close();
|
||||
output.Close();
|
||||
stats.close();
|
||||
|
@ -494,17 +493,17 @@ void AnasenEfficiency::CalculateEfficiency(const std::string& inputname, const s
|
|||
}
|
||||
stats<<"Coincidence Efficiency"<<std::endl;
|
||||
stats<<"---------------------"<<std::endl;
|
||||
if(header.rxn_type == 0)
|
||||
if(header.rxn_type == Mask::RxnType::PureDecay)
|
||||
{
|
||||
stats<<std::setw(10)<<"1 + 2"<<"|"<<std::setw(10)<<((double)coinc_counts[0]/header.nsamples)<<std::endl;
|
||||
stats<<"---------------------"<<std::endl;
|
||||
}
|
||||
else if(header.rxn_type == 1)
|
||||
else if(header.rxn_type == Mask::RxnType::OneStepRxn)
|
||||
{
|
||||
stats<<std::setw(10)<<"2 + 3"<<"|"<<std::setw(10)<<((double)coinc_counts[0]/header.nsamples)<<std::endl;
|
||||
stats<<"---------------------"<<std::endl;
|
||||
}
|
||||
else if(header.rxn_type == 2)
|
||||
else if(header.rxn_type == Mask::RxnType::TwoStepRxn)
|
||||
{
|
||||
stats<<std::setw(10)<<"2 + 4"<<"|"<<std::setw(10)<<((double)coinc_counts[0]/header.nsamples)<<std::endl;
|
||||
stats<<"---------------------"<<std::endl;
|
||||
|
@ -515,7 +514,7 @@ void AnasenEfficiency::CalculateEfficiency(const std::string& inputname, const s
|
|||
stats<<std::setw(10)<<"2 + 4 + 5"<<"|"<<std::setw(10)<<((double)coinc_counts[3]/header.nsamples)<<std::endl;
|
||||
stats<<"---------------------"<<std::endl;
|
||||
}
|
||||
else if(header.rxn_type == 3)
|
||||
else if(header.rxn_type == Mask::RxnType::ThreeStepRxn)
|
||||
{
|
||||
stats<<std::setw(10)<<"2 + 4"<<"|"<<std::setw(10)<<((double)coinc_counts[0]/header.nsamples)<<std::endl;
|
||||
stats<<"---------------------"<<std::endl;
|
||||
|
|
|
@ -53,21 +53,21 @@ void SabreEfficiency::CalculateEfficiency(const std::string& inputname, const st
|
|||
|
||||
std::vector<int> counts;
|
||||
switch(header.rxn_type) {
|
||||
case 0:
|
||||
case Mask::RxnType::PureDecay:
|
||||
counts.resize(3, 0);
|
||||
break;
|
||||
case 1:
|
||||
case Mask::RxnType::OneStepRxn:
|
||||
counts.resize(4, 0);
|
||||
break;
|
||||
case 2:
|
||||
case Mask::RxnType::TwoStepRxn:
|
||||
counts.resize(6, 0);
|
||||
break;
|
||||
case 3:
|
||||
case Mask::RxnType::ThreeStepRxn:
|
||||
counts.resize(8, 0);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
std::cerr<<"Bad reaction type at AnasenEfficiency::CalculateEfficiency (given value: "<<header.rxn_type<<"). Quiting..."<<std::endl;
|
||||
std::cerr<<"Bad reaction type at AnasenEfficiency::CalculateEfficiency (given value: "<<GetStringFromRxnType(header.rxn_type)<<"). Quiting..."<<std::endl;
|
||||
input.Close();
|
||||
output.Close();
|
||||
stats.close();
|
||||
|
|
|
@ -1,46 +1,49 @@
|
|||
#include "Kinematics.h"
|
||||
#include "MaskApp.h"
|
||||
#include "MaskFile.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace Mask {
|
||||
|
||||
Kinematics::Kinematics() :
|
||||
MaskApp::MaskApp() :
|
||||
sys(nullptr)
|
||||
{
|
||||
std::cout<<"----------GWM Kinematics Simulation----------"<<std::endl;
|
||||
}
|
||||
|
||||
Kinematics::~Kinematics() {
|
||||
MaskApp::~MaskApp()
|
||||
{
|
||||
if(sys) delete sys;
|
||||
}
|
||||
|
||||
bool Kinematics::LoadConfig(const std::string& filename) {
|
||||
bool MaskApp::LoadConfig(const std::string& filename)
|
||||
{
|
||||
std::cout<<"Loading configuration in "<<filename<<"..."<<std::endl;
|
||||
|
||||
std::ifstream input(filename);
|
||||
if(!input.is_open()) {
|
||||
if(!input.is_open())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string junk;
|
||||
getline(input, junk);
|
||||
input>>junk>>m_outfile_name;
|
||||
input>>junk>>junk;
|
||||
input>>junk>>junk;
|
||||
|
||||
std::vector<int> avec, zvec, svec;
|
||||
int z, a, s;
|
||||
getline(input, junk);
|
||||
getline(input, junk);
|
||||
input>>junk>>m_rxn_type;
|
||||
input>>junk>>junk;
|
||||
m_rxn_type = GetRxnTypeFromString(junk);
|
||||
getline(input, junk);
|
||||
getline(input, junk);
|
||||
switch(m_rxn_type) {
|
||||
case 0:
|
||||
switch(m_rxn_type)
|
||||
{
|
||||
case RxnType::PureDecay:
|
||||
{
|
||||
sys = new DecaySystem();
|
||||
m_rxn_type = ONESTEP_DECAY;
|
||||
m_rxn_type = RxnType::PureDecay;
|
||||
for(int i=0; i<2; i++) {
|
||||
input>>z>>a;
|
||||
avec.push_back(a);
|
||||
|
@ -48,10 +51,10 @@ namespace Mask {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case RxnType::OneStepRxn:
|
||||
{
|
||||
sys = new OneStepSystem();
|
||||
m_rxn_type = ONESTEP_RXN;
|
||||
m_rxn_type = RxnType::OneStepRxn;
|
||||
for(int i=0; i<3; i++) {
|
||||
input>>z>>a;
|
||||
avec.push_back(a);
|
||||
|
@ -59,10 +62,10 @@ namespace Mask {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
case RxnType::TwoStepRxn:
|
||||
{
|
||||
sys = new TwoStepSystem();
|
||||
m_rxn_type = TWOSTEP;
|
||||
m_rxn_type = RxnType::TwoStepRxn;
|
||||
for(int i=0; i<4; i++) {
|
||||
input>>z>>a;
|
||||
avec.push_back(a);
|
||||
|
@ -70,10 +73,10 @@ namespace Mask {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
case RxnType::ThreeStepRxn:
|
||||
{
|
||||
sys = new ThreeStepSystem();
|
||||
m_rxn_type = THREESTEP;
|
||||
m_rxn_type = RxnType::TwoStepRxn;
|
||||
for(int i=0; i<5; i++) {
|
||||
input>>z>>a;
|
||||
avec.push_back(a);
|
||||
|
@ -92,7 +95,8 @@ namespace Mask {
|
|||
getline(input, junk);
|
||||
input>>junk>>junk;
|
||||
input>>junk>>nlayers;
|
||||
for(int i=0; i<nlayers; i++) {
|
||||
for(int i=0; i<nlayers; i++)
|
||||
{
|
||||
input>>junk>>junk>>thickness;
|
||||
getline(input, junk);
|
||||
getline(input, junk);
|
||||
|
@ -116,18 +120,19 @@ namespace Mask {
|
|||
input>>junk>>par1>>junk>>par2;
|
||||
sys->SetBeamDistro(par1, par2);
|
||||
input>>junk>>par1;
|
||||
switch(m_rxn_type) {
|
||||
case ONESTEP_RXN :
|
||||
switch(m_rxn_type)
|
||||
{
|
||||
case RxnType::OneStepRxn :
|
||||
{
|
||||
dynamic_cast<OneStepSystem*>(sys)->SetReactionThetaType(par1);
|
||||
break;
|
||||
}
|
||||
case TWOSTEP:
|
||||
case RxnType::TwoStepRxn :
|
||||
{
|
||||
dynamic_cast<TwoStepSystem*>(sys)->SetReactionThetaType(par1);
|
||||
break;
|
||||
}
|
||||
case THREESTEP:
|
||||
case RxnType::ThreeStepRxn :
|
||||
{
|
||||
dynamic_cast<ThreeStepSystem*>(sys)->SetReactionThetaType(par1);
|
||||
break;
|
||||
|
@ -141,8 +146,9 @@ namespace Mask {
|
|||
sys->SetExcitationDistro(par1, par2);
|
||||
input>>junk>>dfile1;
|
||||
input>>junk>>dfile2;
|
||||
switch(m_rxn_type) {
|
||||
case ONESTEP_DECAY:
|
||||
switch(m_rxn_type)
|
||||
{
|
||||
case RxnType::OneStepRxn :
|
||||
{
|
||||
DecaySystem* this_sys = dynamic_cast<DecaySystem*>(sys);
|
||||
this_sys->SetDecay1Distribution(dfile1);
|
||||
|
@ -150,7 +156,7 @@ namespace Mask {
|
|||
std::cout<<"Decay1 total branching ratio: "<<this_sys->GetDecay1BranchingRatio()<<std::endl;
|
||||
break;
|
||||
}
|
||||
case TWOSTEP:
|
||||
case RxnType::TwoStepRxn :
|
||||
{
|
||||
TwoStepSystem* this_sys = dynamic_cast<TwoStepSystem*>(sys);
|
||||
this_sys->SetDecay1Distribution(dfile1);
|
||||
|
@ -158,7 +164,7 @@ namespace Mask {
|
|||
std::cout<<"Decay1 total branching ratio: "<<this_sys->GetDecay1BranchingRatio()<<std::endl;
|
||||
break;
|
||||
}
|
||||
case THREESTEP:
|
||||
case RxnType::ThreeStepRxn :
|
||||
{
|
||||
ThreeStepSystem* this_sys = dynamic_cast<ThreeStepSystem*>(sys);
|
||||
this_sys->SetDecay1Distribution(dfile1);
|
||||
|
@ -174,27 +180,28 @@ namespace Mask {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Kinematics::SaveConfig(const std::string& filename) { return true; }
|
||||
bool MaskApp::SaveConfig(const std::string& filename) { return true; }
|
||||
|
||||
void Kinematics::Run() {
|
||||
void MaskApp::Run() {
|
||||
std::cout<<"Running simulation..."<<std::endl;
|
||||
switch(m_rxn_type) {
|
||||
case ONESTEP_DECAY:
|
||||
switch(m_rxn_type)
|
||||
{
|
||||
case RxnType::PureDecay :
|
||||
{
|
||||
RunOneStepDecay();
|
||||
break;
|
||||
}
|
||||
case ONESTEP_RXN:
|
||||
case RxnType::OneStepRxn :
|
||||
{
|
||||
RunOneStepRxn();
|
||||
break;
|
||||
}
|
||||
case TWOSTEP:
|
||||
case RxnType::TwoStepRxn :
|
||||
{
|
||||
RunTwoStep();
|
||||
break;
|
||||
}
|
||||
case THREESTEP:
|
||||
case RxnType::ThreeStepRxn :
|
||||
{
|
||||
RunThreeStep();
|
||||
break;
|
||||
|
@ -205,9 +212,10 @@ namespace Mask {
|
|||
std::cout<<"---------------------------------------------"<<std::endl;
|
||||
}
|
||||
|
||||
void Kinematics::RunOneStepRxn() {
|
||||
void MaskApp::RunOneStepRxn() {
|
||||
OneStepSystem* this_sys = dynamic_cast<OneStepSystem*>(sys);
|
||||
if(this_sys == nullptr) {
|
||||
if(this_sys == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -218,12 +226,14 @@ namespace Mask {
|
|||
|
||||
|
||||
//For progress tracking
|
||||
int percent5 = 0.05*m_nsamples;
|
||||
int count = 0;
|
||||
int npercent = 0;
|
||||
uint64_t percent5 = 0.05*m_nsamples;
|
||||
uint64_t count = 0;
|
||||
uint64_t npercent = 0;
|
||||
|
||||
for(int i=0; i<m_nsamples; i++) {
|
||||
if(++count == percent5) {//Show update every 5 percent
|
||||
for(uint64_t i=0; i<m_nsamples; i++)
|
||||
{
|
||||
if(++count == percent5)
|
||||
{//Show update every 5 percent
|
||||
npercent++;
|
||||
count = 0;
|
||||
std::cout<<"\rPercent complete: "<<npercent*5<<"%"<<std::flush;
|
||||
|
@ -241,9 +251,10 @@ namespace Mask {
|
|||
output.Close();
|
||||
}
|
||||
|
||||
void Kinematics::RunOneStepDecay() {
|
||||
void MaskApp::RunOneStepDecay() {
|
||||
DecaySystem* this_sys = dynamic_cast<DecaySystem*>(sys);
|
||||
if(this_sys == nullptr) {
|
||||
if(this_sys == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -253,12 +264,14 @@ namespace Mask {
|
|||
output.WriteHeader(m_rxn_type, m_nsamples);
|
||||
|
||||
//For progress tracking
|
||||
int percent5 = 0.05*m_nsamples;
|
||||
int count = 0;
|
||||
int npercent = 0;
|
||||
uint64_t percent5 = 0.05*m_nsamples;
|
||||
uint64_t count = 0;
|
||||
uint64_t npercent = 0;
|
||||
|
||||
for(int i=0; i<m_nsamples; i++) {
|
||||
if(++count == percent5) {//Show update every 5 percent
|
||||
for(uint64_t i=0; i<m_nsamples; i++)
|
||||
{
|
||||
if(++count == percent5)
|
||||
{
|
||||
npercent++;
|
||||
count = 0;
|
||||
std::cout<<"\rPercent complete: "<<npercent*5<<"%"<<std::flush;
|
||||
|
@ -274,10 +287,11 @@ namespace Mask {
|
|||
output.Close();
|
||||
}
|
||||
|
||||
void Kinematics::RunTwoStep() {
|
||||
void MaskApp::RunTwoStep() {
|
||||
|
||||
TwoStepSystem* this_sys = dynamic_cast<TwoStepSystem*>(sys);
|
||||
if(this_sys == nullptr) {
|
||||
if(this_sys == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -287,12 +301,14 @@ namespace Mask {
|
|||
output.WriteHeader(m_rxn_type, m_nsamples);
|
||||
|
||||
//For progress tracking
|
||||
int percent5 = 0.05*m_nsamples;
|
||||
int count = 0;
|
||||
int npercent = 0;
|
||||
uint64_t percent5 = 0.05*m_nsamples;
|
||||
uint64_t count = 0;
|
||||
uint64_t npercent = 0;
|
||||
|
||||
for(int i=0; i<m_nsamples; i++) {
|
||||
if(++count == percent5) {//Show update every 5 percent
|
||||
for(uint64_t i=0; i<m_nsamples; i++)
|
||||
{
|
||||
if(++count == percent5)
|
||||
{
|
||||
npercent++;
|
||||
count = 0;
|
||||
std::cout<<"\rPercent complete: "<<npercent*5<<"%"<<std::flush;
|
||||
|
@ -311,10 +327,11 @@ namespace Mask {
|
|||
output.Close();
|
||||
}
|
||||
|
||||
void Kinematics::RunThreeStep() {
|
||||
void MaskApp::RunThreeStep() {
|
||||
|
||||
ThreeStepSystem* this_sys = dynamic_cast<ThreeStepSystem*>(sys);
|
||||
if(this_sys == nullptr) {
|
||||
if(this_sys == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -324,12 +341,14 @@ namespace Mask {
|
|||
output.WriteHeader(m_rxn_type, m_nsamples);
|
||||
|
||||
//For progress updating
|
||||
int percent5 = 0.05*m_nsamples;
|
||||
int count = 0;
|
||||
int npercent = 0;
|
||||
uint64_t percent5 = 0.05*m_nsamples;
|
||||
uint64_t count = 0;
|
||||
uint64_t npercent = 0;
|
||||
|
||||
for(int i=0; i<m_nsamples; i++) {
|
||||
if(++count == percent5) {//Show update every 5 percent
|
||||
for(uint64_t i=0; i<m_nsamples; i++)
|
||||
{
|
||||
if(++count == percent5)
|
||||
{
|
||||
npercent++;
|
||||
count = 0;
|
||||
std::cout<<"\rPercent complete: "<<npercent*5<<"%"<<std::flush;
|
100
src/MaskFile.cpp
100
src/MaskFile.cpp
|
@ -64,33 +64,45 @@ namespace Mask {
|
|||
file.close();
|
||||
}
|
||||
|
||||
void MaskFile::WriteHeader(int rxn_type, int nsamples) {
|
||||
//size of a datum = data nuclei per event * (# doubles per nucleus * sizeof double + # ints per nucleus * sizeof int + sizeof bool)
|
||||
if(rxn_type == 0) {
|
||||
m_rxn_type = 0;
|
||||
data_size = 3 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
}
|
||||
else if (rxn_type == 1) {
|
||||
m_rxn_type = 1;
|
||||
data_size = 4 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
}
|
||||
else if (rxn_type == 2) {
|
||||
m_rxn_type = 2;
|
||||
data_size = 6 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
}
|
||||
else if (rxn_type == 3) {
|
||||
m_rxn_type = 3;
|
||||
data_size = 8 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
} else {
|
||||
std::cerr<<"Invalid number of nuclei at MaskFile::WriteHeader! Returning"<<std::endl;
|
||||
return;
|
||||
void MaskFile::WriteHeader(RxnType rxn_type, int nsamples) {
|
||||
|
||||
m_rxn_type = rxn_type;
|
||||
switch(rxn_type)
|
||||
{
|
||||
case RxnType::PureDecay :
|
||||
{
|
||||
data_size = 3 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
break;
|
||||
}
|
||||
case RxnType::OneStepRxn :
|
||||
{
|
||||
data_size = 4 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
break;
|
||||
}
|
||||
case RxnType::TwoStepRxn :
|
||||
{
|
||||
data_size = 6 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
break;
|
||||
}
|
||||
case RxnType::ThreeStepRxn :
|
||||
{
|
||||
data_size = 8 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
break;
|
||||
}
|
||||
case RxnType::None :
|
||||
{
|
||||
std::cerr<<"Invalid RxnType at MaskFile::WriteHeader!"<<std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
buffersize_bytes = buffersize * data_size; //buffersize_bytes = # of events * size of an event
|
||||
|
||||
data_buffer.resize(buffersize_bytes);
|
||||
|
||||
uint32_t type_value = GetIntFromRxnType(m_rxn_type);
|
||||
file.write((char*) &nsamples, int_size);
|
||||
file.write((char*) &m_rxn_type, int_size);
|
||||
file.write((char*) &type_value, int_size);
|
||||
}
|
||||
|
||||
MaskFileHeader MaskFile::ReadHeader() {
|
||||
|
@ -99,24 +111,38 @@ namespace Mask {
|
|||
file.read(temp_buffer.data(), 4);
|
||||
header.nsamples = *(int*)(&temp_buffer[0]);
|
||||
file.read(temp_buffer.data(), 4);
|
||||
m_rxn_type = *(int*)(&temp_buffer[0]);
|
||||
uint32_t type_value = *(uint32_t*)(&temp_buffer[0]);
|
||||
m_rxn_type = GetRxnTypeFromInt(type_value);
|
||||
|
||||
//size of a datum = data nuclei per event * (# doubles per nucleus * sizeof double + # ints per nucleus * sizeof int + sizeof bool)
|
||||
if(m_rxn_type == 0) {
|
||||
data_size = 3 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
}
|
||||
else if (m_rxn_type == 1) {
|
||||
data_size = 4 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
}
|
||||
else if (m_rxn_type == 2) {
|
||||
data_size = 6 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
}
|
||||
else if (m_rxn_type == 3) {
|
||||
data_size = 8 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
} else {
|
||||
std::cerr<<"Unexpected reaction type at MaskFile::ReadHeader (rxn type = "<<m_rxn_type<<")! Returning"<<std::endl;
|
||||
return header;
|
||||
switch(m_rxn_type)
|
||||
{
|
||||
case RxnType::PureDecay:
|
||||
{
|
||||
data_size = 3 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
break;
|
||||
}
|
||||
case RxnType::OneStepRxn:
|
||||
{
|
||||
data_size = 4 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
break;
|
||||
}
|
||||
case RxnType::TwoStepRxn:
|
||||
{
|
||||
data_size = 6 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
break;
|
||||
}
|
||||
case RxnType::ThreeStepRxn:
|
||||
{
|
||||
data_size = 8 * ( 5 * double_size + 2 * int_size + bool_size);
|
||||
break;
|
||||
}
|
||||
case RxnType::None:
|
||||
{
|
||||
std::cerr<<"Unexpected reaction type at MaskFile::ReadHeader (rxn type = "<<GetIntFromRxnType(m_rxn_type)<<")! Returning"<<std::endl;
|
||||
return header;
|
||||
}
|
||||
}
|
||||
|
||||
buffersize_bytes = buffersize * data_size;//buffersize_bytes = size of a datum * # of events
|
||||
|
||||
header.rxn_type = m_rxn_type;
|
||||
|
|
|
@ -98,7 +98,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
Mask::MaskFileHeader header = input.ReadHeader();
|
||||
|
||||
std::cout<<"File Header -- rxn type: "<<header.rxn_type<<" nsamples: "<<header.nsamples<<std::endl;
|
||||
std::cout<<"File Header -- rxn type: "<<GetStringFromRxnType(header.rxn_type)<<" nsamples: "<<header.nsamples<<std::endl;
|
||||
|
||||
Mask::MaskFileData data;
|
||||
Mask::Nucleus nucleus;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <string>
|
||||
#include "Stopwatch.h"
|
||||
#include "MaskFile.h"
|
||||
#include "Kinematics.h"
|
||||
#include "MaskApp.h"
|
||||
#include "KinematicsExceptions.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
@ -13,7 +13,7 @@ int main(int argc, char** argv) {
|
|||
Stopwatch sw;
|
||||
|
||||
|
||||
Mask::Kinematics calculator;
|
||||
Mask::MaskApp calculator;
|
||||
sw.Start();
|
||||
try {
|
||||
if(!calculator.LoadConfig(argv[1])) {
|
||||
|
@ -33,7 +33,7 @@ int main(int argc, char** argv) {
|
|||
Mask::MaskFileData data;
|
||||
Mask::MaskFileHeader header = input.ReadHeader();
|
||||
|
||||
std::cout<<"Header Found -- rxn type: "<<header.rxn_type<<" nsamples: "<<header.nsamples;
|
||||
std::cout<<"Header Found -- rxn type: "<<GetStringFromRxnType(header.rxn_type)<<" nsamples: "<<header.nsamples;
|
||||
std::cout<<std::endl;
|
||||
|
||||
int counter=0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user