18#include "CLHEP/Units/SystemOfUnits.h"
34 declareInterface<IDataRetriever>(
this);
57 using PRDTruthIter = PRD_MultiTruthCollection::const_iterator;
67 std::set<int> barcodesFirst;
68 std::set<int> barcodesSecond;
69 std::set<int> barcodesCommon;
72 std::pair<PRDTruthIter,PRDTruthIter> equalRangeFirst = truthColl->equal_range(idFirst);
73 for(PRDTruthIter TruthCollItr=equalRangeFirst.first; TruthCollItr!= equalRangeFirst.second; ++TruthCollItr)
74 barcodesFirst.insert(TruthCollItr->second.barcode());
80 barcodesCommon.swap(barcodesFirst);
86 std::pair<PRDTruthIter,PRDTruthIter> equalRangeSecond = truthColl->equal_range(idSecond);
87 for(PRDTruthIter TruthCollItr=equalRangeSecond.first; TruthCollItr!= equalRangeSecond.second; ++TruthCollItr)
88 barcodesSecond.insert(TruthCollItr->second.barcode());
91 std::set_intersection(barcodesFirst.begin(), barcodesFirst.end(), barcodesSecond.begin(), barcodesSecond.end(),
92 std::insert_iterator< std::set<int> >(barcodesCommon,barcodesCommon.begin()) );
96 for (
const auto barcodeCommon : barcodesCommon) barcodes.push_back(
DataType(barcodeCommon));
99 return barcodesCommon.size();
118 if ( not PixelSPContainer.
isValid() )
124 if ( not PixelPRDTruthColl.
isValid() )
129 if ( not SCTSPContainer.
isValid() )
135 if ( not SCTPRDTruthColl.
isValid() )
142 using SpacePointTruthPair = std::pair<const SpacePointContainer *, const PRD_MultiTruthCollection *>;
143 std::vector<SpacePointTruthPair> SpacePointTruthPairList;
146 if (PixelSPContainer.
isValid())
156 int NSpacePoints = 0;
158 for (
const auto &SPTruthPair : SpacePointTruthPairList) {
161 for (
const auto SpacePoint : *(SPTruthPair.first))
162 NSpacePoints += SpacePoint->size();
173 DataVect clusters; clusters.reserve(NSpacePoints*2);
174 DataVect phiModule; phiModule.reserve(NSpacePoints);
175 DataVect etaModule; etaModule.reserve(NSpacePoints);
176 DataVect numBarcodes; numBarcodes.reserve(NSpacePoints);
177 DataVect barcodes; barcodes.reserve(NSpacePoints);
184 for (
const auto &SPTruthPair : SpacePointTruthPairList) {
187 for (
const auto SpacePointColl : *(SPTruthPair.first)){
190 for (
const auto SpacePoint : *SpacePointColl) {
196 x.push_back(
DataType(point.x() * CLHEP::mm/CLHEP::cm));
197 y.push_back(
DataType(point.y() * CLHEP::mm/CLHEP::cm));
198 z.push_back(
DataType(point.z() * CLHEP::mm/CLHEP::cm));
201 const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*> clusterList = SpacePoint->clusterList();
204 Identifier idFirst = clusterList.first->identify();
205 Identifier idSecond = (clusterList.second != NULL) ? clusterList.second->identify() :
Identifier();
209 phiModule.push_back(
DataType(
m_geo->SCTIDHelper()->phi_module(idFirst)));
210 etaModule.push_back(
DataType(
m_geo->SCTIDHelper()->eta_module(idFirst)));
213 phiModule.push_back(
DataType(
m_geo->PixelIDHelper()->phi_module(idFirst)));
214 etaModule.push_back(
DataType(
m_geo->PixelIDHelper()->eta_module(idFirst)));
223 if ( PRDTruthColl ==
nullptr ) continue ;
228 ATH_MSG_VERBOSE(
"Found " << numBarcodes.back() <<
" common barcodes, now "
229 << barcodes.size() <<
" in total" );
237 const auto sz =
x.size();
238 dataMap[
"x"] = std::move(
x);
239 dataMap[
"y"] = std::move(
y);
240 dataMap[
"z"] = std::move(
z);
241 dataMap[
"clusters multiple=\"2\""] = std::move(clusters);
242 dataMap[
"phiModule"] = std::move(phiModule);
243 dataMap[
"etaModule"] = std::move(etaModule);
246 if ( numBarcodes.size() > 0 ){
248 dataMap[
"numBarcodes"] = numBarcodes;
250 std::string bctag =
"barcodes multiple=\""+
DataType(barcodes.size()/
double(numBarcodes.size())).toString()+
"\"";
251 dataMap[bctag] = std::move(barcodes);
257 return FormatTool->AddToEvent(
dataTypeName(),
"", &dataMap);
269 return m_geo.retrieve();
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
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.
ConstVectorMap globalPosition() const
Returns the global position of the pixel cluster.
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())