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