Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:15

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