ATLAS Offline Software
PropResultRootWriterSvc.h
Go to the documentation of this file.
1 
2 /*
3  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 #ifndef TRKEXALGS_PROPRESULTROOTWRITERSVC_H
7 #define TRKEXALGS_PROPRESULTROOTWRITERSVC_H
8 
9 #include "GaudiKernel/IInterface.h"
10 #include "Gaudi/Property.h" /*no forward decl: typedef*/
11 #include "GaudiKernel/ITHistSvc.h"
13 
14 #include "TTree.h"
15 
16 #include <mutex>
17 
18 class TFile;
19 
20 namespace Trk {
21 
23  public:
25  PropResultRootWriterSvc(const std::string& name, ISvcLocator* svcloc);
28 
30  static const InterfaceID& interfaceID() {
32  static const InterfaceID IID_PropResultRootWriterSvc("PropResultRootWriterSvc", 1, 0);
33  return IID_PropResultRootWriterSvc;
34  }
35 
36  virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface) override {
37  ATH_MSG_DEBUG("in queryInterface()");
38  if (PropResultRootWriterSvc::interfaceID().versionMatch(riid)) {
39  ATH_MSG_DEBUG("matched PropResultRootWriterSvc");
40  *ppvInterface=(PropResultRootWriterSvc*)this;
41  } else {
42  ATH_MSG_DEBUG("Default to Service interface");
43  return AthService::queryInterface(riid,ppvInterface);
44  }
45  return StatusCode::SUCCESS;
46  }
47 
48  virtual StatusCode initialize() override;
49  virtual StatusCode finalize() override;
50 
51  template <typename T>
52  void write(const T* initialPerigee,
53  const T* fwdParameters=nullptr, double fwdtime=std::numeric_limits<float>::quiet_NaN(),
54  const T* bkwParameters=nullptr, double bkwtime=std::numeric_limits<float>::quiet_NaN() );
55 
56 private:
58 
59  // jobOptions properties
61  TTree* m_tree;
62  Gaudi::Property<std::string> m_ntupleDirName{this, "DirName", "/ExtrapolationStudies/", ""};
63  Gaudi::Property<std::string> m_treeName{this, "TreeName", "ATLAS", ""};
64 
65  int m_eventNum = 0;
66 
67  float m_start_d0 = 0.0F ;
68  float m_start_z0 = 0.0F ;
69  float m_start_phi = 0.0F ;
70  float m_start_theta = 0.0F ;
71  float m_start_qop = 0.0F ;
72 
73  float m_fwd_success = 0.0F ;
74  float m_fwd_time = 0.0F ;
75  float m_fwd_final_l0 = 0.0F ;
76  float m_fwd_final_l1 = 0.0F ;
77  float m_fwd_final_x = 0.0F ;
78  float m_fwd_final_y = 0.0F ;
79  float m_fwd_final_z = 0.0F ;
80  float m_fwd_final_phi = 0.0F ;
81  float m_fwd_final_theta = 0.0F ;
82  float m_fwd_final_qop = 0.0F ;
83  float m_fwd_final_sigma_l0 = 0.0F ;
84  float m_fwd_final_sigma_l1 = 0.0F ;
85  float m_fwd_final_sigma_phi = 0.0F ;
86  float m_fwd_final_sigma_theta = 0.0F ;
87  float m_fwd_final_sigma_qop = 0.0F ;
88 
89  float m_bkw_success = 0.0F ;
90  float m_bkw_time = 0.0F ;
91  float m_bkw_final_d0 = 0.0F ;
92  float m_bkw_final_z0 = 0.0F ;
93  float m_bkw_final_phi = 0.0F ;
94  float m_bkw_final_theta = 0.0F ;
95  float m_bkw_final_qop = 0.0F ;
96  float m_bkw_final_sigma_d0 = 0.0F ;
97  float m_bkw_final_sigma_z0 = 0.0F ;
98  float m_bkw_final_sigma_phi = 0.0F ;
99  float m_bkw_final_sigma_theta = 0.0F ;
100  float m_bkw_final_sigma_qop = 0.0F ;
101 
102  };
103 
104  template <typename T>
105  void PropResultRootWriterSvc::write(const T* initialPerigee,
106  const T* fwdParameters, double fwdtime,
107  const T* bkwParameters, double bkwtime ) {
108 
109  const auto& ctx = Gaudi::Hive::currentContext();
110 
111  m_eventNum = ctx.eventID().event_number();
112 
113  if (initialPerigee) {
114  m_start_d0 = initialPerigee->parameters()[0];
115  m_start_z0 = initialPerigee->parameters()[1];
116  m_start_phi = initialPerigee->parameters()[2];
117  m_start_theta= initialPerigee->parameters()[3];
118  m_start_qop = initialPerigee->parameters()[4];
119  } else {
120  m_start_d0 = std::numeric_limits<float>::quiet_NaN();
121  m_start_z0 = std::numeric_limits<float>::quiet_NaN();
122  m_start_phi = std::numeric_limits<float>::quiet_NaN();
123  m_start_theta= std::numeric_limits<float>::quiet_NaN();
124  m_start_qop = std::numeric_limits<float>::quiet_NaN();
125  }
126 
127  if (fwdParameters) {
128  m_fwd_success = 1;
129  m_fwd_time = fwdtime;
130  m_fwd_final_l0 = fwdParameters->parameters()[0];
131  m_fwd_final_l1 = fwdParameters->parameters()[1];
132  m_fwd_final_phi = fwdParameters->parameters()[2];
133  m_fwd_final_theta = fwdParameters->parameters()[3];
134  m_fwd_final_qop = fwdParameters->parameters()[4];
135  m_fwd_final_x = fwdParameters->position()[0];
136  m_fwd_final_y = fwdParameters->position()[1];
137  m_fwd_final_z = fwdParameters->position()[2];
138  if (fwdParameters->covariance()) {
139  m_fwd_final_sigma_l0 = (*fwdParameters->covariance())(0,0);
140  m_fwd_final_sigma_l1 = (*fwdParameters->covariance())(1,1);
141  m_fwd_final_sigma_phi = (*fwdParameters->covariance())(2,2);
142  m_fwd_final_sigma_theta = (*fwdParameters->covariance())(3,3);
143  m_fwd_final_sigma_qop = (*fwdParameters->covariance())(4,4);
144  } else {
145  m_fwd_final_sigma_l0 = std::numeric_limits<float>::quiet_NaN();
146  m_fwd_final_sigma_l1 = std::numeric_limits<float>::quiet_NaN();
147  m_fwd_final_sigma_phi = std::numeric_limits<float>::quiet_NaN();
148  m_fwd_final_sigma_theta = std::numeric_limits<float>::quiet_NaN();
149  m_fwd_final_sigma_qop = std::numeric_limits<float>::quiet_NaN();
150  }
151  } else {
152  m_fwd_success = std::numeric_limits<float>::quiet_NaN();
153  m_fwd_time = std::numeric_limits<float>::quiet_NaN();
154  m_fwd_final_l0 = std::numeric_limits<float>::quiet_NaN();
155  m_fwd_final_l1 = std::numeric_limits<float>::quiet_NaN();
156  m_fwd_final_phi = std::numeric_limits<float>::quiet_NaN();
157  m_fwd_final_theta = std::numeric_limits<float>::quiet_NaN();
158  m_fwd_final_qop = std::numeric_limits<float>::quiet_NaN();
159  m_fwd_final_x = std::numeric_limits<float>::quiet_NaN();
160  m_fwd_final_y = std::numeric_limits<float>::quiet_NaN();
161  m_fwd_final_z = std::numeric_limits<float>::quiet_NaN();
162  m_fwd_final_sigma_l0 = std::numeric_limits<float>::quiet_NaN();
163  m_fwd_final_sigma_l1 = std::numeric_limits<float>::quiet_NaN();
164  m_fwd_final_sigma_phi = std::numeric_limits<float>::quiet_NaN();
165  m_fwd_final_sigma_theta = std::numeric_limits<float>::quiet_NaN();
166  m_fwd_final_sigma_qop = std::numeric_limits<float>::quiet_NaN();
167  }
168 
169  if (bkwParameters) {
170  m_bkw_success = 1;
171  m_bkw_time = bkwtime;
172  m_bkw_final_d0 = bkwParameters->parameters()[0];
173  m_bkw_final_z0 = bkwParameters->parameters()[1];
174  m_bkw_final_phi = bkwParameters->parameters()[2];
175  m_bkw_final_theta = bkwParameters->parameters()[3];
176  m_bkw_final_qop = bkwParameters->parameters()[4];
177  if (bkwParameters->covariance()) {
178  m_bkw_final_sigma_d0 = (*bkwParameters->covariance())(0,0);
179  m_bkw_final_sigma_z0 = (*bkwParameters->covariance())(1,1);
180  m_bkw_final_sigma_phi = (*bkwParameters->covariance())(2,2);
181  m_bkw_final_sigma_theta = (*bkwParameters->covariance())(3,3);
182  m_bkw_final_sigma_qop = (*bkwParameters->covariance())(4,4);
183  } else {
184  m_bkw_final_sigma_d0 = std::numeric_limits<float>::quiet_NaN();
185  m_bkw_final_sigma_z0 = std::numeric_limits<float>::quiet_NaN();
186  m_bkw_final_sigma_phi = std::numeric_limits<float>::quiet_NaN();
187  m_bkw_final_sigma_theta = std::numeric_limits<float>::quiet_NaN();
188  m_bkw_final_sigma_qop = std::numeric_limits<float>::quiet_NaN();
189  }
190  } else {
191  m_bkw_success = std::numeric_limits<float>::quiet_NaN();
192  m_bkw_time = std::numeric_limits<float>::quiet_NaN();
193  m_bkw_final_d0 = std::numeric_limits<float>::quiet_NaN();
194  m_bkw_final_z0 = std::numeric_limits<float>::quiet_NaN();
195  m_bkw_final_phi = std::numeric_limits<float>::quiet_NaN();
196  m_bkw_final_theta = std::numeric_limits<float>::quiet_NaN();
197  m_bkw_final_qop = std::numeric_limits<float>::quiet_NaN();
198  m_bkw_final_sigma_d0 = std::numeric_limits<float>::quiet_NaN();
199  m_bkw_final_sigma_z0 = std::numeric_limits<float>::quiet_NaN();
200  m_bkw_final_sigma_phi = std::numeric_limits<float>::quiet_NaN();
201  m_bkw_final_sigma_theta = std::numeric_limits<float>::quiet_NaN();
202  m_bkw_final_sigma_qop = std::numeric_limits<float>::quiet_NaN();
203  }
204  m_tree->Fill();
205  }
206 
207 
208 
209 }
210 
211 #endif
Trk::PropResultRootWriterSvc::m_fwd_final_z
float m_fwd_final_z
Definition: PropResultRootWriterSvc.h:79
Trk::PropResultRootWriterSvc::m_fwd_final_y
float m_fwd_final_y
Definition: PropResultRootWriterSvc.h:78
Trk::PropResultRootWriterSvc::m_fwd_final_phi
float m_fwd_final_phi
Definition: PropResultRootWriterSvc.h:80
Trk::PropResultRootWriterSvc::~PropResultRootWriterSvc
virtual ~PropResultRootWriterSvc()
destructor
Trk::PropResultRootWriterSvc::m_start_phi
float m_start_phi
Definition: PropResultRootWriterSvc.h:69
Trk::PropResultRootWriterSvc::interfaceID
static const InterfaceID & interfaceID()
Retrieve interface ID.
Definition: PropResultRootWriterSvc.h:30
Trk::PropResultRootWriterSvc::m_start_z0
float m_start_z0
Definition: PropResultRootWriterSvc.h:68
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
Trk::PropResultRootWriterSvc::m_fwd_final_theta
float m_fwd_final_theta
Definition: PropResultRootWriterSvc.h:81
Trk::PropResultRootWriterSvc::m_eventNum
int m_eventNum
Definition: PropResultRootWriterSvc.h:65
Trk::PropResultRootWriterSvc::m_treeName
Gaudi::Property< std::string > m_treeName
Definition: PropResultRootWriterSvc.h:63
Trk::PropResultRootWriterSvc::finalize
virtual StatusCode finalize() override
Definition: PropResultRootWriterSvc.cxx:80
Trk::PropResultRootWriterSvc::m_bkw_final_sigma_z0
float m_bkw_final_sigma_z0
Definition: PropResultRootWriterSvc.h:97
Trk::PropResultRootWriterSvc::m_bkw_final_sigma_phi
float m_bkw_final_sigma_phi
Definition: PropResultRootWriterSvc.h:98
Trk::PropResultRootWriterSvc::m_ntupleDirName
Gaudi::Property< std::string > m_ntupleDirName
Definition: PropResultRootWriterSvc.h:62
Trk::PropResultRootWriterSvc::m_bkw_final_d0
float m_bkw_final_d0
Definition: PropResultRootWriterSvc.h:91
Trk::PropResultRootWriterSvc::PropResultRootWriterSvc
PropResultRootWriterSvc(const std::string &name, ISvcLocator *svcloc)
constructor
Definition: PropResultRootWriterSvc.cxx:15
Trk::PropResultRootWriterSvc::initialize
virtual StatusCode initialize() override
Definition: PropResultRootWriterSvc.cxx:23
Trk::PropResultRootWriterSvc::write
void write(const T *initialPerigee, const T *fwdParameters=nullptr, double fwdtime=std::numeric_limits< float >::quiet_NaN(), const T *bkwParameters=nullptr, double bkwtime=std::numeric_limits< float >::quiet_NaN())
Definition: PropResultRootWriterSvc.h:105
Trk::PropResultRootWriterSvc::m_fwd_final_qop
float m_fwd_final_qop
Definition: PropResultRootWriterSvc.h:82
Trk::PropResultRootWriterSvc::m_fwd_success
float m_fwd_success
Definition: PropResultRootWriterSvc.h:73
Trk::PropResultRootWriterSvc::m_fwd_final_sigma_l1
float m_fwd_final_sigma_l1
Definition: PropResultRootWriterSvc.h:84
Trk::PropResultRootWriterSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Definition: PropResultRootWriterSvc.h:36
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
AthService
Definition: AthService.h:32
Trk::PropResultRootWriterSvc::m_bkw_success
float m_bkw_success
Definition: PropResultRootWriterSvc.h:89
Trk::PropResultRootWriterSvc::m_start_qop
float m_start_qop
Definition: PropResultRootWriterSvc.h:71
Trk::PropResultRootWriterSvc::m_fwd_time
float m_fwd_time
Definition: PropResultRootWriterSvc.h:74
Trk::PropResultRootWriterSvc::m_fwd_final_x
float m_fwd_final_x
Definition: PropResultRootWriterSvc.h:77
Trk::PropResultRootWriterSvc::m_bkw_time
float m_bkw_time
Definition: PropResultRootWriterSvc.h:90
Trk::PropResultRootWriterSvc::m_thistSvc
ServiceHandle< ITHistSvc > m_thistSvc
Definition: PropResultRootWriterSvc.h:60
Trk::PropResultRootWriterSvc::m_bkw_final_z0
float m_bkw_final_z0
Definition: PropResultRootWriterSvc.h:92
Trk::PropResultRootWriterSvc::m_fwd_final_l0
float m_fwd_final_l0
Definition: PropResultRootWriterSvc.h:75
Trk::PropResultRootWriterSvc::m_bkw_final_phi
float m_bkw_final_phi
Definition: PropResultRootWriterSvc.h:93
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::PropResultRootWriterSvc::m_fwd_final_sigma_phi
float m_fwd_final_sigma_phi
Definition: PropResultRootWriterSvc.h:85
Trk::PropResultRootWriterSvc::m_fwd_final_l1
float m_fwd_final_l1
Definition: PropResultRootWriterSvc.h:76
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Trk::PropResultRootWriterSvc::m_bkw_final_qop
float m_bkw_final_qop
Definition: PropResultRootWriterSvc.h:95
Trk::PropResultRootWriterSvc::m_start_d0
float m_start_d0
Definition: PropResultRootWriterSvc.h:67
Trk::PropResultRootWriterSvc::m_bkw_final_sigma_theta
float m_bkw_final_sigma_theta
Definition: PropResultRootWriterSvc.h:99
Trk::PropResultRootWriterSvc::m_bkw_final_sigma_qop
float m_bkw_final_sigma_qop
Definition: PropResultRootWriterSvc.h:100
Trk::PropResultRootWriterSvc::m_bkw_final_theta
float m_bkw_final_theta
Definition: PropResultRootWriterSvc.h:94
Trk::PropResultRootWriterSvc::m_bkw_final_sigma_d0
float m_bkw_final_sigma_d0
Definition: PropResultRootWriterSvc.h:96
Trk::PropResultRootWriterSvc::m_fwd_final_sigma_theta
float m_fwd_final_sigma_theta
Definition: PropResultRootWriterSvc.h:86
AthService.h
Trk::PropResultRootWriterSvc::m_fwd_final_sigma_l0
float m_fwd_final_sigma_l0
Definition: PropResultRootWriterSvc.h:83
Trk::PropResultRootWriterSvc::m_start_theta
float m_start_theta
Definition: PropResultRootWriterSvc.h:70
Trk::PropResultRootWriterSvc
Definition: PropResultRootWriterSvc.h:22
Trk::PropResultRootWriterSvc::m_fwd_final_sigma_qop
float m_fwd_final_sigma_qop
Definition: PropResultRootWriterSvc.h:87
Trk::PropResultRootWriterSvc::m_writeMutex
std::mutex m_writeMutex
Definition: PropResultRootWriterSvc.h:57
Trk::PropResultRootWriterSvc::m_tree
TTree * m_tree
Definition: PropResultRootWriterSvc.h:61
ServiceHandle< ITHistSvc >