Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:40

0001 #ifndef INTT_MAPPING_H
0002 #define INTT_MAPPING_H
0003 
0004 #include <cstdint>
0005 #include <iostream>
0006 #include <map>
0007 
0008 class InttRawHit;
0009 
0010 namespace InttNameSpace
0011 {
0012   /// RawData_s (kept as aggregate for convenience)
0013   struct RawData_s
0014   {
0015     int felix_server = 0;
0016     int felix_channel = 0;
0017     int chip = 0;
0018     int channel = 0;
0019 
0020     using value_type = RawData_s;
0021     using pointer = RawData_s*;
0022     using reference = RawData_s&;
0023 
0024     RawData_s& operator*() { return *this; }
0025     RawData_s& operator++();
0026 
0027     friend bool operator<(InttNameSpace::RawData_s const&, InttNameSpace::RawData_s const&);
0028     friend std::ostream& operator<<(std::ostream&, InttNameSpace::RawData_s const&);
0029   };
0030   bool operator<(RawData_s const&, RawData_s const&);
0031   std::ostream& operator<<(std::ostream&, InttNameSpace::RawData_s const&);
0032   class AllRawDataChannels /// For range-based for loops
0033   {
0034   public:
0035       static const RawData_s begin() { return {.felix_server = 0, .felix_channel = 0, .chip = 0, .channel = 0}; }
0036       static const RawData_s end() { return {.felix_server = 8, .felix_channel = 0, .chip = 0, .channel = 0}; }
0037   };
0038 
0039   /// Online_s (kept as aggregate for convenience)
0040   struct Online_s
0041   {
0042     int lyr = 0;
0043     int ldr = 0;
0044     int arm = 0;
0045     int chp = 0;
0046     int chn = 0;
0047 
0048     using value_type = Online_s;
0049     using pointer = Online_s*;
0050     using reference = Online_s&;
0051 
0052     Online_s& operator*() { return *this; }
0053     Online_s& operator++();
0054 
0055     friend bool operator<(InttNameSpace::Online_s const&, InttNameSpace::Online_s const&);
0056     friend std::ostream& operator<<(std::ostream&, InttNameSpace::Online_s const&);
0057   };
0058   bool operator<(Online_s const&, Online_s const&);
0059   std::ostream& operator<<(std::ostream&, InttNameSpace::Online_s const&);
0060   class AllOnlineChannels /// For range-based for loops
0061   {
0062   public:
0063       static const Online_s begin() { return {.lyr = 0, .ldr = 0, .arm = 0, .chp = 0, .chn = 0}; }
0064       static const Online_s end() { return {.lyr = 4, .ldr = 0, .arm = 0, .chp = 0, .chn = 0}; }
0065   };
0066 
0067   /// Offline_s (kept as aggregate for convenience)
0068   struct Offline_s
0069   {
0070     int layer = 0;
0071     int ladder_phi = 0;
0072     int ladder_z = 0;
0073     int strip_x = 0; // row, global phi
0074     int strip_y = 0; // col, global z
0075 
0076     using value_type = Offline_s;
0077     using pointer = Offline_s*;
0078     using reference = Offline_s&;
0079 
0080     Offline_s& operator*() { return *this; }
0081     Offline_s& operator++();
0082 
0083     friend bool operator<(InttNameSpace::Offline_s const&, InttNameSpace::Offline_s const&);
0084     friend std::ostream& operator<<(std::ostream&, InttNameSpace::Online_s const&);
0085   };
0086   bool operator<(Offline_s const&, Offline_s const&);
0087   std::ostream& operator<<(std::ostream&, InttNameSpace::Offline_s const&);
0088   class AllOfflineChannels /// For range-based for loops
0089   {
0090   public:
0091       static const Offline_s begin() { return {.layer = 3, .ladder_phi = 0, .ladder_z = 0, .strip_x = 0, .strip_y = 0}; }
0092       static const Offline_s end() { return {.layer = 7, .ladder_phi = 0, .ladder_z = 0, .strip_x = 0, .strip_y = 0}; }
0093   };
0094 
0095   /// Methods
0096   RawData_s RawFromHit(InttRawHit*);
0097 
0098   Online_s ToOnline(Offline_s const&);
0099   Offline_s ToOffline(Online_s const&);
0100 
0101   RawData_s ToRawData(Online_s const&);
0102   Online_s ToOnline(RawData_s const&);
0103 
0104   inline RawData_s ToRawData(Offline_s const& offline) { return ToRawData(ToOnline(offline)); }
0105   inline Offline_s ToOffline(RawData_s const& rawdata) { return ToOffline(ToOnline(rawdata)); }
0106 };
0107 
0108 /// Relational operators with macro helper
0109 #define DEFINE_RELATIONAL_OPERATORS(ClassName) \
0110     inline bool operator>(InttNameSpace::ClassName const& lhs, InttNameSpace::ClassName const& rhs) { return rhs < lhs; } \
0111     inline bool operator<=(InttNameSpace::ClassName const& lhs, InttNameSpace::ClassName const& rhs) { return !(rhs < lhs); } \
0112     inline bool operator>=(InttNameSpace::ClassName const& lhs, InttNameSpace::ClassName const& rhs) { return !(lhs < rhs); } \
0113     inline bool operator!=(InttNameSpace::ClassName const& lhs, InttNameSpace::ClassName const& rhs) { return (lhs < rhs) || (rhs < lhs); } \
0114     inline bool operator==(InttNameSpace::ClassName const& lhs, InttNameSpace::ClassName const& rhs) { return !(lhs < rhs) && !(rhs < lhs); }
0115 DEFINE_RELATIONAL_OPERATORS(RawData_s)
0116 DEFINE_RELATIONAL_OPERATORS(Online_s)
0117 DEFINE_RELATIONAL_OPERATORS(Offline_s)
0118 #undef DEFINE_RELATIONAL_OPERATORS
0119 
0120 #endif  // INTT_MAPPING_H
0121 
0122 //      Ladder Structure                //
0123 //======================================//
0124 //      U14     U1      Type B  North   //
0125 //      U15     U2        .       .     //
0126 //      U16     U3        .       .     //
0127 //      U17     U4        .       .     //
0128 //      U18     U5      Type B    .     //
0129 //------------------------------  .     //
0130 //      U19     U6      Type A    .     //
0131 //      U20     U7        .       .     //
0132 //      U21     U8        .       .     //
0133 //      U22     U9        .       .     //
0134 //      U23     U10       .       .     //
0135 //      U24     U11       .       .     //
0136 //      U25     U12       .       .     //
0137 //      U26     U13     Type A  North   //
0138 //--------------------------------------//
0139 //      U13     U26     Type A  South   //
0140 //      U12     U25       .       .     //
0141 //      U11     U24       .       .     //
0142 //      U10     U23       .       .     //
0143 //      U9      U22       .       .     //
0144 //      U8      U21       .       .     //
0145 //      U7      U20       .       .     //
0146 //      U6      U19     Type A    .     //
0147 //------------------------------  .     //
0148 //      U5      U18     Type B    .     //
0149 //      U4      U17       .       .     //
0150 //      U3      U16       .       .     //
0151 //      U2      U15       .       .     //
0152 //      U1      U14     Type B  South   //
0153 //======================================//
0154 
0155 //|<-            South                        |                       North            ->|
0156 //|         B      |            A             |             A           |       B        |
0157 //+----------------+--------------------------+-------------------------+----------------+
0158 //|         1      |            0             |             2           |       3        | ladder_z  (offline)
0159 //|  0  1  2  3  4 |  0  1  2  3  4  5  6  7  |  0  1  2  3  4  5  6  7 |  0  1  2  3  4 | strip_y   (offline)
0160 //+----------------+--------------------------+-------------------------+----------------+
0161 //|  0  1  2  3  4 |  5  6  7  8  9 10 11 12  | 25 24 23 22 21 20 19 18 | 17 16 15 14 13 | chp       (online)
0162 //| 13 14 15 16 17 | 18 19 20 21 22 23 24 25  | 12 11 10  9  8  7  6  5 |  4  3  2  1  0 | chp       (online)