Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
flagarde committed Feb 22, 2024
1 parent a90acc3 commit ef10ded
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ option(BUILD_EXAMPLES "Build the examples" TRUE)
option(BUILD_EXTRAS "Build the extras" TRUE)
# Compiling ROOT can be very long so :

option(BUILD_ROOT "Build ROOT Folder" ON)
#option(BUILD_ROOT "Build ROOT Folder" ON)

option(BUILD_ANALYSIS "Build the Analysis code" ON)
option(BUILD_WEBSOCKETSERVER "Build the WebSocket Server" ON)
Expand Down
8 changes: 6 additions & 2 deletions apps/DAQ/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if(BUILD_ROOT)

include(ROOT)

root_generate_dictionary(G__Channel "include/Channel.hpp" LINKDEF "include/ChannelLinkDef.hpp" ${STAGE1})
Expand Down Expand Up @@ -33,8 +33,12 @@ if(BUILD_ROOT)
add_executable(DAQFileWritter DAQFileWritter.cpp)
target_link_libraries(DAQFileWritter PRIVATE DAQFile PRIVATE FileWritter PRIVATE CLI11 PRIVATE ProgramInfos PUBLIC GeneralParameters)
install(TARGETS DAQFileWritter)
endif()

add_executable(Digitizer Digitizer.cpp)
target_link_libraries(Digitizer PRIVATE CAENBoards PRIVATE Board PRIVATE CLI11 PRIVATE ProgramInfos PUBLIC GeneralParameters)
install(TARGETS Digitizer)


add_executable(Viewer Viewer.cpp)
target_link_libraries(Viewer PUBLIC CAENBoards ROOT::Core ROOT::Hist ROOT::Tree ROOT::Graf ROOT::Gpad Board CLI11 ProgramInfos GeneralParameters)
install(TARGETS Viewer)
157 changes: 157 additions & 0 deletions apps/DAQ/Viewer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#include "CAENDigitizerBoard.hpp"
#include "CLI/CLI.hpp"
#include "ProgramInfos.hpp"
#include "TApplication.h"
#include "TCanvas.h"
#include "TF1.h"
#include "TH1F.h"
#include "TRootCanvas.h"
#include "Module.hpp"
#include "TGraph.h"

#include "nlohmann/json.hpp"

namespace yaodaq
{

class Viewer : public Module
{
public:
Viewer(const std::string& name, const std::string& type,int argc, char** argv): Module(name,type,yaodaq::CLASS::Logger),apps("apps", &argc, argv)
{
skipConfigFile();
int x{2540/9};
int y{1400/4};
for(std::size_t j=0;j!=4;++j)
{
for(std::size_t i=0;i!=9;++i)
{
m_TCanvas.push_back(new TCanvas("","",x*i,j*y,x,y));
}
}
}
virtual ~Viewer()
{
}
virtual void onData(const Data& data)
{
Json::Value json = data.getContentAsJson();

/*m_Event->BoardID = json["EventInfos"]["BoardID"].asDouble();
m_Event->EventNumber = json["EventInfos"]["EventCounter"].asInt();
m_Event->Pattern = json["EventInfos"]["Pattern"].asInt();
m_Event->ChannelMask = json["EventInfos"]["ChannelMask"].asInt();
m_Event->EventSize = json["EventInfos"]["EventSize"].asDouble();
m_Event->TriggerTimeTag = json["EventInfos"]["TriggerTimeTag"].asDouble();
m_Event->Period_ns = json["EventInfos"]["Period_ns"].asDouble();
m_Event->Model = json["EventInfos"]["Model"].asString();
m_Event->FamilyCode = json["EventInfos"]["FamilyCode"].asString();*/
for(int i = 0; i != json["Event"]["Groups"].size(); ++i)
{
for(int j = 0; j != json["Event"]["Groups"][i]["Channels"].size(); ++j)
{
std::string title{"Event "+json["EventInfos"]["EventCounter"].asString()+" Channel "+std::to_string(i*9+j)};
int nbr_bins{json["Event"]["Groups"][i]["Channels"][j]["Data"].size()};
double max{json["Event"]["Groups"][i]["Channels"][j]["Data"].size()};
//TH1F* toto = new TH1F(title.c_str(),title.c_str(),nbr_bins, 0,max);
TH1F* th = new TH1F(title.c_str(),title.c_str(),nbr_bins, 0,max);
for(int k = 0; k != json["Event"]["Groups"][i]["Channels"][j]["Data"].size(); ++k)
{
th->AddBinContent(k,json["Event"]["Groups"][i]["Channels"][j]["Data"][k].asDouble());
//channel.Data.push_back(json["Event"]["Groups"][i]["Channels"][j]["Data"][k].asDouble());
}
m_TCanvas[i*9+j]->cd();
m_TCanvas[i*9+j]->Clear();
if(j==8) th->SetLineColor(kRed);
th->Draw();
m_TCanvas[i*9+j]->Modified();
m_TCanvas[i*9+j]->Update();
delete th;
}
}

/*for(std::size_t i=0;i!=m_TH1Fs.size();++i)
{
c->cd(i+1);
m_TH1Fs[i]->Draw();
//c->Modified();
//c->Update();
}
for(std::size_t i=0;i!=m_TH1Fs.size();++i)
{
m_TH1Fs[i]->Clear();
//c->Modified();
//c->Update();
}*/

/*TF1 *f1 = new TF1("f1","sin(x)", -5, 5);
f1->SetLineColor(kBlue+1);
f1->SetTitle("My graph;x; sin(x)");
f1->Draw();*/

//TRootCanvas *rc = (TRootCanvas *)c->GetCanvasImp();
//rc->Connect("CloseWindow()", "TApplication", gApplication, "Terminate()");
//delete rc;
//delete f1;
//apps.Run();
}
bool getApp(){
start();
apps.Run();}
private:
TApplication apps;
std::vector<TCanvas*> m_TCanvas;
//std::vector<TH1F*> m_TH1Fs;
};

}

using namespace yaodaq;

int main(int argc, char** argv)
{
ProgramInfos infos;
infos.Logo();
CLI::App app{"Digitizer"};
int port{yaodaq::GeneralParameters::getPort()};
app.add_option("-p,--port", port, "Port to listen")->check(CLI::Range(0, 65535));
std::string host{yaodaq::GeneralParameters::getHost()};
app.add_option("-i,--ip", host, "IP of the server")->check(CLI::ValidIPV4);
std::string name = "Viewer";
app.add_option("-n,--name", name, "Name of the mode")
->check(
[](const std::string& t) {
if(t == "") return "Name is empty";
else
return "";
},
"Not Empty", "Test is name is empty");
std::string verbosity{"trace"};
app.add_option("-v,--verbosity", verbosity, "Verbosity")->check(
[](const std::string& t) {
if(t != "off" && t != "trace" && t != "info" && t != "debug" && t != "warning" && t != "critical") return "Wrong verbosity level";
else
return "";
},
"Verbosity level", "Verbosity level");
try
{
app.parse(argc, argv);
}
catch(const CLI::ParseError& e)
{
spdlog::error("{}", e.what());
return e.get_exit_code();
}

GeneralParameters::setPort(port);
GeneralParameters::setHost(host);

Viewer viewer(name,"Default",argc,argv);
viewer.setVerbosity(verbosity);


viewer.getApp();
}
2 changes: 2 additions & 0 deletions extras/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include(IterateFolder)

add_subdirectory(ROOT)

sub_dir_list(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})

foreach(subdir ${SUBDIRS})
Expand Down
2 changes: 1 addition & 1 deletion src/Configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace yaodaq

Configurator::Configurator(const std::string& name) : Module(name,"Configurator",CLASS::Configurator)
{
m_session.open(soci::mysql, "");
//m_session.open(soci::mysql, "");
}

}

0 comments on commit ef10ded

Please sign in to comment.