ATLAS Offline Software
L1TriggerTowerToolRun3.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
5 // L1TriggerTowerToolRun3.cxx
8 #include "GaudiKernel/Incident.h"
9 #include "GaudiKernel/IIncidentSvc.h"
10 #include "GaudiKernel/GaudiException.h"
11 
15 
21 
22 #include "StoreGate/ReadHandle.h"
23 #include "GaudiKernel/ThreadLocalContext.h"
24 
25 #include <cstdint>
26 #include <tuple>
27 #include <boost/range/adaptor/reversed.hpp>
28 using namespace boost::adaptors;
29 
30 namespace LVL1
31 {
32 
33 //================ Static Constants ============================================
34 
35 const int L1TriggerTowerToolRun3::s_saturationValue;
36 const int L1TriggerTowerToolRun3::s_maxTowers;
37 
38 //================ Constructor =================================================
39 
40 L1TriggerTowerToolRun3::L1TriggerTowerToolRun3(const std::string& t,
41  const std::string& n,
42  const IInterface* p )
43  :
44  AthAlgTool(t,n,p),
45  m_caloMgr(0),
46  m_lvl1Helper(0),
47  m_l1CaloTTIdTools("LVL1::L1CaloTTIdTools/L1CaloTTIdTools", this),
48  m_ttSvc("CaloTriggerTowerService/CaloTriggerTowerService", this),
49  m_mappingTool("", this),
50  m_correctFir(false),
51  m_dynamicPedestalProvider("", this)
52 {
53  declareInterface<IL1TriggerTowerToolRun3>(this);
54 
55  declareProperty( "BaselineCorrection", m_correctFir );
56  declareProperty( "L1DynamicPedestalProvider", m_dynamicPedestalProvider );
57 }
58 
59 //================ Destructor =================================================
60 
62 
63 //================ Initialisation =================================================
64 
66 {
67 
68  // Reading the Condition Containers Run 3 style
73 
74  ATH_CHECK(m_l1CaloTTIdTools.retrieve());
75 
76  if(!m_ttSvc.retrieve().isSuccess()) {
77  ATH_MSG_WARNING( "Could not retrieve CaloTriggerTowerService Tool" );
78  } else {
79  ATH_MSG_INFO("Retrieved Tool " << m_ttSvc);
80  }
81 
82  StatusCode scID = detStore()->retrieve(m_caloMgr);
83  if (scID.isFailure()) {
84  ATH_MSG_WARNING( "Cannot retrieve m_caloMgr" );
85  } else {
87  }
88 
89  if (!m_mappingTool.empty()) {
90  ATH_CHECK( m_mappingTool.retrieve() );
91  }
92 
93  // Incident Service:
94  IIncidentSvc* incSvc = 0;
95  if (service("IncidentSvc", incSvc).isFailure()) {
96  ATH_MSG_WARNING( "Unable to retrieve pointer to IncidentSvc " );
97  }
98  else {
99  incSvc->addListener(this, "BeginRun");
100  }
101 
102  // Pedestal Correction
103  if (m_correctFir) {
105  ATH_MSG_INFO( "Retrieved L1DynamicPedestalProvider: " << m_dynamicPedestalProvider );
106  }
107 
109 
111 
112 
113 
114 
115  ATH_MSG_INFO( "Initialization completed" );
116 
117  return StatusCode::SUCCESS;
118 }
119 
120 //================ Finalisation =================================================
121 
123 {
124  return StatusCode::SUCCESS;
125 }
126 
127 //================ Reset mapping table at start of run ============================
128 
129 void L1TriggerTowerToolRun3::handle(const Incident& inc)
130 {
131  if (inc.type()=="BeginRun") {
132  ATH_MSG_DEBUG( "Resetting mapping table at start of run" );
133 
134  m_idTable.clear();
135  }
136 }
137 
138 
139 
142 void L1TriggerTowerToolRun3::process(const std::vector<int> &digits, double eta, double phi, int layer,
143  std::vector<int> &et, std::vector<int> &bcidResults,
144  std::vector<int> &bcidDecisions, bool useJepLut /* = true */)
145 {
148 
150  process(digits, id, et, bcidResults, bcidDecisions, useJepLut);
151 }
152 
153 
156 void L1TriggerTowerToolRun3::process(const std::vector<int> &digits, const L1CaloCoolChannelId& channelId,
157  std::vector<int> &et, std::vector<int> &bcidResults,
158  std::vector<int> &bcidDecisions, bool useJepLut /* = true */)
159 {
160 
161  ATH_MSG_DEBUG( "::process: ==== Entered Process ====" );
162  ATH_MSG_DEBUG( "::process: digits: " << digits);
163  ATH_MSG_DEBUG( " channelID: " << MSG::hex << channelId.id() << MSG::dec );
164 
165 
167  et.clear();
168  bcidResults.clear();
169  bcidDecisions.clear();
170 
171  ATH_MSG_DEBUG( "::process: ---- FIR filter ----" );
172 
174  std::vector<int> filter;
175  fir(digits, channelId, filter);
176  std::vector<int> lutInput;
177  dropBits(filter, channelId, lutInput);
178 
179  ATH_MSG_DEBUG( "::process: ---- BCID algorithms ----" );
180 
182  bcid(filter, digits, channelId, bcidResults);
183 
184  ATH_MSG_DEBUG( "::process: ---- BCID decisions ----" );
185 
187  std::vector<int> decisionRange;
188  bcidDecisionRange(lutInput, digits, channelId, decisionRange);
189  bcidDecision(bcidResults, decisionRange, bcidDecisions);
190 
191  ATH_MSG_DEBUG( "::process: ---- LUT ET calculation ----" );
192 
194  std::vector<int> lutOutput;
195  if(useJepLut) jepLut(lutInput, channelId, lutOutput);
196  else cpLut(lutInput, channelId, lutOutput);
197 
198 
199  ATH_MSG_DEBUG( "::process: ---- use ET range ----" );
200 
203  applyEtRange(lutOutput, decisionRange, channelId, et);
204 
205  ATH_MSG_DEBUG( "::process: ==== Leaving Process ====" );
206 }
207 
208 namespace {
209 // helper function to convert vectors of different type
210 template <typename DST, typename SRC>
211 std::vector<DST> convertVectorType(const std::vector<SRC>& s) {
212  std::vector<DST> d(s.size());
214  [](SRC v){return static_cast<DST>(v);});
215  return d;
216 }
217 }
218 
220 void L1TriggerTowerToolRun3::simulateChannel(const xAOD::TriggerTower& tt, std::vector<int>& outCpLut, std::vector<int>& outJepLut, std::vector<int>& bcidResults, std::vector<int>& bcidDecisions) const {
221 
222  //If we have 80 MHz readout, we need to extract the 40 MHz samples. The central 80 MHz sample is always a 40 MHz sample. We use the cool database (runParameters folder) to understand if we are in 80MHz readout
223 
224 
226  unsigned int readoutConfigID = runParameters->runParameters(1)->readoutConfigID();
227  ATH_MSG_DEBUG("RunParameters:: readoutConfigID " << readoutConfigID);
228 
229  std::vector<uint16_t> digits40;
230 
231  if(readoutConfigID == 5 or readoutConfigID == 6){
232 
233 
234  ATH_MSG_DEBUG("80 MHz readout detected, emulating 40 MHz samples");
235 
236  int nSlices = tt.adc().size();
237 
238  if((nSlices%4)==3){
239  for (int i=0 ; i < (nSlices-1)/2 ; i++ ){
240  digits40.push_back(tt.adc().at(2*i+1));
241  }
242  }
243  else if((nSlices%4)==1){
244  for (int i=0 ; i <= (nSlices-1)/2 ; i++){
245  digits40.push_back(tt.adc().at(2*i));
246  }
247  }
248 
249 
250  }else{
251  ATH_MSG_DEBUG("40 MHz readout detected");
252  digits40 = tt.adc();
253  }
254 
255  const auto& digits = convertVectorType<int>(digits40);
256 
257  L1CaloCoolChannelId channelId {tt.coolId()};
258 
259  ATH_MSG_DEBUG( "::simulateChannel: ==== Entered Process ====" );
260  ATH_MSG_DEBUG( "::simulateChannel: digits: " << digits );
261  ATH_MSG_DEBUG( "::simulateChannel: channelID: " << MSG::hex << channelId.id() << MSG::dec );
262 
263 
265  outCpLut.clear();
266  outJepLut.clear();
267  bcidResults.clear();
268  bcidDecisions.clear();
269 
271  ATH_MSG_DEBUG( "::simulateChannel: ---- FIR filter ----" );
272  std::vector<int> filter;
273  fir(digits, channelId, filter);
274 
275 
277  ATH_MSG_DEBUG( "::simulateChannel: ---- pedestalCorrection ----" );
278  // the correction is only available for each LUT slice in the read-out (not ADC/Filter slice)
279  // therefore we can only apply it to the #LUT central filter slices
280  const std::size_t nCorr = tt.correctionEnabled().size();
281  const std::size_t filterOffset = filter.size()/2 - nCorr/2;
282  for(std::size_t iCorr = 0; iCorr < nCorr; ++iCorr) {
283  filter[filterOffset + iCorr] -= tt.correction()[iCorr] * tt.correctionEnabled()[iCorr];
284  }
285 
286  ATH_MSG_DEBUG("::simulateChannel: filter: " << filter);
287 
288 
289  std::vector<int> lutInput;
290  dropBits(filter, channelId, lutInput);
291 
292  ATH_MSG_DEBUG( "::simulateChannel: ---- BCID algorithms ---- ");
293 
295  bcid(filter, digits, channelId, bcidResults);
296 
297 
299  std::vector<int> decisionRange;
300  bcidDecisionRange(lutInput, digits, channelId, decisionRange);
301  bcidDecision(bcidResults, decisionRange, bcidDecisions);
302 
303  ATH_MSG_DEBUG( "::simulateChannel: bcidDecisionRange " << decisionRange);
304  ATH_MSG_DEBUG( "::simulateChannel: bcidDecisions " << bcidDecisions);
305 
306 
307 
308  ATH_MSG_DEBUG( "::simulateChannel: ---- LUT ET calculation ----" );
309 
311  std::vector<int> cpLutOutput, jepLutOutput;
312  cpLut(lutInput, channelId, cpLutOutput);
313  jepLut(lutInput, channelId, jepLutOutput);
314 
315  ATH_MSG_DEBUG( "::simulateChannel: cpLut " << cpLutOutput);
316  ATH_MSG_DEBUG( "::simulateChannel: jepLut " << jepLutOutput);
317 
318  ATH_MSG_DEBUG( "::simulateChannel: ---- use ET range ----" );
319 
322  applyEtRange(cpLutOutput, decisionRange, channelId, outCpLut);
323  applyEtRange(jepLutOutput, decisionRange, channelId, outJepLut);
324 
325  ATH_MSG_DEBUG( "::simulateChannel: cpLut applyETRange " << outCpLut);
326  ATH_MSG_DEBUG( "::simulateChannel: jepLut applyETRange " << outJepLut);
327 
328 
329  ATH_MSG_DEBUG( "::simulateChannel: ==== Leaving Process ====" );
330 }
331 
335 void L1TriggerTowerToolRun3::bcid(const std::vector<int> &filter, const std::vector<int> &digits, const L1CaloCoolChannelId& channelId, std::vector<int> &output) const
336 {
337  // Get decision flags for the 2 BCID algorithms
338  std::vector<int> peak;
339  peakBcid(filter, channelId, peak);
340  std::vector<int> sat;
341  satBcid(digits, channelId, sat);
342 
343  output.clear();
344  output.reserve(sat.size()); // avoid frequent reallocations
345 
346  std::vector<int>::iterator itpeak = peak.begin();
347  std::vector<int>::iterator itsat = sat.begin();
348  for ( ; itpeak!=peak.end() && itsat!=sat.end(); ++itpeak, ++itsat ) {
349  output.push_back( (*itpeak<<2) + (*itsat<<1) );
350  }
351 
352  ATH_MSG_DEBUG( "::bcid: bcidResults: " << output);
353 
354 }
355 
359 void L1TriggerTowerToolRun3::bcid(const std::vector<int> &filter, const std::vector<int> &digits,
360  unsigned int strategy, int satLow, int satHigh, int satLevel, std::vector<int> &output) const
361 {
362  // Get decision flags for the 2 BCID algorithms
363  std::vector<int> peak;
364  peakBcid(filter, strategy, peak);
365  std::vector<int> sat;
366  satBcid(digits, satLow, satHigh, satLevel, sat);
367 
368  output.clear();
369  output.reserve(sat.size()); // avoid frequent reallocations
370 
371  std::vector<int>::iterator itpeak = peak.begin();
372  std::vector<int>::iterator itsat = sat.begin();
373  for ( ; itpeak!=peak.end() && itsat!=sat.end(); ++itpeak, ++itsat ) {
374  output.push_back( (*itpeak<<2) + (*itsat<<1) );
375  }
376 
377  ATH_MSG_DEBUG( "::bcid: bcidResults: " << output);
378 }
379 
383 void 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,
384  unsigned int strategy, int satLow, int satHigh, int satLevel, std::vector<int> &result, std::vector<int> &decision) const
385 {
386  // Get decision flags for the 2 BCID algorithms
387  std::vector<int> peak;
388  peakBcid(filter, strategy, peak);
389  std::vector<int> sat;
390  satBcid(digits, satLow, satHigh, satLevel, sat);
391 
392  result.clear();
393  result.reserve(sat.size()); // avoid frequent reallocations
394  decision.clear();
395 
396  std::vector<int>::iterator itpeak = peak.begin();
397  std::vector<int>::iterator itsat = sat.begin();
398  for ( ; itpeak!=peak.end() && itsat!=sat.end(); ++itpeak, ++itsat ) {
399  result.push_back( (*itpeak<<2) + (*itsat<<1) );
400  }
401 
402  ATH_MSG_DEBUG( "::bcid: bcidResults: " << result);
403 
404 
405 
407  std::vector<int> decisionRange;
408  if (!(decisionSource&0x1)) etRange(digits, energyLow, energyHigh, decisionRange);
409  else etRange(lutInput, energyLow, energyHigh, decisionRange);
410  bcidDecision(result, decisionRange, decisionConditions, decision);
411  ATH_MSG_DEBUG( "::bcid: bcidDecisions: " << decision);
412 
413 }
414 
415 namespace { // helper function
416  template<class T>
417  const std::vector<short int>* getFirCoefficients(unsigned int coolId, SG::ReadCondHandle<L1CaloPprConditionsContainerRun2> pprConditionsRun2) {
418  auto settings = pprConditionsRun2->pprConditions(coolId);
419  if(!settings) return nullptr;
420  return &(settings->firCoefficients());
421  }
422 } // anonymous namespace
423 
427 void L1TriggerTowerToolRun3::fir(const std::vector<int> &digits, const L1CaloCoolChannelId& channelId, std::vector<int> &output) const
428 {
429 
431 
433  std::vector<int> firCoeffs;
435  const std::vector<short int>* hwCoeffs;
436  hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
437  if(hwCoeffs) {
441  firCoeffs.reserve(hwCoeffs->size()); // avoid frequent reallocations
442  for (auto &i : reverse(*hwCoeffs)) {
443  firCoeffs.push_back(i);
444  }
445  } else ATH_MSG_WARNING( "::fir: No L1CaloPprConditions found" );
446  } else ATH_MSG_WARNING( "::fir: No Conditions Container retrieved" );
447 
448  ATH_MSG_DEBUG( "::fir: FIR coefficients: " << firCoeffs);
449 
450 
451  fir(digits, firCoeffs, output);
452 }
453 
458 void L1TriggerTowerToolRun3::fir(const std::vector<int> &digits, const std::vector<int> &firCoeffs, std::vector<int> &output) const
459 {
460  output.clear();
461  output.reserve(digits.size()); // avoid frequent reallocations
464  int firstFIR = -1;
465  int lastFIR = 0;
466  for (unsigned int i = 0; i < firCoeffs.size(); ++i) {
467  if (firstFIR < 0 && firCoeffs[i] != 0) firstFIR = i;
468  if (firCoeffs[i] != 0) lastFIR = i;
469  }
470  if (firstFIR < 0) firstFIR = lastFIR + 1;
471 
472  for (int i = 0; i < (int)digits.size(); i++) {
473  int sum = 0;
475  if (i >= 2-firstFIR && i < (int)digits.size()+2-lastFIR) {
476  for (int j = firstFIR; j <= lastFIR; ++j) {
477  sum += digits[i+j-2]*firCoeffs[j];
478  }
479  }
480  if (sum < 0) sum = 0;
481  output.push_back(sum);
482  }
483 
484  ATH_MSG_DEBUG( "::fir: output: " << output);
485 
486 }
487 
488 namespace {
489  template<typename T>
490  unsigned int getStrategy( SG::ReadCondHandle<L1CaloPprConditionsContainerRun2> pprConditionsRun2) {
491  return pprConditionsRun2->peakFinderCond();
492  }
493 }
494 
496 void L1TriggerTowerToolRun3::peakBcid(const std::vector<int> &fir, const L1CaloCoolChannelId& /*channelId*/, std::vector<int> &output) const
497 {
498  unsigned int strategy = 0;
500 
501 
503  strategy = getStrategy<L1CaloPprConditionsContainerRun2>( pprConditionsRun2);
504  } else ATH_MSG_WARNING( "::peakBcid: No Conditions Container retrieved" );
505 
506  ATH_MSG_DEBUG( "::peakBcid: peak-finder strategy: " << strategy );
507 
509 }
510 
512 void L1TriggerTowerToolRun3::peakBcid(const std::vector<int> &fir, unsigned int strategy, std::vector<int> &output) const
513 {
514  output.clear();
515  output.reserve(fir.size()); // avoid frequent reallocations
516 
517  for (unsigned int i = 0; i < fir.size(); i++) {
518  int result = 0;
520  if (i > 0 && i < fir.size()-1) {
522  if (strategy&0x1) {
523  if ( (fir[i-1]<fir[i]) && (fir[i+1]<fir[i]) ) result = 1;
524  } else {
525  if ( (fir[i-1]<fir[i]) && (fir[i+1]<=fir[i]) ) result = 1;
526  }
527  }
528  output.push_back(result);
529  }
530 
531  ATH_MSG_DEBUG( "::peakBcid: output: " << output);
532 
533 
534 }
535 
536 namespace { // helper function
537  template<class T>
538  std::tuple<bool, int, int, int> getSaturation(unsigned int coolId, SG::ReadCondHandle<L1CaloPprConditionsContainerRun2> pprConditionsRun2) {
539  auto settings = pprConditionsRun2->pprConditions(coolId);
540  if(!settings) return std::make_tuple(false, 0, 0, 0);
541  return std::make_tuple(true, settings->satBcidLevel(), settings->satBcidThreshLow(),
542  settings->satBcidThreshHigh());
543  }
544 } // anonymous namespace
545 
547 void L1TriggerTowerToolRun3::satBcid(const std::vector<int> &digits, const L1CaloCoolChannelId& channelId, std::vector<int> &output) const
548 {
549  int satLevel = 0;
550  int satLow = 0;
551  int satHigh = 0;
553 
555  bool available = false;
556  std::tie(available, satLevel, satLow, satHigh) = getSaturation<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
557  if(!available) ATH_MSG_WARNING( "::satBcid: No L1CaloPprConditions found" );
558  } else ATH_MSG_WARNING( "::satBcid: No Conditions Container retrieved" );
559 
560  ATH_MSG_DEBUG( "::satBcid: satLevel: " << satLevel
561  << " satLow: " << satLow
562  << " satHigh: " << satHigh );
563 
564  satBcid(digits, satLow, satHigh, satLevel, output);
565 }
566 
569 void L1TriggerTowerToolRun3::satBcid(const std::vector<int> &digits, int satLow, int satHigh, int satLevel, std::vector<int> &output) const
570 {
571  output.clear();
572  output.reserve(digits.size()); // avoid frequent reallocations
573 
574  bool enabled = true;
575  int flag[2] = {0,0};
576 
577  for (unsigned int i = 0; i<digits.size(); i++) {
578  // Algorithm can set flag for following sample. So here we
579  // propagate such flags into the current sample.
580  flag[0] = flag[1];
581  flag[1] = 0;
582 
583  if (digits[i]>=satLevel) { // do we have saturation?
584  if (enabled && i>1) { // is algorithm active?
585  bool low = (digits[i-2]>satLow);
586  bool high = (digits[i-1]>satHigh);
587  if (high) { // flag current or next sample?
588  if (low) {
589  flag[0] = 1;
590  }
591  else {
592  flag[1] = 1;
593  }
594  }
595  else {
596  flag[1] = 1;
597  }
598  }
599  enabled = false; // after first saturation, disable algorithm
600  }
601  else {
602  enabled = true; // unsaturated sample reenables algorithm
603  }
604  output.push_back(flag[0]);
605  }
606 
607  ATH_MSG_DEBUG( "::satBcid: output: " << output);
608 
609 }
610 
612 namespace {
613  template<typename T>
614  unsigned int getDecisionSource( SG::ReadCondHandle<L1CaloPprConditionsContainerRun2> pprConditionsRun2) {
615  return pprConditionsRun2->decisionSource();
616  }
617 }
618 
619 void L1TriggerTowerToolRun3::bcidDecisionRange(const std::vector<int>& lutInput, const std::vector<int>& digits, const L1CaloCoolChannelId& channelId, std::vector<int> &output) const
620 {
621  int decisionSource = 0;
623 
625  decisionSource = getDecisionSource<L1CaloPprConditionsContainerRun2>(pprConditionsRun2);
626 
627  } else ATH_MSG_WARNING( "::bcidDecisionRange: No Conditions Container retrieved" );
628 
629  if (!(decisionSource&0x1)) etRange(digits, channelId, output);
630  else etRange(lutInput, channelId, output);
631 
632  ATH_MSG_DEBUG( "::bcidDecisionRange: decisionSource: " << decisionSource);
633  ATH_MSG_DEBUG( " output: " << output);
634 
635 
636 }
637 
639 namespace { // helper function
640  template<class T>
641  std::tuple<unsigned int, unsigned int, unsigned int> getBcidDecision( SG::ReadCondHandle<L1CaloPprConditionsContainerRun2> pprConditionsRun2) {
642  return std::make_tuple(pprConditionsRun2->bcidDecision1(), pprConditionsRun2->bcidDecision2(), pprConditionsRun2->bcidDecision3());
643  }
644 } // anonymous namespace
645 void L1TriggerTowerToolRun3::bcidDecision(const std::vector<int> &bcidResults, const std::vector<int> &range , std::vector<int> &output) const
646 {
647  unsigned int decision1 = 0;
648  unsigned int decision2 = 0;
649  unsigned int decision3 = 0;
651 
653  std::tie(decision1, decision2, decision3) = getBcidDecision<L1CaloPprConditionsContainerRun2>(pprConditionsRun2);
654  } else ATH_MSG_WARNING( "::bcidDecision: No Conditions Container retrieved" );
655 
656  // Reverse the order! (see elog 97082 9/06/10)
657  std::vector<unsigned int> mask = { decision3, decision2, decision1 };
658 
659  ATH_MSG_DEBUG( "::bcidDecision: masks: " << MSG::hex
660  << decision3 << " " << decision2 << " " << decision1 << MSG::dec );
661 
662  bcidDecision(bcidResults, range, mask, output);
663 }
664 
667 void L1TriggerTowerToolRun3::bcidDecision(const std::vector<int> &bcidResults, const std::vector<int> &range, const std::vector<unsigned int> &mask, std::vector<int> &output) const
668 {
669  output.clear();
670  output.reserve(bcidResults.size()); // avoid frequent reallocations
671 
672  std::vector<int>::const_iterator itBcid = bcidResults.begin();
673  std::vector<int>::const_iterator itRange = range.begin();
674  int nRange = mask.size();
675 
676  for ( ; itBcid != bcidResults.end() && itRange != range.end(); ++itBcid, ++itRange) {
677  if ((*itRange) < nRange && (mask[*itRange]&(0x1<<*itBcid))) output.push_back(1);
678  else output.push_back(0);
679  }
680 
681  ATH_MSG_DEBUG( "::bcidDecision: output: " << output);
682 
683 
684 }
685 
686 // TODO implement scale
687 void L1TriggerTowerToolRun3::cpLut(const std::vector<int> &fir, const L1CaloCoolChannelId& channelId, std::vector<int> &output) const
688 {
689  int startBit = 0;
690  int strategy = 0;
691  int offset = 0;
692  double offsetReal = 0;
693  int slope = 0;
694  int cut = 0;
695  unsigned short scale_menu = 0;
696  double pedMean = 0;
697  int ped = 0;
698  int hwCoeffSum = 0;
699  const std::vector<short int>* hwCoeffs;
700 
701 
703  const EventContext& ctx = Gaudi::Hive::currentContext();
704 
706  auto settings = pprConditionsRun2->pprConditions(channelId.id());
707  if (settings) {
708  startBit = settings->firStartBit();
709  strategy = settings->lutCpStrategy();
710  slope = settings->lutCpSlope();
711  cut = settings->lutCpNoiseCut();
712  ped = settings->pedValue();
713  pedMean = settings->pedMean();
714 
715  hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
716 
717  auto l1Menu = getL1Menu(ctx);
718  scale_menu = l1Menu->thrExtraInfo().EM().emScale(); // Retrieve scale param from menu
719 
720 
721  for( auto &coeffs : *hwCoeffs) {
722  hwCoeffSum += coeffs;
723  }
724  if (strategy == 0){
725  offsetReal = pedMean * hwCoeffSum / pow(2.,startBit);
726  }
727  else{
728  offsetReal = pedMean * static_cast<double>(hwCoeffSum) * static_cast<double>(slope) / pow(2.,static_cast<double>(startBit)) - static_cast<double>(slope)/2.;
729  }
730  offset = static_cast<unsigned short>( offsetReal < 0. ? 0 : offsetReal + 0.5 );
731 
732  ATH_MSG_DEBUG( "::cpLut: Offset: offset/strategy/pedMean/firCoeffSum/startBit/slope: "
733  << offset << " " << strategy << " " << " " << pedMean << " " << hwCoeffSum << " " << startBit << " " << slope );
734 
735  } else ATH_MSG_WARNING( "::cpLut: No L1CaloPprConditions found" );
736  } else ATH_MSG_WARNING( "::cpLut: No Conditions Container retrieved" );
737 
738  ATH_MSG_DEBUG( "::cpLut: LUT strategy/offset/slope/cut/ped: "
739  << strategy << " " << offset << " " << slope << " " << cut << " " << ped << " " );
740 
741  unsigned int noiseCut = 0;
742  bool disabled = disabledChannel(channelId, noiseCut);
743  if (noiseCut > 0) cut = noiseCut;
744  if(strategy == 2) {
745  // take the global scale into account - translate strategy to 1 for Run-1 compatible treatment
746  lut(fir, scale_menu*slope, scale_menu*offset, scale_menu*cut, 1, disabled, output);
747  } else if(strategy == 1 || strategy == 0){
748  lut(fir, slope, offset, cut, strategy, disabled, output);
749  } else if (strategy == 4) {
750  // Run-3 FCAL LUT filling scheme (strategy 4) which is identical to
751  // Run-2 strategy 2, but contains an additional fixed factor of 2.
752  lut(fir, scale_menu*slope, scale_menu*offset, scale_menu*cut, 4, disabled, output);
753 
754  }
755 
756  else {
757  ATH_MSG_WARNING(" ::cpLut: Unknown stragegy: " << strategy);
758  output.push_back(0); //avoid crashing with Unknown stragegy
759  }
760 }
761 
762 void L1TriggerTowerToolRun3::jepLut(const std::vector<int> &fir, const L1CaloCoolChannelId& channelId, std::vector<int> &output) const
763 {
764  int startBit = 0;
765  int strategy = 0;
766  int offset = 0;
767  double offsetReal = 0;
768  int slope = 0;
769  int cut = 0;
770  unsigned short scale_db = 0;
771  unsigned short scale_menu = 0;
772  int ped = 0;
773  double pedMean = 0;
774  int hwCoeffSum = 0;
775  const std::vector<short int>* hwCoeffs;
776  short par1 = 0;
777  short par2 = 0;
778  short par3 = 0;
779  short par4 = 0;
780 
781  if(!isRun2()) {
782  // assert instead ?!
783  ATH_MSG_WARNING("::jepLut: Run-1 data - behaviour undefined!");
784  }
785 
786 
788  const EventContext& ctx = Gaudi::Hive::currentContext();
789 
791  const auto settings = pprConditionsRun2->pprConditions(channelId.id());
792  if (settings) {
793  startBit = settings->firStartBit();
794  strategy = settings->lutJepStrategy();
795  slope = settings->lutJepSlope();
796  cut = settings->lutJepNoiseCut();
797  ped = settings->pedValue();
798  pedMean = settings->pedMean();
799  scale_db = settings->lutJepScale();
800 
801  auto l1Menu = getL1Menu(ctx);
802  scale_menu = l1Menu->thrExtraInfo().JET().jetScale(); // Retrieve scale param from menu
803 
804  if (strategy == 3) {
805  par1 = settings->lutJepPar1();
806  par2 = settings->lutJepPar2();
807  par3 = settings->lutJepPar3();
808  par4 = settings->lutJepPar4();
809  }
810 
811  hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
812 
813  for( auto &coeffs : *hwCoeffs) {
814  hwCoeffSum += coeffs;
815  }
816  if (strategy == 0){
817  offsetReal = pedMean * hwCoeffSum / pow(2.,startBit);
818  }
819  else{
820  offsetReal = pedMean * static_cast<double>(hwCoeffSum) * static_cast<double>(slope) / pow(2.,static_cast<double>(startBit)) - static_cast<double>(slope)/2.;
821  }
822  offset = static_cast<unsigned short>( offsetReal < 0. ? 0 : offsetReal + 0.5 );
823 
824  ATH_MSG_VERBOSE( "::jepLut: Offset: offset/strategy/pedMean/firCoeffSum/startBit/slope: "
825  << offset << " " << strategy << " " << " " << pedMean << " " << hwCoeffSum << " " << startBit << " " << slope );
826 
827  } else ATH_MSG_WARNING( "::jepLut: No L1CaloPprConditions found" );
828  } else ATH_MSG_WARNING( "::jepLut: No Conditions Container retrieved" );
829 
830  ATH_MSG_VERBOSE( "::jepLut: LUT strategy/offset/slope/cut/ped: "
831  << strategy << " " << offset << " " << slope << " " << cut << " " << ped << " " );
832 
833  unsigned int noiseCut = 0;
834  bool disabled = disabledChannel(channelId, noiseCut);
835  if (noiseCut > 0) cut = noiseCut;
836 
837  if(strategy == 3) {
838  nonLinearLut(fir, slope, offset, cut, scale_db, par1, par2, par3, par4, disabled, output);
839  }
840  else if(strategy == 2) {
841  // take the global scale into account - translate strategy to 1 for Run-1 compatible treatment
842  lut(fir, scale_menu*slope, scale_menu*offset, scale_menu*cut, 1, disabled, output);
843 
844  }else if(strategy == 1 || strategy == 0) {
845  lut(fir, slope, offset, cut, strategy, disabled, output);
846  }
847  else if (strategy == 4) {
848  // Run-3 FCAL LUT filling scheme (strategy 4) which is identical to
849  // Run-2 strategy 2, but contains an additional fixed factor of 2.
850  lut(fir, scale_menu*slope, scale_menu*offset, scale_menu*cut, 4, disabled, output);
851 
852  }
853 
854  else {
855  ATH_MSG_WARNING(" ::jepLut: Unknown stragegy: " << strategy);
856  output.push_back(0);//avoid crashing with Unknown stragegy
857  }
858 
859 
860 }
861 
863 void L1TriggerTowerToolRun3::lut(const std::vector<int> &fir, int slope, int offset, int cut, int strategy, bool disabled, std::vector<int> &output) const
864 {
865  output.clear();
866  output.reserve(fir.size()); // avoid frequent reallocations
867 
868  const int reScale = 2;
869  for( auto it : fir) {
870  int out = 0;
871  if (!disabled) {
872  if (strategy == 0 && it >= offset+cut) { // Original scheme
873  out = ((it-offset)*slope + 2048)>>12;
874  }
875  else if (strategy == 1 && it*slope >= offset+cut) { // New scheme
876  out = (it*slope - offset + 2048)>>12;
877  }
878  // Note: for strategy 2, the code is called with strategy=1
879  else if (strategy == 4 && it*slope >= offset+ cut/reScale) { // FCAL
880  out = (it*slope*reScale - offset*reScale + 2048)>>12;
881  }
882  if (out < 0) out = 0;
884  }
885  output.push_back(out);
886  }
887 
888  ATH_MSG_DEBUG( "::lut: output: " << output);
889 
890 }
891 
892 void 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
893 {
894  output.clear();
895  output.reserve(fir.size()); // avoid frequent reallocations
896 
897 
898  for( auto it : fir) {
899  int out = 0;
900  if (!disabled) {
901  // turn shorts into double
902  double nll_slope = 0.001 * scale;
903  double nll_offset = 0.001 * par1;
904  double nll_ampl = 0.001 * par2;
905  double nll_expo = 0.;
906  if(par3) {
907  nll_expo = -1. / (4096 * 0.001*par3);
908  } else {
909  nll_ampl = 0.;
910  }
911  double nll_noise = 0.001 * par4;
912 
913  // noise cut
914  if (it * slope < offset + nll_noise * cut) {
915  output.push_back(0);
916  continue;
917  }
918  // actual calculation
919  out = int((((int)(2048 + nll_slope * (it * slope - offset)))>>12) + nll_offset + nll_ampl * std::exp(nll_expo * (it * slope - offset)));
920 
922  if(out < 0) out = 0;
923  }
924  output.push_back(out);
925  }
926  ATH_MSG_DEBUG( "::nonLinearLut: output: " << output);
927 
928 }
932 void L1TriggerTowerToolRun3::applyEtRange(const std::vector<int>& lut, const std::vector<int>& range, const L1CaloCoolChannelId& channelId, std::vector<int> &output) const
933 {
935  std::vector<int>::const_iterator itlut = lut.begin();
936  std::vector<int>::const_iterator itrange = range.begin();
937  while ( itlut != lut.end() && itrange != range.end() ) {
938  if (!disabled && satOverride((*itrange))) output.push_back(s_saturationValue);
939  else output.push_back(*itlut);
940  ++itlut;
941  ++itrange;
942  }
943 
944  ATH_MSG_DEBUG( "::applyEtRange: output: " << output);
945 
946 }
947 
949 namespace { // helper function
950  template<class T>
951  std::tuple<bool, int, int> getBcidEnergyRange(unsigned int coolId, SG::ReadCondHandle<L1CaloPprConditionsContainerRun2> pprConditionsRun2) {
952  auto settings = pprConditionsRun2->pprConditions(coolId);
953  if(!settings) return std::make_tuple(false, 0, 0);
954  return std::make_tuple(true, settings->bcidEnergyRangeLow(), settings->bcidEnergyRangeHigh());
955  }
956 }
957 
958 // anonymous namespace
959 
960 void L1TriggerTowerToolRun3::etRange(const std::vector<int> &et, const L1CaloCoolChannelId& channelId, std::vector<int> &output) const
961 {
962  int energyLow = 0;
963  int energyHigh = 0;
965 
967  bool available = false;
968  std::tie(available, energyLow, energyHigh) = getBcidEnergyRange<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
969  if(!available) ATH_MSG_WARNING("::etRange: No L1CaloPprConditions found");
970  } else ATH_MSG_WARNING("::etRange: No Conditions Container retrieved");
971 
972  ATH_MSG_VERBOSE( "::etRange: energyLow: " << energyLow
973  << " energyHigh: " << energyHigh);
974 
975  etRange(et, energyLow, energyHigh, output);
976 }
977 
980 void L1TriggerTowerToolRun3::etRange(const std::vector<int> &et, int energyLow, int energyHigh, std::vector<int> &output) const
981 {
982  output.clear();
983  output.reserve(et.size()); // avoid frequent reallocations
984  for( auto it : et) {
985  if (it <= energyLow) output.push_back(0);
986  else if (it <= energyHigh) output.push_back(1);
987  else output.push_back(2);
988  }
989 
990  ATH_MSG_DEBUG( "::etRange: output: " << output);
991 
992 
993 }
994 
996 namespace { // helper function
997  template<class T>
998  std::tuple<bool, int> getFirStartBit(unsigned int coolId, SG::ReadCondHandle<L1CaloPprConditionsContainerRun2> pprConditionsRun2) {
999  auto settings = pprConditionsRun2->pprConditions(coolId);
1000  if(!settings) return std::make_tuple(false, 0);
1001  return std::make_tuple(true, settings->firStartBit());
1002  }
1003 } // anonymous namespace
1004 
1005 void L1TriggerTowerToolRun3::dropBits(const std::vector<int> &fir, const L1CaloCoolChannelId& channelId, std::vector<int> &output) const
1006 {
1007  unsigned int start = 0;
1009 
1011  bool available = false;
1012  std::tie(available, start) = getFirStartBit<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
1013  if(!available)ATH_MSG_WARNING( "::dropBits: No L1CaloPprConditions found" );
1014  } else ATH_MSG_WARNING( "::dropBits: No Conditions Container retrieved" );
1015 
1016  ATH_MSG_DEBUG( "::dropBits: firStartBit: " << start );
1017 
1018  dropBits(fir, start, output);
1019 }
1020 
1023 void L1TriggerTowerToolRun3::dropBits(const std::vector<int> &fir, unsigned int start, std::vector<int> &output) const
1024 {
1025  output.clear();
1026  output.reserve(fir.size()); // avoid frequent reallocations
1027 
1029  unsigned int mask = (0x3ff<<start);
1030 
1032  int max = 1<<(10+start);
1033 
1034  for( auto it : fir) {
1035  if (it>=max) output.push_back(0x3ff);
1036  else output.push_back((it&mask)>>start);
1037  }
1038 
1039  ATH_MSG_DEBUG( "::dropBits: output: " << output);
1040 }
1041 
1043 void L1TriggerTowerToolRun3::firParams(const L1CaloCoolChannelId& channelId, std::vector<int> &firCoeffs) const
1044 {
1046  firCoeffs.clear();
1049  const std::vector<short int>* hwCoeffs = nullptr;
1050  hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2 );
1051 
1052  if(hwCoeffs) {
1056  firCoeffs.reserve(hwCoeffs->size()); // avoid frequent reallocations
1057  for (int i = hwCoeffs->size()-1; i >= 0; --i) firCoeffs.push_back((*hwCoeffs)[i]);
1058 
1059  } else ATH_MSG_WARNING( "::firParams: No L1CaloPprConditions found" );
1060  } else ATH_MSG_WARNING( "::firParams: No Conditions Container retrieved" );
1061 
1062 
1063  ATH_MSG_DEBUG( "::fir: FIR coefficients: " << firCoeffs);
1064 
1065 }
1066 
1068 void L1TriggerTowerToolRun3::bcidParams(const L1CaloCoolChannelId& channelId, int &energyLow, int &energyHigh, int &decisionSource, std::vector<unsigned int> &decisionConditions,
1069  unsigned int &peakFinderStrategy, int &satLow, int &satHigh, int &satLevel) const
1070 {
1071  energyLow = 0;
1072  energyHigh = 0;
1073  decisionSource = 0;
1074  decisionConditions.clear();
1075  peakFinderStrategy = 0;
1076  satLevel = 0;
1077  satLow = 0;
1078  satHigh = 0;
1079 
1081 
1083  using std::get;
1084  std::tuple<unsigned int, unsigned int, unsigned int> bcidDecision;
1085  std::tuple<bool, int, int> bcidEnergyRange;
1086  std::tuple<bool, int, int, int> saturation;
1087 
1088  using Cont = L1CaloPprConditionsContainerRun2;
1089  bcidDecision = getBcidDecision<Cont>(pprConditionsRun2);
1090  peakFinderStrategy = getStrategy<Cont>(pprConditionsRun2);
1091  decisionSource = getDecisionSource<Cont>(pprConditionsRun2);
1092  bcidEnergyRange = getBcidEnergyRange<Cont>(channelId.id(), pprConditionsRun2);
1093  saturation = getSaturation<Cont>(channelId.id(), pprConditionsRun2);
1094 
1095 
1096  decisionConditions = { get<2>(bcidDecision),
1097  get<1>(bcidDecision),
1098  get<0>(bcidDecision) }; // reverse order
1099  if(get<0>(bcidEnergyRange)) {
1100  std::tie(std::ignore, energyLow, energyHigh) = bcidEnergyRange;
1101  } else ATH_MSG_WARNING( "::bcidParams: No BcidEnergyRange found" );
1102 
1103  if(get<0>(saturation)) {
1104  std::tie(std::ignore, satLevel, satLow, satHigh) = saturation;
1105  } else ATH_MSG_WARNING( "::bcidParams: No Saturation found" );
1106  } else ATH_MSG_WARNING( "::bcid:Params No Conditions Container retrieved" );
1107 
1108  ATH_MSG_DEBUG( "::bcidParams: satLevel: " << satLevel
1109  << " satLow: " << satLow << " satHigh: " << satHigh << endmsg
1110  << " energyLow: " << energyLow << " energyHigh: " << energyHigh << endmsg
1111  << " decisionSource: " << decisionSource << " peakFinderStrategy: "
1112  << peakFinderStrategy );
1113 
1114 }
1115 
1116 void L1TriggerTowerToolRun3::cpLutParams(const L1CaloCoolChannelId& channelId, int& startBit, int& slope, int& offset, int& cut, int& pedValue, float& pedMean, int& strategy, bool& disabled)
1117 {
1118  startBit = 0;
1119  strategy = 0;
1120  offset = 0;
1121  double offsetReal = 0;
1122  slope = 0;
1123  cut = 0;
1124  pedValue = 0;
1125  pedMean = 0.;
1126  disabled = true;
1127  int hwCoeffSum = 0;
1128  const std::vector<short int>* hwCoeffs;
1129 
1130  if(!isRun2()) {
1131  // assert instead ?!
1132  ATH_MSG_WARNING("::cpLutParams: Run-1 data - behaviour undefined!");
1133  }
1134 
1136 
1138  const auto settings = pprConditionsRun2->pprConditions(channelId.id());
1139  if(settings) {
1140  startBit = settings->firStartBit();
1141  strategy = settings->lutCpStrategy();
1142  slope = settings->lutCpSlope();
1143  cut = settings->lutCpNoiseCut();
1144  pedValue = settings->pedValue();
1145  pedMean = settings->pedMean();
1146 
1147  hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(), pprConditionsRun2);
1148 
1149  for( auto &coeffs : *hwCoeffs) {
1150  hwCoeffSum += coeffs;
1151  }
1152  if (strategy == 0){
1153  offsetReal = pedMean * hwCoeffSum / pow(2.,startBit);
1154  }
1155  else{
1156  offsetReal = pedMean * hwCoeffSum * slope / pow(2.,startBit) - slope/2.;
1157  }
1158  offset = static_cast<unsigned short>( offsetReal < 0. ? 0 : offsetReal + 0.5 );
1159 
1160  ATH_MSG_VERBOSE( "::jepLutParams: Offset: offset/strategy/pedMean/firCoeffSum/startBit/slope: "
1161  << offset << " " << strategy << " " << " " << pedMean << " " << hwCoeffSum << " " << startBit << " " << slope );
1162 
1163  } else ATH_MSG_WARNING( "::cpLutParams: No L1CaloPprConditions found" );
1164  } else ATH_MSG_WARNING( "::cpLutParams: No Conditions Container retrieved" );
1165 
1166  ATH_MSG_VERBOSE( "::cpLutParams: LUT startBit/strategy/offset/slope/cut/pedValue/pedMean: "
1167  << startBit << " " << strategy << " " << offset << " " << slope << " " << cut << " " << pedValue << " " << pedMean );
1168  unsigned int noiseCut = 0;
1169  disabled = disabledChannel(channelId, noiseCut);
1170  if (noiseCut > 0) cut = noiseCut;
1171 }
1172 
1173 void L1TriggerTowerToolRun3::jepLutParams(const L1CaloCoolChannelId& channelId, int& startBit, int& slope, int& offset, int& cut, int& pedValue, float& pedMean, int& strategy, bool& disabled)
1174 {
1175  startBit = 0;
1176  strategy = 0;
1177  offset = 0;
1178  double offsetReal = 0;
1179  slope = 0;
1180  cut = 0;
1181  pedValue = 0;
1182  pedMean = 0.;
1183  disabled = true;
1184  int hwCoeffSum = 0;
1185  const std::vector<short int>* hwCoeffs;
1186 
1187  if(!isRun2()) {
1188  // assert instead ?!
1189  ATH_MSG_WARNING("::jepLutParams: Run-1 data - behaviour undefined!");
1190  }
1191 
1194  const auto settings = pprConditionsRun2->pprConditions(channelId.id());
1195  if(settings) {
1196  startBit = settings->firStartBit();
1197  strategy = settings->lutJepStrategy();
1198  slope = settings->lutJepSlope();
1199  cut = settings->lutJepNoiseCut();
1200  pedValue = settings->pedValue();
1201  pedMean = settings->pedMean();
1202 
1203  hwCoeffs = getFirCoefficients<L1CaloPprConditionsContainerRun2>(channelId.id(),pprConditionsRun2);
1204 
1205  for( auto &coeffs : *hwCoeffs) {
1206  hwCoeffSum += coeffs;
1207  }
1208  if (strategy == 0){
1209  offsetReal = pedMean * hwCoeffSum / pow(2.,startBit);
1210  }
1211  else{
1212  offsetReal = pedMean * hwCoeffSum * slope / pow(2.,startBit) - slope/2.;
1213  }
1214  offset = static_cast<unsigned short>( offsetReal < 0. ? 0 : offsetReal + 0.5 );
1215 
1216  ATH_MSG_VERBOSE( "::jepLutParams: Offset: offset/strategy/pedMean/firCoeffSum/startBit/slope: "
1217  << offset << " " << strategy << " " << " " << pedMean << " " << hwCoeffSum << " " << startBit << " " << slope );
1218 
1219  } else ATH_MSG_WARNING( "::jepLutParams: No L1CaloPprConditions found" );
1220  } else ATH_MSG_WARNING( "::jepLutParams: No Conditions Container retrieved" );
1221 
1222  ATH_MSG_VERBOSE( "::jepLutParams: LUT startBit/strategy/offset/slope/cut/pedValue/pedMean: "
1223  << startBit << " " << strategy << " " << offset << " " << slope << " " << cut << " " << pedValue << " " << pedMean );
1224  unsigned int noiseCut = 0;
1225  disabled = disabledChannel(channelId, noiseCut);
1226  if (noiseCut > 0) cut = noiseCut;
1227 }
1228 
1231 Identifier L1TriggerTowerToolRun3::identifier(double eta, double phi, int layer)
1232 {
1233  Identifier id(0);
1235  int pos_neg_z = m_l1CaloTTIdTools->pos_neg_z(eta);
1236  int region = m_l1CaloTTIdTools->regionIndex(eta);
1237  int ieta = m_l1CaloTTIdTools->etaIndex(eta);
1238  int iphi = m_l1CaloTTIdTools->phiIndex(eta, phi);
1239 
1240  id = m_lvl1Helper->tower_id(pos_neg_z, layer, region, ieta, iphi);
1241  }
1242  return id;
1243 }
1244 
1247 HWIdentifier L1TriggerTowerToolRun3::hwIdentifier(const Identifier& id)
1248 {
1249  HWIdentifier hwId(0);
1250  if (m_ttSvc) {
1251  try { hwId = m_ttSvc->createTTChannelID(id, false); }
1252  catch (const CaloID_Exception&) { hwId = HWIdentifier(0); }
1253  }
1254  return hwId;
1255 }
1256 
1259 HWIdentifier L1TriggerTowerToolRun3::hwIdentifier(double eta, double phi, int layer)
1260 {
1261  Identifier id = identifier(eta, phi, layer);
1262  return hwIdentifier(id);
1263 }
1264 
1268 {
1269  // Use direct lookup table if possible
1270  const double absEta = std::abs(eta);
1271  int index = 0;
1272  if (absEta < 2.5) {
1273  const int etaBin = 10.*absEta;
1274  const int phiBin = phi*(32/M_PI);
1275  index = (etaBin<<6) + phiBin;
1276  } else if (absEta < 3.2) {
1277  const int etaBin = 5.*(absEta - 2.5);
1278  const int phiBin = phi*(16./M_PI);
1279  index = 1600 + (etaBin<<5) + phiBin;
1280  } else {
1281  const int etaBin = (absEta - 3.2)*(1./0.425);
1282  const int phiBin = phi*(8./M_PI);
1283  index = 1728 + (etaBin<<4) + phiBin;
1284  }
1285  if (eta < 0.) index += 1792;
1286  if (layer > 0) index += 3584;
1287  if (index >= s_maxTowers) return L1CaloCoolChannelId(0);
1288  if (m_idTable.empty()) {
1289  m_idTable.reserve(s_maxTowers);
1290  m_idTable.assign(s_maxTowers, 0);
1291  }
1292  if (m_idTable[index] == 0) {
1293  Identifier id = identifier(eta, phi, layer);
1294  L1CaloCoolChannelId coolID = channelID(id);
1295  m_idTable[index] = coolID.id();
1296  }
1298 }
1299 
1303 {
1304  L1CaloCoolChannelId coolId(0);
1305  if (m_ttSvc) {
1306  try {
1307  HWIdentifier hwId = hwIdentifier(id);
1308  coolId = m_ttSvc->createL1CoolChannelId(hwId);
1309  }
1310  catch (const CaloID_Exception&) { coolId = L1CaloCoolChannelId(0); }
1311  }
1312  return coolId;
1313 }
1314 
1316 namespace { // helper function
1317  template<class T>
1318  std::tuple<bool, bool, bool> getSatOverride(SG::ReadCondHandle<L1CaloPprConditionsContainerRun2> pprConditionsRun2) {
1319  return std::make_tuple(pprConditionsRun2->satOverride1(), pprConditionsRun2->satOverride2(), pprConditionsRun2->satOverride3());
1320  }
1321 } // anonymous namespace
1322 
1324 {
1325 
1327 
1328  bool override = false;
1330  std::tuple<bool, bool, bool> satOverride;
1331  satOverride = getSatOverride<L1CaloPprConditionsContainerRun2>(pprConditionsRun2);
1332  // NB Reverse order as for bcidDecision1/2/3
1333  if (range == 0) override = std::get<2>(satOverride);
1334  else if (range == 1) override = std::get<1>(satOverride);
1335  else if (range == 2) override = std::get<0>(satOverride);
1336  } else ATH_MSG_WARNING( "::satOverride: No Conditions Container retrieved" );
1337 
1338  ATH_MSG_VERBOSE( "::satOverride: range " << range
1339  << " has saturation override flag " << override );
1340 
1341  return override;
1342 }
1343 
1347 {
1348  unsigned int noiseCut = 0;
1349  return disabledChannel(channelId, noiseCut);
1350 }
1351 
1353 bool L1TriggerTowerToolRun3::disabledChannel(const L1CaloCoolChannelId& channelId, unsigned int& noiseCut) const
1354 {
1355 
1357  bool isDisabled = false;
1358  noiseCut = 0;
1360 
1361  const auto disabledChan = pprDisabledChannel->pprDisabledChannel(channelId.id());
1362 
1363  if (disabledChan) {
1364  if (!disabledChan->disabledBits()) {
1365  ChanCalibErrorCode calibError(disabledChan->calibErrorCode());
1366  if (calibError.chanValid()) {
1367  ChanDeadErrorCode deadError(disabledChan->deadErrorCode());
1368  if (deadError.chanValid()) noiseCut = disabledChan->noiseCut();
1369  //else isDisabled = true;
1370  } //else isDisabled = true;
1371  } else isDisabled = true;
1372 
1373  ATH_MSG_DEBUG( MSG::hex
1374  << "::disabledChannel: calibErrorCode: " << (disabledChan->calibErrorCode()).errorCode()
1375  << " deadErrorCode: " << (disabledChan->deadErrorCode()).errorCode()
1376  << " noiseCut: " << disabledChan->noiseCut()
1377  << " disabledBits: " << disabledChan->disabledBits()
1378  << MSG::dec );
1379 
1380  } else {
1381  ATH_MSG_DEBUG( "::disabledChannel: No L1CaloPprDisabledChannel found" );
1382  }
1383  } else {
1384  ATH_MSG_WARNING( "::disabledChannel: No DisabledChannel Container retrieved" );
1385  }
1386  if (isDisabled) ATH_MSG_DEBUG( "::disabledChannel: Channel is disabled" );
1387 
1388  return isDisabled;
1389 }
1390 
1391 
1395 double L1TriggerTowerToolRun3::FCalTTeta(double nominalEta, double /*phi*/, int layer)
1396 {
1397  double eta = nominalEta;
1398  float abseta = std::abs(eta);
1399  if (abseta<3.2) return eta; // If called for non-FCAL TT return input value
1400  if (layer == 0) {
1401  int sign = ((eta > 0) ? 1 : -1);
1402  if (abseta < 3.6) eta = 3.15 * sign;
1403  else if (abseta < 4.0) eta = 3.33 * sign;
1404  else if (abseta < 4.5) eta = 3.72 * sign;
1405  else eta = 4.41 * sign;
1406  }
1407  else if (eta > 0) {
1408  if (abseta < 3.6) eta = 3.36;
1409  else if (abseta < 4.0) eta = 3.45;
1410  else if (abseta < 4.5) eta = 4.17;
1411  else eta = 4.19;
1412  }
1413  else {
1414  if (abseta < 3.6) eta = -3.45;
1415  else if (abseta < 4.0) eta = -3.36;
1416  else if (abseta < 4.5) eta = -4.19;
1417  else eta = -4.17;
1418  }
1419  return eta;
1420 }
1421 
1427 {
1428  if ( !m_mappingTool.isValid() ) {
1429  throw GaudiException("No mapping tool configured",
1430  "L1TriggerTowerToolRun3::FCalTTeta", StatusCode::FAILURE);
1431  }
1432 
1434  unsigned int crate = channelId.crate();
1435  unsigned int module = channelId.module();
1436  unsigned int mcm = channelId.subModule();
1437  unsigned int pin = channelId.channel();
1438  int channel = pin*16 + mcm;
1439 
1441  double eta;
1442  double phi;
1443  int layer;
1444  if(!m_mappingTool->mapping(crate, module, channel, eta, phi, layer)) {
1445  ATH_MSG_WARNING("::FCalTTeta: could not map 0x" << std::hex << channelId.id() << std::dec);
1446  }
1447 
1449  return FCalTTeta(eta, phi, layer);
1450 }
1451 
1452 
1453 
1455 {
1456  //method returning the fine time reference and calibration value
1457  //the fineTimeReference folder has to be loaded first using the method L1TriggerTowerToolRun3::loadFTRefs
1458  double reference = 0;
1459  double calib = 0;
1461 
1463  const L1CaloPpmFineTimeRefs* ftref = ppmFineTimeRefs->ppmFineTimeRefs(channelId.id());
1464  if (ftref) {
1465  FineTimeErrorCode errorCode(ftref->errorCode());
1466 // if (errorCode.chanValid()) { //this should be changed at some point, at the moment the error code is ignored
1467  reference = ftref->refValue();
1468  calib = ftref->calibValue();
1469 // }
1470 
1471  ATH_MSG_VERBOSE( MSG::hex
1472  << "::refValues: errorCode: " << (ftref->errorCode()).errorCode()
1473  << MSG::dec << " reference: " << ftref->refValue() << " calib: " << ftref->calibValue() );
1474 
1475  } else {
1476  ATH_MSG_VERBOSE( "::refValue: No FineTimeRefsTowers found" );
1477  }
1478  } else {
1479  ATH_MSG_VERBOSE( "::refValue: No FineTimeRefs Container retrieved" );
1480  }
1481 
1482  return std::make_pair(reference, calib);
1483 }
1484 
1485 void L1TriggerTowerToolRun3::pedestalCorrection(std::vector<int>& firInOut, int firPed, int iElement, int layer, int bcid, float mu, std::vector<int_least16_t>& correctionOut) {
1486  unsigned nFIR = firInOut.size();
1487  correctionOut.assign(nFIR, 0u);
1488 
1489  if(!m_correctFir) return;
1490 
1491  // apply the pedestal correction
1492  for(unsigned i = 0; i != nFIR; ++i) {
1493  correctionOut[i] = (m_dynamicPedestalProvider->dynamicPedestal(iElement, layer, firPed, bcid + i - nFIR/2, mu) - firPed);
1494  firInOut[i] -= correctionOut[i];
1495 
1496  if(firInOut[i] < 0) firInOut[i] = 0;
1497  }
1498 
1499  ATH_MSG_DEBUG( "::pedestalCorrection(BCID=" << bcid << ", mu = " << mu << "): " << correctionOut);
1500 
1501 }
1502 
1504 {
1505  const EventContext& ctx = Gaudi::Hive::currentContext();
1506  if (ctx.eventID().run_number() >= 253377) return true;
1507 
1509  if (eventInfo->eventType (xAOD::EventInfo::IS_SIMULATION)) return true;
1510  return false;
1511 }
1512 
1513 
1514 
1515 const TrigConf::L1Menu* L1TriggerTowerToolRun3::getL1Menu(const EventContext& ctx) const {
1516  const TrigConf::L1Menu* menu = nullptr;
1517 
1518  StatusCode sc = m_configSvc.retrieve();
1519  if (sc.isFailure()) {
1520  ATH_MSG_WARNING( "Cannot retrieve trigger configuration service" );
1521  }
1522 
1523  if (detStore()->contains<TrigConf::L1Menu>(m_L1MenuKey.key())) {
1525  if( l1MenuHandle.isValid() ){
1526  menu=l1MenuHandle.cptr();
1527  }
1528  } else {
1529  menu = &(m_configSvc->l1Menu(ctx));
1530  }
1531 
1532  return menu;
1533 }
1534 
1535 
1536 
1537 } // end of namespace
1538 
1539 
1540 
1541 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
xAOD::strategy
strategy
Definition: L2CombinedMuon_v1.cxx:107
L1CaloPprConditionsContainerRun2::satOverride3
int satOverride3() const
Definition: L1CaloPprConditionsContainerRun2.h:64
L1CaloPprConditionsContainerRun2
Container of L1CaloPprConditions objects, inherit from the abstract base class AbstractL1CaloConditio...
Definition: L1CaloPprConditionsContainerRun2.h:32
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
LVL1::L1TriggerTowerToolRun3::nonLinearLut
virtual void 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
Definition: L1TriggerTowerToolRun3.cxx:892
LVL1::L1TriggerTowerToolRun3::m_ttSvc
ToolHandle< CaloTriggerTowerService > m_ttSvc
Definition: L1TriggerTowerToolRun3.h:136
IL1CaloTTIdTools.h
LVL1::L1TriggerTowerToolRun3::disabledChannel
virtual bool disabledChannel(const L1CaloCoolChannelId &channelId) const override
Check for disabled channel.
Definition: L1TriggerTowerToolRun3.cxx:1346
LVL1::L1TriggerTowerToolRun3::m_L1MenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
Definition: L1TriggerTowerToolRun3.h:156
et
Extra patterns decribing particle interation process.
LVL1::L1TriggerTowerToolRun3::bcidDecisionRange
virtual void bcidDecisionRange(const std::vector< int > &lutInput, const std::vector< int > &digits, const L1CaloCoolChannelId &channelId, std::vector< int > &output) const override
Definition: L1TriggerTowerToolRun3.cxx:619
LVL1::L1TriggerTowerToolRun3::cpLutParams
virtual void cpLutParams(const L1CaloCoolChannelId &channelId, int &startBit, int &slope, int &offset, int &cut, int &pedValue, float &pedMean, int &strategy, bool &disabled) override
Definition: L1TriggerTowerToolRun3.cxx:1116
FineTimeErrorCode
FineTimeErrorCode class for L1Calo error codes.
Definition: FineTimeErrorCode.h:19
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
LVL1::L1TriggerTowerToolRun3::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: L1TriggerTowerToolRun3.cxx:65
get_generator_info.result
result
Definition: get_generator_info.py:21
L1CaloPprConditionsRun2::firStartBit
unsigned short firStartBit() const
Definition: L1CaloPprConditionsRun2.h:74
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
max
#define max(a, b)
Definition: cfImp.cxx:41
L1CaloPpmFineTimeRefsContainer::ppmFineTimeRefs
const L1CaloPpmFineTimeRefs * ppmFineTimeRefs(unsigned int channelId) const
Definition: L1CaloPpmFineTimeRefsContainer.cxx:119
LVL1::L1TriggerTowerToolRun3::m_pprDisabledChannelContainer
SG::ReadCondHandleKey< L1CaloPprDisabledChannelContainerRun2 > m_pprDisabledChannelContainer
Definition: L1TriggerTowerToolRun3.h:143
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
L1CaloPprConditionsContainerRun2::peakFinderCond
int peakFinderCond() const
Definition: L1CaloPprConditionsContainerRun2.h:65
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloID_Exception
Exception class for Calo Identifiers.
Definition: CaloID_Exception.h:20
LVL1::L1TriggerTowerToolRun3::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: L1TriggerTowerToolRun3.h:155
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
hist_file_dump.d
d
Definition: hist_file_dump.py:137
LVL1::L1TriggerTowerToolRun3::identifier
virtual Identifier identifier(double eta, double phi, int layer) override
Return offline identifier for given tower coordinates.
Definition: L1TriggerTowerToolRun3.cxx:1231
LVL1::L1TriggerTowerToolRun3::isRun2
bool isRun2() const
Definition: L1TriggerTowerToolRun3.cxx:1503
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
LVL1::L1TriggerTowerToolRun3::m_caloMgr
const CaloIdManager * m_caloMgr
Id managers.
Definition: L1TriggerTowerToolRun3.h:131
python.TriggerConfig.menu
menu
Definition: TriggerConfig.py:836
LVL1::L1TriggerTowerToolRun3::m_runParametersContainer
SG::ReadCondHandleKey< L1CaloRunParametersContainer > m_runParametersContainer
Definition: L1TriggerTowerToolRun3.h:145
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
LVL1::L1TriggerTowerToolRun3::satOverride
virtual bool satOverride(int range) const override
Definition: L1TriggerTowerToolRun3.cxx:1323
IL1DynamicPedestalProvider.h
skel.it
it
Definition: skel.GENtoEVGEN.py:423
LVL1::L1TriggerTowerToolRun3::refValues
virtual std::pair< double, double > refValues(const L1CaloCoolChannelId &channelId) override
Definition: L1TriggerTowerToolRun3.cxx:1454
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
M_PI
#define M_PI
Definition: ActiveFraction.h:11
LVL1::L1TriggerTowerToolRun3::satBcid
virtual void satBcid(const std::vector< int > &digits, const L1CaloCoolChannelId &channelId, std::vector< int > &output) const override
Saturated pulse BCID.
Definition: L1TriggerTowerToolRun3.cxx:547
LVL1::L1TriggerTowerToolRun3::simulateChannel
virtual void simulateChannel(const xAOD::TriggerTower &tt, std::vector< int > &outCpLut, std::vector< int > &outJepLut, std::vector< int > &bcidResults, std::vector< int > &bcidDecisions) const override
All-in-one routine - give it the TT identifier, and it returns the results.
Definition: L1TriggerTowerToolRun3.cxx:220
LVL1::L1TriggerTowerToolRun3::etRange
virtual void etRange(const std::vector< int > &et, const L1CaloCoolChannelId &channelId, std::vector< int > &output) const override
Definition: L1TriggerTowerToolRun3.cxx:960
ChanCalibErrorCode::chanValid
bool chanValid() const
Checks if channel is valid, ie.
Definition: ChanCalibErrorCode.cxx:46
LVL1::L1TriggerTowerToolRun3::cpLut
virtual void cpLut(const std::vector< int > &fir, const L1CaloCoolChannelId &channelId, std::vector< int > &output) const override
Definition: L1TriggerTowerToolRun3.cxx:687
ChanCalibErrorCode
ChanCalibErrorCode class for L1Calo error codes Adapted from /LVL1/l1calo/coolL1Calo/coolL1Calo/ChanE...
Definition: ChanCalibErrorCode.h:20
LVL1::L1TriggerTowerToolRun3::process
virtual void process(const std::vector< int > &digits, double eta, double phi, int layer, std::vector< int > &et, std::vector< int > &bcidResults, std::vector< int > &bcidDecisions, bool useJepLut=true) override
Take in vector of ADC digits, return PPrASIC results.
Definition: L1TriggerTowerToolRun3.cxx:142
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
reference
Definition: hcg.cxx:437
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
LVL1::L1TriggerTowerToolRun3::pedestalCorrection
virtual void pedestalCorrection(std::vector< int > &firInOut, int firPed, int iElement, int layer, int bcid, float mu, std::vector< int_least16_t > &correctionOut) override
Definition: L1TriggerTowerToolRun3.cxx:1485
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
LVL1::L1TriggerTowerToolRun3::jepLutParams
virtual void jepLutParams(const L1CaloCoolChannelId &channelId, int &startBit, int &slope, int &offset, int &cut, int &pedValue, float &pedMean, int &strategy, bool &disabled) override
Definition: L1TriggerTowerToolRun3.cxx:1173
LVL1::L1TriggerTowerToolRun3::m_configSvc
ServiceHandle< TrigConf::ITrigConfigSvc > m_configSvc
Definition: L1TriggerTowerToolRun3.h:159
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::L1TriggerTowerToolRun3::finalize
virtual StatusCode finalize() override
standard Athena-Algorithm method
Definition: L1TriggerTowerToolRun3.cxx:122
LVL1::L1TriggerTowerToolRun3::handle
virtual void handle(const Incident &) override
catch begRun
Definition: L1TriggerTowerToolRun3.cxx:129
L1CaloPprConditionsContainerRun2::bcidDecision1
int bcidDecision1() const
Definition: L1CaloPprConditionsContainerRun2.h:59
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
LVL1::L1TriggerTowerToolRun3::hwIdentifier
virtual HWIdentifier hwIdentifier(const Identifier &id) override
Return online identifier for given offline identifier.
Definition: L1TriggerTowerToolRun3.cxx:1247
LVL1::L1TriggerTowerToolRun3::FCalTTeta
virtual double FCalTTeta(const L1CaloCoolChannelId &channelId) override
Return median eta of trigger tower from L1CaloCoolChannelId.
Definition: L1TriggerTowerToolRun3.cxx:1426
LVL1::L1TriggerTowerToolRun3::fir
virtual void fir(const std::vector< int > &digits, const L1CaloCoolChannelId &channelId, std::vector< int > &output) const override
This FIR simulation produces a vector of same length as digit vector, with peak positions correspondi...
Definition: L1TriggerTowerToolRun3.cxx:427
L1CaloPprConditionsContainerRun2::bcidDecision3
int bcidDecision3() const
Definition: L1CaloPprConditionsContainerRun2.h:63
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
covarianceTool.filter
filter
Definition: covarianceTool.py:514
ChanDeadErrorCode
ChanDeadErrorCode class for L1Calo error codes Adapted from /LVL1/l1calo/coolL1Calo/coolL1Calo/ChanDe...
Definition: ChanDeadErrorCode.h:20
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:269
python.PyAthena.module
module
Definition: PyAthena.py:134
perfmonmt-refit.coeffs
coeffs
Definition: perfmonmt-refit.py:105
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:54
L1CaloPprDisabledChannelContainerRun2::pprDisabledChannel
const L1CaloPprDisabledChannel * pprDisabledChannel(unsigned int channelId) const
Definition: L1CaloPprDisabledChannelContainer.cxx:224
menu
make the sidebar many part of the config
Definition: hcg.cxx:551
LVL1::L1TriggerTowerToolRun3::bcidDecision
virtual void bcidDecision(const std::vector< int > &bcidResults, const std::vector< int > &range, std::vector< int > &output) const override
Definition: L1TriggerTowerToolRun3.cxx:645
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
L1CaloPprConditionsContainerRun2::bcidDecision2
int bcidDecision2() const
Definition: L1CaloPprConditionsContainerRun2.h:61
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
L1CaloRunParametersContainer::runParameters
const L1CaloRunParameters * runParameters(unsigned int channelId) const
Definition: L1CaloRunParametersContainer.cxx:93
lumiFormat.i
int i
Definition: lumiFormat.py:92
LVL1::L1TriggerTowerToolRun3::getL1Menu
const TrigConf::L1Menu * getL1Menu(const EventContext &ctx) const
Definition: L1TriggerTowerToolRun3.cxx:1515
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
LVL1::L1TriggerTowerToolRun3::bcid
virtual void bcid(const std::vector< int > &fir, const std::vector< int > &digits, const L1CaloCoolChannelId &channelId, std::vector< int > &output) const override
Evaluate both peak-finder and saturated BCID algorithms and return vector of predicted BCID result wo...
Definition: L1TriggerTowerToolRun3.cxx:335
master.flag
bool flag
Definition: master.py:29
LVL1::L1TriggerTowerToolRun3::s_maxTowers
static const int s_maxTowers
Definition: L1TriggerTowerToolRun3.h:164
L1CaloPprConditionsContainerRun2::satOverride1
int satOverride1() const
Definition: L1CaloPprConditionsContainerRun2.h:60
xAOD::TriggerTower_v2
Description of TriggerTower_v2.
Definition: TriggerTower_v2.h:49
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
L1CaloCoolChannelId::id
unsigned int id() const
Definition: L1CaloCoolChannelId.h:32
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:127
CaloIdManager::getLVL1_ID
const CaloLVL1_ID * getLVL1_ID(void) const
Definition: CaloIdManager.cxx:75
L1CaloPprConditionsContainerRun2::decisionSource
int decisionSource() const
Definition: L1CaloPprConditionsContainerRun2.h:66
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Make4DCorrelationMatrix.nominalEta
int nominalEta
Definition: Make4DCorrelationMatrix.py:80
ChanDeadErrorCode::chanValid
bool chanValid() const
Definition: ChanDeadErrorCode.h:62
LVL1::L1TriggerTowerToolRun3::dropBits
virtual void dropBits(const std::vector< int > &fir, const L1CaloCoolChannelId &channelId, std::vector< int > &output) const override
Definition: L1TriggerTowerToolRun3.cxx:1005
SCT_Monitoring::disabled
@ disabled
Definition: SCT_MonitoringNumbers.h:60
LVL1::L1TriggerTowerToolRun3::m_idTable
std::vector< unsigned int > m_idTable
Mapping lookup table.
Definition: L1TriggerTowerToolRun3.h:149
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
LVL1::L1TriggerTowerToolRun3::s_saturationValue
static const int s_saturationValue
Parameters.
Definition: L1TriggerTowerToolRun3.h:163
LVL1::L1TriggerTowerToolRun3::bcidParams
virtual void bcidParams(const L1CaloCoolChannelId &channelId, int &energyLow, int &energyHigh, int &decisionSource, std::vector< unsigned int > &decisionConditions, unsigned int &peakFinderStrategy, int &satLow, int &satHigh, int &satLevel) const override
Return BCID parameters for a channel.
Definition: L1TriggerTowerToolRun3.cxx:1068
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LVL1::L1TriggerTowerToolRun3::m_l1CaloTTIdTools
ToolHandle< LVL1::IL1CaloTTIdTools > m_l1CaloTTIdTools
Definition: L1TriggerTowerToolRun3.h:135
merge.output
output
Definition: merge.py:17
LVL1::L1TriggerTowerToolRun3::lut
virtual void lut(const std::vector< int > &fir, int slope, int offset, int cut, int strategy, bool disabled, std::vector< int > &output) const override
LUT simulation: pedestal subtraction, energy calibration and threshold.
Definition: L1TriggerTowerToolRun3.cxx:863
ChanDeadErrorCode.h
L1CaloPprConditionsContainerRun2::pprConditions
const L1CaloPprConditionsRun2 * pprConditions(unsigned int channelId) const
Definition: L1CaloPprConditionsContainerRun2.cxx:496
LVL1::L1TriggerTowerToolRun3::m_dynamicPedestalProvider
ToolHandle< LVL1::IL1DynamicPedestalProvider > m_dynamicPedestalProvider
Definition: L1TriggerTowerToolRun3.h:153
LVL1::L1TriggerTowerToolRun3::firParams
virtual void firParams(const L1CaloCoolChannelId &channelId, std::vector< int > &firCoeffs) const override
Return FIR filter parameters for a channel.
Definition: L1TriggerTowerToolRun3.cxx:1043
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:191
LVL1::L1TriggerTowerToolRun3::applyEtRange
virtual void applyEtRange(const std::vector< int > &lut, const std::vector< int > &range, const L1CaloCoolChannelId &channelId, std::vector< int > &output) const override
Use ET range to return appropriate ET value Do not test BCID here, since no guarantee enough ADC samp...
Definition: L1TriggerTowerToolRun3.cxx:932
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:144
LVL1::L1TriggerTowerToolRun3::m_lvl1Helper
const CaloLVL1_ID * m_lvl1Helper
and tools for computing identifiers
Definition: L1TriggerTowerToolRun3.h:134
IL1CaloMappingTool.h
L1CaloPprConditionsContainerRun2::satOverride2
int satOverride2() const
Definition: L1CaloPprConditionsContainerRun2.h:62
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
L1CaloPpmFineTimeRefs::refValue
double refValue(void) const
Definition: L1CaloPpmFineTimeRefs.h:38
LVL1::L1TriggerTowerToolRun3::m_pprConditionsContainerRun2
SG::ReadCondHandleKey< L1CaloPprConditionsContainerRun2 > m_pprConditionsContainerRun2
Definition: L1TriggerTowerToolRun3.h:142
LVL1::L1TriggerTowerToolRun3::~L1TriggerTowerToolRun3
virtual ~L1TriggerTowerToolRun3()
default destructor
Definition: L1TriggerTowerToolRun3.cxx:61
LVL1::L1TriggerTowerToolRun3::m_correctFir
bool m_correctFir
Baseline correction Tool.
Definition: L1TriggerTowerToolRun3.h:152
Example_ReadSampleNoise.ped
ped
Definition: Example_ReadSampleNoise.py:45
PlotSFuncertainty.calib
calib
Definition: PlotSFuncertainty.py:110
python.PyAthena.v
v
Definition: PyAthena.py:157
L1CaloCoolChannelId
Definition: L1CaloCoolChannelId.h:10
DeMoScan.index
string index
Definition: DeMoScan.py:362
CaloLVL1_ID.h
L1TriggerTowerToolRun3.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloTriggerTowerService.h
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:232
LVL1::L1TriggerTowerToolRun3::channelID
virtual L1CaloCoolChannelId channelID(double eta, double phi, int layer) override
Return Cool channel identifier for given tower coordinates.
Definition: L1TriggerTowerToolRun3.cxx:1267
LVL1::L1TriggerTowerToolRun3::peakBcid
virtual void peakBcid(const std::vector< int > &fir, const L1CaloCoolChannelId &channelId, std::vector< int > &output) const override
Peak finder BCID.
Definition: L1TriggerTowerToolRun3.cxx:496
CaloIdManager.h
ReadHandle.h
Handle class for reading from StoreGate.
AthAlgTool
Definition: AthAlgTool.h:26
CaloLVL1_ID::tower_id
Identifier tower_id(int pos_neg_z, int sampling, int region, int eta, int phi) const
build a tower identifier
Definition: CaloLVL1_ID.h:429
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
L1CaloRunParameters::readoutConfigID
unsigned int readoutConfigID() const
Definition: L1CaloRunParameters.h:29
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
ChanCalibErrorCode.h
LVL1::L1TriggerTowerToolRun3::m_mappingTool
ToolHandle< LVL1::IL1CaloMappingTool > m_mappingTool
and mappings
Definition: L1TriggerTowerToolRun3.h:139
LVL1::L1TriggerTowerToolRun3::jepLut
virtual void jepLut(const std::vector< int > &fir, const L1CaloCoolChannelId &channelId, std::vector< int > &output) const override
Definition: L1TriggerTowerToolRun3.cxx:762
LVL1::L1TriggerTowerToolRun3::m_ppmFineTimeRefsContainer
SG::ReadCondHandleKey< L1CaloPpmFineTimeRefsContainer > m_ppmFineTimeRefsContainer
Definition: L1TriggerTowerToolRun3.h:144
L1CaloPpmFineTimeRefs::errorCode
FineTimeErrorCode errorCode(void) const
Definition: L1CaloPpmFineTimeRefs.h:37
L1CaloPpmFineTimeRefs
Definition: L1CaloPpmFineTimeRefs.h:23
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.
L1CaloPpmFineTimeRefs::calibValue
double calibValue(void) const
Definition: L1CaloPpmFineTimeRefs.h:40