Skip to content
Snippets Groups Projects
Commit 8e16bbd7 authored by Tomasz Bold's avatar Tomasz Bold
Browse files

Integrated L1 unpacking, still need to make L1Decoder optional to RoIB result presence

parent fa38fb56
No related merge requests found
......@@ -84,7 +84,7 @@ if nThreads >= 1:
topSequence.SGInputLoader.Load = [ ('ROIB::RoIBResult','RoIBResult') ]
doL1Emulation=True
doL1Emulation=False
from L1Decoder.L1DecoderConf import CTPUnpackingTool, EMRoIsUnpackingTool, L1Decoder, MURoIsUnpackingTool
from L1Decoder.L1DecoderConf import CTPUnpackingEmulationTool, RoIsUnpackingEmulationTool
l1Decoder = L1Decoder( OutputLevel=DEBUG )
......
......@@ -36,31 +36,37 @@ StatusCode CTPUnpackingEmulationTool::parseInputFile() {
ATH_MSG_ERROR("Input file " << m_inputFileName << " inaccessible");
return StatusCode::FAILURE;
}
std::string chainName;
m_events.resize(1);
while ( inputFile >> chainName ) {
std::string line;
while ( std::getline( inputFile, line ) ) {
//check if commented out
std::size_t found = chainName.find("#");
if (found != std::string::npos) {
std::string line;
std::getline(inputFile, line);
continue;
}
auto chainId = HLT::Identifier(chainName);
std::map<size_t, HLT::IDVec>::iterator it;// IndexToIdentifiers;
for(it=m_ctpToChain.begin();it!=m_ctpToChain.end();it++) {
auto ctpId = it->first;
HLT::IDVec chains= it->second;
auto itr = find (chains.begin(), chains.end(), chainId);
if ( itr != chains.end() ) {
m_events.back().insert( ctpId );
}
if ( line[0] == '#' ) continue;
// std::size_t found = line.find("#");
// if (found != std::string::npos) {
// std::string line;
// std::getline(inputFile, line);
// continue;
// }
std::istringstream allChains( line );
HLT::IDVec ids;
while ( allChains ) {
std::string chainName;
allChains >> chainName;
ids.push_back( HLT::Identifier(chainName).numeric() );
}
// auto chainId = HLT::Identifier(chainName);
// std::map<size_t, HLT::IDVec>::iterator it;// IndexToIdentifiers;
// for(it=m_ctpToChain.begin();it!=m_ctpToChain.end();it++) {
// auto ctpId = it->first;
// HLT::IDVec chains= it->second;
// auto itr = find (chains.begin(), chains.end(), chainId);
// if ( itr != chains.end() ) {
// event.insert( ctpId );
// }
// }
// m_events.back().push_back(TrigConf::HLTUtils::string2hash(chain, "chain"));
if ( inputFile.peek() == '\n')
m_events.resize( m_events.size() + 1 ); // new event
if ( not ids.empty() )
m_events.push_back( ids ); // new event
}
inputFile.close();
......@@ -83,7 +89,7 @@ StatusCode CTPUnpackingEmulationTool::initialize() {
StatusCode CTPUnpackingEmulationTool::decode( const ROIB::RoIBResult& roib, HLT::IDVec& enabledChains ) const {
StatusCode CTPUnpackingEmulationTool::decode( const ROIB::RoIBResult& /*roib*/, HLT::IDVec& enabledChains ) const {
size_t numberPfActivatedBits= 0;
if (m_events.size() ==0){
......@@ -91,31 +97,36 @@ StatusCode CTPUnpackingEmulationTool::decode( const ROIB::RoIBResult& roib, HLT
return StatusCode::FAILURE;
}
const EventContext& context = Gaudi::Hive::currentContext();
EventContextHash hash;
size_t ctx = hash.hash(context);
int line = ctx % m_events.size();
ATH_MSG_DEBUG("Getting chains for event "<<ctx<<": retrieve combination from line "<< line);
auto tav = m_events[line];
for ( const auto& ctpIndex : tav ) {
// ATH_MSG_DEBUG("Enabling chain from CTP ID " << ctpIndex);
auto itr = m_ctpToChain.find(ctpIndex);
if ( itr != m_ctpToChain.end() ) {
enabledChains.insert( enabledChains.end(), itr->second.begin(), itr->second.end() );
}
numberPfActivatedBits++;
}
// ATH_MSG_DEBUG("Getting chains for event "<<ctx<<": retrieve combination from line "<< line);
// auto tav = m_events[line];
enabledChains = m_events[line];
// for ( const auto& ctpIndex : tav ) {
// // ATH_MSG_DEBUG("Enabling chain from CTP ID " << ctpIndex);
// auto itr = m_ctpToChain.find(ctpIndex);
// if ( itr != m_ctpToChain.end() ) {
// enabledChains.insert( enabledChains.end(), itr->second.begin(), itr->second.end() );
// }
// numberPfActivatedBits++;
// }
// for ( auto chain: enabledChains ) {
// ATH_MSG_DEBUG( "Enabling chain: " << chain );
// }
// if ( numberPfActivatedBits == 0 ) {
// ATH_MSG_ERROR( "All CTP bits were disabled, this event shoudl not have shown here" );
// return StatusCode::FAILURE;
// }
for ( auto chain: enabledChains ) {
ATH_MSG_DEBUG( "Enabling chain: " << chain );
}
if ( numberPfActivatedBits == 0 ) {
ATH_MSG_ERROR( "All CTP bits were disabled, this event shoudl not have shown here" );
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
......
......@@ -50,7 +50,9 @@ private:
std::string m_inputFileName;
// @brief returns names oc the chains (iner vector) to activate for each event (outer vector)
std::vector < std::set< size_t > > m_events; // list of CTPID enabled, per event
// std::vector < std::set< size_t > > m_events; // list of CTPID enabled, per event
std::vector < HLT::IDVec > m_events;
size_t m_event = 0;
StatusCode parseInputFile() ;
};
......
......@@ -17,7 +17,6 @@ RoIsUnpackingEmulationTool::RoIsUnpackingEmulationTool( const std::string& type,
const std::string& name,
const IInterface* parent )
: AthAlgTool ( type, name, parent ),
m_configSvc( "TrigConf::LVL1ConfigSvc/LVL1ConfigSvc", name ),
m_inputFilename("RoIEmulation.dat") {
declareProperty( "Decisions", m_decisionsKey="EMRoIDecisions", "Decisions for each RoI" );
......@@ -33,7 +32,6 @@ RoIsUnpackingEmulationTool::~RoIsUnpackingEmulationTool(){
StatusCode RoIsUnpackingEmulationTool::initialize() {
CHECK( m_configSvc.retrieve() );
CHECK( m_decisionsKey.initialize() );
CHECK( m_trigRoIsKey.initialize() );
......@@ -109,7 +107,7 @@ std::vector<std::vector<RoIsUnpackingEmulationTool::FakeRoI>> RoIsUnpackingEmula
if (result.size() == 0) {
throw std::invalid_argument("File " + m_inputFilename + " does not contain any RoI");
}
ATH_MSG_DEBUG("Read in " << result.size() << " pseudo events from " << m_inputFilename );
return result;
}
......@@ -153,32 +151,18 @@ RoIsUnpackingEmulationTool::FakeRoI RoIsUnpackingEmulationTool::parseInputRoI(co
StatusCode RoIsUnpackingEmulationTool::updateConfiguration() {
using namespace TrigConf;
const ThresholdConfig* thresholdConfig = m_configSvc->thresholdConfig();
auto filteredThresholds= thresholdConfig->getThresholdVector( L1DataDef::EM );
ATH_MSG_DEBUG( "Number of filtered thresholds " << filteredThresholds.size() );
for (auto th : filteredThresholds ) {
if ( th != nullptr ) {
ATH_MSG_DEBUG( "Found threshold in the configuration: " << th->name() << " of ID: " << HLT::Identifier(th->name()).numeric() );
m_emThresholds.push_back(th);
} else {
ATH_MSG_DEBUG( "Nullptr to the threshold" );
}
}
return StatusCode::SUCCESS;
}
StatusCode RoIsUnpackingEmulationTool::finalize()
{
StatusCode RoIsUnpackingEmulationTool::finalize(){
return StatusCode::SUCCESS;
}
StatusCode RoIsUnpackingEmulationTool::unpack( const EventContext& ctx,
const ROIB::RoIBResult& roib,
const HLT::IDSet& activeChains ) const {
const ROIB::RoIBResult& /*roib*/,
const HLT::IDSet& activeChains ) const {
using namespace TrigCompositeUtils;
auto decisionOutput = std::make_unique<DecisionContainer>();
auto decisionAux = std::make_unique<DecisionAuxContainer>();
......@@ -198,7 +182,7 @@ StatusCode RoIsUnpackingEmulationTool::unpack( const EventContext& ctx,
int line = eventId % m_inputData.size();
ATH_MSG_DEBUG("Getting RoIs for event "<<eventId<<": retrieve combination from line "<< line);
auto FakeRoIs = m_inputData[line];
for (auto& roi : FakeRoIs) {
uint32_t roIWord = roi.roIWord;
......@@ -211,20 +195,16 @@ StatusCode RoIsUnpackingEmulationTool::unpack( const EventContext& ctx,
auto decision = TrigCompositeUtils::newDecisionIn( decisionOutput.get() );
for ( auto th: m_emThresholds ) {
ATH_MSG_VERBOSE( "Checking if the threshold " << th->name() << " passed" );
for ( const auto& passedth: roi.passedThresholdIDs ) {
if (passedth == th->name() ){
ATH_MSG_DEBUG("Passed Threshold name " << th->name());
addChainsToDecision( HLT::Identifier( th->name() ), decision, activeChains );
}
}
for ( auto th: roi.passedThresholdIDs ) {
ATH_MSG_DEBUG( "Passed Threshold " << th << " enabling respective chains" );
addChainsToDecision( HLT::Identifier( th ), decision, activeChains );
// TODO would be nice to have this. Requires modifying the TC class: decision->setDetail("Thresholds", passedThresholds); // record passing threshold names (for easy debugging)
decision->setObjectLink( "initialRoI", ElementLink<TrigRoiDescriptorCollection>(m_trigRoIsKey.key(), trigRoIs->size()-1 ) );
}
}
for ( auto roi: *trigRoIs ) {
ATH_MSG_DEBUG("RoI Eta: " << roi->eta() << " Phi: " << roi->phi() << " RoIWord: " << roi->roiWord());
}
......@@ -240,7 +220,6 @@ StatusCode RoIsUnpackingEmulationTool::unpack( const EventContext& ctx,
CHECK ( handle.record( std::move( decisionOutput ), std::move( decisionAux ) ) );
}
return StatusCode::SUCCESS; // what else
}
......@@ -44,7 +44,6 @@ class RoIsUnpackingEmulationTool : virtual public AthAlgTool, virtual public IRo
RoIsUnpackingEmulationTool();
std::vector<TrigConf::TriggerThreshold*> m_emThresholds;
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_trigRoIsKey;
ServiceHandle<TrigConf::ILVL1ConfigSvc> m_configSvc;
float m_roIWidth;
// emulation
......
......@@ -16,21 +16,46 @@ svcMgr += ForwardSchedulerSvc()
svcMgr.ForwardSchedulerSvc.ShowDataFlow=True
svcMgr.ForwardSchedulerSvc.ShowControlFlow=True
include( "ByteStreamCnvSvc/BSEventStorageEventSelector_jobOptions.py" )
svcMgr.ByteStreamInputSvc.FullFileName = [ "./input.data" ]
# This is the list of proxies to set up so that retrieval attempt will trigger the BS conversion
if not hasattr( svcMgr, "ByteStreamAddressProviderSvc" ):
from ByteStreamCnvSvcBase.ByteStreamCnvSvcBaseConf import ByteStreamAddressProviderSvc
svcMgr += ByteStreamAddressProviderSvc()
svcMgr.ByteStreamAddressProviderSvc.TypeNames += [ "ROIB::RoIBResult/RoIBResult" ]
# Event-level algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence, AthSequencer
job = AlgSequence()
topSequence = AlgSequence()
from SGComps.SGCompsConf import SGInputLoader
topSequence += SGInputLoader( OutputLevel=INFO, ShowEventDump=False )
topSequence.SGInputLoader.Load = [ ('ROIB::RoIBResult','RoIBResult') ]
data = {'noreco': [';', ';', ';']} # in the lists there are the events
data['emclusters'] = ['eta:1,phi:1,et:2000; eta:1,phi:-1.2,et:3500;',
'eta:0.5,phi:0,et:1000; eta:1,phi:-1.2,et:3500;',
'eta:-0.6,phi:1.7,et:5000;']
data['msmu'] = ['eta:-1.2,phi:0.7,pt:6500; eta:-1.1,phi:0.6,pt:8500;',
'eta:-1.7,phi:-0.2,pt:6500;',
';']
data['ctp'] = [ '', ]
data['l1emroi'] = ['',]
data['l1muroi'] = ['',]
data['emclusters'] = ['eta:1,phi:1,et:180000; eta:1,phi:-1.2,et:35000;',
'eta:0.5,phi:0,et:120000; eta:1,phi:-1.2,et:65000;',
'eta:-0.6,phi:1.7,et:9000;']
data['msmu'] = [';',
'eta:-1.2,phi:0.7,pt:6500; eta:-1.1,phi:0.6,pt:8500;',
'eta:-1.7,phi:-0.2,pt:9500;']
data['ctp'] = [ 'HLT_g100', 'HLT_2g50 HLT_e20', 'HLT_mu20 HLT_mu8 HLT_2mu8 HLT_mu8_e8' ]
data['l1emroi'] = ['1,1,0,EM3,EM7,EM15,EM20,EM50,EM100; 1,-1.2,0,EM3,EM7',
'-0.6,0.2,0,EM3,EM7,EM15,EM20,EM50,EM100; 1,-1.1,0,EM3,EM7,EM15,EM20,EM50',
'-0.6,1.5,0,EM3,EM7,EM7']
data['l1muroi'] = ['0,0,0,MU0;',
'-1,0.5,0,MU6,MU8; -1,0.5,0,MU6,MU8,MU10',
'-1.5,-0.1,0,MU6,MU8']
for name, d in data.iteritems():
......@@ -69,11 +94,30 @@ def stepSeq(name, filterAlg, rest):
TopHLTSeq = seqAND("TopHLTSeq")
job += TopHLTSeq
topSequence += TopHLTSeq
L1UnpackingSeq = parOR("L1UnpackingSeq")
from L1Decoder.L1DecoderConf import CTPUnpackingEmulationTool, RoIsUnpackingEmulationTool, L1Decoder
l1Decoder = L1Decoder( OutputLevel=DEBUG )
ctpUnpacker = CTPUnpackingEmulationTool( OutputLevel = DEBUG, ForceEnableAllChains=False , InputFilename="ctp.dat" )
ctpUnpacker.CTPToChainMapping = [ "0:HLT_g100", "1:HLT_e20", "2:HLT_mu20", "3:HLT_2mu8", "3:HLT_mu8", "33:HLT_2mu8", "15:HLT_mu8_e8" ]
l1Decoder.ctpUnpacker = ctpUnpacker
emUnpacker = RoIsUnpackingEmulationTool("EMRoIsUnpackingTool", OutputLevel=DEBUG, InputFilename="l1emroi.dat", OutputTrigRoIs="L1EMRoIs", Decisions="L1EMDecisions" )
emUnpacker.ThresholdToChainMapping = ["EM7 : HLT_mu8_e8", "EM20 : HLT_e20", "EM50 : HLT_2g50", "EM100 : HLT_g100" ]
muUnpacker = RoIsUnpackingEmulationTool("MURoIsUnpackingTool", OutputLevel=DEBUG, InputFilename="l1muroi.dat", OutputTrigRoIs="L1MURoIs", Decisions="L1MUDecisions" )
muUnpacker.ThresholdToChainMapping = ["MU8 : HLT_mu8", "MU8 : HLT_2mu8", "MU10 : HLT_mu20", "EM100 : HLT_g100" ]
l1Decoder.roiUnpackers = [emUnpacker, muUnpacker]
L1UnpackingSeq += l1Decoder
TopHLTSeq += L1UnpackingSeq
steps = [ parOR("step%i" % i) for i in range(5)]
HLTChainsSeq = seqAND("HLTChainsSeq", steps)
TopHLTSeq += HLTChainsSeq # in principle we do not need the HLTChainsSeq
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment