Go to the documentation of this file.00001 #include "L1Trigger/RegionalCaloTrigger/interface/L1RCTElectronIsolationCard.h"
00002 #include "L1Trigger/RegionalCaloTrigger/interface/L1RCTLookupTables.h"
00003 #include "CondFormats/L1TObjects/interface/L1RCTParameters.h"
00004
00005 #include <iostream>
00006 #include <iomanip>
00007
00008 L1RCTElectronIsolationCard::L1RCTElectronIsolationCard(int crateNumber,
00009 int cardNumber,
00010 const L1RCTLookupTables* rctLookupTables) :
00011 crtNo(crateNumber),cardNo(cardNumber),
00012 rctLookupTables_(rctLookupTables),
00013 isoElectrons(2),nonIsoElectrons(2), regions(2)
00014 {
00015 regions.push_back(L1RCTRegion());
00016 regions.push_back(L1RCTRegion());
00017 }
00018
00019 L1RCTElectronIsolationCard::~L1RCTElectronIsolationCard()
00020 {
00021 regions.clear();
00022 }
00023
00024
00025 void L1RCTElectronIsolationCard::fillElectronCandidates(){
00026 std::vector<unsigned short> region0Electrons = calcElectronCandidates(regions.at(0),0);
00027 std::vector<unsigned short> region1Electrons = calcElectronCandidates(regions.at(1),1);
00028 isoElectrons.at(0) = region0Electrons.at(0);
00029 isoElectrons.at(1) = region1Electrons.at(0);
00030 nonIsoElectrons.at(0) = region0Electrons.at(1);
00031 nonIsoElectrons.at(1) = region1Electrons.at(1);
00032
00033
00034 }
00035
00036
00037
00038
00039
00040
00041
00042
00043 std::vector<unsigned short>
00044 L1RCTElectronIsolationCard::calcElectronCandidates(const L1RCTRegion& region, int regionNum){
00045
00046 unsigned short nonIsoElectron = 0;
00047 unsigned short isoElectron = 0;
00048
00049
00050 for(int i = 0; i<4; i++){
00051 for(int j = 0; j<4; j++){
00052
00053 unsigned short primaryEt = region.getEtIn7Bits(i,j);
00054 unsigned short primaryHE_FG = region.getHE_FGBit(i,j);
00055
00056 unsigned short northEt = region.getEtIn7Bits(i-1, j);
00057 unsigned short southEt = region.getEtIn7Bits(i+1, j);
00058 unsigned short westEt = region.getEtIn7Bits( i,j-1);
00059 unsigned short eastEt = region.getEtIn7Bits( i,j+1);
00060 unsigned short neEt = region.getEtIn7Bits(i-1,j+1);
00061 unsigned short nwEt = region.getEtIn7Bits(i-1,j-1);
00062 unsigned short seEt = region.getEtIn7Bits(i+1,j+1);
00063 unsigned short swEt = region.getEtIn7Bits(i+1,j-1);
00064
00065 unsigned short northHE_FG = region.getHE_FGBit(i-1, j);
00066 unsigned short southHE_FG = region.getHE_FGBit(i+1, j);
00067 unsigned short westHE_FG = region.getHE_FGBit( i,j-1);
00068 unsigned short eastHE_FG = region.getHE_FGBit( i,j+1);
00069 unsigned short neHE_FG = region.getHE_FGBit(i-1,j+1);
00070 unsigned short nwHE_FG = region.getHE_FGBit(i-1,j-1);
00071 unsigned short seHE_FG = region.getHE_FGBit(i+1,j+1);
00072 unsigned short swHE_FG = region.getHE_FGBit(i+1,j-1);
00073
00074 bool top = false;
00075
00076 int nCrate = crateNumber();
00077 int nCard = cardNumber();
00078 int nRegion = regionNum;
00079
00080
00081 if (nCard == 0 || nCard == 2 || nCard == 4 || (nCard == 6 && nRegion == 0))
00082 {
00083 top = true;
00084 }
00085
00086 else if (nCard == 1 || nCard == 3 || nCard == 5 || (nCard == 6 && nRegion == 1))
00087 {}
00088 else
00089 {
00090 std::cerr << "Error! EIC top assignment" << std::endl;
00091 }
00092
00093
00094
00095
00096
00097 unsigned short primaryTowerEt = primaryEt;
00098 unsigned short northTowerEt = northEt;
00099 unsigned short southTowerEt = southEt;
00100 unsigned short eastTowerEt = eastEt;
00101 unsigned short westTowerEt = westEt;
00102
00103
00104
00105
00106
00107
00108 if (primaryEt > 0)
00109 {
00110 if (nCard != 6)
00111 {
00112 if(top && nCrate >= 9)
00113 {
00114 if(westTowerEt == eastTowerEt) westTowerEt=0;
00115 if(southTowerEt == northTowerEt) southTowerEt=0;
00116 if(southTowerEt == eastTowerEt) southTowerEt=0;
00117 if(westTowerEt == northTowerEt) westTowerEt=0;
00118 }
00119 else if((!top) && nCrate < 9)
00120 {
00121 if(eastTowerEt == westTowerEt) eastTowerEt=0;
00122 if(northTowerEt == southTowerEt) northTowerEt=0;
00123 if(northTowerEt == westTowerEt) northTowerEt=0;
00124 if(eastTowerEt == southTowerEt) eastTowerEt=0;
00125 }
00126 }
00127 else
00128 {
00129
00130
00131 if(nRegion == 0 && nCrate >=9)
00132 {
00133 if(westTowerEt == eastTowerEt) westTowerEt=0;
00134 if(southTowerEt == northTowerEt) southTowerEt=0;
00135 if(southTowerEt == eastTowerEt) southTowerEt=0;
00136 if(westTowerEt == northTowerEt) westTowerEt=0;
00137 }
00138 }
00139 }
00140
00141
00142
00143
00144
00145 bool candidate = false;
00146
00147
00148 if (primaryEt > northEt && primaryEt > southEt && primaryEt > eastEt
00149 && primaryEt > westEt && !primaryHE_FG)
00150 {
00151 candidate = true;
00152 }
00153
00154
00155 else if (primaryEt < northEt || primaryEt < southEt || primaryEt < eastEt
00156 || primaryEt < westEt || primaryHE_FG)
00157 {}
00158
00159 else
00160
00161
00162
00163 {
00164 if (primaryEt > 0)
00165 {
00166 if (nCrate >=9)
00167 {
00168 if (top)
00169
00170 {
00171 if (westTowerEt == primaryTowerEt)
00172 candidate = true;
00173 else if (northTowerEt == primaryTowerEt)
00174 candidate = false;
00175 else if (southTowerEt == primaryTowerEt)
00176 candidate = true;
00177 else if (eastTowerEt == primaryTowerEt)
00178 candidate = false;
00179 }
00180
00181 else
00182
00183 {
00184 if (eastTowerEt == primaryTowerEt)
00185 candidate = true;
00186 else if (southTowerEt == primaryTowerEt)
00187 candidate = true;
00188 else if (northTowerEt == primaryTowerEt)
00189 candidate = false;
00190 else if (westTowerEt == primaryTowerEt)
00191 candidate = false;
00192 if (nCard == 6)
00193 {
00194
00195 if (westTowerEt == primaryTowerEt)
00196 candidate = true;
00197 else if (southTowerEt == primaryTowerEt)
00198 candidate = true;
00199 else if (northTowerEt == primaryTowerEt)
00200 candidate = false;
00201 else if (eastTowerEt == primaryTowerEt)
00202 candidate = false;
00203 }
00204 }
00205 }
00206 else
00207 {
00208 if (top)
00209
00210 {
00211 if (westTowerEt == primaryTowerEt)
00212 candidate = true;
00213 else if (northTowerEt == primaryTowerEt)
00214 candidate = true;
00215 else if (southTowerEt == primaryTowerEt)
00216 candidate = false;
00217 else if (eastTowerEt == primaryTowerEt)
00218 candidate = false;
00219 if (nCard == 6)
00220
00221 {
00222 if (westTowerEt == primaryTowerEt)
00223 candidate = false;
00224 else if (northTowerEt == primaryTowerEt)
00225 candidate = false;
00226 else if (southTowerEt == primaryTowerEt)
00227 candidate = true;
00228 else if (eastTowerEt == primaryTowerEt)
00229 candidate = true;
00230 }
00231 }
00232 else
00233
00234 {
00235 if (eastTowerEt == primaryTowerEt)
00236 candidate = true;
00237 else if (southTowerEt == primaryTowerEt)
00238 candidate = false;
00239 else if (northTowerEt == primaryTowerEt)
00240 candidate = true;
00241 else if (westTowerEt == primaryTowerEt)
00242 candidate = false;
00243
00244 if (nCard == 6)
00245
00246 {
00247 if (eastTowerEt == primaryTowerEt)
00248 candidate = true;
00249 else if (southTowerEt == primaryTowerEt)
00250 candidate = true;
00251 else if (northTowerEt == primaryTowerEt)
00252 candidate = false;
00253 else if (westTowerEt == primaryTowerEt)
00254 candidate = false;
00255 }
00256 }
00257 }
00258 }
00259 }
00260
00261 if (candidate) {
00262
00263
00264
00265
00266
00267
00268 unsigned short candidateEt = calcMaxSum(primaryEt,northEt,southEt,
00269 eastEt,westEt);
00270
00271
00272 bool neighborVeto = (nwHE_FG || northHE_FG || neHE_FG || westHE_FG ||
00273 eastHE_FG || swHE_FG || southHE_FG || seHE_FG);
00274
00275
00276
00277
00278
00279 unsigned quietThreshold = rctLookupTables_->rctParameters()->eicIsolationThreshold();
00280
00281 bool nw = false;
00282 bool ne = false;
00283 bool sw = false;
00284 bool se = false;
00285 bool n = false;
00286 bool w = false;
00287 bool s = false;
00288 bool e = false;
00289
00290
00291 if (nwEt >= quietThreshold) nw = true;
00292 if (neEt >= quietThreshold) ne = true;
00293 if (swEt >= quietThreshold) sw = true;
00294 if (seEt >= quietThreshold) se = true;
00295 if (northEt >= quietThreshold) n = true;
00296 if (southEt >= quietThreshold) s = true;
00297 if (westEt >= quietThreshold) w = true;
00298 if (eastEt >= quietThreshold) e = true;
00299
00300
00301 bool nwC = (sw || w || nw || n || ne);
00302 bool neC = (nw || n || ne || e || se);
00303 bool seC = (ne || e || se || s || sw);
00304 bool swC = (se || s || sw || w || nw);
00305
00306
00307
00308 bool quietVeto = (nwC && neC && seC && swC);
00309
00310
00311
00312 if(!(quietVeto || neighborVeto)){
00313 if(candidateEt > isoElectron)
00314 isoElectron = candidateEt;
00315 }
00316
00317 else if(candidateEt > nonIsoElectron)
00318 nonIsoElectron = candidateEt;
00319
00320 }
00321 }
00322 }
00323
00324
00325 std::vector<unsigned short> candidates;
00326 unsigned short fullIsoElectron = isoElectron*16 + cardNo*2;
00327 candidates.push_back(fullIsoElectron);
00328 unsigned short fullNonIsoElectron = nonIsoElectron*16 + cardNo*2;
00329 candidates.push_back(fullNonIsoElectron);
00330
00331 return candidates;
00332 }
00333
00334 unsigned short
00335 L1RCTElectronIsolationCard::calcMaxSum(unsigned short primaryEt,unsigned short northEt,
00336 unsigned short southEt,unsigned short eastEt,
00337 unsigned short westEt){
00338 unsigned short cardinals[4] = {northEt,southEt,eastEt,westEt};
00339 unsigned short max = 0;
00340 for(int i = 0; i<4;i++){
00341 unsigned short test = primaryEt+cardinals[i];
00342 if(test > max)
00343 max = test;
00344 }
00345 return max;
00346 }
00347
00348 void L1RCTElectronIsolationCard::print() {
00349 std::cout << "Electron isolation card " << cardNo << std::endl;
00350 std::cout << "Region 0 Information" << std::endl;
00351 regions.at(0).print();
00352
00353 std::cout << "IsoElectron Candidate " << isoElectrons.at(0) << std::endl;
00354 std::cout << "NonIsoElectron Candidate " << nonIsoElectrons.at(0) << std::endl << std::endl;
00355
00356 std::cout << "Region 1 Information" << std::endl;
00357 regions.at(1).print();
00358
00359 std::cout << "IsoElectron Candidate " << isoElectrons.at(1) << std::endl;
00360 std::cout << "NonIsoElectron Candidate " << nonIsoElectrons.at(1) << std::endl;
00361 }