27 #include <unordered_set>
36 const std::string &
name,
37 const IInterface *
parent) :
48 return StatusCode::SUCCESS;
55 ATH_MSG_DEBUG(
"------------------- Clusterization Statistics ------------------------");
57 ATH_MSG_DEBUG(
"----------------------------------------------------------------------");
58 return StatusCode::SUCCESS;
75 const std::vector<int>& totgroup,
76 const std::vector<int>& lvl1group,
85 const EventContext& ctx)
const
93 throw std::runtime_error(
"Wrong design at MergedPixelsTool");
95 int rowMin =
int(2*(design->width()/design->phiPitch()))+1;
97 int colMin =
int(2*(design->length()/design->etaPitch()))+1;
99 int qRowMin = 0;
int qRowMax = 0;
100 int qColMin = 0;
int qColMax = 0;
104 std::vector<Identifier> DVid;
105 DVid.reserve(
group.size() );
106 std::vector<Identifier>::const_iterator rdosBegin =
group.begin();
107 std::vector<Identifier>::const_iterator rdosEnd =
group.end();
108 std::vector<int>::const_iterator tot = totgroup.begin();
109 std::vector<int>::const_iterator lvl1= lvl1group.begin();
112 bool hasGanged =
false;
113 for (; rdosBegin!= rdosEnd; ++rdosBegin) {
116 if ( (*lvl1) < lvl1min ) lvl1min=(*lvl1);
124 hasGanged = hasGanged ||
128 (design->positionFromColumnRow(
col,
row));
129 sumOfPositions += siLocalPosition;
134 if (
row == rowMin) qRowMin += realtot;
140 if (
row == rowMax) qRowMax += realtot;
146 if (
col == colMin) qColMin += realtot;
152 if (
col == colMax) qColMax += realtot;
160 const int numberOfPixels =
group.size();
164 const int colWidth = colMax-colMin+1;
165 const int rowWidth = rowMax-rowMin+1;
171 if(qRowMin+qRowMax > 0) etaRow = qRowMax/
float(qRowMin+qRowMax);
172 if(qColMin+qColMax > 0) etaCol = qColMax/
float(qColMin+qColMax);
174 double etaWidth = design->widthFromColumnRange(colMin, colMax);
175 double phiWidth = design->widthFromRowRange(rowMin, rowMax);
180 if(
m_posStrategy == 1 && !hasGanged && etaRow>0 && etaCol > 0){
193 const float sensorThickness = element->
thickness();
198 deltay = sensorThickness*std::abs(globalPos.z())/globalPos.perp();
199 if(deltay > (design->etaPitch()) ) deltay = design->etaPitch();
208 centroid = 0.25*(pos1+pos2+pos3+pos4)+
210 ATH_MSG_VERBOSE(
"Barrel cluster with global position r= " << globalPos.perp() <<
" and z = " << globalPos.z());
214 if(
m_posStrategy == 10 && !hasGanged && etaRow>0 && etaCol > 0){
218 ATH_MSG_ERROR(
"Detected position strategy = 10, this is an obsolete setting for CTB analysis and is not supported anymore since Athena 15.4.0");
219 ATH_MSG_ERROR(
"...reverting to default setting: position strategy = 0");
224 if(
m_posStrategy == 20 && !hasGanged && etaRow>0 && etaCol > 0){
229 design->positionFromColumnRow(colMin,rowMin);
231 design->positionFromColumnRow(colMax,rowMin);
233 design->positionFromColumnRow(colMin,rowMax);
235 design->positionFromColumnRow(colMax,rowMax);
236 centroid = 0.25*(pos1+pos2+pos3+pos4)+
238 deltax*(etaRow-0.5),0.);
246 <<
" x " << rowWidth);
250 << (position)[0] <<
" "
254 return PixelCluster(
id, position, std::move(DVid), lvl1min,
255 std::vector<int>(totgroup), siWidth, element,
259 id, position, std::move(DVid), lvl1min, std::vector<int>(totgroup),
261 splitProb1, splitProb2, calibData, offlineCalibData,ctx);
274 const EventContext& ctx)
const {
277 if (element ==
nullptr){
281 std::vector<UnpackedPixelRDO> collectionID =
282 m_pixelRDOTool->getUnpackedPixelRDOs(collection, pixelID, element, ctx);
286 if(collectionID.empty())
return nullptr;
287 if(collectionID.size() > 1) std::sort(collectionID.begin(),collectionID.end(),
pixel_less);
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 ) {
370 while(collectionID.at(j).NCL > U.
NCL) {
371 collectionID.at(j+1)=collectionID.at(j);
374 collectionID.at(j+1)=U;
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);
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;
460 const std::vector<network>& connections,
461 std::vector<UnpackedPixelRDO>& collectionID)
const {
462 for(
int i=0;
i!=connections.at(
r).
NC; ++
i) {
463 const int k = connections.at(
r).CON.at(
i);
464 if(collectionID.at(
k).NCL < 0) {
465 collectionID.at(
k).NCL = Ncluster;