ATLAS Offline Software
Loading...
Searching...
No Matches
PixelRDORetriever.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "PixelRDORetriever.h"
6
9
10
11#include "JiveXML/IFormatTool.h"
12
13namespace JiveXML {
14
21 PixelRDORetriever::PixelRDORetriever(const std::string& type,const std::string& name,const IInterface* parent):
22 AthAlgTool(type,name,parent)
23 {
24 //Declare the interface
25 declareInterface<IDataRetriever>(this);
26
27 //And properties
28 declareProperty("PixelRDOContainer" , m_PixelRDOContainerName = "PixelRDOs");
29 }
30
38 StatusCode PixelRDORetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
39
40 //be verbose
41 ATH_MSG_DEBUG( "Retrieving " << dataTypeName() );
42
44 const InDetDD::SiDetectorElementCollection* elements(*pixelDetEleHandle);
45 if (not pixelDetEleHandle.isValid() or elements==nullptr) {
46 ATH_MSG_FATAL(m_pixelDetEleCollKey.fullKey() << " is not available.");
47 return StatusCode::FAILURE;
48 }
49
50 //retrieve the PixelRDO container
52 if (!rdoContainer.isValid()) {
53 ATH_MSG_DEBUG( "Unable to retrieve PixelRDO_Container with name " << m_PixelRDOContainerName.key() );
54 return StatusCode::RECOVERABLE;
55 }
56
57 //Define the data vectors we want to fill
58 DataVect idVec,xVec,yVec,zVec,phiModuleVec,etaModuleVec;
59
60 //Loop over pixel RDO container
61 for (const auto rdoCollection : *rdoContainer) {
62
63 //Loop over raw data objects
64 for (const auto rdoData : *rdoCollection) {
65
66 //Get the pixel identifier
67 const Identifier id = rdoData->identify();
68 const Identifier waferID = m_pixelID->wafer_id(id);
69 IdentifierHash wafer_hash = m_pixelID->wafer_hash(waferID);
70
71 //Get the detector element
72 const InDetDD::SiDetectorElement *element = elements->getDetectorElement(wafer_hash);
73
74 //Make sure we got the detector element
75 if (element == nullptr){
76 ATH_MSG_WARNING( "Unable to obtain detector element for PixelRDO hit with id " << id );
77 continue;
78 }
79
80 //Get the global position from the local position
81 Amg::Vector2D localPos = element->rawLocalPositionOfCell(id);
82 localPos[Trk::distPhi] += m_lorentzAngleTool->getLorentzShift(element->identifyHash(), Gaudi::Hive::currentContext());
83 Amg::Vector3D globalPos = element->globalPosition(localPos);
84
85 //Fill in all the data in our data vectors
86 idVec.push_back(DataType( id.get_compact() ));
87 xVec.push_back(DataType(globalPos.x()*CLHEP::mm/CLHEP::cm));
88 yVec.push_back(DataType(globalPos.y()*CLHEP::mm/CLHEP::cm));
89 zVec.push_back(DataType(globalPos.z()*CLHEP::mm/CLHEP::cm));
90 phiModuleVec.push_back(DataType(m_pixelID->phi_module(waferID)));
91 etaModuleVec.push_back(DataType(m_pixelID->eta_module(waferID)));
92 }
93 }
94
95 //be verbose about the amount of data we retrieved
96 ATH_MSG_DEBUG( "Retrieved " << idVec.size() << " PixelRDO objects" );
97
98 //Create a data map
99 DataMap dataMap;
100 //Add the data vectors to our map
101 dataMap["id"]=std::move(idVec);
102 dataMap["x"]=std::move(xVec);
103 dataMap["y"]=std::move(yVec);
104 dataMap["z"]=std::move(zVec);
105 dataMap["phiModule"]=std::move(phiModuleVec);
106 dataMap["etaModule"]=std::move(etaModuleVec);
107
111 //Forward data to formatting tool
112 if ( FormatTool->AddToEvent(dataTypeName(), "PixelRDOs", &dataMap).isFailure())
113 return StatusCode::RECOVERABLE;
114
115 //Clean up and exit
116 ATH_MSG_DEBUG( dataTypeName() << " retrieved" );
117
118 return StatusCode::SUCCESS;
119 }
120
121
123 ATH_CHECK( m_lorentzAngleTool.retrieve() );
124 ATH_CHECK(m_pixelDetEleCollKey.initialize());
126 ATH_CHECK(detStore()->retrieve(m_pixelID, "PixelID"));
127
128 return StatusCode::SUCCESS;
129 }
130}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
This is an Identifier helper class for the Pixel subdetector.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
This is a "hash" representation of an Identifier.
Class to hold the SiDetectorElement objects to be put in the detector store.
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Class to hold geometrical description of a silicon detector element.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
HepGeom::Point3D< double > globalPosition(const HepGeom::Point3D< double > &localPos) const
transform a reconstruction local position into a global position (inline):
Amg::Vector2D rawLocalPositionOfCell(const SiCellId &cellId) const
Returns position (center) of cell.
virtual std::string dataTypeName() const
Return the name of the data type.
ToolHandle< ISiLorentzAngleTool > m_lorentzAngleTool
A tool handle to the SiLorentzAngleTool.
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
PixelRDORetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
virtual StatusCode initialize()
Only retrieve geo tool in initialize.
SG::ReadHandleKey< PixelRDO_Container > m_PixelRDOContainerName
The StoreGate key for the PixelRDO container.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Eigen::Matrix< double, 2, 1 > Vector2D
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
@ distPhi
Definition ParamDefs.h:50