ATLAS Offline Software
TrigSiSpacePointRetriever.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <string>
8 
9 #include "CLHEP/Units/SystemOfUnits.h"
10 
13 #include "InDetIdentifier/SCT_ID.h"
15 
16 namespace JiveXML {
17 
18  //--------------------------------------------------------------------------
19 
20  TrigSiSpacePointRetriever::TrigSiSpacePointRetriever(const std::string& type, const std::string& name, const IInterface* parent):
22  m_typeName("TrigS3D"),
23  m_pixelHelper(nullptr),
24  m_sctHelper(nullptr),
25  m_pixelSpContainerName ("TrigPixelSpacePoints"),
26  m_SCT_SpContainerName ("TrigSCT_SpacePoints")
27  {
28 
29  declareInterface<IDataRetriever>(this);
30 
31  declareProperty("PixelSpacePoints", m_pixelSpContainerName);
32  declareProperty("SCTSpacePoints" , m_SCT_SpContainerName);
33  }
34 
35  //--------------------------------------------------------------------------
36 
37  StatusCode TrigSiSpacePointRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
38 
39  const TrigSiSpacePointContainer* pCont;
40 
41  DataVect x;
42  DataVect y;
43  DataVect z;
44  DataVect layer;
45  DataVect clustersVec;
46  std::string clustersStr = "clusters multiple=\"2\"";
47 
48  if ( evtStore()->retrieve(pCont,m_pixelSpContainerName).isFailure() ) {
49  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Trig SP Pixel container not found at "
51 // return StatusCode::SUCCESS; // not exit here (as in original code)
52  }else{
53  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Retrieving TrigSPPixel with size "
54  << pCont->size() << " from " << m_pixelSpContainerName << endmsg;
55 
56  int maxHash = m_pixelHelper->wafer_hash_max();
57  for(int id=0;id<maxHash;++id){
58  auto spCollIt=pCont->indexFindPtr(id);
59  if(spCollIt==nullptr) continue;
60  for(TrigSiSpacePointCollection::const_iterator spIt=spCollIt->begin(); spIt!=spCollIt->end();++spIt){
61  x.push_back(DataType((*spIt)->x() /10.));
62  y.push_back(DataType((*spIt)->y() /10.));
63  z.push_back(DataType((*spIt)->z() /10.));
64  layer.push_back( DataType( calcPixelLayer( (*spIt)->identify() ) ) );
65  clustersVec.push_back(DataType(((*spIt)->clusters()).first->identify().get_compact()));
66  clustersVec.push_back(DataType(-1));
67  }
68  }
69  }
70  if ( evtStore()->retrieve(pCont,m_SCT_SpContainerName).isFailure() ) {
71  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Trig SP Pixel container not found at "
73 // return StatusCode::SUCCESS; // not exit here (as in original code)
74  }else{
75  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Retrieving TrigSPPixel with size "
76  << pCont->size() << " from " << m_SCT_SpContainerName << endmsg;
77 
78  int maxHash = m_sctHelper->wafer_hash_max();
79  for(int id=0;id<maxHash;++id){
80  auto spCollIt=pCont->indexFindPtr(id);
81  if(spCollIt==nullptr) continue;
82  for(TrigSiSpacePointCollection::const_iterator spIt=spCollIt->begin(); spIt!=spCollIt->end();++spIt){
83  x.push_back(DataType((*spIt)->x() /10.));
84  y.push_back(DataType((*spIt)->y() /10.));
85  z.push_back(DataType((*spIt)->z() /10.));
86  layer.push_back( DataType( calcSCTLayer( (*spIt)->identify() ) ) );
87  clustersVec.push_back(DataType(((*spIt)->clusters()).first->identify().get_compact()));
88  clustersVec.push_back(DataType(((*spIt)->clusters()).second->identify().get_compact()));
89  }
90  }
91  }
92  DataMap myDataMap;
93  myDataMap["x"] = x;
94  myDataMap["y"] = y;
95  myDataMap["z"] = z;
96  myDataMap["layer"] = layer;
97  myDataMap[clustersStr] = clustersVec;
98 
99  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << dataTypeName() << ": "<< x.size() << endmsg;
100 
101  //forward data to formating tool
102  std::string emptyStr="";
103  return FormatTool->AddToEvent(dataTypeName(), emptyStr, &myDataMap);
104  }
105  //--------------------------------------------------------------------------
106 
108 
109 //migration: https://twiki.cern.ch/twiki/bin/view/Atlas/InDetPkgFixing
110  if ( detStore()->retrieve(m_pixelHelper, "PixelID").isFailure() ){
111  if (msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Could not get Pixel ID helper" << endmsg;
112  return StatusCode::RECOVERABLE;
113  }
114 
115  if ( detStore()->retrieve(m_sctHelper, "SCT_ID").isFailure() ){
116  if (msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "Could not get SCT ID helper" << endmsg;
117  return StatusCode::RECOVERABLE;
118  }
119 
120  return StatusCode::SUCCESS;
121  }
122 
123  //--------------------------------------------------------------------------
124 
126  {
127  int layer = m_pixelHelper->layer_disk( id );
128  if ( m_pixelHelper->barrel_ec( id ) ) layer += 3;
129  // Endcap Pixels 3,4,5
130  return layer;
131  }
132 
133  //--------------------------------------------------------------------------
134 
136  {
137  int layer = m_sctHelper->layer_disk( id );
138  if ( m_sctHelper->barrel_ec( id ) ) layer += 11;
139  // Endcap SCT 11,12,13,14,15,16,17,18,19
140  else layer += 7;
141  // Barrel SCT 7,8,9,10
142  return layer;
143  }
144 
145  //--------------------------------------------------------------------------
146 }
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
JiveXML::TrigSiSpacePointRetriever::initialize
virtual StatusCode initialize()
Definition: TrigSiSpacePointRetriever.cxx:107
JiveXML::TrigSiSpacePointRetriever::calcSCTLayer
int calcSCTLayer(const Identifier &)
Definition: TrigSiSpacePointRetriever.cxx:135
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JiveXML::TrigSiSpacePointRetriever::m_sctHelper
const SCT_ID * m_sctHelper
Definition: TrigSiSpacePointRetriever.h:45
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition: DataType.h:58
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition: IdentifiableContainerMT.h:209
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
TrigSiSpacePoint.h
JiveXML::TrigSiSpacePointRetriever::calcPixelLayer
int calcPixelLayer(const Identifier &)
Definition: TrigSiSpacePointRetriever.cxx:125
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition: DataType.h:59
x
#define x
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
JiveXML::TrigSiSpacePointRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition: TrigSiSpacePointRetriever.h:32
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
JiveXML::TrigSiSpacePointRetriever::m_pixelHelper
const PixelID * m_pixelHelper
Definition: TrigSiSpacePointRetriever.h:44
z
#define z
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
test_pyathena.parent
parent
Definition: test_pyathena.py:15
JiveXML::TrigSiSpacePointRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition: TrigSiSpacePointRetriever.cxx:37
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition: BadLArRetriever.cxx:21
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:191
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
SCT_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: SCT_ID.cxx:639
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
JiveXML::TrigSiSpacePointRetriever::m_SCT_SpContainerName
std::string m_SCT_SpContainerName
Definition: TrigSiSpacePointRetriever.h:48
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:912
JiveXML::TrigSiSpacePointRetriever::TrigSiSpacePointRetriever
TrigSiSpacePointRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition: TrigSiSpacePointRetriever.cxx:20
IdentifiableContainerMT::indexFindPtr
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
Definition: IdentifiableContainerMT.h:292
y
#define y
Trk::PrepRawDataContainer
Definition: PrepRawDataContainer.h:26
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
JiveXML::TrigSiSpacePointRetriever::m_pixelSpContainerName
std::string m_pixelSpContainerName
Definition: TrigSiSpacePointRetriever.h:47
TrigSiSpacePointCollection.h
TrigSiSpacePointRetriever.h
AthAlgTool
Definition: AthAlgTool.h:26