ATLAS Offline Software
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 
29  Amg::MatrixX localCovariance;
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 );
59  Trk::ErrorMatrix pMat;
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  static const SG::InitializedReadHandleKey<InDet::PixelClusterContainer> pixelClusContName("PixelClusters");
70  bool isFound{m_eventCnvTool->getHashAndIndex<InDet::PixelClusterContainer, InDet::PixelClusterOnTrack>(transObj, pixelClusContName, hashAndIndex)};
71  //in the case of track overlay, the final output container has a different name which we use instead
72  if(m_eventCnvTool->doTrackOverlay()){
73  persObj->m_prdLink.m_contName = (isFound ? "Bkg_PixelClusters" : "");
74  if(!isFound){ //in this case the input collection is called Bkg_PixelClusters as well
75  static const SG::InitializedReadHandleKey<InDet::PixelClusterContainer> pixelClusContName("Bkg_PixelClusters");
76  isFound=m_eventCnvTool->getHashAndIndex<InDet::PixelClusterContainer, InDet::PixelClusterOnTrack>(transObj, pixelClusContName, hashAndIndex);
77  persObj->m_prdLink.m_contName = (isFound ? "Bkg_PixelClusters" : "");
78  }
79  }
80  else persObj->m_prdLink.m_contName = (isFound ? pixelClusContName.key() : "");
81  persObj->m_prdLink.m_elementIndex = hashAndIndex;
82 }
83 
85  // Do not initialize again:
86  m_isInitialized=true;
87 
88  // Get Storegate, ID helpers, and so on
89  ISvcLocator* svcLocator = Gaudi::svcLocator();
90  SmartIF<StoreGateSvc> detStore{svcLocator->service("DetectorStore")};
91  CHECK( detStore.isValid() );
92  CHECK( detStore->retrieve(m_pixId, "PixelID") );
93 
94  return StatusCode::SUCCESS;
95 }
96 
97 
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
Trk::LocalParameters
Definition: LocalParameters.h:98
PixelClusterOnTrackCnv_p2::transToPers
void transToPers(const InDet ::PixelClusterOnTrack *transObj, InDet ::PixelClusterOnTrack_p2 *persObj, MsgStream &log)
Definition: PixelClusterOnTrackCnv_p2.cxx:54
InDet::SiClusterOnTrack::idDE
virtual IdentifierHash idDE() const override
returns the DE hashID*
Definition: SiClusterOnTrack.h:119
InDet::PixelClusterOnTrack_p2::m_prdLink
ElementLinkInt_p1 m_prdLink
Link to PRD.
Definition: PixelClusterOnTrack_p2.h:32
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
PixelClusterOnTrackCnv_p2::m_errorMxCnv
ErrorMatrixCnv_p1 * m_errorMxCnv
Definition: PixelClusterOnTrackCnv_p2.h:40
PixelClusterOnTrackCnv_p2.h
Identifier::get_compact
value_type get_compact() const
Get the compact id.
InDet::PixelClusterOnTrack_p2::m_energyLoss
float m_energyLoss
Definition: PixelClusterOnTrack_p2.h:30
PixelClusterOnTrackCnv_p2::initialize
StatusCode initialize(MsgStream &log)
Definition: PixelClusterOnTrackCnv_p2.cxx:84
InDet::PixelClusterOnTrack_p2::m_localParams
TPObjRef m_localParams
Definition: PixelClusterOnTrack_p2.h:21
LocalParametersCnv_p1.h
InDet::PixelClusterContainer
Trk::PrepRawDataContainer< PixelClusterCollection > PixelClusterContainer
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelClusterContainer.h:28
InDet::PixelClusterOnTrack_p2::m_localErrMat
TPObjRef m_localErrMat
Definition: PixelClusterOnTrack_p2.h:22
PixelClusterOnTrackCnv_p2::m_localParCnv
LocalParametersCnv_p1 * m_localParCnv
Definition: PixelClusterOnTrackCnv_p2.h:39
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
PixelClusterOnTrackCnv_p2::m_elCnv
ElementLinkCnv_p1< ElementLinkToIDCPixelClusterContainer > m_elCnv
Definition: PixelClusterOnTrackCnv_p2.h:38
InDet::PixelClusterOnTrack::energyLoss
float energyLoss() const
returns the energy loss in MeV associated to this cluster.
Definition: PixelClusterOnTrack.h:206
PixelClusterOnTrackCnv_p2::m_pixId
const PixelID * m_pixId
Definition: PixelClusterOnTrackCnv_p2.h:41
ITPConverterFor< TRANS_BASE >::fillTransFromPStore
void fillTransFromPStore(CNV **cnv, const TPObjRef &ref, TRANS_T *trans, MsgStream &log) const
Convert persistent object, stored in the the top-level persistent object and referenced by the TP Ref...
Definition: TPConverter.h:145
Trk::ErrorMatrix
Definition: ErrorMatrixCnv_p1.h:25
InDet::PixelClusterOnTrack_p2::m_hasClusterAmbiguity
bool m_hasClusterAmbiguity
Definition: PixelClusterOnTrack_p2.h:28
EigenHelpers::vectorToEigenMatrix
static void vectorToEigenMatrix(VECTOR &vec, COVARIANCE &cov, const char *)
Helper fn to fill the covariance from the raw data (vec<float>)
Definition: EigenHelpers.h:22
InDet::SiClusterOnTrack::isBroadCluster
bool isBroadCluster() const
Definition: SiClusterOnTrack.h:124
InDet::PixelClusterOnTrack_p2::m_isFake
bool m_isFake
Definition: PixelClusterOnTrack_p2.h:29
InDet::PixelClusterOnTrack::hasClusterAmbiguity
bool hasClusterAmbiguity() const
returns whether there was an ambiguity associated with this pixel cluster.
Definition: PixelClusterOnTrack.h:198
InDet::PixelClusterOnTrack_p2::m_isbroad
bool m_isbroad
Definition: PixelClusterOnTrack_p2.h:25
InDet::PixelClusterOnTrack::detectorElement
virtual const InDetDD::SiDetectorElement * detectorElement() const override final
returns the detector element, assoicated with the PRD of this class
Definition: PixelClusterOnTrack.h:193
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EigenHelpers.h
python.xAODType.dummy
dummy
Definition: xAODType.py:4
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
EigenHelpers::eigenMatrixToVector
static void eigenMatrixToVector(VECTOR &vec, COVARIANCE &cov, const char *)
Helper fn to get raw data (vec<float>) from the covariance.
Definition: EigenHelpers.h:30
Trk::MeasurementBase::localCovariance
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
Definition: MeasurementBase.h:138
ITPConverterFor< TRANS_BASE >::toPersistent
TPObjRef toPersistent(CNV **cnv, const typename CNV::TransBase_t *transObj, MsgStream &log) const
Persistify an object and store the persistent represenation in the storage vector of the top-level pe...
Definition: TPConverter.h:119
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
errorcheck.h
Helpers for checking error return status codes and reporting errors.
InDet::PixelClusterOnTrack_p2::m_idDE
IdentifierHash::value_type m_idDE
Definition: PixelClusterOnTrack_p2.h:24
PixelClusterOnTrackCnv_p2::persToTrans
void persToTrans(const InDet ::PixelClusterOnTrack_p2 *persObj, InDet ::PixelClusterOnTrack *transObj, MsgStream &log)
Definition: PixelClusterOnTrackCnv_p2.cxx:13
SG::InitializedReadHandleKey
ReadHandleKey that initializes during construction.
Definition: StoreGate/StoreGate/ReadHandleKey.h:133
Trk::ErrorMatrix::values
std::vector< float > values
Definition: ErrorMatrixCnv_p1.h:27
Trk::MeasurementBase::localParameters
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Definition: MeasurementBase.h:132
ErrorMatrixCnv_p1.h
PixelClusterOnTrackCnv_p2::m_isInitialized
bool m_isInitialized
Definition: PixelClusterOnTrackCnv_p2.h:42
InDet::PixelClusterOnTrack
Definition: PixelClusterOnTrack.h:51
InDet::PixelClusterOnTrack::isFake
bool isFake() const
returns whether this cluster is likely to be the fake mirror image of a ganged pixel.
Definition: PixelClusterOnTrack.h:202
PixelID::pixel_id
Identifier pixel_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int phi_index, int eta_index) const
For an individual pixel.
Definition: PixelID.h:432
Trk::RIO_OnTrack::identify
Identifier identify() const
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:152
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
PixelClusterOnTrackCnv_p2::m_eventCnvTool
ToolHandle< Trk::IEventCnvSuperTool > m_eventCnvTool
Definition: PixelClusterOnTrackCnv_p2.h:37
InDet::PixelClusterOnTrack_p2
Definition: PixelClusterOnTrack_p2.h:15
PixelClusterOnTrack.h
InDet::PixelClusterOnTrack_p2::m_id
unsigned long long m_id
Definition: PixelClusterOnTrack_p2.h:20