Commit 88774edc authored by Morag Jean Williams's avatar Morag Jean Williams
Browse files

Merge branch 'remove_gui' into 'master'

Remove GUI module, superseded by OnlineMonitor

See merge request simonspa/corryvreckan!39
parents cdaaaf02 0e4b6848
Pipeline #391717 passed with stages
in 4 minutes and 49 seconds
# Define module and return the generated name as MODULE_NAME
CORRYVRECKAN_MODULE(MODULE_NAME)
# Add source files to library
CORRYVRECKAN_MODULE_SOURCES(${MODULE_NAME}
GUI.cpp
# ADD SOURCE FILES HERE...
)
# Provide standard install target
CORRYVRECKAN_MODULE_INSTALL(${MODULE_NAME})
#include "GUI.h"
#include "TApplication.h"
#include "TPolyLine3D.h"
#include "TROOT.h"
#include "TSystem.h"
using namespace corryvreckan;
using namespace std;
GUI::GUI(Configuration config, std::vector<Detector*> detectors) : Module(std::move(config), std::move(detectors)) {
// Update every X events:
updateNumber = m_config.get<int>("updateNumber", 500);
}
void GUI::initialise() {
// TApplication keeps the canvases persistent
app = new TApplication("example", 0, 0);
//========= Add each canvas that is wanted =========//
TCanvas* trackCanvas = new TCanvas("TrackCanvas", "Track canvas");
addCanvas(trackCanvas);
TCanvas* hitmapCanvas = new TCanvas("HitMapCanvas", "Hit map canvas");
addCanvas(hitmapCanvas);
TCanvas* residualsCanvas = new TCanvas("ResidualsCanvas", "Residuals canvas");
addCanvas(residualsCanvas);
TCanvas* chargeCanvas = new TCanvas("chargeCanvas", "Charge deposit canvas");
addCanvas(chargeCanvas);
//========= Add each histogram =========//
// Individual plots
addPlot(trackCanvas, "/corryvreckan/BasicTracking/trackChi2");
addPlot(trackCanvas, "/corryvreckan/BasicTracking/trackAngleX");
// Per detector histograms
for(auto& detector : get_detectors()) {
string hitmap = "/corryvreckan/TestAlgorithm/hitmap_" + detector->name();
addPlot(hitmapCanvas, hitmap, "colz");
string residualHisto = "/corryvreckan/BasicTracking/residualsX_" + detector->name();
if(detector->name() == m_config.get<std::string>("DUT"))
residualHisto = "/corryvreckan/DUTAnalysis/residualsX";
addPlot(residualsCanvas, residualHisto);
string chargeHisto = "/corryvreckan/TestAlgorithm/clusterTot_" + detector->name();
addPlot(chargeCanvas, chargeHisto);
}
// Divide the canvases if needed
for(auto& canvas : canvases) {
int nHistograms = histograms[canvas].size();
if(nHistograms == 1)
continue;
if(nHistograms < 4)
canvas->Divide(nHistograms);
else
canvas->Divide(ceil(nHistograms / 2.), 2);
}
// Draw all histograms
for(auto& canvas : canvases) {
canvas->cd();
vector<TH1*> histos = histograms[canvas];
int nHistograms = histos.size();
for(int iHisto = 0; iHisto < nHistograms; iHisto++) {
canvas->cd(iHisto + 1);
string style = styles[histos[iHisto]];
if(histos[iHisto] != nullptr)
histos[iHisto]->Draw(style.c_str());
}
}
// Set event counter
eventNumber = 1;
}
StatusCode GUI::run(Clipboard* clipboard) {
// Draw all histograms
if(eventNumber % updateNumber == 0) {
for(int iCanvas = 0; iCanvas < canvases.size(); iCanvas++) {
canvases[iCanvas]->Paint();
canvases[iCanvas]->Update();
}
eventNumber++;
}
gSystem->ProcessEvents();
// Get the tracks from the clipboard
Tracks* tracks = (Tracks*)clipboard->get("tracks");
if(tracks == NULL)
return Success;
// Otherwise increase the event number
eventNumber++;
return Success;
}
void GUI::finalise() {}
void GUI::addCanvas(TCanvas* canvas) {
canvases.push_back(canvas);
}
void GUI::addPlot(TCanvas* canvas, string histoName, std::string style) {
TH1* histogram = (TH1*)gDirectory->Get(histoName.c_str());
histograms[canvas].push_back(histogram);
styles[histogram] = style;
}
#ifndef GUI_H
#define GUI_H 1
#include <iostream>
#include "TApplication.h"
#include "TBrowser.h"
#include "TCanvas.h"
#include "TH1F.h"
#include "TThread.h"
#include "core/module/Module.hpp"
#include "objects/Cluster.h"
#include "objects/Pixel.h"
#include "objects/Track.h"
namespace corryvreckan {
/** @ingroup Modules
*/
class GUI : public Module {
public:
// Constructors and destructors
GUI(Configuration config, std::vector<Detector*> detectors);
~GUI() {}
// Functions
void initialise();
StatusCode run(Clipboard* clipboard);
void finalise();
// Plot holders
std::vector<TCanvas*> canvases;
std::map<TCanvas*, std::vector<TH1*>> histograms;
std::map<TH1*, std::string> styles;
// Add plots and canvases
void addPlot(TCanvas*, std::string, std::string style = "");
void addCanvas(TCanvas*);
// Application to allow display of canvases
TApplication* app;
// Misc. member objects
int eventNumber;
int updateNumber;
};
} // namespace corryvreckan
#endif // GUI_H
## GUI
**Maintainer**: Daniel Hynds (<daniel.hynds@cern.ch>)
**Status**: Functional - needing small fix
#### Description
This module is a GUI for looking at plots made during the `BasicTracking`, `DUTAnalysis`, and `TestAlgorithm` modules. It is not functional.
#### Parameters
* `updateNumber`: Determines how often the plots are updated on screen. Default number is `500`.
* `DUT`: Name of the DUT plane.
#### Plots produced
Plots produced on screen:
* Track chi^2 plot from `BasicTracking`
* Track angle in x from `BasicTracking`
Plots produced on screen for each device:
* Hitmap from `TestAlgorithm`
* Residual in X from `BasicTracking` for telescope planes, from `DUTAnalysis` for the DUT
* Cluster ToT histogram from `TestAlgorithm` - currently not filled
#### Usage
```toml
[GUI]
DUT = "W000_H03"
updateNumber = 400
```
Parameters to be used in multiple modules can also be defined globally at the top of the configuration file. This is highly encouraged for parameters such as `DUT` and `reference`.
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