8#include "GaudiKernel/Incident.h"
9#include "GaudiKernel/IIncidentSvc.h"
10#include "GaudiKernel/GaudiException.h"
46 m_ttSvc(
"CaloTriggerTowerService/CaloTriggerTowerService", this),
51 declareInterface<IL1TriggerTowerToolRun3>(
this);
74 if(!
m_ttSvc.retrieve().isSuccess()) {
81 if (scID.isFailure()) {
92 SmartIF<IIncidentSvc> incSvc{service(
"IncidentSvc")};
94 incSvc->addListener(
this,
"BeginRun");
111 return StatusCode::SUCCESS;
118 return StatusCode::SUCCESS;
125 if (inc.type()==
"BeginRun") {
137 const std::vector<int> &digits,
double eta,
double phi,
int layer,
138 std::vector<int> &
et, std::vector<int> &bcidResults,
139 std::vector<int> &bcidDecisions,
bool useJepLut )
145 process(ctx, digits,
id,
et, bcidResults, bcidDecisions, useJepLut);
153 std::vector<int> &
et, std::vector<int> &bcidResults,
154 std::vector<int> &bcidDecisions,
bool useJepLut )
159 ATH_MSG_DEBUG(
" channelID: " << MSG::hex << channelId.id() << MSG::dec );
165 bcidDecisions.clear();
170 std::vector<int> filter;
171 fir(ctx, digits, channelId, filter);
172 std::vector<int> lutInput;
173 dropBits(ctx, filter, channelId, lutInput);
178 bcid(ctx, filter, digits, channelId, bcidResults);
183 std::vector<int> decisionRange;
185 bcidDecision(ctx, bcidResults, decisionRange, bcidDecisions);
190 std::vector<int> lutOutput;
191 if(useJepLut)
jepLut(ctx, lutInput, channelId, lutOutput);
192 else cpLut(ctx, lutInput, channelId, lutOutput);
206template <
typename DST,
typename SRC>
207std::vector<DST> convertVectorType(
const std::vector<SRC>& s) {
208 std::vector<DST> d(s.size());
209 std::transform(std::begin(s), std::end(s), std::begin(d),
210 [](SRC v){
return static_cast<DST
>(v);});
221 unsigned int readoutConfigID = runParameters->runParameters(1)->readoutConfigID();
222 ATH_MSG_DEBUG(
"RunParameters:: readoutConfigID " << readoutConfigID);
224 std::vector<uint16_t> digits40;
226 if(readoutConfigID == 5 or readoutConfigID == 6){
229 ATH_MSG_DEBUG(
"::simulateChannel: 80 MHz readout detected, emulating 40 MHz samples");
231 int nSlices = tt.adc().size();
234 for (
int i=0 ; i < (nSlices-1)/2 ; i++ ){
235 digits40.push_back(tt.adc().at(2*i+1));
238 else if((nSlices%4)==1){
239 for (
int i=0 ; i <= (nSlices-1)/2 ; i++){
240 digits40.push_back(tt.adc().at(2*i));
250 const auto& digits = convertVectorType<int>(digits40);
254 ATH_MSG_DEBUG(
"::simulateChannel: ==== Entered Process ====" );
256 ATH_MSG_DEBUG(
"::simulateChannel: channelID: " << MSG::hex << channelId.id() << MSG::dec );
263 bcidDecisions.clear();
267 std::vector<int> filter;
268 fir(ctx, digits, channelId, filter);
272 ATH_MSG_DEBUG(
"::simulateChannel: ---- pedestalCorrection ----" );
275 const std::size_t nCorr = tt.correctionEnabled().size();
276 const std::size_t filterOffset = filter.size()/2 - nCorr/2;
277 for(std::size_t iCorr = 0; iCorr < nCorr; ++iCorr) {
278 filter[filterOffset + iCorr] -= tt.correction()[iCorr] * tt.correctionEnabled()[iCorr];
284 std::vector<int> lutInput;
285 dropBits(ctx, filter, channelId, lutInput);
287 ATH_MSG_DEBUG(
"::simulateChannel: ---- BCID algorithms ---- ");
290 bcid(ctx, filter, digits, channelId, bcidResults);
294 std::vector<int> decisionRange;
296 bcidDecision(ctx, bcidResults, decisionRange, bcidDecisions);
298 ATH_MSG_DEBUG(
"::simulateChannel: bcidDecisionRange " << decisionRange);
299 ATH_MSG_DEBUG(
"::simulateChannel: bcidDecisions " << bcidDecisions);
303 ATH_MSG_DEBUG(
"::simulateChannel: ---- LUT ET calculation ----" );
306 std::vector<int> cpLutOutput, jepLutOutput;
307 cpLut(ctx, lutInput, channelId, cpLutOutput);
308 jepLut(ctx, lutInput, channelId, jepLutOutput);
311 ATH_MSG_DEBUG(
"::simulateChannel: jepLut " << jepLutOutput);
313 ATH_MSG_DEBUG(
"::simulateChannel: ---- use ET range ----" );
317 applyEtRange(ctx, cpLutOutput, decisionRange, channelId, outCpLut);
318 applyEtRange(ctx, jepLutOutput, decisionRange, channelId, outJepLut);
320 ATH_MSG_DEBUG(
"::simulateChannel: cpLut applyETRange " << outCpLut);
321 ATH_MSG_DEBUG(
"::simulateChannel: jepLut applyETRange " << outJepLut);
324 ATH_MSG_DEBUG(
"::simulateChannel: ==== Leaving Process ====" );
333 std::vector<int> peak;
334 peakBcid(ctx, filter, channelId, peak);
335 std::vector<int> sat;
336 satBcid(ctx, digits, channelId, sat);
339 output.reserve(sat.size());
341 std::vector<int>::iterator itpeak = peak.begin();
342 std::vector<int>::iterator itsat = sat.begin();
343 for ( ; itpeak!=peak.end() && itsat!=sat.end(); ++itpeak, ++itsat ) {
344 output.push_back( (*itpeak<<2) + (*itsat<<1) );
355 unsigned int strategy,
int satLow,
int satHigh,
int satLevel, std::vector<int> &output)
const
358 std::vector<int> peak;
360 std::vector<int> sat;
361 satBcid(digits, satLow, satHigh, satLevel, sat);
364 output.reserve(sat.size());
366 std::vector<int>::iterator itpeak = peak.begin();
367 std::vector<int>::iterator itsat = sat.begin();
368 for ( ; itpeak!=peak.end() && itsat!=sat.end(); ++itpeak, ++itsat ) {
369 output.push_back( (*itpeak<<2) + (*itsat<<1) );
378void L1TriggerTowerToolRun3::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,
379 unsigned int strategy,
int satLow,
int satHigh,
int satLevel, std::vector<int> &result, std::vector<int> &decision)
const
382 std::vector<int> peak;
384 std::vector<int> sat;
385 satBcid(digits, satLow, satHigh, satLevel, sat);
388 result.reserve(sat.size());
391 std::vector<int>::iterator itpeak = peak.begin();
392 std::vector<int>::iterator itsat = sat.begin();
393 for ( ; itpeak!=peak.end() && itsat!=sat.end(); ++itpeak, ++itsat ) {
394 result.push_back( (*itpeak<<2) + (*itsat<<1) );
402 std::vector<int> decisionRange;
403 if (!(decisionSource&0x1))
etRange(digits, energyLow, energyHigh, decisionRange);
404 else etRange(lutInput, energyLow, energyHigh, decisionRange);
405 bcidDecision(result, decisionRange, decisionConditions, decision);
413 auto settings = pprConditionsRun2->pprConditions(coolId);
414 if(!settings)
return nullptr;
415 return &(settings->firCoefficients());
428 std::vector<int> firCoeffs;
430 const std::vector<short int>* hwCoeffs;
431 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
436 firCoeffs.reserve(hwCoeffs->size());
437 for (
auto &i : std::views::reverse(*hwCoeffs)) {
438 firCoeffs.push_back(i);
446 fir(digits, firCoeffs, output);
456 output.reserve(digits.size());
461 for (
unsigned int i = 0; i < firCoeffs.size(); ++i) {
462 if (firstFIR < 0 && firCoeffs[i] != 0) firstFIR = i;
463 if (firCoeffs[i] != 0) lastFIR = i;
465 if (firstFIR < 0) firstFIR = lastFIR + 1;
467 for (
int i = 0; i < (int)digits.size(); i++) {
470 if (i >= 2-firstFIR && i < (
int)digits.size()+2-lastFIR) {
471 for (
int j = firstFIR; j <= lastFIR; ++j) {
472 sum += digits[i+j-2]*firCoeffs[j];
475 if (sum < 0) sum = 0;
476 output.push_back(sum);
486 return pprConditionsRun2->peakFinderCond();
493 unsigned int strategy = 0;
498 strategy = getStrategy<L1CaloPprConditionsContainerRun2>( pprConditionsRun2);
499 }
else ATH_MSG_WARNING(
"::peakBcid: No Conditions Container retrieved" );
501 ATH_MSG_DEBUG(
"::peakBcid: peak-finder strategy: " << strategy );
510 output.reserve(
fir.size());
512 for (
unsigned int i = 0; i <
fir.size(); i++) {
515 if (i > 0 && i <
fir.size()-1) {
518 if ( (
fir[i-1]<
fir[i]) && (
fir[i+1]<
fir[i]) ) result = 1;
520 if ( (
fir[i-1]<
fir[i]) && (
fir[i+1]<=
fir[i]) ) result = 1;
523 output.push_back(result);
534 auto settings = pprConditionsRun2->pprConditions(coolId);
535 if(!settings)
return std::make_tuple(
false, 0, 0, 0);
536 return std::make_tuple(
true, settings->satBcidLevel(), settings->satBcidThreshLow(),
537 settings->satBcidThreshHigh());
550 bool available =
false;
551 std::tie(available, satLevel, satLow, satHigh) = getSaturation<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
552 if(!available)
ATH_MSG_WARNING(
"::satBcid: No L1CaloPprConditions found" );
553 }
else ATH_MSG_WARNING(
"::satBcid: No Conditions Container retrieved" );
556 <<
" satLow: " << satLow
557 <<
" satHigh: " << satHigh );
559 satBcid(digits, satLow, satHigh, satLevel, output);
567 output.reserve(digits.size());
572 for (
unsigned int i = 0; i<digits.size(); i++) {
578 if (digits[i]>=satLevel) {
579 if (enabled && i>1) {
580 bool low = (digits[i-2]>satLow);
581 bool high = (digits[i-1]>satHigh);
599 output.push_back(flag[0]);
610 return pprConditionsRun2->decisionSource();
616 int decisionSource = 0;
620 decisionSource = getDecisionSource<L1CaloPprConditionsContainerRun2>(pprConditionsRun2);
622 }
else ATH_MSG_WARNING(
"::bcidDecisionRange: No Conditions Container retrieved" );
624 if (!(decisionSource&0x1))
etRange(ctx, digits, channelId, output);
625 else etRange(ctx, lutInput, channelId, output);
627 ATH_MSG_DEBUG(
"::bcidDecisionRange: decisionSource: " << decisionSource);
637 return std::make_tuple(pprConditionsRun2->bcidDecision1(), pprConditionsRun2->bcidDecision2(), pprConditionsRun2->bcidDecision3());
642 unsigned int decision1 = 0;
643 unsigned int decision2 = 0;
644 unsigned int decision3 = 0;
648 std::tie(decision1, decision2, decision3) = getBcidDecision<L1CaloPprConditionsContainerRun2>(pprConditionsRun2);
649 }
else ATH_MSG_WARNING(
"::bcidDecision: No Conditions Container retrieved" );
652 std::vector<unsigned int> mask = { decision3, decision2, decision1 };
655 << decision3 <<
" " << decision2 <<
" " << decision1 << MSG::dec );
665 output.reserve(bcidResults.size());
667 std::vector<int>::const_iterator itBcid = bcidResults.begin();
668 std::vector<int>::const_iterator itRange = range.begin();
669 int nRange = mask.size();
671 for ( ; itBcid != bcidResults.end() && itRange != range.end(); ++itBcid, ++itRange) {
672 if ((*itRange) < nRange && (mask[*itRange]&(0x1<<*itBcid))) output.push_back(1);
673 else output.push_back(0);
689 unsigned short scale_menu = 0;
692 const std::vector<short int>* hwCoeffs;
698 auto settings = pprConditionsRun2->pprConditions(channelId.id());
700 startBit = settings->firStartBit();
701 strategy = settings->lutCpStrategy();
702 slope = settings->lutCpSlope();
703 cut = settings->lutCpNoiseCut();
704 pedMean = settings->pedMean();
706 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
709 scale_menu = l1Menu->thrExtraInfo().EM().emScale();
711 for(
auto &coeffs : *hwCoeffs) {
712 hwCoeffSum += coeffs;
715 offset = this->
getLutOffset(pedMean, startBit, *hwCoeffs, slope, strategy);
718 }
else ATH_MSG_WARNING(
"::cpLut: No Conditions Container retrieved" );
720 ATH_MSG_DEBUG(
"::cpLut: strategy/scale/offset/slope/cut/pedMean/firCoeffSum/startBit: "
721 << strategy <<
"/" << scale_menu <<
"/" << offset <<
"/" << slope <<
"/" << cut <<
"/" << pedMean <<
"/" << hwCoeffSum <<
"/" << startBit );
723 unsigned int noiseCut = 0;
725 if (noiseCut > 0) cut = noiseCut;
728 lut(
fir, scale_menu*slope, scale_menu*offset, scale_menu*cut, 1, disabled, output);
729 }
else if(strategy == 1 || strategy == 0){
730 lut(
fir, slope, offset, cut, strategy, disabled, output);
731 }
else if (strategy == 4) {
734 lut(
fir, scale_menu*slope, scale_menu*offset, scale_menu*cut, 4, disabled, output);
751 unsigned short scale_db = 0;
752 unsigned short scale_menu = 0;
755 const std::vector<short int>* hwCoeffs;
770 const auto settings = pprConditionsRun2->pprConditions(channelId.id());
772 startBit = settings->firStartBit();
773 strategy = settings->lutJepStrategy();
774 slope = settings->lutJepSlope();
775 cut = settings->lutJepNoiseCut();
776 pedMean = settings->pedMean();
777 scale_db = settings->lutJepScale();
780 scale_menu = l1Menu->thrExtraInfo().JET().jetScale();
783 par1 = settings->lutJepPar1();
784 par2 = settings->lutJepPar2();
785 par3 = settings->lutJepPar3();
786 par4 = settings->lutJepPar4();
789 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
791 for(
auto &coeffs : *hwCoeffs) {
792 hwCoeffSum += coeffs;
795 offset = this->
getLutOffset(pedMean, startBit, *hwCoeffs, slope, strategy);
798 }
else ATH_MSG_WARNING(
"::jepLut: No Conditions Container retrieved" );
800 ATH_MSG_DEBUG(
"::jepLut: strategy/scale/offset/slope/cut/pedMean/firCoeffSum/startBit: "
801 << strategy <<
"/" << scale_menu <<
"/" << offset <<
"/" << slope <<
"/" << cut <<
"/" << pedMean <<
"/" << hwCoeffSum <<
"/" << startBit );
803 unsigned int noiseCut = 0;
805 if (noiseCut > 0) cut = noiseCut;
808 nonLinearLut(
fir, slope, offset, cut, scale_db, par1, par2, par3, par4, disabled, output);
810 else if(strategy == 2) {
812 lut(
fir, scale_menu*slope, scale_menu*offset, scale_menu*cut, 1, disabled, output);
814 }
else if(strategy == 1 || strategy == 0) {
815 lut(
fir, slope, offset, cut, strategy, disabled, output);
817 else if (strategy == 4) {
820 lut(
fir, scale_menu*slope, scale_menu*offset, scale_menu*cut, 4, disabled, output);
836 output.reserve(
fir.size());
838 const int reScale = 2;
839 for(
auto it :
fir) {
842 if (strategy == 0 && it >= offset+cut) {
843 out = ((it-offset)*slope + 2048)>>12;
845 else if (strategy == 1 && it*slope >= offset+cut) {
846 out = (it*slope - offset + 2048)>>12;
849 else if (strategy == 4 && it*slope >= offset+ cut/reScale) {
850 out = (it*slope*reScale - offset*reScale + 2048)>>12;
852 if (out < 0) out = 0;
855 output.push_back(out);
862void L1TriggerTowerToolRun3::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)
const
865 output.reserve(
fir.size());
868 for(
auto it :
fir) {
872 double nll_slope = 0.001 * scale;
873 double nll_offset = 0.001 * par1;
874 double nll_ampl = 0.001 * par2;
875 double nll_expo = 0.;
877 nll_expo = -1. / (4096 * 0.001*par3);
881 double nll_noise = 0.001 * par4;
884 if (it * slope < offset + nll_noise * cut) {
889 out = int((((
int)(2048 + nll_slope * (it * slope - offset)))>>12) + nll_offset + nll_ampl * std::exp(nll_expo * (it * slope - offset)));
894 output.push_back(out);
905 std::vector<int>::const_iterator itlut =
lut.begin();
906 std::vector<int>::const_iterator itrange = range.begin();
907 while ( itlut !=
lut.end() && itrange != range.end() ) {
909 else output.push_back(*itlut);
922 auto settings = pprConditionsRun2->pprConditions(coolId);
923 if(!settings)
return std::make_tuple(
false, 0, 0);
924 return std::make_tuple(
true, settings->bcidEnergyRangeLow(), settings->bcidEnergyRangeHigh());
937 bool available =
false;
938 std::tie(available, energyLow, energyHigh) = getBcidEnergyRange<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
939 if(!available)
ATH_MSG_WARNING(
"::etRange: No L1CaloPprConditions found");
940 }
else ATH_MSG_WARNING(
"::etRange: No Conditions Container retrieved");
943 <<
" energyHigh: " << energyHigh);
945 etRange(
et, energyLow, energyHigh, output);
953 output.reserve(
et.size());
955 if (it <= energyLow) output.push_back(0);
956 else if (it <= energyHigh) output.push_back(1);
957 else output.push_back(2);
969 auto settings = pprConditionsRun2->pprConditions(coolId);
970 if(!settings)
return std::make_tuple(
false, 0);
971 return std::make_tuple(
true, settings->firStartBit());
977 unsigned int start = 0;
981 bool available =
false;
982 std::tie(available, start) = getFirStartBit<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
983 if(!available)
ATH_MSG_WARNING(
"::dropBits: No L1CaloPprConditions found" );
984 }
else ATH_MSG_WARNING(
"::dropBits: No Conditions Container retrieved" );
996 output.reserve(
fir.size());
999 unsigned int mask = (0x3ff<<start);
1002 int max = 1<<(10+start);
1004 for(
auto it :
fir) {
1005 if (it>=
max) output.push_back(0x3ff);
1006 else output.push_back((it&mask)>>start);
1019 const std::vector<short int>* hwCoeffs =
nullptr;
1020 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2 );
1026 firCoeffs.reserve(hwCoeffs->size());
1027 for (
int i = hwCoeffs->size()-1; i >= 0; --i) firCoeffs.push_back((*hwCoeffs)[i]);
1029 }
else ATH_MSG_WARNING(
"::firParams: No L1CaloPprConditions found" );
1030 }
else ATH_MSG_WARNING(
"::firParams: No Conditions Container retrieved" );
1039 unsigned int &peakFinderStrategy,
int &satLow,
int &satHigh,
int &satLevel)
const
1044 decisionConditions.clear();
1045 peakFinderStrategy = 0;
1054 std::tuple<unsigned int, unsigned int, unsigned int>
bcidDecision;
1055 std::tuple<bool, int, int> bcidEnergyRange;
1056 std::tuple<bool, int, int, int> saturation;
1059 bcidDecision = getBcidDecision<Cont>(pprConditionsRun2);
1060 peakFinderStrategy = getStrategy<Cont>(pprConditionsRun2);
1061 decisionSource = getDecisionSource<Cont>(pprConditionsRun2);
1062 bcidEnergyRange = getBcidEnergyRange<Cont>(channelId.id(), pprConditionsRun2);
1063 saturation = getSaturation<Cont>(channelId.id(), pprConditionsRun2);
1069 if(
get<0>(bcidEnergyRange)) {
1070 std::tie(std::ignore, energyLow, energyHigh) = bcidEnergyRange;
1074 std::tie(std::ignore, satLevel, satLow, satHigh) = saturation;
1076 }
else ATH_MSG_WARNING(
"::bcid:Params No Conditions Container retrieved" );
1079 <<
" satLow: " << satLow <<
" satHigh: " << satHigh <<
endmsg
1080 <<
" energyLow: " << energyLow <<
" energyHigh: " << energyHigh <<
endmsg
1081 <<
" decisionSource: " << decisionSource <<
" peakFinderStrategy: "
1082 << peakFinderStrategy );
1097 const std::vector<short int>* hwCoeffs;
1108 const auto settings = pprConditionsRun2->pprConditions(channelId.id());
1110 startBit = settings->firStartBit();
1111 strategy = settings->lutCpStrategy();
1112 slope = settings->lutCpSlope();
1113 cut = settings->lutCpNoiseCut();
1114 pedValue = settings->pedValue();
1115 pedMean = settings->pedMean();
1117 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
1119 for(
auto &coeffs : *hwCoeffs) {
1120 hwCoeffSum += coeffs;
1123 offset = this->
getLutOffset(pedMean, startBit, *hwCoeffs, slope, strategy);
1125 ATH_MSG_VERBOSE(
"::jepLutParams: Offset: offset/strategy/pedMean/firCoeffSum/startBit/slope: "
1126 << offset <<
" " << strategy <<
" " <<
" " << pedMean <<
" " << hwCoeffSum <<
" " << startBit <<
" " << slope );
1128 }
else ATH_MSG_WARNING(
"::cpLutParams: No L1CaloPprConditions found" );
1129 }
else ATH_MSG_WARNING(
"::cpLutParams: No Conditions Container retrieved" );
1131 ATH_MSG_VERBOSE(
"::cpLutParams: LUT startBit/strategy/offset/slope/cut/pedValue/pedMean: "
1132 << startBit <<
" " << strategy <<
" " << offset <<
" " << slope <<
" " << cut <<
" " << pedValue <<
" " << pedMean );
1133 unsigned int noiseCut = 0;
1135 if (noiseCut > 0) cut = noiseCut;
1149 const std::vector<short int>* hwCoeffs;
1158 const auto settings = pprConditionsRun2->pprConditions(channelId.id());
1160 startBit = settings->firStartBit();
1161 strategy = settings->lutJepStrategy();
1162 slope = settings->lutJepSlope();
1163 cut = settings->lutJepNoiseCut();
1164 pedValue = settings->pedValue();
1165 pedMean = settings->pedMean();
1167 hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(),pprConditionsRun2);
1169 for(
auto &coeffs : *hwCoeffs) {
1170 hwCoeffSum += coeffs;
1173 offset = this->
getLutOffset(pedMean, startBit, *hwCoeffs, slope, strategy);
1175 ATH_MSG_VERBOSE(
"::jepLutParams: Offset: offset/strategy/pedMean/firCoeffSum/startBit/slope: "
1176 << offset <<
" " << strategy <<
" " <<
" " << pedMean <<
" " << hwCoeffSum <<
" " << startBit <<
" " << slope );
1178 }
else ATH_MSG_WARNING(
"::jepLutParams: No L1CaloPprConditions found" );
1179 }
else ATH_MSG_WARNING(
"::jepLutParams: No Conditions Container retrieved" );
1181 ATH_MSG_VERBOSE(
"::jepLutParams: LUT startBit/strategy/offset/slope/cut/pedValue/pedMean: "
1182 << startBit <<
" " << strategy <<
" " << offset <<
" " << slope <<
" " << cut <<
" " << pedValue <<
" " << pedMean );
1183 unsigned int noiseCut = 0;
1185 if (noiseCut > 0) cut = noiseCut;
1199 id =
m_lvl1Helper->tower_id(pos_neg_z, layer, region, ieta, iphi);
1210 try { hwId =
m_ttSvc->createTTChannelID(
id,
false); }
1229 const double absEta = std::abs(
eta);
1232 const int etaBin = 10.*absEta;
1233 const int phiBin =
phi*(32/
M_PI);
1234 index = (etaBin<<6) + phiBin;
1235 }
else if (absEta < 3.2) {
1236 const int etaBin = 5.*(absEta - 2.5);
1237 const int phiBin =
phi*(16./
M_PI);
1238 index = 1600 + (etaBin<<5) + phiBin;
1240 const int etaBin = (absEta - 3.2)*(1./0.425);
1241 const int phiBin =
phi*(8./
M_PI);
1242 index = 1728 + (etaBin<<4) + phiBin;
1245 if (layer > 0)
index += 3584;
1267 coolId =
m_ttSvc->createL1CoolChannelId(hwId);
1278 return std::make_tuple(pprConditionsRun2->satOverride1(), pprConditionsRun2->satOverride2(), pprConditionsRun2->satOverride3());
1287 bool override =
false;
1290 satOverride = getSatOverride<L1CaloPprConditionsContainerRun2>(pprConditionsRun2);
1292 if (range == 0)
override = std::get<2>(
satOverride);
1293 else if (range == 1)
override = std::get<1>(
satOverride);
1294 else if (range == 2)
override = std::get<0>(
satOverride);
1295 }
else ATH_MSG_WARNING(
"::satOverride: No Conditions Container retrieved" );
1298 <<
" has saturation override flag " <<
override );
1307 unsigned int noiseCut = 0;
1316 bool isDisabled =
false;
1320 const auto disabledChan = pprDisabledChannel->pprDisabledChannel(channelId.id());
1323 if (!disabledChan->disabledBits()) {
1327 if (deadError.
chanValid()) noiseCut = disabledChan->noiseCut();
1330 }
else isDisabled =
true;
1333 <<
"::disabledChannel: calibErrorCode: " << (disabledChan->calibErrorCode()).errorCode()
1334 <<
" deadErrorCode: " << (disabledChan->deadErrorCode()).errorCode()
1335 <<
" noiseCut: " << disabledChan->noiseCut()
1336 <<
" disabledBits: " << disabledChan->disabledBits()
1340 ATH_MSG_DEBUG(
"::disabledChannel: No L1CaloPprDisabledChannel found" );
1343 ATH_MSG_WARNING(
"::disabledChannel: No DisabledChannel Container retrieved" );
1345 if (isDisabled)
ATH_MSG_DEBUG(
"::disabledChannel: Channel is disabled" );
1356 double eta = nominalEta;
1357 float abseta = std::abs(
eta);
1358 if (abseta<3.2)
return eta;
1360 int sign = ((
eta > 0) ? 1 : -1);
1361 if (abseta < 3.6)
eta = 3.15 *
sign;
1362 else if (abseta < 4.0)
eta = 3.33 *
sign;
1363 else if (abseta < 4.5)
eta = 3.72 *
sign;
1367 if (abseta < 3.6)
eta = 3.36;
1368 else if (abseta < 4.0)
eta = 3.45;
1369 else if (abseta < 4.5)
eta = 4.17;
1373 if (abseta < 3.6)
eta = -3.45;
1374 else if (abseta < 4.0)
eta = -3.36;
1375 else if (abseta < 4.5)
eta = -4.19;
1388 throw GaudiException(
"No mapping tool configured",
1389 "L1TriggerTowerToolRun3::FCalTTeta", StatusCode::FAILURE);
1393 unsigned int crate = channelId.crate();
1394 unsigned int module = channelId.module();
1395 unsigned int mcm = channelId.subModule();
1396 unsigned int pin = channelId.channel();
1397 int channel = pin*16 + mcm;
1404 ATH_MSG_WARNING(
"::FCalTTeta: could not map 0x" << std::hex << channelId.id() << std::dec);
1431 <<
"::refValues: errorCode: " << (ftref->
errorCode()).errorCode()
1432 << MSG::dec <<
" reference: " << ftref->
refValue() <<
" calib: " << ftref->
calibValue() );
1441 return std::make_pair(
reference, calib);
1445 unsigned nFIR = firInOut.size();
1446 correctionOut.assign(nFIR, 0u);
1451 for(
unsigned i = 0; i != nFIR; ++i) {
1453 firInOut[i] -= correctionOut[i];
1455 if(firInOut[i] < 0) firInOut[i] = 0;
1458 ATH_MSG_DEBUG(
"::pedestalCorrection(BCID=" <<
bcid <<
", mu = " << mu <<
"): " << correctionOut);
1464 if (ctx.eventID().run_number() >= 253377)
return true;
1471unsigned int L1TriggerTowerToolRun3::getLutOffset(
const double &pedMean,
const unsigned int &firStartBit,
const std::vector<short int> &firCoeff,
const unsigned int &lutSlope,
const unsigned int &lutStrategy)
const
1473 unsigned int lutOffset = 0;
1475 long long int lutOffsetLong = 0;
1476 long long int lutSlopeLong = lutSlope;
1477 long long int firStartBitLong = firStartBit;
1478 long long int pedMeanLong = std::lround(pedMean * 10000.);
1479 long long int firCoeffSum = 0;
1481 for (
unsigned int i=0; i<firCoeff.size(); i++) {
1482 firCoeffSum += firCoeff.at(i);
1485 if ( lutStrategy == 0 ) {
1486 lutOffsetLong = ((pedMeanLong*firCoeffSum) >> firStartBitLong);
1489 lutOffsetLong = ((pedMeanLong*firCoeffSum*lutSlopeLong) >> firStartBitLong) - ((lutSlopeLong * 10000) >> 1);
1492 lutOffsetLong = (lutOffsetLong + (10000-1))/10000;
1493 lutOffset =
static_cast<unsigned int>( lutOffsetLong < 0 ? 0 : lutOffsetLong );
1501 if (
sc.isFailure()) {
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)
Handle class for reading from StoreGate.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() 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...
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
@ 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?)
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
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.