ATLAS Offline Software
SCT_ClusterContainerCnv_p0.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 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  ISvcLocator* svcLocator = Gaudi::svcLocator();
38 
39  // Get the messaging service, print where you are
40  log << MSG::INFO << "SCT_ClusterContainerCnv::initialize()" << endmsg;
41 
42  StoreGateSvc* detStore = nullptr;
43  CHECK( svcLocator->service("DetectorStore", detStore) );
44  CHECK( detStore->retrieve(m_sctId, "SCT_ID") );
46  MSG_DEBUG(log,"Converter initialized.");
47 
48  return StatusCode::SUCCESS;
49 }
50 
52 
53  std::unique_ptr<InDet::SCT_ClusterContainer> trans(std::make_unique<InDet::SCT_ClusterContainer>(m_sctId->wafer_hash_max()) );
54  // MSG_DEBUG(log,"Read PRD vector, size " << persObj->size());
55 
57  const InDetDD::SiDetectorElementCollection* elements(*sctDetEleHandle);
58  if (not sctDetEleHandle.isValid() or elements==nullptr) {
59  log << MSG::FATAL << m_SCTDetEleCollKey.fullKey() << " is not available." << endmsg;
60  return trans.release();
61  }
62 
63  for (InDet::SCT_ClusterCollection* dcColl : *persObj) {
64  // Add detElem to each drift circle
65  IdentifierHash collHash = dcColl->identifyHash();
66  const InDetDD::SiDetectorElement * de = elements->getDetectorElement(collHash);
67  // MSG_DEBUG(log,"Set SCT_Cluster detector element to "<< de);
68 
69  InDet::SCT_ClusterCollection::iterator itColl = dcColl->begin();
70  InDet::SCT_ClusterCollection::iterator lastColl = dcColl->end();
71  for (; itColl != lastColl; ++itColl) {
72  (*itColl)->m_detEl = de;
73  }
74 
75  StatusCode sc= trans ? trans->addCollection(dcColl, collHash): StatusCode::FAILURE;
76  if (sc.isSuccess()){
77  // MSG_VERBOSE("SCT_ClusterContainer successfully added to Container !");
78  } else {
79  log << MSG::ERROR << "Failed to add SCT_ClusterContainer to container" << endmsg;
80  return nullptr;
81  }
82  }
83  return trans.release();
84 }
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:205
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
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
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:581
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:639
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
Definition: IdentifierHash.h:38
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