ATLAS Offline Software
Loading...
Searching...
No Matches
PixelRDORetriever.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "PixelRDORetriever.h"
6
9//#include "TrkEventPrimitives/LocalPosition.h"
10//#include "GaudiKernel/SystemOfUnits.h"
11
12#include "JiveXML/IFormatTool.h"
13
14namespace JiveXML {
15
22 PixelRDORetriever::PixelRDORetriever(const std::string& type,const std::string& name,const IInterface* parent):
23 AthAlgTool(type,name,parent)
24 {
25 //Declare the interface
26 declareInterface<IDataRetriever>(this);
27
28 //And properties
29 declareProperty("PixelRDOContainer" , m_PixelRDOContainerName = "PixelRDOs");
30 }
31
39 StatusCode PixelRDORetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
40
41 //be verbose
42 ATH_MSG_DEBUG( "Retrieving " << dataTypeName() );
43
45 const InDetDD::SiDetectorElementCollection* elements(*pixelDetEleHandle);
46 if (not pixelDetEleHandle.isValid() or elements==nullptr) {
47 ATH_MSG_FATAL(m_pixelDetEleCollKey.fullKey() << " is not available.");
48 return StatusCode::FAILURE;
49 }
50
51 //retrieve the PixelRDO container
53 if (!rdoContainer.isValid()) {
54 ATH_MSG_DEBUG( "Unable to retrieve PixelRDO_Container with name " << m_PixelRDOContainerName.key() );
55 return StatusCode::RECOVERABLE;
56 }
57
58 //Define the data vectors we want to fill
59 DataVect idVec,xVec,yVec,zVec,phiModuleVec,etaModuleVec;
60
61 //Loop over pixel RDO container
62 for (const auto rdoCollection : *rdoContainer) {
63
64 //Loop over raw data objects
65 for (const auto rdoData : *rdoCollection) {
66
67 //Get the pixel identifier
68 const Identifier id = rdoData->identify();
69 const Identifier waferID = m_pixelID->wafer_id(id);
70 IdentifierHash wafer_hash = m_pixelID->wafer_hash(waferID);
71
72 //Get the detector element
73 const InDetDD::SiDetectorElement *element = elements->getDetectorElement(wafer_hash);
74
75 //Make sure we got the detector element
76 if (element == nullptr){
77 ATH_MSG_WARNING( "Unable to obtain detector element for PixelRDO hit with id " << id );
78 continue;
79 }
80
81 //Get the global position from the local position
82 Amg::Vector2D localPos = element->rawLocalPositionOfCell(id);
83 localPos[Trk::distPhi] += m_lorentzAngleTool->getLorentzShift(element->identifyHash(), Gaudi::Hive::currentContext());
84 Amg::Vector3D globalPos = element->globalPosition(localPos);
85
86 //Fill in all the data in our data vectors
87 idVec.push_back(DataType( id.get_compact() ));
88 xVec.push_back(DataType(globalPos.x()*CLHEP::mm/CLHEP::cm));
89 yVec.push_back(DataType(globalPos.y()*CLHEP::mm/CLHEP::cm));
90 zVec.push_back(DataType(globalPos.z()*CLHEP::mm/CLHEP::cm));
91 phiModuleVec.push_back(DataType(m_pixelID->phi_module(waferID)));
92 etaModuleVec.push_back(DataType(m_pixelID->eta_module(waferID)));
93 }
94 }
95
96 //be verbose about the amount of data we retrieved
97 ATH_MSG_DEBUG( "Retrieved " << idVec.size() << " PixelRDO objects" );
98
99 //Create a data map
100 DataMap dataMap;
101 //Add the data vectors to our map
102 dataMap["id"]=idVec;
103 dataMap["x"]=xVec;
104 dataMap["y"]=yVec;
105 dataMap["z"]=zVec;
106 dataMap["phiModule"]=phiModuleVec;
107 dataMap["etaModule"]=etaModuleVec;
108
112 //Forward data to formatting tool
113 if ( FormatTool->AddToEvent(dataTypeName(), "PixelRDOs", &dataMap).isFailure())
114 return StatusCode::RECOVERABLE;
115
116 //Clean up and exit
117 ATH_MSG_DEBUG( dataTypeName() << " retrieved" );
118
119 return StatusCode::SUCCESS;
120 }
121
122
124 ATH_CHECK( m_lorentzAngleTool.retrieve() );
125 ATH_CHECK(m_pixelDetEleCollKey.initialize());
127 ATH_CHECK(detStore()->retrieve(m_pixelID, "PixelID"));
128
129 return StatusCode::SUCCESS;
130 }
131}
#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