ATLAS Offline Software
ActsPropStepRootWriterSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ACTSGEOMETRY_ACTSPROPSTEPROOTWRITERSVC_H
6 #define ACTSGEOMETRY_ACTSPROPSTEPROOTWRITERSVC_H
7 
9 #include "GaudiKernel/IInterface.h"
10 #include "Gaudi/Property.h" /*no forward decl: typedef*/
11 
13 
14 #include "Acts/EventData/TrackParameters.hpp"
15 
16 #include <vector>
17 #include <deque>
18 #include <mutex>
19 #include <thread>
20 #include <atomic>
21 
22 template <typename T>
24 
25 
26 namespace Acts {
27 
28 template <class>
29 class ExtrapolationCell;
30 
31 }
32 
33 class TFile;
34 class TTree;
35 
36 
37 class ActsPropStepRootWriterSvc : public extends<AthService, IActsPropStepRootWriterSvc> {
38 public:
39 
40  virtual StatusCode initialize() override;
41  virtual StatusCode finalize() override;
42 
43  ActsPropStepRootWriterSvc( const std::string& name, ISvcLocator* svc );
44 
45  using StepVector = std::vector<Acts::detail::Step>;
46 
47  void
48  write(const StepVector& steps) override;
49 
50 private:
51  using queue_item_t = std::pair<size_t, StepVector>;
52 
53  //std::shared_ptr<RootPropStepWriter<Acts::TrackParameters>> m_rootEccWriter;
54  std::deque<queue_item_t> m_queue;
56  std::thread m_writeThread;
57  std::atomic<bool> m_doEnd;
58 
59  void writeThread();
60  void doWrite(const StepVector& steps, size_t evtNum);
61  void end();
62 
63  // jobOptions properties
64  Gaudi::Property<std::string> m_filePath{this, "FilePath", "propsteps.root", "Output root file for charged particle"};
65  Gaudi::Property<std::string> m_treeName{this, "TreeName", "propsteps", ""};
66  //Gaudi::Property<bool> m_writeBoundary{this, "WriteBoundary", true, ""};
67  //Gaudi::Property<bool> m_writeMaterial{this, "WriteMaterial", true, ""};
68  //Gaudi::Property<bool> m_writeSensitive{this, "WriteSensitive", true, ""};
69  //Gaudi::Property<bool> m_writePassive{this, "WritePassive", true, ""};
70 
71  // root branch storage
72  TFile* m_outputFile{};
73  TTree* m_outputTree{};
74  int m_eventNum{};
75  std::vector<float> m_s_pX;
76  std::vector<float> m_s_pY;
77  std::vector<float> m_s_pZ;
78  std::vector<float> m_s_pR;
79  std::vector<int> m_s_volumeID;
80  std::vector<int> m_s_boundaryID;
81  std::vector<int> m_s_layerID;
82  std::vector<int> m_s_approachID;
83  std::vector<int> m_s_sensitiveID;
84 
85 };
86 
87 
88 #endif
ActsPropStepRootWriterSvc
Definition: ActsPropStepRootWriterSvc.h:37
ActsPropStepRootWriterSvc::m_s_sensitiveID
std::vector< int > m_s_sensitiveID
sensitive identification
Definition: ActsPropStepRootWriterSvc.h:83
ActsPropStepRootWriterSvc::initialize
virtual StatusCode initialize() override
Definition: ActsPropStepRootWriterSvc.cxx:26
ActsPropStepRootWriterSvc::m_queue
std::deque< queue_item_t > m_queue
Definition: ActsPropStepRootWriterSvc.h:54
ActsPropStepRootWriterSvc::m_outputTree
TTree * m_outputTree
the output tree
Definition: ActsPropStepRootWriterSvc.h:73
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
ActsPropStepRootWriterSvc::finalize
virtual StatusCode finalize() override
Definition: ActsPropStepRootWriterSvc.cxx:60
ActsPropStepRootWriterSvc::m_s_layerID
std::vector< int > m_s_layerID
layer identification
Definition: ActsPropStepRootWriterSvc.h:81
ActsPropStepRootWriterSvc::write
void write(const StepVector &steps) override
Definition: ActsPropStepRootWriterSvc.cxx:68
ActsPropStepRootWriterSvc::m_s_pY
std::vector< float > m_s_pY
global position y of the step
Definition: ActsPropStepRootWriterSvc.h:76
ActsPropStepRootWriterSvc::m_s_boundaryID
std::vector< int > m_s_boundaryID
boundary identification
Definition: ActsPropStepRootWriterSvc.h:80
ActsPropStepRootWriterSvc::doWrite
void doWrite(const StepVector &steps, size_t evtNum)
Definition: ActsPropStepRootWriterSvc.cxx:120
ActsPropStepRootWriterSvc::m_writeMutex
std::mutex m_writeMutex
Definition: ActsPropStepRootWriterSvc.h:55
beamspotman.steps
int steps
Definition: beamspotman.py:505
ActsPropStepRootWriterSvc::ActsPropStepRootWriterSvc
ActsPropStepRootWriterSvc(const std::string &name, ISvcLocator *svc)
Definition: ActsPropStepRootWriterSvc.cxx:21
Acts
Definition: ChamberAssembleTool.h:18
ActsPropStepRootWriterSvc::m_s_pX
std::vector< float > m_s_pX
global position x of the step
Definition: ActsPropStepRootWriterSvc.h:75
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
ActsPropStepRootWriterSvc::writeThread
void writeThread()
Definition: ActsPropStepRootWriterSvc.cxx:82
ActsPropStepRootWriterSvc::end
void end()
Definition: ActsPropStepRootWriterSvc.cxx:169
IActsPropStepRootWriterSvc.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsPropStepRootWriterSvc::StepVector
std::vector< Acts::detail::Step > StepVector
Definition: ActsPropStepRootWriterSvc.h:45
ActsPropStepRootWriterSvc::m_s_approachID
std::vector< int > m_s_approachID
approach identification
Definition: ActsPropStepRootWriterSvc.h:82
ActsPropStepRootWriterSvc::m_treeName
Gaudi::Property< std::string > m_treeName
Definition: ActsPropStepRootWriterSvc.h:65
ActsPropStepRootWriterSvc::m_s_pZ
std::vector< float > m_s_pZ
global position z of the step
Definition: ActsPropStepRootWriterSvc.h:77
ActsPropStepRootWriterSvc::m_s_pR
std::vector< float > m_s_pR
global position z of the step
Definition: ActsPropStepRootWriterSvc.h:78
ActsPropStepRootWriterSvc::queue_item_t
std::pair< size_t, StepVector > queue_item_t
Definition: ActsPropStepRootWriterSvc.h:51
AthService.h
ActsPropStepRootWriterSvc::m_outputFile
TFile * m_outputFile
the output file
Definition: ActsPropStepRootWriterSvc.h:72
RootPropStepWriter
Definition: ActsPropStepRootWriterSvc.h:23
ActsPropStepRootWriterSvc::m_s_volumeID
std::vector< int > m_s_volumeID
volume identification
Definition: ActsPropStepRootWriterSvc.h:79
ActsPropStepRootWriterSvc::m_filePath
Gaudi::Property< std::string > m_filePath
Definition: ActsPropStepRootWriterSvc.h:64
ActsPropStepRootWriterSvc::m_eventNum
int m_eventNum
Definition: ActsPropStepRootWriterSvc.h:74
ActsPropStepRootWriterSvc::m_writeThread
std::thread m_writeThread
Definition: ActsPropStepRootWriterSvc.h:56
ActsPropStepRootWriterSvc::m_doEnd
std::atomic< bool > m_doEnd
Definition: ActsPropStepRootWriterSvc.h:57