Loading [MathJax]/jax/output/SVG/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
CTPSimulation.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "./CTPSimulation.h"
7 #include "./CTPTriggerItem.h"
8 #include "./CTPUtil.h"
9 
10 #include "TrigT1Result/CTP_RDO.h"
14 
18 
19 #include "CLHEP/Random/RandomEngine.h"
20 #include "CLHEP/Random/Ranlux64Engine.h"
21 
22 #include "TTree.h"
23 
24 #include <iomanip>
25 #include <algorithm>
26 #include <cmath>
27 
28 namespace {
29  static std::mutex s_metadataMutex;
30 }
31 
32 
33 using namespace TrigConf;
34 
35 const std::function< CLHEP::HepRandomEngine*(void) > CTPSimRanluxFactory = [](void)->CLHEP::HepRandomEngine*{
36  return new CLHEP::Ranlux64Engine();
37 };
38 
39 
40 LVL1CTP::CTPSimulation::CTPSimulation( const std::string& name, ISvcLocator* pSvcLocator ) :
41  AthReentrantAlgorithm ( name, pSvcLocator ),
42  m_RNGEngines( CTPSimRanluxFactory, SG::getNSlots() )
43 {}
44 
46 {}
47 
50 
51  ATH_MSG_DEBUG("initialize");
52  if(m_forceBunchGroupPattern) {
53  ATH_MSG_INFO("Will use bunchgroup pattern 0x" << std::hex << m_bunchGroupPattern);
54  } else {
55  ATH_MSG_INFO("Will use bunchgroup definition from bunchgroup set");
56  }
57 
58  if( m_isData ) {
59  CHECK( m_oKeyRDO.assign(LVL1CTP::DEFAULT_RDOOutputLocation_Rerun) );
60  CHECK( m_oKeySLink.assign(LVL1CTP::DEFAULT_CTPSLinkLocation_Rerun) );
61  }
62  ATH_CHECK( m_bgKey.initialize( !m_forceBunchGroupPattern ) );
63 
64  // data links
65  ATH_CHECK( m_iKeyTopo.initialize( !m_iKeyTopo.empty() && m_doL1Topo ) );
66  ATH_CHECK( m_iKeyMuctpi.initialize( ! m_iKeyMuctpi.empty() ) );
67 
68  // Legacy L1Calo
69  ATH_CHECK( m_iKeyLegacyTopo.initialize( !m_iKeyLegacyTopo.empty() && m_doL1CaloLegacy && m_doL1TopoLegacy ) );
70  ATH_CHECK( m_iKeyCtpinEM.initialize( m_doL1CaloLegacy ) );
71  ATH_CHECK( m_iKeyCtpinJet.initialize( m_doL1CaloLegacy ) );
72  ATH_CHECK( m_iKeyCtpinXE.initialize( m_doL1CaloLegacy ) );
73 
74  // new L1Calo
75  ATH_CHECK( m_iKeyJFexJets.initialize( ! m_iKeyJFexJets.empty() ) );
76  ATH_CHECK( m_iKeyJFexLJets.initialize( ! m_iKeyJFexLJets.empty() ) );
77  ATH_CHECK( m_iKeyGFexJets.initialize( ! m_iKeyGFexJets.empty() ) );
78  ATH_CHECK( m_iKeyGFexMETNC.initialize( ! m_iKeyGFexMETNC.empty() ) );
79  ATH_CHECK( m_iKeyGFexMETRho.initialize( ! m_iKeyGFexMETRho.empty() ) );
80  ATH_CHECK( m_iKeyGFexMETJwoJ.initialize( ! m_iKeyGFexMETJwoJ.empty() ) );
81  ATH_CHECK( m_iKeyEFexCluster.initialize( ! m_iKeyEFexCluster.empty() ) );
82  ATH_CHECK( m_iKeyEFexTau.initialize( ! m_iKeyEFexTau.empty() ) );
83  ATH_CHECK( m_oKeyRDO.initialize( ! m_oKeyRDO.empty() ) );
84  ATH_CHECK( m_oKeySLink.initialize( ! m_oKeySLink.empty() ) );
85 
86  // L1ZDC
87  ATH_CHECK( m_iKeyZDC.initialize( ! m_iKeyZDC.empty() && m_doZDC ) );
88 
89  // L1TRT
90  ATH_CHECK( m_iKeyTRT.initialize( ! m_iKeyTRT.empty() && m_doTRT ) );
91 
92  // services
93  ATH_CHECK( m_histSvc.retrieve() );
94 
95  // tools
96  ATH_CHECK( m_resultBuilder.retrieve() );
97 
98  ATH_MSG_DEBUG("Registering histograms under " << getBaseHistPath() << " in " << m_histSvc);
99 
100  return StatusCode::SUCCESS;
101 }
102 
105 
106  const TrigConf::L1Menu * l1menu = nullptr;
108 
109  bookHists().ignore();
110 
111  // configure the CTP ResultBuilder
112  ATH_CHECK( m_resultBuilder->setConfiguration( *l1menu ) );
113  setHistLabels(*l1menu).ignore();
114 
115  return StatusCode::SUCCESS;
116 }
117 
119 LVL1CTP::CTPSimulation::execute( const EventContext& context ) const {
120 
121  ATH_MSG_DEBUG("execute");
122 
123  fillInputHistograms(context).ignore();
124 
125  std::map<std::string, unsigned int> thrMultiMap;
126 
127  extractMultiplicities(thrMultiMap, context).ignore();
128 
129  simulateItems(thrMultiMap, context).ignore();
130 
131  return StatusCode::SUCCESS;
132 }
133 
135 LVL1CTP::CTPSimulation::createMultiplicityHist(const std::string & type, unsigned int maxMult ) {
136 
137  StatusCode sc;
138  std::map<std::string,std::vector<std::string>> typeMapping = {
139  { "muon", {"MU"} },
140  { "jet", {"JET", "jJ", "jLJ", "gJ", "gLJ"} },
141  { "xe", {"XE", "gXE", "jXE"} },
142  { "te", {"TE", "jTE", "gTE"} },
143  { "xs", {"XS"} },
144  { "em", {"EM", "eEM", "jEM"} },
145  { "tau", {"TAU", "eTAU", "jTAU", "cTAU"} }
146  };
147  std::vector<TrigConf::L1Threshold> thrV;
148  for( const std::string & t : typeMapping[type] ) {
149  size_t xsize = 1;
150  TH2* hist = new TH2I( Form("%sMult", t.c_str()),
151  Form("%s threshold multiplicity", t.c_str()), xsize, 0, xsize, maxMult, 0, maxMult);
152  sc = hbook( "/multi/" + type, std::unique_ptr<TH2>(hist));
153  }
154 
155  return sc;
156 }
157 
160  StatusCode sc;
161  std::map<std::string,std::vector<std::string>> typeMapping = {
162  { "muon", {"MU"} },
163  { "jet", {"JET", "jJ", "jLJ", "gJ", "gLJ"} },
164  { "xe", {"XE", "gXE", "jXE"} },
165  { "te", {"TE", "jTE", "gTE"} },
166  { "xs", {"XS"} },
167  { "em", {"EM", "eEM", "jEM"} },
168  { "tau", {"TAU", "eTAU", "jTAU", "cTAU"} }
169  };
170 
171 
172  std::vector<TrigConf::L1Threshold> thrV;
173  for( const std::string & t : typeMapping[type] ) {
174  try {
175  auto hist = get2DHist( "/multi/" + type + "/" + t + "Mult" );
176  auto & thrV = l1menu.thresholds(t);
177  while( hist->GetNbinsX() < (int)thrV.size() ) {
178  hist->LabelsInflate("xaxis");
179  }
180  for(auto thr : thrV) {
181  hist->GetXaxis()->SetBinLabel(thr->mapping()+1, thr->name().c_str() );
182  }
183  } catch (std::exception & ex) {
184  ATH_MSG_DEBUG("Caught exception when setting new JSON MultiplicityHistLabel " << t << " : " << ex.what());
185  }
186  }
187  return sc;
188 }
189 
190 std::string
192  std::string baseHistPath( m_histPath );
193  if(baseHistPath.back()!='/') baseHistPath += "/";
194  baseHistPath += name();
195  return baseHistPath;
196 }
197 
199 LVL1CTP::CTPSimulation::hbook(const std::string & path, std::unique_ptr<TH1> hist) {
200  const std::string & hname(hist->GetName());
201 
202  std::string key(path);
203  if(key.back()!='/') key += "/";
204  key+=hname;
205 
206  if(m_hist1D.find(key)!=m_hist1D.end()) {
207  ATH_MSG_WARNING("1D-hist " << key << " already exists, won't register it");
208  return StatusCode::RECOVERABLE;
209  }
210 
211  LockedHandle<TH1> lh;
212  StatusCode sc = m_histSvc->regShared( getBaseHistPath() + key, std::move(hist), lh );
213  if( sc.isSuccess() ) {
214  ATH_MSG_DEBUG("1D-hist " << hname << " registered with key - " << key);
215  m_hist1D[key] = lh;
216  } else {
217  ATH_MSG_WARNING("Could not register histogram " << hname);
218  }
219  return sc;
220 }
221 
223 LVL1CTP::CTPSimulation::hbook(const std::string & path, std::unique_ptr<TH2> hist) {
224  const std::string & hname(hist->GetName());
225 
226  std::string key(path);
227  if(key.back()!='/') key += "/";
228  key+=hname;
229 
230  if(m_hist2D.find(key)!=m_hist2D.end()) {
231  ATH_MSG_WARNING("2D-hist " << key << " already exists, won't register it");
232  return StatusCode::RECOVERABLE;
233  }
234 
235  LockedHandle<TH2> lh;
236  StatusCode sc = m_histSvc->regShared( getBaseHistPath() + key, std::move(hist), lh );
237  if( sc.isSuccess() ) {
238  ATH_MSG_DEBUG("2D-hist " << hname << " registered with key - " << key);
239  m_hist2D[key] = lh;
240  } else {
241  ATH_MSG_WARNING("Could not register histogram " << hname);
242  }
243  return sc;
244 }
245 
246 LockedHandle<TH1> &
247 LVL1CTP::CTPSimulation::get1DHist(const std::string & histName) const {
248  auto itr = m_hist1D.find(histName);
249  if (itr == m_hist1D.end()) {
250  throw GaudiException("1D-hist "+histName +" does not exist", name(), StatusCode::FAILURE);
251  }
252  // returning non-const LockHandle from const function is OK:
253  LockedHandle<TH1>& h ATLAS_THREAD_SAFE = const_cast<LockedHandle<TH1>&>(itr->second);
254  return h;
255 }
256 
257 LockedHandle<TH2> &
258 LVL1CTP::CTPSimulation::get2DHist(const std::string & histName) const {
259  auto itr = m_hist2D.find(histName);
260  if (itr == m_hist2D.end()) {
261  throw GaudiException("2D-hist "+histName +" does not exist", name(), StatusCode::FAILURE);
262  }
263  // returning non-const LockHandle from const function is OK:
264  LockedHandle<TH2>& h ATLAS_THREAD_SAFE = const_cast<LockedHandle<TH2>&>(itr->second);
265  return h;
266 }
267 
270 
271  ATH_MSG_DEBUG("setHistLabels(). L1 menu " << l1menu.size() << " items" );
272  // threshold multiplicities
273  ATH_CHECK ( setMultiplicityHistLabels( l1menu, "muon" ) );
274  ATH_CHECK ( setMultiplicityHistLabels( l1menu, "jet" ) );
275  ATH_CHECK ( setMultiplicityHistLabels( l1menu, "xe" ) );
276  ATH_CHECK ( setMultiplicityHistLabels( l1menu, "te" ) );
277  ATH_CHECK ( setMultiplicityHistLabels( l1menu, "xs" ) );
278  ATH_CHECK ( setMultiplicityHistLabels( l1menu, "em" ) );
279  ATH_CHECK ( setMultiplicityHistLabels( l1menu, "tau" ) );
280 
281  // Topo
282  std::vector<std::string> connNames = l1menu.connectorNames();
283  for( const std::string connName : {"LegacyTopo0", "LegacyTopo1", "Topo1El", "Topo2El", "Topo3El", "Topo1Opt0", "Topo1Opt1", "Topo1Opt2", "Topo1Opt3"}) {
284  if( find(connNames.begin(), connNames.end(), connName) == connNames.end() ) {
285  continue;
286  }
287  auto hTopo = *get1DHist("/input/topo/" + connName);
288  for(uint fpga : {0,1}) {
289  for(uint clock : {0,1}) {
290  for(auto & tl : l1menu.connector(connName).triggerLines(fpga,clock)) {
291  uint flatIndex = tl.flatindex();
292  hTopo->GetXaxis()->SetBinLabel(flatIndex+1,tl.name().c_str());
293  }
294  }
295  }
296  }
297 
298  std::vector<std::string> orderedItemnames;
299  orderedItemnames.reserve( l1menu.size() );
300  for( const auto & item : l1menu ) {
301  orderedItemnames.emplace_back(item.name());
302  }
303  std::sort(orderedItemnames.begin(), orderedItemnames.end());
304 
305  // item decision
306  auto tbpById = *get1DHist( "/output/tbpById" );
307  auto tapById = *get1DHist( "/output/tapById" );
308  auto tavById = *get1DHist( "/output/tavById" );
309  auto tbpByName = *get1DHist( "/output/tbpByName" );
310  auto tapByName = *get1DHist( "/output/tapByName" );
311  auto tavByName = *get1DHist( "/output/tavByName" );
312  unsigned int bin = 1;
313  for ( const std::string & itemname : orderedItemnames ) {
314  unsigned int ctpId(0);
315  TrigConf::L1Item item = l1menu.item( itemname );
316  ctpId = item.ctpId();
317  tbpById->GetXaxis()->SetBinLabel( ctpId+1, itemname.c_str() );
318  tapById->GetXaxis()->SetBinLabel( ctpId+1, itemname.c_str() );
319  tavById->GetXaxis()->SetBinLabel( ctpId+1, itemname.c_str() );
320  tbpByName->GetXaxis()->SetBinLabel( bin, itemname.c_str() );
321  tapByName->GetXaxis()->SetBinLabel( bin, itemname.c_str() );
322  tavByName->GetXaxis()->SetBinLabel( bin++, itemname.c_str() );
323  }
324 
325  return StatusCode::SUCCESS;
326 }
327 
330 
331  // jets
332  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("jJetPt","Jet p_{T} - jJ", 40, 0, 80) ));
333  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("jJetEta","Jet #eta - jJ", 64, -3.2, 3.2) ));
334  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("jJetPhi","Jet #phi - jJ", 64, -3.2, 3.2) ));
335  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("jLJetPt","Jet p_{T} - jLJ", 40, 0, 80) ));
336  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("jLJetEta","Jet #eta - jLJ", 64, -3.2, 3.2) ));
337  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("jLJetPhi","Jet #phi - jLJ", 64, -3.2, 3.2) ));
338  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("gJetPt","Jet p_{T} - gJ", 40, 0, 80) ));
339  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("gJetEta","Jet #eta - gJ", 64, -3.2, 3.2) ));
340  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("gJetPhi","Jet #phi - gJ", 64, -3.2, 3.2) ));
341  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("gLJetPt","Jet p_{T} - gLJ", 40, 0, 80) ));
342  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("gLJetEta","Jet #eta - gLJ", 64, -3.2, 3.2) ));
343  ATH_CHECK ( hbook( "/input/jets/", std::make_unique<TH1I>("gLJetPhi","Jet #phi - gLJ", 64, -3.2, 3.2) ));
344 
345  // MET
346  ATH_CHECK ( hbook( "/input/met/", std::make_unique<TH1I>("Pufit","Missing ET from algorithm pufit", 40, 0, 80) ));
347  ATH_CHECK ( hbook( "/input/met/", std::make_unique<TH1I>("PufitPhi","Missing ET PUfit phi", 64, -3.2, 3.2) ));
348  ATH_CHECK ( hbook( "/input/met/", std::make_unique<TH1I>("Rho","Missing ET from algorithm rhosub", 40, 0, 80) ));
349  ATH_CHECK ( hbook( "/input/met/", std::make_unique<TH1I>("RhoPhi","Missing ET rhosub phi", 64, -3.2, 3.2) ));
350  ATH_CHECK ( hbook( "/input/met/", std::make_unique<TH1I>("JwoJ","Missing ET from algorithm jet without jets", 40, 0, 80) ));
351  ATH_CHECK ( hbook( "/input/met/", std::make_unique<TH1I>("JwoJPhi","Missing ET jet without jet phi", 64, -3.2, 3.2) ));
352 
353  // cluster
354  ATH_CHECK ( hbook( "/input/em/", std::make_unique<TH1I>("et","Cluster et", 40, 0, 40) ));
355  ATH_CHECK ( hbook( "/input/em/", std::make_unique<TH1I>("eta","Cluster eta ", 64, -3.2, 3.2) ));
356  ATH_CHECK ( hbook( "/input/em/", std::make_unique<TH1I>("phi","Cluster phi", 64, -3.2, 3.2) ));
357 
358  // tau
359  ATH_CHECK ( hbook( "/input/tau/", std::make_unique<TH1I>("et","Tau et", 40, 0, 40) ));
360  ATH_CHECK ( hbook( "/input/tau/", std::make_unique<TH1I>("eta","Tau eta ", 64, -3.2, 3.2) ));
361  ATH_CHECK ( hbook( "/input/tau/", std::make_unique<TH1I>("phi","Tau phi", 64, -3.2, 3.2) ));
362  ATH_CHECK ( hbook( "/input/tau/", std::make_unique<TH1I>("emIso","Tau em isolation", 40, 0, 1) ));
363  ATH_CHECK ( hbook( "/input/tau/", std::make_unique<TH1I>("hadIso","Tau hadronic isolation", 40, 0, 1) ));
364  ATH_CHECK ( hbook( "/input/tau/", std::make_unique<TH1I>("R3ET","Tau eT", 40, 0, 40) ));
365  ATH_CHECK ( hbook( "/input/tau/", std::make_unique<TH1I>("R3Iso","Tau isolation", 40, 0, 1) ));
366 
367  // input counts
368  ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("jJets","Number of jets (jJ)", 40, 0, 40) ));
369  ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("jLJets","Number of jets (jLJ)", 40, 0, 40) ));
370  ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("gJets","Number of jets (gJ)", 40, 0, 40) ));
371  ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("gLJets","Number of jets (gLJ)", 40, 0, 40) ));
372  ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("muons","Number of muons", 10, 0, 10) ));
373  ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("emcluster","Number of EM clusters", 20, 0, 20) ));
374  ATH_CHECK ( hbook( "/input/counts/", std::make_unique<TH1I>("taus","Number of TAU candidates", 20, 0, 20) ));
375 
376  // threshold multiplicities
377  ATH_CHECK ( createMultiplicityHist( "muon" ) );
378  ATH_CHECK ( createMultiplicityHist( "jet" ) );
379  ATH_CHECK ( createMultiplicityHist( "xe", 2) );
380  ATH_CHECK ( createMultiplicityHist( "te", 2) );
381  ATH_CHECK ( createMultiplicityHist( "xs", 2) );
382  ATH_CHECK ( createMultiplicityHist( "em" ) );
383  ATH_CHECK ( createMultiplicityHist( "tau" ) );
384 
385  ATH_CHECK ( hbook( "/multi/all", (std::unique_ptr<TH2>)std::make_unique<TH2I>("LegacyMult", "Legacy thresholds multiplicity", 1, 0, 1, 10, 0, 10) ));
386  ATH_CHECK ( hbook( "/multi/all", (std::unique_ptr<TH2>)std::make_unique<TH2I>("R3Mult", "New thresholds multiplicity", 1, 0, 1, 10, 0, 10) ));
387 
388  // Topo
389  ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("LegacyTopo0","L1Topo Decision (Legacy 0)", 64, 0, 64) ));
390  ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("LegacyTopo1","L1Topo Decision (Legacy 1)", 64, 0, 64) ));
391  ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo1El","L1Topo Decision (Topo 1 electrical)", 64, 0, 64) ));
392  ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo2El","L1Topo Decision (Topo 2 electrical)", 64, 0, 64) ));
393  ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo3El","L1Topo Decision (Topo 3 electrical)", 64, 0, 64) ));
394  ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo1Opt0","L1Topo Decision (Topo 1 optical 0)", 128, 0, 128) ));
395  ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo1Opt1","L1Topo Decision (Topo 1 optical 1)", 128, 0, 128) ));
396  ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo1Opt2","L1Topo Decision (Topo 1 optical 2)", 128, 0, 128) ));
397  ATH_CHECK( hbook( "/input/topo/", std::make_unique<TH1I>("Topo1Opt3","L1Topo Decision (Topo 1 optical 3)", 128, 0, 128) ));
398 
399  // item decision
400  ATH_CHECK ( hbook( "/output/", std::make_unique<TH1I>("tbpById", "Items decision (tbp)", 512, 0, 512) ));
401  ATH_CHECK ( hbook( "/output/", std::make_unique<TH1I>("tapById", "Items decision (tap)", 512, 0, 512) ));
402  ATH_CHECK ( hbook( "/output/", std::make_unique<TH1I>("tavById", "Items decision (tav)", 512, 0, 512) ));
403  ATH_CHECK ( hbook( "/output/", std::make_unique<TH1I>("tbpByName", "Items decision (tbp)", 512, 0, 512) ));
404  ATH_CHECK ( hbook( "/output/", std::make_unique<TH1I>("tapByName", "Items decision (tap)", 512, 0, 512) ));
405  ATH_CHECK ( hbook( "/output/", std::make_unique<TH1I>("tavByName", "Items decision (tav)", 512, 0, 512) ));
406 
407  ATH_CHECK ( hbook( "/", std::make_unique<TH1I>("bcid", "Bunch crossing ID", 3564, 0, 3564)) );
408 
409  ATH_CHECK(storeMetadata());
410 
411  return StatusCode::SUCCESS;
412 }
413 
415 LVL1CTP::CTPSimulation::fillInputHistograms(const EventContext& context) const {
416 
417  ATH_MSG_DEBUG( "fillInputHistograms" );
418 
419  // jFEX jets
420  if( not m_iKeyJFexJets.empty() ) {
421  auto jFexJets = SG::makeHandle( m_iKeyJFexJets, context );
422  if(jFexJets.isValid()) {
423  get1DHist("/input/counts/jJets")->Fill(jFexJets->size());
424  auto h0 = *get1DHist("/input/jets/jJetPt"); // calling operator* to get the Guard outside the filling loop
425  auto h1 = *get1DHist("/input/jets/jJetEta");
426  auto h2 = *get1DHist("/input/jets/jJetPhi");
427  for( const auto jet : *jFexJets ) {
428  h0->Fill(fabs(jet->et8x8()/1000.));
429  h1->Fill(jet->eta());
430  h2->Fill(jet->phi());
431  }
432  } else {
433  ATH_MSG_DEBUG("No collection " << m_iKeyJFexJets);
434  }
435  }
436 
437  // jFEX large-R jets
438  if( not m_iKeyJFexLJets.empty() ) {
439  auto jFexLJets = SG::makeHandle( m_iKeyJFexLJets, context );
440  if(jFexLJets.isValid()) {
441  get1DHist("/input/counts/jLets")->Fill(jFexLJets->size());
442  auto h0 = *get1DHist("/input/jets/jLJetPt");
443  auto h1 = *get1DHist("/input/jets/jLJetEta");
444  auto h2 = *get1DHist("/input/jets/jLJetPhi");
445  for( const auto jet : *jFexLJets ) {
446  h0->Fill(fabs(jet->et8x8()/1000.));
447  h1->Fill(jet->eta());
448  h2->Fill(jet->phi());
449  }
450  } else {
451  ATH_MSG_DEBUG("No collection " << m_iKeyJFexLJets);
452  }
453  } else {
454  ATH_MSG_DEBUG("No collection " << m_iKeyJFexLJets);
455  }
456 
457  // gFEX jets
458  if( not m_iKeyGFexJets.empty() ) {
459  auto gFexJets = SG::makeHandle( m_iKeyGFexJets, context );
460  if(gFexJets.isValid()) {
461  get1DHist("/input/counts/gJets")->Fill(gFexJets->size());
462  auto h0 = *get1DHist("/input/jets/gJetPt");
463  auto h1 = *get1DHist("/input/jets/gJetEta");
464  auto h2 = *get1DHist("/input/jets/gJetPhi");
465  for( const auto jet : *gFexJets ) {
466  h0->Fill(fabs(jet->et8x8()/1000.));
467  h1->Fill(jet->eta());
468  h2->Fill(jet->phi());
469  }
470  } else {
471  ATH_MSG_DEBUG("No collection " << m_iKeyGFexJets);
472  }
473  }
474 
475  // MET
476  if( not m_iKeyGFexMETNC.empty() ) {
477  auto gFexMETPufit = SG::makeHandle( m_iKeyGFexMETNC, context );
478  if( gFexMETPufit.isValid() ) {
479  get1DHist("/input/met/Pufit")->Fill(gFexMETPufit->energyT()/1000.);
480  get1DHist("/input/met/PufitPhi")->Fill(atan2(gFexMETPufit->energyX(), gFexMETPufit->energyY()));
481  } else {
482  ATH_MSG_DEBUG("No collection " << m_iKeyGFexMETNC);
483  }
484  }
485 
486  if( not m_iKeyGFexMETRho.empty() ) {
487  auto gFexMETRho = SG::makeHandle( m_iKeyGFexMETRho, context );
488  if( gFexMETRho.isValid() ) {
489  get1DHist("/input/met/Rho")->Fill(gFexMETRho->energyT()/1000.);
490  get1DHist("/input/met/RhoPhi")->Fill(atan2(gFexMETRho->energyX(), gFexMETRho->energyY()));
491  } else {
492  ATH_MSG_DEBUG("No collection " << m_iKeyGFexMETRho);
493  }
494  }
495 
496  if( not m_iKeyGFexMETJwoJ.empty() ) {
497  auto gFexMETJwoJ = SG::makeHandle( m_iKeyGFexMETJwoJ, context );
498  if( gFexMETJwoJ.isValid() ) {
499  get1DHist("/input/met/JwoJ")->Fill(gFexMETJwoJ->energyT()/1000.);
500  get1DHist("/input/met/JwoJPhi")->Fill(atan2(gFexMETJwoJ->energyX(), gFexMETJwoJ->energyY()));
501  } else {
502  ATH_MSG_DEBUG("No collection " << m_iKeyGFexMETJwoJ);
503  }
504  }
505 
506  // EM cluster
507  if( not m_iKeyEFexCluster.empty() ) {
508  auto eFexCluster = SG::makeHandle( m_iKeyEFexCluster, context );
509  if( eFexCluster.isValid() ) {
510  get1DHist( "/input/counts/emcluster")->Fill(eFexCluster->size());
511  auto h0 = *get1DHist("/input/em/et");
512  auto h1 = *get1DHist("/input/em/eta");
513  auto h2 = *get1DHist("/input/em/phi");
514  for( const auto cl : *eFexCluster ) {
515  h0->Fill(cl->et());
516  h1->Fill(cl->eta());
517  h2->Fill(cl->phi());
518  }
519  } else {
520  ATH_MSG_DEBUG("No collection " << m_iKeyEFexCluster);
521  }
522  }
523 
524  // eFEX Tau
525  if( not m_iKeyEFexTau.empty() ) {
526  auto eFexTau = SG::makeHandle( m_iKeyEFexTau, context );
527  if( eFexTau.isValid() ) {
528  get1DHist( "/input/counts/taus")->Fill(eFexTau->size());
529  auto h0 = *get1DHist("/input/tau/et");
530  auto h1 = *get1DHist("/input/tau/eta");
531  auto h2 = *get1DHist("/input/tau/phi");
532  auto h3 = *get1DHist("/input/tau/emIso");
533  auto h4 = *get1DHist("/input/tau/hadIso");
534  auto h5 = *get1DHist("/input/tau/R3ClusterET");
535  auto h6 = *get1DHist("/input/tau/R3ClusterIso");
536  const static SG::AuxElement::ConstAccessor<float> accR3ClET ("R3ClusterET");
537  const static SG::AuxElement::ConstAccessor<float> accR3ClIso ("R3ClusterIso");
538  for( const auto tau : *eFexTau ) {
539  h0->Fill(tau->eT());
540  h1->Fill(tau->eta());
541  h2->Fill(tau->phi());
542  h3->Fill(tau->emIsol());
543  h4->Fill(tau->hadIsol());
544  h5->Fill(accR3ClET(*tau)/1000.);
545  h6->Fill(accR3ClIso(*tau));
546  }
547  } else {
548  ATH_MSG_DEBUG("No collection " << m_iKeyEFexTau);
549  }
550  }
551 
552  // topo
553  if( not m_iKeyLegacyTopo.empty() && m_doL1CaloLegacy && m_doL1TopoLegacy ) {
554  auto legacyTopoInput = SG::makeHandle( m_iKeyLegacyTopo, context );
555  if(legacyTopoInput.isValid()) {
556  ATH_MSG_DEBUG("Retrieved input from L1Topo from StoreGate with key " << m_iKeyTopo);
557  ATH_MSG_DEBUG("L1TopoLegacy0 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << legacyTopoInput->cableWord1(0));
558  ATH_MSG_DEBUG("L1TopoLegacy0 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << legacyTopoInput->cableWord1(1));
559  ATH_MSG_DEBUG("L1TopoLegacy1 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << legacyTopoInput->cableWord2(0));
560  ATH_MSG_DEBUG("L1TopoLegacy1 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << legacyTopoInput->cableWord2(1));
561  auto h0 = *get1DHist("/input/topo/LegacyTopo0");
562  auto h1 = *get1DHist("/input/topo/LegacyTopo1");
563  for(unsigned int i=0; i<32; ++i) {
564  uint32_t mask = 0x1; mask <<= i;
565  if( (legacyTopoInput->cableWord1(0) & mask) != 0 ) h0->Fill(i); // cable 0, clock 0
566  if( (legacyTopoInput->cableWord1(1) & mask) != 0 ) h0->Fill(32 + i); // cable 0, clock 1
567  if( (legacyTopoInput->cableWord2(0) & mask) != 0 ) h1->Fill(i); // cable 1, clock 0
568  if( (legacyTopoInput->cableWord2(1) & mask) != 0 ) h1->Fill(32 + i); // cable 1, clock 1
569  }
570  }
571  }
572 
573  if( not m_iKeyTopo.empty() && m_doL1Topo ) {
574  auto topoInput = SG::makeHandle( m_iKeyTopo, context );
575  if(topoInput.isValid()) {
576  ATH_MSG_DEBUG("Retrieved input from L1Topo from StoreGate with key " << m_iKeyTopo);
577  ATH_MSG_DEBUG("L1Topo0 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord1(0));
578  ATH_MSG_DEBUG("L1Topo0 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord1(1));
579  ATH_MSG_DEBUG("L1Topo1 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord2(0));
580  ATH_MSG_DEBUG("L1Topo1 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << topoInput->cableWord2(1));
581  auto h0 = *get1DHist("/input/topo/Topo2El");
582  auto h1 = *get1DHist("/input/topo/Topo3El");
583  for(unsigned int i=0; i<32; ++i) {
584  uint32_t mask = 0x1; mask <<= i;
585  if( (topoInput->cableWord1(0) & mask) != 0 ) h0->Fill(i); // cable 0, clock 0
586  if( (topoInput->cableWord1(1) & mask) != 0 ) h0->Fill(32 + i); // cable 0, clock 1
587  if( (topoInput->cableWord2(0) & mask) != 0 ) h1->Fill(i); // cable 1, clock 0
588  if( (topoInput->cableWord2(1) & mask) != 0 ) h1->Fill(32 + i); // cable 1, clock 1
589  }
590  auto h2 = *get1DHist("/input/topo/Topo1Opt0");
591  auto h3 = *get1DHist("/input/topo/Topo1Opt1");
592  auto h4 = *get1DHist("/input/topo/Topo1Opt2");
593  auto h5 = *get1DHist("/input/topo/Topo1Opt3");
594  for(unsigned int i=0; i<128; i += 3) {
595  std::bitset<128> mask = 0x11; mask <<= i;
596  if( (topoInput->optcableWord("Topo1Opt0") & mask) != 0 ) h2->Fill(i); //
597  if( (topoInput->optcableWord("Topo1Opt1") & mask) != 0 ) h3->Fill(i); //
598  if( (topoInput->optcableWord("Topo1Opt2") & mask) != 0 ) h4->Fill(i); //
599  if( (topoInput->optcableWord("Topo1Opt3") & mask) != 0 ) h5->Fill(i); //
600  }
601  } else {
602  ATH_MSG_DEBUG("No collection " << m_iKeyTopo);
603  }
604  }
605 
606  // bcid
607  auto bcid = context.eventID().bunch_crossing_id();
608  get1DHist( "/bcid")->Fill(bcid);
609 
610  return StatusCode::SUCCESS;
611 }
612 
614 LVL1CTP::CTPSimulation::extractMultiplicities(std::map<std::string, unsigned int> & thrMultiMap, const EventContext& context) const {
615 
616  const TrigConf::L1Menu * l1menu = nullptr;
618 
619  thrMultiMap.clear();
620 
621  std::vector<std::string> connNames = l1menu->connectorNames();
622  for (const std::string connName : {"LegacyTopo0", "LegacyTopo1", "Topo1El", "Topo2El", "Topo3El", "Topo1Opt0", "Topo1Opt1", "Topo1Opt2", "Topo1Opt3", "CTPCAL", "NIM2"})
623  {
624  if( find(connNames.begin(), connNames.end(), connName) == connNames.end() ) {
625  continue;
626  }
627  bool opt_cable = false;
628  std::bitset<128> cable128 {0};
629  uint64_t cable {0};
630  if (connName.starts_with( "Legacy")) { // legacy topo
631  if (m_iKeyLegacyTopo.empty() || !m_doL1CaloLegacy || !m_doL1TopoLegacy )
632  {
633  continue;
634  }
635  auto topoInput = SG::makeHandle( m_iKeyLegacyTopo, context );
636  if (not topoInput.isValid()) {
637  continue;
638  }
639  if(connName == "LegacyTopo0") {
640  cable = ( (uint64_t)topoInput->cableWord1( 1 ) << 32) + topoInput->cableWord1( 0 );
641  } else if (connName == "LegacyTopo1") {
642  cable = ( (uint64_t)topoInput->cableWord2( 1 ) << 32) + topoInput->cableWord2( 0 );
643  }
644  }
645  else if (connName.starts_with( "CTPCAL") && m_doZDC) // ZDC simulation
646  {
647  auto zdcInput = SG::makeHandle(m_iKeyZDC, context);
648  if (not zdcInput.isValid())
649  {
650  continue;
651  }
652  cable = static_cast<uint64_t>(zdcInput->cableWord0());
653  auto &conn = l1menu->connector(connName);
654  for (auto &tl : conn.triggerLines()){
655  if (tl.name().find("ZDC") == std::string::npos)
656  {
657  continue;
658  }
659  uint flatIndex = tl.flatindex();
660  uint pass = (cable & (uint64_t(0x1) << flatIndex)) == 0 ? 0 : 1;
661  thrMultiMap[tl.name()] = pass;
662  ATH_MSG_DEBUG(tl.name() << " MULT calculated mult for topo " << pass);
663 
664  }
665  continue;
666  }
667  else if (connName.starts_with( "NIM2"))
668  {
669  if (m_doTRT) // TRT simulation
670  {
671  auto trtInput = SG::makeHandle(m_iKeyTRT, context);
672  if (not trtInput.isValid())
673  {
674  continue;
675  }
676  cable = static_cast<uint64_t>(trtInput->cableWord0());
677  auto &conn = l1menu->connector(connName);
678  for (auto &tl : conn.triggerLines()){
679  if (tl.name().find("TRT") == std::string::npos)
680  {
681  continue;
682  }
683  uint flatIndex = tl.flatindex();
684  uint pass = (cable & (uint64_t(0x1) << flatIndex)) == 0 ? 0 : 1;
685  thrMultiMap[tl.name()] = pass;
686  ATH_MSG_DEBUG(tl.name() << " MULT calculated mult for topo " << pass);
687  }
688  }
689  if (m_doZDC) // ZDC ALT simulation
690  {
691  auto zdcInput = SG::makeHandle(m_iKeyZDC, context);
692  if (not zdcInput.isValid())
693  {
694  continue;
695  }
696  cable = static_cast<uint64_t>(zdcInput->cableWord1());
697  auto &conn = l1menu->connector(connName);
698  for (const auto &tl : conn.triggerLines()){
699  if (tl.name().find("ZDC") == std::string::npos)
700  {
701  continue;
702  }
703  uint flatIndex = tl.flatindex();
704  uint pass = (cable & (uint64_t(0x1) << flatIndex)) == 0 ? 0 : 1;
705  thrMultiMap[tl.name()] = pass;
706  ATH_MSG_DEBUG(tl.name() << " MULT calculated mult for topo " << pass);
707  }
708  }
709  continue;
710  }
711 
712  else { // new topo
713  if (m_iKeyTopo.empty() || !m_doL1Topo )
714  {
715  continue;
716  }
717  auto topoInput = SG::makeHandle( m_iKeyTopo, context );
718  if (not topoInput.isValid()) {
719  continue;
720  }
721  if(connName == "Topo1El") {
722  cable = ( (uint64_t)topoInput->cableWord0( 1 ) << 32) + topoInput->cableWord0( 0 );
723  } else if(connName == "Topo2El") {
724  cable = ( (uint64_t)topoInput->cableWord1( 1 ) << 32) + topoInput->cableWord1( 0 );
725  } else if (connName == "Topo3El") {
726  cable = ( (uint64_t)topoInput->cableWord2( 1 ) << 32) + topoInput->cableWord2( 0 );
727  } else if(connName == "Topo1Opt0") {
728  ATH_MSG_DEBUG("BIT word Topo1Opt0: " << topoInput->optcableWord( connName ));
729  opt_cable = true;
730  cable128 = topoInput->optcableWord( connName );
731  } else if(connName == "Topo1Opt1") {
732  ATH_MSG_DEBUG("BIT word Topo1Opt1: " << topoInput->optcableWord( connName ));
733  opt_cable = true;
734  cable128 = topoInput->optcableWord( connName );
735  } else if(connName == "Topo1Opt2") {
736  ATH_MSG_DEBUG("BIT word Topo1Opt2: " << topoInput->optcableWord( connName ));
737  opt_cable = true;
738  cable128 = topoInput->optcableWord( connName );
739  } else if(connName == "Topo1Opt3") {
740  ATH_MSG_DEBUG("BIT word Topo1Opt3: " << topoInput->optcableWord( connName ));
741  opt_cable = true;
742  cable128 = topoInput->optcableWord( connName );
743  }
744  }
745  auto & conn = l1menu->connector(connName);
746  for(uint fpga : {0,1}) {
747  for(uint clock : {0,1}) {
748  for(auto & tl : conn.triggerLines(fpga,clock)) {
749  uint flatIndex = tl.flatindex();
750  uint pass = 0;
751  if (opt_cable) {
752  pass = ((cable128 >> flatIndex).test(0)) == 0 ? 0 : 1;
753  }
754  else {
755  pass = (cable & (static_cast<uint64_t>(0x1) << flatIndex)) == 0 ? 0 : 1;
756  }
757  if(size_t pos = tl.name().find('['); pos == std::string::npos) {
758  thrMultiMap[tl.name()] = pass;
759  ATH_MSG_DEBUG(tl.name() << " MULT calculated mult for topo " << pass);
760  } else {
761  auto thrName = tl.name().substr(0,pos);
762  int bit = std::stoi(tl.name().substr(pos+1));
763  thrMultiMap.try_emplace(thrName, 0);
764  thrMultiMap[thrName] += (pass << bit);
765  ATH_MSG_DEBUG(thrName << " MULT updated mult for topo " << pass);
766  }
767  }
768  }
769  }
770  }
771  for ( auto & thr : l1menu->thresholds() ) {
772  if (thr->type() == "TOPO" or thr->type() == "MULTTOPO" or thr->type() == "MUTOPO")
773  {
774  continue;
775  }
776  if( thr->type() == "ZDC" && m_doZDC ){
777  continue;
778  }
779  if( thr->name() == "NIMTRT" && m_doTRT ){
780  continue;
781  }
782  // get the multiplicity for each threshold
783  unsigned int multiplicity = calculateMultiplicity(*thr, l1menu, context);
784  // and record in threshold--> multiplicity map (to be used for item decision)
785  thrMultiMap[thr->name()] = multiplicity;
786  ATH_MSG_DEBUG( thr->name() << " MULT calculated mult for topo " << multiplicity);
787  }
788 
789  // internal triggers
790  auto bcid = context.eventID().bunch_crossing_id();
791  if( m_forceBunchGroupPattern ) {
792  // force bunch group pattern from job options
793  for ( size_t bg = 0; bg < 16; ++bg ) {
794  std::string bgName("BGRP");
795  bgName += std::to_string(bg);
796  thrMultiMap[bgName] = ( m_bunchGroupPattern & (0x1<<bg) ) ? 1 : 0;
797  }
798  } else {
799  // use bunchgroup definition from configuration and pick according to the BCID
800  SG::ReadCondHandle<TrigConf::L1BunchGroupSet> bgkey(m_bgKey, context);
801  ATH_CHECK(bgkey.isValid());
802  const TrigConf::L1BunchGroupSet *l1bgs = *bgkey;
803  if (l1bgs)
804  {
805  for (size_t i = 0; i < l1bgs->maxNBunchGroups(); ++i)
806  {
807  std::shared_ptr<TrigConf::L1BunchGroup> bg = l1bgs->getBunchGroup(i);
808  thrMultiMap[std::string("BGRP") + std::to_string(i)] = bg->contains(bcid) ? 1 : 0;
809  }
810  }
811  else
812  {
813  ATH_MSG_ERROR("Did not find L1BunchGroupSet in DetectorStore");
814  }
815  }
816 
817  // all RNDM triggers run with 40MHz, so they are always in
818  thrMultiMap["RNDM0"] = 1;
819  thrMultiMap["RNDM1"] = 1;
820  thrMultiMap["RNDM2"] = 1;
821  thrMultiMap["RNDM3"] = 1;
822 
823  return StatusCode::SUCCESS;
824 }
825 
826 
827 unsigned int
828 LVL1CTP::CTPSimulation::calculateJetMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const {
829  unsigned int multiplicity = 0;
830  if( confThr.type() == "JET" ) {
831  if(m_doL1CaloLegacy) {
832  auto ctpinJet = SG::makeHandle( m_iKeyCtpinJet, context );
833  if ( ctpinJet.isValid() ) {
834  if( l1menu->connector("JET1").hasLine(confThr.name()) ) {
835  auto & triggerline = l1menu->connector("JET1").triggerLine(confThr.name());
836  multiplicity = CTPUtil::getMult( ctpinJet->cableWord0(), triggerline.startbit(), triggerline.endbit() );
837  } else if( l1menu->connector("JET2").hasLine(confThr.name()) ) {
838  auto & triggerline = l1menu->connector("JET2").triggerLine(confThr.name());
839  multiplicity = CTPUtil::getMult( ctpinJet->cableWord1(), triggerline.startbit(), triggerline.endbit() );
840  }
841  }
842  }
843  }
844  get2DHist( "/multi/jet/" + confThr.type() + "Mult" )->Fill(confThr.mapping(), multiplicity);
845  ATH_MSG_DEBUG("JET MULT calculated mult for threshold " << confThr.name() << " : " << multiplicity);
846  return multiplicity;
847 }
848 
849 
850 unsigned int
851 LVL1CTP::CTPSimulation::calculateEMMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const {
852  unsigned int multiplicity (0);
853  if ( confThr.name()[0]=='e' ) {
854  // new EM threshold from eFEX
855  if(!m_iKeyEFexCluster.empty()) {
856  float scale = l1menu->getObject("thresholds.legacyCalo.EM.emscale").getValue<float>();
857  auto eFexCluster = SG::makeHandle( m_iKeyEFexCluster, context );
858  for ( const auto cl : *eFexCluster ) {
859  float eta = cl->eta();
860  int ieta = int((eta + (eta>0 ? 0.005 : -0.005))/0.1);
861  unsigned int thrV = confThr.thrValue( ieta );
862  bool clusterPasses = ( ((unsigned int) cl->et()) > (thrV * scale) ); // need to add cut on isolation and other variables, once available
863  multiplicity += clusterPasses ? 1 : 0;
864  }
865  }
866  } else {
867  // old EM threshold from data
868  if(m_doL1CaloLegacy) {
869  auto ctpinEM = SG::makeHandle( m_iKeyCtpinEM, context );
870  if ( ctpinEM.isValid() ) {
871  if( l1menu->connector("EM1").hasLine(confThr.name()) ) {
872  auto & triggerline = l1menu->connector("EM1").triggerLine(confThr.name());
873  multiplicity = CTPUtil::getMult( ctpinEM->cableWord0(), triggerline.startbit(), triggerline.endbit() );
874  } else if( l1menu->connector("EM2").hasLine(confThr.name()) ) {
875  auto & triggerline = l1menu->connector("EM2").triggerLine(confThr.name());
876  multiplicity = CTPUtil::getMult( ctpinEM->cableWord1(), triggerline.startbit(), triggerline.endbit() );
877  }
878  }
879  }
880  }
881  get2DHist( "/multi/em/" + confThr.type() + "Mult" )->Fill(confThr.mapping(), multiplicity);
882  ATH_MSG_DEBUG("EM MULT calculated mult for threshold " << confThr.name() << " : " << multiplicity);
883  return multiplicity;
884 }
885 
886 
887 unsigned int
888 LVL1CTP::CTPSimulation::calculateTauMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const {
889  unsigned int multiplicity = 0;
890  if ( confThr.name()[0]=='e' ) {
891  // new TAU threshold from eFEX
892  auto eFexTaus = SG::makeHandle( m_iKeyEFexTau, context );
893  const static SG::AuxElement::ConstAccessor<float> accR3ClET ("R3ClusterET");
894  const static SG::AuxElement::ConstAccessor<float> accR3ClIso ("R3ClusterIso");
895  if( eFexTaus.isValid() ) {
896  for ( const auto tau : *eFexTaus ) {
897  unsigned int eT = (unsigned int) (accR3ClET(*tau)/1000.); // tau eT is in MeV while the cut is in GeV - this is only temporary and needs to be made consistent for all L1Calo
898  //float iso = accR3ClIso(*tau);
899  unsigned int etCut = confThr.data().get_child("et").get_value<unsigned int>();
900  bool tauPasses = ( eT >= etCut ); // need to add cut on isolation and other variables, once available
901  multiplicity += tauPasses ? 1 : 0;
902  }
903  }
904  } else {
905  // old TAU threshold
906  if(m_doL1CaloLegacy) {
907  auto ctpinEM = SG::makeHandle( m_iKeyCtpinEM, context );
908  if ( ctpinEM.isValid() ) {
909  if( l1menu->connector("TAU1").hasLine(confThr.name()) ) {
910  auto & triggerline = l1menu->connector("TAU1").triggerLine(confThr.name());
911  multiplicity = CTPUtil::getMult( ctpinEM->cableWord2(), triggerline.startbit(), triggerline.endbit() );
912  } else if( l1menu->connector("TAU2").hasLine(confThr.name()) ) {
913  auto & triggerline = l1menu->connector("TAU2").triggerLine(confThr.name());
914  multiplicity = CTPUtil::getMult( ctpinEM->cableWord3(), triggerline.startbit(), triggerline.endbit() );
915  }
916  }
917  }
918  }
919  get2DHist( "/multi/tau/" + confThr.type() + "Mult" )->Fill(confThr.mapping(), multiplicity);
920  ATH_MSG_DEBUG("TAU MULT calculated mult for threshold " << confThr.name() << " : " << multiplicity);
921  return multiplicity;
922 }
923 
924 
925 unsigned int
926 LVL1CTP::CTPSimulation::calculateMETMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const {
927  unsigned int multiplicity = 0;
928  if ( confThr.type() == "XE" or confThr.type() == "TE" or confThr.type() == "XS" ) {
929  // old XE, TE, XS
930  if(m_doL1CaloLegacy) {
931  auto ctpinEnergy = SG::makeHandle( m_iKeyCtpinXE, context );
932  if ( ctpinEnergy.isValid() ) {
933  if( l1menu->connector("EN1").hasLine(confThr.name()) ) {
934  auto & triggerline = l1menu->connector("EN1").triggerLine(confThr.name());
935  multiplicity = CTPUtil::getMult( ctpinEnergy->cableWord0(), triggerline.startbit(), triggerline.endbit() );
936  } else if( l1menu->connector("EN2").hasLine(confThr.name()) ) {
937  auto & triggerline = l1menu->connector("EN2").triggerLine(confThr.name());
938  multiplicity = CTPUtil::getMult( ctpinEnergy->cableWord1(), triggerline.startbit(), triggerline.endbit() );
939  }
940  }
941  }
942  } else {
943  // new XE
944  const SG::ReadHandleKey< xAOD::EnergySumRoI > * rhk { nullptr };
945  if ( confThr.name().find("gXENC")==0 ) {
946  rhk = & m_iKeyGFexMETNC;
947  ATH_MSG_DEBUG("Using Pufit input for threshold " << confThr.name() );
948  } else if ( confThr.name().find("gXERHO")==0 ) {
949  rhk = & m_iKeyGFexMETRho;
950  ATH_MSG_DEBUG("Using Rho input for threshold " << confThr.name() );
951  } else if ( confThr.name().find("gXEJWOJ")==0 ) {
952  rhk = & m_iKeyGFexMETJwoJ;
953  ATH_MSG_DEBUG("Using JwoJ input for threshold " << confThr.name() );
954  } else {
955  rhk = & m_iKeyGFexMETJwoJ;
956  ATH_MSG_DEBUG("Using default input JwoJ for threshold " << confThr.name() );
957  }
958  if(!rhk->empty()) {
959  auto met = SG::makeHandle( *rhk, context );
960  multiplicity = ( met->energyT()/1000. < confThr.getAttribute<unsigned int>("xe") ) ? 0 : 1; // energyT value is in MeV, cut in GeV
961  }
962  }
963  if(confThr.type() == "TE") {
964  get2DHist( "/multi/te/" + confThr.type() + "Mult" )->Fill(confThr.mapping(), multiplicity);
965  ATH_MSG_DEBUG("TE MULT calculated mult for threshold " << confThr.name() << " : " << multiplicity);
966  } else if(confThr.type() == "XS") {
967  get2DHist( "/multi/xs/" + confThr.type() + "Mult" )->Fill(confThr.mapping(), multiplicity);
968  ATH_MSG_DEBUG("XS MULT calculated mult for threshold " << confThr.name() << " : " << multiplicity);
969  } else {
970  get2DHist( "/multi/xe/" + confThr.type() + "Mult" )->Fill(confThr.mapping(), multiplicity);
971  ATH_MSG_DEBUG("XE MULT calculated mult for threshold " << confThr.name() << " : " << multiplicity);
972  }
973  return multiplicity;
974 }
975 
976 
977 unsigned int
978 LVL1CTP::CTPSimulation::calculateMuonMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const {
979  if(m_iKeyMuctpi.empty()) {
980  return 0;
981  }
982  unsigned int multiplicity = 0;
983  auto ctpinMuon = SG::makeHandle( m_iKeyMuctpi, context );
984  if ( ctpinMuon.isValid() ) {
985  auto & triggerline = l1menu->connector("MuCTPiOpt0").triggerLine(confThr.name());
986  multiplicity = CTPUtil::getMuonMult( ctpinMuon->muCTPIWord(), triggerline.startbit() + (m_muonRun2Format ? 1 : 0), triggerline.endbit()+ (m_muonRun2Format ? 1 : 0) );
987  }
988  get2DHist( "/multi/muon/" + confThr.type() + "Mult" )->Fill(confThr.mapping(), multiplicity);
989  ATH_MSG_DEBUG("MU MULT calculated mult for threshold " << confThr.name() << " : " << multiplicity);
990  return multiplicity;
991 }
992 
993 
994 unsigned int
995 LVL1CTP::CTPSimulation::calculateTopoOptMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const {
996  if(m_iKeyTopo.empty() || !m_doL1Topo ) {
997  return 0;
998  }
999  unsigned int multiplicity = 0;
1000  auto topoInput = SG::makeHandle( m_iKeyTopo, context );
1001  std::string connector = "";
1002  if (topoInput.isValid()) {
1003  connector = l1menu->connectorNameFromThreshold(confThr.name());
1004  auto & triggerline = l1menu->connector(connector).triggerLine(confThr.name());
1005  std::bitset<128> bits = topoInput->optcableWord(connector);
1006  multiplicity = CTPUtil::getOptMult( bits, triggerline.startbit(), triggerline.endbit() );
1007  }
1008  std::string subfolder = "";
1009  if (confThr.type().find("XE") != std::string::npos) {
1010  subfolder = "xe";
1011  } else if (confThr.type().find("TE") != std::string::npos) {
1012  subfolder = "te";
1013  } else if (confThr.type().find("TAU") != std::string::npos) {
1014  subfolder = "tau";
1015  } else if (confThr.type().find("EM") != std::string::npos) {
1016  subfolder = "em";
1017  } else if (confThr.type().find("jJ") != std::string::npos) {
1018  subfolder = "jet";
1019  } else if (confThr.type().find("jLJ") != std::string::npos) {
1020  subfolder = "jet";
1021  } else if (confThr.type().find("gJ") != std::string::npos) {
1022  subfolder = "jet";
1023  } else if (confThr.type().find("gLJ") != std::string::npos) {
1024  subfolder = "jet";
1025  }
1026  get2DHist( "/multi/" + subfolder + "/" + confThr.type() + "Mult" )->Fill(confThr.mapping(), multiplicity);
1027  ATH_MSG_DEBUG("TOPO OPT input MULT calculated mult for threshold " << confThr.name() << " : " << multiplicity << " received via connector: " << connector);
1028  //ATH_MSG_INFO("TOPO OPT input MULT calculated mult for threshold " << confThr.name() << " : " << multiplicity << " received via connector: " << connector);
1029  return multiplicity;
1030 }
1031 
1032 
1033 unsigned int
1034 LVL1CTP::CTPSimulation::calculateTopoMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context, bool UseLegacy = false ) const {
1035  unsigned int multiplicity = 0;
1036  if(UseLegacy){
1037  if (m_iKeyLegacyTopo.empty() || !m_doL1TopoLegacy )
1038  {
1039  return 0;
1040  }
1041  multiplicity = 0;
1042  auto topoInput = SG::makeHandle( m_iKeyTopo, context );
1043  if(topoInput.isValid()) {
1044  uint64_t cable = 0;
1045  std::string conn("");
1046  if( l1menu->connector("LegacyTopo0").hasLine(confThr.name()) ) {
1047  conn = "LegacyTopo0";
1048  cable = ( (uint64_t)topoInput->cableWord1( 1 ) << 32) + topoInput->cableWord1( 0 );
1049  } else if( l1menu->connector("LegacyTopo1").hasLine(confThr.name()) ) {
1050  conn = "LegacyTopo1";
1051  cable = ( (uint64_t)topoInput->cableWord2( 1 ) << 32) + topoInput->cableWord2( 0 );
1052  }
1053  if(conn != "") {
1054  auto & triggerline = l1menu->connector(conn).triggerLine(confThr.name());
1055  ATH_MSG_DEBUG( " ---> Topo input " << confThr.name() << " on module " << conn
1056  << ", cable start " << triggerline.startbit() << " and end " << triggerline.endbit()
1057  << " double word 0x" << std::setw(16) << std::setfill('0') << std::hex << cable << std::dec << std::setfill(' ') );
1058  multiplicity = CTPUtil::getMultTopo( cable, triggerline.startbit(), triggerline.endbit(), triggerline.clock() );
1059  }
1060  }
1061  }
1062  else{
1063  if (m_iKeyTopo.empty() || !m_doL1Topo )
1064  {
1065  return 0;
1066  }
1067  multiplicity = 0;
1068  auto topoInput = SG::makeHandle( m_iKeyTopo, context );
1069  if(topoInput.isValid()) {
1070  uint64_t cable = 0;
1071  std::string conn("");
1072  if( l1menu->connector("Topo2El").hasLine(confThr.name()) ) {
1073  conn = "Topo2El";
1074  cable = ( (uint64_t)topoInput->cableWord1( 1 ) << 32) + topoInput->cableWord1( 0 );
1075  } else if( l1menu->connector("Topo3El").hasLine(confThr.name()) ) {
1076  conn = "Topo3El";
1077  cable = ( (uint64_t)topoInput->cableWord2( 1 ) << 32) + topoInput->cableWord2( 0 );
1078  }
1079  if(conn != "") {
1080  auto & triggerline = l1menu->connector(conn).triggerLine(confThr.name());
1081  ATH_MSG_DEBUG( " ---> Topo input " << confThr.name() << " on module " << conn
1082  << ", cable start " << triggerline.startbit() << " and end " << triggerline.endbit()
1083  << " double word 0x" << std::setw(16) << std::setfill('0') << std::hex << cable << std::dec << std::setfill(' ') );
1084  multiplicity = CTPUtil::getMultTopo( cable, triggerline.startbit(), triggerline.endbit(), triggerline.clock() );
1085  }
1086  }
1087  }
1088  return multiplicity;
1089 }
1090 
1091 
1092 unsigned int
1093 LVL1CTP::CTPSimulation::calculateMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const {
1094  unsigned int multiplicity = 0;
1095  try {
1096  if ( confThr.type() == "EM" ) {
1097  multiplicity = calculateEMMultiplicity( confThr, l1menu, context );
1098  } else if ( confThr.type() == "TAU" ) {
1099  multiplicity = calculateTauMultiplicity( confThr, l1menu, context );
1100  } else if ( confThr.type() == "XE" || confThr.type() == "TE" || confThr.type() == "XS" ) {
1101  multiplicity = calculateMETMultiplicity( confThr, l1menu, context );
1102  } else if ( confThr.type() == "JET" ) {
1103  multiplicity = calculateJetMultiplicity( confThr, l1menu, context );
1104  } else if ( confThr.type() == "MU" ) {
1105  multiplicity = calculateMuonMultiplicity( confThr, l1menu, context );
1106  } else if ( confThr.type() == "R2TOPO") {
1107  multiplicity = calculateTopoMultiplicity( confThr, l1menu, context, true );
1108  } else if ( confThr.type() == "TOPO" ) {
1109  multiplicity = calculateTopoMultiplicity( confThr, l1menu, context, m_doL1TopoLegacy);
1110  } else if ( confThr.type()[0] == 'e' || confThr.type()[0] == 'c' || confThr.type()[0] == 'j' || confThr.type()[0] == 'g' ){
1111  multiplicity = calculateTopoOptMultiplicity( confThr, l1menu, context );
1112  }
1113  }
1114  catch(std::exception & ex) {
1115  ATH_MSG_FATAL("Caught exception when calculating multiplicity for threshold " << confThr.name() << ": " << ex.what());
1116  throw;
1117  }
1118  // all other thresholds are not simulated
1119  return multiplicity;
1120 }
1121 
1122 StatusCode
1123 LVL1CTP::CTPSimulation::simulateItems(const std::map<std::string, unsigned int> & thrMultiMap,
1124  const EventContext& context) const
1125 {
1126 
1127  std::vector<uint32_t> tip;
1128  CHECK( m_resultBuilder->constructTIPVector( thrMultiMap, tip ) );
1129 
1130  std::map<std::string, unsigned int> itemDecisionMap;
1131  CLHEP::HepRandomEngine* rndmEngine = m_RNGEngines.getEngine( context );
1132  CHECK( m_resultBuilder->buildItemDecision(thrMultiMap, itemDecisionMap, rndmEngine) );
1133 
1134  std::vector<uint32_t> tbp;
1135  std::vector<uint32_t> tap;
1136  std::vector<uint32_t> tav;
1137  unsigned char triggerType(0);
1138  CHECK( m_resultBuilder->constructResultVectors( itemDecisionMap, tbp, tap, tav, triggerType ) );
1139 
1140  // Create a fixed vector of 6 extra words to allow for inserting prescale change information
1141  // when running a partition with preloaded data, see ATR-24654
1142  const std::vector<uint32_t> extra(size_t{6}, uint32_t{0});
1143 
1144  auto eventID = context.eventID();
1145  std::unique_ptr<CTP_RDO> rdo = m_resultBuilder->constructRDOResult( eventID, tbp, tap, tav, tip, extra );
1146  std::unique_ptr<CTPSLink> roi = m_resultBuilder->constructRoIResult( eventID, tbp, tap, tav, tip, extra, triggerType );
1147 
1148  // create CTP output format and store in the event
1149  auto rdoWriteHandle = SG::makeHandle( m_oKeyRDO, context );
1150  auto sLinkWriteHandle = SG::makeHandle( m_oKeySLink, context );
1151  ATH_CHECK( rdoWriteHandle.record( std::move(rdo) ));
1152  ATH_CHECK( sLinkWriteHandle.record( std::move(roi) ));
1153 
1154  // fill histograms with item simulation results
1155  {
1156  auto tbpById = *get1DHist( "/output/tbpById" );
1157  auto tapById = *get1DHist( "/output/tapById" );
1158  auto tavById = *get1DHist( "/output/tavById" );
1159  for( unsigned int ctpId= 0; ctpId < 512; ++ctpId ) {
1160  unsigned int wordNr = ctpId / 32;
1161  unsigned int posWithinWord = ctpId % 32;
1162  auto mask = 1L << posWithinWord;
1163  if( 0 != (tbp[wordNr] & mask) ) {
1164  tbpById->Fill( ctpId );
1165  }
1166  if( 0 != (tap[wordNr] & mask) ) {
1167  tapById->Fill( ctpId );
1168  }
1169  if( 0 != (tav[wordNr] & mask) ) {
1170  tavById->Fill( ctpId );
1171  }
1172  }
1173  }
1174  return StatusCode::SUCCESS;
1175 }
1176 
1177 
1178 StatusCode
1180 
1181  const TrigConf::L1Menu * l1menu = nullptr;
1183 
1184  constexpr unsigned int sizeOfCTPOutput = 512;
1185 
1186  unsigned int tbp[sizeOfCTPOutput];
1187  unsigned int tap[sizeOfCTPOutput];
1188  unsigned int tav[sizeOfCTPOutput];
1189  {
1190  auto h = *get1DHist( "/output/tbpById" );
1191  for( unsigned int id = 0; id < sizeOfCTPOutput; ++id ) tbp[id] = h->GetBinContent(id+1);
1192  }
1193  {
1194  auto h = *get1DHist( "/output/tapById" );
1195  for( unsigned int id = 0; id < sizeOfCTPOutput; ++id ) tap[id] = h->GetBinContent(id+1);
1196  }
1197  {
1198  auto h = *get1DHist( "/output/tavById" );
1199  for( unsigned int id = 0; id < sizeOfCTPOutput; ++id ) tav[id] = h->GetBinContent(id+1);
1200  }
1201 
1202  // fill the byName TAV histograms from the byID ones
1203  {
1204  auto htbp = *get1DHist( "/output/tbpByName" );
1205  auto htap = *get1DHist( "/output/tapByName" );
1206  auto htav = *get1DHist( "/output/tavByName" );
1207  for( auto & item : *l1menu ) {
1208  unsigned int ctpId = item.ctpId();
1209  htbp->Fill( item.name().c_str(), tbp[ctpId]);
1210  htap->Fill( item.name().c_str(), tap[ctpId]);
1211  htav->Fill( item.name().c_str(), tav[ctpId]);
1212  }
1213  htbp->Sumw2(0);
1214  htap->Sumw2(0);
1215  htav->Sumw2(0);
1216  htbp->LabelsDeflate();
1217  htap->LabelsDeflate();
1218  htav->LabelsDeflate();
1219 
1220  }
1221 
1222  // fill the threshold summary hists
1223  {
1224  // run 2 thresholds (legacy + muon)
1225  std::vector<std::string> thrHists{ "em/EM", "muon/MU", "tau/TAU", "jet/JET", "xe/XE", "te/TE", "xs/XS" };
1226  auto hist = * get2DHist( "/multi/all/LegacyMult" );
1227  for(const std::string & histpath : thrHists) {
1228  auto h = * get2DHist( "/multi/" + histpath + "Mult" );
1229  auto xaxis = h->GetXaxis();
1230  size_t xsize = xaxis->GetNbins();
1231  size_t ysize = h->GetNbinsY();
1232  for(size_t x = 1; x<xsize; x++) {
1233  std::string s("");
1234  for(size_t y = 1; y<=ysize; y++) {
1235  size_t binContent = h->GetBinContent(x,y);
1236  hist->Fill(xaxis->GetBinLabel(x),y-1,binContent);
1237  s += std::to_string(binContent) + " ";
1238  }
1239  ATH_MSG_DEBUG( "REGTEST CTPSim " << xaxis->GetBinLabel(x) << " MULT " << s);
1240  }
1241  }
1242  hist->Sumw2(0);
1243  hist->LabelsDeflate();
1244  }
1245  {
1246  // run 3 thresholds
1247  auto hist = * get2DHist( "/multi/all/R3Mult" );
1248  std::vector<std::string> thrHists = { "em/eEM", "em/jEM", "muon/MU", "tau/eTAU", "tau/jTAU", "tau/cTAU", "jet/jJ", "jet/jLJ", "jet/gJ", "jet/gLJ", "xe/gXE", "xe/jXE", "te/jTE", "te/gTE" };
1249  for(const std::string & histpath : thrHists) {
1250  auto h = * get2DHist( "/multi/" + histpath + "Mult" );
1251  auto xaxis = h->GetXaxis();
1252  size_t xsize = xaxis->GetNbins();
1253  size_t ysize = h->GetNbinsY();
1254  for(size_t x = 1; x<=xsize; x++) {
1255  std::string s("");
1256  for(size_t y = 1; y<=ysize; y++) {
1257  size_t binContent = h->GetBinContent(x,y);
1258  hist->Fill(xaxis->GetBinLabel(x) ,y-1, binContent);
1259  s += std::to_string(binContent) + " ";
1260  }
1261  ATH_MSG_DEBUG( "REGTEST CTPSim " << xaxis->GetBinLabel(x) << " MULT " << s);
1262  }
1263  }
1264  hist->Sumw2(0);
1265  hist->LabelsDeflate();
1266  }
1267 
1268  if ( msgLvl(MSG::DEBUG) ) {
1269  for( auto & item : *l1menu ) {
1270  ATH_MSG_DEBUG( "REGTEST CTPSim " << item.name() << " " << item.ctpId() <<
1271  " TBP " << tbp[item.ctpId()] <<
1272  " TAP " << tap[item.ctpId()] <<
1273  " TAV " << tav[item.ctpId()]);
1274  }
1275  }
1276  return StatusCode::SUCCESS;
1277 }
1278 
1279 /*
1280  stores metadata for all histograms to provide merging information
1281  adapted from @c HistogramFiller/OfflineHistogramProvider.h
1282 */
1283 StatusCode
1285  std::vector<std::string> storedPaths;
1286  for( auto & entry : m_hist1D ) {
1287  storedPaths.push_back( getBaseHistPath() + entry.first);
1288  }
1289  for( auto & entry : m_hist2D ) {
1290  storedPaths.push_back( getBaseHistPath() + entry.first);
1291  }
1292  std::scoped_lock<std::mutex> metadataLock(s_metadataMutex);
1293  for (const auto & path : storedPaths) {
1294  size_t pos = path.find_last_of('/');
1295  auto splitPath = std::make_pair(path.substr(0, pos), path.substr(pos + 1));
1296  std::string treePath = splitPath.first + "/metadata";
1297  std::string interval("run");
1298  char triggerData[] = "<none>";
1299  const std::string mergeDataStr = "<default>";
1300  std::vector<char> mergeData{mergeDataStr.begin(), mergeDataStr.end()};
1301  mergeData.push_back('\0');
1302  interval = "run";
1303  if (!m_histSvc->existsTree(treePath)) {
1304  auto tree = std::make_unique<TTree>("metadata", "Monitoring Metadata");
1305  tree->SetDirectory(nullptr);
1306  tree->Branch("Name", &(splitPath.second[0]), "Name/C");
1307  tree->Branch("Interval", &(interval[0]), "Interval/C");
1308  tree->Branch("TriggerChain", triggerData, "TriggerChain/C");
1309  tree->Branch("MergeMethod", mergeData.data(), "MergeMethod/C");
1310  tree->Fill();
1311  if (!m_histSvc->regTree(treePath, std::move(tree))) {
1312  MsgStream log(Athena::getMessageSvc(), "OfflineHistogramProvider");
1313  log << MSG::ERROR
1314  << "Failed to register DQ metadata TTree " << treePath << endmsg;
1315  }
1316  } else {
1317  TTree *tree{nullptr};
1318  if (m_histSvc->getTree(treePath, tree).isSuccess()) {
1319  tree->SetBranchAddress("Name", &(splitPath.second[0]));
1320  tree->SetBranchAddress("Interval", &(interval[0]));
1321  tree->SetBranchAddress("TriggerChain", triggerData);
1322  tree->SetBranchAddress("MergeMethod", mergeData.data());
1323  tree->Fill();
1324  } else {
1325  MsgStream log(Athena::getMessageSvc(), "OfflineHistogramProvider");
1326  log << MSG::ERROR
1327  << "Failed to retrieve DQ metadata TTree " << treePath << " which is reported to exist" << endmsg;
1328  }
1329  }
1330  }
1331  return StatusCode::SUCCESS;
1332 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TrigConf::DataStructure::data
const ptree & data() const
Access to the underlying data, if needed.
Definition: DataStructure.h:83
TrigConf::L1Threshold::mapping
unsigned int mapping() const
Accessor to the mapping number The mapping is unique within a type.
Definition: L1ThresholdBase.h:163
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
TileDCSDataPlotter.h0
h0
Definition: TileDCSDataPlotter.py:873
DiTauMassTools::TauTypes::lh
@ lh
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:53
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
checkCorrelInHIST.conn
conn
Definition: checkCorrelInHIST.py:25
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
checkCorrelInHIST.histpath
histpath
Definition: checkCorrelInHIST.py:400
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
AddEmptyComponent.histName
string histName
Definition: AddEmptyComponent.py:64
StandaloneBunchgroupHandler.bg
bg
Definition: StandaloneBunchgroupHandler.py:243
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
LVL1CTP::CTPSimulation::extractMultiplicities
StatusCode extractMultiplicities(std::map< std::string, unsigned int > &thrMultiMap, const EventContext &context) const
Definition: CTPSimulation.cxx:614
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
RoIBResult.h
dqt_zlumi_pandas.hname
string hname
Definition: dqt_zlumi_pandas.py:279
JetEnergyRoI.h
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
HistogramDef.h
plotmaker.hist
hist
Definition: plotmaker.py:148
tree
TChain * tree
Definition: tile_monitor.h:30
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:210
bin
Definition: BinsDiffFromStripMedian.h:43
CTPUtil.h
TrigConf::DataStructure::getAttribute
T getAttribute(const std::string &key, bool ignoreIfMissing=false, const T &def=T()) const
Access to simple attribute.
Definition: DataStructure.h:152
CTPSimulation.h
LVL1CTP::CTPSimulation::createMultiplicityHist
StatusCode createMultiplicityHist(const std::string &type, unsigned int maxMult=10)
Definition: CTPSimulation.cxx:135
CTPTriggerItem.h
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
TrigConf::L1Threshold::type
const std::string & type() const
Accessor to the threshold type.
Definition: L1ThresholdBase.h:157
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
LVL1CTP::CTPSimulation::calculateEMMultiplicity
unsigned int calculateEMMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
Definition: CTPSimulation.cxx:851
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
LVL1CTP::CTPSimulation::setMultiplicityHistLabels
StatusCode setMultiplicityHistLabels(const TrigConf::L1Menu &l1menu, const std::string &type)
Definition: CTPSimulation.cxx:159
LVL1CTP::CTPSimulation::calculateTauMultiplicity
unsigned int calculateTauMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
Definition: CTPSimulation.cxx:888
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
TrigConf::DataStructure::name
virtual const std::string & name() const final
Definition: DataStructure.cxx:109
TrigConf::L1BunchGroupSet::getBunchGroup
const std::shared_ptr< L1BunchGroup > & getBunchGroup(const std::string &name) const
Accessor to the bunchgroup by name.
Definition: L1BunchGroupSet.cxx:118
read_hist_ntuple.h1
h1
Definition: read_hist_ntuple.py:21
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
x
#define x
xAOD::tap
setBGCode tap
Definition: TrigDecision_v1.cxx:43
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
LVL1CTP::CTPSimulation::get2DHist
LockedHandle< TH2 > & get2DHist(const std::string &histName) const
Definition: CTPSimulation.cxx:258
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
LVL1CTP::CTPSimulation::getBaseHistPath
std::string getBaseHistPath() const
Definition: CTPSimulation.cxx:191
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
LVL1CTP::CTPUtil::getMult
static int getMult(uint64_t word, unsigned int startbit, unsigned int endbit)
extract multiplicities using new trigger configuration interface
Definition: CTPUtil.cxx:64
met
Definition: IMETSignificance.h:24
CTPSimRanluxFactory
const std::function< CLHEP::HepRandomEngine *(void) > CTPSimRanluxFactory
Definition: CTPSimulation.cxx:35
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1CTP::CTPSimulation::hbook
StatusCode hbook(const std::string &path, std::unique_ptr< TH1 > hist)
Definition: CTPSimulation.cxx:199
LVL1CTP::CTPSimulation::calculateTopoMultiplicity
unsigned int calculateTopoMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context, bool UseLegacy) const
Definition: CTPSimulation.cxx:1034
LVL1CTP::CTPSimulation::storeMetadata
StatusCode storeMetadata()
Definition: CTPSimulation.cxx:1284
LVL1CTP::CTPSimulation::calculateMETMultiplicity
unsigned int calculateMETMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
Definition: CTPSimulation.cxx:926
IDTPM::eT
float eT(const U &p)
Accessor utility function for getting the value of Tranverse energy.
Definition: TrackParametersHelper.h:122
LVL1CTP::CTPSimulation::calculateJetMultiplicity
unsigned int calculateJetMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
Definition: CTPSimulation.cxx:828
lumiFormat.i
int i
Definition: lumiFormat.py:85
h
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
LVL1CTP::CTPSimulation::get1DHist
LockedHandle< TH1 > & get1DHist(const std::string &histName) const
Definition: CTPSimulation.cxx:247
extractSporadic.h
list h
Definition: extractSporadic.py:97
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
getLatestRuns.interval
interval
Definition: getLatestRuns.py:24
LVL1CTP::CTPSimulation::calculateTopoOptMultiplicity
unsigned int calculateTopoOptMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
Definition: CTPSimulation.cxx:995
calibdata.exception
exception
Definition: calibdata.py:496
TrigConf::L1Threshold::thrValue
virtual float thrValue(int eta=0) const
Accessor to the threshold value for eta-dependent threholds.
Definition: L1ThresholdBase.cxx:127
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
TrigConf::L1Item
L1 threshold configuration.
Definition: L1Item.h:18
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
TrigConf::L1BunchGroupSet::maxNBunchGroups
constexpr std::size_t maxNBunchGroups() const
Maximum number of bunchgroups.
Definition: L1BunchGroupSet.h:107
TrigConf::L1BunchGroupSet
L1 board configuration.
Definition: L1BunchGroupSet.h:71
LVL1CTP::CTPSimulation::bookHists
StatusCode bookHists()
Definition: CTPSimulation.cxx:329
TrigConf::name
Definition: HLTChainList.h:35
LVL1CTP::CTPUtil::getOptMult
static int getOptMult(std::bitset< 128 > bits, unsigned int startbit, unsigned int endbit)
Definition: CTPUtil.cxx:77
python.handimod.extra
int extra
Definition: handimod.py:522
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
LVL1CTP::CTPSimulation::simulateItems
StatusCode simulateItems(const std::map< std::string, unsigned int > &thrMultiMap, const EventContext &context) const
Definition: CTPSimulation.cxx:1123
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
LVL1CTP::CTPSimulation::setHistLabels
StatusCode setHistLabels(const TrigConf::L1Menu &l1menu)
Definition: CTPSimulation.cxx:269
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
LVL1CTP::CTPSimulation::~CTPSimulation
~CTPSimulation()
Definition: CTPSimulation.cxx:45
item
Definition: ItemListSvc.h:43
LVL1CTP::CTPSimulation::calculateMuonMultiplicity
unsigned int calculateMuonMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
Definition: CTPSimulation.cxx:978
LVL1CTP::CTPSimulation::stop
virtual StatusCode stop() override
Definition: CTPSimulation.cxx:1179
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
LVL1CTP::CTPUtil::getMuonMult
static int getMuonMult(unsigned int word, int threshold)
get Muon multiplicty in legacy mode
Definition: CTPUtil.cxx:22
CTP_RDO.h
y
#define y
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LVL1CTP::CTPSimulation::start
virtual StatusCode start() override
Definition: CTPSimulation.cxx:104
LVL1CTP::CTPUtil::getMultTopo
static unsigned int getMultTopo(uint64_t word, unsigned int startbit, unsigned int endbit, unsigned int clock)
extract multiplicities from Topo words, were the encoding is different
Definition: CTPUtil.cxx:83
SG::getNSlots
size_t getNSlots()
Return the number of event slots.
Definition: SlotSpecificObj.cxx:64
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LVL1CTP::CTPSimulation::calculateMultiplicity
unsigned int calculateMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
Definition: CTPSimulation.cxx:1093
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:146
RunTileMonitoring.triggerType
triggerType
Definition: RunTileMonitoring.py:162
LVL1CTP::CTPSimulation::fillInputHistograms
StatusCode fillInputHistograms(const EventContext &context) const
Definition: CTPSimulation.cxx:415
SlotSpecificObj.h
Maintain a set of objects, one per slot.
dqt_zlumi_alleff_HIST.tl
tl
Definition: dqt_zlumi_alleff_HIST.py:73
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
checker_macros.h
Define macros for attributes used to control the static checker.
LVL1CTP::CTPSimulation::CTPSimulation
CTPSimulation(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CTPSimulation.cxx:40
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
LVL1CTP::CTPSimulation::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: CTPSimulation.cxx:119
TrigConf::L1Threshold
Standard L1 threshold configuration.
Definition: L1ThresholdBase.h:125
CTPTriggerThreshold.h
python.SystemOfUnits.L
float L
Definition: SystemOfUnits.py:91
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
LVL1CTP::CTPSimulation::initialize
virtual StatusCode initialize() override
Definition: CTPSimulation.cxx:49