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 if (EMcomp+HadET == 0.)[[
unlikely]]{
589 double result = HadET/(EMcomp+HadET);
590 if (result < 0. || result > 1.){
592 ATH_MSG_WARNING (
"fullClus count = " << fullClus.size() <<
", EMcomp = " << EMcomp <<
", HCALcomp = " << HadET);
601 float digitScale,
float digitThresh)
const
604 if (etaWidth1 > etaWidth2)
ATH_MSG_WARNING (
"REta: eta1 = " << etaWidth1 <<
", eta2 = " << etaWidth2);
605 if (phiWidth1 > phiWidth2)
ATH_MSG_WARNING (
"Rphi: phi1 = " << phiWidth1 <<
", phi2 = " << phiWidth2);
607 double inner_ET =
L2clusET(centreCell, etaWidth1, phiWidth1, scells, idHelper, digitScale, digitThresh);
608 double outer_ET =
L2clusET(centreCell, etaWidth2, phiWidth2, scells, idHelper, digitScale, digitThresh);
610 std::vector<const CaloCell*> L2cells_inner =
L2cluster(centreCell, etaWidth1, phiWidth1, scells, idHelper,digitScale, digitThresh);
611 std::vector<const CaloCell*> L1cells_inner;
612 for (
auto ithL2Cell : L2cells_inner){
615 inner_ET +=
sumVectorET(L1cells_inner, digitScale, digitThresh);
616 std::vector<const CaloCell*> L2cells_outer =
L2cluster(centreCell, etaWidth2, phiWidth2, scells, idHelper,digitScale, digitThresh);
617 std::vector<const CaloCell*> L1cells_outer;
618 for (
auto ithL2Cell : L2cells_outer){
621 outer_ET +=
sumVectorET(L1cells_outer, digitScale, digitThresh);
624 if (inner_ET != 0. && outer_ET==0.) normal_REta = 0.;
625 else if (inner_ET==0.) normal_REta = 0.;
626 else normal_REta = inner_ET / outer_ET;
627 if (normal_REta < 0) normal_REta = 0.;
628 double my_REta = 1-normal_REta;
636 if (inputCell==
nullptr)
return;
639 int sampling = idHelper->
sampling(inputID);
640 const int sub_calo = idHelper->
sub_calo(inputID);
641 int pos_neg = idHelper->
pos_neg(inputID);
642 int region = idHelper->
region(inputID);
643 int eta_index = idHelper->
eta(inputID);
644 const int phi_index = idHelper->
phi(inputID);
646 if (sampling != 2)
return;
648 int outputRegion = region;
649 int outputEta = eta_index;
650 bool oneCell =
false;
652 if ((abs(pos_neg) == 1)&&(region == 0)){
657 else if ((abs(pos_neg) == 1)&&(region == 1)){
672 else if (abs(pos_neg)==2 && region == 0) {
677 else if (abs(pos_neg)==2&&((region==1 && eta_index < 2))){
680 outputEta = eta_index + 1;
681 pos_neg /= abs(pos_neg);
685 else if (abs(pos_neg)==2&&((region==1 && eta_index == 2))){
692 else if (abs(pos_neg)==2&®ion==1 && eta_index <= 14){
696 outputEta = eta_index - 3;
700 else if (abs(pos_neg) == 2 && region == 1 && eta_index <= 22){
707 if (eta_index%4 == 0 || eta_index%4 ==1){
710 if (eta_index < 20) outputEta = eta_index -14;
711 else outputEta = eta_index - 12;
717 if (eta_index == 15) offset = 15;
718 else if (eta_index == 18) offset = 14;
719 else if (eta_index == 19) offset = 13;
720 else if (eta_index == 22) offset = 12;
724 for (
unsigned int i = 0; i < 2; i++){
725 outputEta = i+eta_index - offset;
726 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 1, outputRegion, outputEta, phi_index);
728 addOnce(resultCell,outputVector);
733 else if (abs(pos_neg)==2 && region == 1 && eta_index <= 38){
738 outputEta = eta_index - 23;
741 else if (abs(pos_neg)==2 && region == 1 && eta_index == 40){
752 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 1, outputRegion, outputEta, phi_index);
754 addOnce(resultCell,outputVector);
756 ATH_MSG_DEBUG(
"L2->L1: sampling = " << sampling <<
", region = " << region <<
", eta = " << pos_neg*eta_index<<
" tracker = " << tracker);
764 if ( inputCell ==
nullptr )
return nullptr;
765 const CaloCell* resultCell =
nullptr;
767 int sampling = idHelper->
sampling(inputID);
768 const int sub_calo = idHelper->
sub_calo(inputID);
769 const int pos_neg = idHelper->
pos_neg(inputID);
770 int region = idHelper->
region(inputID);
771 int eta_index = idHelper->
eta(inputID);
772 const int phi_index = idHelper->
phi(inputID);
773 if (sampling != 2)
return nullptr;
774 else if (abs(pos_neg)==1 && ((region==0 && eta_index>53)||region==1))
return nullptr;
775 else if ((abs(pos_neg)==2) && (region == 0 || (region == 1 && eta_index < 3)))
return nullptr;
776 else if (abs(pos_neg)==3)
return nullptr;
778 int outputRegion = region;
779 int outputEta = eta_index;
781 if (abs(pos_neg)==1 && region ==0){
782 int outputEta = eta_index/4;
783 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 3, outputRegion, outputEta, phi_index);
788 else if (abs(pos_neg)==1 && region ==1) {
789 int output_pos_neg = pos_neg*2;
792 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, output_pos_neg, 2, outputRegion, outputEta, phi_index);
797 else if (abs(pos_neg)==2 && region ==1){
798 outputEta = (eta_index - 3)/4;
800 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 3, outputRegion, outputEta, phi_index);
804 ATH_MSG_DEBUG(
"L2->L3: sampling = " << sampling <<
", region = " << region <<
", eta = " << pos_neg*eta_index<<
" tracker = " << tracker);
812 if (inputCell==
nullptr)
return nullptr;
813 const CaloCell* resultCell =
nullptr;
815 int sampling = idHelper->
sampling(inputID);
816 const int sub_calo = idHelper->
sub_calo(inputID);
817 const int pos_neg = idHelper->
pos_neg(inputID);
818 int region = idHelper->
region(inputID);
819 int eta_index = idHelper->
eta(inputID);
820 const int phi_index = idHelper->
phi(inputID);
821 if (sampling != 2)
return nullptr;
822 if (abs(pos_neg)==2 && (eta_index<3 || eta_index>14))
return nullptr;
823 if (abs(pos_neg)==3)
return nullptr;
825 int outputRegion = region;
826 int outputEta = eta_index;
828 if (abs(pos_neg)==1 && region ==0){
829 int outputEta = eta_index/4;
830 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 0, outputRegion, outputEta, phi_index);
833 else if (abs(pos_neg)==1 && region ==1){
834 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 0, 0, 14, phi_index);
837 else if (abs(pos_neg)==2 && region ==1){
838 outputEta = (eta_index - 3)/4;
840 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 0, outputRegion, outputEta, phi_index);
846std::vector<const CaloCell*>
851 std::vector<const CaloCell*> centCells;
852 centCells.push_back(centreCell);
857 if (
CaloCellET(upPhiCell, digitScale, digitThresh) >
CaloCellET(downPhiCell, digitScale, digitThresh)) energeticPhiCell = upPhiCell;
858 else energeticPhiCell = downPhiCell;
859 if (phiWidth == 2)
addOnce(energeticPhiCell, centCells);
860 else if (phiWidth == 3){
862 addOnce(downPhiCell, centCells);
864 else if (phiWidth > 3) {
868 std::vector<const CaloCell*> clusCells;
869 int halfEtaWidth = (etaWidth-1)/2;
870 int backToEta = (2*halfEtaWidth)+1;
871 if (backToEta != etaWidth) {
872 ATH_MSG_DEBUG (
"Eta width doesn't match! " << backToEta <<
" -> " << halfEtaWidth <<
" -> " << etaWidth <<
" " << __LINE__);
874 for (
auto ithCentCell : centCells){
875 addOnce(ithCentCell, clusCells);
879 addOnce(tempRightCell, clusCells);
880 addOnce(tempLeftCell, clusCells);
881 for (
int i = 1; i < halfEtaWidth; i++){
882 tempRightCell =
NextEtaCell(tempRightCell,
true,scells,idHelper);
883 tempLeftCell =
NextEtaCell(tempLeftCell,
false,scells,idHelper);
884 addOnce(tempRightCell, clusCells);
885 addOnce(tempLeftCell, clusCells);
894 const TileID* tileIDHelper,
bool isOW,
float tileNoiseThresh)
const
896 std::vector<double> layerEnergy;
897 if (CellCon==
nullptr)
return layerEnergy;
898 if (CellCon->
size()==0)
return layerEnergy;
899 if (inputSCVector.size()==0)
return layerEnergy;
900 double ELayer0 = 0, ELayer1 = 0, ELayer2 = 0;
901 std::vector<const TileCell*> tileCellVector;
902 for (
auto ithSC : inputSCVector){
903 float ithSCEta = ithSC->eta();
904 float ithSCPhi = ithSC->phi();
905 int matchingCells = 0;
908 for ( ; fCell != lCell; ++fCell){
914 int layer = tileIDHelper->
sample(tileCell->
ID());
915 float ithdR =
dR(tileCell->
eta(), tileCell->
phi(), ithSCEta, ithSCPhi);
917 float matchingDistance = 0.;
918 if (isOW && (std::abs(ithSCEta) > 1.38 && std::abs(ithSCEta) < 1.42)) matchingDistance = 0.065;
919 else matchingDistance = 0.05;
920 if (ithdR <= matchingDistance){
921 bool isAlreadyThere =
false;
923 if (isAlreadyThere)
continue;
929 else if (layer == 2){
930 float matchingDistance = 0.;
931 if (std::abs(ithSCEta) > 0.7 && std::abs(ithSCEta) < 0.8) matchingDistance = 0.05;
932 else if (std::abs(ithSCEta) > 0.9 && std::abs(ithSCEta) < 1.0) matchingDistance = 0.05;
933 else matchingDistance = 0.09;
934 if (ithdR < matchingDistance){
935 bool isAlreadyThere =
false;
937 if (isAlreadyThere)
continue;
952 if ((matchingCells > 3 && !isOW) || (matchingCells > 3 && isOW && std::abs(ithSCEta) > 1.42) || (matchingCells > 4 && isOW && std::abs(ithSCEta) < 1.42)){
954 ATH_MSG_WARNING (
"Input SC: (eta,phi) = (" << ithSCEta <<
"," << ithSCPhi <<
")");
955 for (
auto cell : tileCellVector){
956 ATH_MSG_WARNING (
"Tile cell: (eta,phi) = (" << cell->eta() <<
"," << cell->phi() <<
")" <<
" dR = " <<
dR(cell->eta(), cell->phi(), ithSCEta, ithSCPhi) <<
" layer = " << tileIDHelper->
sample(cell->ID()));
962 layerEnergy = {ELayer0, ELayer1, ELayer2};
969 if (inputTower ==
nullptr){
974 double phi = inputTower->
phi();
983 double etaDif = eta1 - eta2;
984 double phiDif = std::abs(phi1 - phi2);
985 if (phiDif >
M_PI) phiDif = phiDif - (2*
M_PI);
986 double result = std::sqrt(pow(etaDif,2)+pow(phiDif,2));
993 std::vector<const xAOD::TriggerTower*> matchingTTs;
994 if (TTContainer==
nullptr)
return nullptr;
995 if (TTContainer->
size()==0)
return nullptr;
996 if (inputCell==
nullptr)
return nullptr;
997 for (
auto ithTT : *TTContainer){
998 if (ithTT->sampling()==1){
999 float ithTT_eta = ithTT->eta();
1000 float ithTT_phi =
TT_phi(ithTT);
1001 float ithdR =
dR(ithTT_eta, ithTT_phi, inputCell->
eta(), inputCell->
phi());
1002 if (ithdR < 0.05) matchingTTs.push_back(ithTT);
1005 if (matchingTTs.size()==1)
return matchingTTs[0];
1006 else if (matchingTTs.size()!=0){
1007 ATH_MSG_WARNING (
"More than one matching HCAL TT!!! (Returned Null)");
1015 std::vector<const CaloCell*> matchingCells;
1016 if (inputCell==
nullptr)
return nullptr;
1017 for (
auto ithSC : *SCContainer){
1019 int ithSub_calo = idHelper->
sub_calo(ithID);
1020 if (ithSub_calo == 1){
1021 double ithdR =
dR(inputCell->
eta(), inputCell->
phi(), ithSC->eta(), ithSC->phi());
1022 if (ithdR < 0.05) matchingCells.push_back(ithSC);
1026 if (matchingCells.size()==1)
1027 return matchingCells[0];
1030 if (matchingCells.size()==0){
1032 ATH_MSG_WARNING (
"No match betweem LAr ECAL SC and LAr HCAL SC!!! Input coords: " << inputCell->
eta() <<
", " << inputCell->
phi());
1034 }
else if (matchingCells.size()!=0) {
1036 ATH_MSG_WARNING (
"More than one matching LAr HCAL SC!!! (Returned Null)");
1038 for (
auto ithMatch : matchingCells){
1039 ATH_MSG_WARNING (
" " << ithMatch->eta() <<
" x " << ithMatch->phi() <<
", dR = "
1040 <<
dR(inputCell->
eta(), inputCell->
phi(), ithMatch->eta(), ithMatch->phi()));
1049 if (inputTower ==
nullptr){
1053 else if (inputTower->
cpET() < 0.) {
1056 return 500*inputTower->
cpET();
1060std::vector<const CaloCell*>
1065 std::vector<const CaloCell*> L2cells =
L2cluster(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale, digitThresh);
1067 std::vector<const CaloCell*> centCells;
1068 centCells.push_back(centreCell);
1075 if (
CaloCellET(upPhiCell, digitScale, digitThresh) >
CaloCellET(downPhiCell, digitScale, digitThresh)) energeticPhiCell = upPhiCell;
1076 else energeticPhiCell = downPhiCell;
1077 if (phiWidth == 2)
addOnce(energeticPhiCell, centCells);
1078 else if (phiWidth == 3){
1079 addOnce(upPhiCell, centCells);
1080 addOnce(downPhiCell, centCells);
1082 else if (phiWidth > 3)
ATH_MSG_WARNING (
"phiWidth not 2 or 3!!!. Value = " << phiWidth);
1085 std::vector<const CaloCell*> fullClus;
1087 for (
auto ithL2Cell : L2cells){
1088 fullClus.push_back(ithL2Cell);
1092 for (
auto ithL2CentCell : centCells){
1103 for (
auto ithCell : inputVector){
1104 if (ithCell!=
nullptr) TotalET +=
CaloCellET(ithCell, digitScale, digitThreshold);
1112 if (EM_ET == 0 || digitScale == 0)
return true;
1114 int div = EM_ET / digitScale;
1115 if (div * digitScale == EM_ET)
return true;
1117 ATH_MSG_WARNING (
"ET = " << EM_ET <<
", digitThresh = " << digitThresh <<
" digitScale = " << digitScale <<
" div = " << div <<
" " <<
" -> div * digitScale");
1126 float digitScale,
float digitThresh)
const
1129 std::vector<const CaloCell*> HCAL_LAr_vector;
1130 std::vector<const xAOD::TriggerTower*> HCAL_TT_vector;
1131 for (
auto ithCell : inputVector){
1132 if (std::abs(ithCell->eta())<1.5){
1134 if (tempTT !=
nullptr) HCAL_TT_vector.push_back(tempTT);
1136 else if (std::abs(ithCell->eta())<2.5){
1138 if (tempLArHad !=
nullptr) HCAL_LAr_vector.push_back(tempLArHad);
1143 for (
auto ithTT : HCAL_TT_vector) {HadET +=
TT_ET(ithTT);}
1144 for (
auto ithSC : HCAL_LAr_vector) {HadET +=
CaloCellET(ithSC, digitScale, digitThresh);}
1155 const CaloCell* isCell = cellContainer->
findCell(idHelper->CaloCell_SuperCell_ID::calo_cell_hash(inputID));
1156 if (isCell)
return isCell;
1157 else return nullptr;
1164 if (inputCell==
nullptr)
return nullptr;
1166 int ithSub_calo = idHelper->
sub_calo(ithID);
1167 int ithPos_neg = idHelper->
pos_neg(ithID);
1168 const CaloCell* tempCell =
nullptr;
1170 if (ithSub_calo==0){
1172 if (abs(ithPos_neg)==1) tempCell =
NextEtaCell_Barrel(inputCell, upwards, cellContainer, idHelper);
1174 else if (abs(ithPos_neg)==2) tempCell =
NextEtaCell_OW(inputCell, upwards, cellContainer, idHelper);
1176 else if (abs(ithPos_neg)==3) tempCell =
NextEtaCell_IW(inputCell, upwards, cellContainer, idHelper);
1179 ATH_MSG_WARNING (
"Layer 2 cell not passed to specific method at" << inputCell->
eta() <<
" , " << inputCell->
phi());
1196 const int ithEta_index = idHelper->
eta(ithID);
1197 const int ithPhi_index = idHelper->
phi(ithID);
1198 const int ithSampling = idHelper->
sampling(ithID);
1199 const int ithSub_calo = idHelper->
sub_calo(ithID);
1200 const int ithPos_neg = idHelper->
pos_neg(ithID);
1201 const int ithRegion = idHelper->
region(ithID);
1204 int maxEta_index = 0;
1205 int minEta_index = 0;
1207 if (ithSampling == 0) maxEta_index = 14;
1208 else if (ithSampling == 1 || ithSampling == 2) maxEta_index = 55;
1209 else if (ithSampling == 3) maxEta_index = 13;
1212 else if (ithRegion==1){
1213 if (ithSampling == 1) maxEta_index =2;
1214 else if (ithSampling == 2) maxEta_index=0;
1219 int nextEta_index = ithEta_index;
1222 int nextSampling = ithSampling;
1223 int nextSub_calo = ithSub_calo;
1224 int nextPos_neg = ithPos_neg;
1225 int nextRegion = ithRegion;
1229 if (upwards) incrementEta = ithPos_neg;
1230 else incrementEta = -1*ithPos_neg;
1235 if (ithEta_index==minEta_index && incrementEta==-1){
1236 if (ithRegion == 0){
1238 nextPos_neg = ithPos_neg * -1;
1241 else if (ithRegion == 1){
1250 else if ((ithEta_index == maxEta_index) && (incrementEta == 1)) {
1252 if ((ithRegion == 0)&&(ithSampling == 1 || ithSampling == 2)){
1258 else if ((ithRegion == 0)&&(ithSampling == 0)){
1261 nextPos_neg = 2*ithPos_neg;
1265 else if ((ithRegion == 0)&&(ithSampling == 3)){
1269 nextPos_neg = 2*ithPos_neg;
1273 else if ((ithRegion == 1)&&(ithSampling == 1)){
1276 nextPos_neg = 2 * ithPos_neg;
1280 else if ((ithRegion == 1)&&(ithSampling == 2)){
1283 nextPos_neg = 2 * ithPos_neg;
1290 nextEta_index = ithEta_index + incrementEta;
1296 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(nextSub_calo, nextPos_neg, nextSampling, nextRegion, nextEta_index, ithPhi_index);
1298 if (nextCell ==
nullptr) {
1301 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);
1305 int IDsample = idHelper->
sampling(nextCell->
ID());
1307 if (IDsample!=ithSampling){
1308 ATH_MSG_DEBUG (
"Layer has changed " <<
" tracker = " << tracker);
1309 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);
1314 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__ <<
" does not match");
1323 int ithEta_index = idHelper->
eta(ithID);
1324 const int ithPhi_index = idHelper->
phi(ithID);
1325 const int ithSampling = idHelper->
sampling(ithID);
1326 int ithSub_calo = idHelper->
sub_calo(ithID);
1327 int ithPos_neg = idHelper->
pos_neg(ithID);
1328 int ithRegion = idHelper->
region(ithID);
1330 int nextEta_index = ithEta_index;
1331 int nextPhi_index = ithPhi_index;
1333 int nextSampling = ithSampling;
1334 int nextSub_calo = ithSub_calo;
1335 int nextPos_neg = ithPos_neg;
1336 int nextRegion = ithRegion;
1338 int maxEta_index = 0;
1339 int minEta_index = 0;
1341 if (ithSampling==0) maxEta_index = 2;
1342 else if (ithSampling==2 && ithRegion==0) maxEta_index = 0;
1343 else if (ithSampling==2 && ithRegion==1) maxEta_index = 42;
1344 else if (ithSampling==3) maxEta_index=9;
1345 else if (ithSampling==1) {
1372 int incrementEta = upwards ? 1 : -1;
1375 if (
auto denom = std::abs(ithPos_neg); denom!=0){
1376 ithSide = ithPos_neg / denom;
1378 incrementEta *= ithSide;
1381 if (ithEta_index==minEta_index && ithRegion==0 && incrementEta==-1){
1382 nextPos_neg = ithSide;
1383 if (ithSampling==0){
1388 else if (ithSampling==1){
1394 else if (ithSampling==2){
1401 else if (ithSampling==3){
1405 nextPos_neg = ithPos_neg;
1410 else if (ithEta_index==maxEta_index && incrementEta==1){
1412 if (ithSampling==0 || ithSampling==3)
return nullptr;
1413 else if (ithSampling==2 && ithRegion==0){
1418 else if ((ithSampling==2 && ithRegion==1)||(ithSampling==1 && ithRegion==5)){
1422 nextPhi_index=ithPhi_index/2;
1423 nextPos_neg=3*ithSide;
1426 else if (ithSampling==1 && ithRegion==0){
1432 else if (ithSampling==1){
1433 nextRegion=ithRegion + 1;
1439 else if (ithEta_index==minEta_index && incrementEta==-1){
1443 if (ithSampling==2){
1446 nextPos_neg = ithPos_neg;
1449 else if (ithSampling==1){
1452 nextRegion = ithRegion-1;
1453 if (nextRegion==0) {
1457 else if (nextRegion==1) {
1461 else if (nextRegion==2) nextEta_index=11;
1462 else if (nextRegion==3) nextEta_index=7;
1463 else if (nextRegion==4) nextEta_index=15;
1468 nextEta_index = ithEta_index+incrementEta;
1471 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(nextSub_calo, nextPos_neg, nextSampling, nextRegion, nextEta_index, nextPhi_index);
1473 if (nextCell ==
nullptr) {
1476 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);
1477 ATH_MSG_DEBUG (
"Increment eta = "<<incrementEta<<
", max_eta = "<<maxEta_index<<
", min_eta = "<<minEta_index);
1481 int IDsample = idHelper->
sampling(nextCell->
ID());
1482 if (IDsample!=ithSampling){
1483 ATH_MSG_DEBUG (
"Layer has changed "<<
" tracker = "<<tracker);
1484 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);
1489 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__<<
" does not match");
1498 const int ithEta_index = idHelper->
eta(ithID);
1499 const int ithPhi_index = idHelper->
phi(ithID);
1500 const int ithSampling = idHelper->
sampling(ithID);
1501 const int ithSub_calo = idHelper->
sub_calo(ithID);
1502 const int ithPos_neg = idHelper->
pos_neg(ithID);
1503 const int ithRegion = idHelper->
region(ithID);
1506 int nextEta_index = ithEta_index;
1507 int nextPhi_index = ithPhi_index;
1509 int nextSub_calo = ithSub_calo;
1510 int nextPos_neg = ithPos_neg;
1511 int nextRegion = ithRegion;
1514 int maxEta_index = 0;
1515 int minEta_index = 0;
1521 else if (ithRegion!=1)
ATH_MSG_DEBUG (
"ISSUE: " <<__LINE__);
1526 if (ithPos_neg != 0){
1527 ithSide = ithPos_neg / std::abs(ithPos_neg);
1529 if (upwards) incrementEta = ithSide;
1530 else incrementEta = ithSide * -1;
1532 if (ithEta_index==minEta_index&& incrementEta==-1){
1534 if (ithRegion == 0){
1535 nextPos_neg = 2*ithSide;
1536 nextPhi_index=2*ithPhi_index;
1537 if (ithSampling==1){
1542 else if (ithSampling==2){
1550 else if (ithRegion == 1){
1557 else if (ithEta_index==maxEta_index && incrementEta==1){
1565 else if (ithRegion==1)
return nullptr;
1570 nextEta_index=ithEta_index+incrementEta;
1572 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(nextSub_calo, nextPos_neg, ithSampling, nextRegion, nextEta_index, nextPhi_index);
1574 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__<<
" does not match");
1581 if (is64&&input_index<0)
return input_index+64;
1582 else if (is64&&input_index>63)
return input_index-64;
1583 else if (!(is64)&&input_index<0)
return input_index+32;
1584 else if (!(is64)&&input_index>31)
return input_index-32;
1585 else return input_index;
1592 if (inputCell==
nullptr)
1596 const int ithEta_index = idHelper->
eta(ithID);
1597 const int ithPhi_index = idHelper->
phi(ithID);
1598 const int ithSampling = idHelper->
sampling(ithID);
1599 const int ithSub_calo = idHelper->
sub_calo(ithID);
1600 const int ithPos_neg = idHelper->
pos_neg(ithID);
1601 const int ithRegion = idHelper->
region(ithID);
1604 if (abs(ithPos_neg)==3) is64 =
false;
1608 if (upwards==
true) incrementPhi=1;
1609 else incrementPhi=-1;
1611 const int nextPhi_index =
restrictPhiIndex(ithPhi_index+incrementPhi, is64);
1612 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(ithSub_calo, ithPos_neg, ithSampling, ithRegion, ithEta_index, nextPhi_index);
1614 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__ <<
" does not match");
1615 if (nextCell ==
nullptr)
ATH_MSG_DEBUG (
"Next phi cell is nullptr at " << __LINE__);
Scalar phi() const
phi method
#define ATH_MSG_DEBUG(x,...)
#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.