ATLAS Offline Software
TrigInDetTrackCnv_p4.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 
10 //-----------------------------------------------------------------------------
11 // Persistent to transient
12 //-----------------------------------------------------------------------------
13 void TrigInDetTrackCnv_p4::persToTrans( const TrigInDetTrack_p4 *persObj, TrigInDetTrack *transObj, MsgStream &log )
14 {
15 
16  // log << MSG::DEBUG << "TrigInDetTrackCnv_p4::persToTrans called " << endmsg;
17 
18  transObj->algorithmId ((TrigInDetTrack::AlgoId) persObj->m_allIntegers[0]);
19  transObj->StrawHits (persObj->m_allIntegers[1]);
20  transObj->Straw (persObj->m_allIntegers[2]);
21  transObj->StrawTime (persObj->m_allIntegers[3]);
22  transObj->TRHits (persObj->m_allIntegers[4]);
23  transObj->NPixelSpacePoints (persObj->m_allIntegers[5]);
24  transObj->NSCT_SpacePoints (persObj->m_allIntegers[6]);
25  transObj->HitPattern (persObj->m_allIntegers[7]);
26 
27  transObj->chi2 (persObj->m_chi2) ;
28 
29  transObj->param (createTransFromPStore( &m_fpCnv, persObj->m_param, log ));
30  transObj->endParam (createTransFromPStore( &m_fpCnv, persObj->m_endParam, log ));
31  //transObj->m_rdoList.resize( persObj->m_rdoList.size() );
32  //std::copy( persObj->m_rdoList.begin(), persObj->m_rdoList.end(), transObj->m_rdoList.begin() );
33 
34  if(!m_isInitialized) {
35  if (this->initialize(log) != StatusCode::SUCCESS) {
36  log << MSG::FATAL << "Could not initialize TrigInDetTrackCnv_p4 " << endmsg;
37  }
38  }
39 
40  std::vector<Identifier> rdoList;
41  rdoList.reserve( persObj->m_rdoList.size() );
42  for (unsigned int id : persObj->m_rdoList) {
43  if (m_pixId->is_shortened_pixel_id(id)) {
44  rdoList.emplace_back (m_pixId->pixel_id_from_shortened(id));
45  }
46  else {
47  rdoList.emplace_back (id);
48  }
49  }
50  transObj->rdoList (std::move(rdoList));
51 
52 }
53 
54 //-----------------------------------------------------------------------------
55 // Transient to persistent
56 //-----------------------------------------------------------------------------
57 void TrigInDetTrackCnv_p4::transToPers( const TrigInDetTrack *transObj, TrigInDetTrack_p4 *persObj, MsgStream &log )
58 {
59  // log << MSG::DEBUG << "TrigInDetTrackCnv_p4::transToPers called " << endmsg;
60  persObj->m_allIntegers[0]= transObj->algorithmId() ;
61  persObj->m_allIntegers[1]= transObj->NStrawHits() ;
62  persObj->m_allIntegers[2]= transObj->NStraw() ;
63  persObj->m_allIntegers[3]= transObj->NStrawTime() ;
64  persObj->m_allIntegers[4]= transObj->NTRHits() ;
65  persObj->m_allIntegers[5]= transObj->NPixelSpacePoints();
66  persObj->m_allIntegers[6]= transObj->NSCT_SpacePoints();
67  persObj->m_allIntegers[7]= transObj->HitPattern();
68 
69  persObj->m_chi2 = transObj->chi2() ;
70 
71  persObj->m_param = toPersistent( &m_fpCnv, transObj->param(), log );
72  persObj->m_endParam = toPersistent( &m_fpCnv, transObj->endParam(), log );
73 
74  const std::vector<Identifier>& rdoList = transObj->rdoList();
75  persObj->m_rdoList.clear();
76  persObj->m_rdoList.reserve( rdoList.size() );
77  for (const Identifier& id : rdoList)
78  persObj->m_rdoList.push_back (id.get_identifier32().get_compact());
79 }
80 
81 
83  // Do not initialize again:
84  m_isInitialized=true;
85 
86  // get DetectorStore service
87  SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
88  if (!detStore) {
89  log << MSG::FATAL << "DetectorStore service not found !" << endmsg;
90  return StatusCode::FAILURE;
91  }
92 
93  // Get the sct helper from the detector store
94  StatusCode sc = detStore->retrieve(m_pixId, "PixelID");
95  if (sc.isFailure()) {
96  log << MSG::FATAL << "Could not get PixelID helper !" << endmsg;
97  return StatusCode::FAILURE;
98  }
99 
100  return StatusCode::SUCCESS;
101 }
102 
103 
105 {
106  m_pixId = pixId;
107  m_isInitialized = true;
108 }
TrigInDetTrack_p4::m_chi2
double m_chi2
Definition: TrigInDetTrack_p4.h:43
TrigInDetTrack::StrawTime
void StrawTime(const int NSTime)
Definition: TrigInDetTrack.h:131
TrigInDetTrack::param
void param(const TrigInDetTrackFitPar *param)
Definition: TrigInDetTrack.h:126
TrigInDetTrack::NStrawTime
int NStrawTime() const
Number of TRT straws with valid drift time intersected by track.
Definition: TrigInDetTrack.h:173
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
TrigInDetTrackCnv_p4::initialize
StatusCode initialize(MsgStream &log)
Definition: TrigInDetTrackCnv_p4.cxx:82
TrigInDetTrack_p4::m_param
TPObjRef m_param
Definition: TrigInDetTrack_p4.h:41
TrigInDetTrack_p4::m_allIntegers
int m_allIntegers[8]
Definition: TrigInDetTrack_p4.h:53
TrigInDetTrack::chi2
void chi2(const double chi2)
Definition: TrigInDetTrack.h:128
TrigInDetTrack::TRHits
void TRHits(const int NTR)
Definition: TrigInDetTrack.h:132
TrigInDetTrack_p4.h
TrigInDetTrack::AlgoId
AlgoId
Definition: TrigInDetTrack.h:37
TrigInDetTrack::NStraw
int NStraw() const
Number of TRT straws intersected by track.
Definition: TrigInDetTrack.h:171
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
TrigInDetTrack
Definition: TrigInDetTrack.h:34
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TrigInDetTrack.h
TrigInDetTrack_p4::m_endParam
TPObjRef m_endParam
Definition: TrigInDetTrack_p4.h:42
TrigInDetTrackCnv_p4::m_pixId
const PixelID * m_pixId
Definition: TrigInDetTrackCnv_p4.h:44
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
TrigInDetTrackCnv_p4::m_fpCnv
ITPConverterFor< TrigInDetTrackFitPar > * m_fpCnv
Definition: TrigInDetTrackCnv_p4.h:42
TrigInDetTrack::NPixelSpacePoints
void NPixelSpacePoints(const int n)
Definition: TrigInDetTrack.h:133
TrigInDetTrack::NSCT_SpacePoints
void NSCT_SpacePoints(const int n)
Definition: TrigInDetTrack.h:134
TrigInDetTrack::Straw
void Straw(const int NS)
Definition: TrigInDetTrack.h:130
TrigInDetTrack::NStrawHits
int NStrawHits() const
Number of TRT hits associated with track.
Definition: TrigInDetTrack.h:169
ITPConverterFor::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
TrigInDetTrack::StrawHits
void StrawHits(const int NSHits)
Definition: TrigInDetTrack.h:129
TrigInDetTrack::NTRHits
int NTRHits() const
Number of high-threshold TRT hits associated with track.
Definition: TrigInDetTrack.h:175
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TrigInDetTrack::endParam
void endParam(const TrigInDetTrackFitPar *param)
Definition: TrigInDetTrack.h:127
TrigInDetTrackCnv_p4::setPixelID
void setPixelID(const PixelID *pixId)
Definition: TrigInDetTrackCnv_p4.cxx:104
TrigInDetTrack_p4
Definition: TrigInDetTrack_p4.h:24
TrigInDetTrack::algorithmId
void algorithmId(const AlgoId id)
Definition: TrigInDetTrack.h:125
PixelID
Definition: PixelID.h:67
TrigInDetTrack::rdoList
const std::vector< Identifier > & rdoList() const
RDOs associated with track.
Definition: TrigInDetTrack.h:184
TrigInDetTrack_p4::m_rdoList
std::vector< unsigned int > m_rdoList
Definition: TrigInDetTrack_p4.h:54
StoreGateSvc.h
TrigInDetTrack::HitPattern
void HitPattern(const long hp)
Hit pattern setter method.
Definition: TrigInDetTrack.h:144
TrigInDetTrackCnv_p4::persToTrans
virtual void persToTrans(const TrigInDetTrack_p4 *, TrigInDetTrack *, MsgStream &)
Definition: TrigInDetTrackCnv_p4.cxx:13
TrigInDetTrackCnv_p4::transToPers
virtual void transToPers(const TrigInDetTrack *, TrigInDetTrack_p4 *, MsgStream &)
Definition: TrigInDetTrackCnv_p4.cxx:57
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
TrigInDetTrackCnv_p4.h
TrigInDetTrackCnv_p4::m_isInitialized
bool m_isInitialized
Definition: TrigInDetTrackCnv_p4.h:45
ITPConverterFor::createTransFromPStore
CNV::Trans_t * createTransFromPStore(CNV **cnv, const TPObjRef &ref, MsgStream &log) const
Create transient representation of a persistent object, stored in the the top-level persistent object...
Definition: TPConverter.h:172
Identifier
Definition: IdentifierFieldParser.cxx:14