Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
NSWL1Simulation.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 "NSWL1Simulation.h"
6 
7 namespace NSWL1 {
8  NSWL1Simulation::NSWL1Simulation( const std::string& name, ISvcLocator* pSvcLocator )
9  : AthReentrantAlgorithm( name, pSvcLocator ),
10  m_histSvc( "THistSvc/THistSvc", name )
11  {}
12 
13 
15  ATH_MSG_DEBUG( "initialize " << name() );
17 
18  // Do not allow debug ntuple in multi-threaded mode
19  if(m_doNtuple and Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() > 1) {
20  ATH_MSG_ERROR("DoNtuple is not possible in multi-threaded mode");
21  return StatusCode::FAILURE;
22  }
23 
24  if(m_dosTGC){
25  if(m_doPad || m_doStrip) ATH_CHECK(m_pad_tds.retrieve());
26  ATH_CHECK(m_pad_trigger.retrieve());
27  if(m_doStrip){
28  ATH_CHECK(m_strip_tds.retrieve());
29  ATH_CHECK(m_strip_cluster.retrieve());
30  ATH_CHECK(m_strip_segment.retrieve());
31  }
32  }
33 
34  if(m_doMM){
35  ATH_CHECK(m_mmtrigger.retrieve());
36  if(m_doNtuple) ATH_CHECK(m_mmtrigger->attachBranches(m_altree));
37  }
38 
39  ATH_CHECK(m_trigProcessor.retrieve());
40 
41  if(m_doNtuple) ATH_CHECK(m_altree.init(this));
42  return StatusCode::SUCCESS;
43  }
44 
45 
46  StatusCode NSWL1Simulation::execute(const EventContext& ctx) const {
47  std::vector<std::shared_ptr<PadData>> pads;
48  std::vector<std::unique_ptr<PadTrigger>> padTriggers;
49  std::vector<std::unique_ptr<StripData>> strips;
50  std::vector<std::unique_ptr<StripClusterData> > clusters;
51  auto padTriggerContainer = std::make_unique<Muon::NSW_PadTriggerDataContainer>();
52  auto stripTriggerContainer = std::make_unique<Muon::NSW_TrigRawDataContainer>();
53  auto MMTriggerContainer = std::make_unique<Muon::NSW_TrigRawDataContainer>();
54 
55  if(m_dosTGC){
56  if(m_doPad || m_doStrip) ATH_CHECK( m_pad_tds->gather_pad_data(pads) );
57  ATH_CHECK( m_pad_trigger->compute_pad_triggers(pads, padTriggers) );
58  if(m_doStrip){
59  ATH_CHECK( m_strip_tds->gather_strip_data(strips,padTriggers) );
60  ATH_CHECK( m_strip_cluster->cluster_strip_data(ctx, strips, clusters) );
61  ATH_CHECK( m_strip_segment->find_segments(clusters,stripTriggerContainer) );
62  }
63  if(m_doPad) ATH_CHECK(PadTriggerAdapter::fillContainer(padTriggerContainer, padTriggers, ctx.eventID().event_number()));
64  }
65 
66  if(m_doMM){
67  ATH_CHECK( m_mmtrigger->runTrigger(ctx, MMTriggerContainer.get(), m_doMMDiamonds) );
68  }
69 
70  // Store output in debug ntuple when running in single-thread only
71  if(m_doNtuple) {
72  static std::mutex mutex;
73  std::scoped_lock lock(mutex);
74  bool success ATLAS_THREAD_SAFE = m_altree.fill(ctx);
75  if(!success) return StatusCode::FAILURE;
76  }
77 
79  auto trgContainer=std::make_unique<Muon::NSW_TrigRawDataContainer>();
80  ATH_CHECK( m_trigProcessor->mergeRDO(padTriggerContainer.get(), stripTriggerContainer.get(), MMTriggerContainer.get(), trgContainer.get()) );
81  ATH_CHECK(rdohandle.record(std::move(trgContainer)));
82  return StatusCode::SUCCESS;
83  }
84 
86  if(m_doNtuple) ATH_CHECK(m_altree.write());
87  return StatusCode::SUCCESS;
88  }
89 }
NSWL1::NSWL1Simulation::m_trigProcessor
ToolHandle< ITriggerProcessorTool > m_trigProcessor
Definition: NSWL1Simulation.h:66
NSWL1::NSWL1Simulation::m_strip_cluster
ToolHandle< IStripClusterTool > m_strip_cluster
Definition: NSWL1Simulation.h:63
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
NSWL1::NSWL1Simulation::m_strip_tds
ToolHandle< IStripTdsTool > m_strip_tds
Definition: NSWL1Simulation.h:62
NSWL1::NSWL1Simulation::m_trigRdoContainer
SG::WriteHandleKey< Muon::NSW_TrigRawDataContainer > m_trigRdoContainer
Definition: NSWL1Simulation.h:57
NSWL1::NSWL1Simulation::m_pad_trigger
ToolHandle< IPadTriggerLogicTool > m_pad_trigger
Definition: NSWL1Simulation.h:61
NSWL1::NSWL1Simulation::m_mmtrigger
ToolHandle< IMMTriggerTool > m_mmtrigger
Definition: NSWL1Simulation.h:65
NSWL1::NSWL1Simulation::ATLAS_THREAD_SAFE
MuonVal::MuonTesterTree m_altree ATLAS_THREAD_SAFE
Definition: NSWL1Simulation.h:77
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
NSWL1::NSWL1Simulation::NSWL1Simulation
NSWL1Simulation(const std::string &name, ISvcLocator *pSvcLocator)
Definition: NSWL1Simulation.cxx:8
NSWL1::NSWL1Simulation::finalize
virtual StatusCode finalize() override
Definition: NSWL1Simulation.cxx:85
NSWL1::NSWL1Simulation::m_pad_tds
ToolHandle< IPadTdsTool > m_pad_tds
Definition: NSWL1Simulation.h:60
NSWL1::NSWL1Simulation::m_doNtuple
Gaudi::Property< bool > m_doNtuple
Definition: NSWL1Simulation.h:68
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
NSWL1::NSWL1Simulation::m_strip_segment
ToolHandle< IStripSegmentTool > m_strip_segment
Definition: NSWL1Simulation.h:64
NSWL1::NSWL1Simulation::m_dosTGC
Gaudi::Property< bool > m_dosTGC
Definition: NSWL1Simulation.h:71
NSWL1::NSWL1Simulation::m_doStrip
Gaudi::Property< bool > m_doStrip
Definition: NSWL1Simulation.h:72
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
NSWL1::NSWL1Simulation::initialize
virtual StatusCode initialize() override
Definition: NSWL1Simulation.cxx:14
NSWL1::PadTriggerAdapter::fillContainer
StatusCode fillContainer(const std::unique_ptr< Muon::NSW_PadTriggerDataContainer > &out, const std::vector< std::unique_ptr< NSWL1::PadTrigger >> &triggers, const uint32_t l1id)
Definition: PadTriggerAdapter.cxx:17
NSWL1::NSWL1Simulation::m_doMMDiamonds
Gaudi::Property< bool > m_doMMDiamonds
Definition: NSWL1Simulation.h:70
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
MuonVal::MuonTesterTree::fill
bool fill(const EventContext &ctx)
Fills the tree per call.
Definition: MuonTesterTree.cxx:89
NSWL1::NSWL1Simulation::m_doPad
Gaudi::Property< bool > m_doPad
Definition: NSWL1Simulation.h:73
NSWL1::NSWL1Simulation::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: NSWL1Simulation.cxx:46
NSWL1
A trigger trigger candidate for a stgc sector.
Definition: NSWL1Simulation.cxx:7
NSWL1Simulation.h
NSWL1::NSWL1Simulation::m_doMM
Gaudi::Property< bool > m_doMM
Definition: NSWL1Simulation.h:69