From e7b4f0c97e6ce6552c802c6af342fe2ab9506e3f Mon Sep 17 00:00:00 2001 From: mingf2 <fm140905@gmail.com> Date: Sun, 16 May 2021 13:52:26 -0500 Subject: [PATCH] update image in parallel --- CMakeLists.txt | 1 + Sources/CMakeLists.txt | 2 +- Sources/gui.cpp | 9 +++++---- Sources/main.cpp | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9925e4..a369d0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) # find_package(ROOT 6.22 CONFIG REQUIRED) find_package(ROOT 6.22 CONFIG REQUIRED COMPONENTS Gui) +find_package(OpenMP REQUIRED) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Headers) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 23fbc60..c00b499 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(gui SHARED gui.cpp) ROOT_GENERATE_DICTIONARY(G__gui ../Headers/gui.h LINKDEF ../Headers/guiLinkDef.h MODULE gui) -target_link_libraries(gui PUBLIC setup ROOT::Gpad ROOT::Gui) +target_link_libraries(gui PUBLIC setup ROOT::Gpad ROOT::Gui OpenMP::OpenMP_CXX) add_executable(main main.cpp) target_link_libraries(main PUBLIC setup simulation gui ROOT::Gpad ROOT::Gui) diff --git a/Sources/gui.cpp b/Sources/gui.cpp index 930df0d..7433a42 100644 --- a/Sources/gui.cpp +++ b/Sources/gui.cpp @@ -189,18 +189,19 @@ void MyMainFrame::addCone(const std::vector<Cone> cones){ // std::cout << "Projecting cones onto the designated spherical surface..."<<std::endl; double alpha(0); double beta(0); - for (const Cone& event : cones) + // for (const Cone& event : cones) + for (int k = 0; k < cones.size(); k++) { // update the image //TODO: add the uncertainty - alpha = event.cosHalfAngle; + alpha = cones[k].cosHalfAngle; + #pragma omp parallel for for (int i = 0; i < config->thetaBins; i++) { for (int j = 0; j < config->phiBins; j++) { - beta = getCosAngle(event.apex - config->xbs[i][j], event.axis); + double beta = getCosAngle(cones[k].apex - config->xbs[i][j], cones[k].axis); histo->SetBinContent(j+1, i+1, histo->GetBinContent(j+1, i+1) + std::exp(-(beta-alpha)*(beta-alpha) / 0.002)); - // histo->SetBinContent(j+1, i+1, std::exp(-(beta-alpha)*(beta-alpha) / 0.002)); } } } diff --git a/Sources/main.cpp b/Sources/main.cpp index 0943c99..8e11641 100644 --- a/Sources/main.cpp +++ b/Sources/main.cpp @@ -35,7 +35,7 @@ int main(int argc, char** argv) { // update image myMainFrame->addCone(cones); myMainFrame->counts += config->chuckSize; - std::cout << "Total counts: " << myMainFrame->counts << ". " << coneQueue->size_approx() << " events left in queue." << '\n'; + std::cout << "Total counts: " << myMainFrame->counts << ". \n"; } // gSystem->Sleep(100); -- GitLab