ATLAS Offline Software
Loading...
Searching...
No Matches
BeamSpotRetriever.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "BeamSpotRetriever.h"
6
8
9namespace JiveXML {
10
17 BeamSpotRetriever::BeamSpotRetriever(const std::string& type,const std::string& name,const IInterface* parent):
18 AthAlgTool(type,name,parent) {
19
20 //Declare the interface
21 declareInterface<IDataRetriever>(this);
22 }
23
25 ATH_CHECK(m_beamSpotKey.initialize());
26 return StatusCode::SUCCESS;
27 }
28
36 StatusCode BeamSpotRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
37
38 //be verbose
39 ATH_MSG_DEBUG( "Retrieving " << dataTypeName() );
40
41 DataVect x; x.reserve( 1 );
42 DataVect y; y.reserve( 1 );
43 DataVect z; z.reserve( 1 );
44 DataVect sigmaX; sigmaX.reserve( 1 );
45 DataVect sigmaXY; sigmaXY.reserve( 1 );
46 DataVect sigmaY; sigmaY.reserve( 1 );
47 DataVect sigmaZ; sigmaZ.reserve( 1 );
48 DataVect tiltX; tiltX.reserve( 1 );
49 DataVect tiltY; tiltY.reserve( 1 );
50 DataVect label; label.reserve( 1 );
51 DataVect status; status.reserve( 1 );
52
55// add the following into the initialize routine.
56 if ( !beamSpotHandle.isValid() ) {
57 ATH_MSG_ERROR( "Failed to retrieve beamspot " );
58 return StatusCode::RECOVERABLE;
59 } else {
60
61// references:
62// https://twiki.cern.ch/twiki/bin/view/Atlas/InDetBeamSpotFAQ#How_can_I_retrieve_the_beam_spot
63// InnerDetector/InDetCalibAlgs/InDetBeamSpotFinder/trunk/#path_InnerDetector_InDetCalibAlgs_InDetBeamSpotFinder_trunk_
64//
65// https://twiki.cern.ch/twiki/bin/view/Atlas/CoolBeamSpotParameters#Beam_Spot_Parametrization
66//
67// status Status word - see bit definition below
68// posX x position of beam spot center (mm)
69// posY y position of beam spot center (mm)
70// posZ z position of beam spot center (mm)
71// sigmaX Width of beam spot in x (mm)
72// sigmaY Width of beam spot in x (mm)
73// sigmaXY rhoXY*sigmaX*sigmaY (mm^2) (describes rotation of non-circular beam spot in transverse plane)
74// sigmaZ Width of beam spot in z (mm)
75// tiltX Tilt angle in x-z plane (rad)
76// tiltY Tilt angle in y-z plane (rad)
77
78
79
80 label.push_back( "Beamspot_position_at_PV_z_position" );
81
82 Trk::RecVertex beamposition(beamSpotHandle->beamVtx());
83 Amg::Vector3D posBS(beamposition.position());
84
85 x.push_back( posBS.x() );
86 y.push_back( posBS.y() );
87 z.push_back( posBS.z() );
88
89 sigmaX.push_back( beamSpotHandle->beamSigma(0) );
90 sigmaY.push_back( beamSpotHandle->beamSigma(1) );
91 sigmaZ.push_back( beamSpotHandle->beamSigma(2) );
92 sigmaXY.push_back( beamSpotHandle->beamSigmaXY() );
93
94 tiltX.push_back( beamSpotHandle->beamTilt(0) );
95 tiltY.push_back( beamSpotHandle->beamTilt(1) );
96
97 status.push_back( beamSpotHandle->beamStatus() );
98
99 ATH_MSG_DEBUG( "BeamSpot Position: "
100 << beamSpotHandle->beamPos() );
101 ATH_MSG_DEBUG( "BeamSpot Sigma "
102 << beamSpotHandle->beamSigma(0) << ", "
103 << beamSpotHandle->beamSigma(1) << ", "
104 << beamSpotHandle->beamSigma(2) );
105 ATH_MSG_DEBUG( "BeamSpot Tilt: "
106 << beamSpotHandle->beamTilt(0) << ", "
107 << beamSpotHandle->beamTilt(1) );
108 ATH_MSG_DEBUG( "Beamspot position at PV z-position" );
109
110 //be verbose about the amount of data we retrieved
111 ATH_MSG_DEBUG( "Retrieved " << label.size() << "Beamspot" );
112
113 //Create a data map
114 DataMap dataMap;
115 //Add the data vectors to our map
116 dataMap["x"]=std::move(x);
117 dataMap["y"]=std::move(y);
118 dataMap["z"]=std::move(z);
119 dataMap["sigmaX"]=std::move(sigmaX);
120 dataMap["sigmaY"]=std::move(sigmaY);
121 dataMap["sigmaXY"]=std::move(sigmaXY);
122 dataMap["sigmaZ"]=std::move(sigmaZ);
123 dataMap["tiltX"]=std::move(tiltX);
124 dataMap["tiltY"]=std::move(tiltY);
125 dataMap["label"]=std::move(label);
126 dataMap["status"]=std::move(status);
127
128 //Forward data to formatting tool
129 if ( FormatTool->AddToEvent(dataTypeName(), "BeamSpot", &dataMap).isFailure())
130 return StatusCode::RECOVERABLE;
131
132 //Clean up and exit
133 ATH_MSG_DEBUG( dataTypeName() << " retrieved" );
134
135 return StatusCode::SUCCESS;
136 }
137 }
138}
139
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define y
#define x
#define z
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
virtual StatusCode initialize() override
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool) override
Retrieve all the data.
virtual std::string dataTypeName() const override
Return the name of the data type.
BeamSpotRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Trk::RecVertex inherits from Trk::Vertex.
Definition RecVertex.h:44
const Amg::Vector3D & position() const
return position of vertex
Definition Vertex.cxx:63
std::string label(const std::string &format, int i)
Definition label.h:19
Eigen::Matrix< double, 3, 1 > Vector3D
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58