The method to prescale chains.
If the prescale set input key is not defined or the chain does not exist in the prescale set, then the chains (or all chains) are kept according to the property KeepUnknownChains
97 if ( initiallyActive.empty() ) {
98 return StatusCode::SUCCESS;
102 remainActive.clear();
107 remainActive.reserve( initiallyActive.size() );
108 for(
const auto &
ch : initiallyActive ) {
109 remainActive.push_back(
ch);
112 return StatusCode::SUCCESS;
125 remainActive.reserve( initiallyActive.size() );
135 CHECK( eventInfoHandle.isValid() );
136 size_t seed = eventInfoHandle->timeStamp() ^ eventInfoHandle->timeStampNSOffset();
139 engine->setSeed( seed, 0 );
143 if (forExpressStream) {
144 return hltPrescaleSet->prescale_express(
ch.numeric() );
146 return hltPrescaleSet->
prescale(
ch.numeric() );
148 }
catch(
const std::out_of_range & ex) {
151 ATH_MSG_DEBUG(
"No prescale value for chain " <<
ch <<
", keeping it because "
160 auto decisionPerChain = [&](
const HLT::Identifier&
ch,
double prescaleValue ) ->
bool {
161 auto flat = engine->flat();
166 return flat < 1./ prescaleValue;
169 struct ChainAndPrescale {
172 double relativePrescale{};
178 if ( forExpressStream ||
std::find(initiallyActive.begin(), initiallyActive.end(), chainIDs.front()) != initiallyActive.end() ) {
179 std::vector<ChainAndPrescale> psValueSorted;
183 if ( forExpressStream &&
std::find(initiallyActive.begin(), initiallyActive.end(),
ch) == initiallyActive.end() ) {
186 auto ps = getPrescale(
ch);
188 psValueSorted.emplace_back( ChainAndPrescale({
ch, ps}) );
190 if ( psValueSorted.empty() ) {
193 std::sort(psValueSorted.begin(), psValueSorted.end(), [](
const ChainAndPrescale&
a,
const ChainAndPrescale&
b){
194 return a.ps.prescale < b.ps.prescale;
198 psValueSorted.front().relativePrescale = psValueSorted.front().ps.prescale;
199 if ( psValueSorted.size() > 1 ) {
200 for (
auto i = psValueSorted.begin()+1;
i < psValueSorted.end(); ++
i ) {
201 i->relativePrescale =
i->ps.prescale / (
i-1)->ps.prescale ;
206 for (
const ChainAndPrescale&
ch: psValueSorted ) {
213 for (
const ChainAndPrescale&
ch: psValueSorted ) {
214 const bool decision = decisionPerChain(
ch.id,
ch.relativePrescale);
215 if ( not decision ) {
break;}
216 remainActive.push_back(
ch.id );
223 if (
std::find( initiallyActive.begin(), initiallyActive.end(),
ch ) != initiallyActive.end() ) {
224 auto prescale = getPrescale(
ch);
225 if ( prescale.enabled ) {
226 const bool decision = decisionPerChain(
ch, prescale.prescale);
228 remainActive.push_back(
ch );
230 ATH_MSG_DEBUG(
"Prescaling decision for chain " <<
ch <<
" " << decision);
237 return StatusCode::SUCCESS;