19#include "CLHEP/Units/SystemOfUnits.h"
35 declareInterface<IDataRetriever>(
this);
58 using PRDTruthIter = PRD_MultiTruthCollection::const_iterator;
68 std::set<int> barcodesFirst;
69 std::set<int> barcodesSecond;
70 std::set<int> barcodesCommon;
73 std::pair<PRDTruthIter,PRDTruthIter> equalRangeFirst = truthColl->equal_range(idFirst);
74 for(PRDTruthIter TruthCollItr=equalRangeFirst.first; TruthCollItr!= equalRangeFirst.second; ++TruthCollItr)
75 barcodesFirst.insert(TruthCollItr->second.barcode());
81 barcodesCommon.swap(barcodesFirst);
87 std::pair<PRDTruthIter,PRDTruthIter> equalRangeSecond = truthColl->equal_range(idSecond);
88 for(PRDTruthIter TruthCollItr=equalRangeSecond.first; TruthCollItr!= equalRangeSecond.second; ++TruthCollItr)
89 barcodesSecond.insert(TruthCollItr->second.barcode());
92 std::set_intersection(barcodesFirst.begin(), barcodesFirst.end(), barcodesSecond.begin(), barcodesSecond.end(),
93 std::insert_iterator< std::set<int> >(barcodesCommon,barcodesCommon.begin()) );
97 for (
const auto barcodeCommon : barcodesCommon) barcodes.push_back(
DataType(barcodeCommon));
100 return barcodesCommon.size();
119 if ( not PixelSPContainer.
isValid() )
125 if ( not PixelPRDTruthColl.
isValid() )
130 if ( not SCTSPContainer.
isValid() )
136 if ( not SCTPRDTruthColl.
isValid() )
143 using SpacePointTruthPair = std::pair<const SpacePointContainer *, const PRD_MultiTruthCollection *>;
144 std::vector<SpacePointTruthPair> SpacePointTruthPairList;
147 if (PixelSPContainer.
isValid())
157 int NSpacePoints = 0;
159 for (
const auto &SPTruthPair : SpacePointTruthPairList) {
162 for (
const auto SpacePoint : *(SPTruthPair.first))
174 DataVect clusters; clusters.reserve(NSpacePoints*2);
175 DataVect phiModule; phiModule.reserve(NSpacePoints);
176 DataVect etaModule; etaModule.reserve(NSpacePoints);
177 DataVect numBarcodes; numBarcodes.reserve(NSpacePoints);
178 DataVect barcodes; barcodes.reserve(NSpacePoints);
185 for (
const auto &SPTruthPair : SpacePointTruthPairList) {
188 for (
const auto SpacePointColl : *(SPTruthPair.first)){
191 for (
const auto SpacePoint : *SpacePointColl) {
197 x.push_back(
DataType(point.x() * CLHEP::mm/CLHEP::cm));
198 y.push_back(
DataType(point.y() * CLHEP::mm/CLHEP::cm));
199 z.push_back(
DataType(point.z() * CLHEP::mm/CLHEP::cm));
202 const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*> clusterList =
SpacePoint->clusterList();
205 Identifier idFirst = clusterList.first->identify();
206 Identifier idSecond = (clusterList.second != NULL) ? clusterList.second->identify() :
Identifier();
210 phiModule.push_back(
DataType(
m_geo->SCTIDHelper()->phi_module(idFirst)));
211 etaModule.push_back(
DataType(
m_geo->SCTIDHelper()->eta_module(idFirst)));
214 phiModule.push_back(
DataType(
m_geo->PixelIDHelper()->phi_module(idFirst)));
215 etaModule.push_back(
DataType(
m_geo->PixelIDHelper()->eta_module(idFirst)));
224 if ( PRDTruthColl ==
nullptr ) continue ;
229 ATH_MSG_VERBOSE(
"Found " << numBarcodes.back() <<
" common barcodes, now "
230 << barcodes.size() <<
" in total" );
238 const auto sz =
x.size();
239 dataMap[
"x"] = std::move(
x);
240 dataMap[
"y"] = std::move(
y);
241 dataMap[
"z"] = std::move(
z);
242 dataMap[
"clusters multiple=\"2\""] = std::move(clusters);
243 dataMap[
"phiModule"] = std::move(phiModule);
244 dataMap[
"etaModule"] = std::move(etaModule);
247 if ( numBarcodes.size() > 0 ){
249 dataMap[
"numBarcodes"] = numBarcodes;
251 std::string bctag =
"barcodes multiple=\""+
DataType(barcodes.size()/
double(numBarcodes.size())).toString()+
"\"";
252 dataMap[bctag] = std::move(barcodes);
258 return FormatTool->AddToEvent(
dataTypeName(),
"", &dataMap);
270 return m_geo.retrieve();
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
defines an "iterator" over instances of a given type in StoreGateSvc
An STL vector of pointers that by default owns its pointed-to elements.
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
Handle class for reading from StoreGate.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool is_valid() const
Check if id is in a valid state.
value_type get_compact() const
Get the compact id.
Templated class to convert any object that is streamable in a ostringstream in a string.
SG::ReadHandleKey< SpacePointContainer > m_PixelSPContainerName
StoreGate key for Pixel space points.
SG::ReadHandleKey< SpacePointContainer > m_SCTSPContainerName
StoreGate key for SCT space points.
SiSpacePointRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
virtual std::string dataTypeName() const
Return the name of the data type.
bool m_usePixelTruthMap
StoreGate key for pixel PRD_MultiTruth.
virtual StatusCode initialize()
Only retrieve geo tool in initialize.
SG::ReadHandleKey< PRD_MultiTruthCollection > m_SCTPRDTruthName
bool m_useSCTTruthMap
StoreGate key for SCT PRD_MultiTruth.
SG::ReadHandleKey< PRD_MultiTruthCollection > m_PixelPRDTruthName
const ToolHandle< IInDetGeoModelTool > m_geo
A tool handle to the geo model tool.
A PRD is mapped onto all contributing particles.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
Eigen::Matrix< double, 3, 1 > Vector3D
unsigned int getTruthBarcodes(const Identifier idFirst, const Identifier idSecond, const PRD_MultiTruthCollection *truthColl, DataVect &barcodes)
Get the barcodes of associated truth particles for a SpacePoint ( we require both clusters,...
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
std::map< std::string, DataVect > DataMap
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())