68 if (
input.regions.empty())
79 LogDebug(
"HGCPatternRecoByCA") <<
"Making Tracksters with CA" << std::endl;
86 bool isRegionalIter = (
input.regions[0].index != -1);
87 std::vector<HGCDoublet::HGCntuplet> foundNtuplets;
88 std::vector<int> seedIndices;
89 std::vector<uint8_t> layer_cluster_usage(
input.layerClusters.size(), 0);
96 input.layerClustersTime,
110 int tracksterId = -1;
113 std::vector<Trackster> tmpTracksters;
114 tmpTracksters.reserve(foundNtuplets.size());
116 for (
auto const &ntuplet : foundNtuplets) {
119 std::set<unsigned int> effective_cluster_idx;
120 std::pair<std::set<unsigned int>::iterator,
bool> retVal;
122 std::vector<float> times;
123 std::vector<float> timeErrors;
125 for (
auto const &doublet : ntuplet) {
126 auto innerCluster =
doublets[doublet].innerClusterId();
127 auto outerCluster =
doublets[doublet].outerClusterId();
129 retVal = effective_cluster_idx.insert(innerCluster);
131 float time =
input.layerClustersTime.get(innerCluster).first;
133 times.push_back(
time);
134 timeErrors.push_back(1. /
pow(
input.layerClustersTime.get(innerCluster).second, 2));
138 retVal = effective_cluster_idx.insert(outerCluster);
140 float time =
input.layerClustersTime.get(outerCluster).first;
142 times.push_back(
time);
143 timeErrors.push_back(1. /
pow(
input.layerClustersTime.get(outerCluster).second, 2));
148 LogDebug(
"HGCPatternRecoByCA") <<
" New doublet " << doublet <<
" for trackster: " <<
result.size()
149 <<
" InnerCl " << innerCluster <<
" " <<
input.layerClusters[innerCluster].x()
150 <<
" " <<
input.layerClusters[innerCluster].y() <<
" "
151 <<
input.layerClusters[innerCluster].z() <<
" OuterCl " << outerCluster <<
" "
152 <<
input.layerClusters[outerCluster].x() <<
" "
153 <<
input.layerClusters[outerCluster].y() <<
" "
154 <<
input.layerClusters[outerCluster].z() <<
" " << tracksterId << std::endl;
157 unsigned showerMinLayerId = 99999;
158 std::vector<unsigned int> uniqueLayerIds;
159 uniqueLayerIds.reserve(effective_cluster_idx.size());
160 std::vector<std::pair<unsigned int, unsigned int>> lcIdAndLayer;
161 lcIdAndLayer.reserve(effective_cluster_idx.size());
162 for (
auto const i : effective_cluster_idx) {
163 auto const &haf =
input.layerClusters[
i].hitsAndFractions();
165 showerMinLayerId =
std::min(layerId, showerMinLayerId);
166 uniqueLayerIds.push_back(layerId);
167 lcIdAndLayer.emplace_back(
i, layerId);
169 std::sort(uniqueLayerIds.begin(), uniqueLayerIds.end());
170 uniqueLayerIds.erase(
std::unique(uniqueLayerIds.begin(), uniqueLayerIds.end()), uniqueLayerIds.end());
171 unsigned int numberOfLayersInTrackster = uniqueLayerIds.size();
173 int numberOfMissingLayers = 0;
174 unsigned int j = showerMinLayerId;
175 unsigned int indexInVec = 0;
176 for (
const auto &layer : uniqueLayerIds) {
178 numberOfMissingLayers++;
181 numberOfLayersInTrackster = indexInVec;
182 for (
auto &llpair : lcIdAndLayer) {
183 if (llpair.second >= layer) {
184 effective_cluster_idx.erase(llpair.first);
198 tmp.vertices().reserve(effective_cluster_idx.size());
199 tmp.vertex_multiplicity().resize(effective_cluster_idx.size(), 1);
202 tmp.setSeed(
input.regions[0].collectionID, seedIndices[tracksterId]);
204 std::pair<float, float> timeTrackster(-99., -1.);
207 tmp.setTimeAndError(timeTrackster.first, timeTrackster.second);
209 tmpTracksters.push_back(
tmp);
223 auto filter_on_pids = [&](
Trackster &
t) ->
bool {
224 auto cumulative_prob = 0.;
226 cumulative_prob +=
t.id_probabilities(
index);
232 std::vector<unsigned int> selectedTrackstersIds;
233 for (
unsigned i = 0;
i < tmpTracksters.size(); ++
i) {
235 selectedTrackstersIds.push_back(
i);
239 result.reserve(selectedTrackstersIds.size());
241 for (
unsigned i = 0;
i < selectedTrackstersIds.size(); ++
i) {
242 const auto &
t = tmpTracksters[selectedTrackstersIds[
i]];
243 for (
auto const lcId :
t.vertices()) {
244 layer_cluster_usage[lcId]++;
246 LogDebug(
"HGCPatternRecoByCA") <<
"LayerID: " << lcId <<
" count: " << (
int)layer_cluster_usage[lcId]
249 if (isRegionalIter) {
250 seedToTracksterAssociation[
t.seedIndex()].push_back(
i);
255 for (
auto &trackster :
result) {
256 assert(trackster.vertices().size() <= trackster.vertex_multiplicity().size());
257 for (
size_t i = 0;
i < trackster.vertices().size(); ++
i) {
258 trackster.vertex_multiplicity()[
i] = layer_cluster_usage[trackster.vertices(
i)];
260 LogDebug(
"HGCPatternRecoByCA") <<
"LayerID: " << trackster.vertices(
i)
261 <<
" count: " << (
int)trackster.vertex_multiplicity(
i) << std::endl;
266 std::vector<Trackster>
tmp;
282 for (
auto &trackster :
result) {
283 LogDebug(
"HGCPatternRecoByCA") <<
"Trackster characteristics: " << std::endl;
284 LogDebug(
"HGCPatternRecoByCA") <<
"Size: " << trackster.vertices().size() << std::endl;
286 for (
auto const &
p : trackster.id_probabilities()) {