48std::vector<LVL1::EFexEMClusterTool::AlgResult>
54 std::vector<AlgResult> baselineClusters;
55 for (
auto & cluster :
looseAlg(scells, TTs, idHelper, tileIDHelper, tileCellCon) ) {
73 bool passBaseLineSelection = cluster.passClusterEnergy &&
78 if (applyBaselineCuts and not passBaseLineSelection ) {
82 baselineClusters.push_back(cluster);
84 return baselineClusters;
87std::vector<LVL1::EFexEMClusterTool::AlgResult>
92 std::vector<AlgResult>
result;
94 std::vector<const CaloCell*> potentialCentres;
95 for (
auto ithCell : *SCs) {
100 if (idHelper->
sampling(ithID) != 2) {
104 if (idHelper->
sub_calo(ithID) != 0) {
108 bool inEfexCoverage =
false;
109 if ( std::abs(idHelper->
pos_neg(ithID)) < 3) {
110 inEfexCoverage =
true;
113 if (!inEfexCoverage) {
118 potentialCentres.push_back(ithCell);
123 for (
auto ithCell : potentialCentres){
125 for (
auto jthCell : potentialCentres){
126 if (jthCell == ithCell)
continue;
127 if (!
SameTT(ithCell, jthCell, idHelper))
continue;
130 if (ithEt > jthEt)
continue;
131 if (ithEt == jthEt && ithCell->eta() > jthCell->eta())
continue;
141 float ithEta = ithCell->eta();
142 float ithPhi = ithCell->phi();
148 ithRHad =
RHadTile(ithCell,
m_etaEMWidth_RHadIsolation,
m_phiEMWidth_RHadIsolation, SCs, idHelper,
m_nominalDigitization,
m_nominalNoise_thresh, tileIDHelper, tileCellCon,
m_tileNoise_tresh, HadET);
156 float ithREtaL12{-1};
162 result.push_back(
AlgResult{ithEta, ithPhi, clustET, ithREta, ithRHad, ithL1Width, HadET, L2ClusterET33, L2ClusterET37, ithREtaL12});
175 if (inputCell==
nullptr)
return 0.;
179 if (!correctProv)
return 0.;
182 float inputCell_energy = inputCell->
energy();
183 float inputCell_eta = inputCell->
eta();
184 float inputCell_ET = inputCell_energy / cosh(inputCell_eta);
186 bool allowNegs =
false;
187 if (digitScale < 0.){
188 digitScale = std::abs(digitScale);
191 if (inputCell_ET==0)
return 0.;
192 else if (digitScale==0)
return inputCell_ET;
193 if (allowNegs || inputCell_ET>0.){
195 float posOrNeg = inputCell_ET / std::abs(inputCell_ET);
196 inputCell_ET = std::abs(inputCell_ET);
198 if (digitScale == 0){
199 if (inputCell_ET>digitThreshold)
return inputCell_ET*posOrNeg;
204 float divET = inputCell_ET / digitScale;
206 float result = digitScale * roundET;
207 if (digitThreshold == 0)
return result*posOrNeg;
208 else if (
result >= digitThreshold)
return result*posOrNeg;
219 int phi1 = idHelper->
phi(ID1);
221 int phi2 = idHelper->
phi(ID2);
225 int pn1 = idHelper->
pos_neg(ID1);
226 int pn2 = idHelper->
pos_neg(ID2);
232 int reg1 = idHelper->
region(ID1);
233 int reg2 = idHelper->
region(ID2);
237 int etaDiv1 = idHelper->
eta(ID1)/4;
238 int etaDiv2 = idHelper->
eta(ID2)/4;
239 if (etaDiv1 == etaDiv2) {
247 else if (abs(pn1)==2){
248 int reg1 = idHelper->
region(ID1);
249 int reg2 = idHelper->
region(ID2);
250 int eta1 = idHelper->
eta(ID1);
251 int eta2 = idHelper->
eta(ID2);
252 if ((reg1 == 0 && reg2 == 1 && eta2 < 3 ) || (reg2 == 0 && reg1 == 1 && eta1 < 3 ))
return true;
254 if (reg1 != reg2)
return false;
255 int etaDiv1 = (idHelper->
eta(ID1) - 3)/4;
256 int etaDiv2 = (idHelper->
eta(ID2) - 3)/4;
257 if (etaDiv1 == etaDiv2)
return true;
268 return localMax(inputContainer, inputCell, 0, idHelper, digitScale, digitThreshold);
275 if (inputCell ==
nullptr)
return false;
278 const int sub_calo = idHelper->
sub_calo(inputID);
279 const int pos_neg = idHelper->
pos_neg(inputID);
280 if (!(sub_calo == 0 || sub_calo == 1) || !(abs(pos_neg) < 4)){
284 double seedCandidateEnergy =
CaloCellET(inputCell, digitScale, digitThreshold);
285 int nCellsMoreEnergetic = 0;
287 if (leftCell !=
nullptr){
288 double leftEnergy =
CaloCellET(leftCell, digitScale, 0.);
289 if (leftEnergy>seedCandidateEnergy) nCellsMoreEnergetic++;
292 if (rightCell !=
nullptr){
293 double rightEnergy =
CaloCellET(rightCell, digitScale, 0.);
294 if (rightEnergy>=seedCandidateEnergy) nCellsMoreEnergetic++;
297 if (upCell !=
nullptr){
298 double upEnergy =
CaloCellET(upCell, digitScale, 0.);
299 if (upEnergy>=seedCandidateEnergy) nCellsMoreEnergetic++;
302 if (downCell !=
nullptr){
303 double downEnergy =
CaloCellET(downCell, digitScale, 0.);
304 if (downEnergy>seedCandidateEnergy) nCellsMoreEnergetic++;
306 if (upCell !=
nullptr){
308 if (upRightCell !=
nullptr){
309 double upRightEnergy =
CaloCellET(upRightCell, digitScale, 0.);
310 if (upRightEnergy>=seedCandidateEnergy) nCellsMoreEnergetic++;
313 if (upLeftCell !=
nullptr){
314 double upLeftEnergy =
CaloCellET(upLeftCell, digitScale, 0.);
315 if (upLeftEnergy>=seedCandidateEnergy) nCellsMoreEnergetic++;
318 if (downCell !=
nullptr){
320 if (downRightCell !=
nullptr){
321 double downRightEnergy =
CaloCellET(downRightCell, digitScale, 0.);
322 if (downRightEnergy>seedCandidateEnergy) nCellsMoreEnergetic++;
325 if (downLeftCell !=
nullptr){
326 double downLeftEnergy =
CaloCellET(downLeftCell, digitScale, 0.);
327 if (downLeftEnergy>seedCandidateEnergy) nCellsMoreEnergetic++;
331 if (nCellsMoreEnergetic <= numOthers)
return true;
338 if (inputCell==
nullptr)
return;
339 bool alreadyThere =
false;
340 for (
auto oCell : outputVector){
342 else if (inputCell->
ID() == oCell->ID()) alreadyThere=
true;
344 if (!alreadyThere) outputVector.push_back(inputCell);
352 std::vector<const CaloCell*> fullClus =
TDR_Clus(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale,digitThresh);
353 double EMcomp =
sumVectorET(fullClus, digitScale, digitThresh);
354 bool EMcheck =
checkDig(EMcomp, digitScale, digitThresh);
355 if (!EMcheck)
ATH_MSG_WARNING (
"EMcomp not digitised " << EMcomp <<
" " << digitScale <<
" " << digitThresh);
356 double total = EMcomp;
365 if (etaWidth1 > etaWidth2)
ATH_MSG_WARNING (
"REta: eta1 = " << etaWidth1 <<
", eta2 = " << etaWidth2);
366 if (phiWidth1 > phiWidth2)
ATH_MSG_WARNING (
"Rphi: phi1 = " << phiWidth1 <<
", phi2 = " << phiWidth2);
368 double inner_ET =
L2clusET(centreCell, etaWidth1, phiWidth1, scells, idHelper, digitScale, digitThresh);
369 double outer_ET =
L2clusET(centreCell, etaWidth2, phiWidth2, scells, idHelper, digitScale, digitThresh);
372 if (inner_ET != 0. && outer_ET==0.) normal_REta = 0.;
373 else if (inner_ET==0.) normal_REta = 0.;
374 else normal_REta = inner_ET / outer_ET;
375 if (normal_REta < 0) normal_REta = 0.;
376 double my_REta = 1-normal_REta;
384 std::vector<const CaloCell*> fullClus =
TDR_Clus(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale, digitThresh);
385 double EMcomp =
sumVectorET(fullClus, digitScale, digitThresh);
386 double HCALcomp =
HadronicET(
L2cluster(centreCell,
m_etaHadWidth_RHadIsolation,
m_phiHadWidth_RHadIsolation, scells, idHelper, digitScale, digitThresh), scells, TTContainer, idHelper, digitScale, digitThresh);
387 HadET = HCALcomp/1e3;
388 double result = HCALcomp/(EMcomp+HCALcomp);
389 if (result < 0. || result > 1.){
391 ATH_MSG_WARNING (
"fullClus count = " << fullClus.size() <<
", EMcomp = " << EMcomp <<
", HCALcomp = " << HCALcomp);
399 for (
auto ithCell : tileCellVector){
400 if (ithCell->ID() == inputCell->
ID()) isAlreadyThere =
true;
402 if (!isAlreadyThere) tileCellVector.push_back(inputCell);
408 if (eIn <= 0)
return 0.;
409 float eOut = eIn/cosh(etaIn);
410 if (tileNoiseThresh == 0.)
return eOut;
412 if (eOut > tileNoiseThresh)
return eOut;
420 float pos_neg = inEta/std::abs(inEta);
425 if (((
int)(std::abs(inEta)*10)) % 2 == 0) isEven =
true;
428 if (inEta < 0.1) inPos = 0;
429 else if (inEta > 0.8 && inEta < 0.9) inPos = 2;
431 if (isEven) inPos = 0;
437 if (inEta > -0.1) inPos = 1;
438 else if (inEta > -0.9 && inEta < -0.8) inPos = 2;
440 if (isEven) inPos = 1;
452 std::vector<const CaloCell*> L2cells =
L2cluster(centreCell, etaWidth, phiWidth, scells, idHelper,digitScale, digitThresh);
458 float oldPhi = centreCell->
phi();
460 std::vector<int> offsets;
461 std::vector<const CaloCell*> frontLayerCells;
462 for (
auto ithL2Cell : L2cells){
464 unsigned int oldsize = frontLayerCells.size();
468 unsigned int additions = frontLayerCells.size() - oldsize;
470 float dPhi = std::abs(ithL2Cell->phi() - oldPhi);
471 if (dPhi >
M_PI) dPhi = 2*
M_PI - dPhi;
474 oldPhi = ithL2Cell->phi();
477 int sign = (ithL2Cell->eta()-centreCell->
eta() > 0 ? 1 : -1);
479 for (
unsigned int adds = 0; adds < additions; ++adds) offsets.push_back(
sign*((
counter+1)/2));
484 float sumET = 0, sumET_Eta2=0;
485 unsigned int cellCount = 0;
487 for (std::vector<const CaloCell*>::iterator ithCell = frontLayerCells.begin(); ithCell != frontLayerCells.end(); ++ithCell){
490 int offset = (cellCount < offsets.size() ? offsets[cellCount] : -999);
491 if (offset < -2 || offset > 2) {
498 int pos_neg = idHelper->
pos_neg(cellID);
499 int region = idHelper->
region(cellID);
500 int eta_index = idHelper->
eta(cellID);
501 bool halfCell =
false;
502 if (abs(pos_neg) == 2 && region == 3 && (eta_index == 1 || eta_index == 4 || eta_index == 7 || eta_index == 10)) halfCell =
true;
505 float ithET =
CaloCellET((*ithCell), digitScale, digitThresh);
510 sumET_Eta2 += 0.5*ithET*
pow(offset,2);
514 if ((
int)cellCount-1 >= 0 && offsets[cellCount-1] == offset) {
515 auto ithPrev = std::prev(ithCell,1);
516 int sign = ((*ithCell)->eta() > (*ithPrev)->eta() ? 1 : -1);
517 int nextOffset = offset+
sign;
518 if (abs(nextOffset) <= 2) sumET_Eta2 += 0.5*ithET*
pow(nextOffset,2);
522 else if (cellCount+1 < offsets.size() && offsets[cellCount+1] == offset) {
523 auto ithNext = std::next(ithCell,1);
524 int sign = ((*ithCell)->eta() > (*ithNext)->eta() ? 1 : -1);
525 int nextOffset = offset+
sign;
526 if (abs(nextOffset) <= 2) sumET_Eta2 += 0.5*ithET*
pow(nextOffset,2);
530 sumET_Eta2 += ithET*
pow(offset,2);
538 if (sumET > 0.)
result = sumET_Eta2/sumET;
546 return sumVectorET(
L2cluster(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale, digitThresh), digitScale, digitThresh);
554 std::vector<float> outVec;
556 std::vector<const CaloCell*> L2Cells =
L2cluster(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale, digitThresh);
560 if (std::abs(centreCell->
eta()) < 1.57){
561 const int barrel_ec = idHelper->
pos_neg(centreCell->
ID());
563 if (std::abs(barrel_ec) == 2) isOW =
true;
564 std::vector<double> energyPerLayer =
EnergyPerTileLayer(L2Cells, tileCellCon, tileIDHelper, isOW, tileNoiseThresh);
565 if (energyPerLayer.size() > 0){
566 for (
auto ithLayerEnergy : energyPerLayer){
567 HadET += ithLayerEnergy;
572 std::vector<const CaloCell*> HCAL_LAr_vector;
573 for (
auto ithCell : L2Cells){
574 if (std::abs(ithCell->eta()) > 2.5)
continue;
576 if (tempLArHad !=
nullptr) HCAL_LAr_vector.push_back(tempLArHad);
578 for (
auto ithSC : HCAL_LAr_vector){
579 HadET +=
CaloCellET(ithSC, digitScale, digitThresh);
583 double EMcomp =
sumVectorET(fullClus, digitScale, digitThresh);
584 double result = HadET/(EMcomp+HadET);
585 if (result < 0. || result > 1.){
587 ATH_MSG_WARNING (
"fullClus count = " << fullClus.size() <<
", EMcomp = " << EMcomp <<
", HCALcomp = " << HadET);
596 float digitScale,
float digitThresh)
const
599 if (etaWidth1 > etaWidth2)
ATH_MSG_WARNING (
"REta: eta1 = " << etaWidth1 <<
", eta2 = " << etaWidth2);
600 if (phiWidth1 > phiWidth2)
ATH_MSG_WARNING (
"Rphi: phi1 = " << phiWidth1 <<
", phi2 = " << phiWidth2);
602 double inner_ET =
L2clusET(centreCell, etaWidth1, phiWidth1, scells, idHelper, digitScale, digitThresh);
603 double outer_ET =
L2clusET(centreCell, etaWidth2, phiWidth2, scells, idHelper, digitScale, digitThresh);
605 std::vector<const CaloCell*> L2cells_inner =
L2cluster(centreCell, etaWidth1, phiWidth1, scells, idHelper,digitScale, digitThresh);
606 std::vector<const CaloCell*> L1cells_inner;
607 for (
auto ithL2Cell : L2cells_inner){
610 inner_ET +=
sumVectorET(L1cells_inner, digitScale, digitThresh);
611 std::vector<const CaloCell*> L2cells_outer =
L2cluster(centreCell, etaWidth2, phiWidth2, scells, idHelper,digitScale, digitThresh);
612 std::vector<const CaloCell*> L1cells_outer;
613 for (
auto ithL2Cell : L2cells_outer){
616 outer_ET +=
sumVectorET(L1cells_outer, digitScale, digitThresh);
619 if (inner_ET != 0. && outer_ET==0.) normal_REta = 0.;
620 else if (inner_ET==0.) normal_REta = 0.;
621 else normal_REta = inner_ET / outer_ET;
622 if (normal_REta < 0) normal_REta = 0.;
623 double my_REta = 1-normal_REta;
631 if (inputCell==
nullptr)
return;
634 int sampling = idHelper->
sampling(inputID);
635 const int sub_calo = idHelper->
sub_calo(inputID);
636 int pos_neg = idHelper->
pos_neg(inputID);
637 int region = idHelper->
region(inputID);
638 int eta_index = idHelper->
eta(inputID);
639 const int phi_index = idHelper->
phi(inputID);
641 if (sampling != 2)
return;
643 int outputRegion = region;
644 int outputEta = eta_index;
645 bool oneCell =
false;
647 if ((abs(pos_neg) == 1)&&(region == 0)){
652 else if ((abs(pos_neg) == 1)&&(region == 1)){
667 else if (abs(pos_neg)==2 && region == 0) {
672 else if (abs(pos_neg)==2&&((region==1 && eta_index < 2))){
675 outputEta = eta_index + 1;
676 pos_neg /= abs(pos_neg);
680 else if (abs(pos_neg)==2&&((region==1 && eta_index == 2))){
687 else if (abs(pos_neg)==2&®ion==1 && eta_index <= 14){
691 outputEta = eta_index - 3;
695 else if (abs(pos_neg) == 2 && region == 1 && eta_index <= 22){
702 if (eta_index%4 == 0 || eta_index%4 ==1){
705 if (eta_index < 20) outputEta = eta_index -14;
706 else outputEta = eta_index - 12;
712 if (eta_index == 15) offset = 15;
713 else if (eta_index == 18) offset = 14;
714 else if (eta_index == 19) offset = 13;
715 else if (eta_index == 22) offset = 12;
719 for (
unsigned int i = 0; i < 2; i++){
720 outputEta = i+eta_index - offset;
721 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 1, outputRegion, outputEta, phi_index);
723 addOnce(resultCell,outputVector);
728 else if (abs(pos_neg)==2 && region == 1 && eta_index <= 38){
733 outputEta = eta_index - 23;
736 else if (abs(pos_neg)==2 && region == 1 && eta_index == 40){
747 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 1, outputRegion, outputEta, phi_index);
749 addOnce(resultCell,outputVector);
751 ATH_MSG_DEBUG(
"L2->L1: sampling = " << sampling <<
", region = " << region <<
", eta = " << pos_neg*eta_index<<
" tracker = " << tracker);
759 if ( inputCell ==
nullptr )
return nullptr;
760 const CaloCell* resultCell =
nullptr;
762 int sampling = idHelper->
sampling(inputID);
763 const int sub_calo = idHelper->
sub_calo(inputID);
764 const int pos_neg = idHelper->
pos_neg(inputID);
765 int region = idHelper->
region(inputID);
766 int eta_index = idHelper->
eta(inputID);
767 const int phi_index = idHelper->
phi(inputID);
768 if (sampling != 2)
return nullptr;
769 else if (abs(pos_neg)==1 && ((region==0 && eta_index>53)||region==1))
return nullptr;
770 else if ((abs(pos_neg)==2) && (region == 0 || (region == 1 && eta_index < 3)))
return nullptr;
771 else if (abs(pos_neg)==3)
return nullptr;
773 int outputRegion = region;
774 int outputEta = eta_index;
776 if (abs(pos_neg)==1 && region ==0){
777 int outputEta = eta_index/4;
778 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 3, outputRegion, outputEta, phi_index);
783 else if (abs(pos_neg)==1 && region ==1) {
784 int output_pos_neg = pos_neg*2;
787 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, output_pos_neg, 2, outputRegion, outputEta, phi_index);
792 else if (abs(pos_neg)==2 && region ==1){
793 outputEta = (eta_index - 3)/4;
795 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 3, outputRegion, outputEta, phi_index);
799 ATH_MSG_DEBUG(
"L2->L3: sampling = " << sampling <<
", region = " << region <<
", eta = " << pos_neg*eta_index<<
" tracker = " << tracker);
807 if (inputCell==
nullptr)
return nullptr;
808 const CaloCell* resultCell =
nullptr;
810 int sampling = idHelper->
sampling(inputID);
811 const int sub_calo = idHelper->
sub_calo(inputID);
812 const int pos_neg = idHelper->
pos_neg(inputID);
813 int region = idHelper->
region(inputID);
814 int eta_index = idHelper->
eta(inputID);
815 const int phi_index = idHelper->
phi(inputID);
816 if (sampling != 2)
return nullptr;
817 if (abs(pos_neg)==2 && (eta_index<3 || eta_index>14))
return nullptr;
818 if (abs(pos_neg)==3)
return nullptr;
820 int outputRegion = region;
821 int outputEta = eta_index;
823 if (abs(pos_neg)==1 && region ==0){
824 int outputEta = eta_index/4;
825 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 0, outputRegion, outputEta, phi_index);
828 else if (abs(pos_neg)==1 && region ==1){
829 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 0, 0, 14, phi_index);
832 else if (abs(pos_neg)==2 && region ==1){
833 outputEta = (eta_index - 3)/4;
835 Identifier resultID = idHelper->CaloCell_SuperCell_ID::cell_id(sub_calo, pos_neg, 0, outputRegion, outputEta, phi_index);
841std::vector<const CaloCell*>
846 std::vector<const CaloCell*> centCells;
847 centCells.push_back(centreCell);
852 if (
CaloCellET(upPhiCell, digitScale, digitThresh) >
CaloCellET(downPhiCell, digitScale, digitThresh)) energeticPhiCell = upPhiCell;
853 else energeticPhiCell = downPhiCell;
854 if (phiWidth == 2)
addOnce(energeticPhiCell, centCells);
855 else if (phiWidth == 3){
857 addOnce(downPhiCell, centCells);
859 else if (phiWidth > 3) {
863 std::vector<const CaloCell*> clusCells;
864 int halfEtaWidth = (etaWidth-1)/2;
865 int backToEta = (2*halfEtaWidth)+1;
866 if (backToEta != etaWidth) {
867 ATH_MSG_DEBUG (
"Eta width doesn't match! " << backToEta <<
" -> " << halfEtaWidth <<
" -> " << etaWidth <<
" " << __LINE__);
869 for (
auto ithCentCell : centCells){
870 addOnce(ithCentCell, clusCells);
874 addOnce(tempRightCell, clusCells);
875 addOnce(tempLeftCell, clusCells);
876 for (
int i = 1; i < halfEtaWidth; i++){
877 tempRightCell =
NextEtaCell(tempRightCell,
true,scells,idHelper);
878 tempLeftCell =
NextEtaCell(tempLeftCell,
false,scells,idHelper);
879 addOnce(tempRightCell, clusCells);
880 addOnce(tempLeftCell, clusCells);
889 const TileID* tileIDHelper,
bool isOW,
float tileNoiseThresh)
const
891 std::vector<double> layerEnergy;
892 if (CellCon==
nullptr)
return layerEnergy;
893 if (CellCon->
size()==0)
return layerEnergy;
894 if (inputSCVector.size()==0)
return layerEnergy;
895 double ELayer0 = 0, ELayer1 = 0, ELayer2 = 0;
896 std::vector<const TileCell*> tileCellVector;
897 for (
auto ithSC : inputSCVector){
898 float ithSCEta = ithSC->eta();
899 float ithSCPhi = ithSC->phi();
900 int matchingCells = 0;
903 for ( ; fCell != lCell; ++fCell){
909 int layer = tileIDHelper->
sample(tileCell->
ID());
910 float ithdR =
dR(tileCell->
eta(), tileCell->
phi(), ithSCEta, ithSCPhi);
912 float matchingDistance = 0.;
913 if (isOW && (std::abs(ithSCEta) > 1.38 && std::abs(ithSCEta) < 1.42)) matchingDistance = 0.065;
914 else matchingDistance = 0.05;
915 if (ithdR <= matchingDistance){
916 bool isAlreadyThere =
false;
918 if (isAlreadyThere)
continue;
924 else if (layer == 2){
925 float matchingDistance = 0.;
926 if (std::abs(ithSCEta) > 0.7 && std::abs(ithSCEta) < 0.8) matchingDistance = 0.05;
927 else if (std::abs(ithSCEta) > 0.9 && std::abs(ithSCEta) < 1.0) matchingDistance = 0.05;
928 else matchingDistance = 0.09;
929 if (ithdR < matchingDistance){
930 bool isAlreadyThere =
false;
932 if (isAlreadyThere)
continue;
947 if ((matchingCells > 3 && !isOW) || (matchingCells > 3 && isOW && std::abs(ithSCEta) > 1.42) || (matchingCells > 4 && isOW && std::abs(ithSCEta) < 1.42)){
949 ATH_MSG_WARNING (
"Input SC: (eta,phi) = (" << ithSCEta <<
"," << ithSCPhi <<
")");
950 for (
auto cell : tileCellVector){
951 ATH_MSG_WARNING (
"Tile cell: (eta,phi) = (" << cell->eta() <<
"," << cell->phi() <<
")" <<
" dR = " <<
dR(cell->eta(), cell->phi(), ithSCEta, ithSCPhi) <<
" layer = " << tileIDHelper->
sample(cell->ID()));
957 layerEnergy = {ELayer0, ELayer1, ELayer2};
964 if (inputTower ==
nullptr){
969 double phi = inputTower->
phi();
978 double etaDif = eta1 - eta2;
979 double phiDif = std::abs(phi1 - phi2);
980 if (phiDif >
M_PI) phiDif = phiDif - (2*
M_PI);
988 std::vector<const xAOD::TriggerTower*> matchingTTs;
989 if (TTContainer==
nullptr)
return nullptr;
990 if (TTContainer->
size()==0)
return nullptr;
991 if (inputCell==
nullptr)
return nullptr;
992 for (
auto ithTT : *TTContainer){
993 if (ithTT->sampling()==1){
994 float ithTT_eta = ithTT->eta();
995 float ithTT_phi =
TT_phi(ithTT);
996 float ithdR =
dR(ithTT_eta, ithTT_phi, inputCell->
eta(), inputCell->
phi());
997 if (ithdR < 0.05) matchingTTs.push_back(ithTT);
1000 if (matchingTTs.size()==1)
return matchingTTs[0];
1001 else if (matchingTTs.size()!=0){
1002 ATH_MSG_WARNING (
"More than one matching HCAL TT!!! (Returned Null)");
1010 std::vector<const CaloCell*> matchingCells;
1011 if (inputCell==
nullptr)
return nullptr;
1012 for (
auto ithSC : *SCContainer){
1014 int ithSub_calo = idHelper->
sub_calo(ithID);
1015 if (ithSub_calo == 1){
1016 double ithdR =
dR(inputCell->
eta(), inputCell->
phi(), ithSC->eta(), ithSC->phi());
1017 if (ithdR < 0.05) matchingCells.push_back(ithSC);
1021 if (matchingCells.size()==1)
1022 return matchingCells[0];
1025 if (matchingCells.size()==0){
1027 ATH_MSG_WARNING (
"No match betweem LAr ECAL SC and LAr HCAL SC!!! Input coords: " << inputCell->
eta() <<
", " << inputCell->
phi());
1029 }
else if (matchingCells.size()!=0) {
1031 ATH_MSG_WARNING (
"More than one matching LAr HCAL SC!!! (Returned Null)");
1033 for (
auto ithMatch : matchingCells){
1034 ATH_MSG_WARNING (
" " << ithMatch->eta() <<
" x " << ithMatch->phi() <<
", dR = "
1035 <<
dR(inputCell->
eta(), inputCell->
phi(), ithMatch->eta(), ithMatch->phi()));
1044 if (inputTower ==
nullptr){
1048 else if (inputTower->
cpET() < 0.) {
1051 return 500*inputTower->
cpET();
1055std::vector<const CaloCell*>
1060 std::vector<const CaloCell*> L2cells =
L2cluster(centreCell, etaWidth, phiWidth, scells, idHelper, digitScale, digitThresh);
1062 std::vector<const CaloCell*> centCells;
1063 centCells.push_back(centreCell);
1070 if (
CaloCellET(upPhiCell, digitScale, digitThresh) >
CaloCellET(downPhiCell, digitScale, digitThresh)) energeticPhiCell = upPhiCell;
1071 else energeticPhiCell = downPhiCell;
1072 if (phiWidth == 2)
addOnce(energeticPhiCell, centCells);
1073 else if (phiWidth == 3){
1074 addOnce(upPhiCell, centCells);
1075 addOnce(downPhiCell, centCells);
1077 else if (phiWidth > 3)
ATH_MSG_WARNING (
"phiWidth not 2 or 3!!!. Value = " << phiWidth);
1080 std::vector<const CaloCell*> fullClus;
1082 for (
auto ithL2Cell : L2cells){
1083 fullClus.push_back(ithL2Cell);
1087 for (
auto ithL2CentCell : centCells){
1098 for (
auto ithCell : inputVector){
1099 if (ithCell!=
nullptr) TotalET +=
CaloCellET(ithCell, digitScale, digitThreshold);
1107 if (EM_ET == 0 || digitScale == 0)
return true;
1109 int div = EM_ET / digitScale;
1110 if (div * digitScale == EM_ET)
return true;
1112 ATH_MSG_WARNING (
"ET = " << EM_ET <<
", digitThresh = " << digitThresh <<
" digitScale = " << digitScale <<
" div = " << div <<
" " <<
" -> div * digitScale");
1121 float digitScale,
float digitThresh)
const
1124 std::vector<const CaloCell*> HCAL_LAr_vector;
1125 std::vector<const xAOD::TriggerTower*> HCAL_TT_vector;
1126 for (
auto ithCell : inputVector){
1127 if (std::abs(ithCell->eta())<1.5){
1129 if (tempTT !=
nullptr) HCAL_TT_vector.push_back(tempTT);
1131 else if (std::abs(ithCell->eta())<2.5){
1133 if (tempLArHad !=
nullptr) HCAL_LAr_vector.push_back(tempLArHad);
1138 for (
auto ithTT : HCAL_TT_vector) {HadET +=
TT_ET(ithTT);}
1139 for (
auto ithSC : HCAL_LAr_vector) {HadET +=
CaloCellET(ithSC, digitScale, digitThresh);}
1150 const CaloCell* isCell = cellContainer->
findCell(idHelper->CaloCell_SuperCell_ID::calo_cell_hash(inputID));
1151 if (isCell)
return isCell;
1152 else return nullptr;
1159 if (inputCell==
nullptr)
return nullptr;
1161 int ithSub_calo = idHelper->
sub_calo(ithID);
1162 int ithPos_neg = idHelper->
pos_neg(ithID);
1163 const CaloCell* tempCell =
nullptr;
1165 if (ithSub_calo==0){
1167 if (abs(ithPos_neg)==1) tempCell =
NextEtaCell_Barrel(inputCell, upwards, cellContainer, idHelper);
1169 else if (abs(ithPos_neg)==2) tempCell =
NextEtaCell_OW(inputCell, upwards, cellContainer, idHelper);
1171 else if (abs(ithPos_neg)==3) tempCell =
NextEtaCell_IW(inputCell, upwards, cellContainer, idHelper);
1174 ATH_MSG_WARNING (
"Layer 2 cell not passed to specific method at" << inputCell->
eta() <<
" , " << inputCell->
phi());
1191 const int ithEta_index = idHelper->
eta(ithID);
1192 const int ithPhi_index = idHelper->
phi(ithID);
1193 const int ithSampling = idHelper->
sampling(ithID);
1194 const int ithSub_calo = idHelper->
sub_calo(ithID);
1195 const int ithPos_neg = idHelper->
pos_neg(ithID);
1196 const int ithRegion = idHelper->
region(ithID);
1199 int maxEta_index = 0;
1200 int minEta_index = 0;
1202 if (ithSampling == 0) maxEta_index = 14;
1203 else if (ithSampling == 1 || ithSampling == 2) maxEta_index = 55;
1204 else if (ithSampling == 3) maxEta_index = 13;
1207 else if (ithRegion==1){
1208 if (ithSampling == 1) maxEta_index =2;
1209 else if (ithSampling == 2) maxEta_index=0;
1214 int nextEta_index = ithEta_index;
1217 int nextSampling = ithSampling;
1218 int nextSub_calo = ithSub_calo;
1219 int nextPos_neg = ithPos_neg;
1220 int nextRegion = ithRegion;
1224 if (upwards) incrementEta = ithPos_neg;
1225 else incrementEta = -1*ithPos_neg;
1230 if (ithEta_index==minEta_index && incrementEta==-1){
1231 if (ithRegion == 0){
1233 nextPos_neg = ithPos_neg * -1;
1236 else if (ithRegion == 1){
1245 else if ((ithEta_index == maxEta_index) && (incrementEta == 1)) {
1247 if ((ithRegion == 0)&&(ithSampling == 1 || ithSampling == 2)){
1253 else if ((ithRegion == 0)&&(ithSampling == 0)){
1256 nextPos_neg = 2*ithPos_neg;
1260 else if ((ithRegion == 0)&&(ithSampling == 3)){
1264 nextPos_neg = 2*ithPos_neg;
1268 else if ((ithRegion == 1)&&(ithSampling == 1)){
1271 nextPos_neg = 2 * ithPos_neg;
1275 else if ((ithRegion == 1)&&(ithSampling == 2)){
1278 nextPos_neg = 2 * ithPos_neg;
1285 nextEta_index = ithEta_index + incrementEta;
1291 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(nextSub_calo, nextPos_neg, nextSampling, nextRegion, nextEta_index, ithPhi_index);
1293 if (nextCell ==
nullptr) {
1296 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);
1300 int IDsample = idHelper->
sampling(nextCell->
ID());
1302 if (IDsample!=ithSampling){
1303 ATH_MSG_DEBUG (
"Layer has changed " <<
" tracker = " << tracker);
1304 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);
1309 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__ <<
" does not match");
1318 int ithEta_index = idHelper->
eta(ithID);
1319 const int ithPhi_index = idHelper->
phi(ithID);
1320 const int ithSampling = idHelper->
sampling(ithID);
1321 int ithSub_calo = idHelper->
sub_calo(ithID);
1322 int ithPos_neg = idHelper->
pos_neg(ithID);
1323 int ithRegion = idHelper->
region(ithID);
1325 int nextEta_index = ithEta_index;
1326 int nextPhi_index = ithPhi_index;
1328 int nextSampling = ithSampling;
1329 int nextSub_calo = ithSub_calo;
1330 int nextPos_neg = ithPos_neg;
1331 int nextRegion = ithRegion;
1333 int maxEta_index = 0;
1334 int minEta_index = 0;
1336 if (ithSampling==0) maxEta_index = 2;
1337 else if (ithSampling==2 && ithRegion==0) maxEta_index = 0;
1338 else if (ithSampling==2 && ithRegion==1) maxEta_index = 42;
1339 else if (ithSampling==3) maxEta_index=9;
1340 else if (ithSampling==1) {
1368 int ithSide = ithPos_neg / abs(ithPos_neg);
1369 if (upwards) incrementEta = ithSide;
1370 else incrementEta = ithSide * -1;
1373 if (ithEta_index==minEta_index && ithRegion==0 && incrementEta==-1){
1374 nextPos_neg = ithSide;
1375 if (ithSampling==0){
1380 else if (ithSampling==1){
1386 else if (ithSampling==2){
1393 else if (ithSampling==3){
1397 nextPos_neg = ithPos_neg;
1402 else if (ithEta_index==maxEta_index && incrementEta==1){
1404 if (ithSampling==0 || ithSampling==3)
return nullptr;
1405 else if (ithSampling==2 && ithRegion==0){
1410 else if ((ithSampling==2 && ithRegion==1)||(ithSampling==1 && ithRegion==5)){
1414 nextPhi_index=ithPhi_index/2;
1415 nextPos_neg=3*ithSide;
1418 else if (ithSampling==1 && ithRegion==0){
1424 else if (ithSampling==1){
1425 nextRegion=ithRegion + 1;
1431 else if (ithEta_index==minEta_index && incrementEta==-1){
1435 if (ithSampling==2){
1438 nextPos_neg = ithPos_neg;
1441 else if (ithSampling==1){
1443 nextPos_neg = ithSide;
1451 nextRegion = ithRegion-1;
1452 if (nextRegion==0) {
1456 else if (nextRegion==1) {
1460 else if (nextRegion==2) nextEta_index=11;
1461 else if (nextRegion==3) nextEta_index=7;
1462 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__);
1525 int ithSide = ithPos_neg / abs(ithPos_neg);
1526 if (upwards) incrementEta = ithSide;
1527 else incrementEta = ithSide * -1;
1529 if (ithEta_index==minEta_index&& incrementEta==-1){
1531 if (ithRegion == 0){
1532 nextPos_neg = 2*ithSide;
1533 nextPhi_index=2*ithPhi_index;
1534 if (ithSampling==1){
1539 else if (ithSampling==2){
1547 else if (ithRegion == 1){
1554 else if (ithEta_index==maxEta_index && incrementEta==1){
1562 else if (ithRegion==1)
return nullptr;
1567 nextEta_index=ithEta_index+incrementEta;
1569 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(nextSub_calo, nextPos_neg, ithSampling, nextRegion, nextEta_index, nextPhi_index);
1571 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__<<
" does not match");
1578 if (is64&&input_index<0)
return input_index+64;
1579 else if (is64&&input_index>63)
return input_index-64;
1580 else if (!(is64)&&input_index<0)
return input_index+32;
1581 else if (!(is64)&&input_index>31)
return input_index-32;
1582 else return input_index;
1589 if (inputCell==
nullptr)
1593 const int ithEta_index = idHelper->
eta(ithID);
1594 const int ithPhi_index = idHelper->
phi(ithID);
1595 const int ithSampling = idHelper->
sampling(ithID);
1596 const int ithSub_calo = idHelper->
sub_calo(ithID);
1597 const int ithPos_neg = idHelper->
pos_neg(ithID);
1598 const int ithRegion = idHelper->
region(ithID);
1601 if (abs(ithPos_neg)==3) is64 =
false;
1605 if (upwards==
true) incrementPhi=1;
1606 else incrementPhi=-1;
1608 const int nextPhi_index =
restrictPhiIndex(ithPhi_index+incrementPhi, is64);
1609 Identifier nextCellID = idHelper->CaloCell_SuperCell_ID::cell_id(ithSub_calo, ithPos_neg, ithSampling, ithRegion, ithEta_index, nextPhi_index);
1611 if (nextCell && (nextCell->
ID() != nextCellID))
ATH_MSG_DEBUG ( __LINE__ <<
" does not match");
1612 if (nextCell ==
nullptr)
ATH_MSG_DEBUG (
"Next phi cell is nullptr at " << __LINE__);
Scalar phi() const
phi method
#define ATH_MSG_WARNING(x)
constexpr int pow(int base, int exp) noexcept
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.