ATLAS Offline Software
PixelClusterContainerCnv_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
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 
29  m_pixelDetEleCollKey{"PixelDetectorElementCollection"}
30 {
31 }
32 
34 
35  log << MSG::INFO << "PixelClusterContainerCnv::initialize()" << endmsg;
36 
37  SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
38  CHECK( detStore.isValid() );
39 
40  CHECK( detStore->retrieve(m_pixId, "PixelID") );
42  MSG_DEBUG(log,"Converter initialized.");
43 
44  return StatusCode::SUCCESS;
45 }
46 
47 
48 
49 
51 
52  std::unique_ptr<InDet::PixelClusterContainer> trans(std::make_unique<InDet::PixelClusterContainer>(m_pixId->wafer_hash_max()) );
53  MSG_DEBUG(log,"Read PRD vector, size " << persObj->size());
54 
56  const InDetDD::SiDetectorElementCollection* elements(*pixelDetEleHandle);
57  if (not pixelDetEleHandle.isValid() or elements==nullptr) {
58  log << MSG::FATAL << m_pixelDetEleCollKey.fullKey() << " is not available." << endmsg;
59  return trans.release();
60  }
61 
62  for (InDet::PixelClusterCollection* dcColl : *persObj) {
63  // Add detElem to each drift circle
64  IdentifierHash collHash = dcColl->identifyHash();
65  const InDetDD::SiDetectorElement * de = elements->getDetectorElement(collHash);
66  MSG_DEBUG(log,"Set PixelCluster detector element to "<< de);
67 
68  InDet::PixelClusterCollection::iterator itColl = dcColl->begin();
69  InDet::PixelClusterCollection::iterator lastColl = dcColl->end();
70  for (int num = 0; itColl != lastColl; ++itColl, ++num) {
71  MSG_DEBUG(log,"PRD " << num);
72  (*itColl)->m_detEl = de;
73  }
74 
75  StatusCode sc= trans? trans->addCollection(dcColl, collHash): StatusCode::FAILURE;
76  if (sc.isSuccess()){
77  MSG_VERBOSE(log,"PixelClusterContainer successfully added to Container !");
78  } else {
79  log << MSG::ERROR << "Failed to add PixelClusterContainer to container" << endmsg;
80  return nullptr;
81  }
82  }
83  return trans.release();
84 }
85 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
PixelClusterContainerCnv_p0::PixelClusterContainerCnv_p0
PixelClusterContainerCnv_p0()
Definition: PixelClusterContainerCnv_p0.cxx:28
PixelClusterContainerCnv_p0::m_pixId
const PixelID * m_pixId
Definition: PixelClusterContainerCnv_p0.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
InDet::PixelClusterContainer
Trk::PrepRawDataContainer< PixelClusterCollection > PixelClusterContainer
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelClusterContainer.h:28
ReadCondHandle.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
PixelClusterContainerCnv_p0::createTransient
virtual InDet::PixelClusterContainer * createTransient(const PixelClusterContainer_p0 *, MsgStream &) override
Definition: PixelClusterContainerCnv_p0.h:32
PixelClusterContainerCnv_p0::initialize
StatusCode initialize(MsgStream &log)
Definition: PixelClusterContainerCnv_p0.cxx:33
PixelClusterContainerCnv_p0::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition: PixelClusterContainerCnv_p0.h:41
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
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
PixelClusterContainerCnv_p0.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
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)
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:907
MSG_VERBOSE
#define MSG_VERBOSE(log, x)
Definition: MsgUtil.h:17
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
StoreGateSvc.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15
InDet::PixelClusterCollection
Trk::PrepRawDataCollection< PixelCluster > PixelClusterCollection
Definition: PixelClusterCollection.h:26
MsgUtil.h