ATLAS Offline Software
InDetSimDataCollectionCnv_p1.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 #include "InDetSimDataCnv_p1.h"
10 #include "Identifier/Identifier.h"
11 #include "MsgUtil.h"
13 #include "StoreGate/StoreGateSvc.h"
14 
16 {
17  InDetSimDataCnv_p1 simDataCnv;
18  persCont->m_simdata.resize(transCont->size());
19  MSG_DEBUG(log," Preparing " << persCont->m_simdata.size() << "Collections");
20  unsigned int collIndex(0);
21  for (const auto& transSimDataPair : *transCont) {
22  // Add in new collection
23  (persCont->m_simdata[collIndex]).first = transSimDataPair.first.get_identifier32().get_compact();
24  const InDetSimData& simData = transSimDataPair.second;
25  InDetSimData_p1& psimData = persCont->m_simdata[collIndex].second;
26  simDataCnv.transToPers(&simData,&psimData,log);
27  ++collIndex;
28  }
29  MSG_DEBUG(log," *** Writing InDetSimdataCollection");
30 }
31 
33 {
34  InDetSimDataCnv_p1 simDataCnv;
35  if(!m_isInitialized) {
36  if (this->initialize(log) != StatusCode::SUCCESS) {
37  log << MSG::FATAL << "Could not initialize InDetSimDataCollectionCnv_p1 " << endmsg;
38  }
39  }
40  MSG_DEBUG(log," Preparing " << persCont->m_simdata.size() << "Collections");
42  for (const auto& persSimDataPair : persCont->m_simdata) {
43  // Add in new collection
44  const InDetSimData_p1& psimData = persSimDataPair.second;
46  simDataCnv.persToTrans(&psimData,&simData,log);
47  // For 64-bit ids, when reading in the old 32-bit ids, we must
48  // treat pixel channel ids specially before creating a new
49  // 64-bit id
50  Identifier id;
51  if (m_pixId->is_shortened_pixel_id(persSimDataPair.first)) {
52  id = m_pixId->pixel_id_from_shortened(persSimDataPair.first); }
53  else { id = persSimDataPair.first; }
54  transCont->insert( transCont->end(), std :: make_pair( id, simData ) );
55  transCont->insert( transCont->end(), std :: make_pair( Identifier( persSimDataPair.first ), simData ) );
56  }
57  MSG_DEBUG(log," *** Reading InDetSimdataCollection");
58 }
59 
60 
62  // Do not initialize again:
63  m_isInitialized=true;
64 
65  // get DetectorStore service
66  SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
67  CHECK( detStore.isValid() );
68 
69  // Get the sct helper from the detector store
70  CHECK( detStore->retrieve(m_pixId, "PixelID") );
71 
72  return StatusCode::SUCCESS;
73 }
InDetSimDataCollectionCnv_p1.h
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
InDetSimDataCollection_p1::m_simdata
std::vector< std::pair< Identifier32::value_type, InDetSimData_p1 > > m_simdata
Definition: InDetSimDataCollection_p1.h:26
InDetSimData_p1
Definition: InDetSimData_p1.h:11
SG::CurrentEventStore::store
static IProxyDict * store()
Fetch the current store.
InDetSimDataCollection
Definition: InDetSimDataCollection.h:25
InDetSimDataCollectionCnv_p1::initialize
StatusCode initialize(MsgStream &log)
Definition: InDetSimDataCollectionCnv_p1.cxx:61
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
InDetSimDataCollectionCnv_p1::transToPers
virtual void transToPers(const InDetSimDataCollection *transCont, InDetSimDataCollection_p1 *persCont, MsgStream &log)
Definition: InDetSimDataCollectionCnv_p1.cxx:15
InDetSimDataCollectionCnv_p1::m_pixId
const PixelID * m_pixId
Definition: InDetSimDataCollectionCnv_p1.h:29
InDetSimDataCnv_p1::persToTrans
virtual void persToTrans(const InDetSimData_p1 *persObj, InDetSimData *transObj, MsgStream &log)
Definition: InDetSimDataCnv_p1.cxx:23
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
InDetSimDataCnv_p1::setCurrentStore
void setCurrentStore(IProxyDict *store)
Definition: InDetSimDataCnv_p1.cxx:56
InDetSimDataCnv_p1.h
InDetSimData
Definition: InDetSimData.h:42
InDetSimData.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
InDetSimDataCnv_p1
Definition: InDetSimDataCnv_p1.h:23
InDetSimDataCollectionCnv_p1::persToTrans
virtual void persToTrans(const InDetSimDataCollection_p1 *persCont, InDetSimDataCollection *transCont, MsgStream &log)
Definition: InDetSimDataCollectionCnv_p1.cxx:32
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
InDetSimDataCnv_p1::transToPers
virtual void transToPers(const InDetSimData *transObj, InDetSimData_p1 *persObj, MsgStream &log)
Definition: InDetSimDataCnv_p1.cxx:41
errorcheck.h
Helpers for checking error return status codes and reporting errors.
InDetSimDataCollectionCnv_p1::m_isInitialized
bool m_isInitialized
Definition: InDetSimDataCollectionCnv_p1.h:30
InDetSimDataCollection_p1
Definition: InDetSimDataCollection_p1.h:14
InDetSimDataCollection.h
DeMoScan.first
bool first
Definition: DeMoScan.py:536
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MSG_DEBUG
#define MSG_DEBUG(log, x)
Definition: MsgUtil.h:15
InDetSimDataCollection_p1.h
simData
constexpr bool simData
Definition: constants.h:36
StoreGateSvc.h
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
Identifier
Definition: IdentifierFieldParser.cxx:14
MsgUtil.h