Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:14:59

0001 #ifndef CHECK_EPD_MAP_H
0002 #define CHECK_EPD_MAP_H
0003 
0004 #include <fun4all/SubsysReco.h>
0005 #include <string>
0006 #include <vector>
0007 #include <iostream>
0008 #include <tuple>
0009 
0010 class PHCompositeNode;
0011 class EpdGeom;
0012 class TowerInfoContainer;
0013 class TProfile2D;
0014 class TH1I;
0015 class TH2I;
0016 class TH2F;
0017 class TH1F;
0018 
0019 /**
0020  * sanity check for the sEPD channel map.
0021  *
0022  * When the run starts (InitRun) the module:
0023  *   1. pulls the EpdGeom node,
0024  *   2. builds the channel-number -> key vector from the CDBTTree,
0025  *   3. compares with TowerInfoDefs::encode_epd().
0026  *
0027  * 
0028  */
0029 class CheckEpdMap : public SubsysReco
0030 {
0031  public:
0032   explicit CheckEpdMap(const std::string& name = "CheckEpdMap");
0033   ~CheckEpdMap() override = default;
0034 
0035 
0036   int InitRun(PHCompositeNode* topNode) override;
0037 
0038  
0039   int process_event(PHCompositeNode* topNode) override;
0040   int End(PHCompositeNode*) override;
0041   void PrintReverseTable(std::ostream &os = std::cout) const;
0042 
0043   void setSimulationMode(bool b) { m_simulationMode = b; }
0044   void SetOutputFile(const std::string &fname) { outputFile = fname; }
0045   //void   SetJobIndex(int idx) { jobIndex = idx; }
0046 
0047  private:
0048     // [0] = south, [1] = north
0049     TProfile2D* m_profOld [2]{};
0050     TProfile2D* m_profNew [2]{};
0051     std::uint64_t m_eventCounter{0};
0052 
0053     TH1I*  m_diffCount = nullptr;   
0054     TH2F*  m_diffADC   = nullptr;
0055     TH1F*  m_hitCenterDist = nullptr;
0056     //TH2I*  hSimMatch[2];
0057 
0058     TH2F*  m_simMatchPolarS01 = nullptr;
0059     TH2F*  m_simMatchPolarN01 = nullptr;
0060 
0061     TH2F*  m_simMatchPolarS = nullptr;
0062     TH2F*  m_simMatchPolarN = nullptr;
0063 
0064     
0065 
0066     std::vector<unsigned> m_keyVec;
0067    
0068     static constexpr int NRING = 16;
0069     static constexpr int NPHI  = 24;
0070     mutable int m_reverse[2][NRING][NPHI]{};
0071 
0072     static constexpr int NSEC = 12;
0073     static constexpr int NTILE = 31;
0074     //map from (arm,sector,tile_id) -> (arm,ring,phi)
0075     std::tuple<uint32_t,uint32_t,uint32_t> m_tile_bin[2][NSEC][NTILE]; 
0076     std::tuple<uint32_t,uint32_t,uint32_t> m_module_coords[2][NRING][NPHI];
0077     //int m_primaryTrackID = std::numeric_limits<unsigned int>::max();;
0078 
0079     TH2F* m_tileHist[2][NRING][NPHI] = {};
0080     TowerInfoContainer *towers;
0081     EpdGeom *geom = nullptr;
0082     bool m_simulationMode = false;
0083     std::string          outputFile;
0084 
0085 
0086     std::pair<
0087     std::vector<unsigned>,   // vkey
0088     std::vector<int>         // mapped_vals
0089     > build_key_vector() const;
0090 
0091     void check_map(const std::vector<unsigned>& vkey,
0092         const std::vector<int> mapped_vals) const;
0093 
0094     int processEventDataMode(PHCompositeNode *topNode);
0095     
0096     int processEventSimulationMode(PHCompositeNode *topNode);
0097 
0098     void BuildSimMap();
0099     void InitializeSimMatchMap();
0100 
0101     int Getphimap(int phiindex);
0102 
0103     int Getrmap(int rindex);
0104     
0105 
0106     
0107 };
0108 
0109 #endif  // CHECK_EPD_MAP_H