1
0
Fork 0
mirror of https://github.com/gwm17/Mask.git synced 2024-11-22 10:18:50 -05:00

Update gitignore. Cleanup DetectorApp

This commit is contained in:
Gordon McCann 2023-05-26 14:45:30 -04:00
parent 49b54af286
commit 47d84e8dca
4 changed files with 6 additions and 73 deletions

1
.gitignore vendored
View File

@ -19,6 +19,7 @@ build/
lib/ lib/
bin/ bin/
scripts/ scripts/
*.yaml
###Keep this file### ###Keep this file###

View File

@ -15,7 +15,7 @@ DetectorApp::~DetectorApp()
delete m_detectorList[i]; delete m_detectorList[i];
} }
bool DetectorApp::ParseConfig(const std::string& filename) bool DetectorApp::LoadConfig(const std::string& filename)
{ {
std::cout<<"----------Detector Efficiency Calculation----------"<<std::endl; std::cout<<"----------Detector Efficiency Calculation----------"<<std::endl;
YAML::Node data; YAML::Node data;
@ -35,18 +35,14 @@ bool DetectorApp::ParseConfig(const std::string& filename)
m_nthreads = data["NumberOfThreads"].as<uint64_t>(); m_nthreads = data["NumberOfThreads"].as<uint64_t>();
ArrayType type = StringToArrayType(data["ArrayType"].as<std::string>()); ArrayType type = StringToArrayType(data["ArrayType"].as<std::string>());
std::cout << "Creating " << m_nthreads << " detector arrays..." << std::endl;
for(uint64_t i=0; i<m_nthreads; i++) for(uint64_t i=0; i<m_nthreads; i++)
{ {
m_detectorList.push_back(CreateDetectorArray(type)); m_detectorList.push_back(CreateDetectorArray(type));
if(m_deadChannelFileName != "None") if(m_deadChannelFileName != "None")
m_detectorList.back()->SetDeadChannelMap(m_deadChannelFileName); m_detectorList.back()->SetDeadChannelMap(m_deadChannelFileName);
} }
std::cout << "Allocating " << m_nthreads << " threads..." << std::endl;
m_resources = std::make_unique<Mask::ThreadPool<DetectorArray*, uint64_t>>(m_nthreads); m_resources = std::make_unique<Mask::ThreadPool<DetectorArray*, uint64_t>>(m_nthreads);
std::cout << "Opening input data file " << m_inputFileName << "..." << std::endl;
m_fileReader.Open(m_inputFileName, "SimTree"); m_fileReader.Open(m_inputFileName, "SimTree");
if(!m_fileReader.IsOpen() || !m_fileReader.IsTree()) if(!m_fileReader.IsOpen() || !m_fileReader.IsTree())
{ {
@ -54,7 +50,6 @@ bool DetectorApp::ParseConfig(const std::string& filename)
return false; return false;
} }
m_nentries = m_fileReader.GetSize(); m_nentries = m_fileReader.GetSize();
std::cout << "Detected " << m_nentries << " events in the file..." << std::endl;
//Little bit of integer division mangling to make sure we read every event in file //Little bit of integer division mangling to make sure we read every event in file
uint64_t quotient = m_nentries / m_nthreads; uint64_t quotient = m_nentries / m_nthreads;
@ -63,7 +58,6 @@ bool DetectorApp::ParseConfig(const std::string& filename)
for(uint64_t i=1; i<m_nthreads; i++) for(uint64_t i=1; i<m_nthreads; i++)
m_chunkSamples.push_back(quotient); m_chunkSamples.push_back(quotient);
std::cout << "Opening output data file " << m_outputFileName << std::endl;
m_fileWriter.Open(m_outputFileName, "SimTree"); m_fileWriter.Open(m_outputFileName, "SimTree");
if(!m_fileWriter.IsOpen() || !m_fileWriter.IsTree()) if(!m_fileWriter.IsOpen() || !m_fileWriter.IsTree())
{ {
@ -71,71 +65,10 @@ bool DetectorApp::ParseConfig(const std::string& filename)
return false; return false;
} }
return true;
}
bool DetectorApp::LoadConfig(const std::string& filename)
{
std::cout<<"----------Detector Efficiency Calculation----------"<<std::endl;
std::ifstream input(filename);
if(!input.is_open())
{
std::cerr<<"Unable to open input config file "<<filename<<std::endl;
return false;
}
std::string junk;
std::string typeName;
input >> junk >> m_inputFileName;
input >> junk >> m_outputFileName;
input >> junk >> m_deadChannelFileName;
input >> junk >> m_nthreads;
input >> junk >> typeName;
std::cout << "Creating " << m_nthreads << " detector arrays..." << std::endl;
ArrayType type = StringToArrayType(typeName);
for(uint64_t i=0; i<m_nthreads; i++)
{
m_detectorList.push_back(CreateDetectorArray(type));
if(m_deadChannelFileName != "None")
m_detectorList.back()->SetDeadChannelMap(m_deadChannelFileName);
}
std::cout << "Done" << std::endl;
std::cout << "Allocating " << m_nthreads << " threads..." << std::endl; std::cout << "Allocating " << m_nthreads << " threads..." << std::endl;
m_resources = std::make_unique<Mask::ThreadPool<DetectorArray*, uint64_t>>(m_nthreads); std::cout << "Input data file " << m_inputFileName << "..." << std::endl;
std::cout << "Done" << std::endl; std::cout << "With " << m_nentries << " events in the file..." << std::endl;
std::cout << "Output data file " << m_outputFileName << "..." << std::endl;
std::cout << "Opening input data file " << m_inputFileName << "..." << std::endl;
m_fileReader.Open(m_inputFileName, "SimTree");
if(!m_fileReader.IsOpen() || !m_fileReader.IsTree())
{
std::cerr << "Unable to open input data file " << m_inputFileName << std::endl;
return false;
}
m_nentries = m_fileReader.GetSize();
std::cout << "Done. Detected " << m_nentries << " events in the file." << std::endl;
//Little bit of integer division mangling to make sure we read every event in file
uint64_t quotient = m_nentries / m_nthreads;
uint64_t remainder = m_nentries % m_nthreads;
m_chunkSamples.push_back(quotient + remainder);
for(uint64_t i=1; i<m_nthreads; i++)
m_chunkSamples.push_back(quotient);
std::cout << "Opening output data file " << m_outputFileName << std::endl;
m_fileWriter.Open(m_outputFileName, "SimTree");
if(!m_fileWriter.IsOpen() || !m_fileWriter.IsTree())
{
std::cerr << "Unable to open output data file " << m_outputFileName << std::endl;
return false;
}
std::cout << "Done" << std::endl;
std::cout << "Ready to launch!" << std::endl;
return true; return true;
} }

View File

@ -17,7 +17,6 @@ public:
~DetectorApp(); ~DetectorApp();
bool LoadConfig(const std::string& filename); bool LoadConfig(const std::string& filename);
bool ParseConfig(const std::string& filename);
void Run(); void Run();

View File

@ -21,7 +21,7 @@ int main(int argc, char** argv)
try try
{ {
DetectorApp app; DetectorApp app;
if(!app.ParseConfig(argv[1])) if(!app.LoadConfig(argv[1]))
{ {
std::cerr << "Unable to load config file " << argv[1] << ". Shutting down." << std::endl; std::cerr << "Unable to load config file " << argv[1] << ". Shutting down." << std::endl;
return 1; return 1;