24 #include "CLHEP/Random/RandomEngine.h"
25 #include "CLHEP/Random/Ranlux64Engine.h"
40 const std::function< CLHEP::HepRandomEngine*(void) >
CTPSimRanluxFactory = [](
void)->CLHEP::HepRandomEngine*{
41 return new CLHEP::Ranlux64Engine();
48 m_decoder(
new LVL1::CPRoIDecoder() ),
49 m_jetDecoder(
new LVL1::JEPRoIDecoder() )
59 if(m_forceBunchGroupPattern) {
60 ATH_MSG_INFO(
"Will use bunchgroup pattern 0x" << std::hex << m_bunchGroupPattern);
62 ATH_MSG_INFO(
"Will use bunchgroup definition from bunchgroup set");
66 CHECK( m_oKeyRDO.assign(LVL1CTP::DEFAULT_RDOOutputLocation_Rerun) );
67 CHECK( m_oKeySLink.assign(LVL1CTP::DEFAULT_CTPSLinkLocation_Rerun) );
69 ATH_CHECK( m_bgKey.initialize( !m_forceBunchGroupPattern ) );
72 ATH_CHECK( m_iKeyTopo.initialize( !m_iKeyTopo.empty() && m_doL1Topo ) );
73 ATH_CHECK( m_iKeyMuctpi.initialize( ! m_iKeyMuctpi.empty() ) );
76 ATH_CHECK( m_iKeyLegacyTopo.initialize( !m_iKeyLegacyTopo.empty() && m_doL1CaloLegacy && m_doL1TopoLegacy ) );
77 ATH_CHECK( m_iKeyCtpinEM.initialize( m_doL1CaloLegacy ) );
78 ATH_CHECK( m_iKeyCtpinJet.initialize( m_doL1CaloLegacy ) );
79 ATH_CHECK( m_iKeyCtpinXE.initialize( m_doL1CaloLegacy ) );
82 ATH_CHECK( m_iKeyJFexJets.initialize( ! m_iKeyJFexJets.empty() ) );
83 ATH_CHECK( m_iKeyJFexLJets.initialize( ! m_iKeyJFexLJets.empty() ) );
84 ATH_CHECK( m_iKeyGFexJets.initialize( ! m_iKeyGFexJets.empty() ) );
85 ATH_CHECK( m_iKeyGFexMETNC.initialize( ! m_iKeyGFexMETNC.empty() ) );
86 ATH_CHECK( m_iKeyGFexMETRho.initialize( ! m_iKeyGFexMETRho.empty() ) );
87 ATH_CHECK( m_iKeyGFexMETJwoJ.initialize( ! m_iKeyGFexMETJwoJ.empty() ) );
88 ATH_CHECK( m_iKeyEFexCluster.initialize( ! m_iKeyEFexCluster.empty() ) );
89 ATH_CHECK( m_iKeyEFexTau.initialize( ! m_iKeyEFexTau.empty() ) );
90 ATH_CHECK( m_oKeyRDO.initialize( ! m_oKeyRDO.empty() ) );
91 ATH_CHECK( m_oKeySLink.initialize( ! m_oKeySLink.empty() ) );
94 ATH_CHECK( m_iKeyZDC.initialize( ! m_iKeyZDC.empty() && m_doZDC ) );
97 ATH_CHECK( m_iKeyTRT.initialize( ! m_iKeyTRT.empty() && m_doTRT ) );
105 ATH_MSG_DEBUG(
"Registering histograms under " << getBaseHistPath() <<
" in " << m_histSvc);
107 return StatusCode::SUCCESS;
116 bookHists().ignore();
120 setHistLabels(*l1menu).ignore();
122 return StatusCode::SUCCESS;
130 fillInputHistograms(context).ignore();
132 std::map<std::string, unsigned int> thrMultiMap;
134 extractMultiplicities(thrMultiMap, context).ignore();
136 simulateItems(thrMultiMap, context).ignore();
138 return StatusCode::SUCCESS;
145 std::map<std::string,std::vector<std::string>> typeMapping = {
147 {
"jet", {
"JET",
"jJ",
"jLJ",
"gJ",
"gLJ"} },
148 {
"xe", {
"XE",
"gXE",
"jXE"} },
149 {
"te", {
"TE",
"jTE",
"gTE"} },
151 {
"em", {
"EM",
"eEM",
"jEM"} },
152 {
"tau", {
"TAU",
"eTAU",
"jTAU",
"cTAU"} }
154 std::vector<TrigConf::L1Threshold> thrV;
155 for(
const std::string &
t : typeMapping[
type] ) {
157 TH2*
hist =
new TH2I( Form(
"%sMult",
t.c_str()),
158 Form(
"%s threshold multiplicity",
t.c_str()), xsize, 0, xsize, maxMult, 0, maxMult);
159 sc = hbook(
"/multi/" +
type, std::unique_ptr<TH2>(
hist));
168 std::map<std::string,std::vector<std::string>> typeMapping = {
170 {
"jet", {
"JET",
"jJ",
"jLJ",
"gJ",
"gLJ"} },
171 {
"xe", {
"XE",
"gXE",
"jXE"} },
172 {
"te", {
"TE",
"jTE",
"gTE"} },
174 {
"em", {
"EM",
"eEM",
"jEM"} },
175 {
"tau", {
"TAU",
"eTAU",
"jTAU",
"cTAU"} }
179 std::vector<TrigConf::L1Threshold> thrV;
180 for(
const std::string &
t : typeMapping[
type] ) {
182 auto hist = get2DHist(
"/multi/" +
type +
"/" +
t +
"Mult" );
183 auto & thrV =
l1menu.thresholds(
t);
184 while(
hist->GetNbinsX() < (
int)thrV.size() ) {
185 hist->LabelsInflate(
"xaxis");
187 for(
auto thr : thrV) {
188 hist->GetXaxis()->SetBinLabel(thr->mapping()+1, thr->name().c_str() );
191 ATH_MSG_DEBUG(
"Caught exception when setting new JSON MultiplicityHistLabel " <<
t <<
" : " << ex.what());
199 std::string baseHistPath( m_histPath );
200 if(baseHistPath.back()!=
'/') baseHistPath +=
"/";
201 baseHistPath +=
name();
207 const std::string &
hname(
hist->GetName());
210 if(
key.back()!=
'/')
key +=
"/";
213 if(m_hist1D.find(
key)!=m_hist1D.end()) {
215 return StatusCode::RECOVERABLE;
218 LockedHandle<TH1>
lh;
220 if(
sc.isSuccess() ) {
231 const std::string &
hname(
hist->GetName());
234 if(
key.back()!=
'/')
key +=
"/";
237 if(m_hist2D.find(
key)!=m_hist2D.end()) {
239 return StatusCode::RECOVERABLE;
242 LockedHandle<TH2>
lh;
244 if(
sc.isSuccess() ) {
256 if (itr == m_hist1D.end()) {
257 throw GaudiException(
"1D-hist "+
histName +
" does not exist",
name(), StatusCode::FAILURE);
267 if (itr == m_hist2D.end()) {
268 throw GaudiException(
"2D-hist "+
histName +
" does not exist",
name(), StatusCode::FAILURE);
289 std::vector<std::string> connNames =
l1menu.connectorNames();
290 for(
const std::string connName : {
"LegacyTopo0",
"LegacyTopo1",
"Topo1El",
"Topo2El",
"Topo3El",
"Topo1Opt0",
"Topo1Opt1",
"Topo1Opt2",
"Topo1Opt3"}) {
291 if(
find(connNames.begin(), connNames.end(), connName) == connNames.end() ) {
294 auto hTopo = *get1DHist(
"/input/topo/" + connName);
295 for(
uint fpga : {0,1}) {
296 for(
uint clock : {0,1}) {
297 for(
auto &
tl :
l1menu.connector(connName).triggerLines(fpga,clock)) {
298 uint flatIndex =
tl.flatindex();
299 hTopo->GetXaxis()->SetBinLabel(flatIndex+1,
tl.name().c_str());
305 std::vector<std::string> orderedItemnames;
306 orderedItemnames.reserve(
l1menu.size() );
308 orderedItemnames.emplace_back(
item.name());
310 std::sort(orderedItemnames.begin(), orderedItemnames.end());
313 auto tbpById = *get1DHist(
"/output/tbpById" );
314 auto tapById = *get1DHist(
"/output/tapById" );
315 auto tavById = *get1DHist(
"/output/tavById" );
316 auto tbpByName = *get1DHist(
"/output/tbpByName" );
317 auto tapByName = *get1DHist(
"/output/tapByName" );
318 auto tavByName = *get1DHist(
"/output/tavByName" );
319 unsigned int bin = 1;
320 for (
const std::string & itemname : orderedItemnames ) {
321 unsigned int ctpId(0);
323 ctpId =
item.ctpId();
324 tbpById->GetXaxis()->SetBinLabel( ctpId+1, itemname.c_str() );
325 tapById->GetXaxis()->SetBinLabel( ctpId+1, itemname.c_str() );
326 tavById->GetXaxis()->SetBinLabel( ctpId+1, itemname.c_str() );
327 tbpByName->GetXaxis()->SetBinLabel(
bin, itemname.c_str() );
328 tapByName->GetXaxis()->SetBinLabel(
bin, itemname.c_str() );
329 tavByName->GetXaxis()->SetBinLabel(
bin++, itemname.c_str() );
332 return StatusCode::SUCCESS;
339 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"jJetPt",
"Jet p_{T} - jJ", 40, 0, 80) ));
340 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"jJetEta",
"Jet #eta - jJ", 64, -3.2, 3.2) ));
341 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"jJetPhi",
"Jet #phi - jJ", 64, -3.2, 3.2) ));
342 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"jLJetPt",
"Jet p_{T} - jLJ", 40, 0, 80) ));
343 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"jLJetEta",
"Jet #eta - jLJ", 64, -3.2, 3.2) ));
344 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"jLJetPhi",
"Jet #phi - jLJ", 64, -3.2, 3.2) ));
345 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"gJetPt",
"Jet p_{T} - gJ", 40, 0, 80) ));
346 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"gJetEta",
"Jet #eta - gJ", 64, -3.2, 3.2) ));
347 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"gJetPhi",
"Jet #phi - gJ", 64, -3.2, 3.2) ));
348 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"gLJetPt",
"Jet p_{T} - gLJ", 40, 0, 80) ));
349 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"gLJetEta",
"Jet #eta - gLJ", 64, -3.2, 3.2) ));
350 ATH_CHECK ( hbook(
"/input/jets/", std::make_unique<TH1I>(
"gLJetPhi",
"Jet #phi - gLJ", 64, -3.2, 3.2) ));
353 ATH_CHECK ( hbook(
"/input/met/", std::make_unique<TH1I>(
"Pufit",
"Missing ET from algorithm pufit", 40, 0, 80) ));
354 ATH_CHECK ( hbook(
"/input/met/", std::make_unique<TH1I>(
"PufitPhi",
"Missing ET PUfit phi", 64, -3.2, 3.2) ));
355 ATH_CHECK ( hbook(
"/input/met/", std::make_unique<TH1I>(
"Rho",
"Missing ET from algorithm rhosub", 40, 0, 80) ));
356 ATH_CHECK ( hbook(
"/input/met/", std::make_unique<TH1I>(
"RhoPhi",
"Missing ET rhosub phi", 64, -3.2, 3.2) ));
357 ATH_CHECK ( hbook(
"/input/met/", std::make_unique<TH1I>(
"JwoJ",
"Missing ET from algorithm jet without jets", 40, 0, 80) ));
358 ATH_CHECK ( hbook(
"/input/met/", std::make_unique<TH1I>(
"JwoJPhi",
"Missing ET jet without jet phi", 64, -3.2, 3.2) ));
361 ATH_CHECK ( hbook(
"/input/em/", std::make_unique<TH1I>(
"et",
"Cluster et", 40, 0, 40) ));
362 ATH_CHECK ( hbook(
"/input/em/", std::make_unique<TH1I>(
"eta",
"Cluster eta ", 64, -3.2, 3.2) ));
363 ATH_CHECK ( hbook(
"/input/em/", std::make_unique<TH1I>(
"phi",
"Cluster phi", 64, -3.2, 3.2) ));
366 ATH_CHECK ( hbook(
"/input/tau/", std::make_unique<TH1I>(
"et",
"Tau et", 40, 0, 40) ));
367 ATH_CHECK ( hbook(
"/input/tau/", std::make_unique<TH1I>(
"eta",
"Tau eta ", 64, -3.2, 3.2) ));
368 ATH_CHECK ( hbook(
"/input/tau/", std::make_unique<TH1I>(
"phi",
"Tau phi", 64, -3.2, 3.2) ));
369 ATH_CHECK ( hbook(
"/input/tau/", std::make_unique<TH1I>(
"emIso",
"Tau em isolation", 40, 0, 1) ));
370 ATH_CHECK ( hbook(
"/input/tau/", std::make_unique<TH1I>(
"hadIso",
"Tau hadronic isolation", 40, 0, 1) ));
371 ATH_CHECK ( hbook(
"/input/tau/", std::make_unique<TH1I>(
"R3ET",
"Tau eT", 40, 0, 40) ));
372 ATH_CHECK ( hbook(
"/input/tau/", std::make_unique<TH1I>(
"R3Iso",
"Tau isolation", 40, 0, 1) ));
375 ATH_CHECK ( hbook(
"/input/counts/", std::make_unique<TH1I>(
"jJets",
"Number of jets (jJ)", 40, 0, 40) ));
376 ATH_CHECK ( hbook(
"/input/counts/", std::make_unique<TH1I>(
"jLJets",
"Number of jets (jLJ)", 40, 0, 40) ));
377 ATH_CHECK ( hbook(
"/input/counts/", std::make_unique<TH1I>(
"gJets",
"Number of jets (gJ)", 40, 0, 40) ));
378 ATH_CHECK ( hbook(
"/input/counts/", std::make_unique<TH1I>(
"gLJets",
"Number of jets (gLJ)", 40, 0, 40) ));
379 ATH_CHECK ( hbook(
"/input/counts/", std::make_unique<TH1I>(
"muons",
"Number of muons", 10, 0, 10) ));
380 ATH_CHECK ( hbook(
"/input/counts/", std::make_unique<TH1I>(
"emcluster",
"Number of EM clusters", 20, 0, 20) ));
381 ATH_CHECK ( hbook(
"/input/counts/", std::make_unique<TH1I>(
"taus",
"Number of TAU candidates", 20, 0, 20) ));
384 ATH_CHECK ( createMultiplicityHist(
"muon" ) );
385 ATH_CHECK ( createMultiplicityHist(
"jet" ) );
386 ATH_CHECK ( createMultiplicityHist(
"xe", 2) );
387 ATH_CHECK ( createMultiplicityHist(
"te", 2) );
388 ATH_CHECK ( createMultiplicityHist(
"xs", 2) );
389 ATH_CHECK ( createMultiplicityHist(
"em" ) );
390 ATH_CHECK ( createMultiplicityHist(
"tau" ) );
392 ATH_CHECK ( hbook(
"/multi/all", (std::unique_ptr<TH2>)std::make_unique<TH2I>(
"LegacyMult",
"Legacy thresholds multiplicity", 1, 0, 1, 10, 0, 10) ));
393 ATH_CHECK ( hbook(
"/multi/all", (std::unique_ptr<TH2>)std::make_unique<TH2I>(
"R3Mult",
"New thresholds multiplicity", 1, 0, 1, 10, 0, 10) ));
396 ATH_CHECK( hbook(
"/input/topo/", std::make_unique<TH1I>(
"LegacyTopo0",
"L1Topo Decision (Legacy 0)", 64, 0, 64) ));
397 ATH_CHECK( hbook(
"/input/topo/", std::make_unique<TH1I>(
"LegacyTopo1",
"L1Topo Decision (Legacy 1)", 64, 0, 64) ));
398 ATH_CHECK( hbook(
"/input/topo/", std::make_unique<TH1I>(
"Topo1El",
"L1Topo Decision (Topo 1 electrical)", 64, 0, 64) ));
399 ATH_CHECK( hbook(
"/input/topo/", std::make_unique<TH1I>(
"Topo2El",
"L1Topo Decision (Topo 2 electrical)", 64, 0, 64) ));
400 ATH_CHECK( hbook(
"/input/topo/", std::make_unique<TH1I>(
"Topo3El",
"L1Topo Decision (Topo 3 electrical)", 64, 0, 64) ));
401 ATH_CHECK( hbook(
"/input/topo/", std::make_unique<TH1I>(
"Topo1Opt0",
"L1Topo Decision (Topo 1 optical 0)", 128, 0, 128) ));
402 ATH_CHECK( hbook(
"/input/topo/", std::make_unique<TH1I>(
"Topo1Opt1",
"L1Topo Decision (Topo 1 optical 1)", 128, 0, 128) ));
403 ATH_CHECK( hbook(
"/input/topo/", std::make_unique<TH1I>(
"Topo1Opt2",
"L1Topo Decision (Topo 1 optical 2)", 128, 0, 128) ));
404 ATH_CHECK( hbook(
"/input/topo/", std::make_unique<TH1I>(
"Topo1Opt3",
"L1Topo Decision (Topo 1 optical 3)", 128, 0, 128) ));
407 ATH_CHECK ( hbook(
"/output/", std::make_unique<TH1I>(
"tbpById",
"Items decision (tbp)", 512, 0, 512) ));
408 ATH_CHECK ( hbook(
"/output/", std::make_unique<TH1I>(
"tapById",
"Items decision (tap)", 512, 0, 512) ));
409 ATH_CHECK ( hbook(
"/output/", std::make_unique<TH1I>(
"tavById",
"Items decision (tav)", 512, 0, 512) ));
410 ATH_CHECK ( hbook(
"/output/", std::make_unique<TH1I>(
"tbpByName",
"Items decision (tbp)", 512, 0, 512) ));
411 ATH_CHECK ( hbook(
"/output/", std::make_unique<TH1I>(
"tapByName",
"Items decision (tap)", 512, 0, 512) ));
412 ATH_CHECK ( hbook(
"/output/", std::make_unique<TH1I>(
"tavByName",
"Items decision (tav)", 512, 0, 512) ));
414 ATH_CHECK ( hbook(
"/", std::make_unique<TH1I>(
"bcid",
"Bunch crossing ID", 3564, 0, 3564)) );
418 return StatusCode::SUCCESS;
427 if( not m_iKeyJFexJets.empty() ) {
429 if(jFexJets.isValid()) {
430 get1DHist(
"/input/counts/jJets")->Fill(jFexJets->size());
431 auto h0 = *get1DHist(
"/input/jets/jJetPt");
432 auto h1 = *get1DHist(
"/input/jets/jJetEta");
433 auto h2 = *get1DHist(
"/input/jets/jJetPhi");
434 for(
const auto jet : *jFexJets ) {
435 h0->Fill(fabs(
jet->et8x8()/1000.));
436 h1->Fill(
jet->eta());
437 h2->Fill(
jet->phi());
445 if( not m_iKeyJFexLJets.empty() ) {
447 if(jFexLJets.isValid()) {
448 get1DHist(
"/input/counts/jLets")->Fill(jFexLJets->size());
449 auto h0 = *get1DHist(
"/input/jets/jLJetPt");
450 auto h1 = *get1DHist(
"/input/jets/jLJetEta");
451 auto h2 = *get1DHist(
"/input/jets/jLJetPhi");
452 for(
const auto jet : *jFexLJets ) {
453 h0->Fill(fabs(
jet->et8x8()/1000.));
454 h1->Fill(
jet->eta());
455 h2->Fill(
jet->phi());
465 if( not m_iKeyGFexJets.empty() ) {
467 if(gFexJets.isValid()) {
468 get1DHist(
"/input/counts/gJets")->Fill(gFexJets->size());
469 auto h0 = *get1DHist(
"/input/jets/gJetPt");
470 auto h1 = *get1DHist(
"/input/jets/gJetEta");
471 auto h2 = *get1DHist(
"/input/jets/gJetPhi");
472 for(
const auto jet : *gFexJets ) {
473 h0->Fill(fabs(
jet->et8x8()/1000.));
474 h1->Fill(
jet->eta());
475 h2->Fill(
jet->phi());
483 if( not m_iKeyGFexMETNC.empty() ) {
485 if( gFexMETPufit.isValid() ) {
486 get1DHist(
"/input/met/Pufit")->Fill(gFexMETPufit->energyT()/1000.);
487 get1DHist(
"/input/met/PufitPhi")->Fill(atan2(gFexMETPufit->energyX(), gFexMETPufit->energyY()));
493 if( not m_iKeyGFexMETRho.empty() ) {
495 if( gFexMETRho.isValid() ) {
496 get1DHist(
"/input/met/Rho")->Fill(gFexMETRho->energyT()/1000.);
497 get1DHist(
"/input/met/RhoPhi")->Fill(atan2(gFexMETRho->energyX(), gFexMETRho->energyY()));
503 if( not m_iKeyGFexMETJwoJ.empty() ) {
505 if( gFexMETJwoJ.isValid() ) {
506 get1DHist(
"/input/met/JwoJ")->Fill(gFexMETJwoJ->energyT()/1000.);
507 get1DHist(
"/input/met/JwoJPhi")->Fill(atan2(gFexMETJwoJ->energyX(), gFexMETJwoJ->energyY()));
514 if( not m_iKeyEFexCluster.empty() ) {
516 if( eFexCluster.isValid() ) {
517 get1DHist(
"/input/counts/emcluster")->Fill(eFexCluster->size());
518 auto h0 = *get1DHist(
"/input/em/et");
519 auto h1 = *get1DHist(
"/input/em/eta");
520 auto h2 = *get1DHist(
"/input/em/phi");
521 for(
const auto cl : *eFexCluster ) {
532 if( not m_iKeyEFexTau.empty() ) {
534 if( eFexTau.isValid() ) {
535 get1DHist(
"/input/counts/taus")->Fill(eFexTau->size());
536 auto h0 = *get1DHist(
"/input/tau/et");
537 auto h1 = *get1DHist(
"/input/tau/eta");
538 auto h2 = *get1DHist(
"/input/tau/phi");
539 auto h3 = *get1DHist(
"/input/tau/emIso");
540 auto h4 = *get1DHist(
"/input/tau/hadIso");
541 auto h5 = *get1DHist(
"/input/tau/R3ClusterET");
542 auto h6 = *get1DHist(
"/input/tau/R3ClusterIso");
545 for(
const auto tau : *eFexTau ) {
547 h1->Fill(tau->eta());
548 h2->Fill(tau->phi());
549 h3->Fill(tau->emIsol());
550 h4->Fill(tau->hadIsol());
551 h5->Fill(accR3ClET(*tau)/1000.);
552 h6->Fill(accR3ClIso(*tau));
560 if( not m_iKeyLegacyTopo.empty() && m_doL1CaloLegacy && m_doL1TopoLegacy ) {
561 auto legacyTopoInput =
SG::makeHandle( m_iKeyLegacyTopo, context );
562 if(legacyTopoInput.isValid()) {
563 ATH_MSG_DEBUG(
"Retrieved input from L1Topo from StoreGate with key " << m_iKeyTopo);
564 ATH_MSG_DEBUG(
"L1TopoLegacy0 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << legacyTopoInput->cableWord1(0));
565 ATH_MSG_DEBUG(
"L1TopoLegacy0 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << legacyTopoInput->cableWord1(1));
566 ATH_MSG_DEBUG(
"L1TopoLegacy1 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << legacyTopoInput->cableWord2(0));
567 ATH_MSG_DEBUG(
"L1TopoLegacy1 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << legacyTopoInput->cableWord2(1));
568 auto h0 = *get1DHist(
"/input/topo/LegacyTopo0");
569 auto h1 = *get1DHist(
"/input/topo/LegacyTopo1");
570 for(
unsigned int i=0;
i<32; ++
i) {
572 if( (legacyTopoInput->cableWord1(0) &
mask) != 0 )
h0->Fill(
i);
573 if( (legacyTopoInput->cableWord1(1) &
mask) != 0 )
h0->Fill(32 +
i);
574 if( (legacyTopoInput->cableWord2(0) &
mask) != 0 )
h1->Fill(
i);
575 if( (legacyTopoInput->cableWord2(1) &
mask) != 0 )
h1->Fill(32 +
i);
580 if( not m_iKeyTopo.empty() && m_doL1Topo ) {
582 if(topoInput.isValid()) {
583 ATH_MSG_DEBUG(
"Retrieved input from L1Topo from StoreGate with key " << m_iKeyTopo);
584 ATH_MSG_DEBUG(
"L1Topo0 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << topoInput->cableWord1(0));
585 ATH_MSG_DEBUG(
"L1Topo0 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << topoInput->cableWord1(1));
586 ATH_MSG_DEBUG(
"L1Topo1 word 0 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << topoInput->cableWord2(0));
587 ATH_MSG_DEBUG(
"L1Topo1 word 1 is: 0x" << std::hex << std::setw( 8 ) << std::setfill(
'0' ) << topoInput->cableWord2(1));
588 auto h0 = *get1DHist(
"/input/topo/Topo2El");
589 auto h1 = *get1DHist(
"/input/topo/Topo3El");
590 for(
unsigned int i=0;
i<32; ++
i) {
592 if( (topoInput->cableWord1(0) &
mask) != 0 )
h0->Fill(
i);
593 if( (topoInput->cableWord1(1) &
mask) != 0 )
h0->Fill(32 +
i);
594 if( (topoInput->cableWord2(0) &
mask) != 0 )
h1->Fill(
i);
595 if( (topoInput->cableWord2(1) &
mask) != 0 )
h1->Fill(32 +
i);
597 auto h2 = *get1DHist(
"/input/topo/Topo1Opt0");
598 auto h3 = *get1DHist(
"/input/topo/Topo1Opt1");
599 auto h4 = *get1DHist(
"/input/topo/Topo1Opt2");
600 auto h5 = *get1DHist(
"/input/topo/Topo1Opt3");
601 for(
unsigned int i=0;
i<128;
i += 3) {
602 std::bitset<128>
mask = 0x11;
mask <<=
i;
603 if( (topoInput->optcableWord(
"Topo1Opt0") &
mask) != 0 ) h2->Fill(
i);
604 if( (topoInput->optcableWord(
"Topo1Opt1") &
mask) != 0 ) h3->Fill(
i);
605 if( (topoInput->optcableWord(
"Topo1Opt2") &
mask) != 0 ) h4->Fill(
i);
606 if( (topoInput->optcableWord(
"Topo1Opt3") &
mask) != 0 ) h5->Fill(
i);
614 auto bcid = context.eventID().bunch_crossing_id();
615 get1DHist(
"/bcid")->Fill(
bcid);
617 return StatusCode::SUCCESS;
628 std::vector<std::string> connNames =
l1menu->connectorNames();
629 for (
const std::string connName : {
"LegacyTopo0",
"LegacyTopo1",
"Topo1El",
"Topo2El",
"Topo3El",
"Topo1Opt0",
"Topo1Opt1",
"Topo1Opt2",
"Topo1Opt3",
"CTPCAL",
"NIM2"})
631 if(
find(connNames.begin(), connNames.end(), connName) == connNames.end() ) {
634 bool opt_cable =
false;
635 std::bitset<128> cable128 {0};
638 if (m_iKeyLegacyTopo.empty() || !m_doL1CaloLegacy || !m_doL1TopoLegacy )
643 if (not topoInput.isValid()) {
646 if(connName ==
"LegacyTopo0") {
647 cable = ( (
uint64_t)topoInput->cableWord1( 1 ) << 32) + topoInput->cableWord1( 0 );
648 }
else if (connName ==
"LegacyTopo1") {
649 cable = ( (
uint64_t)topoInput->cableWord2( 1 ) << 32) + topoInput->cableWord2( 0 );
655 if (not zdcInput.isValid())
659 cable =
static_cast<uint64_t>(zdcInput->cableWord0());
661 for (
auto &
tl :
conn.triggerLines()){
662 if (
tl.name().find(
"ZDC") == std::string::npos)
666 uint flatIndex =
tl.flatindex();
668 thrMultiMap[
tl.name()] = pass;
677 if (not trtInput.isValid())
681 cable =
static_cast<uint64_t>(trtInput->cableWord0());
683 for (
auto &
tl :
conn.triggerLines()){
684 if (
tl.name().find(
"TRT") == std::string::npos)
688 uint flatIndex =
tl.flatindex();
690 thrMultiMap[
tl.name()] = pass;
697 if (m_iKeyTopo.empty() || !m_doL1Topo )
702 if (not topoInput.isValid()) {
705 if(connName ==
"Topo1El") {
706 cable = ( (
uint64_t)topoInput->cableWord0( 1 ) << 32) + topoInput->cableWord0( 0 );
707 }
else if(connName ==
"Topo2El") {
708 cable = ( (
uint64_t)topoInput->cableWord1( 1 ) << 32) + topoInput->cableWord1( 0 );
709 }
else if (connName ==
"Topo3El") {
710 cable = ( (
uint64_t)topoInput->cableWord2( 1 ) << 32) + topoInput->cableWord2( 0 );
711 }
else if(connName ==
"Topo1Opt0") {
712 ATH_MSG_DEBUG(
"BIT word Topo1Opt0: " << topoInput->optcableWord( connName ));
714 cable128 = topoInput->optcableWord( connName );
715 }
else if(connName ==
"Topo1Opt1") {
716 ATH_MSG_DEBUG(
"BIT word Topo1Opt1: " << topoInput->optcableWord( connName ));
718 cable128 = topoInput->optcableWord( connName );
719 }
else if(connName ==
"Topo1Opt2") {
720 ATH_MSG_DEBUG(
"BIT word Topo1Opt2: " << topoInput->optcableWord( connName ));
722 cable128 = topoInput->optcableWord( connName );
723 }
else if(connName ==
"Topo1Opt3") {
724 ATH_MSG_DEBUG(
"BIT word Topo1Opt3: " << topoInput->optcableWord( connName ));
726 cable128 = topoInput->optcableWord( connName );
730 for(
uint fpga : {0,1}) {
731 for(
uint clock : {0,1}) {
732 for(
auto &
tl :
conn.triggerLines(fpga,clock)) {
733 uint flatIndex =
tl.flatindex();
736 pass = ((cable128 >> flatIndex).
test(0)) == 0 ? 0 : 1;
739 pass = (cable & (
static_cast<uint64_t>(0x1) << flatIndex)) == 0 ? 0 : 1;
741 if(
size_t pos =
tl.name().find(
'[');
pos == std::string::npos) {
742 thrMultiMap[
tl.name()] = pass;
745 auto thrName =
tl.name().substr(0,
pos);
746 int bit = std::stoi(
tl.name().substr(
pos+1));
747 thrMultiMap.try_emplace(thrName, 0);
748 thrMultiMap[thrName] += (pass << bit);
749 ATH_MSG_DEBUG(thrName <<
" MULT updated mult for topo " << pass);
755 for (
auto & thr :
l1menu->thresholds() ) {
756 if (thr->type() ==
"TOPO" or thr->type() ==
"R2TOPO" or thr->type() ==
"MULTTOPO" or thr->type() ==
"MUTOPO")
760 if( thr->type() ==
"ZDC" && m_doZDC ){
763 if( thr->name() ==
"NIMTRT" && m_doTRT ){
767 unsigned int multiplicity = calculateMultiplicity(*thr,
l1menu, context);
769 thrMultiMap[thr->name()] = multiplicity;
770 ATH_MSG_DEBUG( thr->name() <<
" MULT calculated mult for topo " << multiplicity);
774 auto bcid = context.eventID().bunch_crossing_id();
775 if( m_forceBunchGroupPattern ) {
777 for (
size_t bg = 0;
bg < 16; ++
bg ) {
778 std::string bgName(
"BGRP");
780 thrMultiMap[bgName] = ( m_bunchGroupPattern & (0x1<<
bg) ) ? 1 : 0;
797 ATH_MSG_ERROR(
"Did not find L1BunchGroupSet in DetectorStore");
802 thrMultiMap[
"RNDM0"] = 1;
803 thrMultiMap[
"RNDM1"] = 1;
804 thrMultiMap[
"RNDM2"] = 1;
805 thrMultiMap[
"RNDM3"] = 1;
807 return StatusCode::SUCCESS;
813 unsigned int multiplicity = 0;
814 if( confThr.
type() ==
"JET" ) {
815 if(m_doL1CaloLegacy) {
817 if ( ctpinJet.isValid() ) {
818 if(
l1menu->connector(
"JET1").hasLine(confThr.
name()) ) {
819 auto & triggerline =
l1menu->connector(
"JET1").triggerLine(confThr.
name());
820 multiplicity =
CTPUtil::getMult( ctpinJet->cableWord0(), triggerline.startbit(), triggerline.endbit() );
821 }
else if(
l1menu->connector(
"JET2").hasLine(confThr.
name()) ) {
822 auto & triggerline =
l1menu->connector(
"JET2").triggerLine(confThr.
name());
823 multiplicity =
CTPUtil::getMult( ctpinJet->cableWord1(), triggerline.startbit(), triggerline.endbit() );
828 get2DHist(
"/multi/jet/" + confThr.
type() +
"Mult" )->Fill(confThr.
mapping(), multiplicity);
829 ATH_MSG_DEBUG(
"JET MULT calculated mult for threshold " << confThr.
name() <<
" : " << multiplicity);
836 unsigned int multiplicity (0);
837 if ( confThr.
name()[0]==
'e' ) {
839 if(!m_iKeyEFexCluster.empty()) {
840 float scale =
l1menu->getObject(
"thresholds.legacyCalo.EM.emscale").getValue<
float>();
842 for (
const auto cl : *eFexCluster ) {
843 float eta =
cl->eta();
844 int ieta =
int((
eta + (
eta>0 ? 0.005 : -0.005))/0.1);
845 unsigned int thrV = confThr.
thrValue( ieta );
846 bool clusterPasses = ( ((
unsigned int)
cl->et()) > (thrV *
scale) );
847 multiplicity += clusterPasses ? 1 : 0;
852 if(m_doL1CaloLegacy) {
854 if ( ctpinEM.isValid() ) {
855 if(
l1menu->connector(
"EM1").hasLine(confThr.
name()) ) {
856 auto & triggerline =
l1menu->connector(
"EM1").triggerLine(confThr.
name());
857 multiplicity =
CTPUtil::getMult( ctpinEM->cableWord0(), triggerline.startbit(), triggerline.endbit() );
858 }
else if(
l1menu->connector(
"EM2").hasLine(confThr.
name()) ) {
859 auto & triggerline =
l1menu->connector(
"EM2").triggerLine(confThr.
name());
860 multiplicity =
CTPUtil::getMult( ctpinEM->cableWord1(), triggerline.startbit(), triggerline.endbit() );
865 get2DHist(
"/multi/em/" + confThr.
type() +
"Mult" )->Fill(confThr.
mapping(), multiplicity);
866 ATH_MSG_DEBUG(
"EM MULT calculated mult for threshold " << confThr.
name() <<
" : " << multiplicity);
873 unsigned int multiplicity = 0;
874 if ( confThr.
name()[0]==
'e' ) {
879 if( eFexTaus.isValid() ) {
880 for (
const auto tau : *eFexTaus ) {
881 unsigned int eT = (
unsigned int) (accR3ClET(*tau)/1000.);
883 unsigned int etCut = confThr.
data().get_child(
"et").get_value<
unsigned int>();
884 bool tauPasses = (
eT >= etCut );
885 multiplicity += tauPasses ? 1 : 0;
890 if(m_doL1CaloLegacy) {
892 if ( ctpinEM.isValid() ) {
893 if(
l1menu->connector(
"TAU1").hasLine(confThr.
name()) ) {
894 auto & triggerline =
l1menu->connector(
"TAU1").triggerLine(confThr.
name());
895 multiplicity =
CTPUtil::getMult( ctpinEM->cableWord2(), triggerline.startbit(), triggerline.endbit() );
896 }
else if(
l1menu->connector(
"TAU2").hasLine(confThr.
name()) ) {
897 auto & triggerline =
l1menu->connector(
"TAU2").triggerLine(confThr.
name());
898 multiplicity =
CTPUtil::getMult( ctpinEM->cableWord3(), triggerline.startbit(), triggerline.endbit() );
903 get2DHist(
"/multi/tau/" + confThr.
type() +
"Mult" )->Fill(confThr.
mapping(), multiplicity);
904 ATH_MSG_DEBUG(
"TAU MULT calculated mult for threshold " << confThr.
name() <<
" : " << multiplicity);
911 unsigned int multiplicity = 0;
912 if ( confThr.
type() ==
"XE" or confThr.
type() ==
"TE" or confThr.
type() ==
"XS" ) {
914 if(m_doL1CaloLegacy) {
916 if ( ctpinEnergy.isValid() ) {
917 if(
l1menu->connector(
"EN1").hasLine(confThr.
name()) ) {
918 auto & triggerline =
l1menu->connector(
"EN1").triggerLine(confThr.
name());
919 multiplicity =
CTPUtil::getMult( ctpinEnergy->cableWord0(), triggerline.startbit(), triggerline.endbit() );
920 }
else if(
l1menu->connector(
"EN2").hasLine(confThr.
name()) ) {
921 auto & triggerline =
l1menu->connector(
"EN2").triggerLine(confThr.
name());
922 multiplicity =
CTPUtil::getMult( ctpinEnergy->cableWord1(), triggerline.startbit(), triggerline.endbit() );
929 if ( confThr.
name().find(
"gXENC")==0 ) {
930 rhk = & m_iKeyGFexMETNC;
932 }
else if ( confThr.
name().find(
"gXERHO")==0 ) {
933 rhk = & m_iKeyGFexMETRho;
935 }
else if ( confThr.
name().find(
"gXEJWOJ")==0 ) {
936 rhk = & m_iKeyGFexMETJwoJ;
939 rhk = & m_iKeyGFexMETJwoJ;
944 multiplicity = (
met->energyT()/1000. < confThr.
getAttribute<
unsigned int>(
"xe") ) ? 0 : 1;
947 if(confThr.
type() ==
"TE") {
948 get2DHist(
"/multi/te/" + confThr.
type() +
"Mult" )->Fill(confThr.
mapping(), multiplicity);
949 ATH_MSG_DEBUG(
"TE MULT calculated mult for threshold " << confThr.
name() <<
" : " << multiplicity);
950 }
else if(confThr.
type() ==
"XS") {
951 get2DHist(
"/multi/xs/" + confThr.
type() +
"Mult" )->Fill(confThr.
mapping(), multiplicity);
952 ATH_MSG_DEBUG(
"XS MULT calculated mult for threshold " << confThr.
name() <<
" : " << multiplicity);
954 get2DHist(
"/multi/xe/" + confThr.
type() +
"Mult" )->Fill(confThr.
mapping(), multiplicity);
955 ATH_MSG_DEBUG(
"XE MULT calculated mult for threshold " << confThr.
name() <<
" : " << multiplicity);
963 if(m_iKeyMuctpi.empty()) {
966 unsigned int multiplicity = 0;
968 if ( ctpinMuon.isValid() ) {
969 auto & triggerline =
l1menu->connector(
"MuCTPiOpt0").triggerLine(confThr.
name());
970 multiplicity =
CTPUtil::getMuonMult( ctpinMuon->muCTPIWord(), triggerline.startbit() + (m_muonRun2Format ? 1 : 0), triggerline.endbit()+ (m_muonRun2Format ? 1 : 0) );
972 get2DHist(
"/multi/muon/" + confThr.
type() +
"Mult" )->Fill(confThr.
mapping(), multiplicity);
973 ATH_MSG_DEBUG(
"MU MULT calculated mult for threshold " << confThr.
name() <<
" : " << multiplicity);
980 if(m_iKeyTopo.empty() || !m_doL1Topo ) {
983 unsigned int multiplicity = 0;
985 std::string connector =
"";
986 if (topoInput.isValid()) {
987 connector =
l1menu->connectorNameFromThreshold(confThr.
name());
988 auto & triggerline =
l1menu->connector(connector).triggerLine(confThr.
name());
989 std::bitset<128> bits = topoInput->optcableWord(connector);
992 std::string subfolder =
"";
993 if (confThr.
type().find(
"XE") != std::string::npos) {
995 }
else if (confThr.
type().find(
"TE") != std::string::npos) {
997 }
else if (confThr.
type().find(
"TAU") != std::string::npos) {
999 }
else if (confThr.
type().find(
"EM") != std::string::npos) {
1001 }
else if (confThr.
type().find(
"jJ") != std::string::npos) {
1003 }
else if (confThr.
type().find(
"jLJ") != std::string::npos) {
1005 }
else if (confThr.
type().find(
"gJ") != std::string::npos) {
1007 }
else if (confThr.
type().find(
"gLJ") != std::string::npos) {
1010 get2DHist(
"/multi/" + subfolder +
"/" + confThr.
type() +
"Mult" )->Fill(confThr.
mapping(), multiplicity);
1011 ATH_MSG_DEBUG(
"TOPO OPT input MULT calculated mult for threshold " << confThr.
name() <<
" : " << multiplicity <<
" received via connector: " << connector);
1013 return multiplicity;
1019 unsigned int multiplicity = 0;
1021 if (m_iKeyLegacyTopo.empty() || !m_doL1TopoLegacy )
1027 if(topoInput.isValid()) {
1029 std::string
conn(
"");
1030 if(
l1menu->connector(
"LegacyTopo0").hasLine(confThr.
name()) ) {
1031 conn =
"LegacyTopo0";
1032 cable = ( (
uint64_t)topoInput->cableWord1( 1 ) << 32) + topoInput->cableWord1( 0 );
1033 }
else if(
l1menu->connector(
"LegacyTopo1").hasLine(confThr.
name()) ) {
1034 conn =
"LegacyTopo1";
1035 cable = ( (
uint64_t)topoInput->cableWord2( 1 ) << 32) + topoInput->cableWord2( 0 );
1038 auto & triggerline =
l1menu->connector(
conn).triggerLine(confThr.
name());
1040 <<
", cable start " << triggerline.startbit() <<
" and end " << triggerline.endbit()
1041 <<
" double word 0x" << std::setw(16) << std::setfill(
'0') << std::hex << cable << std::dec << std::setfill(
' ') );
1042 multiplicity =
CTPUtil::getMultTopo( cable, triggerline.startbit(), triggerline.endbit(), triggerline.clock() );
1047 if (m_iKeyTopo.empty() || !m_doL1Topo )
1053 if(topoInput.isValid()) {
1055 std::string
conn(
"");
1056 if(
l1menu->connector(
"Topo2El").hasLine(confThr.
name()) ) {
1058 cable = ( (
uint64_t)topoInput->cableWord1( 1 ) << 32) + topoInput->cableWord1( 0 );
1059 }
else if(
l1menu->connector(
"Topo3El").hasLine(confThr.
name()) ) {
1061 cable = ( (
uint64_t)topoInput->cableWord2( 1 ) << 32) + topoInput->cableWord2( 0 );
1064 auto & triggerline =
l1menu->connector(
conn).triggerLine(confThr.
name());
1066 <<
", cable start " << triggerline.startbit() <<
" and end " << triggerline.endbit()
1067 <<
" double word 0x" << std::setw(16) << std::setfill(
'0') << std::hex << cable << std::dec << std::setfill(
' ') );
1068 multiplicity =
CTPUtil::getMultTopo( cable, triggerline.startbit(), triggerline.endbit(), triggerline.clock() );
1072 return multiplicity;
1078 unsigned int multiplicity = 0;
1080 if ( confThr.
type() ==
"EM" ) {
1081 multiplicity = calculateEMMultiplicity( confThr,
l1menu, context );
1082 }
else if ( confThr.
type() ==
"TAU" ) {
1083 multiplicity = calculateTauMultiplicity( confThr,
l1menu, context );
1084 }
else if ( confThr.
type() ==
"XE" || confThr.
type() ==
"TE" || confThr.
type() ==
"XS" ) {
1085 multiplicity = calculateMETMultiplicity( confThr,
l1menu, context );
1086 }
else if ( confThr.
type() ==
"JET" ) {
1087 multiplicity = calculateJetMultiplicity( confThr,
l1menu, context );
1088 }
else if ( confThr.
type() ==
"MU" ) {
1089 multiplicity = calculateMuonMultiplicity( confThr,
l1menu, context );
1090 }
else if ( confThr.
type() ==
"R2TOPO") {
1091 multiplicity = calculateTopoMultiplicity( confThr,
l1menu, context,
true );
1092 }
else if ( confThr.
type() ==
"TOPO" ) {
1093 multiplicity = calculateTopoMultiplicity( confThr,
l1menu, context, m_doL1TopoLegacy);
1094 }
else if ( confThr.
type()[0] ==
'e' || confThr.
type()[0] ==
'c' || confThr.
type()[0] ==
'j' || confThr.
type()[0] ==
'g' ){
1095 multiplicity = calculateTopoOptMultiplicity( confThr,
l1menu, context );
1099 ATH_MSG_FATAL(
"Caught exception when calculating multiplicity for threshold " << confThr.
name() <<
": " << ex.what());
1103 return multiplicity;
1108 const EventContext& context)
const
1111 std::vector<uint32_t> tip;
1112 CHECK( m_resultBuilder->constructTIPVector( thrMultiMap, tip ) );
1114 std::map<std::string, unsigned int> itemDecisionMap;
1115 CLHEP::HepRandomEngine* rndmEngine = m_RNGEngines.getEngine( context );
1116 CHECK( m_resultBuilder->buildItemDecision(thrMultiMap, itemDecisionMap, rndmEngine) );
1118 std::vector<uint32_t> tbp;
1119 std::vector<uint32_t>
tap;
1120 std::vector<uint32_t> tav;
1122 CHECK( m_resultBuilder->constructResultVectors( itemDecisionMap, tbp,
tap, tav,
triggerType ) );
1128 auto eventID = context.eventID();
1129 std::unique_ptr<CTP_RDO> rdo = m_resultBuilder->constructRDOResult( eventID, tbp,
tap, tav, tip,
extra );
1130 std::unique_ptr<CTPSLink> roi = m_resultBuilder->constructRoIResult( eventID, tbp,
tap, tav, tip,
extra,
triggerType );
1135 ATH_CHECK( rdoWriteHandle.record( std::move(rdo) ));
1136 ATH_CHECK( sLinkWriteHandle.record( std::move(roi) ));
1140 auto tbpById = *get1DHist(
"/output/tbpById" );
1141 auto tapById = *get1DHist(
"/output/tapById" );
1142 auto tavById = *get1DHist(
"/output/tavById" );
1143 for(
unsigned int ctpId= 0; ctpId < 512; ++ctpId ) {
1144 unsigned int wordNr = ctpId / 32;
1145 unsigned int posWithinWord = ctpId % 32;
1146 auto mask = 1L << posWithinWord;
1147 if( 0 != (tbp[wordNr] &
mask) ) {
1148 tbpById->Fill( ctpId );
1150 if( 0 != (
tap[wordNr] &
mask) ) {
1151 tapById->Fill( ctpId );
1153 if( 0 != (tav[wordNr] &
mask) ) {
1154 tavById->Fill( ctpId );
1158 return StatusCode::SUCCESS;
1168 constexpr
unsigned int sizeOfCTPOutput = 512;
1170 unsigned int tbp[sizeOfCTPOutput];
1171 unsigned int tap[sizeOfCTPOutput];
1172 unsigned int tav[sizeOfCTPOutput];
1174 auto h = *get1DHist(
"/output/tbpById" );
1175 for(
unsigned int id = 0;
id < sizeOfCTPOutput; ++
id ) tbp[
id] =
h->GetBinContent(
id+1);
1178 auto h = *get1DHist(
"/output/tapById" );
1179 for(
unsigned int id = 0;
id < sizeOfCTPOutput; ++
id )
tap[
id] =
h->GetBinContent(
id+1);
1182 auto h = *get1DHist(
"/output/tavById" );
1183 for(
unsigned int id = 0;
id < sizeOfCTPOutput; ++
id ) tav[
id] =
h->GetBinContent(
id+1);
1188 auto htbp = *get1DHist(
"/output/tbpByName" );
1189 auto htap = *get1DHist(
"/output/tapByName" );
1190 auto htav = *get1DHist(
"/output/tavByName" );
1192 unsigned int ctpId =
item.ctpId();
1193 htbp->Fill(
item.name().c_str(), tbp[ctpId]);
1194 htap->Fill(
item.name().c_str(),
tap[ctpId]);
1195 htav->Fill(
item.name().c_str(), tav[ctpId]);
1200 htbp->LabelsDeflate();
1201 htap->LabelsDeflate();
1202 htav->LabelsDeflate();
1209 std::vector<std::string> thrHists{
"em/EM",
"muon/MU",
"tau/TAU",
"jet/JET",
"xe/XE",
"te/TE",
"xs/XS" };
1210 auto hist = * get2DHist(
"/multi/all/LegacyMult" );
1211 for(
const std::string &
histpath : thrHists) {
1212 auto h = * get2DHist(
"/multi/" +
histpath +
"Mult" );
1213 auto xaxis =
h->GetXaxis();
1214 size_t xsize = xaxis->GetNbins();
1215 size_t ysize =
h->GetNbinsY();
1216 for(
size_t x = 1;
x<xsize;
x++) {
1218 for(
size_t y = 1;
y<=ysize;
y++) {
1219 size_t binContent =
h->GetBinContent(
x,
y);
1220 hist->Fill(xaxis->GetBinLabel(
x),
y-1,binContent);
1223 ATH_MSG_DEBUG(
"REGTEST CTPSim " << xaxis->GetBinLabel(
x) <<
" MULT " <<
s);
1227 hist->LabelsDeflate();
1231 auto hist = * get2DHist(
"/multi/all/R3Mult" );
1232 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" };
1233 for(
const std::string &
histpath : thrHists) {
1234 auto h = * get2DHist(
"/multi/" +
histpath +
"Mult" );
1235 auto xaxis =
h->GetXaxis();
1236 size_t xsize = xaxis->GetNbins();
1237 size_t ysize =
h->GetNbinsY();
1238 for(
size_t x = 1;
x<=xsize;
x++) {
1240 for(
size_t y = 1;
y<=ysize;
y++) {
1241 size_t binContent =
h->GetBinContent(
x,
y);
1242 hist->Fill(xaxis->GetBinLabel(
x) ,
y-1, binContent);
1245 ATH_MSG_DEBUG(
"REGTEST CTPSim " << xaxis->GetBinLabel(
x) <<
" MULT " <<
s);
1249 hist->LabelsDeflate();
1255 " TBP " << tbp[
item.ctpId()] <<
1256 " TAP " <<
tap[
item.ctpId()] <<
1257 " TAV " << tav[
item.ctpId()]);
1260 return StatusCode::SUCCESS;
1269 std::vector<std::string> storedPaths;
1270 for(
auto &
entry : m_hist1D ) {
1271 storedPaths.push_back( getBaseHistPath() +
entry.first);
1273 for(
auto &
entry : m_hist2D ) {
1274 storedPaths.push_back( getBaseHistPath() +
entry.first);
1276 std::scoped_lock<std::mutex> metadataLock(s_metadataMutex);
1277 for (
const auto &
path : storedPaths) {
1278 size_t pos =
path.find_last_of(
'/');
1279 auto splitPath = std::make_pair(
path.substr(0,
pos),
path.substr(
pos + 1));
1280 std::string treePath = splitPath.first +
"/metadata";
1282 char triggerData[] =
"<none>";
1283 const std::string mergeDataStr =
"<default>";
1284 std::vector<char> mergeData{mergeDataStr.begin(), mergeDataStr.end()};
1285 mergeData.push_back(
'\0');
1287 if (!m_histSvc->existsTree(treePath)) {
1288 auto tree = std::make_unique<TTree>(
"metadata",
"Monitoring Metadata");
1289 tree->SetDirectory(
nullptr);
1290 tree->Branch(
"Name", &(splitPath.second[0]),
"Name/C");
1291 tree->Branch(
"Interval", &(
interval[0]),
"Interval/C");
1292 tree->Branch(
"TriggerChain", triggerData,
"TriggerChain/C");
1293 tree->Branch(
"MergeMethod", mergeData.data(),
"MergeMethod/C");
1295 if (!m_histSvc->regTree(treePath, std::move(
tree))) {
1298 <<
"Failed to register DQ metadata TTree " << treePath <<
endmsg;
1301 TTree *
tree{
nullptr};
1302 if (m_histSvc->getTree(treePath,
tree).isSuccess()) {
1303 tree->SetBranchAddress(
"Name", &(splitPath.second[0]));
1305 tree->SetBranchAddress(
"TriggerChain", triggerData);
1306 tree->SetBranchAddress(
"MergeMethod", mergeData.data());
1311 <<
"Failed to retrieve DQ metadata TTree " << treePath <<
" which is reported to exist" <<
endmsg;
1315 return StatusCode::SUCCESS;