ATLAS Offline Software
PixelClusterContainerCnv_p0.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  ISvcLocator* svcLocator = Gaudi::svcLocator();
36 
37  log << MSG::INFO << "PixelClusterContainerCnv::initialize()" << endmsg;
38 
39  StoreGateSvc* detStore = nullptr;
40  CHECK( svcLocator->service("DetectorStore", detStore) );
41  CHECK( detStore->retrieve(m_pixId, "PixelID") );
43  MSG_DEBUG(log,"Converter initialized.");
44 
45  return StatusCode::SUCCESS;
46 }
47 
48 
49 
50 
52 
53  std::unique_ptr<InDet::PixelClusterContainer> trans(std::make_unique<InDet::PixelClusterContainer>(m_pixId->wafer_hash_max()) );
54  MSG_DEBUG(log,"Read PRD vector, size " << persObj->size());
55 
57  const InDetDD::SiDetectorElementCollection* elements(*pixelDetEleHandle);
58  if (not pixelDetEleHandle.isValid() or elements==nullptr) {
59  log << MSG::FATAL << m_pixelDetEleCollKey.fullKey() << " is not available." << endmsg;
60  return trans.release();
61  }
62 
63  for (InDet::PixelClusterCollection* 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 PixelCluster detector element to "<< de);
68 
69  InDet::PixelClusterCollection::iterator itColl = dcColl->begin();
70  InDet::PixelClusterCollection::iterator lastColl = dcColl->end();
71  for (int num = 0; itColl != lastColl; ++itColl, ++num) {
72  MSG_DEBUG(log,"PRD " << num);
73  (*itColl)->m_detEl = de;
74  }
75 
76  StatusCode sc= trans? trans->addCollection(dcColl, collHash): StatusCode::FAILURE;
77  if (sc.isSuccess()){
78  MSG_VERBOSE(log,"PixelClusterContainer successfully added to Container !");
79  } else {
80  log << MSG::ERROR << "Failed to add PixelClusterContainer to container" << endmsg;
81  return nullptr;
82  }
83  }
84  return trans.release();
85 }
86 
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:205
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
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
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:912
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
Definition: IdentifierHash.h:38
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