File indexing completed on 2025-08-03 08:21:08
0001 #ifndef TPOT_TPOTMONDRAW_H
0002 #define TPOT_TPOTMONDRAW_H
0003
0004 #include "MicromegasGeometry.h"
0005
0006 #include <micromegas/MicromegasDefs.h>
0007 #include <micromegas/MicromegasMapping.h>
0008 #include <onlmon/OnlMonDraw.h>
0009
0010 #include <TFile.h>
0011
0012 #include <array>
0013 #include <memory>
0014 #include <string>
0015
0016 class OnlMonDB;
0017 class TCanvas;
0018 class TH1;
0019 class TH2Poly;
0020 class TPad;
0021
0022 class TpotMonDraw : public OnlMonDraw
0023 {
0024 public:
0025
0026
0027 TpotMonDraw(const std::string &name);
0028
0029
0030 ~TpotMonDraw() override = default;
0031
0032 int Init() override;
0033 int Draw(const std::string &what = "ALL") override;
0034 int MakeHtml(const std::string &what = "ALL") override;
0035 int SavePlot(const std::string &what = "ALL", const std::string &type = "png") override;
0036
0037
0038 std::vector<std::string> get_detnames_sphenix() const
0039 { return m_detnames_sphenix; }
0040
0041
0042 void set_calibration_file( const std::string& value )
0043 { m_calibration_filename = value; }
0044
0045
0046
0047 using sample_window_t = std::pair<int, int>;
0048 void set_sample_window( const sample_window_t& value )
0049 { m_sample_window = value; }
0050
0051
0052 void set_sample_window_signal( const sample_window_t& value )
0053 { m_sample_window_signal = value; }
0054
0055
0056 void set_n_sigma( double value ) { m_n_sigma = value; }
0057
0058 private:
0059
0060
0061 int DrawDeadServer(TPad*) override;
0062
0063
0064 void draw_time( TPad*);
0065
0066 TCanvas* get_canvas(const std::string& name, bool clear = true );
0067 TCanvas* create_canvas(const std::string &name);
0068
0069 int draw_counters();
0070 int draw_detector_occupancy();
0071 int draw_resist_occupancy();
0072 int draw_server_statistics();
0073
0074 using histogram_array_t = std::array<TH1*, MicromegasDefs::m_nfee>;
0075
0076 using threshold_array_t = std::array<double, MicromegasDefs::m_nfee>;
0077
0078
0079 enum DrawOptions
0080 {
0081 None = 0,
0082 Logx = 1<<0,
0083 Logy = 1<<1,
0084 Logz = 1<<2,
0085 Colz = 1<<3,
0086 MatchRange = 1<<4,
0087 Normalize = 1<<5
0088 };
0089
0090
0091 TH1* get_histogram( const std::string& name ) const;
0092
0093
0094 histogram_array_t get_histograms( const std::string& name ) const;
0095
0096
0097 TH1* get_ref_histogram( const std::string& name ) const;
0098
0099
0100 histogram_array_t get_ref_histograms( const std::string& name ) const;
0101
0102
0103 histogram_array_t get_ref_histograms_scaled( const std::string& name ) const;
0104
0105
0106
0107 double get_ref_scale_factor() const;
0108
0109
0110
0111
0112
0113 TH1* normalize( TH1*, double scale = 1 ) const;
0114
0115
0116 int draw_array( const std::string& name, const histogram_array_t& array, unsigned int options = DrawOptions::None, double norm_factor = 1 )
0117 { return draw_array( name, array, {{nullptr}}, options, norm_factor ); }
0118
0119
0120 int draw_array( const std::string& name, const histogram_array_t&, const histogram_array_t& , unsigned int = DrawOptions::None, double = 1 );
0121
0122
0123
0124 void draw_detnames_sphenix( const std::string& suffix = std::string());
0125
0126
0127 void draw_occupancy( TH2Poly* );
0128
0129
0130 double m_triggercnt = 0;
0131
0132
0133 double m_heartbeatcnt = 0;
0134
0135
0136 MicromegasMapping m_mapping;
0137
0138
0139 MicromegasGeometry m_geometry;
0140
0141
0142 std::string m_calibration_filename;
0143
0144
0145 histogram_array_t m_threshold_histograms;
0146
0147
0148 threshold_array_t m_mean_thresholds;
0149
0150
0151 std::vector<std::string> m_detnames_sphenix;
0152
0153
0154 int TimeOffsetTicks = -1;
0155
0156
0157 sample_window_t m_sample_window = {0, 50};
0158
0159
0160 sample_window_t m_sample_window_signal = {3, 18};
0161
0162
0163 double m_n_sigma = 5;
0164
0165
0166 std::string m_ref_histograms_filename;
0167
0168
0169 std::unique_ptr<TFile> m_ref_histograms_tfile;
0170
0171
0172 std::vector<TCanvas*> m_canvas;
0173 std::unique_ptr<OnlMonDB> dbvars;
0174 };
0175
0176 #endif