10#include <ecl/modules/eclDisplay/EclDisplayModule.h>
13#include <TApplication.h>
18#include <framework/utilities/EnvironmentVariables.h>
21#include <ecl/dataobjects/ECLCalDigit.h>
22#include <ecl/modules/eclDisplay/EclFrame.h>
23#include <ecl/modules/eclDisplay/EclData.h>
24#include <ecl/modules/eclDisplay/geometry.h>
27using namespace ECLDisplayUtility;
38EclDisplayModule::EclDisplayModule() :
Module()
41 setDescription(
"Event display module for ECL.");
44 addParam(
"showDisplay", m_showDisplay,
45 "Show GUI. Off by default because GUI crashes automatic tests.",
false);
46 addParam(
"keepOpen", m_keepOpen,
47 "Keep window open after all events have been processed",
false);
48 addParam(
"displayEnergy", m_displayEnergy,
49 "If true, energy distribution per channel (shaper, crate) is displayed. Otherwise, number of counts is displayed",
false);
50 addParam(
"displayMode", m_displayMode,
51 "Default display mode. Can be later changed in GUI.", 9);
52 addParam(
"autoDisplay", m_autoDisplay,
53 "If true, events are displayed as soon as they are loaded.",
true);
54 addParam(
"InitFileName", m_eclMapperInitFileName,
55 "Initialization file for eclMapper", std::string(
"ecl/data/ecl_channels_map.txt"));
74 B2WARNING(
"Environment variable DISPLAY is not set, event display won't be opened");
89 throw std::runtime_error(
"ECLDisplay: failed to create temp file.");
96 m_app =
new TApplication(
"ECLDisplay App", 0, 0);
100 m_frame->Connect(
"CloseWindow()",
"Belle2::EclDisplayModule",
this,
"handleClosedFrame()");
102 B2DEBUG(100,
"EclDisplayModule::create ECLFrame");
115 B2FATAL(
"ECL Display:: Can't initialize eclChannelMapper");
124 int added_entries = 0;
126 for (
int i = 0; i <
m_eclarray.getEntries(); i++) {
128 if (record->getEnergy() >= 1e-4) {
137 gSystem->ProcessEvents();
141 if (added_entries > 0)
158 gSystem->ProcessEvents();
Class to store calibrated ECLDigits: ECLCalDigits.
bool initFromDB()
Initialize channel mapper from the conditions database.
This class contains data for ECLSimHit's and provides several relevant conversion functions for bette...
int addEvent(ECLCalDigit *event, int evtn)
Add ECLDigit event to inner TTree (m_tree).
void update(bool reset_event_ranges=false)
Update time_min, time_max, event_counts and energy_sums.
bool m_frame_closed
Flag to check if EclFrame is closed;.
int m_evtNum
Counter of added events.
bool m_autoDisplay
If true, events are displayed as soon as they are loaded.
ECL::ECLChannelMapper m_mapper
Channel mapper to show channel <-> (crate, shaper) distributions.
bool m_keepOpen
Keep window open after all events have been processed.
virtual void initialize() override
Initialize EclChannelMapper.
TFile * m_tempfile
Temporary file to store TTree.
virtual void event() override
Handle event.
void initFrame()
Initialize EclFrame.
virtual void endRun() override
Empty method.
virtual void terminate() override
Wait till EclFrame is closed then free allocated resources.
EclFrame * m_frame
Root GUI to display ECL data.
virtual void beginRun() override
Empty method.
bool m_displayEnergy
If true, energy distribution in ECL is displayed.
int m_displayMode
Default display mode.
TApplication * m_app
Application to contain EclFrame.
StoreArray< ECLCalDigit > m_eclarray
Displayed ECL events.
TString m_tempname
Name of temporary file.
virtual ~EclDisplayModule()
Module destructor.
bool m_showDisplay
Show GUI.
void handleClosedFrame()
This method is called when EclFrame is closed.
EclData * m_data
Class that provides interface for quick and comprehensive analysis of large number of events.
Root TGMainFrame that contains multiple widgets that display the ECLSimHit's w.r.t.
void loadNewData()
Update view of the data.
void SetMode(int i)
Changes between display of events (0) and energy (1).
static std::string get(const std::string &name, const std::string &fallback="")
Get the value of an environment variable or the given fallback value if the variable is not set.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.