CMS 3D CMS Logo

L1MuGMTPSB.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuGMTPSB
00004 //
00005 //   Description: Pipelined Synchronising Buffer module 
00006 //
00007 //
00008 //   $Date: 2009/03/06 18:27:00 $
00009 //   $Revision: 1.12.2.2 $
00010 //
00011 //   Author :
00012 //   N. Neumeister            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/L1MuGMTPSB.h"
00024 
00025 //---------------
00026 // C++ Headers --
00027 //---------------
00028 
00029 #include <iostream>
00030 #include <iomanip>
00031 #include <vector>
00032 
00033 //-------------------------------
00034 // Collaborating Class Headers --
00035 //-------------------------------
00036 
00037 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTConfig.h"
00038 #include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
00039 #include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
00040 
00041 #include "L1Trigger/GlobalMuonTrigger/interface/L1MuGlobalMuonTrigger.h"
00042 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
00043 
00044 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00045 
00046 // --------------------------------
00047 //       class L1MuGMTPSB
00048 //---------------------------------
00049 
00050 //----------------
00051 // Constructors --
00052 //----------------
00053 L1MuGMTPSB::L1MuGMTPSB(const L1MuGlobalMuonTrigger& gmt) : 
00054                m_gmt(gmt), 
00055                m_RpcMuons(L1MuGMTConfig::MAXRPC),
00056                m_DtbxMuons(L1MuGMTConfig::MAXDTBX), 
00057                m_CscMuons(L1MuGMTConfig::MAXCSC),
00058                m_Isol(14,18), m_Mip(14,18) {
00059 
00060   m_RpcMuons.reserve(L1MuGMTConfig::MAXRPC);
00061   m_DtbxMuons.reserve(L1MuGMTConfig::MAXDTBX);
00062   m_CscMuons.reserve(L1MuGMTConfig::MAXCSC);
00063   m_Isol.init(false);
00064   m_Mip.init(false);
00065 
00066 }
00067 
00068 //--------------
00069 // Destructor --
00070 //--------------
00071 L1MuGMTPSB::~L1MuGMTPSB() { 
00072 
00073   reset();
00074   m_RpcMuons.clear();
00075   m_DtbxMuons.clear();
00076   m_CscMuons.clear();
00077   
00078 }
00079 
00080 //--------------
00081 // Operations --
00082 //--------------
00083 
00084 //
00085 // receive data
00086 //
00087 void L1MuGMTPSB::receiveData(edm::Event& e, int bx) {
00088 
00090 
00091   edm::Handle<std::vector<L1MuRegionalCand> > rc_handle;
00092 
00093   if((L1MuGMTConfig::getDTInputTag()).label() != "none" ) {
00094     e.getByLabel(L1MuGMTConfig::getDTInputTag(),rc_handle);
00095     if(rc_handle.isValid()) {
00096       getDTBX(rc_handle.product(),bx);
00097     } else {
00098       edm::LogWarning("GlobalMuonTrigger")
00099       << "\nWarning: GlobalMuonTrigger: input tag " << L1MuGMTConfig::getDTInputTag()
00100       << "\nrequested, but not found in the event." << std::endl;      
00101     }
00102   }
00103   if((L1MuGMTConfig::getCSCInputTag()).label() != "none" ) {
00104     e.getByLabel(L1MuGMTConfig::getCSCInputTag(),rc_handle);
00105     if(rc_handle.isValid()) {
00106       getCSC(rc_handle.product(),bx);
00107     } else {
00108       edm::LogWarning("GlobalMuonTrigger")
00109       << "\nWarning: GlobalMuonTrigger: input tag " << L1MuGMTConfig::getCSCInputTag()
00110       << "\nrequested, but not found in the event." << std::endl;      
00111     }
00112   }
00113   if((L1MuGMTConfig::getRPCbInputTag()).label() != "none" ) {
00114     e.getByLabel(L1MuGMTConfig::getRPCbInputTag(),rc_handle);
00115     if(rc_handle.isValid()) {
00116       getRPCb(rc_handle.product(),bx);
00117     } else {
00118       edm::LogWarning("GlobalMuonTrigger")
00119       << "\nWarning: GlobalMuonTrigger: input tag " << L1MuGMTConfig::getRPCbInputTag()
00120       << "\nrequested, but not found in the event." << std::endl;      
00121     }
00122   }
00123   if((L1MuGMTConfig::getRPCfInputTag()).label() != "none" ) {
00124     e.getByLabel(L1MuGMTConfig::getRPCfInputTag(),rc_handle);
00125     if(rc_handle.isValid()) {
00126       getRPCf(rc_handle.product(),bx);
00127     } else {
00128       edm::LogWarning("GlobalMuonTrigger")
00129       << "\nWarning: GlobalMuonTrigger: input tag " << L1MuGMTConfig::getRPCfInputTag()
00130       << "\nrequested, but not found in the event." << std::endl;      
00131     }
00132   }
00134 
00135   const L1MuTriggerScales* theTriggerScales = L1MuGMTConfig::getTriggerScales();
00136   const L1MuTriggerPtScale* theTriggerPtScale = L1MuGMTConfig::getTriggerPtScale();
00137 
00138   // store data in readout record
00139   for (int i=0; i<4; i++) {
00140     L1MuRegionalCand* cand = &(m_DtbxMuons[i]);
00141     cand->setPhiValue( theTriggerScales->getPhiScale()->getLowEdge(cand->phi_packed()) );
00142     cand->setEtaValue( theTriggerScales->getRegionalEtaScale(cand->type_idx())->getCenter(cand->eta_packed()) );
00143     cand->setPtValue( theTriggerPtScale->getPtScale()->getLowEdge(cand->pt_packed()) );
00144     // cand->setPtValue( theTriggerScales->getPtScale()->getLowEdge(cand->pt_packed()) );
00145     m_gmt.currentReadoutRecord()->setInputCand ( i, *cand );
00146   }
00147   for (int i=0; i<4; i++) {
00148     L1MuRegionalCand* cand = &(m_RpcMuons[i]);
00149     cand->setPhiValue( theTriggerScales->getPhiScale()->getLowEdge(cand->phi_packed()) );
00150     cand->setEtaValue( theTriggerScales->getRegionalEtaScale(cand->type_idx())->getCenter(cand->eta_packed()) );
00151     cand->setPtValue( theTriggerPtScale->getPtScale()->getLowEdge(cand->pt_packed()) );
00152     // cand->setPtValue( theTriggerScales->getPtScale()->getLowEdge(cand->pt_packed()) );
00153     m_gmt.currentReadoutRecord()->setInputCand ( i+4, *cand );
00154   }
00155   for (int i=0; i<4; i++) {
00156     L1MuRegionalCand* cand = &(m_CscMuons[i]);
00157     cand->setPhiValue( theTriggerScales->getPhiScale()->getLowEdge(cand->phi_packed()) );
00158     cand->setEtaValue( theTriggerScales->getRegionalEtaScale(cand->type_idx())->getCenter(cand->eta_packed()) );
00159     cand->setPtValue( theTriggerPtScale->getPtScale()->getLowEdge(cand->pt_packed()) );
00160     // cand->setPtValue( theTriggerScales->getPtScale()->getLowEdge(cand->pt_packed()) );
00161     m_gmt.currentReadoutRecord()->setInputCand ( i+8, *cand );
00162   }
00163   for (int i=0; i<4; i++) {
00164     L1MuRegionalCand* cand = &(m_RpcMuons[i+4]);
00165     cand->setPhiValue( theTriggerScales->getPhiScale()->getLowEdge(cand->phi_packed()) );
00166     cand->setEtaValue( theTriggerScales->getRegionalEtaScale(cand->type_idx())->getCenter(cand->eta_packed()) );
00167     cand->setPtValue( theTriggerPtScale->getPtScale()->getLowEdge(cand->pt_packed()) );
00168     // cand->setPtValue( theTriggerScales->getPtScale()->getLowEdge(cand->pt_packed()) );
00169     m_gmt.currentReadoutRecord()->setInputCand ( i+12, *cand );
00170   }
00171 
00172 
00173   // if there is at least one muon start the calorimeter trigger 
00174 
00175   if ( L1MuGMTConfig::getCaloTrigger() && !empty() ) getCalo(e);
00176 
00177 }
00178 
00179 
00180 //
00181 // clear PSB
00182 //
00183 void L1MuGMTPSB::reset() {
00184 
00185   std::vector<L1MuRegionalCand>::iterator iter; 
00186   iter = m_RpcMuons.begin();
00187   while ( iter != m_RpcMuons.end() ) (*(iter++)).reset();
00188 
00189   iter = m_DtbxMuons.begin();
00190   while ( iter != m_DtbxMuons.end() )(*(iter++)).reset();
00191 
00192   iter = m_CscMuons.begin();
00193   while ( iter != m_CscMuons.end() ) (*(iter++)).reset();
00194   
00195   m_Isol.init(false);
00196   m_Mip.init(false);
00197 
00198 }
00199 
00200 
00201 //
00202 // print muons
00203 //
00204 void L1MuGMTPSB::print() const {
00205 
00206   edm::LogVerbatim("GMT_PSB_info") << " ";
00207   printDTBX();
00208   printRPCbarrel();
00209   printCSC();
00210   printRPCendcap();
00211   edm::LogVerbatim("GMT_PSB_info") << " ";
00212   
00213 }
00214 
00215 
00216 //
00217 // return RPC muon
00218 //
00219 const L1MuRegionalCand* L1MuGMTPSB::RPCMuon(int index) const {
00220   
00221   return ( index < (int)L1MuGMTConfig::MAXRPC && index >= 0 ) ? &(m_RpcMuons[index]) : 0;
00222   
00223 }
00224 
00225 
00226 //
00227 // return DTBX muon
00228 //
00229 const L1MuRegionalCand* L1MuGMTPSB::DTBXMuon(int index) const {
00230       
00231   return ( index < (int)L1MuGMTConfig::MAXDTBX && index >= 0 ) ? &(m_DtbxMuons[index]) : 0;
00232   
00233 }
00234 
00235 
00236 //
00237 // return CSC muon
00238 //
00239 const L1MuRegionalCand* L1MuGMTPSB::CSCMuon(int index) const {
00240  
00241   return ( index < (int)L1MuGMTConfig::MAXCSC && index >= 0 ) ? &(m_CscMuons[index]) : 0;
00242   
00243 }
00244 
00245 //
00246 // count number of non empty RPC muons
00247 //
00248 int L1MuGMTPSB::numberRPC() const {
00249 
00250   int count = 0;
00251   std::vector<L1MuRegionalCand>::const_iterator iter = m_RpcMuons.begin();
00252   while ( iter != m_RpcMuons.end() ) {
00253     if ( !(*iter).empty() ) count++;
00254     iter++;
00255   }
00256   return count;
00257 
00258 }
00259 
00260 
00261 //
00262 // count number of non empty DT muons
00263 //
00264 int L1MuGMTPSB::numberDTBX() const {
00265 
00266   int count = 0;
00267   std::vector<L1MuRegionalCand>::const_iterator iter = m_DtbxMuons.begin();
00268   while ( iter != m_DtbxMuons.end() ) {
00269     if ( !(*iter).empty() ) count++;
00270     iter++;
00271   }
00272   return count;
00273 
00274 }
00275 
00276 
00277 //
00278 // count number of non empty CSC muons
00279 //
00280 int L1MuGMTPSB::numberCSC() const {
00281 
00282   int count = 0;
00283   std::vector<L1MuRegionalCand>::const_iterator iter = m_CscMuons.begin();
00284   while ( iter != m_CscMuons.end() ) {
00285     if ( !(*iter).empty() ) count++;
00286     iter++;
00287   }
00288   return count;
00289 
00290 }
00291 
00292 
00293 //
00294 // are there any data in the PSB
00295 //
00296 bool L1MuGMTPSB::empty() const {
00297 
00298   int number = numberRPC() + numberDTBX() + numberCSC();
00299 
00300   return ( number == 0 );
00301 
00302 }
00303 
00304 
00305 //
00306 // get muons from RPCb Trigger
00307 //
00308 void L1MuGMTPSB::getRPCb(std::vector<L1MuRegionalCand> const* data, int bx) {
00309 
00310   int irpcb = 0;
00311   std::vector<L1MuRegionalCand>::const_iterator iter;
00312   for ( iter = data->begin(); iter != data->end(); iter++ ) {
00313     if ( (*iter).bx() != bx ) continue;
00314     if ( irpcb < (int)L1MuGMTConfig::MAXRPCbarrel ) { 
00315       if(!(*iter).empty()) m_RpcMuons[irpcb] = (*iter);
00316       irpcb++;
00317     }  
00318   }
00319   
00320 }
00321 
00322 
00323 //
00324 // get muons from RPCf Trigger
00325 //
00326 void L1MuGMTPSB::getRPCf(std::vector<L1MuRegionalCand> const* data, int bx) {
00327 
00328   int irpcf = 0;
00329   std::vector<L1MuRegionalCand>::const_iterator iter;
00330   for ( iter = data->begin(); iter != data->end(); iter++ ) {
00331     if ( (*iter).bx() != bx ) continue;
00332     if ( irpcf < (int)L1MuGMTConfig::MAXRPCendcap ) { 
00333       if(!(*iter).empty()) m_RpcMuons[irpcf+4] = (*iter);
00334       irpcf++;
00335     }  
00336   }
00337   
00338 }
00339 
00340 
00341 //
00342 // get muons from barrel Muon Trigger Track Finder
00343 //
00344 void L1MuGMTPSB::getDTBX(std::vector<L1MuRegionalCand> const* data, int bx) {
00345 
00346   // temporary hack with bxoffset - to be removed, trigger bx should be 0
00347   int bxoffset = 0;
00348   int idtbx = 0;
00349   std::vector<L1MuRegionalCand>::const_iterator iter;
00350   for ( iter = data->begin(); iter != data->end(); iter++ ) {
00351     if ( L1MuGMTConfig::Debug(2) ) edm::LogVerbatim("") << "DTTF BX: " << (*iter).bx() << " my bx: " << bx;
00352     if ( (*iter).bx() > 10) bxoffset=16;
00353     if ( (*iter).bx() != bx+bxoffset ) continue;
00354     if ( idtbx < (int)L1MuGMTConfig::MAXDTBX ) { 
00355       m_DtbxMuons[idtbx] = (*iter);
00356       m_DtbxMuons[idtbx].setBx(bx);
00357       idtbx++;
00358     }  
00359   }
00360 
00361 }
00362 
00363 
00364 //
00365 // get muons from CSC Track Finder
00366 //
00367 void L1MuGMTPSB::getCSC(std::vector<L1MuRegionalCand> const* data, int bx) {
00368 
00369   int icsc = 0;
00370   std::vector<L1MuRegionalCand>::const_iterator iter;
00371   for ( iter = data->begin(); iter != data->end(); iter++ ) {
00372     if ( (*iter).bx() != bx ) continue;
00373     if ( icsc < (int)L1MuGMTConfig::MAXCSC ) { 
00374       m_CscMuons[icsc] = (*iter);
00375       icsc++;
00376     }
00377   }
00378 
00379 }
00380 
00381 
00382 //
00383 // print barrel RPC muons
00384 //
00385 void L1MuGMTPSB::printRPCbarrel() const {
00386 
00387   edm::LogVerbatim("GMT_PSB_info") << "RPC barrel  muons received by the GMT :";
00388 
00389   for ( unsigned i = 0; i < L1MuGMTConfig::MAXRPCbarrel; i++ ) {
00390     if (!m_RpcMuons[i].empty()) m_RpcMuons[i].print();
00391   }
00392   
00393 }
00394 
00395 
00396 //
00397 // print endcap RPC muons
00398 //
00399 void L1MuGMTPSB::printRPCendcap() const {
00400 
00401   edm::LogVerbatim("GMT_PSB_info") << "RPC endcap  muons received by the GMT :";
00402 
00403   for ( unsigned i = 0; i < L1MuGMTConfig::MAXRPCendcap; i++ ) {
00404     if (!m_RpcMuons[i+4].empty()) m_RpcMuons[i+4].print();
00405   }
00406 
00407 }
00408 
00409 
00410 //
00411 // print DTBX muons
00412 //
00413 void L1MuGMTPSB::printDTBX() const {
00414 
00415   edm::LogVerbatim("GMT_PSB_info") << "DTBX muons received by the GMT :";
00416 
00417   for ( unsigned i = 0; i < L1MuGMTConfig::MAXDTBX; i++ ) {
00418     if (!m_DtbxMuons[i].empty()) m_DtbxMuons[i].print();
00419   }
00420   
00421 }
00422 
00423 
00424 //
00425 // print CSC muons
00426 //
00427 void L1MuGMTPSB::printCSC() const {
00428 
00429   edm::LogVerbatim("GMT_PSB_info") << "CSC  muons received by the GMT :";
00430 
00431   for ( unsigned i = 0; i < L1MuGMTConfig::MAXCSC; i++ ) {
00432     if (!m_CscMuons[i].empty()) m_CscMuons[i].print();
00433   }
00434 
00435 }
00436 
00437 
00438 //
00439 // get data from regional calorimeter trigger
00440 //
00441 void L1MuGMTPSB::getCalo(edm::Event& e) {
00442   
00443   edm::Handle<L1CaloRegionCollection> calocoll_h;
00444   e.getByLabel(L1MuGMTConfig::getMipIsoInputTag(),calocoll_h);
00445   if(calocoll_h.isValid())
00446   {
00447     L1CaloRegionCollection const* regions = calocoll_h.product();
00448     L1CaloRegionCollection::const_iterator iter;
00449 
00450     //  edm::LogVerbatim("GMT_PSB_info") << "MIP/QUIET bits rceived by the GMT :";
00451 
00452     for ( iter = regions->begin(); iter != regions->end(); iter++ ) {
00453       if ( (*iter).id().ieta() < 4 || (*iter).id().ieta() > 17 || (*iter).id().iphi() > 17 ) continue;
00454       m_Isol.set( (*iter).id().ieta()-4, (*iter).id().iphi(), (*iter).quiet() );
00455       m_Mip.set( (*iter).id().ieta()-4, (*iter).id().iphi(), (*iter).mip() );
00456 
00457       if ( (*iter).quiet() )
00458         m_gmt.currentReadoutRecord()->setQuietbit ((*iter).id().ieta()-4, (*iter).id().iphi());
00459 
00460       if ( (*iter).mip() )
00461         m_gmt.currentReadoutRecord()->setMIPbit ((*iter).id().ieta()-4, (*iter).id().iphi());
00462 
00463       //    edm::LogVerbatim("GMT_PSB_info") << (*iter).id().ieta()-4 << " "
00464       //                                     << (*iter).id().iphi() << " "
00465       //                                     << (*iter).quiet() << " "
00466       //                                     << (*iter).mip();
00467     }
00468   } else {
00469     edm::LogWarning("GlobalMuonTrigger")
00470     << "\nWarning: GlobalMuonTrigger: input tag " << L1MuGMTConfig::getMipIsoInputTag()
00471     << "\nrequested, but not found in the event." << std::endl;
00472   }
00473   
00474 }

Generated on Tue Jun 9 17:40:13 2009 for CMSSW by  doxygen 1.5.4