ATLAS Offline Software
Loading...
Searching...
No Matches
PixelClusterOnTrackCnv_p2.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
12
14 //std::cout<<"READING PixelClusterOnTrackCnv_p2"<<std::endl;
15
16 if(!m_isInitialized) {
17 if (this->initialize(log) != StatusCode::SUCCESS) {
18 log << MSG::FATAL << "Could not initialize PixelClusterOnTrackCnv_p2 " << endmsg;
19 }
20 }
21
23 m_elCnv.persToTrans(&persObj->m_prdLink,&rio,log);
24
25 Trk::LocalParameters localParams;
26 fillTransFromPStore( &m_localParCnv, persObj->m_localParams, &localParams, log );
27
28 Trk::ErrorMatrix dummy;
29 Amg::MatrixX localCovariance;
30 fillTransFromPStore( &m_errorMxCnv, persObj->m_localErrMat, &dummy, log );
31 EigenHelpers::vectorToEigenMatrix(dummy.values, localCovariance, "PixelClusterOnTrackCnv_p2");
32
33 *transObj = InDet::PixelClusterOnTrack(rio,
34 localParams,
35 localCovariance,
36 persObj->m_idDE,
37 m_pixId->pixel_id(persObj->m_id),
38 persObj->m_energyLoss,
39 persObj->m_isFake,
40 persObj->m_hasClusterAmbiguity,
41 persObj->m_isbroad
42 );
43
44 // Attempt to call supertool to fill in detElements
45 m_eventCnvTool->recreateRIO_OnTrack(transObj);
46 if (transObj->detectorElement()==nullptr)
47 log << MSG::WARNING<<"Unable to reset DetEl for this RIO_OnTrack, "
48 << "probably because of a problem with the Identifier/IdentifierHash : ("
49 << transObj->identify()<<"/"<<transObj->idDE()<<endmsg;
50
51}
52
53
55 if (transObj==nullptr or persObj==nullptr) return;
56
57 persObj->m_id = transObj->identify().get_compact();
58 persObj->m_localParams = toPersistent( &m_localParCnv, &transObj->localParameters(), log );
60 EigenHelpers::eigenMatrixToVector(pMat.values, transObj->localCovariance(), "PixelClusterOnTrackCnv_p2");
61 persObj->m_localErrMat = toPersistent( &m_errorMxCnv, &pMat, log );
62 persObj->m_idDE = transObj->idDE();
63 persObj->m_isbroad = transObj->isBroadCluster();
64 persObj->m_hasClusterAmbiguity = transObj->hasClusterAmbiguity();
65 persObj->m_isFake = transObj->isFake();
66 persObj->m_energyLoss = transObj->energyLoss();
67
68 using PixelContainer = InDet::PixelClusterContainer;
69
70 static const SG::InitializedReadHandleKey<PixelContainer> pixelClusters{
71 "PixelClusters"};
72 static const SG::InitializedReadHandleKey<PixelContainer> bkgPixelClusters{
73 "Bkg_PixelClusters"};
74 static const SG::InitializedReadHandleKey<PixelContainer> itkPixelClusters{
75 "ITkPixelClusters"};
76 static const SG::InitializedReadHandleKey<PixelContainer> bkgItkPixelClusters{
77 "Bkg_ITkPixelClusters"};
78
79 struct ContainerCandidate {
81 const char* overlayOutputName;
82 };
83 static const ContainerCandidate candidates[] = {
84 {pixelClusters, "Bkg_PixelClusters"},
85 {itkPixelClusters, "Bkg_ITkPixelClusters"},
86 {bkgPixelClusters, "Bkg_PixelClusters"},
87 {bkgItkPixelClusters, "Bkg_ITkPixelClusters"},
88 };
89
91
92 persObj->m_prdLink.m_contName.clear();
93
94 const bool doOverlay = m_eventCnvTool->doTrackOverlay();
95
96 for (const ContainerCandidate& candidate : candidates) {
97 const bool found =
99 ->getHashAndIndex<PixelContainer, InDet::PixelClusterOnTrack>(
100 transObj, candidate.key, hashAndIndex);
101
102 if (!found) continue;
103
104 persObj->m_prdLink.m_contName =
105 doOverlay ? candidate.overlayOutputName : candidate.key.key();
106
107 break;
108 }
109
110 persObj->m_prdLink.m_elementIndex = hashAndIndex;
111}
112
113StatusCode PixelClusterOnTrackCnv_p2::initialize(MsgStream &/*log*/) {
114 // Do not initialize again:
115 m_isInitialized=true;
116
117 // Get Storegate, ID helpers, and so on
118 ISvcLocator* svcLocator = Gaudi::svcLocator();
119 SmartIF<StoreGateSvc> detStore{svcLocator->service("DetectorStore")};
120 CHECK( detStore.isValid() );
121 CHECK( detStore->retrieve(m_pixId, "PixelID") );
122
123 return StatusCode::SUCCESS;
124}
125
126
#define endmsg
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
ElementLink< InDet::PixelClusterContainer > ElementLinkToIDCPixelClusterContainer
This is an Identifier helper class for the Pixel subdetector.
void fillTransFromPStore(CNV **cnv, const TPObjRef &ref, TRANS_T *trans, MsgStream &log) const
TPObjRef toPersistent(CNV **cnv, const typename CNV::TransBase_t *transObj, MsgStream &log) const
value_type get_compact() const
Get the compact id.
ElementLinkInt_p1 m_prdLink
Link to PRD.
IdentifierHash::value_type m_idDE
Specific class to represent the pixel measurements.
virtual const InDetDD::SiDetectorElement * detectorElement() const override final
returns the detector element, assoicated with the PRD of this class
bool isFake() const
returns whether this cluster is likely to be the fake mirror image of a ganged pixel.
bool hasClusterAmbiguity() const
returns whether there was an ambiguity associated with this pixel cluster.
float energyLoss() const
returns the energy loss in MeV associated to this cluster.
virtual IdentifierHash idDE() const override
returns the DE hashID*
void transToPers(const InDet ::PixelClusterOnTrack *transObj, InDet ::PixelClusterOnTrack_p2 *persObj, MsgStream &log)
ToolHandle< Trk::IEventCnvSuperTool > m_eventCnvTool
LocalParametersCnv_p1 * m_localParCnv
ElementLinkCnv_p1< ElementLinkToIDCPixelClusterContainer > m_elCnv
void persToTrans(const InDet ::PixelClusterOnTrack_p2 *persObj, InDet ::PixelClusterOnTrack *transObj, MsgStream &log)
StatusCode initialize(MsgStream &log)
ReadHandleKey that initializes during construction.
Property holding a SG store/key/clid from which a ReadHandle is made.
std::vector< float > values
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
Identifier identify() const
return the identifier -extends MeasurementBase
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
static void eigenMatrixToVector(VECTOR &vec, COVARIANCE &cov, const char *)
void initialize()