49std::vector<LVL1::EFexEMClusterTool::AlgResult>
55 std::vector<AlgResult> baselineClusters;
56 for (
auto & cluster :
looseAlg(scells, TTs, idHelper, tileIDHelper, tileCellCon) ) {
74 bool passBaseLineSelection = cluster.passClusterEnergy &&
79 if (applyBaselineCuts and not passBaseLineSelection ) {
83 baselineClusters.push_back(cluster);
85 return baselineClusters;
88std::vector<LVL1::EFexEMClusterTool::AlgResult>
93 std::vector<AlgResult>
result;
95 std::vector<const CaloCell*> potentialCentres;
96 for (
auto ithCell : *SCs) {
101 if (idHelper->
sampling(ithID) != 2) {
105 if (idHelper->
sub_calo(ithID) != 0) {
109 bool inEfexCoverage =
false;
110 if ( std::abs(idHelper->
pos_neg(ithID)) < 3) {
111 inEfexCoverage =
true;
114 if (!inEfexCoverage) {
119 potentialCentres.push_back(ithCell);
124 for (
auto ithCell : potentialCentres){
126 for (
auto jthCell : potentialCentres){
127 if (jthCell == ithCell)
continue;
128 if (!
SameTT(ithCell, jthCell, idHelper))
continue;
131 if (ithEt > jthEt)
continue;
132 if (ithEt == jthEt && ithCell->eta() > jthCell->eta())
continue;
142 float ithEta = ithCell->eta();
143 float ithPhi = ithCell->phi();
149 ithRHad =
RHadTile(ithCell,
m_etaEMWidth_RHadIsolation,
m_phiEMWidth_RHadIsolation, SCs, idHelper,
m_nominalDigitization,
m_nominalNoise_thresh, tileIDHelper, tileCellCon,
m_tileNoise_tresh, HadET);
157 float ithREtaL12{-1};
163 result.push_back(
AlgResult{ithEta, ithPhi, clustET, ithREta, ithRHad, ithL1Width, HadET, L2ClusterET33, L2ClusterET37, ithREtaL12});
176 if (inputCell==
nullptr)
return 0.;
180 if (!correctProv)
return 0.;
183 float inputCell_energy = inputCell->
energy();
184 float inputCell_eta = inputCell->
eta();
185 float inputCell_ET = inputCell_energy / cosh(inputCell_eta);
187 bool allowNegs =
false;
188 if (digitScale < 0.){
189 digitScale = std::abs(digitScale);
192 if (inputCell_ET==0)
return 0.;
193 else if (digitScale==0)
return inputCell_ET;
194 if (allowNegs || inputCell_ET>0.){
196 float posOrNeg = inputCell_ET / std::abs(inputCell_ET);
197 inputCell_ET = std::abs(inputCell_ET);
199 if (digitScale == 0){
200 if (inputCell_ET>digitThreshold)
return inputCell_ET*posOrNeg;
205 float divET = inputCell_ET / digitScale;
207 float result = digitScale * roundET;
208 if (digitThreshold == 0)
return result*posOrNeg;
209 else if (
result >= digitThreshold)
return result*posOrNeg;
220 int phi1 = idHelper->
phi(ID1);
222 int phi2 = idHelper->
phi(ID2);
226 int pn1 = idHelper->
pos_neg(ID1);
227 int pn2 = idHelper->
pos_neg(ID2);
233 int reg1 = idHelper->
region(ID1);
234 int reg2 = idHelper->
region(ID2);
238 int etaDiv1 = idHelper->
eta(ID1)/4;
239 int etaDiv2 = idHelper->
eta(ID2)/4;
240 if (etaDiv1 == etaDiv2) {
248 else if (abs(pn1)==2){
249 int reg1 = idHelper->
region(ID1);
250 int reg2 = idHelper->
region(ID2);
251 int eta1 = idHelper->
eta(ID1);
252 int eta2 = idHelper->
eta(ID2);
253 if ((reg1 == 0 && reg2 == 1 && eta2 < 3 ) || (reg2 == 0 && reg1 == 1 && eta1 < 3 ))
return true;
255 if (reg1 != reg2)
return false;
256 int etaDiv1 = (idHelper->
eta(ID1) - 3)/4;
257 int etaDiv2 = (idHelper->
eta(ID2) - 3)/4;
258 if (etaDiv1 == etaDiv2)
return true;
269 return localMax(inputContainer, inputCell, 0, idHelper, digitScale, digitThreshold);
276 if (inputCell ==
nullptr)
return false;
279 const int sub_calo = idHelper->
sub_calo(inputID);
280 const int pos_neg = idHelper->
pos_neg(inputID);
281 if (!(sub_calo == 0 || sub_calo == 1) || !(abs(pos_neg) < 4)){
285 double seedCandidateEnergy =
CaloCellET(inputCell, digitScale, digitThreshold);
286 int nCellsMoreEnergetic = 0;
288 if (leftCell !=
nullptr){
289 double leftEnergy =
CaloCellET(leftCell, digitScale, 0.);
290 if (leftEnergy>seedCandidateEnergy) nCellsMoreEnergetic++;
293 if (rightCell !=
nullptr){
294 double rightEnergy =
CaloCellET(rightCell, digitScale, 0.);
295 if (rightEnergy>=seedCandidateEnergy) nCellsMoreEnergetic++;
298 if (upCell !=
nullptr){
299 double upEnergy =
CaloCellET(upCell, digitScale, 0.);
300 if (upEnergy>=seedCandidateEnergy) nCellsMoreEnergetic++;
303 if (downCell !=
nullptr){
304 double downEnergy =
CaloCellET(downCell, digitScale, 0.);
305 if (downEnergy>seedCandidateEnergy) nCellsMoreEnergetic++;
307 if (upCell !=
nullptr){
309 if (upRightCell !=
nullptr){
310 double upRightEnergy =
CaloCellET(upRightCell, digitScale, 0.);
311 if (upRightEnergy>=seedCandidateEnergy) nCellsMoreEnergetic++;
314 if (upLeftCell !=
nullptr){
315 double upLeftEnergy =
CaloCellET(upLeftCell, digitScale, 0.);
316 if (upLeftEnergy>=seedCandidateEnergy) nCellsMoreEnergetic++;
319 if (downCell !=
nullptr){
321 if (downRightCell !=
nullptr){
322 double downRightEnergy =
CaloCellET(downRightCell, digitScale, 0.);
323 if (downRightEnergy>seedCandidateEnergy) nCellsMoreEnergetic++;
326 if (downLeftCell !=
nullptr){
327 double downLeftEnergy =
CaloCellET(downLeftCell, digitScale, 0.);
328 if (downLeftEnergy>seedCandidateEnergy) nCellsMoreEnergetic++;
332 if (nCellsMoreEnergetic <= numOthers)
return true;
339 if (inputCell==
nullptr)
return;
340 bool alreadyThere =
false;
341 for (
auto oCell : outputVector){
343 else if (inputCell->
ID() == oCell->ID()) alreadyThere=
true;
345 if (!alreadyThere) outputVector.push_back(inputCell);
353 std::vector<const CaloCell*> fullClus =
TDR_Clus(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale,digitThresh);
354 double EMcomp =
sumVectorET(fullClus, digitScale, digitThresh);
355 bool EMcheck =
checkDig(EMcomp, digitScale, digitThresh);
356 if (!EMcheck)
ATH_MSG_WARNING (
"EMcomp not digitised " << EMcomp <<
" " << digitScale <<
" " << digitThresh);
357 double total = EMcomp;
366 if (etaWidth1 > etaWidth2)
ATH_MSG_WARNING (
"REta: eta1 = " << etaWidth1 <<
", eta2 = " << etaWidth2);
367 if (phiWidth1 > phiWidth2)
ATH_MSG_WARNING (
"Rphi: phi1 = " << phiWidth1 <<
", phi2 = " << phiWidth2);
369 double inner_ET =
L2clusET(centreCell, etaWidth1, phiWidth1, scells, idHelper, digitScale, digitThresh);
370 double outer_ET =
L2clusET(centreCell, etaWidth2, phiWidth2, scells, idHelper, digitScale, digitThresh);
373 if (inner_ET != 0. && outer_ET==0.) normal_REta = 0.;
374 else if (inner_ET==0.) normal_REta = 0.;
375 else normal_REta = inner_ET / outer_ET;
376 if (normal_REta < 0) normal_REta = 0.;
377 double my_REta = 1-normal_REta;
385 std::vector<const CaloCell*> fullClus =
TDR_Clus(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale, digitThresh);
386 double EMcomp =
sumVectorET(fullClus, digitScale, digitThresh);
387 double HCALcomp =
HadronicET(
L2cluster(centreCell,
m_etaHadWidth_RHadIsolation,
m_phiHadWidth_RHadIsolation, scells, idHelper, digitScale, digitThresh), scells, TTContainer, idHelper, digitScale, digitThresh);
388 HadET = HCALcomp/1e3;
389 double result = HCALcomp/(EMcomp+HCALcomp);
390 if (result < 0. || result > 1.){
392 ATH_MSG_WARNING (
"fullClus count = " << fullClus.size() <<
", EMcomp = " << EMcomp <<
", HCALcomp = " << HCALcomp);
400 for (
auto ithCell : tileCellVector){
401 if (ithCell->ID() == inputCell->
ID()) isAlreadyThere =
true;
403 if (!isAlreadyThere) tileCellVector.push_back(inputCell);
409 if (eIn <= 0)
return 0.;
410 float eOut = eIn/cosh(etaIn);
411 if (tileNoiseThresh == 0.)
return eOut;
413 if (eOut > tileNoiseThresh)
return eOut;
421 float pos_neg = inEta/std::abs(inEta);
426 if (((
int)(std::abs(inEta)*10)) % 2 == 0) isEven =
true;
429 if (inEta < 0.1) inPos = 0;
430 else if (inEta > 0.8 && inEta < 0.9) inPos = 2;
432 if (isEven) inPos = 0;
438 if (inEta > -0.1) inPos = 1;
439 else if (inEta > -0.9 && inEta < -0.8) inPos = 2;
441 if (isEven) inPos = 1;
453 std::vector<const CaloCell*> L2cells =
L2cluster(centreCell, etaWidth, phiWidth, scells, idHelper,digitScale, digitThresh);
459 float oldPhi = centreCell->
phi();
461 std::vector<int> offsets;
462 std::vector<const CaloCell*> frontLayerCells;
463 for (
auto ithL2Cell : L2cells){
465 unsigned int oldsize = frontLayerCells.size();
469 unsigned int additions = frontLayerCells.size() - oldsize;
471 float dPhi = std::abs(ithL2Cell->phi() - oldPhi);
472 if (dPhi >
M_PI) dPhi = 2*
M_PI - dPhi;
475 oldPhi = ithL2Cell->phi();
478 int sign = (ithL2Cell->eta()-centreCell->
eta() > 0 ? 1 : -1);
480 for (
unsigned int adds = 0; adds < additions; ++adds) offsets.push_back(
sign*((
counter+1)/2));
485 float sumET = 0, sumET_Eta2=0;
486 unsigned int cellCount = 0;
488 for (std::vector<const CaloCell*>::iterator ithCell = frontLayerCells.begin(); ithCell != frontLayerCells.end(); ++ithCell){
491 int offset = (cellCount < offsets.size() ? offsets[cellCount] : -999);
492 if (offset < -2 || offset > 2) {
499 int pos_neg = idHelper->
pos_neg(cellID);
500 int region = idHelper->
region(cellID);
501 int eta_index = idHelper->
eta(cellID);
502 bool halfCell =
false;
503 if (abs(pos_neg) == 2 && region == 3 && (eta_index == 1 || eta_index == 4 || eta_index == 7 || eta_index == 10)) halfCell =
true;
506 float ithET =
CaloCellET((*ithCell), digitScale, digitThresh);
511 sumET_Eta2 += 0.5*ithET*pow(offset,2);
515 if ((
int)cellCount-1 >= 0 && offsets[cellCount-1] == offset) {
516 auto ithPrev = std::prev(ithCell,1);
517 int sign = ((*ithCell)->eta() > (*ithPrev)->eta() ? 1 : -1);
518 int nextOffset = offset+
sign;
519 if (abs(nextOffset) <= 2) sumET_Eta2 += 0.5*ithET*pow(nextOffset,2);
523 else if (cellCount+1 < offsets.size() && offsets[cellCount+1] == offset) {
524 auto ithNext = std::next(ithCell,1);
525 int sign = ((*ithCell)->eta() > (*ithNext)->eta() ? 1 : -1);
526 int nextOffset = offset+
sign;
527 if (abs(nextOffset) <= 2) sumET_Eta2 += 0.5*ithET*pow(nextOffset,2);
531 sumET_Eta2 += ithET*pow(offset,2);
539 if (sumET > 0.)
result = sumET_Eta2/sumET;
547 return sumVectorET(
L2cluster(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale, digitThresh), digitScale, digitThresh);
555 std::vector<float> outVec;
557 std::vector<const CaloCell*> L2Cells =
L2cluster(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale, digitThresh);
561 if (std::abs(centreCell->
eta()) < 1.57){
562 const int barrel_ec = idHelper->
pos_neg(centreCell->
ID());
564 if (std::abs(barrel_ec) == 2) isOW =
true;
565 std::vector<double> energyPerLayer =
EnergyPerTileLayer(L2Cells, tileCellCon, tileIDHelper, isOW, tileNoiseThresh);
566 if (energyPerLayer.size() > 0){
567 for (
auto ithLayerEnergy : energyPerLayer){
568 HadET += ithLayerEnergy;
573 std::vector<const CaloCell*> HCAL_LAr_vector;
574 for (
auto ithCell : L2Cells){
575 if (std::abs(ithCell->eta()) > 2.5)
continue;
577 if (tempLArHad !=
nullptr) HCAL_LAr_vector.push_back(tempLArHad);
579 for (
auto ithSC : HCAL_LAr_vector){
580 HadET +=
CaloCellET(ithSC, digitScale, digitThresh);
584 double EMcomp =
sumVectorET(fullClus, digitScale, digitThresh);
585 double result = HadET/(EMcomp+HadET);
586 if (result < 0. || result > 1.){
588 ATH_MSG_WARNING (
"fullClus count = " << fullClus.size() <<
", EMcomp = " << EMcomp <<
", HCALcomp = " << HadET);
597 float digitScale,
float digitThresh)
const
600 if (etaWidth1 > etaWidth2)
ATH_MSG_WARNING (
"REta: eta1 = " << etaWidth1 <<
", eta2 = " << etaWidth2);
601 if (phiWidth1 > phiWidth2)
ATH_MSG_WARNING (
"Rphi: phi1 = " << phiWidth1 <<
", phi2 = " << phiWidth2);
603 double inner_ET =
L2clusET(centreCell, etaWidth1, phiWidth1, scells, idHelper, digitScale, digitThresh);
604 double outer_ET =
L2clusET(centreCell, etaWidth2, phiWidth2, scells, idHelper, digitScale, digitThresh);
606 std::vector<const CaloCell*> L2cells_inner =
L2cluster(centreCell, etaWidth1, phiWidth1, scells, idHelper,digitScale, digitThresh);
607 std::vector<const CaloCell*> L1cells_inner;
608 for (
auto ithL2Cell : L2cells_inner){
611 inner_ET +=
sumVectorET(L1cells_inner, digitScale, digitThresh);
612 std::vector<const CaloCell*> L2cells_outer =
L2cluster(centreCell, etaWidth2, phiWidth2, scells, idHelper,digitScale, digitThresh);
613 std::vector<const CaloCell*> L1cells_outer;
614 for (
auto ithL2Cell : L2cells_outer){
617 outer_ET +=
sumVectorET(L1cells_outer, digitScale, digitThresh);
620 if (inner_ET != 0. && outer_ET==0.) normal_REta = 0.;
621 else if (inner_ET==0.) normal_REta = 0.;
622 else normal_REta = inner_ET / outer_ET;
623 if (normal_REta < 0) normal_REta = 0.;
624 double my_REta = 1-normal_REta;
632 if (inputCell==
nullptr)
return;
635 int sampling = idHelper->
sampling(inputID);
636 const int sub_calo = idHelper->
sub_calo(inputID);
637 int pos_neg = idHelper->
pos_neg(inputID);
638 int region = idHelper->
region(inputID);
639 int eta_index = idHelper->
eta(inputID);
640 const int phi_index = idHelper->
phi(inputID);
642 if (sampling != 2)
return;
644 int outputRegion = region;
645 int outputEta = eta_index;
646 bool oneCell =
false;
648 if ((abs(pos_neg) == 1)&&(region == 0)){
653 else if ((abs(pos_neg) == 1)&&(region == 1)){
668 else if (abs(pos_neg)==2 && region == 0) {
673 else if (abs(pos_neg)==2&&((region==1 && eta_index < 2))){
676 outputEta = eta_index + 1;
677 pos_neg /= abs(pos_neg);
681 else if (abs(pos_neg)==2&&((region==1 && eta_index == 2))){
688 else if (abs(pos_neg)==2&®ion==1 && eta_index <= 14){
692 outputEta = eta_index - 3;
696 else if (abs(pos_neg) == 2 && region == 1 && eta_index <= 22){
703 if (eta_index%4 == 0 || eta_index%4 ==1){
706 if (eta_index < 20) outputEta = eta_index -14;
707 else outputEta = eta_index - 12;
713 if (eta_index == 15) offset = 15;
714 else if (eta_index == 18) offset = 14;
715 else if (eta_index == 19) offset = 13;
716 else if (eta_index == 22) offset = 12;
720 for (
unsigned int i = 0; i < 2; i++){
721 outputEta = i+eta_index - offset;
722 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 1, outputRegion, outputEta, phi_index);
724 addOnce(resultCell,outputVector);
729 else if (abs(pos_neg)==2 && region == 1 && eta_index <= 38){
734 outputEta = eta_index - 23;
737 else if (abs(pos_neg)==2 && region == 1 && eta_index == 40){
748 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 1, outputRegion, outputEta, phi_index);
750 addOnce(resultCell,outputVector);
752 ATH_MSG_DEBUG(
"L2->L1: sampling = " << sampling <<
", region = " << region <<
", eta = " << pos_neg*eta_index<<
" tracker = " << tracker);
760 if ( inputCell ==
nullptr )
return nullptr;
761 const CaloCell* resultCell =
nullptr;
763 int sampling = idHelper->
sampling(inputID);
764 const int sub_calo = idHelper->
sub_calo(inputID);
765 const int pos_neg = idHelper->
pos_neg(inputID);
766 int region = idHelper->
region(inputID);
767 int eta_index = idHelper->
eta(inputID);
768 const int phi_index = idHelper->
phi(inputID);
769 if (sampling != 2)
return nullptr;
770 else if (abs(pos_neg)==1 && ((region==0 && eta_index>53)||region==1))
return nullptr;
771 else if ((abs(pos_neg)==2) && (region == 0 || (region == 1 && eta_index < 3)))
return nullptr;
772 else if (abs(pos_neg)==3)
return nullptr;
774 int outputRegion = region;
775 int outputEta = eta_index;
777 if (abs(pos_neg)==1 && region ==0){
778 int outputEta = eta_index/4;
779 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 3, outputRegion, outputEta, phi_index);
784 else if (abs(pos_neg)==1 && region ==1) {
785 int output_pos_neg = pos_neg*2;
788 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, output_pos_neg, 2, outputRegion, outputEta, phi_index);
793 else if (abs(pos_neg)==2 && region ==1){
794 outputEta = (eta_index - 3)/4;
796 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 3, outputRegion, outputEta, phi_index);
800 ATH_MSG_DEBUG(
"L2->L3: sampling = " << sampling <<
", region = " << region <<
", eta = " << pos_neg*eta_index<<
" tracker = " << tracker);
808 if (inputCell==
nullptr)
return nullptr;
809 const CaloCell* resultCell =
nullptr;
811 int sampling = idHelper->
sampling(inputID);
812 const int sub_calo = idHelper->
sub_calo(inputID);
813 const int pos_neg = idHelper->
pos_neg(inputID);
814 int region = idHelper->
region(inputID);
815 int eta_index = idHelper->
eta(inputID);
816 const int phi_index = idHelper->
phi(inputID);
817 if (sampling != 2)
return nullptr;
818 if (abs(pos_neg)==2 && (eta_index<3 || eta_index>14))
return nullptr;
819 if (abs(pos_neg)==3)
return nullptr;
821 int outputRegion = region;
822 int outputEta = eta_index;
824 if (abs(pos_neg)==1 && region ==0){
825 int outputEta = eta_index/4;
826 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 0, outputRegion, outputEta, phi_index);
829 else if (abs(pos_neg)==1 && region ==1){
830 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 0, 0, 14, phi_index);
833 else if (abs(pos_neg)==2 && region ==1){
834 outputEta = (eta_index - 3)/4;
836 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 0, outputRegion, outputEta, phi_index);
842std::vector<const CaloCell*>
847 std::vector<const CaloCell*> centCells;
848 centCells.push_back(centreCell);
853 if (
CaloCellET(upPhiCell, digitScale, digitThresh) >
CaloCellET(downPhiCell, digitScale, digitThresh)) energeticPhiCell = upPhiCell;
854 else energeticPhiCell = downPhiCell;
855 if (phiWidth == 2)
addOnce(energeticPhiCell, centCells);
856 else if (phiWidth == 3){
858 addOnce(downPhiCell, centCells);
860 else if (phiWidth > 3) {
864 std::vector<const CaloCell*> clusCells;
865 int halfEtaWidth = (etaWidth-1)/2;
866 int backToEta = (2*halfEtaWidth)+1;
867 if (backToEta != etaWidth) {
868 ATH_MSG_DEBUG (
"Eta width doesn't match! " << backToEta <<
" -> " << halfEtaWidth <<
" -> " << etaWidth <<
" " << __LINE__);
870 for (
auto ithCentCell : centCells){
871 addOnce(ithCentCell, clusCells);
875 addOnce(tempRightCell, clusCells);
876 addOnce(tempLeftCell, clusCells);
877 for (
int i = 1; i < halfEtaWidth; i++){
878 tempRightCell =
NextEtaCell(tempRightCell,
true,scells,idHelper);
879 tempLeftCell =
NextEtaCell(tempLeftCell,
false,scells,idHelper);
880 addOnce(tempRightCell, clusCells);
881 addOnce(tempLeftCell, clusCells);
890 const TileID* tileIDHelper,
bool isOW,
float tileNoiseThresh)
const
892 std::vector<double> layerEnergy;
893 if (CellCon==
nullptr)
return layerEnergy;
894 if (CellCon->
size()==0)
return layerEnergy;
895 if (inputSCVector.size()==0)
return layerEnergy;
896 double ELayer0 = 0, ELayer1 = 0, ELayer2 = 0;
897 std::vector<const TileCell*> tileCellVector;
898 for (
auto ithSC : inputSCVector){
899 float ithSCEta = ithSC->eta();
900 float ithSCPhi = ithSC->phi();
901 int matchingCells = 0;
904 for ( ; fCell != lCell; ++fCell){
910 int layer = tileIDHelper->
sample(tileCell->
ID());
911 float ithdR =
dR(tileCell->
eta(), tileCell->
phi(), ithSCEta, ithSCPhi);
913 float matchingDistance = 0.;
914 if (isOW && (std::abs(ithSCEta) > 1.38 && std::abs(ithSCEta) < 1.42)) matchingDistance = 0.065;
915 else matchingDistance = 0.05;
916 if (ithdR <= matchingDistance){
917 bool isAlreadyThere =
false;
919 if (isAlreadyThere)
continue;
925 else if (layer == 2){
926 float matchingDistance = 0.;
927 if (std::abs(ithSCEta) > 0.7 && std::abs(ithSCEta) < 0.8) matchingDistance = 0.05;
928 else if (std::abs(ithSCEta) > 0.9 && std::abs(ithSCEta) < 1.0) matchingDistance = 0.05;
929 else matchingDistance = 0.09;
930 if (ithdR < matchingDistance){
931 bool isAlreadyThere =
false;
933 if (isAlreadyThere)
continue;
948 if ((matchingCells > 3 && !isOW) || (matchingCells > 3 && isOW && std::abs(ithSCEta) > 1.42) || (matchingCells > 4 && isOW && std::abs(ithSCEta) < 1.42)){
950 ATH_MSG_WARNING (
"Input SC: (eta,phi) = (" << ithSCEta <<
"," << ithSCPhi <<
")");
951 for (
auto cell : tileCellVector){
952 ATH_MSG_WARNING (
"Tile cell: (eta,phi) = (" << cell->eta() <<
"," << cell->phi() <<
")" <<
" dR = " <<
dR(cell->eta(), cell->phi(), ithSCEta, ithSCPhi) <<
" layer = " << tileIDHelper->
sample(cell->ID()));
958 layerEnergy = {ELayer0, ELayer1, ELayer2};
965 if (inputTower ==
nullptr){
970 double phi = inputTower->
phi();
979 double etaDif = eta1 - eta2;
980 double phiDif = std::abs(phi1 - phi2);
981 if (phiDif >
M_PI) phiDif = phiDif - (2*
M_PI);
982 double result = std::sqrt(pow(etaDif,2)+pow(phiDif,2));
989 std::vector<const xAOD::TriggerTower*> matchingTTs;
990 if (TTContainer==
nullptr)
return nullptr;
991 if (TTContainer->
size()==0)
return nullptr;
992 if (inputCell==
nullptr)
return nullptr;
993 for (
auto ithTT : *TTContainer){
994 if (ithTT->sampling()==1){
995 float ithTT_eta = ithTT->eta();
996 float ithTT_phi =
TT_phi(ithTT);
997 float ithdR =
dR(ithTT_eta, ithTT_phi, inputCell->
eta(), inputCell->
phi());
998 if (ithdR < 0.05) matchingTTs.push_back(ithTT);
1001 if (matchingTTs.size()==1)
return matchingTTs[0];
1002 else if (matchingTTs.size()!=0){
1003 ATH_MSG_WARNING (
"More than one matching HCAL TT!!! (Returned Null)");
1011 std::vector<const CaloCell*> matchingCells;
1012 if (inputCell==
nullptr)
return nullptr;
1013 for (
auto ithSC : *SCContainer){
1015 int ithSub_calo = idHelper->
sub_calo(ithID);
1016 if (ithSub_calo == 1){
1017 double ithdR =
dR(inputCell->
eta(), inputCell->
phi(), ithSC->eta(), ithSC->phi());
1018 if (ithdR < 0.05) matchingCells.push_back(ithSC);
1022 if (matchingCells.size()==1)
1023 return matchingCells[0];
1026 if (matchingCells.size()==0){
1028 ATH_MSG_WARNING (
"No match betweem LAr ECAL SC and LAr HCAL SC!!! Input coords: " << inputCell->
eta() <<
", " << inputCell->
phi());
1030 }
else if (matchingCells.size()!=0) {
1032 ATH_MSG_WARNING (
"More than one matching LAr HCAL SC!!! (Returned Null)");
1034 for (
auto ithMatch : matchingCells){
1035 ATH_MSG_WARNING (
" " << ithMatch->eta() <<
" x " << ithMatch->phi() <<
", dR = "
1036 <<
dR(inputCell->
eta(), inputCell->
phi(), ithMatch->eta(), ithMatch->phi()));
1045 if (inputTower ==
nullptr){
1049 else if (inputTower->
cpET() < 0.) {
1052 return 500*inputTower->
cpET();
1056std::vector<const CaloCell*>
1061 std::vector<const CaloCell*> L2cells =
L2cluster(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale, digitThresh);
1063 std::vector<const CaloCell*> centCells;
1064 centCells.push_back(centreCell);
1071 if (
CaloCellET(upPhiCell, digitScale, digitThresh) >
CaloCellET(downPhiCell, digitScale, digitThresh)) energeticPhiCell = upPhiCell;
1072 else energeticPhiCell = downPhiCell;
1073 if (phiWidth == 2)
addOnce(energeticPhiCell, centCells);
1074 else if (phiWidth == 3){
1075 addOnce(upPhiCell, centCells);
1076 addOnce(downPhiCell, centCells);
1078 else if (phiWidth > 3)
ATH_MSG_WARNING (
"phiWidth not 2 or 3!!!. Value = " << phiWidth);
1081 std::vector<const CaloCell*> fullClus;
1083 for (
auto ithL2Cell : L2cells){
1084 fullClus.push_back(ithL2Cell);
1088 for (
auto ithL2CentCell : centCells){
1099 for (
auto ithCell : inputVector){
1100 if (ithCell!=
nullptr) TotalET +=
CaloCellET(ithCell, digitScale, digitThreshold);
1108 if (EM_ET == 0 || digitScale == 0)
return true;
1110 int div = EM_ET / digitScale;
1111 if (div * digitScale == EM_ET)
return true;
1113 ATH_MSG_WARNING (
"ET = " << EM_ET <<
", digitThresh = " << digitThresh <<
" digitScale = " << digitScale <<
" div = " << div <<
" " <<
" -> div * digitScale");
1122 float digitScale,
float digitThresh)
const
1125 std::vector<const CaloCell*> HCAL_LAr_vector;
1126 std::vector<const xAOD::TriggerTower*> HCAL_TT_vector;
1127 for (
auto ithCell : inputVector){
1128 if (std::abs(ithCell->eta())<1.5){
1130 if (tempTT !=
nullptr) HCAL_TT_vector.push_back(tempTT);
1132 else if (std::abs(ithCell->eta())<2.5){
1134 if (tempLArHad !=
nullptr) HCAL_LAr_vector.push_back(tempLArHad);
1139 for (
auto ithTT : HCAL_TT_vector) {HadET +=
TT_ET(ithTT);}
1140 for (
auto ithSC : HCAL_LAr_vector) {HadET +=
CaloCellET(ithSC, digitScale, digitThresh);}
1151 const CaloCell* isCell = cellContainer->
findCell(idHelper->CaloCell_SuperCell_ID::calo_cell_hash(inputID));
1152 if (isCell)
return isCell;
1153 else return nullptr;
1160 if (inputCell==
nullptr)
return nullptr;
1162 int ithSub_calo = idHelper->
sub_calo(ithID);
1163 int ithPos_neg = idHelper->
pos_neg(ithID);
1164 const CaloCell* tempCell =
nullptr;
1166 if (ithSub_calo==0){
1168 if (abs(ithPos_neg)==1) tempCell =
NextEtaCell_Barrel(inputCell, upwards, cellContainer, idHelper);
1170 else if (abs(ithPos_neg)==2) tempCell =
NextEtaCell_OW(inputCell, upwards, cellContainer, idHelper);
1172 else if (abs(ithPos_neg)==3) tempCell =
NextEtaCell_IW(inputCell, upwards, cellContainer, idHelper);
1175 ATH_MSG_WARNING (
"Layer 2 cell not passed to specific method at" << inputCell->
eta() <<
" , " << inputCell->
phi());
1192 const int ithEta_index = idHelper->
eta(ithID);
1193 const int ithPhi_index = idHelper->
phi(ithID);
1194 const int ithSampling = idHelper->
sampling(ithID);
1195 const int ithSub_calo = idHelper->
sub_calo(ithID);
1196 const int ithPos_neg = idHelper->
pos_neg(ithID);
1197 const int ithRegion = idHelper->
region(ithID);
1200 int maxEta_index = 0;
1201 int minEta_index = 0;
1203 if (ithSampling == 0) maxEta_index = 14;
1204 else if (ithSampling == 1 || ithSampling == 2) maxEta_index = 55;
1205 else if (ithSampling == 3) maxEta_index = 13;
1208 else if (ithRegion==1){
1209 if (ithSampling == 1) maxEta_index =2;
1210 else if (ithSampling == 2) maxEta_index=0;
1215 int nextEta_index = ithEta_index;
1218 int nextSampling = ithSampling;
1219 int nextSub_calo = ithSub_calo;
1220 int nextPos_neg = ithPos_neg;
1221 int nextRegion = ithRegion;
1225 if (upwards) incrementEta = ithPos_neg;
1226 else incrementEta = -1*ithPos_neg;
1231 if (ithEta_index==minEta_index && incrementEta==-1){
1232 if (ithRegion == 0){
1234 nextPos_neg = ithPos_neg * -1;
1237 else if (ithRegion == 1){
1246 else if ((ithEta_index == maxEta_index) && (incrementEta == 1)) {
1248 if ((ithRegion == 0)&&(ithSampling == 1 || ithSampling == 2)){
1254 else if ((ithRegion == 0)&&(ithSampling == 0)){
1257 nextPos_neg = 2*ithPos_neg;
1261 else if ((ithRegion == 0)&&(ithSampling == 3)){
1265 nextPos_neg = 2*ithPos_neg;
1269 else if ((ithRegion == 1)&&(ithSampling == 1)){
1272 nextPos_neg = 2 * ithPos_neg;
1276 else if ((ithRegion == 1)&&(ithSampling == 2)){
1279 nextPos_neg = 2 * ithPos_neg;
1286 nextEta_index = ithEta_index + incrementEta;
1292 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(nextSub_calo, nextPos_neg, nextSampling, nextRegion, nextEta_index, ithPhi_index);
1294 if (nextCell ==
nullptr) {
1297 ATH_MSG_DEBUG (
"from nextCellID: "<<idHelper->
sub_calo(nextCellID)<<
", "<<idHelper->
pos_neg(nextCellID)<<
", "<<idHelper->
sampling(nextCellID)<<
", "<<idHelper->
region(nextCellID)<<
", "<<idHelper->
eta(nextCellID)<<
", "<<idHelper->
phi(nextCellID)<<
", "<<idHelper->
calo_cell_hash(nextCellID)<<
", "<<nextCellID);
1301 int IDsample = idHelper->
sampling(nextCell->
ID());
1303 if (IDsample!=ithSampling){
1304 ATH_MSG_DEBUG (
"Layer has changed " <<
" tracker = " << tracker);
1305 ATH_MSG_DEBUG (
"from nextCellID: "<<idHelper->
sub_calo(nextCellID)<<
", "<<idHelper->
pos_neg(nextCellID)<<
", "<<idHelper->
sampling(nextCellID)<<
", "<<idHelper->
region(nextCellID)<<
", "<<idHelper->
eta(nextCellID)<<
", "<<idHelper->
phi(nextCellID)<<
", "<<idHelper->
calo_cell_hash(nextCellID)<<
", "<<nextCellID);
1310 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__ <<
" does not match");
1319 int ithEta_index = idHelper->
eta(ithID);
1320 const int ithPhi_index = idHelper->
phi(ithID);
1321 const int ithSampling = idHelper->
sampling(ithID);
1322 int ithSub_calo = idHelper->
sub_calo(ithID);
1323 int ithPos_neg = idHelper->
pos_neg(ithID);
1324 int ithRegion = idHelper->
region(ithID);
1326 int nextEta_index = ithEta_index;
1327 int nextPhi_index = ithPhi_index;
1329 int nextSampling = ithSampling;
1330 int nextSub_calo = ithSub_calo;
1331 int nextPos_neg = ithPos_neg;
1332 int nextRegion = ithRegion;
1334 int maxEta_index = 0;
1335 int minEta_index = 0;
1337 if (ithSampling==0) maxEta_index = 2;
1338 else if (ithSampling==2 && ithRegion==0) maxEta_index = 0;
1339 else if (ithSampling==2 && ithRegion==1) maxEta_index = 42;
1340 else if (ithSampling==3) maxEta_index=9;
1341 else if (ithSampling==1) {
1368 int incrementEta = upwards ? 1 : -1;
1371 if (
auto denom = std::abs(ithPos_neg); denom!=0){
1372 ithSide = ithPos_neg / denom;
1374 incrementEta *= ithSide;
1377 if (ithEta_index==minEta_index && ithRegion==0 && incrementEta==-1){
1378 nextPos_neg = ithSide;
1379 if (ithSampling==0){
1384 else if (ithSampling==1){
1390 else if (ithSampling==2){
1397 else if (ithSampling==3){
1401 nextPos_neg = ithPos_neg;
1406 else if (ithEta_index==maxEta_index && incrementEta==1){
1408 if (ithSampling==0 || ithSampling==3)
return nullptr;
1409 else if (ithSampling==2 && ithRegion==0){
1414 else if ((ithSampling==2 && ithRegion==1)||(ithSampling==1 && ithRegion==5)){
1418 nextPhi_index=ithPhi_index/2;
1419 nextPos_neg=3*ithSide;
1422 else if (ithSampling==1 && ithRegion==0){
1428 else if (ithSampling==1){
1429 nextRegion=ithRegion + 1;
1435 else if (ithEta_index==minEta_index && incrementEta==-1){
1439 if (ithSampling==2){
1442 nextPos_neg = ithPos_neg;
1445 else if (ithSampling==1){
1448 nextRegion = ithRegion-1;
1449 if (nextRegion==0) {
1453 else if (nextRegion==1) {
1457 else if (nextRegion==2) nextEta_index=11;
1458 else if (nextRegion==3) nextEta_index=7;
1459 else if (nextRegion==4) nextEta_index=15;
1464 nextEta_index = ithEta_index+incrementEta;
1467 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(nextSub_calo, nextPos_neg, nextSampling, nextRegion, nextEta_index, nextPhi_index);
1469 if (nextCell ==
nullptr) {
1472 ATH_MSG_DEBUG (
"from nextCellID: "<<idHelper->
sub_calo(nextCellID)<<
", "<<idHelper->
pos_neg(nextCellID)<<
", "<<idHelper->
sampling(nextCellID)<<
", "<<idHelper->
region(nextCellID)<<
", "<<idHelper->
eta(nextCellID)<<
", "<<idHelper->
phi(nextCellID)<<
", "<<idHelper->
calo_cell_hash(nextCellID)<<
", "<<nextCellID);
1473 ATH_MSG_DEBUG (
"Increment eta = "<<incrementEta<<
", max_eta = "<<maxEta_index<<
", min_eta = "<<minEta_index);
1477 int IDsample = idHelper->
sampling(nextCell->
ID());
1478 if (IDsample!=ithSampling){
1479 ATH_MSG_DEBUG (
"Layer has changed "<<
" tracker = "<<tracker);
1480 ATH_MSG_DEBUG (
"from nextCellID: "<<idHelper->
sub_calo(nextCellID)<<
", "<<idHelper->
pos_neg(nextCellID)<<
", "<<idHelper->
sampling(nextCellID)<<
", "<<idHelper->
region(nextCellID)<<
", "<<idHelper->
eta(nextCellID)<<
", "<<idHelper->
phi(nextCellID)<<
", "<<idHelper->
calo_cell_hash(nextCellID)<<
", "<<nextCellID);
1485 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__<<
" does not match");
1494 const int ithEta_index = idHelper->
eta(ithID);
1495 const int ithPhi_index = idHelper->
phi(ithID);
1496 const int ithSampling = idHelper->
sampling(ithID);
1497 const int ithSub_calo = idHelper->
sub_calo(ithID);
1498 const int ithPos_neg = idHelper->
pos_neg(ithID);
1499 const int ithRegion = idHelper->
region(ithID);
1502 int nextEta_index = ithEta_index;
1503 int nextPhi_index = ithPhi_index;
1505 int nextSub_calo = ithSub_calo;
1506 int nextPos_neg = ithPos_neg;
1507 int nextRegion = ithRegion;
1510 int maxEta_index = 0;
1511 int minEta_index = 0;
1517 else if (ithRegion!=1)
ATH_MSG_DEBUG (
"ISSUE: " <<__LINE__);
1522 if (ithPos_neg != 0){
1523 ithSide = ithPos_neg / std::abs(ithPos_neg);
1525 if (upwards) incrementEta = ithSide;
1526 else incrementEta = ithSide * -1;
1528 if (ithEta_index==minEta_index&& incrementEta==-1){
1530 if (ithRegion == 0){
1531 nextPos_neg = 2*ithSide;
1532 nextPhi_index=2*ithPhi_index;
1533 if (ithSampling==1){
1538 else if (ithSampling==2){
1546 else if (ithRegion == 1){
1553 else if (ithEta_index==maxEta_index && incrementEta==1){
1561 else if (ithRegion==1)
return nullptr;
1566 nextEta_index=ithEta_index+incrementEta;
1568 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(nextSub_calo, nextPos_neg, ithSampling, nextRegion, nextEta_index, nextPhi_index);
1570 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__<<
" does not match");
1577 if (is64&&input_index<0)
return input_index+64;
1578 else if (is64&&input_index>63)
return input_index-64;
1579 else if (!(is64)&&input_index<0)
return input_index+32;
1580 else if (!(is64)&&input_index>31)
return input_index-32;
1581 else return input_index;
1588 if (inputCell==
nullptr)
1592 const int ithEta_index = idHelper->
eta(ithID);
1593 const int ithPhi_index = idHelper->
phi(ithID);
1594 const int ithSampling = idHelper->
sampling(ithID);
1595 const int ithSub_calo = idHelper->
sub_calo(ithID);
1596 const int ithPos_neg = idHelper->
pos_neg(ithID);
1597 const int ithRegion = idHelper->
region(ithID);
1600 if (abs(ithPos_neg)==3) is64 =
false;
1604 if (upwards==
true) incrementPhi=1;
1605 else incrementPhi=-1;
1607 const int nextPhi_index =
restrictPhiIndex(ithPhi_index+incrementPhi, is64);
1608 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(ithSub_calo, ithPos_neg, ithSampling, ithRegion, ithEta_index, nextPhi_index);
1610 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__ <<
" does not match");
1611 if (nextCell ==
nullptr)
ATH_MSG_DEBUG (
"Next phi cell is nullptr at " << __LINE__);
Scalar phi() const
phi method
#define ATH_MSG_WARNING(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
int phi(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
int sampling(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
int sub_calo(const Identifier id) const
returns an int taken from SUBCALO enum and describing the subCalo to which the Id belongs.
int region(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
int pos_neg(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
int eta(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
Helper class for offline supercell identifiers.
Data object for each calorimeter readout cell.
virtual double e() const override final
get energy (data member) (synonym to method energy()
virtual double phi() const override final
get phi (through CaloDetDescrElement)
double energy() const
get energy (data member)
uint16_t provenance() const
get provenance (data member)
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
CaloCellContainer that can accept const cell pointers.
::CaloCellContainer::const_iterator beginConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const begin iterator on cell of just one calo
const CaloCell * findCell(IdentifierHash theHash) const
fast find method given identifier hash.
::CaloCellContainer::const_iterator endConstCalo(CaloCell_ID::SUBCALO caloNum) const
get const begin iterator on cell of just one calo
DataModel_detail::const_iterator< DataVector > const_iterator
size_type size() const noexcept
Returns the number of elements in the collection.
float ene1(void) const
get energy of first PMT
float ene2(void) const
get energy of second PMT
Helper class for TileCal offline identifiers.
int sample(const Identifier &id) const
uint8_t cpET() const
get cpET from peak of lut_cp
virtual double phi() const final
The azimuthal angle ( ) of the particle.
TriggerTowerContainer_v2 TriggerTowerContainer
Define the latest version of the TriggerTower container.
TriggerTower_v2 TriggerTower
Define the latest version of the TriggerTower class.