ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
32
33StatusCode PixelClusterContainerCnv_p0::initialize(MsgStream &log ) {
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") );
41 CHECK( m_pixelDetEleCollKey.initialize() );
42 MSG_DEBUG(log,"Converter initialized.");
43
44 return StatusCode::SUCCESS;
45}
46
47
48
49
50InDet::PixelClusterContainer* PixelClusterContainerCnv_p0::createTransient(PixelClusterContainer_p0* persObj, MsgStream& log) {
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
#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:17
#define MSG_DEBUG(log, x)
Definition MsgUtil.h:15
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