ATLAS Offline Software
Loading...
Searching...
No Matches
PixelClusterContainerCnv_p0.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "MsgUtil.h"
8
9// Athena
14
15// Gaudi
16#include "GaudiKernel/Bootstrap.h"
17#include "GaudiKernel/ISvcLocator.h"
18#include "GaudiKernel/Service.h"
19
20#include <string>
21#include <memory>
22
23//================================================================
24
29
30StatusCode PixelClusterContainerCnv_p0::initialize(MsgStream &log ) {
31
32 log << MSG::INFO << "PixelClusterContainerCnv::initialize()" << endmsg;
33
34 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
35 CHECK( detStore.isValid() );
36
37 CHECK( detStore->retrieve(m_pixId, "PixelID") );
38 CHECK( m_pixelDetEleCollKey.initialize() );
39 MSG_DEBUG(log,"Converter initialized.");
40
41 return StatusCode::SUCCESS;
42}
43
44
45
46
47InDet::PixelClusterContainer* PixelClusterContainerCnv_p0::createTransient(PixelClusterContainer_p0* persObj, MsgStream& log) {
48
49 auto trans = std::make_unique<InDet::PixelClusterContainer>(m_pixId->wafer_hash_max()) ;
50 MSG_DEBUG(log,"Read PRD vector, size " << persObj->size());
51
53 const InDetDD::SiDetectorElementCollection* elements(*pixelDetEleHandle);
54 if (not pixelDetEleHandle.isValid() or elements==nullptr) {
55 log << MSG::FATAL << m_pixelDetEleCollKey.fullKey() << " is not available." << endmsg;
56 return trans.release();
57 }
58
59 for (InDet::PixelClusterCollection* dcColl : *persObj) {
60 // Add detElem to each drift circle
61 IdentifierHash collHash = dcColl->identifyHash();
62 const InDetDD::SiDetectorElement * de = elements->getDetectorElement(collHash);
63 MSG_DEBUG(log,"Set PixelCluster detector element to "<< de);
64
65 InDet::PixelClusterCollection::iterator itColl = dcColl->begin();
66 InDet::PixelClusterCollection::iterator lastColl = dcColl->end();
67 for (int num = 0; itColl != lastColl; ++itColl, ++num) {
68 MSG_DEBUG(log,"PRD " << num);
69 (*itColl)->m_detEl = de;
70 }
71 //trans cannot be nullptr at this point
72 StatusCode sc= trans->addCollection(dcColl, collHash);
73 if (sc.isSuccess()){
74 MSG_VERBOSE(log,"PixelClusterContainer successfully added to Container !");
75 } else {
76 log << MSG::ERROR << "Failed to add PixelClusterContainer to container" << endmsg;
77 return nullptr;
78 }
79 }
80 return trans.release();
81}
82
#define endmsg
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t sc
#define MSG_VERBOSE(log, x)
Definition MsgUtil.h:18
#define MSG_DEBUG(log, x)
Definition MsgUtil.h:16
DataVector< Trk::PrepRawDataCollection< InDet::PixelCluster > > PixelClusterContainer_p0
This is an Identifier helper class for the Pixel subdetector.
size_type size() const noexcept
Returns the number of elements in the collection.
This is a "hash" representation of an Identifier.
Class to hold the SiDetectorElement objects to be put in the detector store.
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Class to hold geometrical description of a silicon detector element.
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
virtual InDet::PixelClusterContainer * createTransient(const PixelClusterContainer_p0 *, MsgStream &) override