CMS 3D CMS Logo

FastL1GlobalAlgo.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    L1CaloTriggerProducer
00004 // Class:      FastL1GlobalAlgo
00005 // 
00013 //
00014 // Original Author:  Chi Nhan Nguyen
00015 //         Created:  Mon Feb 19 13:25:24 CST 2007
00016 // $Id: FastL1GlobalAlgo.cc,v 1.39 2008/06/16 16:47:51 chinhan Exp $
00017 //
00018 
00019 // No BitInfos for release versions
00020 
00021 #include "FastSimulation/L1CaloTriggerProducer/interface/FastL1GlobalAlgo.h"
00022 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00023 #include <iostream>
00024 #include <fstream>
00025 
00026 //
00027 // constructors and destructor
00028 //
00029 FastL1GlobalAlgo::FastL1GlobalAlgo(const edm::ParameterSet& iConfig)
00030 {  
00031   m_RMap = FastL1RegionMap::getL1RegionMap();
00032 
00033   // Get L1 config
00034   m_L1Config.DoEMCorr = iConfig.getParameter<bool>("DoEMCorr");
00035   m_L1Config.DoJetCorr = iConfig.getParameter<bool>("DoJetCorr");
00036   m_DoBitInfo = iConfig.getParameter<bool>("DoBitInfo");
00037   m_GctIso = iConfig.getParameter<bool>("GctIso");
00038   m_IsolationEt = iConfig.getParameter<double>("IsolationEt");
00039 
00040   // get uncompressed hcal et
00041   m_L1Config.HcalLUT = iConfig.getParameter<edm::FileInPath>("HcalLUT");
00042 
00043   m_L1Config.EMSeedEnThreshold = iConfig.getParameter<double>("EMSeedEnThreshold");
00044   m_L1Config.EMActiveLevel = iConfig.getParameter<double>("EMActiveLevel");
00045   m_L1Config.HadActiveLevel = iConfig.getParameter<double>("HadActiveLevel");
00046   m_L1Config.noTauVetoLevel = iConfig.getParameter<double>("noTauVetoLevel");   
00047   m_L1Config.hOeThreshold = iConfig.getParameter<double>("hOeThreshold");
00048   m_L1Config.FGEBThreshold = iConfig.getParameter<double>("FGEBThreshold");
00049   m_L1Config.FGEEThreshold = iConfig.getParameter<double>("FGEEThreshold");
00050 
00051   m_L1Config.MuonNoiseLevel = iConfig.getParameter<double>("MuonNoiseLevel");
00052   m_L1Config.EMNoiseLevel = iConfig.getParameter<double>("EMNoiseLevel");
00053   m_L1Config.HadNoiseLevel = iConfig.getParameter<double>("HadNoiseLevel");
00054   m_L1Config.QuietRegionThreshold = iConfig.getParameter<double>("QuietRegionThreshold");
00055   m_L1Config.JetSeedEtThreshold = iConfig.getParameter<double>("JetSeedEtThreshold");
00056 
00057   m_L1Config.TowerEMLSB = iConfig.getParameter<double>("TowerEMLSB");
00058   m_L1Config.TowerHadLSB = iConfig.getParameter<double>("TowerHadLSB");
00059   m_L1Config.EMLSB = iConfig.getParameter<double>("EMLSB");
00060   m_L1Config.JetLSB = iConfig.getParameter<double>("JetLSB");
00061 
00062   m_L1Config.CrystalEBThreshold = iConfig.getParameter<double>("CrystalEBThreshold");
00063   m_L1Config.CrystalEEThreshold = iConfig.getParameter<double>("CrystalEEThreshold");
00064 
00065   m_L1Config.TowerEBThreshold = iConfig.getParameter<double>("TowerEBThreshold");
00066   m_L1Config.TowerEEThreshold = iConfig.getParameter<double>("TowerEEThreshold");
00067   m_L1Config.TowerHBThreshold = iConfig.getParameter<double>("TowerHBThreshold");
00068   m_L1Config.TowerHEThreshold = iConfig.getParameter<double>("TowerHEThreshold");
00069 
00070   m_L1Config.TowerEBScale = iConfig.getParameter<double>("TowerEBScale");
00071   m_L1Config.TowerEEScale = iConfig.getParameter<double>("TowerEEScale");
00072   m_L1Config.TowerHBScale = iConfig.getParameter<double>("TowerHBScale");
00073   m_L1Config.TowerHEScale = iConfig.getParameter<double>("TowerHEScale");
00074 
00075   m_L1Config.noFGThreshold = iConfig.getParameter<double>("noFGThreshold");     
00076   
00077   m_L1Config.EmInputs = iConfig.getParameter <std::vector<edm::InputTag> >("EmInputs");
00078   m_L1Config.TowerInput = iConfig.getParameter<edm::InputTag>("TowerInput");
00079 
00080   m_L1Config.EcalTPInput = iConfig.getParameter<edm::InputTag>("EcalTPInput");
00081   m_L1Config.HcalTPInput = iConfig.getParameter<edm::InputTag>("HcalTPInput");
00082 
00083 
00084   //Load Hcal LUT file
00085   std::ifstream userfile;
00086   const std::string userfileName = m_L1Config.HcalLUT.fullPath();
00087   userfile.open(userfileName.c_str());
00088   static const int etabound = 32;
00089   static const int tpgmax = 256;
00090   for (int i=0; i<tpgmax; i++) { 
00091     for(int j = 1; j <=etabound; j++) {
00092       userfile >> m_hcaluncomp[j][i];
00093       //std::cout<<"+++ "<<m_hcaluncomp[j][i]<<std::endl;
00094     }
00095   }
00096   userfile.close();  
00097   
00098 
00099 }
00100 
00101 FastL1GlobalAlgo::~FastL1GlobalAlgo()
00102 {
00103   // do anything here that needs to be done at desctruction time
00104   // (e.g. close files, deallocate resources etc.)
00105 }
00106 
00107 //
00108 // member functions
00109 //
00110 
00111 
00112 // ------------ Dump out CaloTower info  ------------
00113 void
00114 FastL1GlobalAlgo::CaloTowersDump(edm::Event const& e) {
00115   /*
00116     std::vector<edm::Handle<CaloTowerCollection> > prods;
00117     
00118     edm::LogInfo("FastL1GlobalAlgo::CaloTowersDump") << "Start!";
00119     e.getManyByType(prods);
00120     
00121     std::vector<edm::Handle<CaloTowerCollection> >::iterator i;
00122 
00123     for (i=prods.begin(); i!=prods.end(); i++) {
00124     const CaloTowerCollection& c=*(*i);
00125       
00126     for (CaloTowerCollection::const_iterator j=c.begin(); j!=c.end(); j++) {
00127     edm::LogInfo("FastL1GlobalAlgo::CaloTowersDump") << *j;
00128     }
00129     }
00130     edm::LogInfo("FastL1GlobalAlgo::CaloTowersDump") << "End!";
00131   */
00132 
00133 
00134   edm::Handle<CaloTowerCollection> input;
00135     
00136   edm::LogInfo("FastL1GlobalAlgo::CaloTowersDump") << "Start!";
00137   e.getByLabel(m_L1Config.TowerInput,input);
00138 
00139   for (CaloTowerCollection::const_iterator j=input->begin(); j!=input->end(); j++) {
00140     edm::LogInfo("FastL1GlobalAlgo::CaloTowersDump") << *j;
00141   }
00142 
00143   edm::LogInfo("FastL1GlobalAlgo::CaloTowersDump") << "End!";
00144 }
00145 
00146 
00147 // ------------ For sort()  ------------
00148 namespace myspace {
00149   bool 
00150   //FastL1GlobalAlgo::greaterEt( const reco::Candidate& a, const reco::Candidate& b ) {
00151   greaterEt( const reco::Candidate& a, const reco::Candidate& b ) {
00152     return (a.et()>b.et());
00153   }
00154 }
00155 
00156 // ------------ Find Jets  ------------
00157 void
00158 FastL1GlobalAlgo::findJets() {
00159 
00160   m_TauJets.clear();
00161   m_CenJets.clear();
00162   m_ForJets.clear();
00163   
00164   for (int i=0; i<396; i++) {
00165     // barrel/endcap part only:
00166     //if ((i%22)>3 && (i%22)<18) {
00167     std::pair<double, double> p = m_RMap->getRegionCenterEtaPhi(i);
00168     
00169     double eta   = p.first;
00170     double phi   = p.second;
00171     if (m_DoBitInfo){
00172       m_Regions[i].BitInfo.setEta ( eta);
00173       m_Regions[i].BitInfo.setPhi ( phi);
00174     }
00175     
00176     if (m_Regions.at(i).SumEt()>m_L1Config.JetSeedEtThreshold) {
00177       if (isMaxEtRgn_Window33(i)) {
00178 
00179         if (m_GctIso == true) { 
00180           if (TauIsolation(i) && (i%22)>3 && (i%22)<18 ) {
00181             addJet(i,true);    
00182           } else {
00183             addJet(i,false);    
00184           }
00185         } else {
00186 
00187           if (isTauJet(i) && (i%22)>3 && (i%22)<18 ) {
00188             addJet(i,true);    
00189           } else {
00190             //if (m_DoBitInfo) m_Regions[i].BitInfo.setIsolationVeto (true);
00191             addJet(i,false);    
00192           }
00193         }
00194 
00195 
00196       }
00197       else {  if (m_DoBitInfo) m_Regions[i].BitInfo.setMaxEt (true);}
00198     } else {
00199       if (m_DoBitInfo)      m_Regions[i].BitInfo.setSumEtBelowThres (true);
00200     }
00201     //}
00202   }
00203   
00204 }
00205 
00206 
00207 // ------------ Add a jet  ------------
00208 void
00209 FastL1GlobalAlgo::addJet(int iRgn, bool taubit) {
00210   std::pair<double, double> p = m_RMap->getRegionCenterEtaPhi(iRgn);
00211 
00212   //double e     = m_Regions.at(iRgn).GetJetE();
00213   //double et = GCTEnergyTrunc(m_Regions.at(iRgn).GetJetEt(), m_L1Config.JetLSB, false);
00214   double et = m_Regions.at(iRgn).GetJetEt();
00215 
00216   double eta   = p.first;
00217   double phi   = p.second;
00218 
00219   /*
00220     if (std::abs(eta)>4.4) {
00221     std::cout<<">>> "<<et<<" "<<eta<<" "<<phi<<std::endl;
00222     }
00223   */
00224 
00225   if (m_L1Config.DoJetCorr) {
00226     et = GCTEnergyTrunc(corrJetEt(et,eta), m_L1Config.JetLSB, false);
00227   } else {
00228     et = GCTEnergyTrunc(et, m_L1Config.JetLSB, false);
00229   }
00230   /*
00231     if (et>0.) {
00232     std::cout<<"*** "<<et<<" "<<eta<<" "<<phi<<std::endl;
00233     }
00234   */
00235 
00236   double theta = 2.*atan(exp(-eta));
00237   double ex = et*cos(phi);
00238   double ey = et*sin(phi);
00239   //double ex = e*sin(theta)*cos(phi);
00240   //double ey = e*sin(theta)*sin(phi);
00241   double e = ex/sin(theta)/cos(phi);
00242   double ez = e*cos(theta);
00243 
00244   //sm
00245   if (m_DoBitInfo){
00246     m_Regions[iRgn].BitInfo.setEt ( et);
00247     m_Regions[iRgn].BitInfo.setEnergy ( e);
00248   }
00249   //ms
00250 
00251   reco::Particle::LorentzVector rp4(ex,ey,ez,e); 
00252   l1extra::L1JetParticle tjet(rp4);
00253   
00254   //if (et>0.) {
00255   //  std::cout << "region et, eta, phi: "<< et << " "<< eta << " "<< phi << " " << std::endl;
00256   //  std::cout << "reg lv et, eta, phi: "<< tjet.et()<<" "<< tjet.eta()<<" "<< tjet.phi()<<" " << std::endl;
00257   //}
00258 
00259   if (et>=1.) { // set from 5. by hands
00260     if ((taubit || et>m_L1Config.noTauVetoLevel) && (std::abs(eta)<3.0) ) {
00261       m_TauJets.push_back(tjet);
00262       // sort by et 
00263       std::sort(m_TauJets.begin(),m_TauJets.end(), myspace::greaterEt);
00264     } else {
00265       //sm
00266       if (m_DoBitInfo) m_Regions[iRgn].BitInfo.setHard ( true);
00267       //ms
00268       if (std::abs(eta)<3.0) {
00269         m_CenJets.push_back(tjet);
00270         std::sort(m_CenJets.begin(),m_CenJets.end(), myspace::greaterEt);
00271       } else {
00272         m_ForJets.push_back(tjet);
00273         std::sort(m_ForJets.begin(),m_ForJets.end(), myspace::greaterEt);
00274       }
00275     }
00276   }
00277   else{  if (m_DoBitInfo) m_Regions[iRgn].BitInfo.setSoft ( true);} 
00278 }
00279 
00280 
00281 // ------------ Fill Egammas for TP input------------
00282 void
00283 FastL1GlobalAlgo::FillEgammasTP(edm::Event const& e) {
00284   m_Egammas.clear();
00285   m_isoEgammas.clear();
00286 
00287   l1extra::L1EmParticle* ph = new l1extra::L1EmParticle();
00288   //l1extra::L1EmParticle ph;
00289   for (int i=0; i<396; i++) { 
00290     CaloTowerCollection towers = m_Regions[i].GetCaloTowers();
00291 
00292     for (CaloTowerCollection::const_iterator cnd=towers.begin(); cnd!=towers.end(); cnd++) {
00293       if (cnd->emEt()<0.01 && cnd->hadEt()<0.01) continue;
00294       //if (cnd->emEt()<0.01) continue;
00295 
00296       reco::Particle::LorentzVector rp4(0.,0.,0.,0.);
00297       // l1extra::L1EmParticle* ph = new l1extra::L1EmParticle(rp4);
00298       *ph = l1extra::L1EmParticle(rp4);
00299 
00300       CaloTowerDetId cid   = cnd->id();
00301       //std::cout<<"+++ "<<cid<<std::endl;
00302       
00303       int emTag = isEMCand(cid,ph,e);
00304       //std::cout<<"+++ "<<ph<<std::endl;
00305       //std::cout<<"+++ "<<emTag<<" | "<<ph->et()<<std::endl;
00306       
00307       // 1 = non-iso EM, 2 = iso EM
00308       if (emTag==1) {
00309         m_Egammas.push_back(*ph);
00310       } else if (emTag==2) {
00311         m_isoEgammas.push_back(*ph);
00312       }
00313       
00314     }
00315     std::sort(m_Egammas.begin(),m_Egammas.end(), myspace::greaterEt);
00316     std::sort(m_isoEgammas.begin(),m_isoEgammas.end(), myspace::greaterEt);
00317   }
00318   delete ph;
00319 }
00320 
00321 
00322 // ------------ Fill Egammas for Tower input ------------
00323 void
00324 FastL1GlobalAlgo::FillEgammas(edm::Event const& e) {
00325   m_Egammas.clear();
00326   m_isoEgammas.clear();
00327 
00328   //std::vector< edm::Handle<CaloTowerCollection> > input;
00329   //e.getManyByType(input);
00330   edm::Handle<CaloTowerCollection> input;
00331   e.getByLabel(m_L1Config.TowerInput,input);
00332 
00333   //std::vector< edm::Handle<CaloTowerCollection> >::iterator j;
00334   //for (j=input.begin(); j!=input.end(); j++) {
00335   //  const CaloTowerCollection& c=*(*j);
00336   
00337   l1extra::L1EmParticle* ph = new l1extra::L1EmParticle();  
00338   //l1extra::L1EmParticle ph;
00339   //for (CaloTowerCollection::const_iterator cnd=c.begin(); cnd!=c.end(); cnd++) {
00340   for (CaloTowerCollection::const_iterator cnd=input->begin(); cnd!=input->end(); cnd++) {
00341     reco::Particle::LorentzVector rp4(0.,0.,0.,0.);
00342     //l1extra::L1EmParticle* ph = new l1extra::L1EmParticle(rp4);
00343     *ph = l1extra::L1EmParticle(rp4);
00344 
00345     CaloTowerDetId cid   = cnd->id();
00346 
00347     int emTag = isEMCand(cid,ph,e);
00348       
00349     // 1 = non-iso EM, 2 = iso EM
00350     if (emTag==1) {
00351       m_Egammas.push_back(*ph);
00352     } else if (emTag==2) {
00353       m_isoEgammas.push_back(*ph);
00354     }
00355 
00356   }
00357   //}
00358 
00359   std::sort(m_Egammas.begin(),m_Egammas.end(), myspace::greaterEt);
00360   std::sort(m_isoEgammas.begin(),m_isoEgammas.end(), myspace::greaterEt);
00361 
00362   delete ph;
00363 }
00364 
00365 // ------------ Fill MET 1: loop over towers ------------
00366 void
00367 FastL1GlobalAlgo::FillMET(edm::Event const& e) {
00368   //m_METs.clear();
00369 
00370   //std::vector< edm::Handle<CaloTowerCollection> > input;
00371   //e.getManyByType(input);
00372   edm::Handle<CaloTowerCollection> input;
00373   e.getByLabel(m_L1Config.TowerInput,input);
00374 
00375   double sum_hade = 0.0;
00376   double sum_hadet = 0.0;
00377   double sum_hadex = 0.0;
00378   double sum_hadey = 0.0;
00379   double sum_hadez = 0.0;
00380   double sum_e = 0.0;
00381   double sum_et = 0.0;
00382   double sum_ex = 0.0;
00383   double sum_ey = 0.0;
00384   double sum_ez = 0.0;
00385 
00386   //std::vector< edm::Handle<CaloTowerCollection> >::iterator i;
00387 
00388   //for (i=input.begin(); i!=input.end(); i++) {
00389   //  const CaloTowerCollection& c=*(*i);
00390 
00391   //  for (CaloTowerCollection::const_iterator candidate=c.begin(); candidate!=c.end(); candidate++) {
00392   for (CaloTowerCollection::const_iterator candidate=input->begin(); candidate!=input->end(); candidate++) {
00393     //double eme    = candidate->emEnergy();
00394     //double hade    = candidate->hadEnergy();
00395     double eme    = candidate->emEt();
00396     double hade    = candidate->hadEt();
00397       
00398     double EThres = 0.;
00399     double HThres = 0.;
00400     double EBthres = m_L1Config.TowerEBThreshold;
00401     double HBthres = m_L1Config.TowerHBThreshold;
00402     double EEthres = m_L1Config.TowerEBThreshold;
00403     double HEthres = m_L1Config.TowerEEThreshold;
00404 
00405     //if(std::abs(candidate->eta())<1.479) {
00406     if(std::abs(candidate->eta())<2.322) {
00407       EThres = EBthres;
00408     } else {
00409       EThres = EEthres;
00410     }
00411     //if(std::abs(candidate->eta())<1.305) {
00412     if(std::abs(candidate->eta())<2.322) {
00413       HThres = HBthres;
00414     } else {
00415       HThres = HEthres;
00416     }
00417 
00418     // rescale energies
00419     double emScale = 1.0;
00420     double hadScale = 1.0;
00421     if (std::abs(candidate->eta()>1.3050) && std::abs(candidate->eta())<3.0) {
00422       hadScale = m_L1Config.TowerHEScale;
00423       emScale = m_L1Config.TowerEEScale;
00424     }
00425     if (std::abs(candidate->eta()<1.3050)) {
00426       hadScale = m_L1Config.TowerHBScale;
00427       emScale = m_L1Config.TowerEBScale;
00428     }
00429     eme    *= emScale;
00430     hade   *= hadScale;
00431       
00432     if (eme>=EThres || hade>=HThres) {
00433       double phi   = candidate->phi();
00434       double eta = candidate->eta();
00435       //double et    = candidate->et();
00436       //double e     = candidate->energy();
00437       double theta = 2.*atan(exp(-eta));
00438       double et    = 0.;
00439       double e     = 0.;
00440       double had_et    = 0.;
00441       double had_e     = 0.;
00442 
00443       if (eme>=EThres) {
00444         et    += candidate->emEt();
00445         e    += candidate->emEnergy();
00446       }
00447       if (hade>=HThres) {
00448         et    += candidate->hadEt();
00449         e    += candidate->hadEnergy();
00450         had_et  += candidate->hadEt();
00451         had_e   += candidate->hadEnergy();
00452       }
00453 
00454       //sum_et += et;
00455       sum_et += RCTEnergyTrunc(et,1.0,1024);
00456       sum_ex += et*cos(phi);
00457       sum_ey += et*sin(phi); 
00458       //sum_ex += e*sin(theta)*cos(phi);
00459       //sum_ey += e*sin(theta)*sin(phi); 
00460       //sum_e += e;
00461       sum_e += et/sin(theta);
00462       sum_ez += et*cos(theta)/sin(theta);
00463 
00464       sum_hadet += had_et;
00465       sum_hadex += had_et*cos(phi);
00466       sum_hadey += had_et*sin(phi); 
00467       //sum_hadex += had_e*sin(theta)*cos(phi);
00468       //sum_hadey += had_e*sin(theta)*sin(phi); 
00469       //sum_hade += had_e;
00470       sum_hade += had_et/sin(theta);
00471       sum_hadez += had_et*cos(theta)/sin(theta);
00472     }
00473   }
00474   //}
00475 
00476   reco::Particle::LorentzVector rp4(-sum_ex,-sum_ey,0.,std::sqrt(sum_ex*sum_ex + sum_ey*sum_ey));
00477   m_MET = l1extra::L1EtMissParticle(rp4,sum_et,0.);  
00478   //m_METs.push_back(l1extra::L1EtMissParticle(rp4,sum_et,0.));  
00479 }
00480 
00481 // ------------ Fill MET 2: loop over regions ------------
00482 void
00483 FastL1GlobalAlgo::FillMET() {
00484   //m_METs.clear();
00485 
00486   //double sum_e = 0.0;
00487   double sum_et = 0.0;
00488   double sum_ex = 0.0;
00489   double sum_ey = 0.0;
00490   //double sum_ez = 0.0;
00491 
00492   for (int i=0; i<396; i++) { 
00493     std::pair<double, double> etaphi = m_RMap->getRegionCenterEtaPhi(i);
00494     double phi   = etaphi.second;
00495     //double eta = etaphi.first;
00496     //double theta = 2.*atan(exp(-eta));
00497     
00498     double et = m_Regions[i].SumEt();
00499     //double e = m_Regions[i].SumE();
00500 
00501     //sum_et += et;
00502     //sum_et += RCTEnergyTrunc(et,0.5,2048);
00503     //sum_et += et;
00504     //sum_ex += RCTEnergyTrunc(et*cos(phi),0.5,2048);
00505     //sum_ey += RCTEnergyTrunc(et*sin(phi),0.5,2048); 
00506     sum_ex += et*cos(phi);
00507     sum_ey += et*sin(phi); 
00508     //sum_ex += e*sin(theta)*cos(phi);
00509     //sum_ey += e*sin(theta)*sin(phi); 
00510     //sum_e += e;
00511     //sum_e += RCTEnergyTrunc(et/sin(theta),0.5,2048);
00512     //sum_ez += RCTEnergyTrunc(et*cos(theta)/sin(theta),0.5,2048);
00513     //sum_e += et/sin(theta);
00514     //sum_ez += et*cos(theta)/sin(theta);
00515     //sum_ez += e*cos(theta);
00516     //sum_et += e*sin(theta);
00517   }
00518   
00519   //sum_et = RCTEnergyTrunc(std::sqrt(sum_ex*sum_ex + sum_ey*sum_ey),0.5,2048);
00520   sum_et = std::sqrt(sum_ex*sum_ex + sum_ey*sum_ey);
00521     
00522   //reco::Particle::LorentzVector rp4(-sum_ex,-sum_ey,-sum_ez,sum_e);
00523   reco::Particle::LorentzVector rp4(-sum_ex,-sum_ey,0.,std::sqrt(sum_ex*sum_ex + sum_ey*sum_ey));
00524   //edm::LogInfo("********** FastL1GlobalAlgo::FillMET()")<<rp4.mass()<<std::endl; 
00525   m_MET = l1extra::L1EtMissParticle(rp4,sum_et,0.);  
00526   //m_METs.push_back(l1extra::L1EtMissParticle(rp4,sum_et,0.));  
00527  
00528 }
00529 
00530 void 
00531 FastL1GlobalAlgo::InitL1Regions() 
00532 {
00533   m_Regions.clear();
00534   m_Regions = std::vector<FastL1Region>(396); // ieta: 1-22, iphi: 1-18
00535 
00536   // init regions
00537   for (int i=0; i<396; i++) {
00538     m_Regions[i].SetParameters(m_L1Config);
00539     /*/ sm
00540       for (unsigned int j = 0; j < 16; ++j){
00541       m_Regions[i].BitInfo.ecal[j];
00542       m_Regions[i].BitInfo.hcal[j];
00543       }
00544       //ms */     
00545     std::pair<int, int> p = m_RMap->getRegionEtaPhiIndex(i);
00546     m_Regions[i].SetEtaPhiIndex(p.first,p.second,i);
00547     CaloTower c;
00548     //std::cout<<"+++ "<<c.emEt()<<" "<<c.hadEt()<<std::endl;
00549     for (int twrid=0; twrid<16; twrid++) {
00550       m_Regions[i].FillTowerZero(c,twrid);
00551     }
00552   }  
00553 }
00554 
00555 // ------------ Fill L1 Regions on Trigger Primitives------------
00556 void 
00557 FastL1GlobalAlgo::FillL1RegionsTP(edm::Event const& e, const edm::EventSetup& s) 
00558 {
00559   //edm::ESHandle<CaloTowerConstituentsMap> cttopo;
00560   //s.get<IdealGeometryRecord>().get(cttopo);
00561   //const CaloTowerConstituentsMap* theTowerConstituentsMap = cttopo.product();
00562 
00563   InitL1Regions();
00564 
00565   edm::Handle<EcalTrigPrimDigiCollection> ETPinput;
00566   e.getByLabel(m_L1Config.EcalTPInput,ETPinput);
00567 
00568   edm::Handle<HcalTrigPrimDigiCollection> HTPinput;
00569   e.getByLabel(m_L1Config.HcalTPInput,HTPinput);
00570 
00571   //CaloTowerCollection towers;
00572   int hEtV[396][16] = {0};
00573   int hFGV[396][16] = {0};
00574   int hiEtaV[396][16] = {0};
00575   int hiPhiV[396][16] = {0};
00576   for (HcalTrigPrimDigiCollection::const_iterator hTP=HTPinput->begin(); 
00577        hTP!=HTPinput->end(); hTP++) {
00578     
00579     //if (hTP!=HTPinput->end()) {
00580     //HcalTrigTowerDetId htwrid   = hTP->id();
00581     //DetId htwrid   = (DetId)hTP->id();
00582     //std::cout<<"******* AAAAAAAAAAA"<<std::endl;
00583     //CaloTowerDetId hTPtowerDetId = theTowerConstituentsMap->towerOf((DetId)htwrid);
00584     //std::cout<<"******* BBBBBBBBB"<<std::endl;
00585     
00586     int rgnid = 999;
00587     int twrid = 999;
00588 
00589     int hiphi = hTP->id().iphi();
00590     int hieta = hTP->id().ieta();
00591 
00592     /*
00593       if(abs(hieta) > 20 && hiphi%2 == 0) hiphi--;
00594       std::pair<int, int> prim_tower_feed; // prim tower indeces iEta +/- 1~32, iPhi (+) 1~72
00595       prim_tower_feed.first = hieta;
00596       prim_tower_feed.second = hiphi;
00597       std::pair<int, int> rct_index = m_RMap-> getRegionEtaPhiIndex(prim_tower_feed); // convert prim tower indeces into RCT indeces ieta 0~21, iphi 0~17
00598       rgnid = rct_index.second*22 + rct_index.first; // converting fastL1 obsolete RCT numbering
00599     */
00600 
00601     rgnid  = m_RMap->getRegionIndex(hieta,hiphi);
00602     twrid = m_RMap->getRegionTowerIndex(hieta,hiphi);
00603 
00604     //std::cout<<hieta<<" "<<hiphi<<" "<<rgnid<<" "<<twrid<<" "<<std::endl;
00605     /*
00606       if (std::abs(htwrid.ieta())>28) {
00607       std::cout<<htwrid.ieta()<<" "<<htwrid.iphi()<<" "<<rgnid<<" "<<twrid<<" "<<std::endl;
00608       }
00609     */
00610 
00611     /*
00612     if (hTP->SOI_compressedEt()>0) {
00613       std::cout<<"hcalTP >>> "<<hTP->SOI_compressedEt()<<" "<<hTP->SOI_fineGrain()<<" "
00614                <<rgnid<<" "<<twrid<<std::endl;
00615     }
00616     */
00617     if(rgnid < 396 && twrid < 16){
00618       hEtV[rgnid][twrid] = (int)hTP->SOI_compressedEt();
00619       hFGV[rgnid][twrid] = (int)hTP->SOI_fineGrain();
00620       hiEtaV[rgnid][twrid] = hieta;
00621       hiPhiV[rgnid][twrid] = hiphi;
00622     }
00623   }
00624   
00625 
00626   int emEtV[396][16] = {0};
00627   int emFGV[396][16] = {0};
00628   int emiEtaV[396][16] = {0};
00629   int emiPhiV[396][16] = {0};
00630   //double emEtaV[396][16] = {0.};
00631   for (EcalTrigPrimDigiCollection::const_iterator eTP=ETPinput->begin(); 
00632        eTP!=ETPinput->end(); eTP++) {
00633    
00634     int eieta = eTP->id().ieta();
00635 
00636     if(abs(eieta)> 28) continue; // no crystal in HF
00637     else{
00638       int eiphi = eTP->id().iphi();
00639       //int teiphi = eiphi;
00640       
00641       int rgnid = 999;
00642       int twrid = 999;
00643       
00644       //if(abs(eieta) > 20 && eiphi%2 == 0) teiphi=eiphi-1;
00645       
00646       /*
00647         if(abs(eieta) > 20 && eiphi%2 == 0) eiphi--;
00648         std::pair<int, int> prim_tower_feed; // prim tower indeces iEta +/- 1~28, iPhi (+) 1~72
00649         prim_tower_feed.first = eieta;
00650         prim_tower_feed.second = eiphi;
00651         std::pair<int, int> rct_index = m_RMap-> getRegionEtaPhiIndex(prim_tower_feed); // convert prim tower indeces into RCT indeces ieta 0~21, iphi 0~17
00652         rgnid = rct_index.second*22 + rct_index.first; // converting fastL1 obsolete RCT numbering
00653       */
00654       
00655       /*  
00656       rgnid  = m_RMap->getRegionIndex(eieta,eiphi);
00657       twrid = m_RMap->getRegionTowerIndex(eieta,eiphi);
00658       
00659       if (eTP->compressedEt()>0) {
00660         std::cout<<"ecalTP *** "<<eTP->compressedEt()<<" "<<eTP->fineGrain()<<" "
00661                  <<rgnid<<" "<<twrid<<std::endl;
00662       }
00663       */
00664       if(rgnid < 396 && twrid < 16){
00665         emEtV[rgnid][twrid] = (int)eTP->compressedEt();
00666         emFGV[rgnid][twrid] = (int)eTP->fineGrain();
00667         emiEtaV[rgnid][twrid] = eieta;
00668         emiPhiV[rgnid][twrid] = eiphi;
00669         
00670         //edm::ESHandle<CaloGeometry> cGeom; 
00671         //s.get<IdealGeometryRecord>().get(cGeom);    
00672       
00673         //CaloTowerDetId  towerDetId = CaloTowerDetId( eieta, teiphi); 
00674         //CaloTowerDetId  towerDetId2 = CaloTowerDetId( eieta, eiphi); 
00675         //const GlobalPoint gP1 = cGeom->getPosition(towerDetId);
00676         //const GlobalPoint gP12 = cGeom->getPosition(towerDetId2);
00677         //double eta = gP1.eta();  
00678 
00679         //if(abs(eieta) > 20) 
00680         //std::cout<<eiphi<<" "<<gP1.phi()<<" "<<eieta<<" "<<gP1.eta()<<" "<<std::endl;
00681 
00682         //double phi = gP1.phi();    
00683         //emEtaV[rgnid][twrid] = eta;
00684       }
00685     } // else
00686   } // ecalTP
00687   
00688   
00689   for (int i=0; i<396; i++) {
00690     for (int j=0; j<16; j++) {
00691       /* sm
00692          if  (emEtV[i][j] == 0 && hEtV[i][j] == 0){
00693          m_Regions[i].BitInfo.ecal.push_back(0);
00694          m_Regions[i].BitInfo.hcal.push_back(0);
00695          }
00696       *///ms
00697       if (emEtV[i][j]>0 || hEtV[i][j]>0) {
00698         
00699 
00700         std::pair<double, double> etaphi 
00701           = m_RMap->getRegionCenterEtaPhi(i);
00702         double eta = etaphi.first;
00703         double phi = etaphi.second;
00704    
00705 
00706         double emEt = ((double) emEtV[i][j]) * m_L1Config.EMLSB;
00707         //double hadEt = ((double )hEtV[i][j]) * m_L1Config.JetLSB * cos(2.*atan(exp(-hiEtaV[i][j])));
00708         int iAbsTwrEta = std::abs(hiEtaV[i][j]);
00709         //double hadEt = ((double )hcaletValue(iAbsTwrEta, hEtV[i][j])) * m_L1Config.JetLSB;
00710         double hadEt = ((double )hcaletValue(iAbsTwrEta, hEtV[i][j]));
00711         //double hadEt = hEtV[i][j] * m_L1Config.JetLSB;
00712    
00713         if (m_L1Config.DoEMCorr) {
00714           //emEt = corrEmEt(emEt,emEtaV[i][j]);
00715           emEt = corrEmEt(emEt,std::abs(emiEtaV[i][j]));
00716         }
00717 
00718         double et = emEt + hadEt;
00719         /*/ sm
00720           m_Regions[i].BitInfo.ecal[j] = emEt;
00721           m_Regions[i].BitInfo.hcal[j] = hadEt;
00722           //ms */
00723           //math::RhoEtaPhiVector lvec(et,eta,phi);
00724           math::PtEtaPhiMLorentzVector lvec(et,eta,phi,0.);
00725 
00726           CaloTowerDetId towerDetId;  
00727           if (emEtV[i][j]>0) 
00728             towerDetId = CaloTowerDetId(emiEtaV[i][j],emiPhiV[i][j]); 
00729           else
00730             towerDetId = CaloTowerDetId(hiEtaV[i][j],hiPhiV[i][j]); 
00731           
00732           /*
00733           CaloTower t = CaloTower(towerDetId, lvec, 
00734                                   emEt, hadEt, 
00735                                   0., 0, 0);
00736           */
00737           // New Dataformat in 2_1_X
00738           GlobalPoint emPosition,hadPosition;
00739           double theta = 2.*atan(exp(-eta));
00740           CaloTower t = CaloTower(towerDetId,emEt/sin(theta),hadEt/sin(theta),
00741                                   0.,0,0,lvec,emPosition,hadPosition);
00742     
00743           //m_Regions[i].FillTower_Scaled(t,j,false);
00744           m_Regions[i].FillTower_Scaled(t,j,true);
00745     
00746           /*
00747             if (et>0) {
00748             std::cout<<"+++ "<<emEt<<" "<<hadEt<<" "
00749             <<i<<" "<<j<<" "
00750             <<std::endl<<"-- "
00751             <<t.emEt()<<" "<<t.hadEt()<<" "
00752             <<t.eta()<<" "<<t.phi()<<" "
00753             <<std::endl;
00754             }
00755           */
00756 
00757 
00758           // Explicitely take care of integer boolean conversion
00759           if (emEt > 3.0 && emEt < m_L1Config.noFGThreshold && (int)emFGV[i][j]!=0) 
00760             m_Regions[i].SetFGBit(j,true);
00761           else 
00762             m_Regions[i].SetFGBit(j,false);
00763         
00764           if (emEt > 3.0){
00765             if (emEt < 60. && hadEt/emEt >  m_L1Config.hOeThreshold)  
00766               m_Regions[i].SetHOEBit(j,true);
00767             else
00768               m_Regions[i].SetHOEBit(j,false);
00769           }
00770           else
00771             m_Regions[i].SetHOEBit(j,false);
00772 
00773           m_Regions[i].SetRegionBits(e, m_DoBitInfo);
00774       }
00775       
00776 
00777     }
00778   }
00779 
00780 
00781 
00782 
00783   
00784 
00785 }
00786 
00787 // ------------ Fill L1 Regions on Towers and RecHits------------
00788 void 
00789 FastL1GlobalAlgo::FillL1Regions(edm::Event const& e, const edm::EventSetup& c) 
00790 {
00791   InitL1Regions();
00792   
00793   edm::Handle<CaloTowerCollection> input;
00794   e.getByLabel(m_L1Config.TowerInput,input);
00795   
00796   edm::ESHandle<CaloTowerConstituentsMap> cttopo;
00797   c.get<IdealGeometryRecord>().get(cttopo);
00798   const CaloTowerConstituentsMap* theTowerConstituentsMap = cttopo.product();
00799   
00800   edm::ESHandle<CaloTopology> calotopo;
00801   c.get<CaloTopologyRecord>().get(calotopo);
00802   
00803   edm::ESHandle<CaloGeometry> cGeom;
00804   c.get<CaloGeometryRecord>().get(cGeom);
00805   
00806   edm::Handle<EcalRecHitCollection> ec1;
00807   e.getByLabel(m_L1Config.EmInputs.at(1),ec1);
00808   
00809   edm::Handle<EcalRecHitCollection> ec0;
00810   e.getByLabel(m_L1Config.EmInputs.at(0),ec0);
00811   
00812   // ascii visualisation of mapping
00813   //m_RMap->display();
00814   
00815  
00816   // works for barrel/endcap region only right now!
00817   //std::vector< edm::Handle<CaloTowerCollection> > input;
00818   //e.getManyByType(input);
00819   //edm::Handle<CaloTowerCollection> input;
00820   //e.getByLabel(m_L1Config.TowerInput,input);
00821 
00822   //std::vector< edm::Handle<CaloTowerCollection> >::iterator j;
00823   //for (j=input.begin(); j!=input.end(); j++) {
00824   //  const CaloTowerCollection& c=*(*j);
00825     
00826   //  for (CaloTowerCollection::const_iterator cnd=c.begin(); cnd!=c.end(); cnd++) {
00827   for (CaloTowerCollection::const_iterator cnd=input->begin(); cnd!=input->end(); cnd++) {
00828 
00829     CaloTowerDetId cid   = cnd->id();
00830     std::pair<int, int> pep = m_RMap->getRegionEtaPhiIndex(cid);
00831 
00832     //if (abs(cid.ieta())>=0) {
00833     //std::cout << cid.ieta() << " " << cid.iphi() << std::endl;
00834     //std::cout << cnd->eta() << " " << cnd->phi() << std::endl;
00835     //std::cout << pep.first << " " << pep.second << std::endl;
00836     //std::cout << "**************************************************" << std::endl;
00837     //}
00838  
00839     int rgnid = 999;
00840     int twrid = 999;
00841       
00842     //std::cout << "FastL1GlobalAlgo::FillL1Regions calotowers dump: " << *cnd << std::endl;
00843       
00844     if (std::abs(pep.first)<=22) {
00845       rgnid = pep.second*22 + pep.first;
00846       twrid = m_RMap->getRegionTowerIndex(cid);
00847       //std::cout << rgnid << " " << twrid << std::endl;
00848     } 
00849 
00850     if (rgnid<396 && twrid<16) {
00851       m_Regions[rgnid].FillTower_Scaled(*cnd,twrid);
00852       m_Regions[rgnid].SetRegionBits(e, m_DoBitInfo);
00853     } else {
00854       //std::cerr << "FastL1GlobalAlgo::FillL1Regions(): ERROR - invalid region or tower ID: " << rgnid << " | " << twrid  << std::endl;
00855     }
00856 
00857   }
00858 
00859   //}
00860   
00861   // Fill EM Crystals
00862   for (int i=0; i<396; i++) {
00863 
00864     //m_Regions[i].FillEMCrystals(e,iConfig,m_RMap);
00865     m_Regions[i].FillEMCrystals(theTowerConstituentsMap,
00866                                 &(*calotopo),
00867                                 &(*cGeom),
00868                                 &(*ec0), &(*ec1),
00869                                 m_RMap);
00870     
00871   }
00872 
00873   //checkMapping();
00874   
00875 }
00876 
00877 
00878 // Fill Bitwords
00879 void 
00880 FastL1GlobalAlgo::FillBitInfos() {
00881   if (m_DoBitInfo){
00882     m_BitInfos.clear();
00883     for (int i=0; i<396; i++) {
00884       m_BitInfos.push_back(m_Regions[i].getBitInfo());
00885     }
00886   }
00887 }
00888 
00889 // ------------ Check if jet is taujet ------------
00890 bool 
00891 FastL1GlobalAlgo::isTauJet(int cRgn) {
00892 
00893   // Barrel and Endcap only
00894   if ((cRgn%22)<4 || (cRgn%22)>17)  
00895     return false;
00896 
00897   int shower_shape = 0; 
00898   int et_isolation = 0;
00899 
00900   if (m_Regions[cRgn].GetTauBit()) 
00901     if (!m_DoBitInfo)
00902       return false;
00903 
00904   int nwid = m_Regions[cRgn].GetNWId();
00905   int nid = m_Regions[cRgn].GetNorthId();
00906   int neid = m_Regions[cRgn].GetNEId();
00907   int wid = m_Regions[cRgn].GetWestId();
00908   int eid = m_Regions[cRgn].GetEastId();
00909   int swid = m_Regions[cRgn].GetSWId();
00910   int sid = m_Regions[cRgn].GetSouthId();
00911   int seid = m_Regions[cRgn].GetSEId();
00912 
00913   if (!m_DoBitInfo)
00914     if (m_Regions[cRgn].GetTauBit()) shower_shape = 1; // check center
00915 
00916   //Use 3x2 window at eta borders!
00917 
00918   if((cRgn%22)==4  || (cRgn%22)==17 ) {
00919     // west border:
00920     if ((cRgn%22)==4) { 
00921       //std::cout << "West border check: " << std::endl
00922       //      << nwid << " " << nid << " "  << neid << " " << std::endl
00923       //      << wid << " " << cRgn << " "  << eid << " " << std::endl
00924       //      << swid << " " << sid << " "  << seid << " " << std::endl;    
00925       //std::cout << "West border check: " << std::endl
00926       //      << m_Regions[nwid].GetTauBit() << " " << m_Regions[nid].GetTauBit() << " "  << m_Regions[neid].GetTauBit() << " " << std::endl
00927       //      << m_Regions[wid].GetTauBit() << " " << m_Regions[cRgn].GetTauBit() << " "  << m_Regions[eid].GetTauBit() << " " << std::endl
00928       //      << m_Regions[swid].GetTauBit() << " " << m_Regions[sid].GetTauBit() << " "  << m_Regions[seid].GetTauBit() << " " << std::endl;    
00929 
00930       if (
00931           m_Regions[nid].GetTauBit()  ||
00932           m_Regions[neid].GetTauBit() ||
00933           m_Regions[eid].GetTauBit()  ||
00934           m_Regions[seid].GetTauBit() ||
00935           m_Regions[sid].GetTauBit()  ||
00936           m_Regions[cRgn].GetTauBit()
00937           ) 
00938         {
00939           if (!m_DoBitInfo) return false;
00940         } 
00941       else {
00942         if (!m_DoBitInfo) return true;
00943       }
00944 
00945       if (m_DoBitInfo) m_Regions[cRgn].BitInfo.setIsolationVeto ( true);         
00946       et_isolation = 1;
00947     } else { et_isolation = 2;}          
00948 
00949     // east border:
00950     if ((cRgn%22)==17) { 
00951       //std::cout << "East border check2: " << std::endl
00952       //      << nwid << " " << nid << " "  << neid << " " << std::endl
00953       //      << wid << " " << cRgn << " "  << eid << " " << std::endl
00954       //      << swid << " " << sid << " "  << seid << " " << std::endl;    
00955       //std::cout << "East border check: " << std::endl
00956       //      << m_Regions[nwid].GetTauBit() << " " << m_Regions[nid].GetTauBit() << " "  << m_Regions[neid].GetTauBit() << " " << std::endl
00957       //      << m_Regions[wid].GetTauBit() << " " << m_Regions[cRgn].GetTauBit() << " "  << m_Regions[eid].GetTauBit() << " " << std::endl
00958       //      << m_Regions[swid].GetTauBit() << " " << m_Regions[sid].GetTauBit() << " "  << m_Regions[seid].GetTauBit() << " " << std::endl;    
00959 
00960       if (
00961           m_Regions[nid].GetTauBit()  ||
00962           m_Regions[nwid].GetTauBit() ||
00963           m_Regions[wid].GetTauBit()  ||
00964           m_Regions[swid].GetTauBit() ||
00965           m_Regions[sid].GetTauBit()  ||
00966           m_Regions[cRgn].GetTauBit()
00967           ) 
00968         {
00969           if (!m_DoBitInfo) return false;
00970         } 
00971       else {
00972         if (!m_DoBitInfo) return true;
00973       }
00974 
00975     } else { et_isolation = 2; }         
00976 
00977 
00978     // Closing 2x3 method        
00979     if (et_isolation == 1 || shower_shape == 1 ) return false; // done at boarder        
00980     if (et_isolation == 2 && shower_shape == 0) return true; // done at boarder          
00981   }
00982 
00983   if ( (cRgn%22)>4 && (cRgn%22)<17){ // non-boarder
00984     if (nwid==999 || neid==999 || nid==999 || swid==999 || seid==999 || sid==999 || wid==999 || 
00985         eid==999 ) { 
00986       return false;
00987     }
00988     
00989     if (
00990         m_Regions[nwid].GetTauBit() ||
00991         m_Regions[nid].GetTauBit()  ||
00992         m_Regions[neid].GetTauBit() ||
00993         m_Regions[wid].GetTauBit()  ||
00994         m_Regions[eid].GetTauBit()  ||
00995         m_Regions[swid].GetTauBit() ||
00996         m_Regions[seid].GetTauBit() ||
00997         m_Regions[sid].GetTauBit()  ||
00998         m_Regions[cRgn].GetTauBit()
00999         ) 
01000       {
01001         if (m_DoBitInfo) m_Regions[cRgn].BitInfo.setIsolationVeto(true);
01002         et_isolation = 1; 
01003         if (!m_DoBitInfo) return false;
01004       } else {
01005       et_isolation = 2;
01006       if (!m_DoBitInfo) return true;
01007     }
01008     
01009     if (et_isolation == 1 || shower_shape == 1) return false;    
01010     if (et_isolation == 2 && shower_shape == 0) return true;     
01011   } // non-boarder
01012 
01013   return true; // shouldn't reach here
01014 }
01015 
01016 // ------------ Check if tower is emcand ------------
01017 // returns 1 = non-iso EM, 2 = iso EM, 0 = no EM
01018 int
01019 FastL1GlobalAlgo::isEMCand(CaloTowerDetId cid, l1extra::L1EmParticle* ph,const edm::Event& iEvent) {
01020 
01021   // center tower
01022   int crgn = m_RMap->getRegionIndex(cid);
01023   int ctwr = m_RMap->getRegionTowerIndex(cid);
01024 
01025   // crystals only in barrel/endcap part
01026   if ((crgn%22)<4 || (crgn%22)>17) return 0;
01027   if (crgn>395 || crgn < 0 || ctwr > 15 || ctwr < 0) return 0;
01028 
01029   CaloTowerCollection c = m_Regions.at(crgn).GetCaloTowers();
01030   double cenEt = c[ctwr].et();
01031   //double cenEt = RCTEnergyTrunc(c[ctwr].et(),0.5,64);
01032   //double cenE = c[ctwr].emEnergy();
01033   
01034   // Using region position rather than tower position
01035   std::pair<double, double> crpos = m_RMap->getRegionCenterEtaPhi(crgn);
01036   //double cenEta = c[ctwr].eta();
01037   //double cenPhi = c[ctwr].phi();
01038   double cenEta = crpos.first;
01039   double cenPhi = crpos.second;
01040 
01041   double cenFGbit = m_Regions.at(crgn).GetFGBit(ctwr);
01042   double cenHOEbit = m_Regions.at(crgn).GetHOEBit(ctwr);
01043 
01044   if (cenEt<m_L1Config.TowerEBThreshold) return 0;
01045 
01046   // check fine grain bit
01047   if (cenFGbit) return 0;
01048 
01049   // check H/E bit
01050   if (cenHOEbit) return 0;
01051 
01052   // check neighbours
01053   std::pair<int, int> no = m_RMap->GetTowerNorthEtaPhi(cid.ieta(),cid.iphi()); 
01054   std::pair<int, int> so = m_RMap->GetTowerSouthEtaPhi(cid.ieta(),cid.iphi()); 
01055   std::pair<int, int> we = m_RMap->GetTowerWestEtaPhi(cid.ieta(),cid.iphi()); 
01056   std::pair<int, int> ea = m_RMap->GetTowerEastEtaPhi(cid.ieta(),cid.iphi()); 
01057   std::pair<int, int> nw = m_RMap->GetTowerNWEtaPhi(cid.ieta(),cid.iphi()); 
01058   std::pair<int, int> ne = m_RMap->GetTowerNEEtaPhi(cid.ieta(),cid.iphi()); 
01059   std::pair<int, int> sw = m_RMap->GetTowerSWEtaPhi(cid.ieta(),cid.iphi()); 
01060   std::pair<int, int> se = m_RMap->GetTowerSEEtaPhi(cid.ieta(),cid.iphi()); 
01061   if (no.first>29 || no.first<-29 || no.second>72 || no.second<0) return 0;
01062   if (so.first>29 || so.first<-29 || so.second>72 || so.second<0) return 0;
01063   if (we.first>29 || we.first<-29 || we.second>72 || we.second<0) return 0;
01064   if (ea.first>29 || ea.first<-29 || ea.second>72 || ea.second<0) return 0;
01065   if (nw.first>29 || nw.first<-29 || nw.second>72 || nw.second<0) return 0;
01066   if (ne.first>29 || ne.first<-29 || ne.second>72 || ne.second<0) return 0;
01067   if (sw.first>29 || sw.first<-29 || sw.second>72 || sw.second<0) return 0;
01068   if (se.first>29 || se.first<-29 || se.second>72 || se.second<0) return 0;
01069 
01070   int notwr = m_RMap->getRegionTowerIndex(no);
01071   int norgn = m_RMap->getRegionIndex(no.first,no.second);
01072   int sotwr = m_RMap->getRegionTowerIndex(so);
01073   int sorgn = m_RMap->getRegionIndex(so.first,so.second);
01074   int wetwr = m_RMap->getRegionTowerIndex(we);
01075   int wergn = m_RMap->getRegionIndex(we.first,we.second);
01076   int eatwr = m_RMap->getRegionTowerIndex(ea);
01077   int eargn = m_RMap->getRegionIndex(ea.first,ea.second);
01078   int setwr = m_RMap->getRegionTowerIndex(se);
01079   int sergn = m_RMap->getRegionIndex(se.first,sw.second);
01080   int swtwr = m_RMap->getRegionTowerIndex(sw);
01081   int swrgn = m_RMap->getRegionIndex(sw.first,sw.second);
01082   int netwr = m_RMap->getRegionTowerIndex(ne);
01083   int nergn = m_RMap->getRegionIndex(ne.first,ne.second);
01084   int nwtwr = m_RMap->getRegionTowerIndex(nw);
01085   int nwrgn = m_RMap->getRegionIndex(nw.first,nw.second);
01086   
01087   //
01088   if (norgn>395 || norgn < 0 || notwr > 15 || notwr < 0) return 0;
01089   c = m_Regions[norgn].GetCaloTowers();
01090   double noEt = c[notwr].et();
01091   //double noEt = RCTEnergyTrunc(c[notwr].et(),0.5,64);
01092   //double noE = c[notwr].emEnergy();
01093   // check fine grain bit
01094   bool noFGbit = m_Regions[norgn].GetFGBit(notwr);
01095   // check H/E bit
01096   bool noHOEbit = m_Regions[norgn].GetHOEBit(notwr);
01097 
01098   //
01099   if (sorgn>395 || sorgn < 0 || sotwr > 15 || sotwr < 0) return 0;
01100   c = m_Regions[sorgn].GetCaloTowers();
01101   double soEt = c[sotwr].et();
01102   //double soEt = RCTEnergyTrunc(c[sotwr].et(),0.5,64);
01103   //double soE = c[sotwr].emEnergy();
01104   // check fine grain bit
01105   bool soFGbit = m_Regions[sorgn].GetFGBit(sotwr);
01106   // check H/E bit
01107   bool soHOEbit = m_Regions[sorgn].GetHOEBit(sotwr);
01108 
01109   //
01110   if (wergn>395 || wergn < 0 || wetwr > 15 || wetwr < 0) return 0;
01111   c = m_Regions[wergn].GetCaloTowers();
01112   double weEt = c[wetwr].et();
01113   //double weEt = RCTEnergyTrunc(c[wetwr].et(),0.5,64);
01114   //double weE = c[wetwr].emEnergy();
01115   // check fine grain bit
01116   bool weFGbit = m_Regions[wergn].GetFGBit(wetwr);
01117   // check H/E bit
01118   bool weHOEbit = m_Regions[wergn].GetHOEBit(wetwr);
01119 
01120   //
01121   if (eargn>395 || eargn < 0 || eatwr > 15 || eatwr < 0) return 0;
01122   c = m_Regions[eargn].GetCaloTowers();
01123   double eaEt = c[eatwr].et();
01124   //double eaEt = RCTEnergyTrunc(c[eatwr].et(),0.5,64);
01125   //double eaE = c[eatwr].emEnergy();
01126   // check fine grain bit
01127   bool eaFGbit = m_Regions[eargn].GetFGBit(eatwr);
01128   // check H/E bit
01129   bool eaHOEbit = m_Regions[eargn].GetHOEBit(eatwr);
01130 
01131   //
01132   if (nwrgn>395 || nwrgn < 0 || nwtwr > 15 || nwtwr < 0) return 0;
01133   c = m_Regions[nwrgn].GetCaloTowers();
01134   double nwEt = c[nwtwr].et();
01135   //double nwEt = RCTEnergyTrunc(c[nwtwr].et(),0.5,64);
01136   //double nwE = c[nwtwr].emEnergy();
01137   // check fine grain bit
01138   bool nwFGbit = m_Regions[nwrgn].GetFGBit(nwtwr);
01139   // check H/E bit
01140   bool nwHOEbit = m_Regions[nwrgn].GetHOEBit(nwtwr);
01141 
01142   //
01143   if (nergn>395 || nergn < 0 || netwr > 15 || netwr < 0) return 0;
01144   c = m_Regions[nergn].GetCaloTowers();
01145   double neEt = c[netwr].et();
01146   //double neEt = RCTEnergyTrunc(c[netwr].et(),0.5,64);
01147   //double neE = c[netwr].emEnergy();
01148   // check fine grain bit
01149   bool neFGbit = m_Regions[nergn].GetFGBit(netwr);
01150   // check H/E bit
01151   bool neHOEbit = m_Regions[nergn].GetHOEBit(netwr);
01152 
01153   //
01154   if (swrgn>395 || swrgn < 0 || swtwr > 15 || swtwr < 0) return 0;
01155   c = m_Regions[swrgn].GetCaloTowers();
01156   double swEt = c[swtwr].et();
01157   //double swEt = RCTEnergyTrunc(c[swtwr].et(),0.5,64);
01158   //double swE = c[swtwr].emEnergy();
01159   // check fine grain bit
01160   bool swFGbit = m_Regions[swrgn].GetFGBit(swtwr);
01161   // check H/E bit
01162   bool swHOEbit = m_Regions[swrgn].GetHOEBit(swtwr);
01163 
01164   //
01165   if (sergn>395 || sergn < 0 || setwr > 15 || setwr < 0) return 0;
01166   c = m_Regions[sergn].GetCaloTowers();
01167   double seEt = c[setwr].et();
01168   //double seEt = RCTEnergyTrunc(c[setwr].et(),0.5,64);
01169   //double seE = c[setwr].emEnergy();
01170   // check fine grain bit
01171   bool seFGbit = m_Regions[sergn].GetFGBit(setwr);
01172   // check H/E bit
01173   bool seHOEbit = m_Regions[sergn].GetHOEBit(setwr);
01174 
01175   
01176   // check if highest et tower
01177   bool isHit = false;
01178   if ( cenEt > noEt && cenEt >= soEt && cenEt > weEt &&
01179        cenEt >= eaEt && cenEt > nwEt && cenEt > neEt &&
01180        cenEt >= swEt && cenEt >= seEt ) isHit = true;
01181   else 
01182     return 0;
01183 
01184   // find highest neighbour
01185   double hitEt = cenEt;
01186   //double hitE = cenE;
01187   double maxEt = std::max(noEt,std::max(soEt,std::max(weEt,eaEt)));
01188   //double maxE = std::max(noE,std::max(soE,std::max(weE,eaE)));
01189 
01190   // check 2 tower Et
01191   float emEtThres = m_L1Config.EMSeedEnThreshold;
01192   
01193   // at this point candidate is at least non-iso Egamma
01194   //double eme = (hitE+maxE);
01195   //double eme = (hitE+maxE);
01196   double emet = (hitEt+maxEt);
01197 
01198   /*
01199     if (m_L1Config.DoEMCorr) {
01200     emet = GCTEnergyTrunc(corrEmEt(emet,cenEta),m_L1Config.EMLSB, true);
01201     //emet = GCTEnergyTrunc(emet,m_L1Config.EMLSB, true);
01202     } else {
01203     emet = GCTEnergyTrunc(emet,m_L1Config.EMLSB, true);
01204     }
01205   */
01206   emet = GCTEnergyTrunc(emet,m_L1Config.EMLSB, true);
01207 
01208   if ((emet)<emEtThres) return 0;
01209 
01210   double emtheta = 2.*atan(exp(-cenEta));
01211   //double emet = eme*sin(emtheta);
01212   double emex = emet*cos(cenPhi);
01213   double emey = emet*sin(cenPhi);
01214   //double emex = eme*sin(emtheta)*cos(cenPhi);
01215   //double emey = eme*sin(emtheta)*sin(cenPhi);
01216   double eme = emex/sin(emtheta)/cos(cenPhi);
01217   double emez = eme*cos(emtheta);
01218 
01219 
01220   reco::Particle::LorentzVector rp4(emex,emey,emez,eme);
01221   //reco::Particle::Point rp3(0.,0.,0.);
01222   //reco::Particle::Charge q(0);
01223   //*ph = reco::Photon(q,rp4,rp3);
01224   *ph = l1extra::L1EmParticle(rp4);
01225   //ph = l1extra::L1EmParticle(rp4);
01226 
01227   //std::cout<<"EM eme     : "<<eme<<std::endl;
01228   //std::cout<<"EM rp4.et(): "<<rp4.Et()<<std::endl;
01229   //std::cout<<"EM ph->et() : "<<ph->et()<<std::endl;
01230  
01231   //if (emet>0.) {
01232   //  std::cout << "em region et, eta, phi: "<< emet<<" "<< cenEta<<" "<< cenPhi<<" " << std::endl;
01233   //  std::cout << "em lv et, eta, phi: "<< ph->et()<<" "<< ph->eta()<<" "<< ph->phi()<<" " << std::endl;
01234   //}
01235 
01236   // check isolation FG bits
01237   if (noFGbit || soFGbit || weFGbit || eaFGbit || 
01238       nwFGbit || neFGbit || swFGbit || seFGbit ||
01239       noHOEbit || soHOEbit || weHOEbit || eaHOEbit || 
01240       nwHOEbit || neHOEbit || swHOEbit || seHOEbit)
01241     return 1;
01242   
01243   // check isolation corners
01244   //double corThres = 0.4;
01245   //double quietThres = m_L1Config.EMNoiseLevel;
01246   double quietThres = m_L1Config.QuietRegionThreshold;
01247   bool isoVeto1 = false,isoVeto2 = false,isoVeto3 = false,isoVeto4 = false;
01248   if (swEt>quietThres || weEt>quietThres || nwEt>quietThres || noEt>quietThres || neEt>quietThres ) {
01249     //if ((swEt + weEt + nwEt + noEt + neEt)/cenEt > corThres) 
01250     isoVeto1 = true;
01251   }
01252   if (neEt>quietThres || eaEt>quietThres || seEt>quietThres || soEt>quietThres || swEt>quietThres ) {
01253     //if ((neEt + eaEt + seEt + soEt + swEt)/cenEt > corThres) 
01254     isoVeto2 = true;
01255   }
01256   if (nwEt>quietThres || noEt>quietThres || neEt>quietThres || eaEt>quietThres || seEt>quietThres ) {
01257     //if ((nwEt + noEt + neEt + eaEt + seEt)/cenEt > corThres) 
01258     isoVeto3 = true;
01259   }
01260   if (seEt>quietThres || soEt>quietThres || swEt>quietThres || weEt>quietThres || nwEt>quietThres ) {
01261     //if ((seEt + soEt + swEt + weEt + nwEt)/cenEt > corThres) 
01262     isoVeto4 = true;
01263   }
01264   if (isoVeto1 && isoVeto2 && isoVeto3 && isoVeto4)
01265     return 1;
01266   
01267   return 2;    
01268 }
01269 
01270 
01271 // is central region the highest Et Region?
01272 bool 
01273 FastL1GlobalAlgo::isMaxEtRgn_Window33(int crgn) {
01274 
01275   int nwid = m_Regions.at(crgn).GetNWId();
01276   int nid = m_Regions.at(crgn).GetNorthId();
01277   int neid = m_Regions.at(crgn).GetNEId();
01278   int wid = m_Regions.at(crgn).GetWestId();
01279   int eid = m_Regions.at(crgn).GetEastId();
01280   int swid = m_Regions.at(crgn).GetSWId();
01281   int sid = m_Regions.at(crgn).GetSouthId();
01282   int seid = m_Regions.at(crgn).GetSEId();
01283 
01284 
01285   //Use 3x2 window at eta borders!
01286   // east border:
01287   if ((crgn%22)==21) { 
01288     
01289     if (nwid==999 || nid==999 || swid==999 || sid==999 || wid==999 ) { 
01290       return false;
01291     }
01292 
01293     double cenet = m_Regions.at(crgn).SumEt();
01294     double nwet =  m_Regions[nwid].SumEt();
01295     double noet = m_Regions[nid].SumEt();
01296     double weet = m_Regions[wid].SumEt();
01297     double swet = m_Regions[swid].SumEt();
01298     double soet = m_Regions[sid].SumEt();
01299     
01300     if ( cenet > nwet &&  cenet > noet &&
01301          cenet >= weet &&  cenet >= soet &&
01302          cenet >= swet ) 
01303       {
01304 
01305         double cene = m_Regions.at(crgn).SumE();
01306         double nwe =  m_Regions[nwid].SumE();
01307         double noe = m_Regions[nid].SumE();
01308         double wee = m_Regions[wid].SumE();
01309         double swe = m_Regions[swid].SumE();
01310         double soe = m_Regions[sid].SumE();
01311         
01312         // if region is central: jet energy is sum of 3x3 region
01313         // surrounding the central region
01314         double jE = cene + nwe + noe + wee + swe + soe;
01315         double jEt = cenet + nwet + noet + weet + swet + soet;
01316         
01317 
01318         m_Regions.at(crgn).SetJetE(jE);
01319         m_Regions.at(crgn).SetJetEt(jEt);
01320         
01321         m_Regions.at(crgn).SetJetE3x3(cene);
01322         m_Regions.at(crgn).SetJetEt3x3(cenet);
01323         
01324         return true;
01325       } else { return false; }
01326     
01327   }
01328 
01329 
01330   // west border:
01331   if ((crgn%22)==0) { 
01332     
01333     if (neid==999 || nid==999 || seid==999 || sid==999 || eid==999 ) { 
01334       return false;
01335     }
01336 
01337     double cenet = m_Regions.at(crgn).SumEt();
01338     double neet =  m_Regions[neid].SumEt();
01339     double noet = m_Regions[nid].SumEt();
01340     double eaet = m_Regions[eid].SumEt();
01341     double seet = m_Regions[seid].SumEt();
01342     double soet = m_Regions[sid].SumEt();
01343     
01344     if ( cenet > neet &&  cenet > noet &&
01345          cenet >= eaet &&  cenet >= soet &&
01346          cenet >= seet ) 
01347       {
01348 
01349         double cene = m_Regions.at(crgn).SumE();
01350         double nee =  m_Regions[neid].SumE();
01351         double noe = m_Regions[nid].SumE();
01352         double eae = m_Regions[eid].SumE();
01353         double see = m_Regions[seid].SumE();
01354         double soe = m_Regions[sid].SumE();
01355         
01356         // if region is central: jet energy is sum of 3x3 region
01357         // surrounding the central region
01358         double jE = cene + nee + noe + eae + see + soe;
01359         double jEt = cenet + neet + noet + eaet + seet + soet;
01360         
01361         m_Regions.at(crgn).SetJetE(jE);
01362         m_Regions.at(crgn).SetJetEt(jEt);
01363         
01364         m_Regions.at(crgn).SetJetE3x3(cene);
01365         m_Regions.at(crgn).SetJetEt3x3(cenet);
01366         
01367         return true;
01368       } else { return false; }
01369     
01370   }
01371 
01372 
01373   if (nwid==999 || neid==999 || nid==999 || swid==999 || seid==999 || sid==999 || wid==999 || 
01374       eid==999 ) { 
01375     //std::cerr << "FastL1GlobalAlgo::isMaxEtRgn_Window33(): RegionId out of bounds: " << std::endl
01376     //      << nwid << " " << nid << " "  << neid << " " << std::endl
01377     //      << wid << " " << crgn << " "  << eid << " " << std::endl
01378     //      << swid << " " << sid << " "  << seid << " " << std::endl;    
01379     return false;
01380   }
01381 
01382   double cenet = m_Regions.at(crgn).SumEt();
01383   double nwet =  m_Regions[nwid].SumEt();
01384   double noet = m_Regions[nid].SumEt();
01385   double neet = m_Regions[neid].SumEt();
01386   double weet = m_Regions[wid].SumEt();
01387   double eaet = m_Regions[eid].SumEt();
01388   double swet = m_Regions[swid].SumEt();
01389   double soet = m_Regions[sid].SumEt();
01390   double seet = m_Regions[seid].SumEt();
01391 
01392   if ( cenet > nwet &&  cenet > noet &&
01393        cenet > neet &&  cenet >= eaet &&
01394        cenet > weet &&  cenet >= soet &&
01395        cenet >= swet &&  cenet >= seet ) 
01396     {
01397 
01398       double cene = m_Regions.at(crgn).SumE();
01399       double nwe =  m_Regions[nwid].SumE();
01400       double noe = m_Regions[nid].SumE();
01401       double nee = m_Regions[neid].SumE();
01402       double wee = m_Regions[wid].SumE();
01403       double eae = m_Regions[eid].SumE();
01404       double swe = m_Regions[swid].SumE();
01405       double soe = m_Regions[sid].SumE();
01406       double see = m_Regions[seid].SumE();
01407 
01408       // if region is central: jet energy is sum of 3x3 region
01409       // surrounding the central region
01410       double jE = cene + nwe + noe + nee + wee + eae + swe + soe + see;
01411       double jEt = cenet + nwet + noet + neet + weet + eaet + swet + soet + seet;
01412 
01413 
01414       m_Regions.at(crgn).SetJetE(jE);
01415       m_Regions.at(crgn).SetJetEt(jEt);
01416 
01417       m_Regions.at(crgn).SetJetE3x3(cene);
01418       m_Regions.at(crgn).SetJetEt3x3(cenet);
01419       
01420       return true;
01421     } else { return false; }
01422 
01423 }
01424 
01425 
01426 void
01427 FastL1GlobalAlgo::checkMapping() {
01428 
01429   // loop over towers ieta,iphi
01430   for (int j=1;j<=72;j++) {
01431     for (int i=-28; i<=28; i++) {
01432       if (i==0) continue;
01433       int iRgn =  m_RMap->getRegionIndex(i,j);
01434       std::pair<double, double> RgnEtaPhi = m_RMap->getRegionCenterEtaPhi(iRgn);
01435       //int iTwr = m_RMap->getRegionTowerIndex(i,j);
01436       std::pair<int, int> iRgnEtaPhi = m_RMap->getRegionEtaPhiIndex(iRgn);
01437       std::pair<int, int> iRgnEtaPhi2 = m_RMap->getRegionEtaPhiIndex(std::pair<int, int>(i,j));
01438 
01439       std::cout<<"---------------------------------------------------------------------------"<<std::endl;
01440       std::cout<<"Region:   "<<iRgn<<" | "<<RgnEtaPhi.first<<", "<<RgnEtaPhi.second*180./3.141<<std::endl;
01441       std::cout<<"   -      "<<iRgnEtaPhi.first<<", "<<iRgnEtaPhi.second<<std::endl;
01442       std::cout<<"   -      "<<iRgnEtaPhi2.first<<", "<<iRgnEtaPhi2.second<<std::endl;
01443       std::cout<<" Tower:   "<<i<<", "<<m_RMap->convertFromECal_to_HCal_iphi(j)<<std::endl;
01444       std::cout<<" TowerId: "<<m_RMap->getRegionTowerIndex(i,j)<<std::endl;
01445 
01446     }
01447   }
01448 
01449 }
01450 
01451 double
01452 FastL1GlobalAlgo::hcaletValue(const int ieta,const int compET) {
01453   double etvalue = m_hcaluncomp[ieta][compET];//*cos(eta_ave);
01454   return etvalue;
01455 }
01456 
01457 // Et Check      
01458 bool     
01459 FastL1GlobalAlgo::TauIsolation(int cRgn) {       
01460                  
01461   if ((cRgn%22)<4 || (cRgn%22)>17) return false;         
01462                  
01463   double iso_threshold =  m_IsolationEt; // arbitrarily set      
01464   int shower_shape = 0;          
01465   int et_isolation = 0;          
01466   unsigned int iso_count = 0;    
01467                  
01468   int nwid = m_Regions[cRgn].GetNWId();          
01469   int nid = m_Regions[cRgn].GetNorthId();        
01470   int neid = m_Regions[cRgn].GetNEId();          
01471   int wid = m_Regions[cRgn].GetWestId();         
01472   int eid = m_Regions[cRgn].GetEastId();         
01473   int swid = m_Regions[cRgn].GetSWId();          
01474   int sid = m_Regions[cRgn].GetSouthId();        
01475   int seid = m_Regions[cRgn].GetSEId();          
01476                  
01477   if (m_Regions[cRgn].GetTauBit()) shower_shape = 1; // check center     
01478   if((cRgn%22)==4  || (cRgn%22)==17 ) {          
01479     // west border       
01480     if ((cRgn%22)==4) {          
01481       if( m_Regions[neid].SumEt() > iso_threshold){      
01482         iso_count ++;    
01483         if (m_Regions[neid].GetTauBit()) iso_count++;    
01484       }          
01485       if( m_Regions[nid].SumEt() > iso_threshold){       
01486         iso_count ++;    
01487         if (m_Regions[nid].GetTauBit()) iso_count++;     
01488       }          
01489       if( m_Regions[eid].SumEt() > iso_threshold){       
01490         iso_count ++;    
01491         if (m_Regions[eid].GetTauBit()) iso_count++;     
01492       }          
01493       if( m_Regions[seid].SumEt() > iso_threshold){      
01494         iso_count ++;    
01495         if (m_Regions[seid].GetTauBit()) iso_count++;    
01496       }          
01497       if( m_Regions[sid].SumEt() > iso_threshold){       
01498         iso_count ++;    
01499         if (m_Regions[sid].GetTauBit()) iso_count++;     
01500       }          
01501                  
01502       if (iso_count >= 2 ){      
01503         if (m_DoBitInfo){        
01504           m_Regions[cRgn].BitInfo.setIsolationVeto ( true);      
01505           // m_Regions[cRgn].BitInfo.setIsolationCount ( iso_count);     
01506         }        
01507         et_isolation = 1;        
01508       }          
01509       else{ et_isolation = 2;}   
01510     } // west bd         
01511                  
01512     // east border:      
01513     if ((cRgn%22)==17) {         
01514       if( m_Regions[nwid].SumEt() > iso_threshold){      
01515         iso_count ++;    
01516         if (m_Regions[nwid].GetTauBit()) iso_count++;    
01517       }          
01518       if( m_Regions[nid].SumEt() > iso_threshold){       
01519         iso_count ++;    
01520         if (m_Regions[nid].GetTauBit()) iso_count++;     
01521       }          
01522       if( m_Regions[wid].SumEt() > iso_threshold){       
01523         iso_count ++;    
01524         if (m_Regions[wid].GetTauBit()) iso_count++;     
01525       }          
01526       if( m_Regions[swid].SumEt() > iso_threshold){      
01527         iso_count ++;    
01528         if (m_Regions[swid].GetTauBit()) iso_count++;    
01529       }          
01530       if( m_Regions[sid].SumEt() > iso_threshold){       
01531         iso_count ++;    
01532         if (m_Regions[sid].GetTauBit()) iso_count++;     
01533       }          
01534                  
01535       if (iso_count >= 2 ){      
01536         if (m_DoBitInfo){        
01537           m_Regions[cRgn].BitInfo.setIsolationVeto ( true);      
01538           // m_Regions[cRgn].BitInfo.setIsolationCount ( iso_count);     
01539         }        
01540         et_isolation = 1;        
01541       }          
01542       else{ et_isolation = 2;}   
01543     } // east bd         
01544                  
01545     // Closing 2x3 method        
01546     if (et_isolation == 1 || shower_shape == 1 ) return false; // done at boarder        
01547     if (et_isolation == 2 && shower_shape == 0) return true; // done at boarder          
01548   }      
01549                  
01550   if ( (cRgn%22)>4 && (cRgn%22)<17){ // non-boarder      
01551     if (nwid==999 || neid==999 || nid==999 || swid==999 || seid==999 || sid==999 || wid==999 ||          
01552         eid==999 ) {     
01553       return false;      
01554     }    
01555                  
01556     if( m_Regions[neid].SumEt() > iso_threshold){        
01557       iso_count ++;      
01558       if (m_Regions[neid].GetTauBit()) iso_count++;      
01559     }    
01560     if( m_Regions[nid].SumEt() > iso_threshold){         
01561       iso_count ++;      
01562       if (m_Regions[nid].GetTauBit()) iso_count++;       
01563     }    
01564     if( m_Regions[eid].SumEt() > iso_threshold){         
01565       iso_count ++;      
01566       if (m_Regions[eid].GetTauBit()) iso_count++;       
01567     }    
01568     if( m_Regions[seid].SumEt() > iso_threshold){        
01569       iso_count ++;      
01570       if (m_Regions[seid].GetTauBit()) iso_count++;      
01571     }    
01572     if( m_Regions[sid].SumEt() > iso_threshold){         
01573       iso_count ++;      
01574       if (m_Regions[sid].GetTauBit()) iso_count++;       
01575     }    
01576     if( m_Regions[nwid].SumEt() > iso_threshold){        
01577       iso_count ++;      
01578       if (m_Regions[nwid].GetTauBit()) iso_count++;      
01579     }    
01580     if( m_Regions[wid].SumEt() > iso_threshold){         
01581       iso_count ++;      
01582       if (m_Regions[wid].GetTauBit()) iso_count++;       
01583     }    
01584     if( m_Regions[swid].SumEt() > iso_threshold){        
01585       iso_count ++;      
01586       if (m_Regions[swid].GetTauBit()) iso_count++;      
01587     }    
01588                  
01589     if (iso_count >= 2 ){        
01590       if (m_DoBitInfo){          
01591         m_Regions[cRgn].BitInfo.setIsolationVeto ( true);        
01592         // m_Regions[cRgn].BitInfo.setIsolationCount ( iso_count);       
01593       }          
01594       et_isolation = 1;          
01595     }    
01596     else {et_isolation = 2;}     
01597                  
01598     if (et_isolation == 1 || shower_shape == 1) return false;    
01599     if (et_isolation == 2 && shower_shape == 0) return true;     
01600   }// non-boarder        
01601                  
01602   return true; // shouldn't reach here   
01603 }//
01604 

Generated on Tue Jun 9 17:35:09 2009 for CMSSW by  doxygen 1.5.4