Commit 8798a85f authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Merge branch 'Histogramer' into 'preprod'

Histogramer

See merge request IPNL_GAMMA/narval_emulator!30
parents d7165edf dc1c1178
#----------------------------------------------------------------------------
# Search Narval : Only if WITH_NARVAL is given
#
......@@ -16,6 +15,7 @@ if (EXISTS ${WITH_NARVAL}/narval_install)
else()
MESSAGE("[AGAPRO] Narval has not been found on this machine")
endif()
#----------------------------------------------------------------------------
if (DCOD_FOUND)
......
#define MAX_TH1BINS 4096
#define MAX_TH2BINS 1024
#define MAX_TH1HISTS 79
#define MAX_TH2HISTS 1
#define MAX_CHAR_SIZE 200
struct Hist
{
Int_t nevts = 0;
Int_t spec_number = 0;
Float_t xbinmin = -1;
Float_t xbinmax = -1;
Int_t xnbins = -1;
char name[MAX_CHAR_SIZE];
char title[MAX_CHAR_SIZE];
char xtitle[MAX_CHAR_SIZE];
char gruname[MAX_CHAR_SIZE];
};
struct Hist1F : Hist
{
Float_t bins[(MAX_TH1BINS+2)]; // +2 for underflow and overflow bins
};
struct Hist2F : Hist
{
Float_t ybinmin = -1;
Float_t ybinmax = -1;
Int_t ynbins = -1;
Float_t bins[(MAX_TH2BINS+2)*(MAX_TH2BINS+2)]; // +2 for underflow and overflow bins
char ytitle[MAX_CHAR_SIZE];
};
struct ActorMap
{
int N_TH1_Entries = 0; // number of 1d histograms
int N_TH2_Entries = 0; // number of 2d histograms
Hist1F hist1f_list[MAX_TH1HISTS];
Hist2F hist2f_list[MAX_TH2HISTS];
};
......@@ -372,8 +372,6 @@ ActorMap *Histogramer::CreateNewSMz(const char *name, Int_t Size, Int_t PortNumb
// create a new Transport Layer
SMZ.str("");
Float_t RefreshTimeInSec = 2.0;
SMZ << "curl http://localhost:8765/TLs --data-binary '{";
SMZ << "\"name\":\"source_" << name << "\", ";
SMZ << "\"buffer_name\":\"" << name << "\", ";
......@@ -382,7 +380,7 @@ ActorMap *Histogramer::CreateNewSMz(const char *name, Int_t Size, Int_t PortNumb
SMZ << "\"size\":" << Size << ", ";
SMZ << "\"unit\":\"Bytes\", ";
SMZ << "\"plugin_name\":\"source_smz_updater\",";
SMZ << "\"period\":" << std::fixed << std::setprecision(1) << RefreshTimeInSec << ", ";
SMZ << "\"period\":" << std::fixed << std::setprecision(1) << fRefreshTime << ", ";
SMZ << "\"port\":" << PortNumber << ", ";
SMZ << "\"log_level\":\"debug\"}'";
SMZ << " -H \"Content-Type: application/json\" -X POST ";
......
......@@ -26,6 +26,8 @@
#include "Trigger.h"
#include "CycleServer.h"
#include "AGAPRO_HistoDefs.h"
using namespace std;
//! Post preprocessing histogramer
......@@ -34,51 +36,6 @@ using namespace std;
namespace AGAPRO {
#define MAX_TH1BINS 4096
#define MAX_TH2BINS 1024
#define MAX_TH1HISTS 79
#define MAX_TH2HISTS 1
#define MAX_CHAR_SIZE 200
struct Hist
{
Int_t nevts = 0;
Int_t spec_number = 0;
Float_t xbinmin = -1;
Float_t xbinmax = -1;
Int_t xnbins = -1;
char name[MAX_CHAR_SIZE];
char title[MAX_CHAR_SIZE];
char xtitle[MAX_CHAR_SIZE];
char gruname[MAX_CHAR_SIZE];
};
struct Hist1F : Hist
{
Float_t bins[(MAX_TH1BINS+2)]; // +2 for underflow and overflow bins
};
struct Hist2F : Hist
{
Float_t ybinmin = -1;
Float_t ybinmax = -1;
Int_t ynbins = -1;
Float_t bins[(MAX_TH2BINS+2)*(MAX_TH2BINS+2)]; // +2 for underflow and overflow bins
char ytitle[MAX_CHAR_SIZE];
};
struct ActorMap
{
int N_TH1_Entries = 0; // number of 1d histograms
int N_TH2_Entries = 0; // number of 2d histograms
Hist1F hist1f_list[MAX_TH1HISTS];
Hist2F hist2f_list[MAX_TH2HISTS];
};
struct binning_TH1{
Int_t NBins;
Float_t Min;
......@@ -116,6 +73,8 @@ protected:
Int_t fBasePortNumber;
Float_t fRefreshTime = 2.0;
public:
static std::string gMotherClass; //! Static string containing the name of the base class
......
......@@ -103,6 +103,9 @@ UInt_t PreproHist::Process()
{
for(int nn = 0; nn < kNSG; nn++)
{
if(SegE[nn]<1)
continue;
auto hist = (Hist1F*)Amplilist[nn];
FillHist1F(hist,SegE[nn]);
......@@ -306,6 +309,8 @@ UInt_t PreproHist::GetParameters(const std::string& confFile, Bool_t doList)
ConfReader conf;
conf.Add("Crystal", "Crystal name"
, &crystal_name);
conf.Add("RefreshTime", "Refresh time of the Shared Memory Zone (in seconds)"
, &fRefreshTime);
conf.Add("PlotAmpli", "Binning of the amplitude spectra"
, &fAmpliBinning.NBins, &fAmpliBinning.Min, &fAmpliBinning.Max);
conf.Add("PlotAmplivsSegId", "Binning of the E_vs_id matrice"
......@@ -326,6 +331,9 @@ UInt_t PreproHist::GetParameters(const std::string& confFile, Bool_t doList)
if(fAmplivsIdBinning.NBinsX>0) fPlotAmplivsId = true;
if(fBaselineBinning.NBins>0) fPlotBaseline = true;
// To randomize the refresh time among the different crystals
fRefreshTime = fRefreshTime - 0.5 + ((double) rand() / (RAND_MAX));
return rv;
}
......@@ -358,7 +366,7 @@ void PreproHist::InitSMZ(Int_t id)
{
Name<<"Prepro_Ampli_Cry" << id << "_Seg" << i;
Title<<"Prepro_Ampli_Cry"<<CrystalName.data()<<"_Seg"<<GetSegmentNameFromID(i).data();
XTitle<<"Raw Amplitude (channels)";
XTitle<<"Energy (keV)";
GruName<<"Prepro/Ampli/Cry"<<CrystalName.data();
Hist1F *hist1F = NewHist1F(Name.str(),Title.str(),XTitle.str(),GruName.str(),fAmpliBinning.NBins,fAmpliBinning.Min,fAmpliBinning.Max,map_ptr,PortNumber);
......@@ -369,7 +377,7 @@ void PreproHist::InitSMZ(Int_t id)
{
Name<<"Prepro_Ampli_Cry" << id << "_Core" << i;
Title<<"Prepro_Ampli_Cry"<<CrystalName.data()<<"_"<<GetCoreNameFromID(i).data();
XTitle<<"Raw Amplitude (channels)";
XTitle<<"Energy (keV)";
GruName<<"Prepro/Ampli/Cry"<<CrystalName.data();
Hist1F *hist1F = NewHist1F(Name.str(),Title.str(),XTitle.str(),GruName.str(),fAmpliBinning.NBins,fAmpliBinning.Min,fAmpliBinning.Max,map_ptr,PortNumber);
......@@ -381,7 +389,7 @@ void PreproHist::InitSMZ(Int_t id)
{
Name<<"Prepro_Ampli_vs_SegId_Cry" << id;
Title<<"Prepro_Ampli_vs_SegId_Cry"<<CrystalName.data();
XTitle<<"Raw Amplitude (channels)";
XTitle<<"Energy (keV)";
YTitle<<"[0;36]: Segment Id ; 37: Core HG ; 38: Core LG)";
GruName<<"Prepro/Ampli_vs_SegId/Cry"<<CrystalName.data();
......@@ -402,7 +410,7 @@ void PreproHist::InitSMZ(Int_t id)
{
Name<<"Prepro_Baseline_Cry" << id << "_Seg" << i;
Title<<"Prepro_Baseline_Cry"<<CrystalName.data()<<"_Seg"<<GetSegmentNameFromID(i).data();
XTitle<<"Raw Amplitude (channels)";
XTitle<<"Corrected Amplitude";
GruName<<"Prepro/Baseline/Cry"<<CrystalName.data();
Hist1F *hist1F = NewHist1F(Name.str(),Title.str(),XTitle.str(),GruName.str(),fBaselineBinning.NBins,fBaselineBinning.Min,fBaselineBinning.Max,map_ptr,PortNumber);
......@@ -413,7 +421,7 @@ void PreproHist::InitSMZ(Int_t id)
{
Name<<"Prepro_Baseline_Cry" << id << "_Core" << i;
Title<<"Prepro_Baseline_Cry"<<CrystalName.data()<<"_"<<GetCoreNameFromID(i).data();
XTitle<<"Raw Amplitude (channels)";
XTitle<<"Corrected Amplitude";
GruName<<"Prepro/Baseline/Cry"<<CrystalName.data();
Hist1F *hist1F = NewHist1F(Name.str(),Title.str(),XTitle.str(),GruName.str(),fBaselineBinning.NBins,fBaselineBinning.Min,fBaselineBinning.Max,map_ptr,PortNumber);
......
......@@ -109,6 +109,9 @@ UInt_t ProdHist::Process()
{
for(int nn = 0; nn < kNSG; nn++)
{
if(SegE[nn]<5)
continue;
auto hist = (Hist1F*)Amplilist[nn];
FillHist1F(hist,SegE[nn]);
......@@ -322,6 +325,8 @@ UInt_t ProdHist::GetParameters(const std::string& confFile, Bool_t doList)
ConfReader conf;
conf.Add("Crystal", "Crystal name"
, &crystal_name);
conf.Add("RefreshTime", "Refresh time of the Shared Memory Zone (in seconds)"
, &fRefreshTime);
conf.Add("PlotAmpli", "Binning of the amplitude spectra"
, &fAmpliBinning.NBins, &fAmpliBinning.Min, &fAmpliBinning.Max);
conf.Add("PlotAmplivsSegId", "Binning of the E_vs_id matrice"
......@@ -342,6 +347,9 @@ UInt_t ProdHist::GetParameters(const std::string& confFile, Bool_t doList)
if(fAmplivsIdBinning.NBinsX>0) fPlotAmplivsId = true;
if(fBaselineBinning.NBins>0) fPlotBaseline = true;
// To randomize the refresh time among the different crystals
fRefreshTime = fRefreshTime - 0.5 + ((double) rand() / (RAND_MAX));
return rv;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment