ATLAS Offline Software
Loading...
Searching...
No Matches
JiveXML::SiSpacePointRetrieverHelpers Namespace Reference

Functions

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, in case there are)

Function Documentation

◆ getTruthBarcodes()

unsigned int JiveXML::SiSpacePointRetrieverHelpers::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, in case there are)

Parameters
idFirstthe SpacePoint identifier of first cluster
idSecondthe SpacePoint identifier of second cluster (only for SCT)
truthCollthe truth collection
barcodesthe date vector to which to append the barcodes
Returns
number of associated truth particles

NOTE: This function could be simplified if we could directly insert into the DataVect, instead of barcodesCommon. At the moment, this doesnt work as we are lacking operator< and operator== for DataType

Definition at line 55 of file SiSpacePointRetriever.cxx.

55 {
56
57 //Make life easier
58 using PRDTruthIter = PRD_MultiTruthCollection::const_iterator;
59
60
66
67 //Sets of barcodes associated with first, second and both cluster
68 std::set<int> barcodesFirst;
69 std::set<int> barcodesSecond;
70 std::set<int> barcodesCommon;
71
72 //Get the set of particle barcodes associated with the first cluster identifier
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());
76
77 //Check if we have only have one valid cluster identifier
78 if (! idSecond.is_valid()){
79
80 //Make this our list of barcodes (swap is O(1))
81 barcodesCommon.swap(barcodesFirst);
82
83 //otherwise only store barcodes associated with both identifiers
84 } else {
85
86 //Get the set of particle barcodes associated with the second cluster identifier
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());
90
91 //Copy the list of particle barcodes that are associated with both clusters
92 std::set_intersection(barcodesFirst.begin(), barcodesFirst.end(), barcodesSecond.begin(), barcodesSecond.end(),
93 std::insert_iterator< std::set<int> >(barcodesCommon,barcodesCommon.begin()) );
94 }
95
96 //Finally add the list of barcodes to our DataVect
97 for (const auto barcodeCommon : barcodesCommon) barcodes.push_back(DataType(barcodeCommon));
98
99 //return the number of added barcodes
100 return barcodesCommon.size();
101 }
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
bool is_valid() const
Check if id is in a valid state.