20 m_rateAccumulatorOR(0.),
21 m_rateAccumulatorAND(0.),
22 m_rateAccumulatorOR2(0.),
23 m_rateAccumulatorAND2(0.),
24 m_doCachedWeights(
false),
26 m_useCachedWeights(
false),
28 m_masterGroup(
nullptr),
29 m_uniqueTrigger(
nullptr),
30 m_isExpressGroup(
false),
40 if (child.first != std::hash<std::string>{}(
""))
ss <<
"\t" << (**(child.second.begin())).getSeedName() <<
" ->" << std::endl;
41 for (
const auto& chain : child.second) {
42 ss <<
"\t\t" << chain->getName() << std::endl;
51 <<
" +- " << std::setw(11) << std::left << sqrt(
m_rateAccumulatorOR2)/ratesDenominator <<
" Hz, "
60 if (
m_children.count(toAdd->getSeedHash()) == 0) {
61 m_children.insert( std::make_pair(toAdd->getSeedHash(), std::set<const RatesTrigger*>() ) );
64 m_children.at(toAdd->getSeedHash()).insert(toAdd);
68 if (
m_children.count(toRemove->getSeedHash()) == 0)
return;
69 m_children.at(toRemove->getSeedHash()).erase(toRemove);
83 double weightOR = 1., weightAND = 1.;
92 const std::set<const RatesTrigger*>& triggers = element.second;
95 double weightHLT_OR = 1.;
96 double weightHLT_AND = 1.;
97 std::unordered_map<size_t, RatesCPS> weightHLT_CPS;
99 for (
const auto& trigger : triggers) {
100 if (trigger->getPassed()) {
102 const double trigPrescaleReciprocal = 1. / trigger->getPrescale(
m_isExpressGroup );
104 weightL1 = 1. / trigger->getSeedPrescale();
105 weightHLT_AND *= trigPrescaleReciprocal;
107 const size_t CPSID = trigger->getCPSID();
109 weightHLT_OR *= 1. - trigPrescaleReciprocal;
111 RatesCPS& cps = weightHLT_CPS[CPSID];
113 cps.
execute( 1. / trigPrescaleReciprocal );
123 if (
isZero(weightHLT_OR) &&
isZero(weightHLT_AND))
break;
127 for (
const auto& cps : weightHLT_CPS) weightHLT_OR *= 1. - cps.second.getWeight();
129 weightOR *= 1. - (weightL1 * (1. - weightHLT_OR));
130 weightAND *= weightL1 * weightHLT_AND;
137 if (cacheElement.first == element.first)
continue;
138 cacheElement.second *= 1. - (weightL1 * (1. - weightHLT_OR));
147 size_t myOneAndOnlyL1SeedHash = (
m_children.begin())->first;
148 weightOR *=
m_masterGroup->getCachedWeight( myOneAndOnlyL1SeedHash );
153 const double wOR = w * (1. - weightOR);
154 const double wAND = w * weightAND;
181 return diff / ratesDenominator;
@ kPASS_WEIGHTED_AND_BIN
Bin used to store the total rate (AND)
@ kPASS_WEIGHTED_OR_BIN
Bin used to store the total rate (OR)
@ kUNIQUE_BIN
Bin used to store data needed to get the unique rate.
@ kLINEAR
Scale trigger linearly with luminosity.
@ kNONE
Do not scale this trigger for changes in luminosity.
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Helper class to keep track of coherent prescales between chains in a group This class knows about its...
double getWeight() const
Return the union product (OR of many chains) coherently weighted by the coherent factor.
void execute(const double prescale)
Keep track of a union product (OR of many chains) excluding the coherent part.
void setCoherentFactor(const double coherentFactor)
Set a common prescale factor for this group.
bool m_useCachedWeights
Efficiency.
void setUseCachedWeights(const bool i)
Set to use cached weights from the Master group (need ptr to m_masterGroup)
double getCachedWeight(const size_t l1Hash) const
Get cached weight from triggers seeding from a given L1 item.
bool m_doCachedWeights
Used in the global rates group.
void removeFromGroup(const RatesTrigger *toRemove)
Remove a trigger from this group.
void setDoCachedWeights(const bool i)
Flag group to cache weights.
double m_rateAccumulatorOR2
For stat error.
RatesTrigger * getUniqueTrigger()
Get the trigger I am doing unique rates for.
double m_rateAccumulatorAND
Numerator for the rate of the AND of all triggers.
const ExtrapStrat_t m_extrapolationStrategy
How this group is to scale with luminosity.
const std::string m_name
Name of the group.
const std::unordered_map< size_t, std::set< const RatesTrigger * > > & getChildren() const
void execute(const WeightingValuesSummary_t &weights)
Perform group rates evaluation.
void setExpressGroup(const bool i)
Flag this group as the express group (modifies group trigger's prescales)
double getUniqueWeight(const double ratesDenominator) const
Get the unique rate of a unique-rate group For a group being used to get a unique rate,...
RatesGroup(const std::string &name, IMessageSvc *msgSvc, const bool doHistograms=true, const bool doExtrapolation=true)
Construct new RatesGroup to enumerate the combined union (OR) and intersection (AND) rate of a set of...
const std::string printConfig() const
Prints the RatesGroup's configuration.
void duplicateChildren(const RatesGroup *toDuplicate)
Copy in triggers from another group.
const std::string printRate(const double ratesDenominator) const
Prints the RatesGroup's rate.
RatesTrigger * m_uniqueTrigger
If not nullptr, then a trigger this group is calculating the unique rate for.
void setUniqueTrigger(RatesTrigger *trigger)
Set trigger I am doing unique rates for.
void addToGroup(const RatesTrigger *toAdd)
Add a trigger to this group.
const RatesGroup * m_masterGroup
If not nullptr, then use the cached weights info in this master group object.
std::unordered_map< size_t, double > m_cachedWeights
Cached weight of the OR of all triggers except for the L1 seed-hash of the key here.
double m_rateAccumulatorAND2
For stat error.
double m_rateAccumulatorOR
Numerator for the rate of the OR of all triggers.
const size_t m_nameHash
Hash of the group's name.
bool m_isExpressGroup
If this group is calculating for the express stream - also include express prescales.
void removeOtherL1(const RatesTrigger *toKeep)
Remove from the groups mapping all triggers which have a dissimilar seed to the supplied trigger.
std::unordered_map< size_t, std::set< const RatesTrigger * > > m_children
const std::string & getExtrapolationFactorString(ExtrapStrat_t strat) const
double getExtrapolationFactor(const WeightingValuesSummary_t &weights, const ExtrapStrat_t strat) const
bool doHistograms() const
If histogramming was enabled in this rates object.
TH1 * m_rateVsTrainCachedPtr
Cached, non-owning pointer.
RatesHistoBase(const std::string &name, IMessageSvc *msgSvc, const bool doHistograms=true)
TH1 * m_rateVsMuCachedPtr
Cached, non-owning pointer.
static bool isZero(double v)
TH1 * m_dataCachedPtr
Cached, non-owning pointer.
Used to calculate the rate for a single trigger at L1 or the HLT.
size_t getSeedHash() const
Structure to hold per-event weights for distribution.