ATLAS Offline Software
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 
14 namespace JiveXML {
15 
22  PixelRDORetriever::PixelRDORetriever(const std::string& type,const std::string& name,const IInterface* 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
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() );
126  ATH_CHECK(m_PixelRDOContainerName.initialize());
127  ATH_CHECK(detStore()->retrieve(m_pixelID, "PixelID"));
128 
129  return StatusCode::SUCCESS;
130  }
131 }
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
JiveXML::PixelRDORetriever::m_lorentzAngleTool
ToolHandle< ISiLorentzAngleTool > m_lorentzAngleTool
A tool handle to the SiLorentzAngleTool.
Definition: PixelRDORetriever.h:56
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
JiveXML::PixelRDORetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: PixelRDORetriever.h:46
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JiveXML::PixelRDORetriever::initialize
virtual StatusCode initialize()
Only retrieve geo tool in initialize.
Definition: PixelRDORetriever.cxx:123
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
JiveXML::PixelRDORetriever::m_PixelRDOContainerName
SG::ReadHandleKey< PixelRDO_Container > m_PixelRDOContainerName
The StoreGate key for the PixelRDO container.
Definition: PixelRDORetriever.h:59
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
InDetDD::SolidStateDetectorElementBase::identifyHash
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
JiveXML::PixelRDORetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: PixelRDORetriever.cxx:39
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
PixelID::wafer_hash
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition: PixelID.h:387
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::PixelRDORetriever::PixelRDORetriever
PixelRDORetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: PixelRDORetriever.cxx:22
JiveXML::PixelRDORetriever::m_pixelID
const PixelID * m_pixelID
Definition: PixelRDORetriever.h:53
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Trk::distPhi
@ distPhi
Definition: ParamDefs.h:50
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:22
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:651
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
SiDetectorElement.h
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
InDetDD::SolidStateDetectorElementBase::rawLocalPositionOfCell
Amg::Vector2D rawLocalPositionOfCell(const SiCellId &cellId) const
Returns position (center) of cell.
Definition: SolidStateDetectorElementBase.cxx:230
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
InDetDD::SolidStateDetectorElementBase::globalPosition
HepGeom::Point3D< double > globalPosition(const HepGeom::Point3D< double > &localPos) const
transform a reconstruction local position into a global position (inline):
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthAlgTool
Definition: AthAlgTool.h:26
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:644
PixelRDORetriever.h
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15
JiveXML::PixelRDORetriever::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition: PixelRDORetriever.h:61
IFormatTool.h
Identifier
Definition: IdentifierFieldParser.cxx:14