Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-01 06:11:54

0001 #include <cmath>
0002 #include <cstdint>
0003 #include <cstdlib>
0004 #include <iomanip>
0005 #include <iostream>
0006 #include <vector>
0007 
0008 using namespace std;
0009 
0010 #include "UCTSummaryCard.hh"
0011 #include "UCTObject.hh"
0012 #include "UCTLayer1.hh"
0013 #include "UCTCrate.hh"
0014 #include "UCTCard.hh"
0015 #include "UCTRegion.hh"
0016 #include "UCTGeometry.hh"
0017 #include "UCTLogging.hh"
0018 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
0019 
0020 using namespace l1tcalo;
0021 
0022 UCTSummaryCard::UCTSummaryCard(const std::vector<std::vector<std::vector<uint32_t> > >* l,
0023                                uint32_t jetSeedIn,
0024                                uint32_t tauSeedIn,
0025                                double tauIsolationFactorIn,
0026                                uint32_t eGammaSeedIn,
0027                                double eGammaIsolationFactorIn)
0028     : pumLUT(l),
0029       jetSeed(jetSeedIn),
0030       tauSeed(tauSeedIn),
0031       tauIsolationFactor(tauIsolationFactorIn),
0032       eGammaSeed(tauSeedIn),
0033       eGammaIsolationFactor(tauIsolationFactorIn) {
0034   UCTGeometry g;
0035   sinPhi[0] = 0;
0036   cosPhi[0] = 1;
0037   for (int iPhi = 1; iPhi <= 72; iPhi++) {
0038     sinPhi[iPhi] = sin(g.getUCTTowerPhi(iPhi));
0039     cosPhi[iPhi] = cos(g.getUCTTowerPhi(iPhi));
0040   }
0041 }
0042 
0043 bool UCTSummaryCard::process() {
0044   clearEvent();
0045   UCTGeometry g;
0046   uint32_t etValue = 0;
0047   uint32_t htValue = 0;
0048   int sumEx = 0;
0049   int sumEy = 0;
0050   int sumHx = 0;
0051   int sumHy = 0;
0052   int etaMin = -NRegionsInCard;
0053   int etaMax = NRegionsInCard;
0054   // Determine pumLevel using only the central regions
0055   pumLevel = 0;
0056   for (int iEta = etaMin; iEta <= etaMax; iEta++) {  // Ranging between -7 to 7
0057     if (iEta == 0)
0058       continue;                                                 // Note that eta == 0 is illegal
0059     for (uint32_t iPhi = 0; iPhi < MaxUCTRegionsPhi; iPhi++) {  // Note that phi ranges from 0 to 17
0060       const UCTRegion* uctRegion = getRegion(iEta, iPhi);
0061       uint32_t et = uctRegion->et();
0062       if (et > 0)
0063         pumLevel++;
0064     }
0065   }
0066   uint32_t totalRegionCount = 2 * etaMax * MaxUCTRegionsPhi;
0067   uint32_t pumBinSize = totalRegionCount / pumLUT->size();
0068   pumBin = floor(pumLevel / pumBinSize);
0069   if (pumBin >= pumLUT->size())
0070     pumBin = pumLUT->size() - 1;  // Max index
0071   // We walk the eta-phi plane looping over all regions.
0072   // to make global objects like TotalET, HT, MET, MHT
0073   // subtracting pileup along the way
0074   // For compact objects we use processRegion(regionIndex)
0075   uint32_t pileup = 0;
0076   uint32_t et = 0;
0077   for (uint32_t side = 0; side < 2; side++) {
0078     bool negativeSide = true;
0079     if (side == 1)
0080       negativeSide = false;
0081     for (uint32_t crate = 0; crate < g.getNCrates(); crate++) {
0082       for (uint32_t card = 0; card < g.getNCards(); card++) {
0083         for (uint32_t region = 0; region < NRegionsInCard; region++) {
0084           int iEta = g.getUCTRegionEtaIndex(negativeSide, region);
0085           uint32_t iPhi = g.getUCTRegionPhiIndex(crate, card);
0086           UCTRegionIndex regionIndex(iEta, iPhi);
0087           processRegion(regionIndex);
0088           const UCTRegion* uctRegion = getRegion(iEta, iPhi);
0089           if (uctRegion == nullptr) {
0090             continue;
0091           }
0092           et = uctRegion->et();
0093           uint32_t pileupInRegion = (*pumLUT)[pumBin][side][region];
0094           pileup += pileupInRegion;
0095           if (pileupInRegion < et)
0096             et -= pileupInRegion;
0097           else
0098             et = 0;
0099           UCTTowerIndex hitTower = g.getUCTTowerIndexFromL1CaloRegion(regionIndex, uctRegion->rawData());
0100           int hitCaloPhi = hitTower.second;
0101           sumEx += ((int)(((double)et) * cosPhi[hitCaloPhi]));
0102           sumEy += ((int)(((double)et) * sinPhi[hitCaloPhi]));
0103           etValue += et;
0104           if (et > 10) {
0105             sumHx += ((int)(((double)et) * cosPhi[hitCaloPhi]));
0106             sumHy += ((int)(((double)et) * sinPhi[hitCaloPhi]));
0107             htValue += et;
0108           }
0109         }
0110       }
0111     }
0112   }
0113   uint32_t metSquare = sumEx * sumEx + sumEy * sumEy;
0114   uint32_t metValue = sqrt((double)metSquare);
0115   double metPhi = (atan2(sumEy, sumEx) * 180. / 3.1415927) + 180.;
0116   int metIPhi = (int)(72. * (metPhi / 360.));
0117   uint32_t mhtSquare = sumHx * sumHx + sumHy * sumHy;
0118   uint32_t mhtValue = sqrt((double)mhtSquare);
0119   double mhtPhi = (atan2(sumHy, sumHx) * 180. / 3.1415927) + 180.;
0120   int mhtIPhi = (int)(72. * (mhtPhi / 360.));
0121 
0122   ET = std::make_shared<UCTObject>(UCTObject::ET, etValue, 0, metIPhi, pileup, 0, 0);
0123   HT = std::make_shared<UCTObject>(UCTObject::HT, htValue, 0, mhtIPhi, pileup, 0, 0);
0124   MET = std::make_shared<UCTObject>(UCTObject::MET, metValue, 0, metIPhi, pileup, 0, 0);
0125   MHT = std::make_shared<UCTObject>(UCTObject::MHT, mhtValue, 0, mhtIPhi, pileup, 0, 0);
0126 
0127   // Then sort the candidates for output usage
0128   emObjs.sort();
0129   isoEMObjs.sort();
0130   tauObjs.sort();
0131   isoTauObjs.sort();
0132   centralJetObjs.sort();
0133   forwardJetObjs.sort();
0134   boostedJetObjs.sort();
0135   // Cool we never fail :)
0136   return true;
0137 }
0138 
0139 bool UCTSummaryCard::processRegion(UCTRegionIndex center) {
0140   // We process the region looking at nearest neighbor data
0141   // We should never need beyond nearest-neighbor for most
0142   // objects - eGamma, tau or jet
0143 
0144   std::vector<uint32_t> boostedJetTowers;
0145   boostedJetTowers.clear();
0146   for (size_t iPhi = 0; iPhi < 12; iPhi++) {
0147     for (size_t iEta = 0; iEta < 12; iEta++) {
0148       boostedJetTowers.push_back(0);
0149     }
0150   }
0151 
0152   std::vector<uint32_t> boostedJetRegionET, boostedJetRegionTauVeto;
0153   boostedJetRegionET.clear();
0154   boostedJetRegionTauVeto.clear();
0155   for (size_t i = 0; i < 9; i++) {
0156     boostedJetRegionET.push_back(0);
0157     boostedJetRegionTauVeto.push_back(0);
0158   }
0159 
0160   UCTGeometryExtended g;
0161 
0162   const UCTRegion* cRegion = getRegion(center.first, center.second);
0163   if (cRegion == nullptr) {
0164     return false;
0165   }
0166 
0167   // Central jets do not use HF - note border exclusion
0168   bool centralRegion = false;
0169   if (cRegion->getRegion() < (NRegionsInCard - 1))
0170     centralRegion = true;
0171 
0172   uint32_t centralET = cRegion->et();
0173   uint32_t centralPU = std::min(centralET, (*pumLUT)[pumBin][0][cRegion->getRegion()]);
0174   if (!cRegion->isNegativeEta())
0175     centralPU = std::min(centralET, (*pumLUT)[pumBin][1][cRegion->getRegion()]);
0176   centralET -= centralPU;
0177   UCTTowerIndex centralHitTower = g.getUCTTowerIndexFromL1CaloRegion(center, cRegion->rawData());
0178   int nTauLike = 0;
0179   bool centralIsTauLike = cRegion->isTauLike();
0180   if (cRegion->isTauLike())
0181     nTauLike++;
0182   bool centralIsEGammaLike = cRegion->isEGammaLike();
0183   int hitCaloEta = centralHitTower.first;
0184   int hitCaloPhi = centralHitTower.second;
0185 
0186   boostedJetRegionET[4] = centralET;
0187   boostedJetRegionTauVeto[4] = cRegion->isTauLike();
0188 
0189   UCTRegionIndex northIndex = g.getUCTRegionNorth(center);
0190   const UCTRegion* northRegion = getRegion(northIndex.first, northIndex.second);
0191   uint32_t northET = 0;
0192   uint32_t northPU = 0;
0193   UCTTowerIndex northHitTower;
0194   bool northIsTauLike = false;
0195   bool northIsEGammaLike = false;
0196   if (northRegion != nullptr) {
0197     northET = northRegion->et();
0198     northPU = std::min(northET, (*pumLUT)[pumBin][0][northRegion->getRegion()]);
0199     if (!northRegion->isNegativeEta())
0200       northPU = std::min(northET, (*pumLUT)[pumBin][1][northRegion->getRegion()]);
0201     northET -= northPU;
0202     northHitTower = g.getUCTTowerIndexFromL1CaloRegion(northIndex, northRegion->rawData());
0203     northIsTauLike = northRegion->isTauLike();
0204     if (northRegion->isTauLike())
0205       nTauLike++;
0206     northIsEGammaLike = northRegion->isEGammaLike();
0207     boostedJetRegionET[3] = northET;
0208     boostedJetRegionTauVeto[3] = northRegion->isTauLike();
0209   }
0210 
0211   UCTRegionIndex southIndex = g.getUCTRegionSouth(center);
0212   const UCTRegion* southRegion = getRegion(southIndex.first, southIndex.second);
0213   uint32_t southET = 0;
0214   uint32_t southPU = 0;
0215   UCTTowerIndex southHitTower;
0216   bool southIsTauLike = false;
0217   bool southIsEGammaLike = false;
0218   if (southRegion != nullptr) {
0219     southET = southRegion->et();
0220     southPU = std::min(southET, (*pumLUT)[pumBin][0][southRegion->getRegion()]);
0221     if (!southRegion->isNegativeEta())
0222       southPU = std::min(southET, (*pumLUT)[pumBin][1][southRegion->getRegion()]);
0223     southET -= southPU;
0224     southHitTower = g.getUCTTowerIndexFromL1CaloRegion(southIndex, southRegion->rawData());
0225     southIsTauLike = southRegion->isTauLike();
0226     if (southRegion->isTauLike())
0227       nTauLike++;
0228     southIsEGammaLike = southRegion->isEGammaLike();
0229     boostedJetRegionET[5] = southET;
0230     boostedJetRegionTauVeto[5] = southRegion->isTauLike();
0231   }
0232 
0233   UCTRegionIndex westIndex = g.getUCTRegionWest(center);
0234   const UCTRegion* westRegion = getRegion(westIndex.first, westIndex.second);
0235   uint32_t westET = 0;
0236   uint32_t westPU = 0;
0237   UCTTowerIndex westHitTower;
0238   bool westIsTauLike = false;
0239   bool westIsEGammaLike = false;
0240   if (westRegion != nullptr) {
0241     westET = westRegion->et();
0242     westPU = std::min(westET, (*pumLUT)[pumBin][0][westRegion->getRegion()]);
0243     if (!westRegion->isNegativeEta())
0244       westPU = std::min(westET, (*pumLUT)[pumBin][1][westRegion->getRegion()]);
0245     westET -= westPU;
0246     westHitTower = g.getUCTTowerIndexFromL1CaloRegion(westIndex, westRegion->rawData());
0247     westIsTauLike = westRegion->isTauLike();
0248     if (westRegion->isTauLike())
0249       nTauLike++;
0250     westIsEGammaLike = westRegion->isEGammaLike();
0251     boostedJetRegionET[7] = westET;
0252     boostedJetRegionTauVeto[7] = westRegion->isTauLike();
0253   }
0254 
0255   UCTRegionIndex eastIndex = g.getUCTRegionEast(center);
0256   const UCTRegion* eastRegion = getRegion(eastIndex.first, eastIndex.second);
0257   uint32_t eastET = 0;
0258   uint32_t eastPU = 0;
0259   UCTTowerIndex eastHitTower;
0260   bool eastIsTauLike = false;
0261   bool eastIsEGammaLike = false;
0262   if (eastRegion != nullptr) {
0263     eastET = eastRegion->et();
0264     eastPU = std::min(eastET, (*pumLUT)[pumBin][0][eastRegion->getRegion()]);
0265     if (!eastRegion->isNegativeEta())
0266       eastPU = std::min(eastET, (*pumLUT)[pumBin][1][eastRegion->getRegion()]);
0267     eastET -= eastPU;
0268     eastHitTower = g.getUCTTowerIndexFromL1CaloRegion(eastIndex, eastRegion->rawData());
0269     eastIsTauLike = eastRegion->isTauLike();
0270     if (eastRegion->isTauLike())
0271       nTauLike++;
0272     eastIsEGammaLike = eastRegion->isEGammaLike();
0273     boostedJetRegionET[1] = eastET;
0274     boostedJetRegionTauVeto[1] = eastRegion->isTauLike();
0275   }
0276 
0277   UCTRegionIndex nwIndex = g.getUCTRegionNW(center);
0278   const UCTRegion* nwRegion = getRegion(nwIndex.first, nwIndex.second);
0279   uint32_t nwET = 0;
0280   uint32_t nwPU = 0;
0281   UCTTowerIndex nwHitTower;
0282   if (nwRegion != nullptr) {
0283     if (nwRegion->isTauLike())
0284       nTauLike++;
0285     nwET = nwRegion->et();
0286     nwPU = std::min(nwET, (*pumLUT)[pumBin][0][nwRegion->getRegion()]);
0287     if (!nwRegion->isNegativeEta())
0288       nwPU = std::min(nwET, (*pumLUT)[pumBin][1][nwRegion->getRegion()]);
0289     nwET -= nwPU;
0290     nwHitTower = g.getUCTTowerIndexFromL1CaloRegion(nwIndex, nwRegion->rawData());
0291     boostedJetRegionET[6] = nwET;
0292     boostedJetRegionTauVeto[6] = nwRegion->isTauLike();
0293   }
0294 
0295   UCTRegionIndex neIndex = g.getUCTRegionNE(center);
0296   const UCTRegion* neRegion = getRegion(neIndex.first, neIndex.second);
0297   uint32_t neET = 0;
0298   uint32_t nePU = 0;
0299   UCTTowerIndex neHitTower;
0300   if (neRegion != nullptr) {
0301     if (neRegion->isTauLike())
0302       nTauLike++;
0303     neET = neRegion->et();
0304     nePU = std::min(neET, (*pumLUT)[pumBin][0][neRegion->getRegion()]);
0305     if (!neRegion->isNegativeEta())
0306       nePU = std::min(neET, (*pumLUT)[pumBin][1][neRegion->getRegion()]);
0307     neET -= nePU;
0308     neHitTower = g.getUCTTowerIndexFromL1CaloRegion(neIndex, neRegion->rawData());
0309     boostedJetRegionET[0] = neET;
0310     boostedJetRegionTauVeto[0] = neRegion->isTauLike();
0311   }
0312 
0313   UCTRegionIndex swIndex = g.getUCTRegionSW(center);
0314   const UCTRegion* swRegion = getRegion(swIndex.first, swIndex.second);
0315   uint32_t swET = 0;
0316   uint32_t swPU = 0;
0317   UCTTowerIndex swHitTower;
0318   if (swRegion != nullptr) {
0319     if (swRegion->isTauLike())
0320       nTauLike++;
0321     swET = swRegion->et();
0322     swPU = std::min(swET, (*pumLUT)[pumBin][0][swRegion->getRegion()]);
0323     if (!swRegion->isNegativeEta())
0324       swPU = std::min(swET, (*pumLUT)[pumBin][1][swRegion->getRegion()]);
0325     swET -= swPU;
0326     swHitTower = g.getUCTTowerIndexFromL1CaloRegion(swIndex, swRegion->rawData());
0327     boostedJetRegionET[8] = swET;
0328     boostedJetRegionTauVeto[8] = swRegion->isTauLike();
0329   }
0330 
0331   UCTRegionIndex seIndex = g.getUCTRegionSE(center);
0332   const UCTRegion* seRegion = getRegion(seIndex.first, seIndex.second);
0333   uint32_t seET = 0;
0334   uint32_t sePU = 0;
0335   UCTTowerIndex seHitTower;
0336   if (seRegion != nullptr) {
0337     if (seRegion->isTauLike())
0338       nTauLike++;
0339     seET = seRegion->et();
0340     sePU = std::min(seET, (*pumLUT)[pumBin][0][seRegion->getRegion()]);
0341     if (!seRegion->isNegativeEta())
0342       sePU = std::min(seET, (*pumLUT)[pumBin][1][seRegion->getRegion()]);
0343     seET -= sePU;
0344     seHitTower = g.getUCTTowerIndexFromL1CaloRegion(seIndex, seRegion->rawData());
0345     boostedJetRegionET[2] = seET;
0346     boostedJetRegionTauVeto[2] = seRegion->isTauLike();
0347   }
0348 
0349   uint32_t et3x3 = centralET + northET + nwET + westET + swET + southET + seET + eastET + neET;
0350   if (et3x3 > 0x3FF)
0351     et3x3 = 0x3FF;  // Peg at 10-bits
0352 
0353   uint32_t pu3x3 = centralPU + northPU + nwPU + westPU + swPU + southPU + sePU + eastPU + nePU;
0354 
0355   // Jet - a 3x3 object with center greater than a seed and all neighbors
0356   uint32_t jetET = et3x3;
0357 
0358   if (centralET >= northET && centralET >= nwET && centralET >= westET && centralET >= swET && centralET > southET &&
0359       centralET > seET && centralET > eastET && centralET > neET && centralET > jetSeed) {
0360     if (centralRegion)
0361       centralJetObjs.push_back(
0362           std::make_shared<UCTObject>(UCTObject::jet, jetET, hitCaloEta, hitCaloPhi, pu3x3, 0, et3x3));
0363     else
0364       forwardJetObjs.push_back(
0365           std::make_shared<UCTObject>(UCTObject::jet, jetET, hitCaloEta, hitCaloPhi, pu3x3, 0, et3x3));
0366   }
0367 
0368   //auto boostedJet = new UCTObject(UCTObject::jet, jetET, hitCaloEta, hitCaloPhi, pu3x3, 0, et3x3);
0369   std::shared_ptr<UCTObject> boostedJet =
0370       std::make_shared<UCTObject>(UCTObject::jet, jetET, hitCaloEta, hitCaloPhi, pu3x3, 0, et3x3);
0371   boostedJet->setNTaus(nTauLike);
0372   boostedJet->setBoostedJetRegionET(boostedJetRegionET);
0373   boostedJet->setBoostedJetRegionTauVeto(boostedJetRegionTauVeto);
0374   boostedJetObjs.push_back(boostedJet);
0375 
0376   // tau Object - a single region or a 2-region sum, where the neighbor with lower ET is located using matching hit calo towers
0377 
0378   if (centralRegion && centralIsTauLike && centralET > tauSeed) {
0379     uint32_t tauET = centralET;
0380     uint32_t tauPU = centralPU;
0381     int neighborMatchCount = 0;
0382     //check to see if we are on the edge of the calorimeter
0383     if (!g.isEdgeTower(centralHitTower)) {
0384       //Check to see if the neighbor regions are tau like and if central ET is greater
0385       //if region is tau like and a neighbor AND with less energy, set it to 0.
0386       if (g.areNeighbors(centralHitTower, northHitTower) && northIsTauLike && centralET >= northET) {
0387         tauET += northET;
0388         tauPU += northPU;
0389         neighborMatchCount++;
0390       } else if (g.areNeighbors(centralHitTower, northHitTower) && northIsTauLike && centralET < northET) {
0391         tauET = 0;
0392       }
0393       if (g.areNeighbors(centralHitTower, southHitTower) && southIsTauLike && centralET > southET) {
0394         tauET += southET;
0395         tauPU += southPU;
0396         neighborMatchCount++;
0397       } else if (g.areNeighbors(centralHitTower, southHitTower) && southIsTauLike && centralET <= southET) {
0398         tauET = 0;
0399       }
0400       if (g.areNeighbors(centralHitTower, westHitTower) && westIsTauLike && centralET >= westET) {
0401         tauET += westET;
0402         tauPU += westPU;
0403         neighborMatchCount++;
0404       } else if (g.areNeighbors(centralHitTower, westHitTower) && westIsTauLike && centralET < westET) {
0405         tauET = 0;
0406       }
0407       if (g.areNeighbors(centralHitTower, eastHitTower) && eastIsTauLike && centralET > eastET) {
0408         tauET += eastET;
0409         tauPU += eastPU;
0410         neighborMatchCount++;
0411       } else if (g.areNeighbors(centralHitTower, eastHitTower) && eastIsTauLike && centralET <= eastET) {
0412         tauET = 0;
0413       }
0414       if (neighborMatchCount > 2) {
0415         tauET = 0;
0416       }
0417     }
0418     if (tauET != 0) {
0419       tauObjs.push_back(
0420           std::make_shared<UCTObject>(UCTObject::tau, tauET, hitCaloEta, hitCaloPhi, tauPU, 0xDEADBEEF, et3x3));
0421       // Subtract footprint
0422       uint32_t isolation = 0;
0423       if (et3x3 > tauET)
0424         isolation = et3x3 - tauET;
0425       if (isolation < ((uint32_t)(tauIsolationFactor * (double)tauET))) {
0426         isoTauObjs.push_back(
0427             std::make_shared<UCTObject>(UCTObject::isoTau, tauET, hitCaloEta, hitCaloPhi, pu3x3, isolation, et3x3));
0428       }
0429     }
0430   }
0431 
0432   // eGamma Object - This is a sad story
0433   // eGamma should be in 2-3 contiguous towers, but we have no bandwidth to get a second cluster from cards
0434   // so we use essentially the same clustering as for tau, but demand that energy is almost all in the ECAL
0435   // pileup subtraction is critical to not overshoot - further this should work better for isolated eGamma
0436   // a single region or a 2-region sum, where the neighbor with lower ET is located using matching hit calo towers
0437 
0438   if (centralRegion && centralIsEGammaLike && centralET > eGammaSeed) {
0439     uint32_t eGammaET = centralET;
0440     uint32_t eGammaPU = centralPU;
0441     int neighborMatchCount = 0;
0442     if (!g.isEdgeTower(centralHitTower)) {
0443       if (g.areNeighbors(centralHitTower, northHitTower) && northIsEGammaLike && centralET >= northET) {
0444         eGammaET += northET;
0445         eGammaPU += northPU;
0446         neighborMatchCount++;
0447       } else if (g.areNeighbors(centralHitTower, northHitTower) && northIsEGammaLike && centralET < northET) {
0448         eGammaET = 0;
0449       }
0450       if (g.areNeighbors(centralHitTower, southHitTower) && southIsEGammaLike && centralET > southET) {
0451         eGammaET += southET;
0452         eGammaPU += southPU;
0453         neighborMatchCount++;
0454       } else if (g.areNeighbors(centralHitTower, southHitTower) && southIsEGammaLike && centralET <= southET) {
0455         eGammaET = 0;
0456       }
0457       if (g.areNeighbors(centralHitTower, westHitTower) && westIsEGammaLike && centralET >= westET) {
0458         eGammaET += westET;
0459         eGammaPU += westPU;
0460         neighborMatchCount++;
0461       } else if (g.areNeighbors(centralHitTower, westHitTower) && westIsEGammaLike && centralET < westET) {
0462         eGammaET = 0;
0463       }
0464       if (g.areNeighbors(centralHitTower, eastHitTower) && eastIsEGammaLike && centralET > eastET) {
0465         eGammaET += eastET;
0466         eGammaPU += eastPU;
0467         neighborMatchCount++;
0468       } else if (g.areNeighbors(centralHitTower, eastHitTower) && eastIsEGammaLike && centralET <= eastET) {
0469         eGammaET = 0;
0470       }
0471       if (neighborMatchCount > 2) {
0472         eGammaET = 0;
0473       }
0474     }
0475     if (eGammaET != 0) {
0476       emObjs.push_back(std::make_shared<UCTObject>(
0477           UCTObject::eGamma, eGammaET, hitCaloEta, hitCaloPhi, eGammaPU, 0xDEADBEEF, et3x3));
0478       uint32_t isolation = 0;
0479       if (et3x3 > eGammaET)
0480         isolation = et3x3 - eGammaET;
0481       if (isolation < ((uint32_t)(eGammaIsolationFactor * (double)eGammaET))) {
0482         isoEMObjs.push_back(std::make_shared<UCTObject>(
0483             UCTObject::isoEGamma, eGammaET, hitCaloEta, hitCaloPhi, pu3x3, isolation, et3x3));
0484       }
0485     }
0486   }
0487 
0488   return true;
0489 }
0490 
0491 bool UCTSummaryCard::clearEvent() {
0492   emObjs.clear();
0493   isoEMObjs.clear();
0494   tauObjs.clear();
0495   isoTauObjs.clear();
0496   centralJetObjs.clear();
0497   forwardJetObjs.clear();
0498   boostedJetObjs.clear();
0499   return true;
0500 }
0501 
0502 bool UCTSummaryCard::clearRegions() {
0503   regions.clear();
0504   return true;
0505 }
0506 
0507 const UCTRegion* UCTSummaryCard::getRegion(int regionEtaIndex, uint32_t regionPhiIndex) const {
0508   if (regionEtaIndex == 0 || (uint32_t)std::abs(regionEtaIndex) > NRegionsInCard ||
0509       regionPhiIndex >= MaxUCTRegionsPhi) {
0510     return nullptr;
0511   }
0512   UCTGeometry g;
0513   UCTRegionIndex r = UCTRegionIndex(regionEtaIndex, regionPhiIndex);
0514   UCTTowerIndex t = g.getUCTTowerIndex(r);
0515   uint32_t absCaloEta = std::abs(t.first);
0516   uint32_t absCaloPhi = std::abs(t.second);
0517   bool negativeEta = false;
0518   if (t.first < 0)
0519     negativeEta = true;
0520   uint32_t nCrate = g.getCrate(absCaloEta, absCaloPhi);
0521   uint32_t nCard = g.getCard(absCaloEta, absCaloPhi);
0522   uint32_t nRegion = g.getRegion(absCaloEta, absCaloPhi);
0523   uint32_t i = ((NCardsInCrate * NRegionsInCard * nCrate) + (NRegionsInCard * nCard) + nRegion) *
0524                2;  // Correct index for region collection vector of size 3*6*7*2
0525   if (!negativeEta)
0526     i++;
0527   if (i > regions.size()) {
0528     edm::LogError("L1TCaloSummary") << "UCTSummaryCard: Incorrect region requested -- bailing" << std::endl;
0529     exit(1);
0530   }
0531   return &regions[i];
0532 }
0533 
0534 bool UCTSummaryCard::setRegionData(std::vector<UCTRegion> inputRegions) {
0535   for (long unsigned int i = 0; i < inputRegions.size(); i++) {
0536     regions.push_back(inputRegions[i]);
0537   }
0538   return true;
0539 }
0540 
0541 void UCTSummaryCard::print() {
0542   if (cardSummary > 0)
0543     edm::LogInfo("L1TCaloSummary") << "UCTSummaryCard: result = " << cardSummary << std::endl;
0544 }