![]() |
|
|||
File indexing completed on 2025-08-05 08:13:11
0001 /// =========================================================================== 0002 /*! \file BeamBackgroundFilterAndQADefs.h 0003 * \authors Derek Anderson 0004 * \date 11.01.2024 0005 * 0006 * A namespace to hold various definitions 0007 * useful across the BeamBackgroundFilterAndQA 0008 * module and its various filters. 0009 */ 0010 /// =========================================================================== 0011 0012 #ifndef BEAMBACKGROUNDFILTERANDQADEFS_H 0013 #define BEAMBACKGROUNDFILTERANDQADEFS_H 0014 0015 // c++ utilities 0016 #include <algorithm> 0017 #include <array> 0018 0019 // calo base 0020 #include <calobase/TowerInfo.h> 0021 #include <calobase/TowerInfoContainer.h> 0022 0023 // ============================================================================ 0024 //! Misc beam background filter and QA definitions 0025 // ============================================================================ 0026 namespace BeamBackgroundFilterAndQADefs 0027 { 0028 0029 // ========================================================================== 0030 //! Event status codes 0031 // ========================================================================== 0032 /*! This enumerates the outcomes of applying a filter: 0033 * Evt = null, no filter applied yet 0034 * NoBkgd = filter finds there is no beam background 0035 * HasBkgd = filter finds there is beam background 0036 */ 0037 enum Status 0038 { 0039 Evt, 0040 NoBkgd, 0041 HasBkgd 0042 }; 0043 0044 // ========================================================================== 0045 // Helper struct to scrape info from TowerInfo 0046 // ========================================================================== 0047 /*! This is a lightweight struct to scrape only the info relevant to various 0048 * filters from a TowerInfo object. 0049 * 0050 * An example usage is in the StreakSidebandFilter algorithm, where its used 0051 * to build a 2D array of tower energies & status (see below) for quick 0052 * lookup. 0053 */ 0054 struct Tower 0055 { 0056 // members 0057 uint8_t status = 0; 0058 double energy = -1.; 0059 bool isGood = false; 0060 //! grab info from a TowerInfo object 0061 void SetInfo(TowerInfo* info) 0062 { 0063 status = info->get_status(); 0064 energy = info->get_energy(); 0065 isGood = info->get_isGood(); 0066 return; 0067 } 0068 0069 //! reset values 0070 void Reset() 0071 { 0072 status = 0; 0073 energy = -1.; 0074 return; 0075 } 0076 0077 }; // end Tower 0078 0079 // ========================================================================== 0080 //! Helper type for building (eta, phi) maps of towers 0081 // ========================================================================== 0082 /*! This is a lightweight struct to organize the above Tower structs into a 0083 * handy (eta, phi) map. See the StreakSidebandFilter algorithm for an 0084 * example usage. 0085 */ 0086 template <std::size_t H, std::size_t F> 0087 struct TowerMap 0088 { 0089 // members 0090 std::array<std::array<Tower, F>, H> towers; 0091 0092 //! build array 0093 void Build(TowerInfoContainer* container) 0094 { 0095 for (std::size_t iTwr = 0; iTwr < container->size(); ++iTwr) 0096 { 0097 const int32_t key = container->encode_key(iTwr); 0098 const int32_t iEta = container->getTowerEtaBin(key); 0099 const int32_t iPhi = container->getTowerPhiBin(key); 0100 towers.at(iEta).at(iPhi).SetInfo(container->get_tower_at_channel(iTwr)); 0101 } 0102 return; 0103 } 0104 0105 //! reset 0106 void Reset() 0107 { 0108 for (auto row : towers) 0109 { 0110 for (auto tower : row) 0111 { 0112 tower.Reset(); 0113 } 0114 } 0115 return; 0116 } 0117 0118 }; // end TowerArray 0119 0120 // -------------------------------------------------------------------------- 0121 //! Maps for specific calorimeters 0122 // -------------------------------------------------------------------------- 0123 typedef TowerMap<96, 256> EMCalMap; 0124 typedef TowerMap<24, 64> IHCalMap; 0125 typedef TowerMap<24, 64> OHCalMap; 0126 0127 // ========================================================================== 0128 //! Make QA-compliant histogram names 0129 // ========================================================================== 0130 /*! This helper method takes in a list of base names (e.g. 0131 * some variable you want to histogram like "JetEne") and 0132 * produces a list of histogram names compliant w/ the 0133 * rest of the jet QA. 0134 * 0135 * The format should always be: 0136 * h_<module name>_<trigger tag>_<jet tag>_<base name> + <tag> 0137 * 0138 * FIXME this should get moved into JetQADefs.h 0139 */ 0140 inline std::vector<std::string> MakeQAHistNames( 0141 const std::vector<std::string>& bases, 0142 const std::string& module, 0143 const std::string& tag = "") 0144 { 0145 // copy base names to list of hist names 0146 std::vector<std::string> names = bases; 0147 0148 // inject module names, tags, etc. 0149 for (auto& name : names) 0150 { 0151 name.insert(0, "h_" + module + "_"); 0152 if (!tag.empty()) 0153 { 0154 name.append("_" + tag); 0155 } 0156 std::transform( 0157 name.begin(), 0158 name.end(), 0159 name.begin(), 0160 ::tolower); 0161 } 0162 return names; 0163 0164 } // end 'MakeQAHistNames( 0165 0166 } // namespace BeamBackgroundFilterAndQADefs 0167 0168 #endif 0169 0170 // end ========================================================================
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |