CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CaloOnlineTools/EcalTools/plugins/EcalExclusiveTrigFilter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EcalExclusiveTrigFilter
00004 // Class:      EcalExclusiveTrigFilter
00005 // 
00013 //
00014 // Original Author:  Seth COOPER
00015 //         Created:  Thu May 22 11:40:12 CEST 2008
00016 // $Id: EcalExclusiveTrigFilter.cc,v 1.2 2010/01/04 15:07:40 ferriff Exp $
00017 //
00018 //
00019 
00020 #include "CaloOnlineTools/EcalTools/plugins/EcalExclusiveTrigFilter.h"
00021 
00022 using namespace cms;
00023 using namespace edm;
00024 using namespace std;
00025 
00026 //
00027 // constants, enums and typedefs
00028 //
00029 
00030 //
00031 // static data member definitions
00032 //
00033 
00034 //
00035 // constructors and destructor
00036 //
00037 EcalExclusiveTrigFilter::EcalExclusiveTrigFilter(const edm::ParameterSet& iConfig) :
00038   l1GTReadoutRecTag_ (iConfig.getUntrackedParameter<std::string>("L1GlobalReadoutRecord","gtDigis"))
00039 {
00040    //now do what ever initialization is needed
00041 
00042 }
00043 
00044 
00045 EcalExclusiveTrigFilter::~EcalExclusiveTrigFilter()
00046 {
00047  
00048    // do anything here that needs to be done at desctruction time
00049    // (e.g. close files, deallocate resources etc.)
00050 
00051 }
00052 
00053 
00054 //
00055 // member functions
00056 //
00057 
00058 // ------------ method called on each new Event  ------------
00059 bool
00060 EcalExclusiveTrigFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00061 {
00062   // get the GMTReadoutCollection
00063   Handle<L1MuGMTReadoutCollection> gmtrc_handle; 
00064   iEvent.getByLabel(l1GTReadoutRecTag_,gmtrc_handle);
00065   L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
00066   if (!(gmtrc_handle.isValid())) 
00067   {
00068     LogWarning("EcalExclusiveTrigFilter") << "l1MuGMTReadoutCollection" << " not available";
00069     //return;
00070   }
00071 
00072   // get hold of L1GlobalReadoutRecord
00073   Handle<L1GlobalTriggerReadoutRecord> L1GTRR;
00074   iEvent.getByLabel(l1GTReadoutRecTag_,L1GTRR);
00075   bool isEcalL1 = false;
00076   const unsigned int sizeOfDecisionWord(L1GTRR->decisionWord().size());
00077   if (!(L1GTRR.isValid()))
00078   {
00079     LogWarning("EcalExclusiveTrigFilter") << l1GTReadoutRecTag_ << " not available";
00080     //return;
00081   }
00082   else if(sizeOfDecisionWord<128)
00083   {
00084     LogWarning("EcalExclusiveTrigFilter") << "size of L1 decisionword is " << sizeOfDecisionWord
00085       << "; L1 Ecal triggering bits not available";
00086   }
00087   else
00088   {
00089     l1Names_.resize(sizeOfDecisionWord);
00090     l1Accepts_.resize(sizeOfDecisionWord);
00091     for (unsigned int i=0; i!=sizeOfDecisionWord; ++i) {
00092       l1Accepts_[i]=0;
00093       l1Names_[i]="NameNotAvailable";
00094     }
00095     for (unsigned int i=0; i!=sizeOfDecisionWord; ++i) {
00096       if (L1GTRR->decisionWord()[i])
00097       {
00098         l1Accepts_[i]++;
00099         //cout << "L1A bit: " << i << endl;
00100       }
00101     }
00102 
00103     if(l1Accepts_[14] || l1Accepts_[15] || l1Accepts_[16] || l1Accepts_[17]
00104         || l1Accepts_[18] || l1Accepts_[19] || l1Accepts_[20])
00105       isEcalL1 = true;
00106     if(l1Accepts_[73] || l1Accepts_[74] || l1Accepts_[75] || l1Accepts_[76]
00107         || l1Accepts_[77] || l1Accepts_[78])
00108       isEcalL1 = true;
00109   }
00110 
00111   bool isRPCL1 = false;
00112   bool isDTL1 = false;
00113   bool isCSCL1 = false;
00114   bool isHCALL1 = false;
00115 
00116   std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
00117   std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
00118 
00119     for(igmtrr=gmt_records.begin(); igmtrr!=gmt_records.end(); igmtrr++) {
00120 
00121       std::vector<L1MuRegionalCand>::const_iterator iter1;
00122       std::vector<L1MuRegionalCand> rmc;
00123 
00124       //DT triggers
00125       int idt = 0;
00126       rmc = igmtrr->getDTBXCands();
00127       for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
00128         if ( !(*iter1).empty() ) {
00129           idt++;
00130         }
00131       }
00132 
00133       //if(idt>0) std::cout << "Found " << idt << " valid DT candidates in bx wrt. L1A = " 
00134       //  << igmtrr->getBxInEvent() << std::endl;
00135       if(igmtrr->getBxInEvent()==0 && idt>0) isDTL1 = true;
00136 
00137       //RPC triggers
00138       int irpcb = 0;
00139       rmc = igmtrr->getBrlRPCCands();
00140       for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
00141         if ( !(*iter1).empty() ) {
00142           irpcb++;
00143         }
00144       }
00145 
00146       //if(irpcb>0) std::cout << "Found " << irpcb << " valid RPC candidates in bx wrt. L1A = " 
00147       //  << igmtrr->getBxInEvent() << std::endl;
00148       if(igmtrr->getBxInEvent()==0 && irpcb>0) isRPCL1 = true;
00149 
00150       //CSC Triggers
00151       int icsc = 0;
00152       rmc = igmtrr->getCSCCands();
00153       for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
00154         if ( !(*iter1).empty() ) {
00155           icsc++;
00156         }
00157       }
00158       //if(icsc>0) std::cout << "Found " << icsc << " valid CSC candidates in bx wrt. L1A = " 
00159       //    //  << igmtrr->getBxInEvent() << std::endl;
00160       if(igmtrr->getBxInEvent()==0 && icsc>0) isCSCL1 = true;
00161     }
00162 
00163     L1GlobalTriggerReadoutRecord const* gtrr = L1GTRR.product();
00164 
00165     for(int ibx=-1; ibx<=1; ibx++) {
00166       bool hcal_top = false;
00167       bool hcal_bot = false;
00168       const L1GtPsbWord psb = gtrr->gtPsbWord(0xbb0d,ibx);
00169       std::vector<int> valid_phi;
00170       if((psb.aData(4)&0x3f) >= 1) {valid_phi.push_back( (psb.aData(4)>>10)&0x1f ); }
00171       if((psb.bData(4)&0x3f) >= 1) {valid_phi.push_back( (psb.bData(4)>>10)&0x1f ); }
00172       if((psb.aData(5)&0x3f) >= 1) {valid_phi.push_back( (psb.aData(5)>>10)&0x1f ); }
00173       if((psb.bData(5)&0x3f) >= 1) {valid_phi.push_back( (psb.bData(5)>>10)&0x1f ); }
00174       std::vector<int>::const_iterator iphi;
00175       for(iphi=valid_phi.begin(); iphi!=valid_phi.end(); iphi++) {
00176         //std::cout << "Found HCAL mip with phi=" << *iphi << " in bx wrt. L1A = " << ibx << std::endl;
00177         if(*iphi<9) hcal_top=true;
00178         if(*iphi>8) hcal_bot=true;
00179       }
00180       if(ibx==0 && hcal_top && hcal_bot) isHCALL1=true;
00181     }
00182 
00183     std::cout << "**** Trigger Source ****" << std::endl;
00184     if(isDTL1) std::cout << "DT" << std::endl;
00185     if(isRPCL1) std::cout << "RPC" << std::endl;
00186     if(isCSCL1) cout << "CSC" << endl;
00187     if(isHCALL1) std::cout << "HCAL" << std::endl;
00188     if(isEcalL1) std::cout << "ECAL" << std::endl;
00189     std::cout << "************************" << std::endl;
00190 
00191     return(isEcalL1 && !isDTL1 && !isRPCL1 && !isCSCL1 && !isHCALL1);
00192 
00193 }