CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/L1Trigger/GlobalMuonTrigger/src/L1MuGMTMipIsoAU.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuGMTMipIsoAU
00004 //
00005 //   Description:  GMT MIP & ISO bit assignment unit
00006 //
00007 //
00008 //   $Date: 2007/04/10 09:59:19 $
00009 //   $Revision: 1.4 $
00010 //
00011 //   Author :
00012 //   H. Sakulin                CERN EP 
00013 //
00014 //   Migrated to CMSSW:
00015 //   I. Mikulec
00016 //
00017 //--------------------------------------------------
00018 
00019 //-----------------------
00020 // This Class's Header --
00021 //-----------------------
00022 
00023 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTMipIsoAU.h"
00024 
00025 //---------------
00026 // C++ Headers --
00027 //---------------
00028 
00029 #include <iostream>
00030 #include <vector>
00031 #include <cmath>
00032 #include <string>
00033 #include <sstream>
00034 
00035 //-------------------------------
00036 // Collaborating Class Headers --
00037 //-------------------------------
00038 
00039 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTConfig.h"
00040 #include "L1Trigger/GlobalMuonTrigger/interface/L1MuGlobalMuonTrigger.h"
00041 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTPSB.h"
00042 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTPhiProjectionUnit.h"
00043 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTEtaProjectionUnit.h"
00044 
00045 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTDebugBlock.h"
00046 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00047 
00048 // --------------------------------
00049 //       class L1MuGMTMipIsoAU
00050 //---------------------------------
00051 
00052 //----------------
00053 // Constructors --
00054 //----------------
00055 L1MuGMTMipIsoAU::L1MuGMTMipIsoAU(const L1MuGlobalMuonTrigger& gmt, int id) : 
00056   m_gmt(gmt), m_id(id), m_muons(8), m_MIP(8), m_ISO(8),
00057   m_MIP_PPUs(8), m_MIP_EPUs(8), m_ISO_PPUs(8), m_ISO_EPUs(8) {
00058 
00059   m_muons.reserve(8);
00060   m_MIP.reserve(8);
00061   m_ISO.reserve(8);
00062         
00063   // reserve MIP and ISO phi and eta projection units
00064   m_MIP_PPUs.reserve(8);
00065   m_MIP_EPUs.reserve(8);
00066   m_ISO_PPUs.reserve(8);
00067   m_ISO_EPUs.reserve(8);
00068         
00069   for (int i=0; i<8; i++) {
00070     m_MIP_PPUs[i]=new L1MuGMTPhiProjectionUnit (*this, 16 * m_id + i) ;
00071     m_MIP_EPUs[i]=new L1MuGMTEtaProjectionUnit (*this, 16 * m_id + i) ;
00072                 
00073     m_ISO_PPUs[i]=new L1MuGMTPhiProjectionUnit (*this, 16 * m_id + 8 + i) ;
00074     m_ISO_EPUs[i]=new L1MuGMTEtaProjectionUnit (*this, 16 * m_id + 8 + i) ;
00075   }
00076 
00077 }
00078 
00079 //--------------
00080 // Destructor --
00081 //--------------
00082 L1MuGMTMipIsoAU::~L1MuGMTMipIsoAU() { 
00083 
00084   reset();
00085         
00086   // delete MIP phi projection units    
00087   std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
00088   for ( p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++ )
00089     delete *p_iter;
00090   m_MIP_PPUs.clear();
00091         
00092   // delete ISO phi projection units    
00093   for ( p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++ )
00094     delete *p_iter;
00095   m_ISO_PPUs.clear();
00096 
00097   // delete MIP eta projection units    
00098   std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
00099   for ( e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++ )
00100         delete *e_iter;
00101   m_MIP_EPUs.clear();
00102         
00103   // delete ISO eta projection units    
00104   for ( e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++ )
00105         delete *e_iter;
00106   m_ISO_EPUs.clear();
00107 }
00108 
00109 //--------------
00110 // Operations --
00111 //--------------
00112 
00113 //
00114 // run MIP & ISO assignment unit
00115 //
00116 void L1MuGMTMipIsoAU::run() {
00117 
00118   load();
00119 
00120   // run MIP phi projection units       
00121   std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
00122   for ( p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++ )
00123     (*p_iter)->run();
00124         
00125   // run ISO phi projection units       
00126   for ( p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++ )
00127     (*p_iter)->run();
00128 
00129   // run MIP eta projection units       
00130   std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
00131   for ( e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++ )
00132     (*e_iter)->run();
00133         
00134   // run ISO eta projection units       
00135   for ( e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++ )
00136     (*e_iter)->run();
00137         
00138   assignMIP();
00139   assignISO();
00140 }
00141 
00142 
00143 //
00144 // reset MIP & ISO assignment unit
00145 //
00146 void L1MuGMTMipIsoAU::reset() {
00147 
00148   for ( int i = 0; i < 8; i++ ) {  
00149     m_muons[i] = 0;
00150     m_MIP[i] = false;
00151     m_ISO[i] = false;
00152   }
00153         
00154   // reset MIP phi projection units     
00155   std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
00156   for ( p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++ ) {
00157     (*p_iter)->reset();
00158   }
00159         
00160   // reset ISO phi projection units     
00161   for ( p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++ )
00162     (*p_iter)->reset();
00163 
00164   // reset MIP eta projection units     
00165   std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
00166   for ( e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++ )
00167     (*e_iter)->reset();
00168         
00169   // reset ISO eta projection units     
00170   for ( e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++ )
00171     (*e_iter)->reset();
00172 }
00173 
00174 
00175 //
00176 // print results of MIP & ISO assignment
00177 //
00178 void L1MuGMTMipIsoAU::print() const {
00179 
00180   std::stringstream outmip;
00181   outmip << "Assigned MIP bits : ";
00182   std::vector<bool>::const_iterator iter;
00183   for ( iter = m_MIP.begin(); iter != m_MIP.end(); iter++ ) {
00184     outmip << (*iter) << "  ";
00185   }
00186   edm::LogVerbatim("GMT_MipIso_info") << outmip.str();
00187 
00188   std::stringstream outiso;
00189   outiso << "Assigned ISO bits : ";
00190   for ( iter = m_ISO.begin(); iter != m_ISO.end(); iter++ ) {
00191     outiso << (*iter) << "  ";
00192   }
00193   edm::LogVerbatim("GMT_MipIso_info") << outiso.str();
00194 }
00195 
00196 
00197 //
00198 // load MIP & ISO assignment unit (get data from PSB)
00199 //
00200 void L1MuGMTMipIsoAU::load() {
00201 
00202   // barrel MIP & ISO assignment unit gets DTBX and barrel RPC muons
00203   if ( m_id == 0 ) {
00204     for ( unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++ ) {
00205       m_muons[idt] = m_gmt.Data()->DTBXMuon(idt);
00206     }
00207     for ( unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCbarrel; irpc++ ) {
00208       m_muons[irpc+4] = m_gmt.Data()->RPCMuon(irpc);
00209     }
00210   }
00211   
00212   // endcap MIP & ISO assignment unit gets CSC and endcap RPC muons
00213   if ( m_id == 1 ) {  
00214     for ( unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++ ) {
00215       m_muons[icsc] = m_gmt.Data()->CSCMuon(icsc);
00216     }
00217     for ( unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCendcap; irpc++ ) {
00218       m_muons[irpc+4] = m_gmt.Data()->RPCMuon(irpc+4);
00219     }
00220   }
00221  
00222 }
00223 
00224 //
00225 // run MIP assignment
00226 //
00227 void L1MuGMTMipIsoAU::assignMIP() {
00228 
00229   // get MIP bits from PSB
00230   const L1MuGMTMatrix<bool>& mip = m_gmt.Data()->mipBits();
00231 
00232   for ( int imuon = 0; imuon < 8; imuon++ ) 
00233     if (m_muons[imuon] && !m_muons[imuon]->empty() ) {
00234       bool tmpMIP=false;
00235 
00236       for ( int iphi = 0; iphi < 18; iphi++ )
00237         for ( int ieta = 0; ieta < 14; ieta++ ) {
00238           if (m_MIP_PPUs[imuon]->isSelected(iphi) &&
00239               m_MIP_EPUs[imuon]->isSelected(ieta) ) {
00240             tmpMIP |= mip(ieta, iphi);
00241             if ( L1MuGMTConfig::Debug(3) ) edm::LogVerbatim("GMT_MipIso_info") << "L1MuGMTMipIsoAU::assignMIP() checking calo region phi=" << 
00242               iphi << ", eta="  << ieta;
00243           }
00244         }
00245       m_MIP[imuon] = tmpMIP;
00246       m_gmt.DebugBlockForFill()->SetIsMIPISO( m_MIP_PPUs[imuon]->id(), tmpMIP?1:0) ;      
00247   }
00248 }
00249 
00250 
00251 //
00252 // run ISO assignment
00253 //
00254 void L1MuGMTMipIsoAU::assignISO() {
00255   
00256   // get isolation bits from PSB
00257   const L1MuGMTMatrix<bool>& isol = m_gmt.Data()->isolBits();
00258   
00259   for ( int imuon = 0; imuon < 8; imuon++ )
00260     if (m_muons[imuon] && !m_muons[imuon]->empty() ) {
00261       bool tmpISO=true;
00262       bool any=false;
00263 
00264       for ( int iphi = 0; iphi < 18; iphi++ )
00265         for ( int ieta = 0; ieta < 14; ieta++ ) {
00266           if (m_ISO_PPUs[imuon]->isSelected(iphi) &&
00267               m_ISO_EPUs[imuon]->isSelected(ieta) ) {
00268             tmpISO &= isol(ieta, iphi);
00269             any  = true;
00270             if ( L1MuGMTConfig::Debug(3) ) edm::LogVerbatim("GMT_MipIso_info") << "L1MuGMTMipIsoAU::assignISO() checking calo region phi=" << 
00271               iphi << ", eta="  << ieta;
00272           }
00273         }
00274       if (any) m_ISO[imuon] = tmpISO;
00275       else edm::LogWarning("MipISOProblem") << "L1MuGMTMipIsoAU::assignISO(): no calo region was checked!!"; 
00276 
00277       m_gmt.DebugBlockForFill()->SetIsMIPISO( m_ISO_PPUs[imuon]->id(), m_ISO[imuon]?1:0) ;      
00278     }
00279  
00280 }
00281 
00282 
00283 
00284 
00285 
00286 
00287