Loading [MathJax]/jax/output/SVG/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Run2TriggerTowerMaker.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ================================================
6 // Run2TriggerTowerMaker class Implementation
7 // ================================================
8 
10 
11 // trigger include(s)
17 
19 
22 
23 // calorimeter include(s)
26 
29 
30 //For getting TriggerTowers from BS
32 
33 // For the Athena-based random numbers.
37 #include "GaudiKernel/IIncidentSvc.h"
38 
39 // AthenaMT
40 #include "StoreGate/ReadHandle.h"
42 #include "GaudiKernel/ThreadLocalContext.h"
43 
44 #include "CLHEP/Random/RandGaussZiggurat.h"
45 #include "CLHEP/Random/Randomize.h"
46 #include "CLHEP/Random/RandomEngine.h"
47 
48 #include <cassert>
49 #include <cmath>
50 #include <fstream>
51 #include <limits> // for std::numeric_limits<std::streamsize>
52 #include <utility> // for std::move
53 #include <stdexcept>
54 #include <sys/types.h>
55 #include <unordered_map>
56 
57 #include <iostream>
58 using std::cout;
59 using std::endl;
60 
61 namespace {
62  template <typename MSG, typename T>
63  void printVec(MSG& msg, const std::vector<T>& v) {
64  for(auto x : v) msg << (int)x << endmsg;
65  }
66 
67  template <typename MSG, typename T, std::size_t N>
68  void printVec(MSG& msg, const std::array<T, N>& v) {
69  for(auto x : v) msg << (int)x << endmsg;
70  }
71 
72  constexpr static int ADCMAX = 1023;
73  constexpr static int SATURATIONVALUE = 255;
74 
75  // keep these local to this compilation unit
76  static const xAOD::TriggerTower::Decorator<int> firDecorator("fir");
77 } // namespace
78 
79 namespace LVL1 {
80 
81  Run2TriggerTowerMaker::Run2TriggerTowerMaker(const std::string& name, ISvcLocator* pSvcLocator)
82  : AthAlgorithm(name, pSvcLocator),
83  m_rngSvc("AthRNGSvc", name),
84  m_rndmADCs(0),
85  m_mappingTool("LVL1::PpmMappingTool/PpmMappingTool", this),
86  m_bstowertool("LVL1BS__TrigT1CaloDataAccessV2/TrigT1CaloDataAccessV2", this),
87  m_caloId(0),
88  m_cpLutScale(1.),
89  m_jepLutScale(1.),
90  m_TileToMeV(s_MEV/4.1), // Scale for converting ET -> counts
91  m_TileTTL1Ped(0.), // TileTTL1 pedestal value - need to subtract if set non-zero
92  m_isDataReprocessing(false),
93  m_doOverlay(false), m_isReco(false)
94  {
95  declareProperty("xAODEventInfoKey", m_xaodevtKey=std::string{"EventInfo"});
96  declareProperty("RngSvc", m_rngSvc, "Random number service");
97  declareProperty("DigiEngine", m_digiEngine = "TrigT1CaloSim_Digitization");
98 
99  declareProperty("L1TriggerTowerTool", m_TTtool);
100  declareProperty("PpmMappingTool", m_mappingTool);
101 
103  declareProperty("EmTTL1ContainerName",m_EmTTL1ContainerName= "LArTTL1EM");
104  declareProperty("HadTTL1ContainerName",m_HadTTL1ContainerName= "LArTTL1HAD");
105  declareProperty("TileTTL1ContainerName",m_TileTTL1ContainerName= "TileTTL1Cnt");
106  declareProperty("RequireAllCalos",m_requireAllCalos=true,"Should EM,Had and Tile all be available?");
107 
110  declareProperty("CellType", m_cellType = TTL1);
111 
112  // ADC simulation
113  declareProperty("ADCStep", m_adcStep=250.);
114  declareProperty("ADCNoise", m_adcVar=0.65);
115  declareProperty("CalibrationUncertainty", m_gainCorr=0.);
116 
117  declareProperty("DoOverlay",m_doOverlay = false);
118  declareProperty("IsReco",m_isReco = false);
119 
120  declareProperty("DecorateFIR", m_decorateFIR = false, "Add FIR values to the xAOD::TriggerTowers");
121 
122  declareProperty("ZeroSuppress", m_ZeroSuppress = true, "Do not save towers with 0 energy");
123 
124  declareProperty("ChanCalibFolderKeyoverlay",m_chanCalibKeyoverlay = "/TRIGGER/L1Calo/V2overlay/Calibration/Physics/PprChanCalib","PprChanCalib key for overlay");
125  declareProperty("ChanDefaultsFolderKeyoverlay",m_chanDefaultsKeyoverlay = "/TRIGGER/L1Calo/V2overlay/Configuration/PprChanDefaults","PprChanDefaults key for overlay");
126  declareProperty("DisabledTowersFolderKeyoverlay",m_disabledTowersKeyoverlay = "/TRIGGER/L1Calo/V2overlay/Conditions/DisabledTowers","DisabledTowers key for overlay");
127  declareProperty("DeadChannelsFolderKeyoverlay",m_deadChannelsKeyoverlay = "/TRIGGER/L1Calo/V2overlay/Calibration/PpmDeadChannels","PpmDeadChannels key for overlay");
128 
129  // Create hash table for E->ET conversions
130  /* Fill table with dummy values */
131  m_sinThetaHash.fill(-1.);
132 
133  /* set values for barrel region with granularity of 0.1*/
134  for(unsigned int i = 0; i < 25; i++) {
135  m_sinThetaHash[i] = 1.0/cosh((i+0.5)* 0.1);
136  }
137 
138  /* set values for EndCap with granularity of 0.2 except tt by |3.2|
139  eta values are are: 2.6, 2.8, 3.0, 3.15 */
140  m_sinThetaHash[26] = 1.0/cosh(2.6);
141  m_sinThetaHash[28] = 1.0/cosh(2.8);
142  m_sinThetaHash[30] = 1.0/cosh(3.0);
143  m_sinThetaHash[31] = 1.0/cosh(3.15);
144 
145  /* fcal granularity is 0.425 */
146  m_sinThetaHash[ (unsigned int)(32 + (0.5*0.425)*10.) ] = 1.0/cosh(3.2 + 0.5*0.425);
147  m_sinThetaHash[ (unsigned int)(32 + (1.5*0.425)*10.) ] = 1.0/cosh(3.2 + 1.5*0.425);
148  m_sinThetaHash[ (unsigned int)(32 + (2.5*0.425)*10.) ] = 1.0/cosh(3.2 + 2.5*0.425);
149  m_sinThetaHash[ (unsigned int)(32 + (3.5*0.425)*10.) ] = 1.0/cosh(3.2 + 3.5*0.425);
150  }
151 
153 
155  {
156  ATH_MSG_DEBUG("Initialising");
157 
159  ATH_CHECK(m_mappingTool.retrieve());
160  ATH_CHECK(m_TTtool.retrieve());
161  ATH_CHECK(m_rngSvc.retrieve());
162  ATH_CHECK(m_bstowertool.retrieve());
163 
164  m_rndmADCs = m_rngSvc->getEngine(this, m_digiEngine);
165  if(!m_rndmADCs) {
166  ATH_MSG_ERROR("Failed to retrieve random engine");
167  return StatusCode::FAILURE;
168  }
169 
170  // Listen for BeginRun
171  ServiceHandle<IIncidentSvc> incSvc("IncidentSvc",name());
172  ATH_CHECK(incSvc.retrieve());
173  incSvc->addListener(this, "BeginRun");
174 
175  // reserve enough storage for the amps
176  m_xaodTowersAmps.assign(7168, std::vector<double>());
177 
179  ATH_CHECK(m_actMuKey.initialize());
180 
181  ATH_CHECK(m_inputTTLocation.initialize());
182 
185  ATH_CHECK(m_TileTTL1ContainerName.initialize());
186  ATH_CHECK(m_outputLocation.initialize());
187 
188  ATH_CHECK(m_outputLocationRerun.initialize());
189 
190  //Rerun on trigger towers
191  if (m_cellType == TRIGGERTOWERS) {
196  }
197  //Start from RDO inputs
198  else if (m_cellType == TTL1) {
201  }
202 
208 
209  return StatusCode::SUCCESS;
210  }
211 
214  void Run2TriggerTowerMaker::handle(const Incident& inc)
215  {
216  if(inc.type() != "BeginRun") return;
218 
219  auto l1Menu = SG::makeHandle( m_L1MenuKey );
220  m_cpLutScale = l1Menu->thrExtraInfo().EM().emScale();
221  m_jepLutScale = l1Menu->thrExtraInfo().JET().jetScale();
222 
223  ATH_MSG_INFO("REGTEST CP scale = " << m_cpLutScale << " count/GeV");
224  ATH_MSG_INFO("REGTEST JEP scale = " << m_jepLutScale << " count/GeV");
225 
228 
229 
230 
231 
232  if (m_doOverlay) {
233 
234  throw std::runtime_error("Overlay no longer supported in Run2TriggerTowerMaker");
235 
236  // Leaving this code commented here as a reminder of what functionality might need to be added to L1CaloCondAlg
237  // if we want to restart supporting overlay
238 
239 // if (! m_condSvc->retrieve(m_chanCalibContaineroverlay, m_chanCalibKeyoverlay).isSuccess()){ATH_MSG_ERROR("failed!");}
240 // ATH_MSG_INFO("Loading "<<m_chanCalibKeyoverlay<<" into m_chanCalibContaineroverlay");
241 // if (! m_condSvc->retrieve(m_disabledTowersContaineroverlay, m_disabledTowersKeyoverlay).isSuccess()){ATH_MSG_ERROR("failed!");}
242 // if (! m_condSvc->retrieve(m_deadChannelsContaineroverlay, m_deadChannelsKeyoverlay).isSuccess()){ATH_MSG_ERROR("failed!");}
243 // L1CaloPprChanDefaultsContainer *cDCoverlay = nullptr;
244 // if (! m_condSvc->retrieve(cDCoverlay, m_chanDefaultsKeyoverlay).isSuccess()){ATH_MSG_ERROR("failed!");}
245 // if(!m_chanCalibContaineroverlay || !cDCoverlay ||
246 // !m_disabledTowersContaineroverlay || !m_deadChannelsContaineroverlay) {
247 // ATH_MSG_ERROR("Could not retrieve database containers for overlay. Aborting ...");
248 // throw std::runtime_error("Run2TriggerTowerMaker: database container for overlay not accesible");
249 // }
250 //
251 // auto* defaultsoverlay = cDCoverlay->pprChanDefaults(0); // non-owning ptr
252 // if(!defaultsoverlay) {
253 // ATH_MSG_ERROR("Could not retrieve channel 0 PprChanDefaults folder for overlay. Aborting ...");
254 // throw std::runtime_error("Run2TriggerTowerMaker: channel 0 of PprChanDefaults for overlay not accesible");
255 // }
256 // m_chanDefaultsoverlay = *defaultsoverlay;
257 
258  }
259 
260  const TileInfo* tileInfo = nullptr;
261  if(detStore()->retrieve(tileInfo, "TileInfo").isFailure()) {
262  ATH_MSG_ERROR("Failed to find TileInfo");
263  m_TileToMeV = s_MEV/4.1;
264  }
265 
266  m_TileToMeV = s_MEV/tileInfo->TTL1Calib({});
267  ATH_MSG_DEBUG("Tile TTL1 calibration scale = " << tileInfo->TTL1Calib({}));
268  m_TileTTL1Ped = tileInfo->TTL1Ped({});
269  ATH_MSG_DEBUG("Tile TTL1 pedestal value = " << m_TileTTL1Ped);
270 
271  // try to determine wheter we run on data or on simulation
272  const xAOD::EventInfo* evtinfo{nullptr};
273  if(evtStore()->retrieve(evtinfo)!=StatusCode::SUCCESS) {
274  ATH_MSG_WARNING("Could not determine if input file is data or simulation. Will assume simulation.");
275  }
276  else {
277  bool isData = !(evtinfo->eventTypeBitmask()&xAOD::EventInfo::IS_SIMULATION);
278  m_isDataReprocessing = isData;
280  ATH_MSG_INFO("Detected data reprocessing. Will take pedestal correction values from input trigger towers.");
281  } else {
282  ATH_MSG_VERBOSE("No data reprocessing - running normal simulation.");
283  }
284  }
285 
286  // If this is an overlay job, we will handle this in a different way
287  if (m_doOverlay) {
288  m_isDataReprocessing = false;
289  ATH_MSG_INFO("L1Calo overlay job - setting m_isDataReprocessing to false");
290  }
291 
292 
293  }
294 
296  ATH_MSG_DEBUG("Finalizing");
297  return StatusCode::SUCCESS;
298  }
299 
304  ATH_MSG_VERBOSE("Executing");
305 
306  if (m_isReco && m_doOverlay) return StatusCode::SUCCESS; // nothing to to, since we did overlay and made towers during digi
307 
308 
309  // retrieve conditions
311  CHECK(pprCalibCont.isValid());
312  m_chanCalibContainer = (*pprCalibCont);
314  CHECK(pprDisabledTowers.isValid());
315  m_disabledTowersContainer = (*pprDisabledTowers);
317  CHECK(pprDeadTowers.isValid());
318  m_deadChannelsContainer = (*pprDeadTowers);
320  CHECK(pprChanDefaults.isValid());
321  auto* defaults = pprChanDefaults->pprChanDefaults(0); // non-owning ptr
322  if(!defaults) {
323  ATH_MSG_ERROR("Could not retrieve channel 0 PprChanDefaults folder. Aborting ...");
324  throw std::runtime_error("Run2TriggerTowerMaker: channel 0 of PprChanDefaults not accesible");
325  }
327 
328  const EventContext& ctx = Gaudi::Hive::currentContext();
330 
333  m_xaodTowers->setStore(m_xaodTowersAux.get());
334  m_xaodTowers->resize(7168); // avoid frequent reallocations
335  m_curIndex = 0u;
336 
337  switch(m_cellType) {
338  case TRIGGERTOWERS:
339  ATH_MSG_VERBOSE("Looking for TriggerTower input");
341  break;
342  case TTL1:
343  ATH_MSG_VERBOSE("Looking for calo towers");
345  digitize(ctx); // digitisation
346  break;
347  default:
348  ATH_MSG_ERROR("Unsupported Cell Type!!!!!!"); return StatusCode::FAILURE;
349  }
350 
353  ATH_CHECK(evt.isValid());
354  ATH_CHECK(muDecor.isPresent());
355  const float mu = muDecor(0);
356 
357  ATH_CHECK(preProcess(evt->bcid(), mu)); // FIR, BCID etc
358 
359  if (m_doOverlay) {
360  ATH_CHECK( addOverlay(evt->bcid(), mu) );
361  }
362 
363  // store them thar trigger towers
364  ATH_CHECK(store());
365 
366  return StatusCode::SUCCESS;
367  }
368 
371  {
372  if (!db) return false; // No DB entry - assume that this is not a dead channel
373  if (db->errorCode() > 0 || db->noiseCut() > 0) return true; // We do not want these
374  return false;
375  }
376 
378  {
379  if (!db) return false; // No DB entry - assume that this is not a disabled channel
380  if (db->disabledBits() > 0) return true; // We do not want these
381  return false;
382  }
383 
385  {
386  bool isDead = IsDeadChannel(dead->ppmDeadChannels(tt->coolId()));
387  bool isDisabled = IsDisabledChannel(disabled->disabledTowers(tt->coolId()));
388  if (!isDead && !isDisabled) return true;
389  return false;
390  }
391 
393  {
394  // Get the overlay data TTs from Bytestream
396  xAOD::TriggerTowerAuxContainer overlayDataTTsAux;
397  overlayDataTTs->setStore( &overlayDataTTsAux );
398  ATH_CHECK( m_bstowertool->loadTriggerTowers(*overlayDataTTs) ); // use L1Calo tool to fill xAOD::TriggerTowerContainer from BS
399 
400  // put the overlay data TTs into a map
401  std::unordered_map<uint32_t,xAOD::TriggerTower*> overlayMap;
403 
404  // decorate the overlay TTs to indicate if they have been used or not
405  char decor_ttNotUsedInOverlay = 0;
406  char decor_ttUsedInOverlay = 1;
407  static const SG::Decorator<char> decor ("addedToSignal");
408  for (auto tt:*overlayDataTTs) {
409  // Let's exclude all dead and disabled towers
411  decor(*tt) = decor_ttNotUsedInOverlay;
412  overlayMap.insert( std::make_pair( tt->coolId() , tt ) );
413  }
414  }
415 
416  // What is the size of the primary LUT readout?
417  bool findSizeOfPrimaryLUT(true);
418  unsigned int sizeOfPrimaryLUT(0);
419  uint8_t peakOfPrimary(0);
420 
421  // Loop over primary TTs, match overlay TTs, and add LUT values
422  for (auto tt:*m_xaodTowers) {
423 
424  // find size of primary LUT readout for first TT
425  if (findSizeOfPrimaryLUT) {
426  findSizeOfPrimaryLUT = false;
427  sizeOfPrimaryLUT = tt->lut_cp().size();
428  peakOfPrimary = tt->peak();
429  }
430 
431  // Do we have a matching overlay tower?
432  Itr match = overlayMap.find( tt->coolId() );
433  if (match != overlayMap.end()) {
434 
435  ATH_CHECK( addOverlay(bcid,mu,tt,(*match).second) );
436 
437  // Let the overlay TT know that it has been used
438  decor(*match->second) = decor_ttUsedInOverlay;
439 
440  } // end of match
441  } // end of loop over primary TTs
442 
443  // Now we need to add all overlay TTs that have not been used so far
444  for (Itr i=overlayMap.begin();i!=overlayMap.end();++i) {
445  xAOD::TriggerTower* tt = (*i).second;
446  if (decor(*tt) == decor_ttNotUsedInOverlay) {
447  // Ensure that LUT vectors are the same size as the primary TTs
448  std::vector<uint8_t> overlay_lut_cp(sizeOfPrimaryLUT,0.);
449  std::vector<uint8_t> overlay_lut_jep(sizeOfPrimaryLUT,0.);
450 
451  // Fill the LUT vectors
452  overlay_lut_cp.at(peakOfPrimary) = tt->cpET();
453  overlay_lut_jep.at(peakOfPrimary) = tt->jepET();
454 
455  // Set the LUT vectors and peak
456  tt->setPeak( peakOfPrimary );
457  tt->setLut_cp( overlay_lut_cp );
458  tt->setLut_jep( overlay_lut_jep );
459 
460  // add the overlay TT to the primary TT
461  m_xaodTowers->push_back( tt );
462  }
463  }
464 
465  // Should be done!!!
466  return StatusCode::SUCCESS;
467  }
468 
471  {
472  // Get the relevant databases
475 
476  if (!sigDB) {
477  ATH_MSG_ERROR("Cannot find signal DB for tower 0x"<<std::hex<<sigTT->coolId()<<std::dec<<" Aborting...");
478  return StatusCode::FAILURE;
479  }
480 
481  if (!ovDB) {
482  ATH_MSG_ERROR("Cannot find overlay DB for tower 0x"<<std::hex<<ovTT->coolId()<<std::dec<<" Aborting...");
483  return StatusCode::FAILURE;
484  }
485 
486  // Let's begin with the same number of ADC samples
487  // retrieve signal and overlay digits
488  std::vector<int> sigDigits( std::begin(sigTT->adc()) , std::end(sigTT->adc()) );
489  std::vector<int> ovDigits( std::begin(ovTT->adc()) , std::end(ovTT->adc()) );
490  std::vector<int> normOverlayDigits;
491  normaliseDigits(sigDigits,ovDigits,normOverlayDigits);
492 
493  // Get LUT input
494  std::vector<int> sigLutIn,ovLutIn;
495  ATH_CHECK( preProcessTower_getLutIn(bcid,mu,sigTT,sigDB,sigDigits,sigLutIn) );
496  ATH_CHECK( preProcessTower_getLutIn(bcid,mu,ovTT,ovDB,normOverlayDigits,ovLutIn) );
497 
498  // LUT ouput
499  std::vector<int> lutOut_cp,lutOut_jep;
500  ATH_CHECK( calcLutOutCP(sigLutIn,sigDB,ovLutIn,ovDB,lutOut_cp) );
501  ATH_CHECK( calcLutOutJEP(sigLutIn,sigDB,ovLutIn,ovDB,lutOut_jep) );
502 
503  // Not doing BCID yet.. can be added at a later date
504 
505  std::size_t peak = lutOut_jep.size()/2; // both cp & jep have the same length
506  std::vector<uint_least8_t> etResultVectorCp { uint8_t(lutOut_cp[peak]) };
507  std::vector<uint_least8_t> etResultVectorJep { uint8_t(lutOut_jep[peak]) };
508 
509  sigTT->setLut_cp(std::move(etResultVectorCp));
510  sigTT->setLut_jep(std::move(etResultVectorJep));
511 
512  return StatusCode::SUCCESS;
513  }
514 
515  StatusCode Run2TriggerTowerMaker::calcLutOutCP(const std::vector<int>& sigLutIn,const L1CaloPprChanCalib* sigDB,const std::vector<int>& ovLutIn,const L1CaloPprChanCalib* ovDB,std::vector<int>& output)
516  {
517  if (sigDB->lutCpStrategy() > 2 || ovDB->lutCpStrategy() > 2) {
518  ATH_MSG_ERROR("Cannot process calcLutOutCP as lutCpStrategy > 2");
519  return StatusCode::FAILURE;
520  }
521 
522  double sigScale = (sigDB->lutCpStrategy() == 0) ? 1. : m_cpLutScale;
523  double sigSlope = sigScale * sigDB->lutCpSlope();
524  double sigOffset = sigScale * sigDB->lutCpOffset();
525 
526  double ovScale = (ovDB->lutCpStrategy() == 0) ? 1. : m_cpLutScale;
527  double ovSlope = ovScale * ovDB->lutCpSlope();
528  double ovOffset = ovScale * ovDB->lutCpOffset();
529  double ovNoiseCut = ovScale * ovDB->lutCpNoiseCut();
530 
531  calcCombinedLUT(sigLutIn,sigSlope,sigOffset,ovLutIn,ovSlope,ovOffset,ovNoiseCut,output);
532 
533  return StatusCode::SUCCESS;
534  }
535 
536  StatusCode Run2TriggerTowerMaker::calcLutOutJEP(const std::vector<int>& sigLutIn,const L1CaloPprChanCalib* sigDB,const std::vector<int>& ovLutIn,const L1CaloPprChanCalib* ovDB,std::vector<int>& output)
537  {
538  if (sigDB->lutJepStrategy() > 2 || ovDB->lutJepStrategy() > 2) {
539  ATH_MSG_ERROR("Cannot process calcLutOutJEP as lutJepStrategy > 2");
540  return StatusCode::FAILURE;
541  }
542 
543  double sigScale = (sigDB->lutJepStrategy() == 0) ? 1. : m_jepLutScale;
544  double sigSlope = sigScale * sigDB->lutJepSlope();
545  double sigOffset = sigScale * sigDB->lutJepOffset();
546 
547  double ovScale = (ovDB->lutCpStrategy() == 0) ? 1. : m_jepLutScale;
548  double ovSlope = ovScale * ovDB->lutJepSlope();
549  double ovOffset = ovScale * ovDB->lutJepOffset();
550  double ovNoiseCut = ovScale * ovDB->lutJepNoiseCut();
551 
552  calcCombinedLUT(sigLutIn,sigSlope,sigOffset,ovLutIn,ovSlope,ovOffset,ovNoiseCut,output);
553 
554  return StatusCode::SUCCESS;
555  }
556 
557  void Run2TriggerTowerMaker::calcCombinedLUT(const std::vector<int>& sigIN,const int sigSlope,const int sigOffset,
558  const std::vector<int>& ovIN,const int ovSlope,const int ovOffset,const int ovNoiseCut,std::vector<int>& output)
559  {
560  // Modified version of TrigT1CaloTools/src/L1TriggerTowerTool
561 
562  // (1) Calculate the Et conversion for the signal and the overlay
563  // (2) Combine the Et's
564  // (3) apply noise cut on combined Et sum
565  // (4) apply bitshift
566 
567  output.clear();
568  output.reserve(sigIN.size()); // avoid frequent reallocations
569 
570  for (unsigned int i=0;i<sigIN.size();++i) {
571  int out(0);
572  int signal = sigIN[i];
573  int overlay = ovIN[i];
574 
575  int outSig = signal*sigSlope - sigOffset; // Et conversion for signal
576  int outOv = overlay*ovSlope - ovOffset; // Et conversion for overlay
577  int outTmp = outSig + outOv; // Combined Et
578 
579  // Noise cut from overlay
580  if (outTmp >= ovNoiseCut) {
581  out = (outSig + outOv + 2048)>>12; // pedestal and bitshift
582  }
583 
584  // keep things in range
585  if (out < 0) out = 0;
586  if (out > 255) out = 255;
587 
588  output.push_back( out );
589  }
590  }
591 
592  StatusCode Run2TriggerTowerMaker::preProcessTower_getLutIn(int bcid,float mu,xAOD::TriggerTower* tower,const L1CaloPprChanCalib* db,const std::vector<int>& digits,std::vector<int>& output)
593  {
594  // factorised version of Run2TriggerTowerMaker::preProcessTower
595 
596  // process tower -- digital filter
597  std::vector<int> fir;
598  m_TTtool->fir(digits,
599  {db->firCoeff5(),db->firCoeff4(),db->firCoeff3(),db->firCoeff2(),db->firCoeff1()}, // reverse order in database
600  fir);
601 
602  // pedestal correction
603  int pedCorrectionStrategy = db->lutCpStrategy();
604  std::vector<int16_t> correction;
605 
606  // 1.) simulation and pedestal correction enabled
607  if (pedCorrectionStrategy == 1) {
608 // cout<<"Using Simulation pedCorrectionStrategy"<<endl;
609  // case 1.) (database "abuses" pedFirSum to steer pedestal correction)
610  // apply the parameterized pedestal correction
611  int firPed = (db->firCoeff5() + db->firCoeff4() + db->firCoeff3() +
612  db->firCoeff2() + db->firCoeff1()) * int(db->pedMean() + 0.5);
613  m_TTtool->pedestalCorrection(fir,
614  firPed,
615  etaToElement(tower->eta(), tower->layer()),
616  tower->layer(),
617  bcid,
618  mu,
619  correction);
620  }
621 
622  // 2.) data reprocessing and pedestal correction enabled
623  if (pedCorrectionStrategy == 2) {
624 // cout<<"Using data pedCorrectionStrategy"<<endl;
625  // case 2.) (database "abuses" pedFirSum to steer pedestal correction)
626  // apply the recorded pedestal correction
627  if(!tower->correctionEnabled().empty() && tower->correctionEnabled().front()) {
628  std::size_t offset = (fir.size() - tower->correction().size())/2;
629 
630  for(std::size_t i = offset, e = fir.size() - offset; i != e; ++i) {
631  correction.push_back(tower->correction()[i-offset]);
632  fir[i] -= tower->correction()[i-offset];
633  }
634  }
635  }
636 
637  m_TTtool->dropBits(fir, db->firStartBit(), output);
638 
639  return StatusCode::SUCCESS;
640  }
641 
642  void Run2TriggerTowerMaker::normaliseDigits(const std::vector<int>& sigDigits,const std::vector<int>& ovDigits,std::vector<int>& normDigits)
643  {
644 
645  // 3 possible cases:
646  // Case 1.) Signal MC and overlay data have same number of digits - easy peasy lemon squeezy
647  // Case 2.) Signal MC is larger - pad the overlay digits
648  // Case 3.) Signal MC is smaller - crop the overlay digits
649 
650  // Case 1.)
651  if (sigDigits.size() == ovDigits.size()) {
652  for (auto x:ovDigits) normDigits.push_back( x );
653  }
654 
655  // Case 2.)
656  if (sigDigits.size() > ovDigits.size()) {
657  unsigned int pad = (sigDigits.size() - ovDigits.size()) / 2;
658  for (unsigned int x=0;x<pad;++x) normDigits.push_back( 32 );
659  for (auto x:ovDigits) normDigits.push_back( x );
660  for (unsigned int x=0;x<pad;++x) normDigits.push_back( 32 );
661  }
662 
663 
664  // Case 3.)
665  if (sigDigits.size() < ovDigits.size()) {
666  unsigned int offset = (ovDigits.size() - sigDigits.size()) / 2;
667  for (unsigned int x=0;x<sigDigits.size();++x) {
668  unsigned int pos = x + offset;
669  normDigits.push_back( ovDigits[pos] );
670  }
671  }
672 
673  }
674 
675 
679  {
680  // Loop over all existing towers and simulate preprocessor functions
681  for(auto tower : *m_xaodTowers) {
683  }
684  return StatusCode::SUCCESS;
685  }
686 
688  {
689 
690  const L1CaloPprChanCalib* chanCalib = m_chanCalibContainer->pprChanCalib(tower->coolId());
691 
692  if (!chanCalib) {
693  ATH_MSG_ERROR("Tower with coolId 0x"<<std::hex<<tower->coolId()<<std::dec<<" Not in database! Aborting ...");
694  return StatusCode::FAILURE;
695  }
696 
697  // pedestal correction
698  int pedCorrectionStrategy(0);
699  // Regular job - no overlay
700  if (!m_doOverlay) {
701  if (chanCalib->pedFirSum() && !m_isDataReprocessing) pedCorrectionStrategy = 1; // simulation
702  if (chanCalib->pedFirSum() && m_isDataReprocessing) pedCorrectionStrategy = 2; // data reprocessing
703  }
704  if (m_doOverlay) {
705  pedCorrectionStrategy = chanCalib->lutCpStrategy();
706  }
707 
709  std::vector<int> digits(std::begin(tower->adc()), std::end(tower->adc()));
710 
712  std::vector<int> fir;
713  m_TTtool->fir(digits,
714  { chanCalib->firCoeff5(), chanCalib->firCoeff4(), chanCalib->firCoeff3(),
715  chanCalib->firCoeff2(), chanCalib->firCoeff1() }, // reverse order in database
716  fir);
717 
719  std::vector<int16_t> correction;
720  // a few cases follow
721  // 1.) simulation and pedestal correction enabled
722  // 2.) data reprocessing and pedestal correction enabled
723  // 3.) pedestal correction disabled
724 
725  // old method - now deprecated
726 // if(chanCalib->pedFirSum() && !m_isDataReprocessing) {
727 
728  // new method
729  if (pedCorrectionStrategy == 1) {
730  // case 1.) (database "abuses" pedFirSum to steer pedestal correction)
731  // apply the parameterized pedestal correction
732  int firPed = (chanCalib->firCoeff5() + chanCalib->firCoeff4() + chanCalib->firCoeff3() +
733  chanCalib->firCoeff2() + chanCalib->firCoeff1()) * int(chanCalib->pedMean() + 0.5);
734  m_TTtool->pedestalCorrection(fir,
735  firPed,
736  etaToElement(tower->eta(), tower->layer()),
737  tower->layer(),
738  bcid,
739  mu,
740  correction);
741  }
742 
743  // old method - now deprecated
744  //else if(chanCalib->pedFirSum() && m_isDataReprocessing) {
745  if (pedCorrectionStrategy == 2) {
746 
747  // case 2.) (database "abuses" pedFirSum to steer pedestal correction)
748  // apply the recorded pedestal correction
749  if(!tower->correctionEnabled().empty() && tower->correctionEnabled().front()) {
750  std::size_t offset = (fir.size() - tower->correction().size())/2;
751 
752  for(std::size_t i = offset, e = fir.size() - offset; i != e; ++i) {
753  correction.push_back(tower->correction()[i-offset]);
754  fir[i] -= tower->correction()[i-offset];
755  }
756  ATH_MSG_VERBOSE("::correction: (from data");
757  printVec(this->msg(MSG::VERBOSE), correction);
758  } // in case the correction wasn't enabled in the readout nothing has to be done
759  }
760 
761  // Case 3.) not yet implemented (will it ever be....??)
762 
763  std::vector<int> lutIn;
764  m_TTtool->dropBits(fir, chanCalib->firStartBit(), lutIn);
765 
766  // linear LUTs - CP
767  std::vector<int> lutOut_cp;
768  ATH_MSG_VERBOSE("::cp-lut: strategy: " << chanCalib->lutCpStrategy());
769  if(chanCalib->lutCpStrategy() < 3) {
770  // for new strategy lutSlope, lutOffset and lutNoiseCut are in units of LUTOut
771  // and need to be multiplied by the scale factor
772  double scale = (chanCalib->lutCpStrategy() == 0) ? 1. : m_cpLutScale;
773 
774  m_TTtool->lut(lutIn,
775  scale * chanCalib->lutCpSlope(),
776  scale * chanCalib->lutCpOffset(),
777  scale * chanCalib->lutCpNoiseCut(),
778  32 /* unused */,
779  chanCalib->lutCpStrategy() > 0,
780  false, // TODO - disabled?
781  lutOut_cp);
782  } else if(chanCalib->lutCpStrategy() == 3) {
783  for(auto l : lutIn) lutOut_cp.push_back(non_linear_lut(l, chanCalib->lutCpOffset(), chanCalib->lutCpSlope(), chanCalib->lutCpNoiseCut(), chanCalib->lutCpScale(), chanCalib->lutCpPar1(), chanCalib->lutCpPar2(), chanCalib->lutCpPar3(), chanCalib->lutCpPar4()));
784  }
785  ATH_MSG_VERBOSE("::cp-lut: lut:");
786  printVec(this->msg(MSG::VERBOSE), lutOut_cp);
787 
788 
789  // linear LUTs - JEP
790  std::vector<int> lutOut_jep;
791  ATH_MSG_VERBOSE("::jep-lut: strategy: " << chanCalib->lutJepStrategy());
792  if(chanCalib->lutJepStrategy() < 3) {
793  // for new strategy lutSlope, lutOffset and lutNoiseCut are in units of LUTOut
794  // and need to be multiplied by the scale factor
795  double scale = (chanCalib->lutJepStrategy() == 0) ? 1. : m_jepLutScale;
796 
797  m_TTtool->lut(lutIn,
798  scale * chanCalib->lutJepSlope(),
799  scale * chanCalib->lutJepOffset(),
800  scale * chanCalib->lutJepNoiseCut(),
801  32 /* unused */,
802  chanCalib->lutJepStrategy() > 0,
803  false, // TODO - disabled?
804  lutOut_jep);
805  } else if(chanCalib->lutJepStrategy() == 3) {
806  for(auto l : lutIn) lutOut_jep.push_back(non_linear_lut(l, chanCalib->lutJepOffset(), chanCalib->lutJepSlope(), chanCalib->lutJepNoiseCut(), chanCalib->lutJepScale(), chanCalib->lutJepPar1(), chanCalib->lutJepPar2(), chanCalib->lutJepPar3(), chanCalib->lutJepPar4()));
807  }
808  ATH_MSG_VERBOSE("::jep-lut: lut:");
809  printVec(this->msg(MSG::VERBOSE), lutOut_jep);
810 
811 
813  std::vector<int> BCIDOut;
814  if(!m_isDataReprocessing || tower->adc().size() >= 7) {
815  m_TTtool->bcid(fir, digits,
817  chanCalib->satBcidThreshLow(),
818  chanCalib->satBcidThreshHigh(),
819  chanCalib->satBcidLevel(),
820  BCIDOut);
821  } else {
822  // in data reprocessing with less than 7 slices take decision from data
823  BCIDOut.assign(tower->bcidVec().begin(), tower->bcidVec().end());
824  ATH_MSG_VERBOSE("::bcidOut: (from data):");
825  printVec(this->msg(MSG::VERBOSE), BCIDOut);
826  }
827 
828  std::size_t peak = lutOut_jep.size()/2; // both cp & jep have the same length
829  std::vector<uint_least8_t> etResultVectorCp { uint8_t(lutOut_cp[peak]) };
830  ATH_MSG_VERBOSE("::etResultVector: cp:");
831  printVec(this->msg(MSG::VERBOSE), etResultVectorCp);
832  std::vector<uint_least8_t> etResultVectorJep { uint8_t(lutOut_jep[peak]) };
833  ATH_MSG_VERBOSE("::etResultVector: jep:");
834  printVec(this->msg(MSG::VERBOSE), etResultVectorJep);
835 
836  // identify BCID range
837  int range;
838  if(!(m_chanDefaults.decisionSource() & 0x1)) {
839  range = EtRange(digits[digits.size()/2], chanCalib->bcidEnergyRangeLow(), chanCalib->bcidEnergyRangeHigh());
840  } else {
841  range = EtRange(fir[fir.size()/2], chanCalib->bcidEnergyRangeLow(), chanCalib->bcidEnergyRangeHigh());
842  }
843  ATH_MSG_VERBOSE("::range: " << range);
844 
845  // correct BCID for this range?
846  std::array<int, 3> bcidDecision {
848  };
849  ATH_MSG_VERBOSE("::bcidDecision:");
850  printVec(this->msg(MSG::VERBOSE), bcidDecision);
851 
852  std::array<int, 3> satOverride {
854  };
855  ATH_MSG_VERBOSE("::satOverride:");
856  printVec(this->msg(MSG::VERBOSE), satOverride);
857 
858  if((bcidDecision[range]) & (0x1 << (BCIDOut[BCIDOut.size()/2]))) {
859  if((satOverride[range]) & 0x1) {
860  // return saturation if set
861  etResultVectorCp[0] = SATURATIONVALUE;
862  etResultVectorJep[0] = SATURATIONVALUE;
863  }
864  } else {
865  // zero if fail BCID
866  etResultVectorCp[0] = 0;
867  etResultVectorJep[0] = 0;
868  }
869 
870  // Overlay protection
871  if (m_inputTTLocation.key() == "NoneForOverlay") return StatusCode::SUCCESS;
872 
873  tower->setLut_cp(std::move(etResultVectorCp));
874  tower->setLut_jep(std::move(etResultVectorJep));
875  tower->setBcidVec({uint8_t(BCIDOut[BCIDOut.size()/2])});
876  ATH_MSG_VERBOSE("::set bcidVec:");
877  printVec(this->msg(MSG::VERBOSE), tower->bcidVec());
878  tower->setPeak(0u); // we only added one item to etResultVector
879  if(m_decorateFIR) firDecorator(*tower) = fir[fir.size()/2];
880 
883  tower->setBcidExt(std::vector<uint8_t>(tower->adc().size(), 0u));
884 
885  // fill the pedestal correction
886  if(chanCalib->pedFirSum()) {
887  // online database abuses pedFirSum to steer pedestal correction
888  tower->setCorrectionEnabled(std::vector<uint8_t>(tower->lut_cp().size(), 1u));
889  tower->setCorrection(std::vector<int16_t>(tower->lut_cp().size(),
890  correction[correction.size()/2]));
891  ATH_MSG_VERBOSE("::set correction:");
892  printVec(this->msg(MSG::VERBOSE), tower->correction());
893  } else {
894  tower->setCorrectionEnabled(std::vector<uint8_t>(tower->lut_cp().size(), 0u));
895  tower->setCorrection(std::vector<int16_t>(tower->lut_cp().size(), 0u));
896  }
897  return StatusCode::SUCCESS;
898  }
899 
906  {
907  ATH_MSG_DEBUG("Storing TTs in DataVector");
908  if(m_ZeroSuppress) {
909  // remove trigger towers whose energy is 0
910  m_xaodTowers->erase(std::remove_if(m_xaodTowers->begin(), m_xaodTowers->end(),
911  [](const xAOD::TriggerTower* tt){
912  return tt->cpET() == 0 && tt->jepET() == 0;
913  }),
914  m_xaodTowers->end());
915  }
916 
917 
918 
919  if (m_cellType == TRIGGERTOWERS) {
921  ATH_CHECK(output.record(std::move(m_xaodTowers), std::move(m_xaodTowersAux)));
922  }
923  else if (m_cellType == TTL1) {
925  ATH_CHECK(output.record(std::move(m_xaodTowers), std::move(m_xaodTowersAux)));
926  }
927 
928  return StatusCode::SUCCESS;
929  } // end of LVL1::Run2TriggerTowerMaker::store(){
930 
931 
935  {
936  ATH_MSG_INFO("Retrieve input TriggerTowers " << m_inputTTLocation.key());
938  ATH_CHECK(inputTTs.isValid());
939  ATH_MSG_INFO("Found " << inputTTs->size() << " input TriggerTowers");
940 
941  for(const xAOD::TriggerTower* tower : *inputTTs) {
942  xAOD::TriggerTower* t = (*m_xaodTowers)[m_curIndex++] = new xAOD::TriggerTower;
943  *t = *tower;
944  }
945 
947  // /// So clean-up m_xaodTowers before these cause problems later.
948  m_xaodTowers->erase(std::remove_if(m_xaodTowers->begin(), m_xaodTowers->end(),
949  [](const xAOD::TriggerTower* tt){return (tt == 0);}),
950  m_xaodTowers->end());
951 
952  // Remove dead and disabled towers
953  m_xaodTowers->erase(std::remove_if(m_xaodTowers->begin(), m_xaodTowers->end(),
954  [this](const xAOD::TriggerTower* tt){return !IsGoodTower(tt,m_deadChannelsContainer,m_disabledTowersContainer);}),
955  m_xaodTowers->end());
956 
957  return StatusCode::SUCCESS;
958  } // end of getTriggerTowers()
959 
962  {
963  // Find LAr towers in TES
964  StatusCode sc1 = StatusCode::SUCCESS;
966  if(!EMTowers.isValid()){
967  ATH_MSG_WARNING("EM LArTTL1Container not found");
968  sc1 = StatusCode::FAILURE;
969  }
970 
971  StatusCode sc2 = StatusCode::SUCCESS;
973  if(!HECTowers.isValid()){
974  ATH_MSG_WARNING("Had LArTTL1Container not found");
975  sc2 = StatusCode::FAILURE;
976  }
977 
978  // Find Tile towers in TES
979  StatusCode sc3 = StatusCode::SUCCESS;
981  if(!TileTowers.isValid()){
982  ATH_MSG_WARNING("Tile LArTTL1Container not found");
983  sc3 = StatusCode::FAILURE;
984  }
985 
986  if(m_requireAllCalos && ((sc1==StatusCode::FAILURE) ||
987  (sc2==StatusCode::FAILURE) ||
988  (sc3==StatusCode::FAILURE))) {
989  ATH_MSG_ERROR("Can't find calo towers - stopping processing" << endmsg
990  << "Found Em LArTTL1 : "<<sc1 << endmsg
991  << "Found Had LArTTL1 : "<<sc2 << endmsg
992  << "Found TileTTL1 : "<<sc3<< endmsg
993  );
994  return StatusCode::FAILURE;
995  }
996 
997  // lets now try to create some trigger towers
998  if(sc1 == StatusCode::SUCCESS) {
999  processLArTowers(EMTowers.cptr());
1000  }
1001  if(sc2 == StatusCode::SUCCESS) {
1002  processLArTowers(HECTowers.cptr());
1003  }
1004  if(sc3 == StatusCode::SUCCESS) {
1005  processTileTowers(TileTowers.cptr());
1006  }
1007 
1009  // /// So clean-up m_xaodTowers before these cause problems later.
1010  m_xaodTowers->erase(std::remove_if(m_xaodTowers->begin(), m_xaodTowers->end(),
1011  [](const xAOD::TriggerTower* tt){return (tt == 0);}),
1012  m_xaodTowers->end());
1013 
1014  // Remove dead and disabled towers
1015  m_xaodTowers->erase(std::remove_if(m_xaodTowers->begin(), m_xaodTowers->end(),
1016  [this](const xAOD::TriggerTower* tt){return !IsGoodTower(tt,m_deadChannelsContainer,m_disabledTowersContainer);}),
1017  m_xaodTowers->end());
1018 
1019  return StatusCode::SUCCESS;
1020  }
1021 
1024  {
1025  int towerNumber=0;
1026  for(const LArTTL1* tower : *towers){
1027  ATH_MSG_VERBOSE("Looking at retrieved tower number "<<towerNumber++<<" ***********");
1028 
1029  // Obtain identifier
1030  Identifier id = tower->ttOfflineID();
1031  double eta = IDeta(id, m_caloId);
1032  double phi = IDphi(id, m_caloId);
1033  int layer = int(m_caloId->sampling(id) != 0);
1034  L1CaloCoolChannelId coolId = channelId(eta, phi, layer);
1035 
1036  // Tower amplitudes and type
1037  int nsamples = tower->nsamples();
1038  std::vector<float> tower_amps = tower->samples();
1039 
1040  // Now calibrate tower_amps then fill TriggerTower amplitude vector
1041  // TTL1 should have 7 samples, but this little kludge handles other
1042  // eventualities, provided peak is in centre of the pulse
1043  int offset = (nsamples - (s_FIRLENGTH+2))/2;
1044  std::vector<double> amps(s_FIRLENGTH+2);
1045 
1046  ATH_MSG_VERBOSE("nsamples = " << nsamples << " offset = " << offset);
1047 
1048  for(int i = 0; i < s_FIRLENGTH+2; i++) {
1049  int j = i + offset;
1050  if(j >= 0 && j < nsamples) {
1051  amps[i] = tower_amps[j];
1052  }
1053  else {
1054  amps[i] = 0.;
1055  }
1056  ATH_MSG_VERBOSE("amps[" << i << "] = " << amps[i]);
1057  }
1058 
1059  // Create TriggerTower
1060  xAOD::TriggerTower* t = (*m_xaodTowers)[m_curIndex++] = new xAOD::TriggerTower;
1061  t->setCoolId(coolId.id());
1062  t->setEta(eta);
1063  t->setPhi(phi);
1064  m_xaodTowersAmps[t->index()] = std::move(amps);
1065  } // end for loop
1066  }
1067 
1069  {
1070  // Step over all towers
1071  int towerNumber=0;
1072  for(const TileTTL1* tower : *towers) {
1073  ATH_MSG_VERBOSE("Looking at retrieved tower number "<<towerNumber++<<" ***********");
1074 
1075  // Obtain identifier
1076  Identifier id = tower->TTL1_ID();
1077  double cal = m_TileToMeV;//calib(id, m_caloId)*m_TileToMeV;
1078 
1079  // Check this tower is used by the trigger
1080  // don't use gap or mbias scinitllators
1081  if(m_caloId->is_tile(id)) {
1082  double tower_eta = IDeta(id, m_caloId);
1083  double tower_phi = IDphi(id, m_caloId);
1084 
1085  // need to convert tower energy to E_t later
1086  unsigned Ieta = unsigned(fabs(tower_eta)*10.0);
1087  if(Ieta >= m_maxIetaBins){
1088  ATH_MSG_WARNING("TileTTL1 with invalid index for m_sinThetaHash: Ieta = " << Ieta);
1089  Ieta = 0u;
1090  }
1091 
1092  /* Extract amplitudes and rescale according to tower eta */
1093  int nsamples = tower->nsamples();
1094  std::vector<float> tower_amps = tower->fsamples();
1095 
1096  /* Debug message */
1097  ATH_MSG_VERBOSE(" nsamples = " << nsamples);
1098 
1099  // Want 7 samples, but this little kludge allows us to accept other
1100  // numbers, provided peak is in centre of the pulse
1101  int offset = (nsamples - (s_FIRLENGTH+2))/2;
1102  std::vector<double> amps(s_FIRLENGTH+2);
1103  for(int i = 0; i < 7; i++) {
1104  int j = i + offset;
1105  if(j >= 0 && j < nsamples) {
1106  amps[i] = (tower_amps[j]-m_TileTTL1Ped)*m_sinThetaHash[Ieta]*cal; // rescale to MeV
1107  }
1108  else {
1109  amps[i] = 0.;
1110  }
1111  /* Debug message */
1112  ATH_MSG_VERBOSE("amps[" << i << "] = " << amps[i]);
1113  }
1114 
1115  // Create TriggerTower
1116  // m_xaodTowers->push_back(new xAOD::TriggerTower);
1117  // auto t = m_xaodTowers->back();
1118  xAOD::TriggerTower* t = (*m_xaodTowers)[m_curIndex++] = new xAOD::TriggerTower;
1119  t->setCoolId(channelId(tower_eta, tower_phi, 1).id());
1120  t->setEta(tower_eta);
1121  t->setPhi(tower_phi);
1122  m_xaodTowersAmps[t->index()] = std::move(amps);
1123  } // end check on whether tower is used
1124  } // end for loop
1125 
1126  return;
1127  }
1128 
1130  void Run2TriggerTowerMaker::digitize(const EventContext& ctx)
1131  {
1132  CLHEP::HepRandomEngine* rndmADCs = m_rndmADCs->getEngine (ctx);
1133 
1134  // Loop over all existing towers and digitize pulses
1135  for(auto tower : *m_xaodTowers) {
1136  // First process EM layer
1137  L1CaloCoolChannelId id(tower->coolId());
1138  std::vector<int> digits = ADC(rndmADCs, id, m_xaodTowersAmps[tower->index()]); // ADC simulation
1139  tower->setAdc(std::vector<uint16_t>(std::begin(digits), std::end(digits)));
1140  tower->setAdcPeak(digits.size()/2);
1141  }
1142  }
1143 
1144  std::vector<int> Run2TriggerTowerMaker::ADC(CLHEP::HepRandomEngine* rndmADCs,
1145  L1CaloCoolChannelId channel, const std::vector<double>& amps) const
1146  {
1147  auto* chanCalib = m_chanCalibContainer->pprChanCalib(channel);
1148  if(!chanCalib) { ATH_MSG_WARNING("No database entry for tower " << channel.id()); return {}; }
1149  double ped = chanCalib->pedMean();
1150 
1151  // dice the calibration uncertainty if requested
1152  double adcCal = (m_gainCorr > 0.) ? CLHEP::RandGaussZiggurat::shoot(rndmADCs, 1., m_gainCorr) : 1.;
1153 
1154  std::vector<int> digits;
1155  const int nSamples = amps.size();
1156  digits.reserve(nSamples);
1157  for(int i = 0; i < nSamples; ++i) {
1158  // dice the adc noise if requested
1159  double adcNoise = (m_adcVar > 0.) ? CLHEP::RandGaussZiggurat::shoot(rndmADCs,0.,m_adcVar) : 0.;
1160 
1161  int digit = int((amps[i]*adcCal/m_adcStep) + ped + adcNoise);
1162  if(digit > ADCMAX) digit = ADCMAX;
1163  if(digit < 0) digit = 0;
1164  digits.push_back(digit);
1165  }
1166  return digits;
1167  }
1168 
1169  int Run2TriggerTowerMaker::EtRange(int et, unsigned short bcidEnergyRangeLow, unsigned short bcidEnergyRangeHigh) const
1170  {
1171  if(et < bcidEnergyRangeLow) return 0;
1172  if(et < bcidEnergyRangeHigh) return 1;
1173  return 2;
1174  }
1175 
1176  double Run2TriggerTowerMaker::IDeta(const Identifier& id, const CaloLVL1_ID* l1id)
1177  {
1178  int region = l1id->region(id);
1179  int ieta = l1id->eta(id);
1180  int sign = l1id->pos_neg_z(id);
1181 
1182  double gran[4] = {0.1, 0.2, 0.1, 0.425};
1183  double offset[4] = {0., 2.5, 3.1, 3.2};
1184  double eta;
1185 
1186  if(region>=0 && region<=3) {
1187  eta = sign* (((ieta+0.5) * gran[region]) + offset[region]);
1188  }
1189  else {
1190  eta = 0.;
1191  }
1192 
1193  return eta;
1194  }
1195 
1196 
1197  double Run2TriggerTowerMaker::IDphi(const Identifier& id, const CaloLVL1_ID* l1id)
1198  {
1199  Identifier regId = l1id->region_id(id);
1200 
1201  double phiMax = l1id->phi_max(regId);
1202  int iphi = l1id->phi(id);
1203  double phi = (iphi+0.5)*2*M_PI/(phiMax+1);
1204 
1205  return phi;
1206  }
1207 
1213  {
1214  int crate, module, channel;
1215  m_mappingTool->mapping(eta, phi, layer, crate, module, channel);
1216  int slot = module + 5;
1217  int pin = channel % 16;
1218  int asic = channel / 16;
1219  return L1CaloCoolChannelId(crate, L1CaloModuleType::Ppm, slot, pin, asic, false);
1220  }
1221 
1222  int Run2TriggerTowerMaker::etaToElement(float feta, int layer) const
1223  {
1224  constexpr static int NELEMENTS = 33;
1226  float shiftedEta = feta + 4.9;
1227  uint eta = (uint)floor(shiftedEta*10.0);
1228  if(fabs(shiftedEta*10.0 - (uint)(eta+1)) < 0.01) eta++;
1229  if(fabs(shiftedEta) < 0.01) eta = 0;
1230 
1231  constexpr int nBins = 16;
1232  constexpr uint map[nBins] = {2,6,10,14,17,19,21,23,75,77,79,80,83,87,91,95};
1233  int element = -1;
1234  if(eta > 23 && eta < 74) {
1235  element = eta - 16;
1236  } else {
1237  for(int i = 0; i < nBins; i++) {
1238  if(eta == map[i]) {
1239  if(i < 8) element = i;
1240  else element = i + 50;
1241  break;
1242  }
1243  }
1244  }
1245  if (layer == 1 && (element == 0 || element == 64)) element = 1; // FCal2-2
1246  else if (layer == 1 && (element == 1 || element == 65)) element = 0; // FCal3-2
1247  else if (layer == 1 && (element == 2 || element == 62)) element = 3; // FCal2-1
1248  else if (layer == 1 && (element == 3 || element == 63)) element = 2; // FCal3-1
1249  else if (element > 32) element = 65-element;
1250 
1251  // element 29 = FCal2-1, element 30 = FCal3-1, element 31 = FCal2-2, element 32 = FCal3-2
1252  element = NELEMENTS-element-1;
1253 
1254  return element;
1255  }
1256 
1257  // This is the non-linear LUT function corresponding to strategy 3.
1258  // This should actually go into LVL1::L1TriggerTowerTools (TrigT1CaloTools)
1259  // but for now we keep it here to keep the number of touched packages small
1260  // and make it easier to change some parts of the definition later on.
1261  int Run2TriggerTowerMaker::non_linear_lut(int lutin, unsigned short offset, unsigned short slope, unsigned short noiseCut, unsigned short scale, short par1, short par2, short par3, short par4) {
1262  // turn shorts into double (database fields are shorts ... )
1263 
1264  // turn shorts into double
1265  double nll_slope = 0.001 * scale;
1266  double nll_offset = 0.001 * par1;
1267  double nll_ampl = 0.001 * par2;
1268  double nll_expo = 0.;
1269  if(par3) {
1270  nll_expo = -1. / (4096 * 0.001*par3);
1271  } else {
1272  nll_ampl = 0.;
1273  }
1274  double nll_noise = 0.001 * par4;
1275 
1276  // noise cut
1277  if (lutin * slope < offset + nll_noise * noiseCut) {
1278  return 0;
1279  }
1280 
1281  // actual calculation
1282  int output = int((((int)(2048 + nll_slope * (lutin * slope - offset)))>>12) + nll_offset + nll_ampl * std::exp(nll_expo * (lutin * slope - offset)));
1283  if(output >= 255) return 255;
1284  if(output < 0) return 0;
1285  return output;
1286  }
1287 
1288 } // end of namespace bracket
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
xAOD::TriggerTower_v2::correctionEnabled
const std::vector< uint8_t > & correctionEnabled() const
get correctionEnabled
LVL1::Run2TriggerTowerMaker::m_deadChannelsContainer
const L1CaloPpmDeadChannelsContainer * m_deadChannelsContainer
Definition: Run2TriggerTowerMaker.h:179
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
LVL1::Run2TriggerTowerMaker::m_curIndex
std::size_t m_curIndex
Definition: Run2TriggerTowerMaker.h:189
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition: RNGWrapper.h:169
LVL1::Run2TriggerTowerMaker::calcLutOutCP
StatusCode calcLutOutCP(const std::vector< int > &sigLutIn, const L1CaloPprChanCalib *sigDB, const std::vector< int > &ovLutIn, const L1CaloPprChanCalib *ovDB, std::vector< int > &output)
calculate LUT out
Definition: Run2TriggerTowerMaker.cxx:515
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
LVL1::Run2TriggerTowerMaker::store
StatusCode store()
Stores Trigger Towers in the TES, at a location defined in m_outputLocation.
Definition: Run2TriggerTowerMaker.cxx:905
Run2TriggerTowerMaker.h
LVL1::Run2TriggerTowerMaker::m_adcStep
double m_adcStep
Definition: Run2TriggerTowerMaker.h:131
LVL1::Run2TriggerTowerMaker::preProcess
StatusCode preProcess(int bcid, float mu)
Simulate PreProcessing on analogue amplitudes.
Definition: Run2TriggerTowerMaker.cxx:678
et
Extra patterns decribing particle interation process.
L1CaloPpmDeadChannels
Folder <-> Object mapping for /TRIGGER/L1Calo/V1/Calibration/PpmDeadChannels .
Definition: L1CaloPpmDeadChannels.h:17
LVL1::Run2TriggerTowerMaker::m_EmTTL1ContainerName
SG::ReadHandleKey< LArTTL1Container > m_EmTTL1ContainerName
Definition: Run2TriggerTowerMaker.h:276
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
LVL1::Run2TriggerTowerMaker::processLArTowers
void processLArTowers(const LArTTL1Container *)
extract amplitudes from TTL1
Definition: Run2TriggerTowerMaker.cxx:1023
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
LVL1::Run2TriggerTowerMaker::m_chanDefaultsKeyoverlay
std::string m_chanDefaultsKeyoverlay
Definition: Run2TriggerTowerMaker.h:147
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
L1CaloPprChanCalib::lutCpStrategy
unsigned short lutCpStrategy() const
Definition: L1CaloPprChanCalib.h:39
L1CaloDisabledTowersContainer
Definition: L1CaloDisabledTowersContainer.h:27
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
L1CaloPprChanCalib::satBcidThreshLow
unsigned short satBcidThreshLow() const
Definition: L1CaloPprChanCalib.h:28
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
L1CaloPprChanCalib::lutCpSlope
unsigned short lutCpSlope() const
Definition: L1CaloPprChanCalib.h:42
xAOD::TriggerTower_v2::lut_cp
const std::vector< uint8_t > & lut_cp() const
get lut_cp
LVL1::Run2TriggerTowerMaker::addOverlay
virtual StatusCode addOverlay(int bcid, float mu)
Add overlay data.
Definition: Run2TriggerTowerMaker.cxx:392
CaloLVL1_ID::phi_max
int phi_max(const Identifier regId) const
min value of phi index (-999 == failure)
Definition: CaloLVL1_ID.cxx:495
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
L1CaloPprChanCalib::lutCpPar2
short lutCpPar2() const
Definition: L1CaloPprChanCalib.h:44
L1CaloPprChanDefaults::bcidDecision1
int bcidDecision1() const
Definition: L1CaloPprChanDefaults.h:23
LVL1::Run2TriggerTowerMaker::ADC
std::vector< int > ADC(CLHEP::HepRandomEngine *rndmADCs, L1CaloCoolChannelId channel, const std::vector< double > &amps) const
Functions to simulate processing of tower signals.
Definition: Run2TriggerTowerMaker.cxx:1144
LVL1::Run2TriggerTowerMaker::~Run2TriggerTowerMaker
virtual ~Run2TriggerTowerMaker()
Definition: Run2TriggerTowerMaker.cxx:152
LVL1::Run2TriggerTowerMaker::initialize
StatusCode initialize()
Definition: Run2TriggerTowerMaker.cxx:154
AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
Definition: AthCommonDataStore.h:380
LVL1::Run2TriggerTowerMaker::normaliseDigits
void normaliseDigits(const std::vector< int > &sigDigits, const std::vector< int > &ovDigits, std::vector< int > &normDigits)
normalise the number of ADC digits for overlay
Definition: Run2TriggerTowerMaker.cxx:642
L1CaloPprChanCalib::firCoeff3
short firCoeff3() const
Definition: L1CaloPprChanCalib.h:36
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
L1CaloPprChanCalib::pedFirSum
unsigned int pedFirSum() const
Definition: L1CaloPprChanCalib.h:26
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
TileTTL1
Definition: TileTTL1.h:26
M_PI
#define M_PI
Definition: ActiveFraction.h:11
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
SG::ReadDecorHandle::isPresent
bool isPresent() const
Is the referenced container present in SG?
CaloLVL1_ID::region
int region(const Identifier id) const
return region according to :
Definition: CaloLVL1_ID.h:647
L1CaloPprChanCalib::lutJepNoiseCut
unsigned short lutJepNoiseCut() const
Definition: L1CaloPprChanCalib.h:50
TileInfo.h
xAOD::TriggerTower_v2::correction
const std::vector< int16_t > & correction() const
get correction
LVL1::Run2TriggerTowerMaker::m_doOverlay
bool m_doOverlay
Definition: Run2TriggerTowerMaker.h:173
xAOD::TriggerTower_v2::setBcidVec
void setBcidVec(const std::vector< uint8_t > &)
set bcidVec
LVL1::Run2TriggerTowerMaker::preProcessTower
StatusCode preProcessTower(int bcid, float mu, xAOD::TriggerTower *tower)
Definition: Run2TriggerTowerMaker.cxx:687
L1CaloDisabledTowersContainer.h
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
LVL1::Run2TriggerTowerMaker::calcLutOutJEP
StatusCode calcLutOutJEP(const std::vector< int > &sigLutIn, const L1CaloPprChanCalib *sigDB, const std::vector< int > &ovLutIn, const L1CaloPprChanCalib *ovDB, std::vector< int > &output)
Definition: Run2TriggerTowerMaker.cxx:536
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
CaloLVL1_ID::region_id
Identifier region_id(int pos_neg_z, int sampling, int region) const
build a region (of towers) identifier
Definition: CaloLVL1_ID.h:502
LVL1::Run2TriggerTowerMaker::m_rndmADCs
ATHRNG::RNGWrapper * m_rndmADCs
Definition: Run2TriggerTowerMaker.h:153
TileInfo
Definition: TileInfo.h:49
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
LVL1::Run2TriggerTowerMaker::m_xaodTowersAmps
std::vector< std::vector< double > > m_xaodTowersAmps
Definition: Run2TriggerTowerMaker.h:188
LVL1::Run2TriggerTowerMaker::m_jepLutScale
double m_jepLutScale
Definition: Run2TriggerTowerMaker.h:163
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
LVL1::Run2TriggerTowerMaker::s_FIRLENGTH
constexpr static int s_FIRLENGTH
Definition: Run2TriggerTowerMaker.h:113
LVL1::Run2TriggerTowerMaker::m_TileTTL1ContainerName
SG::ReadHandleKey< TileTTL1Container > m_TileTTL1ContainerName
Definition: Run2TriggerTowerMaker.h:278
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
x
#define x
LVL1::Run2TriggerTowerMaker::finalize
StatusCode finalize()
Definition: Run2TriggerTowerMaker.cxx:295
L1CaloPprChanCalib::bcidEnergyRangeLow
unsigned short bcidEnergyRangeLow() const
Definition: L1CaloPprChanCalib.h:31
xAOD::TriggerTower_v2::bcidVec
const std::vector< uint8_t > & bcidVec() const
get bcidVec
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
LVL1::Run2TriggerTowerMaker::m_TileTTL1Ped
double m_TileTTL1Ped
Definition: Run2TriggerTowerMaker.h:167
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
LVL1::Run2TriggerTowerMaker::EtRange
int EtRange(int et, unsigned short bcidEnergyRangeLow, unsigned short bcidEnergyRangeHigh) const
Definition: Run2TriggerTowerMaker.cxx:1169
LVL1::Run2TriggerTowerMaker::TRIGGERTOWERS
@ TRIGGERTOWERS
Definition: Run2TriggerTowerMaker.h:118
L1CaloPprChanCalibContainer.h
L1CaloPprChanCalib::lutJepPar1
short lutJepPar1() const
Definition: L1CaloPprChanCalib.h:52
L1CaloPprChanDefaults::peakFinderCond
int peakFinderCond() const
Definition: L1CaloPprChanDefaults.h:29
LVL1::Run2TriggerTowerMaker::preProcessTower_getLutIn
StatusCode preProcessTower_getLutIn(int bcid, float mu, xAOD::TriggerTower *tower, const L1CaloPprChanCalib *db, const std::vector< int > &digits, std::vector< int > &output)
PreProcess up to LUT in.
Definition: Run2TriggerTowerMaker.cxx:592
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LVL1::Run2TriggerTowerMaker::m_TTtool
ToolHandle< IL1TriggerTowerTool > m_TTtool
Definition: Run2TriggerTowerMaker.h:155
LVL1::Run2TriggerTowerMaker::channelId
L1CaloCoolChannelId channelId(double eta, double phi, int layer)
Compute L1CaloCoolChannelId (including support for old geometries)
Definition: Run2TriggerTowerMaker.cxx:1212
L1CaloPprChanCalib::lutJepPar3
short lutJepPar3() const
Definition: L1CaloPprChanCalib.h:54
L1CaloPprChanCalib::firCoeff4
short firCoeff4() const
Definition: L1CaloPprChanCalib.h:37
ThresholdConfig.h
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
CaloLVL1_ID::phi
int phi(const Identifier id) const
return phi according to :
Definition: CaloLVL1_ID.h:659
LVL1::Run2TriggerTowerMaker::m_disabledTowersKeyoverlay
std::string m_disabledTowersKeyoverlay
Definition: Run2TriggerTowerMaker.h:148
python.PyAthena.module
module
Definition: PyAthena.py:131
Cut::signal
@ signal
Definition: SUSYToolsAlg.cxx:67
L1CaloPprChanCalib::satBcidThreshHigh
unsigned short satBcidThreshHigh() const
Definition: L1CaloPprChanCalib.h:29
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
L1CaloPprChanCalib::lutCpOffset
unsigned short lutCpOffset() const
Definition: L1CaloPprChanCalib.h:40
LVL1::Run2TriggerTowerMaker::m_L1MenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
Definition: Run2TriggerTowerMaker.h:280
LVL1::Run2TriggerTowerMaker::Run2TriggerTowerMaker
Run2TriggerTowerMaker(const std::string &name, ISvcLocator *pSvcLocator)
Definition: Run2TriggerTowerMaker.cxx:81
LVL1::Run2TriggerTowerMaker::IsDisabledChannel
bool IsDisabledChannel(const L1CaloDisabledTowers *db) const
Definition: Run2TriggerTowerMaker.cxx:377
LVL1::Run2TriggerTowerMaker::m_xaodTowersAux
std::unique_ptr< xAOD::TriggerTowerAuxContainer > m_xaodTowersAux
Definition: Run2TriggerTowerMaker.h:187
LVL1::Run2TriggerTowerMaker::s_MEV
constexpr static int s_MEV
Definition: Run2TriggerTowerMaker.h:114
LVL1::Run2TriggerTowerMaker::m_chanDefaults
L1CaloPprChanDefaults m_chanDefaults
Definition: Run2TriggerTowerMaker.h:180
xAOD::TriggerTower_v2::setPeak
void setPeak(uint8_t)
set peak
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1::Run2TriggerTowerMaker::m_chanCalibKey
SG::ReadCondHandleKey< L1CaloPprChanCalibContainer > m_chanCalibKey
Definition: Run2TriggerTowerMaker.h:142
LVL1::Run2TriggerTowerMaker::IDeta
double IDeta(const Identifier &id, const CaloLVL1_ID *caloId)
functions to extract eta, phi coordinates from calo tower identifiers
Definition: Run2TriggerTowerMaker.cxx:1176
LVL1::Run2TriggerTowerMaker::m_isDataReprocessing
bool m_isDataReprocessing
Definition: Run2TriggerTowerMaker.h:171
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
LVL1::Run2TriggerTowerMaker::m_deadChannelsKeyoverlay
std::string m_deadChannelsKeyoverlay
Definition: Run2TriggerTowerMaker.h:149
L1CaloPprChanCalib::lutJepPar4
short lutJepPar4() const
Definition: L1CaloPprChanCalib.h:55
LVL1::Run2TriggerTowerMaker::m_xaodevtKey
SG::ReadHandleKey< xAOD::EventInfo > m_xaodevtKey
Definition: Run2TriggerTowerMaker.h:265
L1CaloPpmDeadChannelsContainer::ppmDeadChannels
const L1CaloPpmDeadChannels * ppmDeadChannels(unsigned int channelId) const
Definition: L1CaloPpmDeadChannelsContainer.cxx:72
lumiFormat.i
int i
Definition: lumiFormat.py:85
L1CaloPprChanCalib::firCoeff2
short firCoeff2() const
Definition: L1CaloPprChanCalib.h:35
L1CaloPprChanCalib::lutJepOffset
unsigned short lutJepOffset() const
Definition: L1CaloPprChanCalib.h:49
MSG
Definition: MsgLevel.h:28
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
LVL1::Run2TriggerTowerMaker::IsDeadChannel
bool IsDeadChannel(const L1CaloPpmDeadChannels *db) const
Database helper functions for dead and disabled towers.
Definition: Run2TriggerTowerMaker.cxx:370
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
xAOD::TriggerTower_v2::layer
int layer() const
get layer ( 0 = EM, 1 = Had, 2 = FCAL23) - to be confirmed
Definition: TriggerTower_v2.cxx:121
L1CaloPprChanCalib::firCoeff5
short firCoeff5() const
Definition: L1CaloPprChanCalib.h:38
xAOD::TriggerTower_v2
Description of TriggerTower_v2.
Definition: TriggerTower_v2.h:49
L1CaloPprChanCalib::satBcidLevel
unsigned short satBcidLevel() const
Definition: L1CaloPprChanCalib.h:30
TileInfo::TTL1Ped
double TTL1Ped(const Identifier &) const
Returns the pedestal (in mV) for TTL1 adcs.
Definition: TileInfo.h:139
xAOD::TriggerTower_v2::eta
virtual double eta() const final
The pseudorapidity ( ) of the particle.
Definition: TriggerTower_v2.cxx:210
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
LVL1::Run2TriggerTowerMaker::m_digiEngine
std::string m_digiEngine
Definition: Run2TriggerTowerMaker.h:122
L1CaloCoolChannelId::id
unsigned int id() const
Definition: L1CaloCoolChannelId.h:32
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
L1CaloPprChanDefaults::bcidDecision3
int bcidDecision3() const
Definition: L1CaloPprChanDefaults.h:27
L1CaloPprChanDefaults::satOverride2
int satOverride2() const
Definition: L1CaloPprChanDefaults.h:26
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TriggerTower_v2::coolId
uint32_t coolId() const
Tower identifiers.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
LVL1::Run2TriggerTowerMaker::m_actMuKey
SG::ReadDecorHandleKey< xAOD::EventInfo > m_actMuKey
Definition: Run2TriggerTowerMaker.h:266
SCT_Monitoring::disabled
@ disabled
Definition: SCT_MonitoringNumbers.h:60
L1CaloPprChanCalib::lutCpScale
unsigned short lutCpScale() const
Definition: L1CaloPprChanCalib.h:47
LVL1::Run2TriggerTowerMaker::execute
StatusCode execute()
Checks that the Cell Type is supported (terminates with errors if not) and calls relevant routine to ...
Definition: Run2TriggerTowerMaker.cxx:303
L1CaloPprChanCalib::lutJepSlope
unsigned short lutJepSlope() const
Definition: L1CaloPprChanCalib.h:51
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
xAOD::TriggerTowerAuxContainer_v2
AuxContainer for TriggerTower_v2.
Definition: TriggerTowerAuxContainer_v2.h:28
LVL1::Run2TriggerTowerMaker::TTL1
@ TTL1
Definition: Run2TriggerTowerMaker.h:118
L1CaloPprChanCalib
Folder <-> Object mapping for /TRIGGER/L1Calo/V2/Calibration/Physics/PprChanCalib .
Definition: L1CaloPprChanCalib.h:17
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
LArTTL1Container
Container class for LArTTL1.
Definition: LArTTL1Container.h:24
xAOD::TriggerTower_v2::setCorrection
void setCorrection(const std::vector< int16_t > &)
set correction
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LVL1::Run2TriggerTowerMaker::m_cpLutScale
double m_cpLutScale
Definition: Run2TriggerTowerMaker.h:162
L1CaloPprChanCalib::firCoeff1
short firCoeff1() const
Definition: L1CaloPprChanCalib.h:34
TrigConf::name
Definition: HLTChainList.h:35
LVL1::Run2TriggerTowerMaker::IDphi
double IDphi(const Identifier &id, const CaloLVL1_ID *caloId)
Definition: Run2TriggerTowerMaker.cxx:1197
LVL1::Run2TriggerTowerMaker::etaToElement
int etaToElement(float feta, int layer) const
Definition: Run2TriggerTowerMaker.cxx:1222
L1CaloPprChanCalib::bcidEnergyRangeHigh
unsigned short bcidEnergyRangeHigh() const
Definition: L1CaloPprChanCalib.h:32
merge.output
output
Definition: merge.py:17
L1CaloPprChanCalib::lutCpPar1
short lutCpPar1() const
Definition: L1CaloPprChanCalib.h:43
xAOD::TriggerTowerContainer
TriggerTowerContainer_v2 TriggerTowerContainer
Define the latest version of the TriggerTower container.
Definition: TriggerTowerContainer.h:15
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
LVL1::Run2TriggerTowerMaker::m_TileToMeV
double m_TileToMeV
Definition: Run2TriggerTowerMaker.h:165
CaloLVL1_ID
Helper class for offline TT identifiers.
Definition: CaloLVL1_ID.h:66
PathResolver.h
L1CaloPprChanCalib::lutCpNoiseCut
unsigned short lutCpNoiseCut() const
Definition: L1CaloPprChanCalib.h:41
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LVL1::Run2TriggerTowerMaker::non_linear_lut
int non_linear_lut(int lutin, unsigned short offset, unsigned short slope, unsigned short noiseCut, unsigned short scale, short par1, short par2, short par3, short par4)
Definition: Run2TriggerTowerMaker.cxx:1261
LVL1::Run2TriggerTowerMaker::m_rngSvc
ServiceHandle< IAthRNGSvc > m_rngSvc
Definition: Run2TriggerTowerMaker.h:152
LVL1::Run2TriggerTowerMaker::getTriggerTowers
StatusCode getTriggerTowers()
gets collection of input TriggerTowers for reprocessing
Definition: Run2TriggerTowerMaker.cxx:934
L1CaloPprChanCalib::firStartBit
unsigned short firStartBit() const
Definition: L1CaloPprChanCalib.h:33
L1CaloPprChanCalib::lutJepScale
unsigned short lutJepScale() const
Definition: L1CaloPprChanCalib.h:56
L1CaloModuleType.h
IL1CaloMappingTool.h
CaloLVL1_ID::eta
int eta(const Identifier id) const
return eta according to :
Definition: CaloLVL1_ID.h:653
LVL1::Run2TriggerTowerMaker::m_xaodTowers
std::unique_ptr< xAOD::TriggerTowerContainer > m_xaodTowers
Definition: Run2TriggerTowerMaker.h:186
LVL1::Run2TriggerTowerMaker::m_mappingTool
ToolHandle< IL1CaloMappingTool > m_mappingTool
Definition: Run2TriggerTowerMaker.h:156
LVL1::Run2TriggerTowerMaker::m_caloId
const CaloLVL1_ID * m_caloId
Definition: Run2TriggerTowerMaker.h:159
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Base_Fragment.defaults
dictionary defaults
This includes now the top quark, the leptons and the bosons.
Definition: GeneratorFilters/share/common/Base_Fragment.py:79
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
xAOD::TriggerTower_v2::setLut_cp
void setLut_cp(const std::vector< uint8_t > &)
set lut_cp
LVL1::TrigT1CaloDefs::xAODTriggerTowerLocation
static const std::string xAODTriggerTowerLocation
Definition: TrigT1CaloDefs.h:36
TrigT1CaloDefs.h
L1CaloPpmDeadChannelsContainer
Definition: L1CaloPpmDeadChannelsContainer.h:27
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition: RNGWrapper.h:134
RNGWrapper.h
xAOD::TriggerTower_v2::setLut_jep
void setLut_jep(const std::vector< uint8_t > &)
set lut_jep
EventInfo.h
L1CaloPprChanDefaultsContainer::pprChanDefaults
const L1CaloPprChanDefaults * pprChanDefaults(unsigned int channelId) const
Definition: L1CaloPprChanDefaultsContainer.cxx:175
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
Example_ReadSampleNoise.ped
ped
Definition: Example_ReadSampleNoise.py:45
LVL1::Run2TriggerTowerMaker::processTileTowers
void processTileTowers(const TileTTL1Container *)
Definition: Run2TriggerTowerMaker.cxx:1068
LVL1::Run2TriggerTowerMaker::m_disabledTowersContaineroverlay
L1CaloDisabledTowersContainer * m_disabledTowersContaineroverlay
Definition: Run2TriggerTowerMaker.h:182
CaloLVL1_ID::pos_neg_z
int pos_neg_z(const Identifier id) const
return pos_neg_z according to :
Definition: CaloLVL1_ID.h:635
L1CaloPprChanCalibContainer::pprChanCalib
const L1CaloPprChanCalib * pprChanCalib(unsigned int channelId) const
Definition: L1CaloPprChanCalibContainer.cxx:170
ReadOfcFromCool.nsamples
nsamples
Definition: ReadOfcFromCool.py:115
python.PyAthena.v
v
Definition: PyAthena.py:154
LVL1::Run2TriggerTowerMaker::m_sinThetaHash
std::array< double, m_maxIetaBins > m_sinThetaHash
instead of calculating the expression: double theta =2.
Definition: Run2TriggerTowerMaker.h:197
L1CaloCoolChannelId
Definition: L1CaloCoolChannelId.h:10
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
L1CaloDisabledTowers
Folder <-> Object mapping for /TRIGGER/L1Calo/V1/Conditions/DisabledTowers .
Definition: L1CaloDisabledTowers.h:17
LVL1::Run2TriggerTowerMaker::m_outputLocation
SG::WriteHandleKey< xAOD::TriggerTowerContainer > m_outputLocation
Definition: Run2TriggerTowerMaker.h:271
L1CaloPpmDeadChannelsContainer.h
LVL1::Run2TriggerTowerMaker::m_isReco
bool m_isReco
Definition: Run2TriggerTowerMaker.h:174
L1CaloModuleType::Ppm
@ Ppm
Definition: L1CaloModuleType.h:17
LVL1::Run2TriggerTowerMaker::calcCombinedLUT
void calcCombinedLUT(const std::vector< int > &sigIN, const int sigSlope, const int sigOffset, const std::vector< int > &ovIN, const int ovSlope, const int ovOffset, const int ovNoiseCut, std::vector< int > &output)
Definition: Run2TriggerTowerMaker.cxx:557
CaloLVL1_ID.h
L1CaloPprChanCalib::lutJepStrategy
unsigned short lutJepStrategy() const
Definition: L1CaloPprChanCalib.h:48
LVL1::Run2TriggerTowerMaker::m_disabledTowersContainer
const L1CaloDisabledTowersContainer * m_disabledTowersContainer
Definition: Run2TriggerTowerMaker.h:178
RunTileMonitoring.towers
towers
Definition: RunTileMonitoring.py:133
LVL1::Run2TriggerTowerMaker::m_decorateFIR
bool m_decorateFIR
Definition: Run2TriggerTowerMaker.h:133
LVL1::Run2TriggerTowerMaker::getCaloTowers
StatusCode getCaloTowers()
fetch Calorimeter Towers
Definition: Run2TriggerTowerMaker.cxx:961
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LVL1::Run2TriggerTowerMaker::m_adcVar
double m_adcVar
Definition: Run2TriggerTowerMaker.h:128
L1CaloPprChanCalib::lutCpPar4
short lutCpPar4() const
Definition: L1CaloPprChanCalib.h:46
LVL1::Run2TriggerTowerMaker::m_chanCalibContaineroverlay
L1CaloPprChanCalibContainer * m_chanCalibContaineroverlay
Definition: Run2TriggerTowerMaker.h:181
xAOD::TriggerTower_v2::setCorrectionEnabled
void setCorrectionEnabled(const std::vector< uint8_t > &)
set correctionEnabled
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LVL1::Run2TriggerTowerMaker::m_deadChannelsKey
SG::ReadCondHandleKey< L1CaloPpmDeadChannelsContainer > m_deadChannelsKey
Definition: Run2TriggerTowerMaker.h:145
LVL1::Run2TriggerTowerMaker::m_disabledTowersKey
SG::ReadCondHandleKey< L1CaloDisabledTowersContainer > m_disabledTowersKey
Definition: Run2TriggerTowerMaker.h:144
CaloLVL1_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
Definition: CaloLVL1_ID.h:641
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
LVL1::Run2TriggerTowerMaker::m_chanCalibKeyoverlay
std::string m_chanCalibKeyoverlay
Definition: Run2TriggerTowerMaker.h:146
LVL1::Run2TriggerTowerMaker::m_cellType
int m_cellType
Definition: Run2TriggerTowerMaker.h:125
L1CaloPprChanCalib::lutCpPar3
short lutCpPar3() const
Definition: L1CaloPprChanCalib.h:45
ReadDecorHandle.h
Handle class for reading a decoration on an object.
LVL1::Run2TriggerTowerMaker::m_chanCalibContainer
const L1CaloPprChanCalibContainer * m_chanCalibContainer
Definition: Run2TriggerTowerMaker.h:177
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:70
LVL1::Run2TriggerTowerMaker::m_requireAllCalos
bool m_requireAllCalos
Definition: Run2TriggerTowerMaker.h:139
L1CaloPprChanDefaults::satOverride3
int satOverride3() const
Definition: L1CaloPprChanDefaults.h:28
L1CaloPprChanDefaults::decisionSource
int decisionSource() const
Definition: L1CaloPprChanDefaults.h:30
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
xAOD::TriggerTower_v2::setBcidExt
void setBcidExt(const std::vector< uint8_t > &)
set bcidExt
LVL1::Run2TriggerTowerMaker::m_maxIetaBins
constexpr static unsigned int m_maxIetaBins
Definition: Run2TriggerTowerMaker.h:115
ReadHandle.h
Handle class for reading from StoreGate.
L1CaloPprChanCalib::lutJepPar2
short lutJepPar2() const
Definition: L1CaloPprChanCalib.h:53
LVL1::Run2TriggerTowerMaker::m_bstowertool
ToolHandle< LVL1BS::ITrigT1CaloDataAccessV2 > m_bstowertool
Definition: Run2TriggerTowerMaker.h:157
LVL1::Run2TriggerTowerMaker::digitize
void digitize(const EventContext &ctx)
Convert analogue pulses to digits.
Definition: Run2TriggerTowerMaker.cxx:1130
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
LVL1::Run2TriggerTowerMaker::m_HadTTL1ContainerName
SG::ReadHandleKey< LArTTL1Container > m_HadTTL1ContainerName
Definition: Run2TriggerTowerMaker.h:277
ITrigT1CaloDataAccessV2.h
overlay
bool overlay
Definition: listroot.cxx:42
TileContainer
Definition: TileContainer.h:38
CaloLVL1_ID::is_tile
bool is_tile(const Identifier id) const
Test wether given tower or layer is part of the Tile Calorimeter.
Definition: CaloLVL1_ID.h:672
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
LVL1::TrigT1CaloDefs::xAODTriggerTowerRerunLocation
static const std::string xAODTriggerTowerRerunLocation
Definition: TrigT1CaloDefs.h:37
LVL1::Run2TriggerTowerMaker::m_ZeroSuppress
bool m_ZeroSuppress
Definition: Run2TriggerTowerMaker.h:136
LVL1::Run2TriggerTowerMaker::IsGoodTower
bool IsGoodTower(const xAOD::TriggerTower *tt, const L1CaloPpmDeadChannelsContainer *dead, const L1CaloDisabledTowersContainer *disabled) const
Definition: Run2TriggerTowerMaker.cxx:384
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
LArTTL1
Liquid Argon TT L1 sum class.
Definition: LArTTL1.h:29
LVL1::Run2TriggerTowerMaker::m_deadChannelsContaineroverlay
L1CaloPpmDeadChannelsContainer * m_deadChannelsContaineroverlay
Definition: Run2TriggerTowerMaker.h:183
Decorator.h
Helper class to provide type-safe access to aux data.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
LVL1::Run2TriggerTowerMaker::m_inputTTLocation
SG::ReadHandleKey< xAOD::TriggerTowerContainer > m_inputTTLocation
Definition: Run2TriggerTowerMaker.h:269
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356
LVL1::Run2TriggerTowerMaker::m_gainCorr
double m_gainCorr
Definition: Run2TriggerTowerMaker.h:132
L1CaloPprChanDefaultsContainer.h
xAOD::TriggerTower
TriggerTower_v2 TriggerTower
Define the latest version of the TriggerTower class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/TriggerTower.h:16
LVL1::Run2TriggerTowerMaker::m_chanDefaultsKey
SG::ReadCondHandleKey< L1CaloPprChanDefaultsContainer > m_chanDefaultsKey
Definition: Run2TriggerTowerMaker.h:143
LVL1::Run2TriggerTowerMaker::m_outputLocationRerun
SG::WriteHandleKey< xAOD::TriggerTowerContainer > m_outputLocationRerun
Definition: Run2TriggerTowerMaker.h:273
xAOD::TriggerTower_v2::adc
const std::vector< uint16_t > & adc() const
get adc
L1CaloPprChanDefaults::bcidDecision2
int bcidDecision2() const
Definition: L1CaloPprChanDefaults.h:25
IAthRNGSvc.h
ServiceHandle< IIncidentSvc >
L1CaloPprChanCalib::pedMean
double pedMean() const
Definition: L1CaloPprChanCalib.h:24
LVL1::Run2TriggerTowerMaker::handle
void handle(const Incident &)
Best if initialisation which uses COOL-derived values is done here rather than in initialize()
Definition: Run2TriggerTowerMaker.cxx:214
TileInfo::TTL1Calib
double TTL1Calib(const Identifier &) const
Returns the factor which converts amplitude in pCb to mV in TTL1.
Definition: TileInfo.h:112
L1CaloPprChanDefaults::satOverride1
int satOverride1() const
Definition: L1CaloPprChanDefaults.h:24
Identifier
Definition: IdentifierFieldParser.cxx:14