9#include "GaudiKernel/Incident.h"
10#include "GaudiKernel/IIncidentSvc.h"
11#include "GaudiKernel/GaudiException.h"
42#include "GaudiKernel/ThreadLocalContext.h"
65 m_ttSvc(
"CaloTriggerTowerService/CaloTriggerTowerService", this),
71 declareInterface<IL1TriggerTowerTool>(
this);
97 if(!
m_ttSvc.retrieve().isSuccess()) {
104 if (scID.isFailure()) {
115 SmartIF<IIncidentSvc> incSvc{service(
"IncidentSvc")};
117 incSvc->addListener(
this,
"BeginRun");
131 return StatusCode::SUCCESS;
138 return StatusCode::SUCCESS;
145 if (inc.type()==
"BeginRun") {
188 ATH_MSG_ERROR(
"non-Run2 no longer supported ... requires update to L1CaloCondAlg to create non-Run2 versions of containers");
189 return StatusCode::FAILURE;
191 return StatusCode::SUCCESS;
197 std::vector<int> &
et, std::vector<int> &bcidResults,
198 std::vector<int> &bcidDecisions,
bool useJepLut )
204 process(digits,
id,
et, bcidResults, bcidDecisions, useJepLut);
211 std::vector<int> &
et, std::vector<int> &bcidResults,
212 std::vector<int> &bcidDecisions,
bool useJepLut )
218 ATH_MSG_VERBOSE(
" channelID: " << MSG::hex << channelId.id() << MSG::dec );
224 bcidDecisions.clear();
229 std::vector<int> filter;
230 fir(digits, channelId, filter);
231 std::vector<int> lutInput;
232 dropBits(filter, channelId, lutInput);
237 bcid(filter, digits, channelId, bcidResults);
242 std::vector<int> decisionRange;
244 bcidDecision(bcidResults, decisionRange, channelId, bcidDecisions);
249 std::vector<int> lutOutput;
251 if(useJepLut)
jepLut(lutInput, channelId, lutOutput);
252 else cpLut(lutInput, channelId, lutOutput);
254 lut(lutInput, channelId, lutOutput);
268template <
typename DST,
typename SRC>
269std::vector<DST> convertVectorType(
const std::vector<SRC>& s) {
270 std::vector<DST> d(s.size());
271 std::transform(std::begin(s), std::end(s), std::begin(d),
272 [](SRC v){
return static_cast<DST
>(v);});
283 unsigned int readoutConfigID = std::cbegin(*m_runParametersContainer)->readoutConfigID();
289 std::vector<uint16_t> digits40;
291 if(readoutConfigID == 5 or readoutConfigID == 6){
297 int nSlices = tt.adc().size();
300 for (
int i=0 ; i < (nSlices-1)/2 ; i++ ){
301 digits40.push_back(tt.adc().at(2*i+1));
304 else if((nSlices%4)==1){
305 for (
int i=0 ; i <= (nSlices-1)/2 ; i++){
306 digits40.push_back(tt.adc().at(2*i));
318 const auto& digits = convertVectorType<int>(digits40);
326 ATH_MSG_VERBOSE(
"::simulateChannel: channelID: " << MSG::hex << channelId.id() << MSG::dec );
333 bcidDecisions.clear();
337 std::vector<int> filter;
338 fir(digits, channelId, filter);
346 const std::size_t nCorr = tt.correctionEnabled().size();
347 const std::size_t filterOffset = filter.size()/2 - nCorr/2;
348 for(std::size_t iCorr = 0; iCorr < nCorr; ++iCorr) {
349 filter[filterOffset + iCorr] -= tt.correction()[iCorr] * tt.correctionEnabled()[iCorr];
353 std::vector<int> lutInput;
354 dropBits(filter, channelId, lutInput);
359 bcid(filter, digits, channelId, bcidResults);
364 std::vector<int> decisionRange;
366 bcidDecision(bcidResults, decisionRange, channelId, bcidDecisions);
371 std::vector<int> cpLutOutput, jepLutOutput;
372 cpLut(lutInput, channelId, cpLutOutput);
373 jepLut(lutInput, channelId, jepLutOutput);
379 applyEtRange(cpLutOutput, decisionRange, channelId, outCpLut);
380 applyEtRange(jepLutOutput, decisionRange, channelId, outJepLut);
391 std::vector<int> peak;
393 std::vector<int> sat;
394 satBcid(digits, channelId, sat);
397 output.reserve(sat.size());
399 std::vector<int>::iterator itpeak = peak.begin();
400 std::vector<int>::iterator itsat = sat.begin();
401 for ( ; itpeak!=peak.end() && itsat!=sat.end(); ++itpeak, ++itsat ) {
402 output.push_back( (*itpeak<<2) + (*itsat<<1) );
415 unsigned int strategy,
int satLow,
int satHigh,
int satLevel, std::vector<int> &output)
418 std::vector<int> peak;
420 std::vector<int> sat;
421 satBcid(digits, satLow, satHigh, satLevel, sat);
424 output.reserve(sat.size());
426 std::vector<int>::iterator itpeak = peak.begin();
427 std::vector<int>::iterator itsat = sat.begin();
428 for ( ; itpeak!=peak.end() && itsat!=sat.end(); ++itpeak, ++itsat ) {
429 output.push_back( (*itpeak<<2) + (*itsat<<1) );
441void L1TriggerTowerTool::bcid(
const std::vector<int> &filter,
const std::vector<int> &lutInput,
const std::vector<int> &digits,
int energyLow,
int energyHigh,
int decisionSource, std::vector<unsigned int> &decisionConditions,
442 unsigned int strategy,
int satLow,
int satHigh,
int satLevel, std::vector<int> &
result, std::vector<int> &decision)
445 std::vector<int> peak;
447 std::vector<int> sat;
448 satBcid(digits, satLow, satHigh, satLevel, sat);
451 result.reserve(sat.size());
454 std::vector<int>::iterator itpeak = peak.begin();
455 std::vector<int>::iterator itsat = sat.begin();
456 for ( ; itpeak!=peak.end() && itsat!=sat.end(); ++itpeak, ++itsat ) {
457 result.push_back( (*itpeak<<2) + (*itsat<<1) );
466 std::vector<int> decisionRange;
467 if (!(decisionSource&0x1))
etRange(digits, energyLow, energyHigh, decisionRange);
468 else etRange(lutInput, energyLow, energyHigh, decisionRange);
479 const std::vector<short int>* getFirCoefficients(
unsigned int coolId, std::any&
C) {
480 auto settings = std::any_cast<T*>(
C)->pprConditions(coolId);
481 if(!settings)
return nullptr;
482 return &(settings->firCoefficients());
492 std::vector<int> firCoeffs;
494 const std::vector<short int>* hwCoeffs;
496 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(),
m_conditionsContainer);
503 firCoeffs.reserve(hwCoeffs->size());
504 for (
int i = hwCoeffs->size()-1; i >= 0; --i) firCoeffs.push_back((*hwCoeffs)[i]);
515 fir(digits, firCoeffs, output);
525 output.reserve(digits.size());
530 for (
unsigned int i = 0; i < firCoeffs.size(); ++i) {
531 if (firstFIR < 0 && firCoeffs[i] != 0) firstFIR = i;
532 if (firCoeffs[i] != 0) lastFIR = i;
534 if (firstFIR < 0) firstFIR = lastFIR + 1;
536 for (
int i = 0; i < (int)digits.size(); i++) {
539 if (i >= 2-firstFIR && i < (
int)digits.size()+2-lastFIR) {
540 for (
int j = firstFIR; j <= lastFIR; ++j) {
541 sum += digits[i+j-2]*firCoeffs[j];
544 if (sum < 0) sum = 0;
545 output.push_back(sum);
556 unsigned int getStrategy(std::any&
C) {
557 return std::any_cast<T*>(
C)->peakFinderCond();
564 unsigned int strategy = 0;
570 }
else ATH_MSG_WARNING(
"::peakBcid: No Conditions Container retrieved" );
581 output.reserve(
fir.size());
583 for (
unsigned int i = 0; i <
fir.size(); i++) {
586 if (i > 0 && i <
fir.size()-1) {
605 std::tuple<bool, int, int, int> getSaturation(
unsigned int coolId, std::any&
C) {
606 auto settings = std::any_cast<T*>(
C)->pprConditions(coolId);
607 if(!settings)
return std::make_tuple(
false, 0, 0, 0);
608 return std::make_tuple(
true, settings->satBcidLevel(), settings->satBcidThreshLow(),
609 settings->satBcidThreshHigh());
620 bool available =
false;
622 std::tie(available, satLevel, satLow, satHigh) = getSaturation<L1CaloPprConditionsContainerRun2>(channelId.id(),
m_conditionsContainer);
624 std::tie(available, satLevel, satLow, satHigh) = getSaturation<L1CaloPprConditionsContainer>(channelId.id(),
m_conditionsContainer);
625 if(!available)
ATH_MSG_WARNING(
"::satBcid: No L1CaloPprConditions found" );
626 }
else ATH_MSG_WARNING(
"::satBcid: No Conditions Container retrieved" );
629 <<
" satLow: " << satLow
630 <<
" satHigh: " << satHigh );
632 satBcid(digits, satLow, satHigh, satLevel, output);
640 output.reserve(digits.size());
645 for (
unsigned int i = 0; i<digits.size(); i++) {
651 if (digits[i]>=satLevel) {
652 if (enabled && i>1) {
653 bool low = (digits[i-2]>satLow);
654 bool high = (digits[i-1]>satHigh);
672 output.push_back(flag[0]);
684 unsigned int getDecisionSource(std::any&
C) {
685 return std::any_cast<T*>(
C)->decisionSource();
691 int decisionSource = 0;
696 }
else ATH_MSG_WARNING(
"::bcidDecisionRange: No Conditions Container retrieved" );
698 if (!(decisionSource&0x1))
etRange(digits, channelId, output);
699 else etRange(lutInput, channelId, output);
701 ATH_MSG_VERBOSE(
"::bcidDecisionRange: decisionSource: " << decisionSource);
711 std::tuple<unsigned int, unsigned int, unsigned int> getBcidDecision(std::any&
C) {
712 auto CC = std::any_cast<T*>(
C);
713 return std::make_tuple(CC->bcidDecision1(), CC->bcidDecision2(), CC->bcidDecision3());
718 unsigned int decision1 = 0;
719 unsigned int decision2 = 0;
720 unsigned int decision3 = 0;
723 std::tie(decision1, decision2, decision3) = getBcidDecision<L1CaloPprConditionsContainerRun2>(
m_conditionsContainer);
725 std::tie(decision1, decision2, decision3) = getBcidDecision<L1CaloPprConditionsContainer>(
m_conditionsContainer);
726 }
else ATH_MSG_WARNING(
"::bcidDecision: No Conditions Container retrieved" );
729 std::vector<unsigned int> mask = { decision3, decision2, decision1 };
732 << decision3 <<
" " << decision2 <<
" " << decision1 << MSG::dec );
742 output.reserve(bcidResults.size());
744 std::vector<int>::const_iterator itBcid = bcidResults.begin();
745 std::vector<int>::const_iterator itRange = range.begin();
746 int nRange = mask.size();
748 for ( ; itBcid != bcidResults.end() && itRange != range.end(); ++itBcid, ++itRange) {
749 if ((*itRange) < nRange && (mask[*itRange]&(0x1<<*itBcid))) output.push_back(1);
750 else output.push_back(0);
786 << strategy <<
" " << offset <<
" " << slope <<
" " << cut <<
" " << ped <<
" " );
788 unsigned int noiseCut = 0;
790 if (noiseCut > 0) cut = noiseCut;
792 lut(
fir, slope, offset, cut, ped, strategy, disabled, output);
801 double offsetReal = 0;
804 unsigned short scale = 0;
808 const std::vector<short int>* hwCoeffs;
827 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(),
m_conditionsContainer);
829 for (
unsigned int i = 0; i < hwCoeffs->size(); i++){
830 hwCoeffSum += hwCoeffs->at(i);
834 offsetReal = pedMean * hwCoeffSum /
pow(2.,startBit);
837 offsetReal = pedMean * hwCoeffSum * slope /
pow(2.,startBit) - slope/2.;
839 offset =
static_cast<unsigned short>( offsetReal < 0. ? 0 : offsetReal + 0.5 );
841 ATH_MSG_VERBOSE(
"::cpLut: Offset: offset/strategy/pedMean/firCoeffSum/startBit/slope: "
842 << offset <<
" " << strategy <<
" " <<
" " << pedMean <<
" " << hwCoeffSum <<
" " << startBit <<
" " << slope );
845 }
else ATH_MSG_WARNING(
"::cpLut: No Conditions Container retrieved" );
848 << strategy <<
" " << offset <<
" " << slope <<
" " << cut <<
" " << ped <<
" " );
850 unsigned int noiseCut = 0;
852 if (noiseCut > 0) cut = noiseCut;
855 lut(
fir, scale*slope, scale*offset, scale*cut, ped, 1, disabled, output);
856 }
else if(strategy == 1 || strategy == 0){
857 lut(
fir, slope, offset, cut, ped, strategy, disabled, output);
866 double offsetReal = 0;
869 unsigned short scale_db = 0;
870 unsigned short scale_menu = 0;
874 const std::vector<short int>* hwCoeffs;
898 scale_menu = l1Menu->thrExtraInfo().JET().jetScale();
906 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(),
m_conditionsContainer);
908 for (
unsigned int i = 0; i < hwCoeffs->size(); i++){
909 hwCoeffSum += hwCoeffs->at(i);
913 offsetReal = pedMean * hwCoeffSum /
pow(2.,startBit);
916 offsetReal = pedMean * hwCoeffSum * slope /
pow(2.,startBit) - slope/2.;
918 offset =
static_cast<unsigned short>( offsetReal < 0. ? 0 : offsetReal + 0.5 );
920 ATH_MSG_VERBOSE(
"::jepLut: Offset: offset/strategy/pedMean/firCoeffSum/startBit/slope: "
921 << offset <<
" " << strategy <<
" " <<
" " << pedMean <<
" " << hwCoeffSum <<
" " << startBit <<
" " << slope );
924 }
else ATH_MSG_WARNING(
"::jepLut: No Conditions Container retrieved" );
927 << strategy <<
" " << offset <<
" " << slope <<
" " << cut <<
" " << ped <<
" " );
929 unsigned int noiseCut = 0;
931 if (noiseCut > 0) cut = noiseCut;
934 nonLinearLut(
fir, slope, offset, cut, scale_db, par1, par2, par3, par4, disabled, output);
936 else if(strategy == 2) {
938 lut(
fir, scale_menu*slope, scale_menu*offset, scale_menu*cut, ped, 1, disabled, output);
939 }
else if(strategy == 1 || strategy == 0) {
940 lut(
fir, slope, offset, cut, ped, strategy, disabled, output);
946void L1TriggerTowerTool::lut(
const std::vector<int> &
fir,
int slope,
int offset,
int cut,
int ,
int strategy,
bool disabled, std::vector<int> &output)
949 output.reserve(
fir.size());
951 std::vector<int>::const_iterator it =
fir.begin();
952 for ( ; it !=
fir.end(); ++it) {
955 if (strategy == 0 && (*it) >= offset+cut) {
956 out = (((*it)-offset)*slope + 2048)>>12;
957 }
else if (strategy == 1 && (*it)*slope >= offset+cut) {
958 out = ((*it)*slope - offset + 2048)>>12;
960 if (out < 0) out = 0;
963 output.push_back(out);
972void L1TriggerTowerTool::nonLinearLut(
const std::vector<int> &
fir,
int slope,
int offset,
int cut,
int scale,
short par1,
short par2,
short par3,
short par4,
bool disabled, std::vector<int> &output)
975 output.reserve(
fir.size());
977 std::vector<int>::const_iterator it =
fir.begin();
978 for ( ; it !=
fir.end(); ++it) {
982 double nll_slope = 0.001 * scale;
983 double nll_offset = 0.001 * par1;
984 double nll_ampl = 0.001 * par2;
985 double nll_expo = 0.;
987 nll_expo = -1. / (4096 * 0.001*par3);
991 double nll_noise = 0.001 * par4;
994 if ((*it) * slope < offset + nll_noise * cut) {
999 out = int((((
int)(2048 + nll_slope * ((*it) * slope - offset)))>>12) + nll_offset + nll_ampl * std::exp(nll_expo * ((*it) * slope - offset)));
1002 if(out < 0) out = 0;
1004 output.push_back(out);
1018 std::vector<int>::const_iterator itlut =
lut.begin();
1019 std::vector<int>::const_iterator itrange = range.begin();
1020 while ( itlut !=
lut.end() && itrange != range.end() ) {
1022 else output.push_back(*itlut);
1036 std::tuple<bool, int, int> getBcidEnergyRange(
unsigned int coolId, std::any&
C) {
1037 auto settings = std::any_cast<T*>(
C)->pprConditions(coolId);
1038 if(!settings)
return std::make_tuple(
false, 0, 0);
1039 return std::make_tuple(
true, settings->bcidEnergyRangeLow(), settings->bcidEnergyRangeHigh());
1048 bool available =
false;
1050 std::tie(available, energyLow, energyHigh) = getBcidEnergyRange<L1CaloPprConditionsContainerRun2>(channelId.id(),
m_conditionsContainer);
1052 std::tie(available, energyLow, energyHigh) = getBcidEnergyRange<L1CaloPprConditionsContainer>(channelId.id(),
m_conditionsContainer);
1054 if(!available)
ATH_MSG_WARNING(
"::etRange: No L1CaloPprConditions found");
1055 }
else ATH_MSG_WARNING(
"::etRange: No Conditions Container retrieved");
1058 <<
" energyHigh: " << energyHigh);
1060 etRange(
et, energyLow, energyHigh, output);
1068 output.reserve(
et.size());
1069 for (std::vector<int>::const_iterator it =
et.begin(); it !=
et.end(); ++it) {
1070 if ((*it) <= energyLow) output.push_back(0);
1071 else if ((*it) <= energyHigh) output.push_back(1);
1072 else output.push_back(2);
1084 std::tuple<bool, int> getFirStartBit(
unsigned int coolId, std::any&
C) {
1085 auto settings = std::any_cast<T*>(
C)->pprConditions(coolId);
1086 if(!settings)
return std::make_tuple(
false, 0);
1087 return std::make_tuple(
true, settings->firStartBit());
1093 unsigned int start = 0;
1095 bool available =
false;
1097 std::tie(available, start) = getFirStartBit<L1CaloPprConditionsContainerRun2>(channelId.id(),
m_conditionsContainer);
1099 std::tie(available, start) = getFirStartBit<L1CaloPprConditionsContainer>(channelId.id(),
m_conditionsContainer);
1100 if(!available)
ATH_MSG_WARNING(
"::dropBits: No L1CaloPprConditions found" );
1101 }
else ATH_MSG_WARNING(
"::dropBits: No Conditions Container retrieved" );
1113 output.reserve(
fir.size());
1116 unsigned int mask = (0x3ff<<start);
1119 int max = 1<<(10+start);
1121 for (std::vector<int>::const_iterator it =
fir.begin(); it !=
fir.end(); ++it) {
1122 if ((*it)>=
max) output.push_back(0x3ff);
1123 else output.push_back(((*it)&mask)>>start);
1138 const std::vector<short int>* hwCoeffs =
nullptr;
1140 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(),
m_conditionsContainer);
1148 firCoeffs.reserve(hwCoeffs->size());
1149 for (
int i = hwCoeffs->size()-1; i >= 0; --i) firCoeffs.push_back((*hwCoeffs)[i]);
1151 }
else ATH_MSG_WARNING(
"::firParams: No L1CaloPprConditions found" );
1152 }
else ATH_MSG_WARNING(
"::firParams: No Conditions Container retrieved" );
1163 unsigned int &peakFinderStrategy,
int &satLow,
int &satHigh,
int &satLevel)
1168 decisionConditions.clear();
1169 peakFinderStrategy = 0;
1176 std::tuple<unsigned int, unsigned int, unsigned int>
bcidDecision;
1177 std::tuple<bool, int, int> bcidEnergyRange;
1178 std::tuple<bool, int, int, int> saturation;
1198 if(
get<0>(bcidEnergyRange)) {
1199 std::tie(std::ignore, energyLow, energyHigh) = bcidEnergyRange;
1203 std::tie(std::ignore, satLevel, satLow, satHigh) = saturation;
1205 }
else ATH_MSG_WARNING(
"::bcid:Params No Conditions Container retrieved" );
1208 <<
" satLow: " << satLow <<
" satHigh: " << satHigh <<
endmsg
1209 <<
" energyLow: " << energyLow <<
" energyHigh: " << energyHigh <<
endmsg
1210 <<
" decisionSource: " << decisionSource <<
" peakFinderStrategy: "
1211 << peakFinderStrategy );
1243 pedMean = settings->
pedMean();
1244 }
else ATH_MSG_WARNING(
"::lutParams: No L1CaloPprConditions found" );
1245 }
else ATH_MSG_WARNING(
"::lutParams: No Conditions Container retrieved" );
1247 ATH_MSG_VERBOSE(
"::lutParams: LUT startBit/strategy/offset/slope/cut/pedValue/pedMean: "
1248 << startBit <<
" " << strategy <<
" " << offset <<
" " << slope <<
" " << cut <<
" " << pedValue <<
" " << pedMean );
1249 unsigned int noiseCut = 0;
1251 if (noiseCut > 0) cut = noiseCut;
1259 double offsetReal = 0;
1266 const std::vector<short int>* hwCoeffs;
1283 pedMean = settings->
pedMean();
1285 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(),
m_conditionsContainer);
1286 for (
unsigned int i = 0; i < hwCoeffs->size(); i++){
1287 hwCoeffSum += hwCoeffs->at(i);
1291 offsetReal = pedMean * hwCoeffSum /
pow(2.,startBit);
1294 offsetReal = pedMean * hwCoeffSum * slope /
pow(2.,startBit) - slope/2.;
1296 offset =
static_cast<unsigned short>( offsetReal < 0. ? 0 : offsetReal + 0.5 );
1298 ATH_MSG_VERBOSE(
"::jepLutParams: Offset: offset/strategy/pedMean/firCoeffSum/startBit/slope: "
1299 << offset <<
" " << strategy <<
" " <<
" " << pedMean <<
" " << hwCoeffSum <<
" " << startBit <<
" " << slope );
1301 }
else ATH_MSG_WARNING(
"::cpLutParams: No L1CaloPprConditions found" );
1302 }
else ATH_MSG_WARNING(
"::cpLutParams: No Conditions Container retrieved" );
1304 ATH_MSG_VERBOSE(
"::cpLutParams: LUT startBit/strategy/offset/slope/cut/pedValue/pedMean: "
1305 << startBit <<
" " << strategy <<
" " << offset <<
" " << slope <<
" " << cut <<
" " << pedValue <<
" " << pedMean );
1306 unsigned int noiseCut = 0;
1308 if (noiseCut > 0) cut = noiseCut;
1316 double offsetReal = 0;
1323 const std::vector<short int>* hwCoeffs;
1340 pedMean = settings->
pedMean();
1342 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(),
m_conditionsContainer);
1344 for (
unsigned int i = 0; i < hwCoeffs->size(); i++){
1345 hwCoeffSum += hwCoeffs->at(i);
1349 offsetReal = pedMean * hwCoeffSum /
pow(2.,startBit);
1352 offsetReal = pedMean * hwCoeffSum * slope /
pow(2.,startBit) - slope/2.;
1354 offset =
static_cast<unsigned short>( offsetReal < 0. ? 0 : offsetReal + 0.5 );
1356 ATH_MSG_VERBOSE(
"::jepLutParams: Offset: offset/strategy/pedMean/firCoeffSum/startBit/slope: "
1357 << offset <<
" " << strategy <<
" " <<
" " << pedMean <<
" " << hwCoeffSum <<
" " << startBit <<
" " << slope );
1359 }
else ATH_MSG_WARNING(
"::jepLutParams: No L1CaloPprConditions found" );
1360 }
else ATH_MSG_WARNING(
"::jepLutParams: No Conditions Container retrieved" );
1362 ATH_MSG_VERBOSE(
"::jepLutParams: LUT startBit/strategy/offset/slope/cut/pedValue/pedMean: "
1363 << startBit <<
" " << strategy <<
" " << offset <<
" " << slope <<
" " << cut <<
" " << pedValue <<
" " << pedMean );
1364 unsigned int noiseCut = 0;
1366 if (noiseCut > 0) cut = noiseCut;
1380 id =
m_lvl1Helper->tower_id(pos_neg_z, layer, region, ieta, iphi);
1391 try { hwId =
m_ttSvc->createTTChannelID(
id,
false); }
1410 const double absEta = fabs(
eta);
1413 const int etaBin = 10.*absEta;
1414 const int phiBin =
phi*(32/
M_PI);
1415 index = (etaBin<<6) + phiBin;
1416 }
else if (absEta < 3.2) {
1417 const int etaBin = 5.*(absEta - 2.5);
1418 const int phiBin =
phi*(16./
M_PI);
1419 index = 1600 + (etaBin<<5) + phiBin;
1421 const int etaBin = (absEta - 3.2)*(1./0.425);
1422 const int phiBin =
phi*(8./
M_PI);
1423 index = 1728 + (etaBin<<4) + phiBin;
1426 if (layer > 0)
index += 3584;
1448 coolId =
m_ttSvc->createL1CoolChannelId(hwId);
1458 std::tuple<bool, bool, bool> getSatOverride(std::any&
C) {
1459 auto CC = std::any_cast<T*>(
C);
1460 return std::make_tuple(CC->satOverride1(), CC->satOverride2(), CC->satOverride3());
1466 bool override =
false;
1474 if (range == 0)
override = std::get<2>(
satOverride);
1475 if (range == 1)
override = std::get<1>(
satOverride);
1476 if (range == 2)
override = std::get<0>(
satOverride);
1477 }
else ATH_MSG_WARNING(
"::satOverride: No Conditions Container retrieved" );
1480 <<
" has saturation override flag " <<
override );
1489 unsigned int noiseCut = 0;
1496 bool isDisabled =
false;
1501 else disabledChan = std::any_cast<L1CaloPprDisabledChannelContainer*>(
m_disabledChannelContainer)->pprDisabledChannel(channelId.id());
1511 }
else isDisabled =
true;
1514 <<
"::disabledChannel: calibErrorCode: " << (disabledChan->
calibErrorCode()).errorCode()
1515 <<
" deadErrorCode: " << (disabledChan->
deadErrorCode()).errorCode()
1516 <<
" noiseCut: " << disabledChan->
noiseCut()
1521 ATH_MSG_VERBOSE(
"::disabledChannel: No L1CaloPprDisabledChannel found" );
1524 ATH_MSG_WARNING(
"::disabledChannel: No DisabledChannel Container retrieved" );
1543 double eta = nominalEta;
1544 float abseta = fabs(
eta);
1545 if (abseta<3.2)
return eta;
1547 int sign = ((
eta > 0) ? 1 : -1);
1548 if (abseta < 3.6)
eta = 3.15 *
sign;
1549 else if (abseta < 4.0)
eta = 3.33 *
sign;
1550 else if (abseta < 4.5)
eta = 3.72 *
sign;
1554 if (abseta < 3.6)
eta = 3.36;
1555 else if (abseta < 4.0)
eta = 3.45;
1556 else if (abseta < 4.5)
eta = 4.17;
1560 if (abseta < 3.6)
eta = -3.45;
1561 else if (abseta < 4.0)
eta = -3.36;
1562 else if (abseta < 4.5)
eta = -4.19;
1575 throw GaudiException(
"No mapping tool configured",
1576 "L1TriggerTowerTool::FCalTTeta", StatusCode::FAILURE);
1580 unsigned int crate = channelId.crate();
1581 unsigned int module = channelId.module();
1582 unsigned int mcm = channelId.subModule();
1583 unsigned int pin = channelId.channel();
1584 int channel = pin*16 + mcm;
1591 ATH_MSG_WARNING(
"::FCalTTeta: could not map 0x" << std::hex << channelId.id() << std::dec);
1599template <
typename T>
1628 return StatusCode::SUCCESS;
1648 <<
"::refValues: errorCode: " << (ftref->
errorCode()).errorCode()
1649 << MSG::dec <<
" reference: " << ftref->
refValue() <<
" calib: " << ftref->
calibValue() );
1658 return std::make_pair(
reference, calib);
1662 unsigned nFIR = firInOut.size();
1663 correctionOut.assign(nFIR, 0u);
1668 for(
unsigned i = 0; i != nFIR; ++i) {
1670 firInOut[i] -= correctionOut[i];
1672 if(firInOut[i] < 0) firInOut[i] = 0;
1684 const EventContext& ctx = Gaudi::Hive::currentContext();
1685 if (ctx.eventID().run_number() >= 253377)
return true;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::vector< size_t > vec
#define CHECK_WITH_CONTEXT(...)
Evaluate an expression and check for errors, with an explicitly specified context name.
Handle class for reading from StoreGate.
constexpr int pow(int base, int exp) noexcept
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
Exception class for Calo Identifiers.
ChanCalibErrorCode class for L1Calo error codes Adapted from /LVL1/l1calo/coolL1Calo/coolL1Calo/ChanE...
bool chanValid() const
Checks if channel is valid, ie.
ChanDeadErrorCode class for L1Calo error codes Adapted from /LVL1/l1calo/coolL1Calo/coolL1Calo/ChanDe...
FineTimeErrorCode class for L1Calo error codes.
Encapsulates the ID of one channel of conditions data in COOL, ie the ID of a row in a table.
FineTimeErrorCode errorCode(void) const
double calibValue(void) const
double refValue(void) const
Container of L1CaloPprConditions objects, inherit from the abstract base class AbstractL1CaloConditio...
Container of L1CaloPprConditions objects, inherit from the abstract base class AbstractL1CaloConditio...
Transient conditions class for objects defined by the online framework and retrieved from COOL for th...
unsigned short lutJepSlope() const
unsigned short lutCpStrategy() const
unsigned short lutCpSlope() const
unsigned short lutCpNoiseCut() const
unsigned short lutCpScale() const
unsigned short firStartBit() const
unsigned short lutJepStrategy() const
unsigned short lutJepScale() const
unsigned int pedValue() const
unsigned short lutJepNoiseCut() const
Transient conditions class for objects defined by the online framework and retrieved from COOL.
unsigned short lutStrategy() const
unsigned short lutSlope() const
unsigned short firStartBit() const
unsigned int pedValue() const
unsigned short lutOffset() const
unsigned short lutNoiseCut() const
Transient conditions class for objects defined by the online framework and retrieved from COOL.
ChanCalibErrorCode calibErrorCode(void) const
unsigned int disabledBits() const
ChanDeadErrorCode deadErrorCode(void) const
unsigned int noiseCut() const
@ IS_SIMULATION
true: simulation, false: data
const std::string process
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
TriggerTower_v2 TriggerTower
Define the latest version of the TriggerTower class.
Extra patterns decribing particle interation process.