3#include "BmnHgndDigi.h"
10 fName = title +
"_cl";
20 LOG(info) <<
"BmnHistHgnd::~BmnHistHgnd: fDir return";
25 for (
auto*& pad : canvasInfo->pads) {
31 canvasInfo->pads.clear();
33 delete canvasInfo->canvas;
39 LOG(debug) <<
"BmnHistHgnd::SetGeometry " << path;
49 std::vector<int> detectors = {1, 2};
51 for (
int det : detectors) {
52 for (uint32_t lay = 1; lay <=
kLAYRS; ++lay) {
53 for (uint32_t row = 1; row <=
kROWS; ++row) {
54 for (uint32_t col = 1; col <=
kCOLS; ++col) {
62 LOG(info) <<
"BmnHistHgnd: initialized " <<
fAddresses.size() <<
" addresses";
67 if (!xTitle.empty()) {
71 if (!yTitle.empty()) {
80 auto createH1 = [
this](
const std::string& name,
const std::string& title,
int nbins,
double xmin,
double xmax,
81 const std::string& xTitle =
"",
const std::string& yTitle =
"") ->
TH1F* {
83 auto* hist =
new TH1F(fullName, title.c_str(), nbins, xmin, xmax);
89 auto createH2 = [
this](
const std::string& name,
const std::string& title,
int nbinsx,
double xmin,
double xmax,
90 int nbinsy,
double ymin,
double ymax,
const std::string& xTitle =
"",
91 const std::string& yTitle =
"") ->
TH2F* {
93 auto* hist =
new TH2F(fullName, title.c_str(), nbinsx, xmin, xmax, nbinsy, ymin, ymax);
95 hist->GetZaxis()->SetNoExponent(
kFALSE);
96 hist->SetOption(
"colz");
102 auto addCanvas = [
this](
const std::string& name,
int w,
int h,
int rows = 1,
int cols = 1) ->
CanvasInfo* {
104 auto* canvas =
new TCanvas(fullName, fullName, w, h);
105 if (rows > 1 || cols > 1)
106 canvas->Divide(rows, cols);
108 auto info = std::make_unique<CanvasInfo>(canvas);
114 auto addPad = [](
CanvasInfo* cinfo,
TH1* hist,
const std::string& opt,
const std::string& name =
"") {
120 pad->name = hist->GetName();
122 cinfo->
pads.push_back(pad);
129 createH1(
"h1_ProfileSlice",
"Energy in detector slice",
kLAYRS, 1,
kLAYRS + 1,
"Layer id",
"Events");
135 kROWS *
kCOLS + 2,
"Layer number",
"Cell number");
137 for (uint32_t layer = 1; layer <=
kLAYRS; ++layer) {
164 100, 0, 100, 100, -300, 300);
170 auto* canAmpsInfo = addCanvas(
"CanvasAmplitudes", PAD_WIDTH, PAD_HEIGHT, 2, 1);
171 addPad(canAmpsInfo,
h2_grid,
"colz",
"h2_grid");
172 addPad(canAmpsInfo,
h1_ECells,
"hist",
"h1_ECells");
174 auto* canvSliceInfo = addCanvas(
"CanvasSlice", PAD_WIDTH, PAD_HEIGHT, 2, 1);
175 addPad(canvSliceInfo,
h2_Layer_Cell,
"colz",
"h2_Layer_Cell");
179 auto* canvProfInfo = addCanvas(
"CanvasProfiles", PAD_WIDTH, PAD_HEIGHT,
kROWS,
kCOLS);
190 auto* canvCellAmpInfo = addCanvas(
"CanvasCellAmp", PAD_WIDTH, PAD_HEIGHT,
kROWS,
kCOLS);
206 fServer->Register(path, cinfo_ptr->canvas);
210 fServer->SetItemField(path.Data(),
"_monitoring",
"2000");
211 fServer->SetItemField(path.Data(),
"_layout",
"grid11x11");
212 TString cmdTitle = path +
"Reset";
214 fServer->Restrict(cmdTitle,
"visible=shift");
215 fServer->Restrict(cmdTitle,
"allow=shift");
216 cmd =
"/" +
fName +
"/->SetRefRun(%arg1%)";
217 cmdTitle = path +
"SetRefRun";
219 cmdTitle = path +
"ChangeSelection";
220 fServer->RegisterCommand(cmdTitle,
TString(
"/") +
fName.Data() +
"/->SetSelection(%arg1%)",
"button;");
221 fServer->Restrict(cmdTitle,
"visible=shift");
222 fServer->Restrict(cmdTitle,
"allow=shift");
235 hist->SetDirectory(
fDir);
269 for (
auto& [address, hist] :
hProfCell) {
278 double signal = digi->GetSignal();
279 double time = digi->GetTime();
280 auto arm = digi->GetArmId();
281 auto row = digi->GetRowId();
282 auto col = digi->GetColumnId();
283 auto cell = (row - 1) *
kCOLS + col;
284 auto lay = digi->GetLayerId();
288 LOG(debug) <<
"Unknown Hgnd address: " << address;
295 h2_grid->Fill(col, row, signal);
316 TString FileName =
Form(
"bmn_run%04d_hist.root",
id);
317 printf(
"SetRefRun: %s\n", FileName.
Data());
334 for (
auto* pad : cinfo_ptr->pads) {
346 printf(
"BmnHistHgnd : Reset histos\n");
char * Form(const char *fmt,...)
BmnStatus
Define status code.
BmnSetup
Define experimental setup.
uint32_t GetAddress() const
Data structure for a single HGND digit.
std::map< uint32_t, TH1F * > hProfCell
std::vector< std::unique_ptr< CanvasInfo > > m_canvases
std::set< uint32_t > fAddresses
void FillFromDigi(DigiArrays *fDigiArrays) override
void SetGeometry(const std::string &path)
T * createH1(Args &&... args)
static constexpr UInt_t kCOLS
void SetDir(TFile *outFile, TTree *recoTree) override
void SetSelection(Int_t Trigger)
void ClearRefRun() override
std::map< uint32_t, TH2F * > hLayerAmps
std::vector< TH1 * > m_allHistograms
BmnHistHgnd(TString title, TString path, Int_t PeriodID, BmnSetup stp)
static constexpr UInt_t kLAYRS
void Register(THttpServer *serv) override
void setupAxis(TH1 *hist, const std::string &xTitle, const std::string &yTitle)
T * createH2(Args &&... args)
BmnStatus SetRefRun(Int_t id)
std::map< uint32_t, TH2F * > hCellAmpTime
std::unique_ptr< BmnNdetGeo > fGeoHandler
void InitializeAddresses()
static constexpr UInt_t kROWS
static void DrawRef(unique_ptr< TCanvas > &canGemStrip, vector< PadInfo * > *canGemStripPads)
static BmnStatus LoadRefRun(Int_t refID, TString FullName, TString fTitle, vector< PadInfo * > canPads, vector< TString > Names)
BmnHist(Int_t periodID=7, BmnSetup setup=kBMNSETUP)
static uint32_t GetRowId(uint32_t address)
Return Row id from address.
static uint32_t GetAddress(uint32_t ArmId, uint32_t RowId, uint32_t ColumnId, uint32_t LayerId)
Return address.
static uint32_t GetColumnId(uint32_t address)
Return Column id from address.
static uint32_t GetArmId(uint32_t address)
Return Arm id from address.
static uint32_t GetLayerId(uint32_t address)
Return Layer id from address.
Storage for pad content and it's options.
virtual void SetTitleColor(Color_t color=1)
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
static void SetMaxDigits(Int_t maxd=5)
virtual void SetTitle(const char *title="")
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
friend friend class TClonesArray
const char * Data() const
static TString Format(const char *fmt,...)
std::vector< PadInfo * > pads