Commit 63ff3490 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'muctpi-MT' into 'master'

Make MUCTPI MT safe

Closes ATR-23540

See merge request atlas/athena!45207
parents 5efe474f 629fae25
......@@ -77,25 +77,19 @@ def L1TopoSimulationCfg(flags):
acc = ComponentAccumulator()
#Grab the MUCTPI tool
if flags.Trigger.enableL1MuonPhase1:
from TrigT1MuctpiPhase1.TrigT1MuctpiPhase1Config import MUCTPI_AthToolCfg
muctpiTool = MUCTPI_AthToolCfg("MUCTPI_AthTool")
acc.addPublicTool(muctpiTool, primary=True)
else:
from TrigT1Muctpi.TrigT1MuctpiConfig import L1MuctpiToolRDOCfg
muctpiToolAcc = L1MuctpiToolRDOCfg(flags)
muctpiTool = muctpiToolAcc.getPrimary()
acc.merge(muctpiToolAcc)
#Configure the MuonInputProvider
if flags.Trigger.enableL1MuonPhase1:
muProvider = CompFactory.LVL1.MuonInputProvider("MuonInputProvider",
ROIBResultLocation = "", #disable input from RoIBResult
MuctpiSimTool = muctpiTool,
MuonEncoding = 1 if flags.Input.isMC else 0,
UseNewConfig = flags.Trigger.readLVL1FromJSON)
else:
#Grab the MUCTPI tool
from TrigT1Muctpi.TrigT1MuctpiConfig import L1MuctpiToolRDOCfg
muctpiToolAcc = L1MuctpiToolRDOCfg(flags)
muctpiTool = muctpiToolAcc.getPrimary()
acc.merge(muctpiToolAcc)
muProvider = CompFactory.LVL1.MuonInputProviderLegacy("MuonInputProviderLegacy",
ROIBResultLocation = "", #disable input from RoIBResult
MuctpiSimTool = muctpiTool,
......@@ -145,9 +139,6 @@ def L1TopoSimulationOldStyleCfg(flags, isLegacy):
ToolSvc.MuonInputProviderLegacy.ROIBResultLocation = "" #disable input from RoIBResult
if flags.Trigger.enableL1MuonPhase1:
from TrigT1MuctpiPhase1.TrigT1MuctpiPhase1Config import L1MuctpiPhase1Tool
ToolSvc += L1MuctpiPhase1Tool("MUCTPI_AthTool")
topoSimSeq.MuonInputProvider.MuctpiSimTool = ToolSvc.MUCTPI_AthTool
from TrigT1MuonRecRoiTool.TrigT1MuonRecRoiToolConfig import getRun3RPCRecRoiTool, getRun3TGCRecRoiTool
topoSimSeq.MuonInputProvider.RecRpcRoiTool = getRun3RPCRecRoiTool(useRun3Config=True)
topoSimSeq.MuonInputProvider.RecTgcRoiTool = getRun3TGCRecRoiTool(useRun3Config=True)
......
......@@ -51,11 +51,6 @@ MuonInputProvider::initialize() {
incidentSvc->addListener(this,"BeginRun", 100);
incidentSvc.release().ignore();
// get MuctpiTool handle
ATH_MSG_DEBUG("Retrieving MuctpiToolHandle " << m_MuctpiSimTool);
CHECK( m_MuctpiSimTool.retrieve() );
//This is a bit ugly but I've done it so the job options can be used to determine
//use of storegate
CHECK(m_MuCTPItoL1TopoLocation.initialize(!m_MuCTPItoL1TopoLocation.key().empty()));
......@@ -354,8 +349,7 @@ MuonInputProvider::fillTopoInputEvent(TCS::TopoInputEvent& inputEvent) const {
} else { // reduced granularity encoding
ATH_MSG_DEBUG("Use MuCTPiToTopo granularity Muon ROIs.");
// first see if L1Muctpi simulation already ran and object is in storegate, if not
// call tool version of the L1MuctpiSimulation and create it on the fly
// first see if L1Muctpi simulation already ran and object is in storegate, if not throw an error
const LVL1::MuCTPIL1Topo* l1topo {nullptr};
......@@ -376,16 +370,8 @@ MuonInputProvider::fillTopoInputEvent(TCS::TopoInputEvent& inputEvent) const {
}
}
} else {
ATH_MSG_DEBUG("Use MuCTPiToTopo granularity Muon ROIs: calculate from ROIs sent to RoIB");
LVL1::MuCTPIL1Topo l1topo;
CHECK(m_MuctpiSimTool->fillMuCTPIL1Topo(l1topo));
for( const MuCTPIL1TopoCandidate & cand : l1topo.getCandidates() ) {
inputEvent.addMuon( MuonInputProvider::createMuonTOB( cand ) );
if(cand.moreThan2CandidatesOverflow()){
inputEvent.setOverflowFromMuonInput(true);
ATH_MSG_DEBUG("setOverflowFromMuonInput : true (MuCTPIL1TopoCandidate from MuctpiSimTool)");
}
}
ATH_MSG_ERROR("Couldn't retrieve L1Topo inputs from StoreGate");
return StatusCode::FAILURE;
}
//BC+1 ... this can only come from simulation, in data taking this is collected by the L1Topo at its input
......
......@@ -15,7 +15,6 @@
#include "TrigT1Interfaces/MuCTPIToRoIBSLink.h"
#include "TrigT1Interfaces/TrigT1StoreGateKeys.h"
#include "TrigT1Interfaces/ITrigT1MuonRecRoiTool.h"
#include "TrigT1Interfaces/IMuctpiSimTool.h"
#include "TrigConfInterfaces/ILVL1ConfigSvc.h"
#include "TH1.h"
......@@ -89,8 +88,6 @@ namespace LVL1 {
ToolHandle<LVL1::ITrigT1MuonRecRoiTool> m_recRPCRoiTool{this, "RecRpcRoiTool", "LVL1::TrigT1RPCRecRoiTool/TrigT1RPCRecRoiTool", "RPC RoI reconstruction tool"};
ToolHandle<LVL1::ITrigT1MuonRecRoiTool> m_recTGCRoiTool{this, "RecTgcRoiTool", "LVL1::TrigT1TGCRecRoiTool/TrigT1TGCRecRoiTool", "TGC RoI reconstruction tool"};
ToolHandle<LVL1MUCTPI::IMuctpiSimTool> m_MuctpiSimTool{this, "MuctpiSimTool", "LVL1MUCTPI::L1MuctpiTool/LVL1MUCTPI__L1MuctpiTool", "Tool for MUCTPIsimulation"};
std::vector< TrigConf::TriggerThreshold* > m_MuonThresholds;
SG::ReadHandleKey<L1MUINT::MuCTPIToRoIBSLink> m_muonROILocation { this, "MuonROILocation", LVL1MUCTPI::DEFAULT_MuonRoIBLocation, "Storegate key for the Muon ROIs" };
......
// This file is really -*- C++ -*-.
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRIGT1MUCTPIPHASE1_MUCTPIRESULTS_H
#define TRIGT1MUCTPIPHASE1_MUCTPIRESULTS_H
/*
Simple holder for results of MUCTPI simulation
*/
#include "TrigT1Interfaces/MuCTPIL1Topo.h"
#include "TrigConfData/L1Threshold.h"
namespace LVL1MUCTPIPHASE1 {
struct DAQData {
DAQData(unsigned word,
const std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>, bool> >& decisions)
{
dataWord=word;
thresholdDecisions=decisions;
}
unsigned dataWord=0;
std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>, bool> > thresholdDecisions;
};
class MUCTPIResults
{
public:
LVL1::MuCTPIL1Topo l1topoData;
std::vector<unsigned int> ctp_words;
std::vector<DAQData> daq_data;
};
}
#endif
......@@ -4,7 +4,7 @@
// First the corresponding header.
#include "MUCTPI_AthAlg.h"
#include "TrigT1Interfaces/IMuctpiSimTool.h"
#include "MUCTPI_AthTool.h"
namespace LVL1MUCTPIPHASE1 {
MUCTPI_AthAlg::MUCTPI_AthAlg( const std::string& name, ISvcLocator* pSvcLocator )
......
......@@ -15,8 +15,8 @@ class description
#include "GaudiKernel/ToolHandle.h"
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
namespace LVL1MUCTPI {
class IMuctpiSimTool;
namespace LVL1MUCTPIPHASE1 {
class MUCTPI_AthTool;
}
namespace LVL1MUCTPIPHASE1 {
......@@ -32,12 +32,10 @@ namespace LVL1MUCTPIPHASE1 {
/// Regular Gaudi algorithm execute function
virtual StatusCode execute(const EventContext& eventContext) const override;
// Delete this once the algorithm has been made thread-safe (ATR-23540):
virtual bool isReEntrant() const override final { return false; }
private:
ToolHandle<LVL1MUCTPI::IMuctpiSimTool> m_muctpiTool{this, "MUCTPI_AthTool", "LVL1MUCTPIPHASE1::MUCTPI_AthTool/MUCTPI_AthTool", "Tool to steer the MUCTPI simulation"};
ToolHandle<MUCTPI_AthTool> m_muctpiTool{this, "MUCTPI_AthTool", "LVL1MUCTPIPHASE1::MUCTPI_AthTool/MUCTPI_AthTool", "Tool to steer the MUCTPI simulation"};
};
}
......
......@@ -4,7 +4,6 @@
// First the corresponding header.
#include "MUCTPI_AthTool.h"
#include "SimController.h"
#include "TriggerProcessor.h"
#include "MuonSectorProcessor.h"
#include "Configuration.h"
......@@ -52,9 +51,8 @@ namespace LVL1MUCTPIPHASE1 {
MUCTPI_AthTool::MUCTPI_AthTool(const std::string& type, const std::string& name,
const IInterface* parent)
:
base_class(type, name, parent),
m_MuCTPIL1TopoKey(LVL1MUCTPI::DEFAULT_MuonL1TopoLocation),
m_theMuctpi(new SimController())
AthAlgTool(type, name, parent),
m_MuCTPIL1TopoKey(LVL1MUCTPI::DEFAULT_MuonL1TopoLocation)
{
// Init message
......@@ -91,16 +89,6 @@ namespace LVL1MUCTPIPHASE1 {
}
void MUCTPI_AthTool::handle(const Incident& incident) {
ATH_MSG_INFO( "=======================================" );
ATH_MSG_INFO( "Handle in Phase1 MUCTPI_AthTool" );
ATH_MSG_INFO( "=======================================" );
if (incident.type()!="BeginRun") return;
ATH_MSG_DEBUG( "In MUCTPI_AthTool BeginRun incident");
}
StatusCode MUCTPI_AthTool::initialize()
{
ATH_MSG_INFO( "=======================================" );
......@@ -146,7 +134,7 @@ namespace LVL1MUCTPIPHASE1 {
ATH_MSG_INFO(" EC/Fwd file: " << ecfFileName);
ATH_MSG_INFO(" Side 0 LUT: " << side0LUTFileName);
ATH_MSG_INFO(" Side 1 LUT: " << side1LUTFileName);
std::vector<std::string> topo_errors = m_theMuctpi->configureTopo(barrelFileName,
std::vector<std::string> topo_errors = m_theMuctpi.configureTopo(barrelFileName,
ecfFileName,
side0LUTFileName,
side1LUTFileName);
......@@ -175,7 +163,7 @@ namespace LVL1MUCTPIPHASE1 {
const std::string fullFileName = PathResolverFindCalibFile( m_lutXMLFile );
ATH_MSG_DEBUG( "Full path to XML LUT file: " << fullFileName );
for (MuonSectorProcessor& msp : m_theMuctpi->getMuonSectorProcessors())
for (MuonSectorProcessor& msp : m_theMuctpi.getMuonSectorProcessors())
{
msp.configureOverlapRemoval(fullFileName);
}
......@@ -223,9 +211,9 @@ namespace LVL1MUCTPIPHASE1 {
ATH_MSG_INFO( "initialize(): use L1 trigger menu from detector store" );
const TrigConf::L1Menu * l1menu = nullptr;
ATH_CHECK( m_detStore->retrieve(l1menu) );
m_theMuctpi->getTriggerProcessor().setTrigTool(*m_trigThresholdDecisionTool);
m_theMuctpi->getTriggerProcessor().setMenu(l1menu);
for (MuonSectorProcessor& msp : m_theMuctpi->getMuonSectorProcessors())
m_theMuctpi.getTriggerProcessor().setTrigTool(*m_trigThresholdDecisionTool);
m_theMuctpi.getTriggerProcessor().setMenu(l1menu);
for (MuonSectorProcessor& msp : m_theMuctpi.getMuonSectorProcessors())
{
msp.setMenu(l1menu);
if (!msp.configurePtEncoding())
......@@ -308,14 +296,15 @@ namespace LVL1MUCTPIPHASE1 {
//always process the central slice, which defaults to bcidOffset = 0
// process the input in the MUCTPI simulation
std::string ret = m_theMuctpi->processData( &mergedInput );
MUCTPIResults results;
std::string ret = m_theMuctpi.processData(&mergedInput, results, 0);
if (ret != "")
{
REPORT_ERROR( StatusCode::FAILURE ) << "Error while processing MUCTPI data: " << ret;
return StatusCode::FAILURE;
}
// Save the output of the simulation
CHECK( saveOutput() );
CHECK( saveOutput(results) );
// check the other 4 possible BC offset values in case the input objects tells us there are
// out of time candidates
......@@ -327,9 +316,10 @@ namespace LVL1MUCTPIPHASE1 {
for (std::vector<int>::const_iterator it = m_bcidOffsetList.begin(); it != m_bcidOffsetList.end(); ++it){
if (! mergedInput.isEmptyAll( (*it) ) ){
// process the input in the MUCTPI simulation
m_theMuctpi->processData( &mergedInput, (*it));
MUCTPIResults results;
m_theMuctpi.processData( &mergedInput, results, (*it));
// Save the output of the simulation
CHECK( saveOutput( (*it) ) );
CHECK( saveOutput( results, (*it) ) );
}
}
}
......@@ -364,11 +354,11 @@ namespace LVL1MUCTPIPHASE1 {
// CHECK( Converter::convertRoIs( convertableRoIs, &convertedInput ) );
// // process the input with the MuCTPI simulation
// m_theMuctpi->processData( &convertedInput );
// m_theMuctpi.processData( &convertedInput );
// store CTP result in interface object and put to StoreGate
//TEMPORARILY REMOVED UNTIL MUCTPICTP UPDATED TO VECTOR!
//LVL1::MuCTPICTP* theCTPResult = new LVL1::MuCTPICTP( m_theMuctpi->getCTPData() );
//LVL1::MuCTPICTP* theCTPResult = new LVL1::MuCTPICTP( m_theMuctpi.getCTPData() );
//CHECK( evtStore()->record( theCTPResult, m_ctpOutputLocId ) );
// ATH_MSG_DEBUG( "CTP word recorded to StoreGate with key: "
// << m_ctpOutputLocId );
......@@ -404,7 +394,7 @@ namespace LVL1MUCTPIPHASE1 {
// CHECK( Converter::convertRDO( old_RDO->dataWord(), bcid, &convertedInput ) );
// // process the input with the MuCTPI simulation
// m_theMuctpi->processData( &convertedInput );
// m_theMuctpi.processData( &convertedInput );
// // Save the output of the simulation
// CHECK( saveOutput() );
......@@ -415,21 +405,12 @@ namespace LVL1MUCTPIPHASE1 {
StatusCode MUCTPI_AthTool::fillMuCTPIL1Topo(LVL1::MuCTPIL1Topo& l1topoCandidates, int bcidOffset) const {
// get outputs for L1Topo
ATH_MSG_DEBUG("Getting the output for L1Topo");
l1topoCandidates = m_theMuctpi->getL1TopoData(bcidOffset);
return StatusCode::SUCCESS;
}
StatusCode MUCTPI_AthTool::saveOutput(int bcidOffset) const {
StatusCode MUCTPI_AthTool::saveOutput(MUCTPIResults& results, int bcidOffset) const {
/// the standart processing is done for the central slice, with no Bcid offset
if (bcidOffset == 0 ) {
// store CTP result in interface object and put to StoreGate
const std::vector<unsigned int>& ctpData = m_theMuctpi->getTriggerProcessor().getCTPData();
const std::vector<unsigned int>& ctpData = results.ctp_words;
LVL1::MuCTPICTP* theCTPResult = new LVL1::MuCTPICTP( ctpData );
SG::WriteHandle<LVL1::MuCTPICTP> wh_muctpi_ctp(m_MuCTPICTPWriteKey);
......@@ -446,7 +427,7 @@ namespace LVL1MUCTPIPHASE1 {
}
// create MuCTPI RDO
const std::vector<DAQData>& daqData = m_theMuctpi->getTriggerProcessor().getDAQData();
const std::vector<DAQData>& daqData = results.daq_data;
// create MuCTPI xAOD
auto xAODRoIs = SG::makeHandle(m_MuCTPI_xAODWriteKey);
......@@ -466,7 +447,7 @@ namespace LVL1MUCTPIPHASE1 {
// get outputs for L1Topo and store into Storegate
ATH_MSG_DEBUG("Getting the output for L1Topo");
LVL1::MuCTPIL1Topo* l1topo = new LVL1::MuCTPIL1Topo(m_theMuctpi->getL1TopoData(bcidOffset).getCandidates());
LVL1::MuCTPIL1Topo* l1topo = new LVL1::MuCTPIL1Topo(results.l1topoData.getCandidates());
SG::WriteHandle<LVL1::MuCTPIL1Topo> wh_l1topo(m_MuCTPIL1TopoKey);
ATH_CHECK(wh_l1topo.record(std::unique_ptr<LVL1::MuCTPIL1Topo>(l1topo)));
}
......@@ -474,7 +455,7 @@ namespace LVL1MUCTPIPHASE1 {
/// if we have a bcid offset, then just get the topo output and put it on storegate
if (bcidOffset != 0) {
ATH_MSG_DEBUG("Getting the output for L1Topo for BCID slice");
LVL1::MuCTPIL1Topo* l1topoBC = new LVL1::MuCTPIL1Topo(m_theMuctpi->getL1TopoData(bcidOffset).getCandidates());
LVL1::MuCTPIL1Topo* l1topoBC = new LVL1::MuCTPIL1Topo(results.l1topoData.getCandidates());
l1topoBC->setBcidOffset(bcidOffset);
if (bcidOffset == -2){
......@@ -490,7 +471,6 @@ namespace LVL1MUCTPIPHASE1 {
SG::WriteHandle<LVL1::MuCTPIL1Topo> wh_l1topo(m_MuCTPIL1TopoKey_p2);
ATH_CHECK(wh_l1topo.record(std::unique_ptr<LVL1::MuCTPIL1Topo>(l1topoBC)));
}
}
......
......@@ -11,7 +11,9 @@
Tool to perform simulation of PhaseI MUCTPI board
*/
#include "TrigT1Interfaces/IMuctpiSimTool.h"
#include "SimController.h"
#include "MUCTPIResults.h"
#include "TrigT1Interfaces/Lvl1MuCTPIInputPhase1.h"
#include "TrigT1Interfaces/MuCTPICTP.h"
#include "TrigT1Interfaces/MuCTPIL1Topo.h"
......@@ -30,8 +32,7 @@ namespace LVL1 {
namespace LVL1MUCTPIPHASE1 {
class SimController;
class MUCTPI_AthTool : public extends2<AthAlgTool, LVL1MUCTPI::IMuctpiSimTool, IIncidentListener>
class MUCTPI_AthTool : public AthAlgTool
{
public:
......@@ -39,15 +40,12 @@ namespace LVL1MUCTPIPHASE1 {
MUCTPI_AthTool(const std::string& type, const std::string& name,
const IInterface* parent);
virtual ~MUCTPI_AthTool();
~MUCTPI_AthTool();
virtual void handle(const Incident&) override;
virtual StatusCode initialize() override;
virtual StatusCode start() override;
virtual StatusCode execute() const override;
StatusCode initialize();
StatusCode start();
StatusCode execute() const;
virtual StatusCode fillMuCTPIL1Topo(LVL1::MuCTPIL1Topo& l1topoCandidates, int bcidOffset) const override;
private:
/// Event loop method for running as part of digitization
......@@ -57,7 +55,7 @@ namespace LVL1MUCTPIPHASE1 {
/// Event loop method for running on an RDO file
StatusCode executeFromRDO() const;
/// Save the outputs of the simulation into StoreGate
StatusCode saveOutput(int bcidOffset = 0) const;
StatusCode saveOutput(MUCTPIResults& results, int bcidOffset = 0) const;
std::vector<int> m_bcidOffsetList = {-2,-1,1,2};
......@@ -112,7 +110,7 @@ namespace LVL1MUCTPIPHASE1 {
ServiceHandle<StoreGateSvc> m_detStore { this, "DetectorStore", "StoreGateSvc/DetectorStore", "Detector store to get the menu" };
SimController* m_theMuctpi;
SimController m_theMuctpi;
ToolHandle<LVL1::ITrigT1MuonRecRoiTool> m_rpcTool{this, "RPCRecRoiTool", "LVL1::TrigT1RPCRecRoiTool/LVL1__TrigT1RPCRecRoiTool", "Tool to get the eta/phi coordinates in the RPC"};
ToolHandle<LVL1::ITrigT1MuonRecRoiTool> m_tgcTool{this, "TGCRecRoiTool", "LVL1::TrigT1TGCRecRoiTool/LVL1__TrigT1TGCRecRoiTool", "Tool to get the eta/phi coordinates in the TGC"};
ToolHandle<LVL1::TrigThresholdDecisionTool> m_trigThresholdDecisionTool{this, "TrigThresholdDecisionTool", "LVL1::TrigThresholdDecisionTool/LVL1__TrigThresholdDecisionTool", "Tool to get pass/fail of each trigger threshold"};
......
......@@ -225,7 +225,6 @@ namespace LVL1MUCTPIPHASE1 {
MuonSectorProcessor::MuonSectorProcessor(bool side)
:
m_muctpiInput(nullptr),
m_overlapHelper(std::make_unique<OverlapHelper>()),
m_l1menu(nullptr),
m_l1topoLUT(nullptr),
......@@ -309,12 +308,7 @@ namespace LVL1MUCTPIPHASE1 {
}
void MuonSectorProcessor::setInput(LVL1MUONIF::Lvl1MuCTPIInputPhase1* input)
{
m_muctpiInput=input;
}
void MuonSectorProcessor::runOverlapRemoval(int bcid)
void MuonSectorProcessor::runOverlapRemoval(LVL1MUONIF::Lvl1MuCTPIInputPhase1* inputs, int bcid) const
{
std::map<std::string,std::vector<std::pair<std::shared_ptr<LVL1MUONIF::Lvl1MuSectorLogicDataPhase1>, unsigned> > > buckets;
......@@ -330,7 +324,7 @@ namespace LVL1MUCTPIPHASE1 {
if (isub != size_t(m_side)) continue;
//get a pointer to this since we'll need to modify the 'veto' flag of the SL data
std::shared_ptr<LVL1MUONIF::Lvl1MuSectorLogicDataPhase1> sectorData = m_muctpiInput->getSectorLogicDataPtr(isys, isub, isec, bcid);
std::shared_ptr<LVL1MUONIF::Lvl1MuSectorLogicDataPhase1> sectorData = inputs->getSectorLogicDataPtr(isys, isub, isec, bcid);
if (!sectorData) continue;
for (unsigned int icand=0;icand<LVL1MUONIF::NCAND[isys];icand++)
......@@ -377,9 +371,9 @@ namespace LVL1MUCTPIPHASE1 {
}
}
std::string MuonSectorProcessor::makeL1TopoData(int bcid)
std::string MuonSectorProcessor::makeL1TopoData(LVL1MUONIF::Lvl1MuCTPIInputPhase1* inputs, int bcid,
LVL1::MuCTPIL1Topo& l1topoData) const
{
m_bcid_to_l1topo[bcid] = std::make_unique<LVL1::MuCTPIL1Topo>();
// Barrel + EC + Fwd
for (unsigned short isys=0;isys<LVL1MUONIF::Lvl1MuCTPIInputPhase1::numberOfSystems();isys++)
{
......@@ -391,7 +385,7 @@ namespace LVL1MUCTPIPHASE1 {
for (unsigned short isub=0;isub<2;isub++)
{
if (isub != (unsigned short)(m_side)) continue;
const LVL1MUONIF::Lvl1MuSectorLogicDataPhase1* sectorData = &m_muctpiInput->getSectorLogicData(isys, isub, isec, bcid);
std::shared_ptr<LVL1MUONIF::Lvl1MuSectorLogicDataPhase1> sectorData = inputs->getSectorLogicDataPtr(isys, isub, isec, bcid);
if (!sectorData) continue;
//build the sector name
......@@ -494,7 +488,7 @@ namespace LVL1MUCTPIPHASE1 {
sectorData->charge(icand));
m_bcid_to_l1topo[bcid]->addCandidate(cand);
l1topoData.addCandidate(cand);
}
}
}
......@@ -502,14 +496,4 @@ namespace LVL1MUCTPIPHASE1 {
return "";
}
const LVL1MUONIF::Lvl1MuCTPIInputPhase1* MuonSectorProcessor::getOutput() const
{
return m_muctpiInput;
}
const LVL1::MuCTPIL1Topo* MuonSectorProcessor::getL1TopoData(int bcid) const
{
const auto& itr = m_bcid_to_l1topo.find(bcid);
return itr!=m_bcid_to_l1topo.end() ? itr->second.get() : nullptr;
}
}
......@@ -14,6 +14,8 @@
#include <vector>
#include <memory>
#include "MUCTPIResults.h"
namespace LVL1MUONIF {
class Lvl1MuCTPIInputPhase1;
}
......@@ -39,21 +41,19 @@ namespace LVL1MUCTPIPHASE1 {
MuonSectorProcessor(MuonSectorProcessor &&o);
MuonSectorProcessor(const MuonSectorProcessor &) = delete;
//initialization
void setMenu(const TrigConf::L1Menu* l1menu);
void setL1TopoLUT(const L1TopoLUT* l1topoLUT) {m_l1topoLUT=l1topoLUT;}
void configureOverlapRemoval(const std::string& lutFile);
bool configurePtEncoding();
void setInput(LVL1MUONIF::Lvl1MuCTPIInputPhase1* input);
void runOverlapRemoval(int bcid);
std::string makeL1TopoData(int bcid);
const LVL1::MuCTPIL1Topo* getL1TopoData(int bcid) const;
const LVL1MUONIF::Lvl1MuCTPIInputPhase1* getOutput() const;
//processing
void runOverlapRemoval(LVL1MUONIF::Lvl1MuCTPIInputPhase1* inputs, int bcid) const;
std::string makeL1TopoData(LVL1MUONIF::Lvl1MuCTPIInputPhase1* inputs, int bcid, LVL1::MuCTPIL1Topo& l1topoData) const;
bool getSide() const { return m_side; };
private:
const LVL1MUONIF::Lvl1MuCTPIInputPhase1* m_muctpiInput;
std::unordered_map<int, std::unique_ptr<LVL1::MuCTPIL1Topo>> m_bcid_to_l1topo;
std::unique_ptr<OverlapHelper> m_overlapHelper;
const TrigConf::L1Menu* m_l1menu;
const L1TopoLUT* m_l1topoLUT;
......
......@@ -52,35 +52,20 @@ namespace LVL1MUCTPIPHASE1 {
m_candBcidOffset = conf.getCandBcidOffset();
}
std::string SimController::processData(LVL1MUONIF::Lvl1MuCTPIInputPhase1* input, int bcid)
std::string SimController::processData(LVL1MUONIF::Lvl1MuCTPIInputPhase1* input, MUCTPIResults& results, int bcid) const
{
std::string ret = "";
std::vector<const LVL1MUONIF::Lvl1MuCTPIInputPhase1*> processedInputs;
for (MuonSectorProcessor& msp : m_muonSectorProcessors )
for (const MuonSectorProcessor& msp : m_muonSectorProcessors )
{
msp.setInput(input);
msp.runOverlapRemoval(bcid);
if ((ret = msp.makeL1TopoData(bcid)) != "") return ret;
processedInputs.push_back(msp.getOutput());
msp.runOverlapRemoval(input, bcid);
if ((ret = msp.makeL1TopoData(input, bcid, results.l1topoData)) != "") return ret;
processedInputs.push_back(input);
}
//Run the trigger processor algorithms
m_triggerProcessor.mergeInputs(processedInputs);
if ((ret = m_triggerProcessor.computeMultiplicities(bcid)) != "") return ret;
m_triggerProcessor.makeTopoSelections();
//Run the trigger processor algorithms
LVL1MUONIF::Lvl1MuCTPIInputPhase1 mergedInputs = m_triggerProcessor.mergeInputs(processedInputs);
if ((ret = m_triggerProcessor.computeMultiplicities(mergedInputs, bcid, results)) != "") return ret;
return "";
}
LVL1::MuCTPIL1Topo SimController::getL1TopoData(int bcid) const
{
LVL1::MuCTPIL1Topo l1topo;
for (const MuonSectorProcessor& msp : m_muonSectorProcessors )
{
const LVL1::MuCTPIL1Topo* l1topo_ptr = msp.getL1TopoData(bcid);
if (l1topo_ptr) l1topo += *l1topo_ptr;
}
return l1topo;
}
}
......@@ -14,6 +14,7 @@
#include "L1TopoLUT.h"
#include "MuonSectorProcessor.h"
#include "TriggerProcessor.h"
#include "MUCTPIResults.h"
#include "TrigT1Interfaces/Lvl1MuCTPIInputPhase1.h"
......@@ -38,11 +39,9 @@ namespace LVL1MUCTPIPHASE1 {
const std::string& side0LUTFileName,
const std::string& side1LUTFileName);
std::string processData(LVL1MUONIF::Lvl1MuCTPIInputPhase1* input, int bcid=0);
std::string processData(LVL1MUONIF::Lvl1MuCTPIInputPhase1* input, MUCTPIResults& results, int bcid) const;
void setConfiguration( const Configuration& conf );
LVL1::MuCTPIL1Topo getL1TopoData(int bcid) const;
TriggerProcessor& getTriggerProcessor() { return m_triggerProcessor; }
MuonSectorProcessors& getMuonSectorProcessors() { return m_muonSectorProcessors; }
......
......@@ -29,17 +29,18 @@ namespace LVL1MUCTPIPHASE1 {
m_l1menu = l1menu;
}