CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes

FastL1RegionMap Class Reference

#include <FastL1RegionMap.h>

List of all members.

Public Member Functions

int convertFromECal_to_HCal_iphi (int iphi_ecal)
int convertFromHCal_to_ECal_iphi (int iphi_hcal)
void display ()
 FastL1RegionMap ()
int getNRegion ()
int getNTower ()
std::pair< double, double > getRegionCenterEtaPhi (int iRgn)
std::pair< int, int > getRegionEtaPhiIndex (CaloTowerDetId towerId)
std::pair< int, int > getRegionEtaPhiIndex (int regionId)
std::pair< int, int > getRegionEtaPhiIndex (std::pair< int, int > iEtaPhi)
int getRegionIndex (int ieta, int iphi)
int getRegionIndex (CaloTowerDetId tower)
int getRegionTowerIndex (std::pair< int, int > iEtaPhi)
int getRegionTowerIndex (int ieta, int iphi)
int getRegionTowerIndex (CaloTowerDetId towerId)
std::pair< int, int > GetTowerEastEtaPhi (int ieta, int iphi)
std::pair< int, int > GetTowerNEEtaPhi (int ieta, int iphi)
std::pair< int, int > GetTowerNorthEtaPhi (int ieta, int iphi)
std::pair< int, int > GetTowerNWEtaPhi (int ieta, int iphi)
std::pair< int, int > GetTowerSEEtaPhi (int ieta, int iphi)
std::pair< int, int > GetTowerSouthEtaPhi (int ieta, int iphi)
std::pair< int, int > GetTowerSWEtaPhi (int ieta, int iphi)
std::pair< int, int > GetTowerWestEtaPhi (int ieta, int iphi)
 ~FastL1RegionMap ()

Static Public Member Functions

static FastL1RegionMapgetFastL1RegionMap ()

Private Attributes

int nRegion
int nTower

Static Private Attributes

static FastL1RegionMaptheInstance = 0

Detailed Description

Description: Mapping between DetIds, CaloTower IDs and Region IDs.

Implementation: <Notes on="" implementation>="">

Definition at line 49 of file FastL1RegionMap.h.


Constructor & Destructor Documentation

FastL1RegionMap::FastL1RegionMap ( )

Definition at line 23 of file FastL1RegionMap.cc.

References nRegion, and nTower.

Referenced by getFastL1RegionMap().

{
  nTower = 4608;
  nRegion = 396;

}
FastL1RegionMap::~FastL1RegionMap ( )

Member Function Documentation

int FastL1RegionMap::convertFromECal_to_HCal_iphi ( int  iphi_ecal)

Definition at line 313 of file FastL1RegionMap.cc.

References createXMLFile::iphi.

Referenced by FastL1GlobalAlgo::checkMapping().

{
  int iphi = 999;
  if (iphi_ecal>=3)
    iphi = iphi_ecal - 2;
  else if (iphi_ecal==1 || iphi_ecal==2)
    iphi = 70 + iphi_ecal;
 
  return iphi; 
}
int FastL1RegionMap::convertFromHCal_to_ECal_iphi ( int  iphi_hcal)

Definition at line 328 of file FastL1RegionMap.cc.

References createXMLFile::iphi.

{
  int iphi = 999;
  if (iphi_hcal>=1 && iphi_hcal<=70)
    iphi = iphi_hcal + 2;
  else if (iphi_hcal==71 || iphi_hcal==72)
    iphi = iphi_hcal - 70;
 
  return iphi; 
}
void FastL1RegionMap::display ( )

Definition at line 232 of file FastL1RegionMap.cc.

References dtNoiseDBValidation_cfg::cerr.

                         {
  // Region IDs
  for (int iRgn=0; iRgn<396; iRgn++) {
    if (iRgn%22 == 0) std::cerr << std::endl;   
    std::cerr << iRgn << " ";
  }

  for (int iRgn=0; iRgn<396; iRgn++) {
    if (iRgn%22 == 0) std::cerr << std::endl;   
    //std::pair<int, int> pep = m_Regions[iRgn].SetEtaPhiIndex();
    for (int iTwr=0; iTwr<16; iTwr++) {
      
      if (iTwr%4 == 0) std::cerr << " | ";   
      std::cerr << iRgn << " ";
    }
  }
  
}
FastL1RegionMap * FastL1RegionMap::getFastL1RegionMap ( ) [static]

Definition at line 33 of file FastL1RegionMap.cc.

References FastL1RegionMap(), and theInstance.

Referenced by FastL1GlobalAlgo::FastL1GlobalAlgo().

{
  if(theInstance == 0)
    {
      theInstance = new FastL1RegionMap();
    }
  return theInstance;
}
int FastL1RegionMap::getNRegion ( ) [inline]

Definition at line 69 of file FastL1RegionMap.h.

References nRegion.

{ return nRegion; };
int FastL1RegionMap::getNTower ( ) [inline]

Definition at line 68 of file FastL1RegionMap.h.

References nTower.

{ return nTower; };
std::pair< double, double > FastL1RegionMap::getRegionCenterEtaPhi ( int  iRgn)

Definition at line 252 of file FastL1RegionMap.cc.

References eta, getRegionEtaPhiIndex(), and phi.

Referenced by FastL1GlobalAlgo::addJet(), FastL1GlobalAlgo::checkMapping(), FastL1GlobalAlgo::FillL1RegionsTP(), FastL1GlobalAlgo::FillMET(), FastL1GlobalAlgo::findJets(), and FastL1GlobalAlgo::isEMCand().

{

  std::pair<int, int> ep = getRegionEtaPhiIndex(iRgn);

  // this only true for barrel + endcap!
  double eta = 999.;  
  double phi = 999.;  

  // phi
  if (ep.second <= 9) {
    //phi = ep.second * 0.349065 + 0.1745329; // 10 degrees
    phi = ep.second * 0.349065 ;
    //phi = ep.second * 0.3490658504 + 0.1745329252; // 10 degrees
  } else {
    //phi = (18-ep.second)  * (-0.349065)  + 0.1745329; // -10 degrees
    phi = (18-ep.second)  * (-0.349065);
  }
  // eta
  if (ep.first >= 11 && ep.first <= 15 )
    eta = (ep.first-11)*0.349 + 0.1745;
    //eta = (ep.first-11)*0.3490658504 + 0.1745329252;
  if (ep.first == 16 )
    eta = 1.956;
  if (ep.first == 17 )
    eta = 2.586;
  if (ep.first == 18 )
    eta = 3.25;
  if (ep.first == 19 )
    eta = 3.75;
  if (ep.first == 20 )
    eta = 4.25;
  if (ep.first == 21 )
    eta = 4.75;

  if (ep.first >= 6 && ep.first <= 10 )
    eta = (10-ep.first)*(-0.348) - 0.174;
  if (ep.first == 5 )
    eta = -1.956;
  if (ep.first == 4 )
    eta = -2.586;
  if (ep.first == 3 )
    eta = -3.25;
  if (ep.first == 2 )
    eta = -3.75;
  if (ep.first == 1 )
    eta = -4.25;
  if (ep.first == 0 )
    eta = -4.75;

  //std::cout << "eta, phi ID: "<< ep.first << ", " << ep.second << std::endl;
  //std::cout << "eta, phi: "<< eta << ", " << phi << std::endl;
 

  return std::pair<double, double>(eta, phi);
}
std::pair< int, int > FastL1RegionMap::getRegionEtaPhiIndex ( int  regionId)

Definition at line 204 of file FastL1RegionMap.cc.

References createXMLFile::iphi.

{
  int ieta = regionId%22;  
  int iphi = regionId/22;

  return std::pair<int, int>(ieta, iphi);
}
std::pair< int, int > FastL1RegionMap::getRegionEtaPhiIndex ( std::pair< int, int >  iEtaPhi)

Definition at line 62 of file FastL1RegionMap.cc.

References abs, and createXMLFile::iphi.

Referenced by FastL1GlobalAlgo::checkMapping(), FastL1GlobalAlgo::FillL1Regions(), getRegionCenterEtaPhi(), getRegionEtaPhiIndex(), getRegionIndex(), and FastL1GlobalAlgo::InitL1Regions().

{
  // barrel: 2x(17x72) [eta,phi] -> 2x1224 (etaid: +/- 1-17  phiid: 1-72)
  // endcap: 2x(11x72) [eta,phi] -> 2x792  (etaid: +/- 18-28 phiid: 1-72)
  // forward: 2x(4x18) [eta,phi] -> 2x72   (etaid: +/- 29-32 phiid: 1-18)
  // barrel:  2x(20x72) [eta,phi] -> 2x1440 (etaid: +/- 1-20  phiid: 1-72)
  // endcap:  2x(18x36) [eta,phi] -> 2x648  (etaid: +/- 21-38 phiid: 1-36)
  // forward: 2x(3x18)  [eta,phi] -> 2x54   (etaid: +/- 40-41 phiid: 1-18)
  // barrel: 2x(20x72) [eta,phi] -> 2x1440 (etaid: +/- 1-20  phiid: 1-72 interv: 1)
  // endcap: 2x(19x36) [eta,phi] -> 2x684  (etaid: +/- 21-39 phiid: 1-72 interv: 2)
  // forward: 2x(2x18) [eta,phi] -> 2x36   (etaid: +/- 40-41 phiid: 1-72 interv: 4)
  // barrel: 2x(20x72) [eta,phi] -> 2x1440 (etaid: +/- 1-20  phiid: 1-72 interv: 1)
  // endcap: 2x(18x36) [eta,phi] -> 2x684  (etaid: +/- 21-28 phiid: 1-72 interv: 2)
  // forward: 2x(2x18) [eta,phi] -> 2x36   (etaid: +/- 29-32 phiid: 1-72 interv: 4)

  int iTwrEta = EtaPhi.first;
  int iTwrPhi = EtaPhi.second;

  //iTwrPhi = convertFromECal_to_HCal_iphi(iTwrPhi);

  int iphi=999; // 0-17 
  int ieta=999; // 0-21 (barrel: 6-15, endcap: 4,5,16,17, HF: 0-3,18-21??)

  // Right now: only barrel/endcap parts work!!!
  if (abs(iTwrEta)<=28) {

    //int isub; // 0-15 4x4 region matrix 
    
    iphi = ((iTwrPhi + 1) / 4) % 18;
    
    if (iTwrEta > 0) {
      ieta = (iTwrEta - 1) / 4  + 11;
    } else {
      ieta = (iTwrEta + 1) / 4  + 10;
    }
  }

  // Test HF!!!
  if (abs(iTwrEta)>=29 && abs(iTwrEta)<=32) {
    iphi = ((iTwrPhi + 1) / 4) % 18;

    if (iTwrEta == 29) {
      ieta = 18;
    } 

    if (iTwrEta == 30) {
      ieta = 19;
    } 

    if (iTwrEta == 31) {
      ieta = 20;
    } 

    if (iTwrEta == 32) {
      ieta = 21;
    } 

    if (iTwrEta == -29) {
      ieta = 3;
    } 

    if (iTwrEta == -30) {
      ieta = 2;
    } 

    if (iTwrEta == -31) {
      ieta = 1;
    } 

    if (iTwrEta == -32) {
      ieta = 0;
    } 

    /*
    if (iTwrEta >= 29 && iTwrEta <= 32) {
      ieta = 18;
    } 
    if (iTwrEta >= 33 && iTwrEta <= 35) {
      ieta = 19;
    } 
    if (iTwrEta >= 36 && iTwrEta <= 38) {
      ieta = 20;
    } 
    if (iTwrEta >= 39 && iTwrEta <= 41) {
      ieta = 21;
    } 

    if (iTwrEta <= -29 && iTwrEta >= -32) {
      ieta = 3;
    } 
    if (iTwrEta <= -33 && iTwrEta >= -35) {
      ieta = 2;
    } 
    if (iTwrEta <= -36 && iTwrEta >= -38) {
      ieta = 1;
    } 
    if (iTwrEta <= -39 && iTwrEta >= -41) {
      ieta = 0;
    } 
    */
  }

  return std::pair<int, int>(ieta, iphi);
}
std::pair< int, int > FastL1RegionMap::getRegionEtaPhiIndex ( CaloTowerDetId  towerId)

Definition at line 44 of file FastL1RegionMap.cc.

References getRegionEtaPhiIndex(), CaloTowerDetId::ieta(), and CaloTowerDetId::iphi().

{

  return FastL1RegionMap::getRegionEtaPhiIndex(std::pair<int, int>(tower.ieta(), tower.iphi()));
}
int FastL1RegionMap::getRegionIndex ( int  ieta,
int  iphi 
)

Definition at line 213 of file FastL1RegionMap.cc.

References getRegionEtaPhiIndex().

Referenced by FastL1GlobalAlgo::checkMapping(), FastL1GlobalAlgo::FillL1RegionsTP(), getRegionIndex(), and FastL1GlobalAlgo::isEMCand().

{

  std::pair<int, int> ietaphi(ieta,iphi);
  std::pair<int, int> iep = getRegionEtaPhiIndex(ietaphi);

  int rgnid = iep.second*22 + iep.first;

  return rgnid;
}
int FastL1RegionMap::getRegionIndex ( CaloTowerDetId  tower)

Definition at line 225 of file FastL1RegionMap.cc.

References getRegionIndex(), CaloTowerDetId::ieta(), and CaloTowerDetId::iphi().

{
  return getRegionIndex(tower.ieta(), tower.iphi());
}
int FastL1RegionMap::getRegionTowerIndex ( int  ieta,
int  iphi 
)

Definition at line 198 of file FastL1RegionMap.cc.

References getRegionTowerIndex().

{
  return FastL1RegionMap::getRegionTowerIndex(std::pair<int, int>(iEta,iPhi));
}
int FastL1RegionMap::getRegionTowerIndex ( CaloTowerDetId  towerId)

Definition at line 52 of file FastL1RegionMap.cc.

References getRegionTowerIndex(), CaloTowerDetId::ieta(), and CaloTowerDetId::iphi().

{
  return FastL1RegionMap::getRegionTowerIndex(std::pair<int, int>(tower.ieta(), tower.iphi()));
}
int FastL1RegionMap::getRegionTowerIndex ( std::pair< int, int >  iEtaPhi)

Definition at line 175 of file FastL1RegionMap.cc.

References abs.

Referenced by FastL1GlobalAlgo::checkMapping(), FastL1GlobalAlgo::FillL1Regions(), FastL1GlobalAlgo::FillL1RegionsTP(), getRegionTowerIndex(), and FastL1GlobalAlgo::isEMCand().

{
  int iTwrEta = EtaPhi.first;
  int iTwrPhi = EtaPhi.second;

  //iTwrPhi = convertFromECal_to_HCal_iphi(iTwrPhi);

  // Right now: only barrel/encap part!!!
  int isub = 999; // 0-15 4x4 region matrix 

  if (abs(iTwrEta)<=41) {
    //if (abs(iTwrEta)<=28) {
    if (iTwrEta > 0) {
      isub = 4*(3 - (iTwrPhi + 1) %4) + ((iTwrEta  - 1)  % 4) ;
    } else {
      isub = 4*(3 - (iTwrPhi + 1) %4) + (3 + (iTwrEta+1)%4) ;
    }
  }

  return isub;
}
std::pair< int, int > FastL1RegionMap::GetTowerEastEtaPhi ( int  ieta,
int  iphi 
)

Definition at line 369 of file FastL1RegionMap.cc.

References createXMLFile::iphi.

Referenced by FastL1GlobalAlgo::isEMCand().

{ 
  if (ieta == -1) return std::pair<int, int>(1, iphi);

  if (ieta < 32) 
    return std::pair<int, int>(ieta+1, iphi); 
  else 
    return std::pair<int, int>(999, iphi); 
}
std::pair< int, int > FastL1RegionMap::GetTowerNEEtaPhi ( int  ieta,
int  iphi 
)

Definition at line 395 of file FastL1RegionMap.cc.

Referenced by FastL1GlobalAlgo::isEMCand().

{ 
  int iEta = ieta + 1;
  int iPhi = iphi + 1;
  if (ieta >= 32) 
    iEta = 999;
  if (ieta == -1) 
    iEta = 1;
  if (iphi == 72) 
    iPhi = 1;

  return std::pair<int, int>(iEta, iPhi); 
}
std::pair< int, int > FastL1RegionMap::GetTowerNorthEtaPhi ( int  ieta,
int  iphi 
)

Definition at line 340 of file FastL1RegionMap.cc.

Referenced by FastL1GlobalAlgo::isEMCand().

{ 
  if (iphi < 72) 
    return std::pair<int, int>(ieta, iphi+1); 
  else 
    return std::pair<int, int>(ieta, 1); 
}
std::pair< int, int > FastL1RegionMap::GetTowerNWEtaPhi ( int  ieta,
int  iphi 
)

Definition at line 380 of file FastL1RegionMap.cc.

Referenced by FastL1GlobalAlgo::isEMCand().

{ 
  int iEta = ieta - 1;
  int iPhi = iphi + 1;
  if (ieta <= -32) 
    iEta = 999;
  if (ieta == 1) 
    iEta = -1;
  if (iphi == 72) 
    iPhi = 1;

  return std::pair<int, int>(iEta, iPhi); 
}
std::pair< int, int > FastL1RegionMap::GetTowerSEEtaPhi ( int  ieta,
int  iphi 
)

Definition at line 427 of file FastL1RegionMap.cc.

Referenced by FastL1GlobalAlgo::isEMCand().

{ 
  int iEta = ieta + 1;
  int iPhi = iphi - 1;
  if (ieta >= 32) 
    iEta = 999;
  if (ieta == -1) 
    iEta = 1;
  if (iphi == 1) 
    iPhi = 72;

  return std::pair<int, int>(iEta, iPhi); 
}
std::pair< int, int > FastL1RegionMap::GetTowerSouthEtaPhi ( int  ieta,
int  iphi 
)

Definition at line 349 of file FastL1RegionMap.cc.

Referenced by FastL1GlobalAlgo::isEMCand().

{ 
  if (iphi > 1) 
    return std::pair<int, int>(ieta, iphi-1); 
  else 
    return std::pair<int, int>(ieta, 72); 
}
std::pair< int, int > FastL1RegionMap::GetTowerSWEtaPhi ( int  ieta,
int  iphi 
)

Definition at line 412 of file FastL1RegionMap.cc.

Referenced by FastL1GlobalAlgo::isEMCand().

{ 
  int iEta = ieta - 1;
  int iPhi = iphi - 1;
  if (ieta <= -32) 
    iEta = 999;
  if (ieta == 1) 
    iEta = -1;
  if (iphi == 1) 
    iPhi = 72;

  return std::pair<int, int>(iEta, iPhi); 
}
std::pair< int, int > FastL1RegionMap::GetTowerWestEtaPhi ( int  ieta,
int  iphi 
)

Definition at line 358 of file FastL1RegionMap.cc.

References createXMLFile::iphi.

Referenced by FastL1GlobalAlgo::isEMCand().

{ 
  if (ieta == 1) return std::pair<int, int>(-1, iphi);

  if (ieta > -32) 
    return std::pair<int, int>(ieta-1, iphi); 
  else 
    return std::pair<int, int>(999, iphi); 
}

Member Data Documentation

int FastL1RegionMap::nRegion [private]

Definition at line 91 of file FastL1RegionMap.h.

Referenced by FastL1RegionMap(), and getNRegion().

int FastL1RegionMap::nTower [private]

Definition at line 90 of file FastL1RegionMap.h.

Referenced by FastL1RegionMap(), and getNTower().

Definition at line 88 of file FastL1RegionMap.h.

Referenced by getFastL1RegionMap().