277 if (element ==
nullptr){
281 std::vector<UnpackedPixelRDO> collectionID =
282 m_pixelRDOTool->getUnpackedPixelRDOs(collection, pixelID, element, ctx);
286 if(collectionID.empty())
return nullptr;
291 std::vector<network> connections(collectionID.size());
295 int collectionSize = collectionID.size();
303 for(
int currentPixel = 0; currentPixel!=collectionSize-1; ++currentPixel) {
305 int row = collectionID.at(currentPixel).ROW;
306 int col = collectionID.at(currentPixel).COL;
308 auto & currentConnection = connections.at(currentPixel);
309 for(
int otherPixel = currentPixel+1; otherPixel!=collectionSize; ++otherPixel) {
310 auto & otherConnection = connections.at(otherPixel);
311 int deltaCol = std::abs(collectionID.at(otherPixel).COL -
col);
312 int deltaRow = std::abs(collectionID.at(otherPixel).ROW -
row);
332 if( (deltaCol+deltaRow) == 1 or (
m_addCorners and deltaCol == 1 and deltaRow == 1) ) {
333 int NC1 = currentConnection.NC;
334 int NC2 = otherConnection.NC;
335 int maxPossible = currentConnection.CON.size() - 1;
336 if ((NC1>maxPossible) or (NC2>maxPossible)){
337 std::string
m=
"attempt to access connection array of dimension 8 at idx "+
std::to_string(currentConnection.NC);
341 currentConnection.CON.at(currentConnection.NC++) = otherPixel;
342 otherConnection.CON.at(otherConnection.NC++) = currentPixel ;
344 if(++NB==maxElements) {
355 for(
int currentPixel=0; currentPixel!=collectionSize; ++currentPixel) {
356 if(collectionID.at(currentPixel).NCL < 0) {
357 collectionID.at(currentPixel).NCL = Ncluster;
365 if(--collectionSize > 1) {
366 for(
int i(1);
i<collectionSize; ++
i ) {
367 UnpackedPixelRDO U = collectionID.at(
i+1);
370 while(collectionID.at(j).NCL > U.NCL) {
371 collectionID.at(j+1)=collectionID.at(j);
374 collectionID.at(j+1)=U;
380 const Identifier elementID = collection.identify();
386 clusterCollection->setIdentifier(elementID);
387 clusterCollection->reserve(Ncluster);
389 std::vector<Identifier> DVid = {collectionID.at(0).ID };
390 std::vector<int> Totg = {collectionID.at(0).TOT};
391 std::vector<int> Lvl1 = {collectionID.at(0).LVL1};
393 int clusterNumber = 0;
396 DVid.reserve(collectionID.back().NCL);
397 Totg.reserve(collectionID.back().NCL);
398 Lvl1.reserve(collectionID.back().NCL);
406 calibData = *calibDataHandle;
412 offlineCalibData = *offlineCalibDataHandle;
415 for(
int i=1;
i<=collectionSize; ++
i) {
416 if(
i!=collectionSize and collectionID.at(
i).NCL==NCL0) {
417 DVid.push_back(collectionID.at(
i).ID );
418 Totg.push_back(collectionID.at(
i).TOT);
419 Lvl1.push_back(collectionID.at(
i).LVL1);
431 makeCluster(DVid, Totg, Lvl1, element, pixelID, ++clusterNumber,
432 false, 0.0, 0.0, calibData, offlineCalibData,ctx);
437 makeCluster(DVid, Totg, Lvl1, element, pixelID, ++clusterNumber,
438 false, 0.0, 0.0, calibData, offlineCalibData,ctx);
441 cluster->setHashAndIndex(clusterCollection->identifyHash(),
442 clusterCollection->size());
443 clusterCollection->push_back(cluster);
446 if (
i!=collectionSize) {
447 NCL0 = collectionID.at(
i).NCL ;
448 DVid.clear(); DVid = {collectionID.at(
i).ID };
449 Totg.clear(); Totg = {collectionID.at(
i).TOT};
450 Lvl1.clear(); Lvl1 = {collectionID.at(
i).LVL1};
455 return clusterCollection;