ATLAS Offline Software
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 
7 #include "JiveXML/IFormatTool.h"
8 
9 namespace JiveXML {
10 
17  BeamSpotRetriever::BeamSpotRetriever(const std::string& type,const std::string& name,const IInterface* parent):
19 
20  //Declare the interface
21  declareInterface<IDataRetriever>(this);
22  }
23 
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
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 
beamspotman.sigmaZ
sigmaZ
Definition: beamspotman.py:1625
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
JiveXML::BeamSpotRetriever::BeamSpotRetriever
BeamSpotRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: BeamSpotRetriever.cxx:17
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
beamspotman.tiltY
tiltY
Definition: beamspotman.py:1627
beamspotman.tiltX
tiltX
Definition: beamspotman.py:1626
beamspotman.sigmaXY
sigmaXY
Definition: beamspotman.py:1628
beamspotman.sigmaX
sigmaX
Definition: beamspotman.py:1625
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
beamspotman.sigmaY
sigmaY
Definition: beamspotman.py:1625
x
#define x
Trk::RecVertex
Trk::RecVertex inherits from Trk::Vertex.
Definition: RecVertex.h:44
JiveXML::BeamSpotRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool) override
Retrieve all the data.
Definition: BeamSpotRetriever.cxx:36
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
z
#define z
LArHistMerge_trf.dataMap
dataMap
Definition: LArHistMerge_trf.py:218
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
JiveXML::BeamSpotRetriever::initialize
virtual StatusCode initialize() override
Definition: BeamSpotRetriever.cxx:24
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::Vertex::position
const Amg::Vector3D & position() const
return position of vertex
Definition: Vertex.cxx:72
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
y
#define y
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
merge.status
status
Definition: merge.py:17
AthAlgTool
Definition: AthAlgTool.h:26
JiveXML::BeamSpotRetriever::m_beamSpotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Definition: BeamSpotRetriever.h:41
BeamSpotRetriever.h
JiveXML::BeamSpotRetriever::dataTypeName
virtual std::string dataTypeName() const override
Return the name of the data type.
Definition: BeamSpotRetriever.h:37
IFormatTool.h