Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:42

0001 ///
0002 /// \class l1t::Stage1Layer2CentralityAlgorithm
0003 ///
0004 /// \authors: Gian Michele Innocenti
0005 ///           R. Alex Barbieri
0006 ///
0007 /// Description: Centrality Algorithm HI
0008 
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "L1Trigger/L1TCalorimeter/interface/Stage1Layer2HFRingSumAlgorithmImp.h"
0011 #include "L1Trigger/L1TCalorimeter/interface/PUSubtractionMethods.h"
0012 #include "L1Trigger/L1TCalorimeter/interface/legacyGtHelper.h"
0013 
0014 l1t::Stage1Layer2CentralityAlgorithm::Stage1Layer2CentralityAlgorithm(CaloParamsHelper const* params)
0015     : params_(params) {}
0016 
0017 void l1t::Stage1Layer2CentralityAlgorithm::processEvent(const std::vector<l1t::CaloRegion>& regions,
0018                                                         const std::vector<l1t::CaloEmCand>& EMCands,
0019                                                         const std::vector<l1t::Tau>* taus,
0020                                                         l1t::CaloSpare* spare) {
0021   // This is no really two algorithms, the first is the HI centrality algorithm
0022   // while the second is an alternative MB trigger.
0023 
0024   // Begin Centrality Trigger //
0025   int etaMask = params_->centralityRegionMask();
0026   int sumET = 0;
0027   int regionET = 0;
0028 
0029   for (std::vector<CaloRegion>::const_iterator region = regions.begin(); region != regions.end(); region++) {
0030     int etaVal = region->hwEta();
0031     if (etaVal > 3 && etaVal < 18)
0032       continue;  // never consider central regions, independent of mask
0033     if ((etaMask & (1 << etaVal)) >> etaVal)
0034       continue;
0035 
0036     regionET = region->hwPt();
0037     sumET += regionET;
0038   }
0039 
0040   // The LUT format is pretty funky.
0041   int LUT_under[8];
0042   int LUT_nominal[8];
0043   int LUT_over[8];
0044   for (int i = 0; i < 8; ++i) {
0045     LUT_nominal[i] = params_->centralityLUT()->data(i);
0046   }
0047   LUT_under[0] = LUT_nominal[0];
0048   LUT_over[0] = LUT_nominal[0];
0049   for (int i = 8; i < 22; ++i) {
0050     int j = i - 8;
0051     if (j % 2 == 0) {
0052       LUT_under[j / 2 + 1] = params_->centralityLUT()->data(i);
0053     } else {
0054       LUT_over[j / 2 + 1] = params_->centralityLUT()->data(i);
0055     }
0056   }
0057 
0058   int regularResult = 0;
0059   int underlapResult = 0;
0060   int overlapResult = 0;
0061 
0062   for (int i = 0; i < 8; ++i) {
0063     if (sumET > LUT_nominal[i])
0064       regularResult = i;
0065     if (sumET > LUT_under[i])
0066       underlapResult = i;
0067     if (sumET >=
0068         LUT_over[i])  // logical expression in firmware is constructed slightly differently, but this is equivalent
0069       overlapResult = i;
0070   }
0071 
0072   int alternateResult = 0;
0073   if (underlapResult > regularResult) {
0074     alternateResult = underlapResult;
0075   } else if (overlapResult < regularResult) {
0076     alternateResult = overlapResult;
0077   } else {
0078     alternateResult = regularResult;
0079   }
0080 
0081   //paranoia
0082   if (regularResult > 0x7)
0083     regularResult = 0x7;
0084   if (alternateResult > 0x7)
0085     alternateResult = 0x7;
0086 
0087   spare->SetRing(0, regularResult);
0088   spare->SetRing(1, alternateResult);
0089   // End Centrality Trigger //
0090 
0091   // Begin MB Trigger //
0092   std::vector<int> thresholds = params_->minimumBiasThresholds();
0093   int numOverThresh[4] = {0};
0094   for (std::vector<CaloRegion>::const_iterator region = regions.begin(); region != regions.end(); region++) {
0095     if (region->hwEta() < 4) {
0096       if (region->hwPt() >= thresholds.at(0))
0097         numOverThresh[0]++;
0098       if (region->hwPt() >= thresholds.at(2))
0099         numOverThresh[2]++;
0100     }
0101     if (region->hwEta() > 17) {
0102       if (region->hwPt() >= thresholds.at(1))
0103         numOverThresh[1]++;
0104       if (region->hwPt() >= thresholds.at(3))
0105         numOverThresh[3]++;
0106     }
0107   }
0108 
0109   int bits[6];
0110   bits[0] = ((numOverThresh[0] > 0) && (numOverThresh[1] > 0));
0111   bits[1] = ((numOverThresh[0] > 0) || (numOverThresh[1] > 0));
0112   bits[2] = ((numOverThresh[2] > 0) && (numOverThresh[3] > 0));
0113   bits[3] = ((numOverThresh[2] > 0) || (numOverThresh[3] > 0));
0114   bits[4] = ((numOverThresh[0] > 1) && (numOverThresh[1] > 1));
0115   bits[5] = ((numOverThresh[2] > 1) && (numOverThresh[3] > 1));
0116 
0117   spare->SetRing(2, (bits[2] << 2) + (bits[1] << 1) + bits[0]);
0118   spare->SetRing(3, (bits[5] << 2) + (bits[4] << 1) + bits[3]);
0119   // End MB Trigger //
0120 }