CMS 3D CMS Logo

L1RCTElectronIsolationCard Class Reference

#include <L1Trigger/RegionalCaloTrigger/interface/L1RCTElectronIsolationCard.h>

List of all members.

Public Member Functions

int cardNumber ()
int crateNumber ()
void fillElectronCandidates ()
unsigned short getIsoElectrons (int i)
unsigned short getNonIsoElectrons (int i)
 L1RCTElectronIsolationCard (int crateNumber, int cardNumber, const L1RCTLookupTables *rctLookupTables)
void print ()
void printEdges ()
void setRegion (int i, L1RCTRegion *region)
 ~L1RCTElectronIsolationCard ()

Private Member Functions

std::vector< unsigned short > calcElectronCandidates (L1RCTRegion *region, int regionNum)
unsigned short calcMaxSum (unsigned short primaryEt, unsigned short northEt, unsigned short southEt, unsigned short eastEt, unsigned short westEt)
 L1RCTElectronIsolationCard ()

Private Attributes

unsigned short cardNo
unsigned short crtNo
L1RCTRegion empty
std::vector< unsigned short > isoElectrons
std::vector< unsigned short > nonIsoElectrons
const L1RCTLookupTablesrctLookupTables_
std::vector< L1RCTRegion * > regions


Detailed Description

Definition at line 19 of file L1RCTElectronIsolationCard.h.


Constructor & Destructor Documentation

L1RCTElectronIsolationCard::L1RCTElectronIsolationCard ( int  crateNumber,
int  cardNumber,
const L1RCTLookupTables rctLookupTables 
)

Definition at line 8 of file L1RCTElectronIsolationCard.cc.

References regions.

00010                                                                                                  :
00011   crtNo(crateNumber),cardNo(cardNumber),
00012   rctLookupTables_(rctLookupTables),
00013   isoElectrons(2),nonIsoElectrons(2), regions(2)
00014 {
00015   regions.at(0) = new L1RCTRegion();
00016   regions.at(1) = new L1RCTRegion();
00017 }

L1RCTElectronIsolationCard::~L1RCTElectronIsolationCard (  ) 

Definition at line 19 of file L1RCTElectronIsolationCard.cc.

00019 {}

L1RCTElectronIsolationCard::L1RCTElectronIsolationCard (  )  [private]


Member Function Documentation

std::vector< unsigned short > L1RCTElectronIsolationCard::calcElectronCandidates ( L1RCTRegion region,
int  regionNum 
) [private]

Definition at line 39 of file L1RCTElectronIsolationCard.cc.

References calcMaxSum(), cardNo, cardNumber(), TestMuL1L2Filter_cff::cerr, crateNumber(), e, L1RCTParameters::eicIsolationThreshold(), lat::endl(), L1RCTRegion::getEtIn7Bits(), L1RCTRegion::getHE_FGBit(), i, j, n, rctLookupTables_, L1RCTLookupTables::rctParameters(), s, and w.

Referenced by fillElectronCandidates().

00039                                                                                     {
00040   
00041   unsigned short nonIsoElectron = 0;
00042   unsigned short isoElectron = 0;
00043   
00044   //i is row and j is column
00045   for(int i = 0; i<4; i++){
00046     for(int j = 0; j<4; j++){
00047 
00048       unsigned short primaryEt = region->getEtIn7Bits(i,j);
00049       unsigned short primaryHE_FG = region->getHE_FGBit(i,j); 
00050       
00051       unsigned short northEt = region->getEtIn7Bits(i-1,  j);
00052       unsigned short southEt = region->getEtIn7Bits(i+1,  j);
00053       unsigned short westEt  = region->getEtIn7Bits(  i,j-1);
00054       unsigned short eastEt  = region->getEtIn7Bits(  i,j+1);
00055       unsigned short neEt    = region->getEtIn7Bits(i-1,j+1);
00056       unsigned short nwEt    = region->getEtIn7Bits(i-1,j-1);
00057       unsigned short seEt    = region->getEtIn7Bits(i+1,j+1);
00058       unsigned short swEt    = region->getEtIn7Bits(i+1,j-1);
00059 
00060       unsigned short northHE_FG = region->getHE_FGBit(i-1,  j);
00061       unsigned short southHE_FG = region->getHE_FGBit(i+1,  j);
00062       unsigned short westHE_FG  = region->getHE_FGBit(  i,j-1);
00063       unsigned short eastHE_FG  = region->getHE_FGBit(  i,j+1);
00064       unsigned short neHE_FG    = region->getHE_FGBit(i-1,j+1);
00065       unsigned short nwHE_FG    = region->getHE_FGBit(i-1,j-1);
00066       unsigned short seHE_FG    = region->getHE_FGBit(i+1,j+1);
00067       unsigned short swHE_FG    = region->getHE_FGBit(i+1,j-1);
00068 
00069       bool top = false;
00070 
00071       int nCrate = crateNumber();
00072       int nCard = cardNumber();
00073       int nRegion = regionNum;
00074 
00075       // top row of crate
00076       if (nCard == 0 || nCard == 2 || nCard == 4 || (nCard == 6 && nRegion == 0))
00077         {
00078           top = true;
00079         }
00080       // bottom row of crate
00081       else if (nCard == 1 || nCard == 3 || nCard == 5 || (nCard == 6 && nRegion == 1))
00082         {} // top already false
00083       else
00084         {
00085           std::cerr << "Error! EIC top assignment" << std::endl;  // this shouldn't happen!
00086         }
00087 
00088       // The following values are used for zeroing and determining whether or
00089       // not a tower is a "candidate".  The original primaryEt, northEt, neEt, etc.
00090       // are used to calculate vetoes and must not be zeroed.
00091 
00092       unsigned short primaryTowerEt = primaryEt;
00093       unsigned short northTowerEt = northEt;
00094       unsigned short southTowerEt = southEt;
00095       unsigned short eastTowerEt = eastEt;
00096       unsigned short westTowerEt = westEt;
00097 
00098       // In order to ensure proper selection of candidate tower and neighbor,
00099       // if two neighbor energies are equal, one is set to zero (in the
00100       // appropriate regions, those for which tp_lf bit is set to 0 in
00101       // Pam's JCCTest/EGWithShare.cc). 
00102 
00103       if (primaryEt > 0)  // this value should maybe be customizable?
00104         {
00105           if (nCard != 6)  // all cards except 6
00106             {
00107               if(top && nCrate >= 9)  // top row of regions in positive-eta crate
00108                 {
00109                   if(westTowerEt == eastTowerEt) westTowerEt=0;
00110                   if(southTowerEt == northTowerEt) southTowerEt=0;
00111                   if(southTowerEt == eastTowerEt) southTowerEt=0;
00112                   if(westTowerEt == northTowerEt) westTowerEt=0;
00113                 }
00114               else if((!top) && nCrate < 9) // bottom row of regions in negative-eta crate
00115                 {
00116                   if(eastTowerEt == westTowerEt) eastTowerEt=0;
00117                   if(northTowerEt == southTowerEt) northTowerEt=0;
00118                   if(northTowerEt == westTowerEt) northTowerEt=0;
00119                   if(eastTowerEt == southTowerEt) eastTowerEt=0;
00120                 }
00121             }
00122           else  // card 6                                            
00123             {
00124               // only +eta card 6 needs to have zeroing.  Pam sez.  
00125               // -eta card 6 does what it's supposed to even w/o zeroing.
00126               if(nRegion == 0 && nCrate >=9)
00127                 {
00128                   if(westTowerEt == eastTowerEt) westTowerEt=0;
00129                   if(southTowerEt == northTowerEt) southTowerEt=0;
00130                   if(southTowerEt == eastTowerEt) southTowerEt=0;
00131                   if(westTowerEt == northTowerEt) westTowerEt=0;
00132                 }
00133             }
00134         }
00135       
00136       // This section compares the energies in the primary tower with the
00137       // surrounding towers to determine whether or not the primary tower
00138       // should be considered a "candidate".  
00139 
00140       bool candidate = false;
00141 
00142       // for case where primary tower et greater than all neighbors -> candidate
00143       if (primaryEt > northEt && primaryEt > southEt && primaryEt > eastEt
00144           && primaryEt > westEt && !primaryHE_FG)
00145         {
00146           candidate = true;
00147         }
00148 
00149       // if primary et less than any neighbors (or HE_FG veto set) NOT a candidate!
00150       else if (primaryEt < northEt || primaryEt < southEt || primaryEt < eastEt
00151           || primaryEt < westEt || primaryHE_FG)
00152         {} // candidate already false
00153 
00154       else // Case of primary tower et being equal to any of its neighbors.
00155         // This section determines which tower gets the candidate.
00156         // See AboutTP.pdf document, figure on p. 4, for clarification.
00157         // Zeroed values are used in this calculation.
00158         {
00159           if (primaryEt > 0)
00160             {
00161               if (nCrate >=9)  // positive eta
00162                 {
00163                   if (top) // top row of regions in crate.  tp_lf == 0
00164                     // priority order: east < south < north < west
00165                     {
00166                       if (westTowerEt == primaryTowerEt)
00167                         candidate = true;
00168                       else if (northTowerEt == primaryTowerEt)
00169                         candidate = false;
00170                       else if (southTowerEt == primaryTowerEt)
00171                         candidate = true;
00172                       else if (eastTowerEt == primaryTowerEt)
00173                         candidate = false;
00174                     }
00175 
00176                   else // bottom row of regions in crate.  tp_lf == 1
00177                     // priority order: west < north < south < east
00178                     {
00179                       if (eastTowerEt == primaryTowerEt)
00180                         candidate = true;
00181                       else if (southTowerEt == primaryTowerEt)
00182                         candidate = true;
00183                       else if (northTowerEt == primaryTowerEt)
00184                         candidate = false;
00185                       else if (westTowerEt == primaryTowerEt)
00186                         candidate = false;
00187                       if (nCard == 6)  // card 6. tp_lf == 1
00188                         {
00189                           // priority order: east < north < south < west
00190                           if (westTowerEt == primaryTowerEt)
00191                             candidate = true;
00192                           else if (southTowerEt == primaryTowerEt)
00193                             candidate = true;
00194                           else if (northTowerEt == primaryTowerEt)
00195                             candidate = false;
00196                           else if (eastTowerEt == primaryTowerEt)
00197                             candidate = false;
00198                         }
00199                     }
00200                 }
00201               else // negative eta
00202                 {
00203                   if (top) // top row of regions in crate.  tp_lf == 1  
00204                     // priority order: east < south < north < west
00205                     {
00206                       if (westTowerEt == primaryTowerEt)
00207                         candidate = true;
00208                       else if (northTowerEt == primaryTowerEt)
00209                         candidate = true;
00210                       else if (southTowerEt == primaryTowerEt)
00211                         candidate = false;
00212                       else if (eastTowerEt == primaryTowerEt)
00213                         candidate = false;
00214                       if (nCard == 6)  // card 6.  tp_lf == 0
00215                         // east < south < north < west
00216                         {
00217                           if (westTowerEt == primaryTowerEt)
00218                             candidate = false;
00219                           else if (northTowerEt == primaryTowerEt)
00220                             candidate = false;
00221                           else if (southTowerEt == primaryTowerEt)
00222                             candidate = true;
00223                           else if (eastTowerEt == primaryTowerEt)
00224                             candidate = true;
00225                         }
00226                     }
00227                   else // bottom row of regions.  tp_lf == 0
00228                     // west < north < south < east
00229                     {
00230                       if (eastTowerEt == primaryTowerEt)
00231                         candidate = true;
00232                       else if (southTowerEt == primaryTowerEt)
00233                         candidate = false;
00234                       else if (northTowerEt == primaryTowerEt)
00235                         candidate = true;
00236                       else if (westTowerEt == primaryTowerEt)
00237                         candidate = false;
00238                       
00239                       if (nCard == 6) // card 6.  tp_lf == 1
00240                         // west < north < south < east
00241                         {
00242                           if (eastTowerEt == primaryTowerEt)
00243                             candidate = true;
00244                           else if (southTowerEt == primaryTowerEt)
00245                             candidate = true;
00246                           else if (northTowerEt == primaryTowerEt)
00247                             candidate = false;
00248                           else if (westTowerEt == primaryTowerEt)
00249                             candidate = false;
00250                         }
00251                     }
00252                 }
00253             }
00254         } // end of if (primary == neighbors)
00255       
00256       if (candidate) {
00257         
00258         // Either zeroed or non-zeroed set of values can be used here --
00259         // neighbor tower only zeroed if another neighbor tower of same
00260         // energy.  Max sum calculated from primary and only one neighbor
00261         // tower, and always one neighbor tower left over, so value of sum
00262         // is not affected.  Currently using non-zeroed.
00263         unsigned short candidateEt = calcMaxSum(primaryEt,northEt,southEt,
00264                                                 eastEt,westEt);
00265         
00266         // neighbor HE_FG veto true if neighbor has HE_FG set
00267         bool neighborVeto = (nwHE_FG || northHE_FG || neHE_FG || westHE_FG ||
00268                              eastHE_FG || swHE_FG || southHE_FG || seHE_FG); 
00269         
00270         // threshold for five-tower corner quiet veto
00271         //int quietThreshold = 3;   // 3 - loose isolation 0 - very tight isolation
00272         //int quietThreshold = 7; // ECALGREN
00273         //int quietThreshold = 0; // HCALGREN
00274         unsigned quietThreshold = rctLookupTables_->rctParameters()->eicIsolationThreshold();
00275         
00276         bool nw = false;
00277         bool ne = false;
00278         bool sw = false;
00279         bool se = false;
00280         bool n = false;
00281         bool w = false;
00282         bool s = false;
00283         bool e = false;
00284 
00285         // individual neighbor vetoes set if neighbor is over threshold
00286         if (nwEt >= quietThreshold) nw = true;
00287         if (neEt >= quietThreshold) ne = true;
00288         if (swEt >= quietThreshold) sw = true;
00289         if (seEt >= quietThreshold) se = true;
00290         if (northEt >= quietThreshold) n = true;
00291         if (southEt >= quietThreshold) s = true;
00292         if (westEt >= quietThreshold) w = true;
00293         if (eastEt >= quietThreshold) e = true;
00294 
00295         // veto TRUE for each corner set if any individual tower in each set is over threshold
00296         bool nwC = (sw || w || nw || n || ne);
00297         bool neC = (nw || n || ne || e || se);
00298         bool seC = (ne || e || se || s || sw);
00299         bool swC = (se || s || sw || w || nw);
00300 
00301         // overall quiet veto TRUE only if NO corner sets are quiet 
00302         // (all are "loud") -> non-isolated
00303         bool quietVeto = (nwC && neC && seC && swC);
00304 
00305         // only isolated if both vetoes are false
00306         // Note: quietThreshold = 0 forces all candidates to be non-iso
00307         if(!(quietVeto || neighborVeto)){
00308           if(candidateEt > isoElectron)
00309             isoElectron = candidateEt;
00310         }
00311         // otherwise, non-isolated
00312         else if(candidateEt > nonIsoElectron)
00313           nonIsoElectron = candidateEt;
00314 
00315       }
00316     }
00317   }
00318 
00319   
00320   std::vector<unsigned short> candidates;
00321   unsigned short fullIsoElectron = isoElectron*16 + cardNo*2;  // leaves room for last bit -- region number, added in Crate.cc
00322   candidates.push_back(fullIsoElectron);
00323   unsigned short fullNonIsoElectron = nonIsoElectron*16 + cardNo*2;  // leaves room for region info in last bit
00324   candidates.push_back(fullNonIsoElectron);
00325 
00326   return candidates;
00327 }

unsigned short L1RCTElectronIsolationCard::calcMaxSum ( unsigned short  primaryEt,
unsigned short  northEt,
unsigned short  southEt,
unsigned short  eastEt,
unsigned short  westEt 
) [private]

Definition at line 330 of file L1RCTElectronIsolationCard.cc.

References i, max, and parsecf::pyparsing::test().

Referenced by calcElectronCandidates().

00332                                                               {
00333   unsigned short cardinals[4] = {northEt,southEt,eastEt,westEt};
00334   unsigned short max = 0;
00335   for(int i = 0; i<4;i++){
00336     unsigned short test = primaryEt+cardinals[i];
00337     if(test > max)
00338       max = test;
00339   }
00340   return max;
00341 }

int L1RCTElectronIsolationCard::cardNumber (  )  [inline]

Definition at line 29 of file L1RCTElectronIsolationCard.h.

References cardNo.

Referenced by calcElectronCandidates().

00029 {return cardNo;}

int L1RCTElectronIsolationCard::crateNumber (  )  [inline]

Definition at line 28 of file L1RCTElectronIsolationCard.h.

References crtNo.

Referenced by calcElectronCandidates().

00028 {return crtNo;}

void L1RCTElectronIsolationCard::fillElectronCandidates (  ) 

Definition at line 22 of file L1RCTElectronIsolationCard.cc.

References calcElectronCandidates(), isoElectrons, nonIsoElectrons, and regions.

00022                                                        {
00023   std::vector<unsigned short> region0Electrons = calcElectronCandidates(regions.at(0),0);
00024   std::vector<unsigned short> region1Electrons = calcElectronCandidates(regions.at(1),1);
00025   isoElectrons.at(0) = region0Electrons.at(0);
00026   isoElectrons.at(1) = region1Electrons.at(0);
00027   nonIsoElectrons.at(0) = region0Electrons.at(1);
00028   nonIsoElectrons.at(1) = region1Electrons.at(1);
00029 }

unsigned short L1RCTElectronIsolationCard::getIsoElectrons ( int  i  )  [inline]

Definition at line 37 of file L1RCTElectronIsolationCard.h.

References isoElectrons.

00037                                         {
00038     return isoElectrons.at(i);
00039   }

unsigned short L1RCTElectronIsolationCard::getNonIsoElectrons ( int  i  )  [inline]

Definition at line 41 of file L1RCTElectronIsolationCard.h.

References nonIsoElectrons.

00041                                            {
00042     return nonIsoElectrons.at(i);
00043   }

void L1RCTElectronIsolationCard::print ( void   ) 

Definition at line 343 of file L1RCTElectronIsolationCard.cc.

References cardNo, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), isoElectrons, nonIsoElectrons, and regions.

00343                                        {
00344   std::cout << "Electron isolation card " << cardNo << std::endl;
00345   std::cout << "Region 0 Information" << std::endl;
00346   regions.at(0)->print();
00347 
00348   std::cout << "IsoElectron Candidate " << isoElectrons.at(0) << std::endl;
00349   std::cout << "NonIsoElectron Candidate " << nonIsoElectrons.at(0) << std::endl << std::endl;
00350 
00351   std::cout << "Region 1 Information" << std::endl;
00352   regions.at(1)->print();
00353 
00354   std::cout << "IsoElectron Candidate " << isoElectrons.at(1) << std::endl;
00355   std::cout << "NonIsoElectron Candidate " << nonIsoElectrons.at(1) << std::endl;
00356 }

void L1RCTElectronIsolationCard::printEdges (  )  [inline]

Definition at line 45 of file L1RCTElectronIsolationCard.h.

References regions.

00045                    {
00046     regions.at(0)->printEdges();
00047     regions.at(1)->printEdges();
00048   }

void L1RCTElectronIsolationCard::setRegion ( int  i,
L1RCTRegion region 
) [inline]

Definition at line 32 of file L1RCTElectronIsolationCard.h.

References regions.

00032                                             {
00033     regions.at(i) = region;
00034   }


Member Data Documentation

unsigned short L1RCTElectronIsolationCard::cardNo [private]

Definition at line 57 of file L1RCTElectronIsolationCard.h.

Referenced by calcElectronCandidates(), cardNumber(), and print().

unsigned short L1RCTElectronIsolationCard::crtNo [private]

Definition at line 56 of file L1RCTElectronIsolationCard.h.

Referenced by crateNumber().

L1RCTRegion L1RCTElectronIsolationCard::empty [private]

Definition at line 61 of file L1RCTElectronIsolationCard.h.

std::vector<unsigned short> L1RCTElectronIsolationCard::isoElectrons [private]

Definition at line 63 of file L1RCTElectronIsolationCard.h.

Referenced by fillElectronCandidates(), getIsoElectrons(), and print().

std::vector<unsigned short> L1RCTElectronIsolationCard::nonIsoElectrons [private]

Definition at line 64 of file L1RCTElectronIsolationCard.h.

Referenced by fillElectronCandidates(), getNonIsoElectrons(), and print().

const L1RCTLookupTables* L1RCTElectronIsolationCard::rctLookupTables_ [private]

Definition at line 59 of file L1RCTElectronIsolationCard.h.

Referenced by calcElectronCandidates().

std::vector<L1RCTRegion*> L1RCTElectronIsolationCard::regions [private]

Definition at line 65 of file L1RCTElectronIsolationCard.h.

Referenced by fillElectronCandidates(), L1RCTElectronIsolationCard(), print(), printEdges(), and setRegion().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:26:57 2009 for CMSSW by  doxygen 1.5.4