ATLAS Offline Software
SCT_ClusterContainerCnv_p0.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "MsgUtil.h"
8 
9 // Athena
11 #include "InDetIdentifier/SCT_ID.h"
13 #include "StoreGate/StoreGateSvc.h"
14 
15 // Gaudi
16 #include "GaudiKernel/Bootstrap.h"
17 #include "GaudiKernel/ISvcLocator.h"
18 #include "GaudiKernel/MsgStream.h"
19 #include "GaudiKernel/Service.h"
20 #include "GaudiKernel/StatusCode.h"
21 
22 #include <iostream>
23 #include <sstream>
24 #include <string>
25 
26 //================================================================
27 
28 
30  m_sctId{nullptr},
31  m_SCTDetEleCollKey{"SCT_DetectorElementCollection"}
32 {
33 }
34 
36 
37  log << MSG::INFO << "SCT_ClusterContainerCnv::initialize()" << endmsg;
38 
39  SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
40  CHECK( detStore.isValid() );
41 
42  CHECK( detStore->retrieve(m_sctId, "SCT_ID") );
44  MSG_DEBUG(log,"Converter initialized.");
45 
46  return StatusCode::SUCCESS;
47 }
48 
50 
51  std::unique_ptr<InDet::SCT_ClusterContainer> trans(std::make_unique<InDet::SCT_ClusterContainer>(m_sctId->wafer_hash_max()) );
52  // MSG_DEBUG(log,"Read PRD vector, size " << persObj->size());
53 
55  const InDetDD::SiDetectorElementCollection* elements(*sctDetEleHandle);
56  if (not sctDetEleHandle.isValid() or elements==nullptr) {
57  log << MSG::FATAL << m_SCTDetEleCollKey.fullKey() << " is not available." << endmsg;
58  return trans.release();
59  }
60 
61  for (InDet::SCT_ClusterCollection* dcColl : *persObj) {
62  // Add detElem to each drift circle
63  IdentifierHash collHash = dcColl->identifyHash();
64  const InDetDD::SiDetectorElement * de = elements->getDetectorElement(collHash);
65  // MSG_DEBUG(log,"Set SCT_Cluster detector element to "<< de);
66 
67  InDet::SCT_ClusterCollection::iterator itColl = dcColl->begin();
68  InDet::SCT_ClusterCollection::iterator lastColl = dcColl->end();
69  for (; itColl != lastColl; ++itColl) {
70  (*itColl)->m_detEl = de;
71  }
72 
73  StatusCode sc= trans ? trans->addCollection(dcColl, collHash): StatusCode::FAILURE;
74  if (sc.isSuccess()){
75  // MSG_VERBOSE("SCT_ClusterContainer successfully added to Container !");
76  } else {
77  log << MSG::ERROR << "Failed to add SCT_ClusterContainer to container" << endmsg;
78  return nullptr;
79  }
80  }
81  return trans.release();
82 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SCT_ClusterContainerCnv_p0::initialize
StatusCode initialize(MsgStream &log)
Definition: SCT_ClusterContainerCnv_p0.cxx:35
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
SCT_ClusterContainerCnv_p0::SCT_ClusterContainerCnv_p0
SCT_ClusterContainerCnv_p0()
Definition: SCT_ClusterContainerCnv_p0.cxx:29
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
SCT_ClusterContainerCnv_p0::m_sctId
const SCT_ID * m_sctId
Definition: SCT_ClusterContainerCnv_p0.h:41
InDet::SCT_ClusterContainer
Trk::PrepRawDataContainer< SCT_ClusterCollection > SCT_ClusterContainer
Definition: SCT_ClusterContainer.h:27
SCT_ClusterContainerCnv_p0.h
ReadCondHandle.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
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
SCT_ClusterContainerCnv_p0::createTransient
virtual InDet::SCT_ClusterContainer * createTransient(const SCT_ClusterContainer_p0 *, MsgStream &) override
Definition: SCT_ClusterContainerCnv_p0.h:34
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
SCT_ClusterContainerCnv_p0::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Definition: SCT_ClusterContainerCnv_p0.h:42
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
SCT_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: SCT_ID.cxx:645
errorcheck.h
Helpers for checking error return status codes and reporting errors.
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MSG_DEBUG
#define MSG_DEBUG(log, x)
Definition: MsgUtil.h:15
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
InDet::SCT_ClusterCollection
Trk::PrepRawDataCollection< SCT_Cluster > SCT_ClusterCollection
Definition: SCT_ClusterCollection.h:26
StoreGateSvc.h
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15
MsgUtil.h