ATLAS Offline Software
NSWL1Simulation.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "NSWL1Simulation.h"
8 
9 namespace NSWL1 {
10  NSWL1Simulation::NSWL1Simulation( const std::string& name, ISvcLocator* pSvcLocator )
11  : AthReentrantAlgorithm( name, pSvcLocator ),
12  m_tree(nullptr)
13  {}
14 
15 
17  ATH_MSG_DEBUG( "initialize " << name() );
19  // Create an register the ntuple if requested, add branch for event and run number
20  if ( m_doNtuple ) {
21  ITHistSvc* tHistSvc;
22  ATH_CHECK(service("THistSvc", tHistSvc));
23 
24  // create Ntuple and the branches
25  std::string ntuple_name = name()+"Tree";
26  m_tree = new TTree(ntuple_name.c_str(), "Ntuple of NSWL1Simulation");
27 
28  std::string tdir_name = "/"+name()+"/"+ntuple_name;
29  ATH_CHECK(tHistSvc->regTree(tdir_name,m_tree));
30  }
31 
32  // retrieving the private tools implementing the simulation
33  if(m_dosTGC){
34  if(m_doPad || m_doStrip) ATH_CHECK(m_pad_tds.retrieve());
35  //if(m_useLookup){
36  // ATH_CHECK(m_pad_trigger_lookup.retrieve());
37  //}
38  //else{
39  ATH_CHECK(m_pad_trigger.retrieve());
40  //}
41  if(m_doStrip){
42  ATH_CHECK(m_strip_tds.retrieve());
43  ATH_CHECK(m_strip_cluster.retrieve());
44  ATH_CHECK(m_strip_segment.retrieve());
45  }
46  }
47 
48  if(m_doMM ){
49  ATH_CHECK(m_mmtrigger.retrieve());
50  }
51 
52  ATH_CHECK(m_trigProcessor.retrieve());
53  return StatusCode::SUCCESS;
54  }
55 
56 
57  StatusCode NSWL1Simulation::execute(const EventContext& ctx) const {
58  std::vector<std::shared_ptr<PadData>> pads;
59  std::vector<std::unique_ptr<PadTrigger>> padTriggers;
60  std::vector<std::unique_ptr<StripData>> strips;
61  std::vector<std::unique_ptr<StripClusterData> > clusters;
62  auto padTriggerContainer = std::make_unique<Muon::NSW_PadTriggerDataContainer>();
63  auto stripTriggerContainer = std::make_unique<Muon::NSW_TrigRawDataContainer>();
64  auto MMTriggerContainer = std::make_unique<Muon::NSW_TrigRawDataContainer>();
65 
66  if(m_dosTGC){
67  if(m_doPad || m_doStrip) ATH_CHECK( m_pad_tds->gather_pad_data(pads) );
68  // if(m_useLookup){
69  // ATH_CHECK( m_pad_trigger_lookup->lookup_pad_triggers(pads, padTriggers) );
70  // }
71  // else{
72  ATH_CHECK( m_pad_trigger->compute_pad_triggers(pads, padTriggers) );
73  // }
74  if(m_doStrip){
75  ATH_CHECK( m_strip_tds->gather_strip_data(strips,padTriggers) );
76  ATH_CHECK( m_strip_cluster->cluster_strip_data(ctx, strips, clusters) );
77  ATH_CHECK( m_strip_segment->find_segments(clusters,stripTriggerContainer) );
78  }
79  if(m_doPad) ATH_CHECK(PadTriggerAdapter::fillContainer(padTriggerContainer, padTriggers, ctx.eventID().event_number()));
80  }
81 
82  //retrive the MM Strip hit data
83  if(m_doMM){
84  ATH_CHECK( m_mmtrigger->runTrigger(ctx, MMTriggerContainer.get(), m_doMMDiamonds) );
85  }
86  if(m_doNtuple && m_tree){
87  static std::mutex mutex;
88  std::scoped_lock lock(mutex);
89  TTree* locked_tree ATLAS_THREAD_SAFE = m_tree;
90  locked_tree->Fill();
91  }
92 
94  auto trgContainer=std::make_unique<Muon::NSW_TrigRawDataContainer>();
95  ATH_CHECK( m_trigProcessor->mergeRDO(padTriggerContainer.get(), stripTriggerContainer.get(), MMTriggerContainer.get(), trgContainer.get()) );
96  ATH_CHECK(rdohandle.record(std::move(trgContainer)));
97  return StatusCode::SUCCESS;
98  }
99 }
NSWL1::NSWL1Simulation::m_strip_cluster
ToolHandle< IStripClusterTool > m_strip_cluster
Definition: NSWL1Simulation.h:70
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
NSWL1::NSWL1Simulation::m_strip_tds
ToolHandle< IStripTdsTool > m_strip_tds
Definition: NSWL1Simulation.h:69
NSWL1::NSWL1Simulation::m_trigRdoContainer
SG::WriteHandleKey< Muon::NSW_TrigRawDataContainer > m_trigRdoContainer
Definition: NSWL1Simulation.h:63
NSWL1::NSWL1Simulation::m_pad_trigger
ToolHandle< IPadTriggerLogicTool > m_pad_trigger
Definition: NSWL1Simulation.h:67
NSWL1::NSWL1Simulation::m_mmtrigger
ToolHandle< IMMTriggerTool > m_mmtrigger
Definition: NSWL1Simulation.h:72
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
NSWL1::NSWL1Simulation::NSWL1Simulation
NSWL1Simulation(const std::string &name, ISvcLocator *pSvcLocator)
Definition: NSWL1Simulation.cxx:10
NSWL1::NSWL1Simulation::m_pad_tds
ToolHandle< IPadTdsTool > m_pad_tds
Definition: NSWL1Simulation.h:66
NSWL1::NSWL1Simulation::m_doNtuple
Gaudi::Property< bool > m_doNtuple
Definition: NSWL1Simulation.h:76
NSWL1::NSWL1Simulation::m_tree
TTree * m_tree
analysis ntuple
Definition: NSWL1Simulation.h:84
NSWL1::NSWL1Simulation::m_strip_segment
ToolHandle< IStripSegmentTool > m_strip_segment
Definition: NSWL1Simulation.h:71
NSWL1::NSWL1Simulation::m_dosTGC
Gaudi::Property< bool > m_dosTGC
Definition: NSWL1Simulation.h:79
NSWL1::NSWL1Simulation::m_doStrip
Gaudi::Property< bool > m_doStrip
Definition: NSWL1Simulation.h:80
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:16
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:78
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
NSWL1::NSWL1Simulation::m_doPad
Gaudi::Property< bool > m_doPad
Definition: NSWL1Simulation.h:81
NSWL1::NSWL1Simulation::m_trigProcessor
ToolHandle< TriggerProcessorTool > m_trigProcessor
Definition: NSWL1Simulation.h:73
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
NSWL1::NSWL1Simulation::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: NSWL1Simulation.cxx:57
checker_macros.h
Define macros for attributes used to control the static checker.
NSWL1
A trigger trigger candidate for a stgc sector.
Definition: NSWL1Simulation.cxx:9
NSWL1Simulation.h
NSWL1::NSWL1Simulation::m_doMM
Gaudi::Property< bool > m_doMM
Definition: NSWL1Simulation.h:77