ATLAS Offline Software
TrigFPGATrackSimRawHitsWrapperAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "GaudiKernel/ThreadLocalContext.h"
8 
9 #include "TFile.h"
10 #include "TTree.h"
11 #include "TH2F.h"
12 
14 
15 
16 TrigFPGATrackSimRawHitsWrapperAlg::TrigFPGATrackSimRawHitsWrapperAlg(const std::string& name, ISvcLocator* pSvcLocator) :
17  AthAlgorithm(name, pSvcLocator)
18 {}
19 
20 
22 {
23  ATH_MSG_DEBUG("TrigFPGATrackSimRawHitsWrapperAlg::initialize()");
24 
25 
26  ATH_CHECK(m_hitInputTool.retrieve());
27  ATH_MSG_DEBUG("Setting FPGATrackSim_SGHitInput tool");
28 
29  ATH_MSG_INFO("Creating output file: " << m_outpath);
30  TNamed meta("metadata",m_metaData.value().c_str());
31  m_outfile = TFile::Open(m_outpath.value().c_str(), "recreate");
32  meta.Write();
34 
35  ATH_MSG_DEBUG("instantiating tree");
36  m_EventTree = new TTree("FPGATrackSimEventTree", "data");
37 
38  ATH_MSG_DEBUG("Setting branch");
39  m_EventTree->Branch("FPGATrackSimEventInputHeader",
40  "FPGATrackSimEventInputHeader",
41  &m_eventHeader, 6400, 1);
42 
43  ATH_MSG_DEBUG("Finished initialize");
44 
45  return StatusCode::SUCCESS;
46 }
47 
48 
50  ATH_MSG_DEBUG("Running on event ");
51 
52  ATH_CHECK(m_eventHeader != nullptr);
53  ATH_CHECK(m_hitInputTool->readData(m_eventHeader, Gaudi::Hive::currentContext()));
54  m_EventTree->Fill();
55  return StatusCode::SUCCESS;
56 
57 }
58 
59 
61 {
62  // close the output files, but check that it exists (for athenaMP)
63  if (m_outfile) {
64  m_outfile->Write();
65  m_outfile->Close();
66  }
67  delete m_eventHeader;
68  return StatusCode::SUCCESS;
69 }
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSimTowerInputHeader.h
TrigFPGATrackSimRawHitsWrapperAlg.h
TrigFPGATrackSimRawHitsWrapperAlg::m_outfile
TFile * m_outfile
Definition: TrigFPGATrackSimRawHitsWrapperAlg.h:38
TrigFPGATrackSimRawHitsWrapperAlg::m_metaData
Gaudi::Property< std::string > m_metaData
Definition: TrigFPGATrackSimRawHitsWrapperAlg.h:34
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
TrigFPGATrackSimRawHitsWrapperAlg::finalize
virtual StatusCode finalize() override
Definition: TrigFPGATrackSimRawHitsWrapperAlg.cxx:60
TrigFPGATrackSimRawHitsWrapperAlg::m_hitInputTool
ToolHandle< IFPGATrackSimInputTool > m_hitInputTool
Definition: TrigFPGATrackSimRawHitsWrapperAlg.h:32
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FPGATrackSimEventInputHeader
Definition: FPGATrackSimEventInputHeader.h:22
AthAlgorithm
Definition: AthAlgorithm.h:47
TrigFPGATrackSimRawHitsWrapperAlg::execute
virtual StatusCode execute() override
Definition: TrigFPGATrackSimRawHitsWrapperAlg.cxx:49
FPGATrackSimEventInputHeader.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrigFPGATrackSimRawHitsWrapperAlg::m_outpath
Gaudi::Property< std::string > m_outpath
Definition: TrigFPGATrackSimRawHitsWrapperAlg.h:33
TrigFPGATrackSimRawHitsWrapperAlg::initialize
virtual StatusCode initialize() override
Definition: TrigFPGATrackSimRawHitsWrapperAlg.cxx:21
TrigFPGATrackSimRawHitsWrapperAlg::m_eventHeader
FPGATrackSimEventInputHeader * m_eventHeader
Definition: TrigFPGATrackSimRawHitsWrapperAlg.h:37
TrigFPGATrackSimRawHitsWrapperAlg::TrigFPGATrackSimRawHitsWrapperAlg
TrigFPGATrackSimRawHitsWrapperAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigFPGATrackSimRawHitsWrapperAlg.cxx:16
TrigFPGATrackSimRawHitsWrapperAlg::m_EventTree
TTree * m_EventTree
Definition: TrigFPGATrackSimRawHitsWrapperAlg.h:39