File indexing completed on 2025-08-06 08:18:39
0001 #include "TriggerRunInfov1.h"
0002
0003 #include <phool/phool.h>
0004
0005 void TriggerRunInfov1::setTrigger(int index, const std::string& name, int bit, int prescale)
0006 {
0007 if (index >= 0 && index < 64)
0008 {
0009 trigger_names[index] = name;
0010 trigger_bits[index] = bit;
0011 trigger_initial_prescales[index] = prescale;
0012 }
0013 else
0014 {
0015 std::cout << PHWHERE << "Index out of bounds: " << index << std::endl;
0016 }
0017 }
0018
0019 void TriggerRunInfov1::setTriggerScalers(int index, int scalertype, uint64_t scalers)
0020 {
0021 if (index >= 0 && index < 64 && scalertype >= 0 && scalertype < 3)
0022 {
0023 trigger_scalers[index][scalertype] = scalers;
0024 }
0025 else
0026 {
0027 std::cout << PHWHERE << "Index out of bounds: " << index << std::endl;
0028 }
0029 }
0030
0031 void TriggerRunInfov1::setTriggerPrescale(int index, double prescale)
0032 {
0033 if (!(index >= 0 && index < 64))
0034 {
0035 std::cout << PHWHERE << "Index out of bounds: " << index << std::endl;
0036 return;
0037 }
0038
0039 if (prescale > 0)
0040 {
0041 trigger_prescales[index] = prescale;
0042 return;
0043 }
0044
0045 trigger_prescales[index] = -1;
0046
0047 return;
0048 }
0049
0050 double TriggerRunInfov1::getPrescaleByName(const std::string& name) const
0051 {
0052 for (int i = 0; i < 64; ++i)
0053 {
0054 if (trigger_names[i] == name)
0055 {
0056 return trigger_prescales[i];
0057 }
0058 }
0059 std::cout << PHWHERE << "Trigger name not found: " << name << std::endl;
0060 return 0;
0061 }
0062
0063 double TriggerRunInfov1::getPrescaleByBit(int triggerbit) const
0064 {
0065 if (triggerbit >= 0 && triggerbit < 64)
0066 {
0067 return trigger_prescales[triggerbit];
0068 }
0069 return -1;
0070 }
0071 int TriggerRunInfov1::getInitialPrescaleByName(const std::string& name) const
0072 {
0073 for (int i = 0; i < 64; ++i)
0074 {
0075 if (trigger_names[i] == name)
0076 {
0077 return trigger_initial_prescales[i];
0078 }
0079 }
0080 std::cout << PHWHERE << "Trigger name not found: " << name << std::endl;
0081 return 0;
0082 }
0083
0084 int TriggerRunInfov1::getInitialPrescaleByBit(int triggerbit) const
0085 {
0086 if (triggerbit >= 0 && triggerbit < 64)
0087 {
0088 return trigger_initial_prescales[triggerbit];
0089 }
0090 return -1;
0091 }
0092
0093 std::string TriggerRunInfov1::getTriggerName(int triggerbit) const
0094 {
0095 if (triggerbit >= 0 && triggerbit < 64)
0096 {
0097 return trigger_names[triggerbit];
0098 }
0099 return "unknown";
0100 }
0101
0102 uint64_t TriggerRunInfov1::getScalersByName(const std::string& name) const
0103 {
0104 for (int i = 0; i < 64; ++i)
0105 {
0106 if (trigger_names[i] == name)
0107 {
0108 return trigger_scalers[i][0];
0109 }
0110 }
0111 std::cout << PHWHERE << "Trigger name not found: " << name << std::endl;
0112 return 0;
0113 }
0114
0115 uint64_t TriggerRunInfov1::getScalersByBit(int triggerbit) const
0116 {
0117 if (triggerbit >= 0 && triggerbit < 64)
0118 {
0119 return trigger_scalers[triggerbit][0];
0120 }
0121 return -1;
0122 }
0123 uint64_t TriggerRunInfov1::getLiveScalersByName(const std::string& name) const
0124 {
0125 for (int i = 0; i < 64; ++i)
0126 {
0127 if (trigger_names[i] == name)
0128 {
0129 return trigger_scalers[i][1];
0130 }
0131 }
0132 std::cout << PHWHERE << "Trigger name not found: " << name << std::endl;
0133 return 0;
0134 }
0135
0136 uint64_t TriggerRunInfov1::getLiveScalersByBit(int triggerbit) const
0137 {
0138 if (triggerbit >= 0 && triggerbit < 64)
0139 {
0140 return trigger_scalers[triggerbit][1];
0141 }
0142 return -1;
0143 }
0144
0145 uint64_t TriggerRunInfov1::getRawScalersByName(const std::string& name) const
0146 {
0147 for (int i = 0; i < 64; ++i)
0148 {
0149 if (trigger_names[i] == name)
0150 {
0151 return trigger_scalers[i][2];
0152 }
0153 }
0154 std::cout << PHWHERE << "Trigger name not found: " << name << std::endl;
0155 return 0;
0156 }
0157
0158 uint64_t TriggerRunInfov1::getRawScalersByBit(int triggerbit) const
0159 {
0160 if (triggerbit >= 0 && triggerbit < 64)
0161 {
0162 return trigger_scalers[triggerbit][2];
0163 }
0164 return -1;
0165 }
0166
0167 uint32_t TriggerRunInfov1::getTriggerBitByName(const std::string& name) const
0168 {
0169 for (uint32_t i = 0; i < 64; ++i)
0170 {
0171 if (trigger_names[i] == name)
0172 {
0173 return i;
0174 }
0175 }
0176 std::cout << PHWHERE << "Trigger name not found: " << name << std::endl;
0177 return 0;
0178 }
0179
0180 void TriggerRunInfov1::identify(std::ostream& os) const
0181 {
0182 for (int i = 0; i < 64; ++i)
0183 {
0184 os << "Trigger " << i << ": Name = " << trigger_names[i]
0185 << ", Bit = " << trigger_bits[i]
0186 << ", Prescale = " << trigger_prescales[i]
0187 << ", Scalers = " << trigger_scalers[i][0] << "/" << trigger_scalers[i][1] << "/" << trigger_scalers[i][2] << std::endl;
0188 }
0189 }