Skip to content
Snippets Groups Projects
Commit 31c69533 authored by Oliver Kirsebom's avatar Oliver Kirsebom
Browse files

sort executable

parent 1475f930
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ cotire/*
# Custom
vktest
vksort
*.pdf
*.png
......
......@@ -19,6 +19,8 @@ file(GLOB_RECURSE SOURCE "source/*.cpp")
add_library(vklib ${HEADERS} ${SOURCE} ${GIT_FILE})
add_executable(vksort sort.cpp ${HEADERS} ${SOURCE})
############################################
## Dependencies ##
......@@ -47,6 +49,7 @@ message (STATUS ${ROOT_INCLUDE_DIR})
# Add libraries to target
target_link_libraries(vklib ${LIBRARIES})
target_link_libraries(vksort vklib ${LIBRARIES})
#########################################
......@@ -79,3 +82,8 @@ INSTALL(TARGETS vklib
)
install(DIRECTORY include/vklib DESTINATION include)
INSTALL(TARGETS vksort
RUNTIME DESTINATION bin
)
......@@ -66,6 +66,7 @@ namespace VEIKONKONE {
std::unique_ptr<std::ifstream> file;
bool _eof;
std::string input;
bool first;
};
}
#endif //VK_RAW_READER_H
sort.cpp 0 → 100644
#include "vklib/VKSorter.h"
#include "vklib/VKRawReader.h"
#include <ausa/util/memory>
#include <string>
#include <iostream>
#include <memory>
#include <TSystem.h>
#include <TSystemDirectory.h>
using namespace std;
using namespace VEIKONKONE;
string datadir = "/home/oliskir/Desktop/f20/data/";
void findFiles(int run, vector<string>& input);
// syntax: ./vksort <Run> [Window]
int main( int argc, char* argv[] ){
// run number
int run = atoi(argv[1]);
// coincidence window
double window = 30;
if (argc == 3) window = atof(argv[2]);
vector<string> input;
findFiles(run, input);
vector<shared_ptr<VKRawReader>> readers;
for (auto& i : input) {
auto r = make_shared<VKRawReader> (i);
readers.emplace_back(move(r));
}
string output = Form("%ssorted/new/s%04d_000.root", datadir.data(), run);
auto sorter = make_unique<VKSorter>(readers, output, window);
// SIGNAL energy calibration
double a0 = 30.0, a1 = 1.252, a2 = 0;
sorter->setCalibration(0, a0, a1, a2);
sorter->run();
return 0;
}
void findFiles(int run, vector<string>& input)
{
TString path = datadir + "raw/";
TSystemDirectory dir(path, path);
TList *files = dir.GetListOfFiles();
if (files) {
TSystemFile *file;
TString fname;
TIter next(files);
while ((file = (TSystemFile*)next())) {
fname = file->GetName();
if (!file->IsDirectory()) {
if (fname.EndsWith(Form("%04d_ch000.txt", run))) {
input.push_back(fname.Data());
}
else if (fname.EndsWith(Form("%04d_ch001.txt", run))) {
input.push_back(fname.Data());
}
else if (fname.EndsWith(Form("%04d_ch002.txt", run))) {
input.push_back(fname.Data());
}
}
}
}
for (auto& i : input) i = datadir + "raw/" + i;
}
......@@ -11,7 +11,8 @@ using namespace VEIKONKONE;
VKRawReader::VKRawReader(string input)
: input(input)
: input(input),
first(true)
{
reset();
}
......@@ -69,4 +70,9 @@ void VKRawReader::reset()
file = make_unique<ifstream> (input.c_str());
if (!file->good())
throw invalid_argument("Unable to find input file " + input);
if (first) {
cout << "Reading from: " << input << endl;
first = false;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment