ATLAS Offline Software
ActsMaterialTrackWriterSvc.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_ACTSMATERIALTRACKWRITERSVC_H
6 #define ACTSGEOMETRY_ACTSMATERIALTRACKWRITERSVC_H
7 
10 
12 #include "GaudiKernel/IInterface.h"
13 #include "Gaudi/Property.h" /*no forward decl: typedef*/
14 
15 #include <vector>
16 #include <deque>
17 #include <mutex>
18 #include <thread>
19 #include <atomic>
20 
21 #include "TTree.h"
22 #include "TFile.h"
23 
24 class ActsMaterialTrackWriterSvc : public extends<AthService, IActsMaterialTrackWriterSvc> {
25 public:
26 
27  virtual StatusCode initialize() override;
28  virtual StatusCode finalize() override;
29 
30  ActsMaterialTrackWriterSvc( const std::string& name, ISvcLocator* svc );
31 
32  virtual void
33  write(const Acts::RecordedMaterialTrack& mTrack) override;
34 
35 private:
36 
37  std::deque<Acts::RecordedMaterialTrack> m_mTracks;
39  std::thread m_writeThread;
40  std::atomic<bool> m_doEnd;
41  TFile* p_tFile{};
42  TTree* p_tree{};
43 
44  float m_v_x{};
45  float m_v_y{};
46  float m_v_z{};
47  float m_v_px{};
48  float m_v_py{};
49  float m_v_pz{};
50  float m_v_phi{};
51  float m_v_eta{};
52  float m_tX0{};
53  float m_tL0{};
54 
55  std::vector<float> m_step_sx;
56  std::vector<float> m_step_sy;
57  std::vector<float> m_step_sz;
58  std::vector<float> m_step_x;
59  std::vector<float> m_step_y;
60  std::vector<float> m_step_z;
61  std::vector<float> m_step_ex;
62  std::vector<float> m_step_ey;
63  std::vector<float> m_step_ez;
64  std::vector<float> m_step_dx;
65  std::vector<float> m_step_dy;
66  std::vector<float> m_step_dz;
67  std::vector<float> m_step_length;
68  std::vector<float> m_step_X0;
69  std::vector<float> m_step_L0;
70  std::vector<float> m_step_A;
71  std::vector<float> m_step_Z;
72  std::vector<float> m_step_rho;
73 
74  std::vector<std::uint64_t>
76  std::vector<int32_t>
78  std::vector<float> m_sur_x;
79  std::vector<float> m_sur_y;
81  std::vector<float> m_sur_z;
83 
85  std::vector<float>
87  std::vector<float>
89 
90  std::vector<std::uint64_t>
92 
93  void writerThread();
94  void doWrite(const Acts::RecordedMaterialTrack &mTrack);
95 
97 
98  // jobOptions properties
99  Gaudi::Property<std::string> m_filePath{this, "FilePath", "MaterialTracks.root", "Output root file for charged particle"};
100  Gaudi::Property<std::string> m_treeName{this, "TreeName", "material-tracks", ""};
101  Gaudi::Property<bool> m_storeSurface{this, "StoreSurface", true, "Store the surface info in the root file"};
102  Gaudi::Property<bool> m_storeVolume{this, "StoreVolume", true, "Store the volume info in the root file"};
103  Gaudi::Property<size_t> m_maxQueueSize{this, "MaxQueueSize", 5000, "Limit the write queue to this size"};
104 
105 };
106 
107 
108 #endif
ActsMaterialTrackWriterSvc::m_writeMutex
std::mutex m_writeMutex
Definition: ActsMaterialTrackWriterSvc.h:38
ActsMaterialTrackWriterSvc::m_trackingGeometrySvc
ServiceHandle< IActsTrackingGeometrySvc > m_trackingGeometrySvc
Definition: ActsMaterialTrackWriterSvc.h:96
ActsMaterialTrackWriterSvc::m_step_dy
std::vector< float > m_step_dy
step y direction
Definition: ActsMaterialTrackWriterSvc.h:65
ActsMaterialTrackWriterSvc::m_v_py
float m_v_py
start global momentum y
Definition: ActsMaterialTrackWriterSvc.h:48
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
ActsMaterialTrackWriterSvc::m_storeVolume
Gaudi::Property< bool > m_storeVolume
Definition: ActsMaterialTrackWriterSvc.h:102
ActsMaterialTrackWriterSvc::m_writeThread
std::thread m_writeThread
Definition: ActsMaterialTrackWriterSvc.h:39
ActsMaterialTrackWriterSvc::m_sur_range_min
std::vector< float > m_sur_range_min
Min range of the suface associated with the step.
Definition: ActsMaterialTrackWriterSvc.h:86
Acts::RecordedMaterialTrack
std::pair< std::pair< Acts::Vector3, Acts::Vector3 >, RecordedMaterial > RecordedMaterialTrack
Recorded material track.
Definition: ActsExtrapolationAlg.cxx:43
ActsMaterialTrackWriterSvc::m_v_eta
float m_v_eta
start eta direction
Definition: ActsMaterialTrackWriterSvc.h:51
ActsMaterialTrackWriterSvc::m_v_y
float m_v_y
start global y
Definition: ActsMaterialTrackWriterSvc.h:45
ActsMaterialTrackWriterSvc::m_mTracks
std::deque< Acts::RecordedMaterialTrack > m_mTracks
Definition: ActsMaterialTrackWriterSvc.h:37
ActsMaterialTrackWriterSvc::m_sur_x
std::vector< float > m_sur_x
x position of the center of the suface associated with the step
Definition: ActsMaterialTrackWriterSvc.h:78
ActsMaterialTrackWriterSvc::m_storeSurface
Gaudi::Property< bool > m_storeSurface
Definition: ActsMaterialTrackWriterSvc.h:101
ActsMaterialTrackWriterSvc::m_v_pz
float m_v_pz
start global momentum z
Definition: ActsMaterialTrackWriterSvc.h:49
ActsMaterialTrackWriterSvc::m_step_A
std::vector< float > m_step_A
step material A
Definition: ActsMaterialTrackWriterSvc.h:70
ActsMaterialTrackWriterSvc::m_step_sz
std::vector< float > m_step_sz
step z (start) position (optional)
Definition: ActsMaterialTrackWriterSvc.h:57
ActsMaterialTrackWriterSvc::m_sur_type
std::vector< int32_t > m_sur_type
Type of the suface associated with the step.
Definition: ActsMaterialTrackWriterSvc.h:77
ActsMaterialTrackWriterSvc::m_step_dx
std::vector< float > m_step_dx
step x direction
Definition: ActsMaterialTrackWriterSvc.h:64
ActsMaterialTrackWriterSvc::m_step_sy
std::vector< float > m_step_sy
step y (start) position (optional)
Definition: ActsMaterialTrackWriterSvc.h:56
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ActsMaterialTrackWriterSvc::m_step_x
std::vector< float > m_step_x
step x position
Definition: ActsMaterialTrackWriterSvc.h:58
ActsMaterialTrackWriterSvc::m_v_phi
float m_v_phi
start phi direction
Definition: ActsMaterialTrackWriterSvc.h:50
ActsMaterialTrackWriterSvc::m_sur_z
std::vector< float > m_sur_z
z position of the center of the suface associated with the step
Definition: ActsMaterialTrackWriterSvc.h:82
IActsTrackingGeometrySvc.h
ActsMaterialTrackWriterSvc::m_sur_y
std::vector< float > m_sur_y
y position of the center of the suface associated with the step
Definition: ActsMaterialTrackWriterSvc.h:80
ActsMaterialTrackWriterSvc::m_doEnd
std::atomic< bool > m_doEnd
Definition: ActsMaterialTrackWriterSvc.h:40
ActsMaterialTrackWriterSvc::m_step_y
std::vector< float > m_step_y
step y position
Definition: ActsMaterialTrackWriterSvc.h:59
ActsMaterialTrackWriterSvc::m_filePath
Gaudi::Property< std::string > m_filePath
Definition: ActsMaterialTrackWriterSvc.h:99
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
ActsMaterialTrackWriterSvc::m_step_dz
std::vector< float > m_step_dz
step z direction
Definition: ActsMaterialTrackWriterSvc.h:66
ActsMaterialTrackWriterSvc::writerThread
void writerThread()
Definition: ActsMaterialTrackWriterSvc.cxx:116
ActsMaterialTrackWriterSvc::m_step_Z
std::vector< float > m_step_Z
step material Z
Definition: ActsMaterialTrackWriterSvc.h:71
ActsMaterialTrackWriterSvc::m_step_rho
std::vector< float > m_step_rho
step material rho
Definition: ActsMaterialTrackWriterSvc.h:72
ActsMaterialTrackWriterSvc::m_step_L0
std::vector< float > m_step_L0
step material l0
Definition: ActsMaterialTrackWriterSvc.h:69
ActsMaterialTrackWriterSvc::ActsMaterialTrackWriterSvc
ActsMaterialTrackWriterSvc(const std::string &name, ISvcLocator *svc)
Definition: ActsMaterialTrackWriterSvc.cxx:25
ActsMaterialTrackWriterSvc::m_step_ex
std::vector< float > m_step_ex
step x (end) position (optional)
Definition: ActsMaterialTrackWriterSvc.h:61
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsMaterialTrackWriterSvc::m_v_x
float m_v_x
start global x
Definition: ActsMaterialTrackWriterSvc.h:44
ActsMaterialTrackWriterSvc::m_vol_id
std::vector< std::uint64_t > m_vol_id
ID of the volume associated with the step
Definition: ActsMaterialTrackWriterSvc.h:91
ActsMaterialTrackWriterSvc
Definition: ActsMaterialTrackWriterSvc.h:24
ActsMaterialTrackWriterSvc::m_step_ey
std::vector< float > m_step_ey
step y (end) position (optional)
Definition: ActsMaterialTrackWriterSvc.h:62
ActsMaterialTrackWriterSvc::p_tree
TTree * p_tree
Definition: ActsMaterialTrackWriterSvc.h:42
ActsMaterialTrackWriterSvc::m_v_px
float m_v_px
start global momentum x
Definition: ActsMaterialTrackWriterSvc.h:47
ActsMaterialTrackWriterSvc::initialize
virtual StatusCode initialize() override
Definition: ActsMaterialTrackWriterSvc.cxx:31
ActsMaterialTrackWriterSvc::finalize
virtual StatusCode finalize() override
Definition: ActsMaterialTrackWriterSvc.cxx:87
ActsMaterialTrackWriterSvc::write
virtual void write(const Acts::RecordedMaterialTrack &mTrack) override
Definition: ActsMaterialTrackWriterSvc.cxx:107
ActsMaterialTrackWriterSvc::m_tL0
float m_tL0
thickness in X0/L0
Definition: ActsMaterialTrackWriterSvc.h:53
ActsMaterialTrackWriterSvc::m_step_z
std::vector< float > m_step_z
step z position
Definition: ActsMaterialTrackWriterSvc.h:60
ActsMaterialTrackWriterSvc::m_treeName
Gaudi::Property< std::string > m_treeName
Definition: ActsMaterialTrackWriterSvc.h:100
ActsMaterialTrackWriterSvc::m_step_ez
std::vector< float > m_step_ez
step z (end) position (optional)
Definition: ActsMaterialTrackWriterSvc.h:63
ActsMaterialTrackWriterSvc::m_sur_range_max
std::vector< float > m_sur_range_max
Max range of the suface associated with the step.
Definition: ActsMaterialTrackWriterSvc.h:88
ActsMaterialTrackWriterSvc::m_maxQueueSize
Gaudi::Property< size_t > m_maxQueueSize
Definition: ActsMaterialTrackWriterSvc.h:103
ActsMaterialTrackWriterSvc::m_sur_id
std::vector< std::uint64_t > m_sur_id
ID of the suface associated with the step.
Definition: ActsMaterialTrackWriterSvc.h:75
ActsMaterialTrackWriterSvc::p_tFile
TFile * p_tFile
Definition: ActsMaterialTrackWriterSvc.h:41
AthService.h
ActsMaterialTrackWriterSvc::m_step_length
std::vector< float > m_step_length
step length
Definition: ActsMaterialTrackWriterSvc.h:67
ActsMaterialTrackWriterSvc::m_v_z
float m_v_z
start global z
Definition: ActsMaterialTrackWriterSvc.h:46
ActsMaterialTrackWriterSvc::m_tX0
float m_tX0
thickness in X0/L0
Definition: ActsMaterialTrackWriterSvc.h:52
ActsMaterialTrackWriterSvc::m_step_X0
std::vector< float > m_step_X0
step material x0
Definition: ActsMaterialTrackWriterSvc.h:68
IActsMaterialTrackWriterSvc.h
ActsMaterialTrackWriterSvc::doWrite
void doWrite(const Acts::RecordedMaterialTrack &mTrack)
Definition: ActsMaterialTrackWriterSvc.cxx:171
ActsMaterialTrackWriterSvc::m_step_sx
std::vector< float > m_step_sx
step x (start) position (optional)
Definition: ActsMaterialTrackWriterSvc.h:55
ServiceHandle< IActsTrackingGeometrySvc >