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