Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:13:25

0001 // ----------------------------------------------------------------------------
0002 /*! \file    TriggerClusterMakerDefs.h'
0003  *  \authors Derek Anderson
0004  *  \date    05.29.2024
0005  *
0006  *  Miscellaneous definitions for the TriggerClusterMaker
0007  *  fun4all module
0008  */
0009 // ----------------------------------------------------------------------------
0010 
0011 #ifndef TRIGGERCLUSTERMAKERDEFS_H
0012 #define TRIGGERCLUSTERMAKERDEFS_H
0013 
0014 // c++ utilities
0015 #include <limits>
0016 #include <utility>
0017 // calo base
0018 #include <calobase/TowerInfoDefs.h>
0019 // trigger libraries
0020 //   - TODO use local paths when ready
0021 #include <calotrigger/TriggerDefs.h>
0022 
0023 
0024 
0025 // ----------------------------------------------------------------------------
0026 //! Miscellaneous tools for the TriggerClusterMaker module
0027 // ----------------------------------------------------------------------------
0028 namespace TriggerClusterMakerDefs {
0029 
0030   // enums --------------------------------------------------------------------
0031 
0032   // calo layers
0033   enum Cal {
0034     EM,
0035     IH,
0036     OH
0037   };
0038 
0039   // eta vs. phi bin
0040   enum Axis {
0041     Eta,
0042     Phi
0043   };
0044 
0045   // trigger info type
0046   enum Type {
0047     Prim,
0048     LL1
0049   };
0050 
0051 
0052 
0053   // constants ----------------------------------------------------------------
0054 
0055   // --------------------------------------------------------------------------
0056   //! No. of EMCal towers in a retower
0057   // --------------------------------------------------------------------------
0058   inline uint32_t NTowInRetow() {
0059     static const uint32_t nTowInRetow = 4;
0060     return nTowInRetow;
0061   }
0062 
0063   // --------------------------------------------------------------------------
0064   //! No. of HCal towers (EMCal retowers) along an LL1
0065   // --------------------------------------------------------------------------
0066   inline uint32_t NTowInLL1() {
0067     static const uint32_t nTowInLL1 = 4;
0068     return nTowInLL1;
0069   }
0070 
0071   // --------------------------------------------------------------------------
0072   //! No. of HCal towers (EMCal retowers) along a side of a trigger primitive
0073   // --------------------------------------------------------------------------
0074   inline uint32_t NTowInPrim() {
0075     static const uint32_t nTowInPrim = 2;
0076     return nTowInPrim;
0077   }
0078 
0079 
0080 
0081   // methods ------------------------------------------------------------------
0082 
0083   // --------------------------------------------------------------------------
0084   //! Calculate eta/phi bin based on sum key
0085   // --------------------------------------------------------------------------
0086   uint32_t GetBin(const uint32_t sumkey, const uint32_t axis, const uint32_t type = Type::Prim) {
0087 
0088     // get relevant sum and primitive IDs
0089     uint32_t sumID;
0090     uint32_t primID;
0091     switch (axis) {
0092       case Axis::Eta:
0093         sumID  = TriggerDefs::getSumEtaId(sumkey);
0094         primID = TriggerDefs::getPrimitiveEtaId_from_TriggerSumKey(sumkey);
0095         break;
0096       case Axis::Phi:
0097         sumID  = TriggerDefs::getSumPhiId(sumkey);
0098         primID = TriggerDefs::getPrimitivePhiId_from_TriggerSumKey(sumkey);
0099         break;
0100       default:
0101         sumID  = std::numeric_limits<uint32_t>::max();
0102         primID = std::numeric_limits<uint32_t>::max();
0103         break;
0104     }
0105 
0106     // get relevant segmentation
0107     uint32_t segment;
0108     switch (type) {
0109       case Type::LL1:
0110         segment = NTowInLL1();
0111         break;
0112       case Type::Prim:
0113         [[fallthrough]];
0114       default:
0115         segment = NTowInPrim();
0116         break;
0117     }
0118     return sumID + (segment * primID);
0119 
0120   }  // end 'GetBin(uint32_t, uint32_t, uint32_t)'
0121 
0122 
0123 
0124   // --------------------------------------------------------------------------
0125   //! Get tower key based on provided eta, phi indices
0126   // --------------------------------------------------------------------------
0127   uint32_t GetKeyFromEtaPhiIndex(const uint32_t eta, const uint32_t phi, const uint32_t det) {
0128 
0129     uint32_t key;
0130     switch (det) {
0131 
0132       // get emcal tower index
0133       case TriggerDefs::DetectorId::emcalDId:
0134         key = TowerInfoDefs::encode_emcal(eta, phi);
0135         break;
0136 
0137       // get hcal tower index
0138       case TriggerDefs::DetectorId::hcalinDId:
0139         [[fallthrough]];
0140       case TriggerDefs::DetectorId::hcaloutDId:
0141         [[fallthrough]];
0142       case TriggerDefs::DetectorId::hcalDId:
0143         key = TowerInfoDefs::encode_hcal(eta, phi);
0144         break;
0145 
0146       // otherwise return dummy value
0147       default:
0148         key = std::numeric_limits<uint32_t>::max();
0149         break;
0150     }
0151     return key;
0152 
0153   } //  end 'GetKeyFromEtaPhiIndex(uint32_t, uint32_t, uint32_t)'
0154 
0155 
0156 
0157   // --------------------------------------------------------------------------
0158   //! Get range of tower indices for a specified direction from a starting point
0159   // --------------------------------------------------------------------------
0160   std::pair<uint32_t, uint32_t> GetRangeOfIndices(
0161     const uint32_t iStartTrg,
0162     const uint32_t detector,
0163     const uint32_t type = Type::Prim
0164   ) {
0165 
0166     uint32_t iStart;
0167     uint32_t iStop;
0168     switch (detector) {
0169 
0170       // get max emcal tower index
0171       case TriggerDefs::DetectorId::emcalDId:
0172         iStart = iStartTrg;
0173         iStop  = iStartTrg + (2 * NTowInRetow()) - 1;
0174         break;
0175 
0176       // get max hcal tower index
0177       case TriggerDefs::DetectorId::hcalinDId:
0178         [[fallthrough]];
0179       case TriggerDefs::DetectorId::hcaloutDId:
0180         [[fallthrough]];
0181       case TriggerDefs::DetectorId::hcalDId:
0182         iStart = iStartTrg;  // TODO implement
0183         iStop  = iStartTrg;  // TODO implement
0184         break;
0185 
0186       // otherwise set both to start
0187       default:
0188         iStart = iStartTrg;
0189         iStop  = iStartTrg;
0190         break;
0191     }
0192     return std::make_pair(iStart, iStop);
0193 
0194   }  // end 'GetRangeOfIndeices(uint32_t, uint32_t, uint32_t)'
0195 
0196 }  // end TriggerClusterMakerDefs namespace
0197 
0198 #endif
0199 
0200 // end ------------------------------------------------------------------------