ATLAS Offline Software
Loading...
Searching...
No Matches
SegmentRetriever.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
10
11#include "JiveXML/DataType.h"
12
13namespace JiveXML {
14
21 SegmentRetriever::SegmentRetriever(const std::string& type,const std::string& name,const IInterface* parent):
22 AthAlgTool(type,name,parent){}
23
24
26 ATH_CHECK(m_keys.initialize());
27 return StatusCode::SUCCESS;
28 }
29
30
38 StatusCode SegmentRetriever::retrieve(ToolHandle<IFormatTool> &FormatTool) {
39
40 ATH_MSG_DEBUG("Retrieving " << dataTypeName());
41
42 for( const auto& key : m_keys ) {
44 if (cont.isValid()) {
45
46 //Get number of segments in this collection
47 Trk::SegmentCollection::size_type NSegs=cont.cptr()->size();
48
49 //Define the data vectors we want to fill and create space
50 DataVect x; x.reserve(NSegs);
51 DataVect y; y.reserve(NSegs);
52 DataVect z; z.reserve(NSegs);
53 DataVect phi; phi.reserve(NSegs);
54 DataVect theta; theta.reserve(NSegs);
55 DataVect numHits; numHits.reserve(NSegs);
56 DataVect hits;
57
58 //Loop over the segments
60 for (SegmentItr=cont.cptr()->begin(); SegmentItr!=cont.cptr()->end(); ++SegmentItr) {
61
62 //Retrieve primitive variables
63 x.emplace_back((*SegmentItr)->globalPosition().x()/10.);
64 y.emplace_back((*SegmentItr)->globalPosition().y()/10.);
65 z.emplace_back((*SegmentItr)->globalPosition().z()/10.);
66 phi.emplace_back((*SegmentItr)->localParameters()[Trk::phi]);
67 theta.emplace_back((*SegmentItr)->localParameters()[Trk::theta]);
68
69 //Count number of valid (non-null) RIO_OnTracks
70 int NRoTs = 0;
71 //Reserve space for expected number
72 hits.reserve(hits.size()+(*SegmentItr)->containedMeasurements().size());
73
74 //Loop over segment measurments
75 std::vector< const Trk::MeasurementBase * >::const_iterator measItr, measEnd;
76 measItr=(*SegmentItr)->containedMeasurements().begin();
77 measEnd=(*SegmentItr)->containedMeasurements().end();
78
79 //Now loop over measurements
80 for (; measItr!=measEnd; ++measItr) {
81
82 //dynamic_cast to RIO_OnTrack - will return NULL if not a RIO_OnTrack object
83 const Trk::RIO_OnTrack *RoT = dynamic_cast<const Trk::RIO_OnTrack*>(*measItr);
84
85 //Ignore failed dynamic_casts
86 if (!RoT) continue ;
87
88 //Add the hit
89 hits.emplace_back(RoT->identify().get_compact() );
90 //count as valid
91 NRoTs++;
92 }
93
94 //Store number of hits for this segement
95 numHits.emplace_back(NRoTs);
96 }
97
98 //Add data to our map
100 DataMap["x"] = x;
101 DataMap["y"] = y;
102 DataMap["z"] = z;
103 DataMap["phi"] = phi;
104 DataMap["theta"] = theta;
105 DataMap["numHits"] = numHits;
106
107 //Hits are stored as multiple with average size given in XML header
108 if (NSegs > 0) {
109 std::string multiple = "hits multiple=\"" + DataType( hits.size()*1./numHits.size()).toString() + "\"";
110 DataMap[multiple] = hits;
111 }
112
113 //forward data to formating tool
114 if ( FormatTool->AddToEvent(dataTypeName(), key.key(), &DataMap).isFailure())
115 return StatusCode::RECOVERABLE;
116
117 ATH_MSG_DEBUG(dataTypeName() << " collection " << key << " retrieved with " << NSegs << " entries");
118
119 }
120 else{
121 ATH_MSG_WARNING("Collection " << key << " not found in SG ");
122 }
123 }
124
125 //All collections retrieved - done
126 return StatusCode::SUCCESS;
127
128 } // retrieve
129} //namespace
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
#define y
#define x
#define z
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
typename DataVectorBase< Trk::Segment >::Base::size_type size_type
Definition DataVector.h:814
value_type get_compact() const
Get the compact id.
SegmentRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
SG::ReadHandleKeyArray< Trk::SegmentCollection > m_keys
virtual StatusCode initialize()
virtual std::string dataTypeName() const
Return the name of the data type.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
Identifier identify() const
return the identifier -extends MeasurementBase
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
std::map< std::string, DataVect > DataMap
Definition DataType.h:59
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition DataType.h:58
@ theta
Definition ParamDefs.h:66
@ phi
Definition ParamDefs.h:75