File indexing completed on 2025-12-17 09:19:02
0001 #ifndef INTTCALIB_H
0002 #define INTTCALIB_H
0003
0004 #include <intt/InttMapping.h>
0005 #include <intt/InttSurveyMap.h>
0006
0007 #include <fun4all/SubsysReco.h>
0008
0009 #include <RtypesCore.h>
0010
0011 #include <array>
0012 #include <map>
0013 #include <string>
0014 #include <utility>
0015
0016 class PHCompositeNode;
0017 class TF1;
0018 class TH1;
0019
0020 class InttCalib : public SubsysReco
0021 {
0022 public:
0023 InttCalib(std::string const& = "InttCalib");
0024 ~InttCalib() override;
0025
0026 int InitRun(PHCompositeNode*) override;
0027 int process_event(PHCompositeNode*) override;
0028
0029
0030 int EndRun(int const) override;
0031
0032 void SetHotMapCdbFile(std::string const& file) { m_hotmap_cdb_file = file; }
0033 void SetHotMapPngFile(std::string const& file) { m_hotmap_png_file = file; }
0034
0035 void SetBcoMapCdbFile(std::string const& file) { m_bcomap_cdb_file = file; }
0036 void SetBcoMapPngFile(std::string const& file) { m_bcomap_png_file = file; }
0037 void SetStreamingMode(bool mode) { m_streaming = mode; }
0038 void SetppMode(bool mode) { m_ppmode = mode; }
0039 void SetBcoMaximumEvent(int mext) { m_evts_bco = mext; }
0040 void SetRunNumber(int runnum) { m_run_num = runnum; }
0041 void SetRawHitContainerName(const std::string& name)
0042 {
0043 m_rawhit_container_name = name;
0044 }
0045 void SetOneFelixServer(int in) { m_FELIX_TARGET = in; }
0046 void SetDoFeebyFee(bool in) { m_do_fee = in; }
0047 int SaveHitrates();
0048 int LoadHitrates();
0049
0050
0051 private:
0052 int ConfigureHotMap_v3();
0053 int MakeHotMapCdb_v3();
0054 int MakeHotMapPng_v3();
0055
0056 int ConfigureBcoMap();
0057 int MakeBcoMapCdb();
0058 int MakeBcoMapPng();
0059
0060 int ConfigureHist_v3(TH1*&, TF1*&, double, std::map<double, int> const&, std::string const&, std::string const&);
0061 static int adjust_hitrate(InttNameSpace::Offline_s const&, double&);
0062 static int GetIndex(InttNameSpace::RawData_s const&, InttNameSpace::Offline_s const&);
0063 static int GetFeeIndex(InttNameSpace::RawData_s const&, InttNameSpace::Offline_s const&);
0064 void SetColdSigmaCut(double in) { m_NUM_SIGMA_COLD = in; }
0065 void SetHotSigmaCut(double in) { m_NUM_SIGMA_HOT = in; }
0066
0067
0068 int ConfigureHotMap_fee();
0069 int MakeHotMapCdb_fee();
0070 int MakeHotMapROOT_fee();
0071
0072
0073 static std::pair<double, double> CalculateStandardDeviation(const std::vector<int>& data);
0074 static Color_t GetFeeColor(int);
0075
0076 int m_evts{0};
0077 int m_run_num{0};
0078 std::string m_rawhit_container_name{"INTTRAWHIT"};
0079 double m_bco_stdDev{0};
0080 double m_bco_mean{0};
0081 double m_mean[8]{0.};
0082 double m_sigma[8]{0.};
0083 double m_mean_fee[112]{0.};
0084 double m_sigma_fee[112]{0.};
0085 int m_evts_bco{50000};
0086
0087 int static const m_MAX_INDEX{8};
0088 int static const m_MAX_LADDER{112};
0089 double static constexpr m_NUM_CHANNELS{8 * 14 * 26 * 128};
0090 double m_NUM_SIGMA_HOT{5.0};
0091 double m_NUM_SIGMA_COLD{3.0};
0092 int m_FELIX_TARGET{-1};
0093
0094
0095
0096
0097
0098 std::string m_hotmap_cdb_file;
0099 std::string m_hotmap_png_file;
0100 std::string m_bcomap_cdb_file;
0101 std::string m_bcomap_png_file;
0102
0103 InttSurveyMap m_survey;
0104 Eigen::Vector3d m_vertex{0.0, 0.0, 0.0};
0105
0106 std::array<std::array<std::array<std::array<std::array<double, 129>, 128>, 26>, 14>, 8> m_hitmap{};
0107 std::array<std::array<std::array<int, 26>, 14>, 8> m_hitmap_half{};
0108
0109
0110 std::array<TH1*, m_MAX_INDEX> m_hist{};
0111 std::array<TH1*, m_MAX_INDEX> m_bco_peak{};
0112 std::array<TH1*, m_MAX_INDEX> m_hist_half{};
0113 std::array<TF1*, m_MAX_INDEX> m_fit{};
0114 std::array<double, m_MAX_INDEX> m_min{};
0115 std::array<double, m_MAX_INDEX> m_max{};
0116 std::array<double, m_MAX_LADDER> m_min_fee{};
0117 std::array<double, m_MAX_LADDER> m_max_fee{};
0118 std::array<double, m_MAX_INDEX> m_half_min{};
0119 std::array<double, m_MAX_INDEX> m_half_max{};
0120
0121 std::array<TH1*, m_MAX_LADDER> m_hist_fee{};
0122 std::array<TF1*, m_MAX_LADDER> m_fit_fee{};
0123
0124 std::map<double, double> m_hitrates;
0125 std::map<double, double> m_invcdf;
0126
0127 int m_bcorates_fee[8][14][128]{};
0128 int m_bcopeaks_fee[8][14]{};
0129
0130 bool m_do_nothing{false};
0131 bool m_streaming{false};
0132 bool m_ppmode{true};
0133 bool m_do_make_bco{true};
0134 bool m_do_fee{false};
0135 };
0136
0137 #endif