ATLAS Offline Software
RIO_OnTrackCnv_p1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 void RIO_OnTrackCnv_p1::persToTrans( const Trk::RIO_OnTrack_p1 *persObj, Trk::RIO_OnTrack *transObj, MsgStream &log )
10 {
11 // static int count = 0;
12 // if( count++ < 10 ) {
13 // log << MSG::INFO << ">>>>--------- RIO_OnTrack ID = " << persObj->m_id << endmsg;
14 // }
15 
16  //transObj->m_identifier = persObj->m_id;
17 
18  if(!m_isInitialized) {
19  if (this->initialize(log) != StatusCode::SUCCESS) {
20  log << MSG::FATAL << "Could not initialize RIO_OnTRackCnv_p1 " << endmsg;
21  }
22  }
23 
24  if (m_pixId->is_shortened_pixel_id(persObj->m_id)) {
25  transObj->m_identifier = m_pixId->pixel_id_from_shortened(persObj->m_id);
26  }
27  else {
28  transObj->m_identifier = persObj->m_id;
29  }
30 
32 
33  //Error matrix
36  EigenHelpers::vectorToEigenMatrix(dummy.values, transObj->m_localCovariance, "RIO_OnTrackCnv_p1");
37  // Now try to fill actual data... Amg::MatrixX m_localCovariance;
38  // 1x1 => size=1
39  // 2x2 => size=3
40  size_t size = dummy.values.size();
41  if (size==1){
42  transObj->m_localCovariance<<dummy.values[0];
43  } else if (size==3){
44  transObj->m_localCovariance<<dummy.values[0],dummy.values[1],dummy.values[1],dummy.values[2];
45  } else {
46  throw std::runtime_error("RIO_OnTrackCnv_p2::persToTrans - matrix has unexpected size of "+std::to_string (size)+"!");
47  }
48 
49  // Attempt to call supertool to fill in detElements
50 
51  m_eventCnvTool->recreateRIO_OnTrack(transObj);
52 // std::cout<<"RIO_OnTrackCnv_p1::persToTrans after : detEl="<<transObj->detectorElement()<<std::endl;
53  if (transObj->detectorElement()==nullptr)
54  log << MSG::WARNING<<"Unable to reset DetEl for this RIO_OnTrack, "
55  << "probably because of a problem with the Identifier/IdentifierHash : ("
56  << transObj->identify()<<"/"<<transObj->idDE()<<endmsg;
57 }
58 
59 
61 {
62  throw std::runtime_error("RIO_OnTrackCnv_p1::transToPers is deprecated!");
63 }
64 
66  // Do not initialize again:
67  m_isInitialized=true;
68 
69  // Get Storegate, ID helpers, and so on
70  ISvcLocator* svcLocator = Gaudi::svcLocator();
71  // get StoreGate service
72  StatusCode sc = svcLocator->service("StoreGateSvc", m_storeGate);
73  if (sc.isFailure()) {
74  log << MSG::FATAL << "StoreGate service not found !" << endmsg;
75  return StatusCode::FAILURE;
76  }
77 
78  // get DetectorStore service
80  sc = svcLocator->service("DetectorStore", detStore);
81  if (sc.isFailure()) {
82  log << MSG::FATAL << "DetectorStore service not found !" << endmsg;
83  return StatusCode::FAILURE;
84  }
85  // else {
86  // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Found DetectorStore." << endmsg;
87  // }
88 
89  // Get the sct helper from the detector store
90  sc = detStore->retrieve(m_pixId, "PixelID");
91  if (sc.isFailure()) {
92  log << MSG::FATAL << "Could not get PixelID helper !" << endmsg;
93  return StatusCode::FAILURE;
94  }
95 
96 
97  // if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Converter initialized." << endmsg;
98  return StatusCode::SUCCESS;
99 }
Trk::RIO_OnTrack_p1::m_localParams
TPObjRef m_localParams
Definition: RIO_OnTrack_p1.h:29
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
RIO_OnTrackCnv_p1.h
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
Trk::RIO_OnTrack_p1::m_id
unsigned int m_id
Definition: RIO_OnTrack_p1.h:26
PixelID::is_shortened_pixel_id
bool is_shortened_pixel_id(Identifier32::value_type val) const
Test if this is a valid shortened pixel channel id.
Definition: PixelID.h:516
RIO_OnTrackCnv_p1::initialize
StatusCode initialize(MsgStream &log)
Definition: RIO_OnTrackCnv_p1.cxx:65
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
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
Trk::ErrorMatrix
Definition: ErrorMatrixCnv_p1.h:25
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
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
Trk::RIO_OnTrack_p1
Definition: RIO_OnTrack_p1.h:22
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
RIO_OnTrackCnv_p1::transToPers
virtual void transToPers(const Trk::RIO_OnTrack *transObj, Trk::RIO_OnTrack_p1 *persObj, MsgStream &log)
Definition: RIO_OnTrackCnv_p1.cxx:60
RIO_OnTrackCnv_p1::persToTrans
virtual void persToTrans(const Trk::RIO_OnTrack_p1 *persObj, Trk::RIO_OnTrack *transObj, MsgStream &log)
Definition: RIO_OnTrackCnv_p1.cxx:9
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
Trk::MeasurementBase::m_localParams
LocalParameters m_localParams
Definition: MeasurementBase.h:111
RIO_OnTrackCnv_p1::m_errorMxCnv
ErrorMatrixCnv_p1 * m_errorMxCnv
Definition: RIO_OnTrackCnv_p1.h:40
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
RIO_OnTrackCnv_p1::m_pixId
const PixelID * m_pixId
Definition: RIO_OnTrackCnv_p1.h:42
RIO_OnTrack.h
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
RIO_OnTrackCnv_p1::m_eventCnvTool
ToolHandle< Trk::IEventCnvSuperTool > m_eventCnvTool
Definition: RIO_OnTrackCnv_p1.h:41
RIO_OnTrackCnv_p1::m_isInitialized
bool m_isInitialized
Definition: RIO_OnTrackCnv_p1.h:44
Trk::RIO_OnTrack::idDE
virtual IdentifierHash idDE() const =0
returns the DE hashID
Trk::MeasurementBase::m_localCovariance
Amg::MatrixX m_localCovariance
Definition: MeasurementBase.h:112
Trk::RIO_OnTrack::m_identifier
Identifier m_identifier
Identifier of the RIO_OnTrack (comes from the associated Trk::PrepRawData)
Definition: RIO_OnTrack.h:152
RIO_OnTrackCnv_p1::m_localParCnv
LocalParametersCnv_p1 * m_localParCnv
Definition: RIO_OnTrackCnv_p1.h:39
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Trk::RIO_OnTrack::identify
virtual Identifier identify() const final
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:155
RIO_OnTrackCnv_p1::m_storeGate
StoreGateSvc * m_storeGate
Definition: RIO_OnTrackCnv_p1.h:43
Trk::RIO_OnTrack::detectorElement
virtual const TrkDetElementBase * detectorElement() const =0
returns the detector element, assoicated with the PRD of this class
Trk::RIO_OnTrack_p1::m_localErrMat
TPObjRef m_localErrMat
Definition: RIO_OnTrack_p1.h:31
PixelID::pixel_id_from_shortened
Identifier pixel_id_from_shortened(Identifier32::value_type val) const
Create a compact pixel id from a (fixed format) legacy pixel channel id.
Definition: PixelID.h:546