mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-16 17:27:14 +02:00
pedestal (#67)
* add config files for multimodule receiving * read subfiles with unordered and missing frames * save work debugging * Revert "save work debugging" This reverts commite791992a05
. * Revert "read subfiles with unordered and missing frames" This reverts commit1177fd129d
. * throw when two frames have different frame numbers * write single part RawFile (working beta) * correct total number of frames in master file * add new mythen file with syncd frames * save work * save work for receive multimodule multimodule config results in too much packet loss. needs more debugging. * setup Task Distributiosn/ parallelization programming model * read frames with same frame number * clang-tidy fixes, formatting, add tests * added second receiver * Synchronize between zmq streams and merge frames * improve readability in loop * fix failing tests * add simple test for merge frames * restructure files and use top-level header * working pedestal + tests * test_pedestal statistics * QA test pedestal, fix clang-tidy errors --------- Co-authored-by: Bechir <bechir.brahem420@gmail.com> Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com>
This commit is contained in:
@ -2,10 +2,12 @@
|
||||
set(EXAMPLE_LIST "json_example;logger_example;numpy_read_example;multiport_example;raw_example;zmq_restream_example")
|
||||
set(EXAMPLE_LIST "${EXAMPLE_LIST};mythen_example;numpy_write_example;zmq_receiver_example;zmq_sender_example;")
|
||||
set(EXAMPLE_LIST "${EXAMPLE_LIST};cluster_example;zmq_multi_receiver;zmq_task_ventilator;zmq_worker;zmq_sink")
|
||||
set(EXAMPLE_LIST "${EXAMPLE_LIST};testing_pedestal;")
|
||||
|
||||
foreach(example ${EXAMPLE_LIST})
|
||||
add_executable(${example} ${example}.cpp)
|
||||
target_include_directories(${example} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_link_libraries(${example} PUBLIC aare PRIVATE aare_compiler_flags libzmq)
|
||||
target_link_libraries(${example} PUBLIC aare PRIVATE aare_compiler_flags libzmq )
|
||||
endforeach()
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "aare/core/defs.hpp"
|
||||
#include "aare/file_io/ClusterFile.hpp"
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Your First C++ Program
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
#include "aare/file_io/File.hpp"
|
||||
#include "aare/utils/logger.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using aare::File;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
#include "aare/utils/logger.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
@ -1,7 +1,5 @@
|
||||
// Your First C++ Program
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
#include "aare/file_io/File.hpp"
|
||||
#include "aare/utils/logger.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
// Your First C++ Program
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
#include "aare/file_io/File.hpp"
|
||||
#include "aare/utils/logger.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
// Your First C++ Program
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
#include "aare/file_io/File.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
// Your First C++ Program
|
||||
#include "aare/core/Frame.hpp"
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
#include "aare/file_io/File.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Your First C++ Program
|
||||
#include "aare/aare.hpp"
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace aare;
|
||||
|
112
examples/testing_pedestal.cpp
Normal file
112
examples/testing_pedestal.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
#include "aare.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace aare;
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <numeric>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
|
||||
void print_vpair(std::vector<std::pair<int, double>> &v) {
|
||||
std::cout << "[ ";
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
std::cout << "(" << v[i].first << "," << v[i].second << "), ";
|
||||
}
|
||||
std::cout << "]" << std::endl;
|
||||
}
|
||||
int range(int min, int max, int i, int steps) { return min + (max - min) * i / steps; }
|
||||
int main() {
|
||||
const int rows = 1, cols = 1;
|
||||
double MEAN = 5.0, STD = 1.0, VAR = STD * STD, TOLERANCE = 0.1;
|
||||
|
||||
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
|
||||
std::default_random_engine generator(seed);
|
||||
std::normal_distribution<double> distribution(MEAN, STD);
|
||||
|
||||
Pedestal pedestal(rows, cols, 1000);
|
||||
std::vector<double> values;
|
||||
std::vector<double> vmean, vvariance, pmean, pvariance, pstandard_deviation;
|
||||
std::vector<int> samples;
|
||||
std::vector<std::pair<int, double>> cur_mean, cur_variance;
|
||||
|
||||
// int steps = 1000;
|
||||
// for (int n_iters = 0; n_iters < steps; n_iters++) {
|
||||
// int x=range(1000, 1000000, n_iters,steps);
|
||||
// std::cout<<x<<std::endl;
|
||||
|
||||
// for (int i = 0; i < x; i++) {
|
||||
// Frame frame(rows, cols, 64);
|
||||
// for (int j = 0; j < rows; j++)
|
||||
// for (int k = 0; k < cols; k++) {
|
||||
// double val = distribution(generator);
|
||||
// frame.set<double>(j, k, val);
|
||||
// }
|
||||
// pedestal.push<double>(frame);
|
||||
// }
|
||||
// pmean.push_back({x, pedestal.mean(0, 0)});
|
||||
// pvariance.push_back({x, pedestal.variance(0, 0)});
|
||||
// }
|
||||
|
||||
long double sum = 0;
|
||||
long double sum2 = 0;
|
||||
// fill 1000 first values of pedestal
|
||||
for (int x = 0; x < 1000; x++) {
|
||||
Frame frame(rows, cols, 64);
|
||||
double val = distribution(generator);
|
||||
frame.set<double>(0, 0, val);
|
||||
pedestal.push<double>(frame);
|
||||
values.push_back(val);
|
||||
sum += val;
|
||||
sum2 += val * val;
|
||||
}
|
||||
|
||||
for (int x = 0, aa = 0; x < 100000; x++, aa++) {
|
||||
Frame frame(rows, cols, 64);
|
||||
double val = distribution(generator);
|
||||
frame.set<double>(0, 0, val);
|
||||
pedestal.push<double>(frame);
|
||||
|
||||
values.push_back(val);
|
||||
auto old_val = values[values.size() - 1000 - 1];
|
||||
sum += val - old_val;
|
||||
sum2 += val * val - old_val * old_val;
|
||||
if (aa % 100 == 1) {
|
||||
aa = 2;
|
||||
samples.push_back(x);
|
||||
vmean.push_back(sum / 1000);
|
||||
vvariance.push_back(sum2 / (1000) - (sum / (1000)) * (sum / (1000)));
|
||||
pmean.push_back(pedestal.mean(0, 0));
|
||||
pvariance.push_back(pedestal.variance(0, 0));
|
||||
}
|
||||
if (x % 1000 == 999) {
|
||||
MEAN *= 1.1;
|
||||
STD *= 1.1;
|
||||
|
||||
distribution.param(std::normal_distribution<double>::param_type(MEAN, STD));
|
||||
cur_mean.push_back({x, MEAN});
|
||||
cur_variance.push_back({x, STD * STD});
|
||||
}
|
||||
}
|
||||
|
||||
logger::info("x6=", samples);
|
||||
logger::info("pmean6=", pmean);
|
||||
logger::info("pvar6=", pvariance);
|
||||
logger::info("vmean6=", vmean);
|
||||
logger::info("vvar6=", vvariance);
|
||||
std::cout << "cur_mean6=";
|
||||
print_vpair(cur_mean);
|
||||
std::cout << "cur_variance6=";
|
||||
print_vpair(cur_variance);
|
||||
|
||||
// std::cout << "PEDESTAL" << std::endl;
|
||||
// std::cout << "Mean: " << pmean(0, 0) << std::endl;
|
||||
// std::cout << "Variance: " << pvariance(0, 0) << std::endl;
|
||||
// std::cout << "Standard Deviation: " << pstandard_deviation(0, 0) << std::endl;
|
||||
|
||||
// std::cout << "VALUES" << std::endl;
|
||||
// std::cout << "Mean: " << std::accumulate(values.begin(), values.end(), 0.0) / values.size() << std::endl;
|
||||
// std::cout << "Variance: " << variance<double>(values) << std::endl;
|
||||
// std::cout << "Standard Deviation: " << std::sqrt(variance<double>(values)) << std::endl;
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
#include "aare/network_io/ZmqMultiReceiver.hpp"
|
||||
#include "aare/network_io/ZmqSocketReceiver.hpp"
|
||||
#include "aare/network_io/defs.hpp"
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <cassert>
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
#include "aare/network_io/ZmqSocketReceiver.hpp"
|
||||
#include "aare/network_io/defs.hpp"
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <cassert>
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "aare/file_io/File.hpp"
|
||||
#include "aare/network_io/ZmqSocketSender.hpp"
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
using namespace aare;
|
||||
using namespace std;
|
||||
|
@ -1,9 +1,5 @@
|
||||
#include "aare/core/Frame.hpp"
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
#include "aare/network_io/ZmqHeader.hpp"
|
||||
#include "aare/network_io/ZmqSocketSender.hpp"
|
||||
#include "aare/network_io/defs.hpp"
|
||||
#include "aare/utils/logger.hpp"
|
||||
|
||||
#include <ctime> // std::time
|
||||
#include <fmt/core.h>
|
||||
|
@ -1,8 +1,5 @@
|
||||
|
||||
#include "aare/network_io/ZmqSink.hpp"
|
||||
#include "aare/network_io/ZmqSocketReceiver.hpp"
|
||||
#include "aare/network_io/ZmqVentilator.hpp"
|
||||
#include "aare/network_io/ZmqWorker.hpp"
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
|
||||
#include "zmq.h"
|
||||
#include <boost/program_options.hpp>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "aare/network_io/ZmqSocketReceiver.hpp"
|
||||
#include "aare/network_io/ZmqVentilator.hpp"
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
|
||||
#include "zmq.h"
|
||||
#include <boost/program_options.hpp>
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
#include "aare/network_io/ZmqSink.hpp"
|
||||
#include "aare/network_io/ZmqSocketReceiver.hpp"
|
||||
#include "aare/network_io/ZmqVentilator.hpp"
|
||||
#include "aare/network_io/ZmqWorker.hpp"
|
||||
#include "aare.hpp"
|
||||
#include "aare/examples/defs.hpp"
|
||||
|
||||
#include "zmq.h"
|
||||
#include <boost/program_options.hpp>
|
||||
|
Reference in New Issue
Block a user