Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:15:35

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   /// Called at the end of each run.
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   /// For debugging
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   // For Fee by Fee
0067   int ConfigureHotMap_fee();
0068   int MakeHotMapCdb_fee();
0069   int MakeHotMapROOT_fee();
0070   // For Fee by Fee
0071 
0072   static std::pair<double, double> CalculateStandardDeviation(const std::vector<int>& data);
0073   static Color_t GetFeeColor(int);
0074 
0075   int m_evts{0};
0076   int m_run_num{0};
0077   std::string m_rawhit_container_name{"INTTRAWHIT"};
0078   double m_bco_stdDev{0};
0079   double m_bco_mean{0};
0080   double m_mean[8]{0.};
0081   double m_sigma[8]{0.};
0082   double m_mean_fee[112]{0.};
0083   double m_sigma_fee[112]{0.};
0084   int m_evts_bco{50000};
0085   // int static const m_MAX_INDEX = 32;
0086   int static const m_MAX_INDEX{8};
0087   int static const m_MAX_LADDER{112};
0088   double static constexpr m_NUM_CHANNELS{8 * 14 * 26 * 128};
0089   double m_NUM_SIGMA_HOT{5.0};
0090   double m_NUM_SIGMA_COLD{3.0};
0091   int m_FELIX_TARGET{-1};
0092   // double m_min_hitrate{0.0};
0093   // double m_min_fraction{0.0};
0094   // double m_max_hitrate{0.0};
0095   // double m_max_fraction{0.0};
0096 
0097   std::string m_hotmap_cdb_file;
0098   std::string m_hotmap_png_file;
0099   std::string m_bcomap_cdb_file;
0100   std::string m_bcomap_png_file;
0101 
0102   InttSurveyMap m_survey;
0103   Eigen::Vector3d m_vertex{0.0, 0.0, 0.0};
0104   // int m_hitmap[8][14][26][128][129]
0105   std::array<std::array<std::array<std::array<std::array<double, 129>, 128>, 26>, 14>, 8> m_hitmap{};
0106   std::array<std::array<std::array<int, 26>, 14>, 8> m_hitmap_half{};
0107 
0108   // TH1* m_hist[8][14]
0109   std::array<TH1*, m_MAX_INDEX> m_hist{};
0110   std::array<TH1*, m_MAX_INDEX> m_bco_peak{};
0111   std::array<TH1*, m_MAX_INDEX> m_hist_half{};
0112   std::array<TF1*, m_MAX_INDEX> m_fit{};
0113   std::array<double, m_MAX_INDEX> m_min{};
0114   std::array<double, m_MAX_INDEX> m_max{};
0115   std::array<double, m_MAX_LADDER> m_min_fee{};
0116   std::array<double, m_MAX_LADDER> m_max_fee{};
0117   std::array<double, m_MAX_INDEX> m_half_min{};
0118   std::array<double, m_MAX_INDEX> m_half_max{};
0119 
0120   std::array<TH1*, m_MAX_LADDER> m_hist_fee{};
0121   std::array<TF1*, m_MAX_LADDER> m_fit_fee{};
0122 
0123   std::map<double, double> m_hitrates;
0124   std::map<double, double> m_invcdf;
0125 
0126   int m_bcorates_fee[8][14][128]{};
0127   int m_bcopeaks_fee[8][14]{};
0128 
0129   bool m_do_nothing{false};
0130   bool m_streaming{false};
0131   bool m_ppmode{true};
0132   bool m_do_make_bco{true};
0133   bool m_do_fee{false};
0134 };
0135 
0136 #endif  // INTTCALIB_H