CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/L1TriggerConfig/GctConfigProducers/src/L1GctChannelMaskOnlineProd.cc

Go to the documentation of this file.
00001 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
00002 #include "CondFormats/L1TObjects/interface/L1GctChannelMask.h"
00003 #include "CondFormats/DataRecord/interface/L1GctChannelMaskRcd.h"
00004 
00005 class L1GctChannelMaskOnlineProd : public L1ConfigOnlineProdBase< L1GctChannelMaskRcd, L1GctChannelMask > {
00006    public:
00007       L1GctChannelMaskOnlineProd(const edm::ParameterSet& iConfig)
00008          : L1ConfigOnlineProdBase< L1GctChannelMaskRcd, L1GctChannelMask >( iConfig ) {}
00009       ~L1GctChannelMaskOnlineProd() {}
00010 
00011       virtual boost::shared_ptr< L1GctChannelMask > newObject( const std::string& objectKey ) ;
00012    private:
00013 };
00014 
00015 boost::shared_ptr< L1GctChannelMask >
00016 L1GctChannelMaskOnlineProd::newObject( const std::string& objectKey )
00017 { 
00018   // get EM mask data
00019   l1t::OMDSReader::QueryResults emMaskResults =
00020     m_omdsReader.basicQuery(
00021                             "GCT_EM_MASK",
00022                             "CMS_GCT",
00023                             "GCT_MASKS",
00024                             "GCT_MASKS.CONFIG_KEY",
00025                             m_omdsReader.singleAttribute( objectKey ) ) ;
00026   
00027   if( emMaskResults.queryFailed() ) { // check if query was successful
00028     edm::LogError( "L1-O2O" ) << "Problem with L1GctChannelMask EM mask for key "  << objectKey;
00029     return boost::shared_ptr< L1GctChannelMask >() ;
00030   }
00031   
00032   int emMask ;
00033   emMaskResults.fillVariable( emMask ) ;
00034   
00035   // get region masks
00036   l1t::OMDSReader::QueryResults rgnMaskKeyResults =
00037     m_omdsReader.basicQuery(
00038                             "GCT_RGN_MASK_KEY",
00039                             "CMS_GCT",
00040                             "GCT_MASKS",
00041                             "GCT_MASKS.CONFIG_KEY",
00042                             m_omdsReader.singleAttribute( objectKey ) ) ;
00043   
00044   if( rgnMaskKeyResults.queryFailed() ) { // check if query was successful
00045     edm::LogError( "L1-O2O" ) << "Problem with L1GctChannelMask region mask for key "  << objectKey;
00046     return boost::shared_ptr< L1GctChannelMask >() ;
00047   }
00048 
00049   std::string rgnKey;
00050   rgnMaskKeyResults.fillVariable( rgnKey );
00051 
00052   std::vector< std::string > rgnMaskCols;
00053   rgnMaskCols.push_back("RCT_CRATE_0_RGN_MASK");
00054   rgnMaskCols.push_back("RCT_CRATE_1_RGN_MASK");
00055   rgnMaskCols.push_back("RCT_CRATE_2_RGN_MASK");
00056   rgnMaskCols.push_back("RCT_CRATE_3_RGN_MASK");
00057   rgnMaskCols.push_back("RCT_CRATE_4_RGN_MASK");
00058   rgnMaskCols.push_back("RCT_CRATE_5_RGN_MASK");
00059   rgnMaskCols.push_back("RCT_CRATE_6_RGN_MASK");
00060   rgnMaskCols.push_back("RCT_CRATE_7_RGN_MASK");
00061   rgnMaskCols.push_back("RCT_CRATE_8_RGN_MASK");
00062   rgnMaskCols.push_back("RCT_CRATE_9_RGN_MASK");
00063   rgnMaskCols.push_back("RCT_CRATE_10_RGN_MASK");
00064   rgnMaskCols.push_back("RCT_CRATE_11_RGN_MASK");
00065   rgnMaskCols.push_back("RCT_CRATE_12_RGN_MASK");
00066   rgnMaskCols.push_back("RCT_CRATE_13_RGN_MASK");
00067   rgnMaskCols.push_back("RCT_CRATE_14_RGN_MASK");
00068   rgnMaskCols.push_back("RCT_CRATE_15_RGN_MASK");
00069   rgnMaskCols.push_back("RCT_CRATE_16_RGN_MASK");
00070   rgnMaskCols.push_back("RCT_CRATE_17_RGN_MASK");
00071 
00072   l1t::OMDSReader::QueryResults rgnMaskResults =
00073     m_omdsReader.basicQuery(
00074                             rgnMaskCols,
00075                             "CMS_GCT",
00076                             "GCT_RGN_MASKS",
00077                             "GCT_RGN_MASKS.CONFIG_KEY",
00078                             m_omdsReader.singleAttribute( rgnKey ) ) ;
00079   
00080 
00081   // get energy sum masks
00082   l1t::OMDSReader::QueryResults esumMaskKeyResults =
00083     m_omdsReader.basicQuery(
00084                             "GCT_ESUM_MASK_KEY",
00085                             "CMS_GCT",
00086                             "GCT_MASKS",
00087                             "GCT_MASKS.CONFIG_KEY",
00088                             m_omdsReader.singleAttribute( objectKey ) ) ;
00089   
00090   if( esumMaskKeyResults.queryFailed() ) { // check if query was successful
00091     edm::LogError( "L1-O2O" ) << "Problem with L1GctChannelMask energy sum mask for key "  << objectKey;
00092     return boost::shared_ptr< L1GctChannelMask >() ;
00093   }
00094 
00095   std::string esumKey;
00096   esumMaskKeyResults.fillVariable( esumKey );
00097 
00098   std::vector< std::string > esumMaskCols;
00099   esumMaskCols.push_back("GCT_TET_MASK");
00100   esumMaskCols.push_back("GCT_MET_MASK");
00101   esumMaskCols.push_back("GCT_HT_MASK");
00102   esumMaskCols.push_back("GCT_MHT_MASK");
00103 
00104   l1t::OMDSReader::QueryResults esumMaskResults =
00105     m_omdsReader.basicQuery(
00106                             esumMaskCols,
00107                             "CMS_GCT",
00108                             "GCT_ESUM_MASKS",
00109                             "GCT_ESUM_MASKS.CONFIG_KEY",
00110                             m_omdsReader.singleAttribute( esumKey ) ) ;
00111 
00112 
00113   // create masks object
00114   boost::shared_ptr< L1GctChannelMask > masks( new L1GctChannelMask() );
00115   
00116   // set EM masks
00117   for (int i=0; i<18; i++) {
00118     if ((emMask & (1<<i)) != 0) masks->maskEmCrate(i);  // mask crate if emMask bit i is set
00119   }
00120  
00121   // set region masks
00122   for (unsigned irct=0; irct<18; irct++) {
00123     std::stringstream rgnCol;
00124     rgnCol << "RCT_CRATE_" << std::dec << irct << "_RGN_MASK";
00125     int mask;
00126     rgnMaskResults.fillVariable( rgnCol.str(), mask );
00127     if (mask != 0) {
00128       for (unsigned irgn=0; irgn<22; ++irgn) {
00129         if ((mask & (1<<irgn)) != 0) {
00130           edm::LogError( "L1-O2O" ) << "Masked region, but no O2O code!";
00131         }
00132       }
00133     }
00134   }
00135 
00136   // set esum masks
00137   int tetMask, metMask, htMask, mhtMask ;
00138   esumMaskResults.fillVariable( "GCT_TET_MASK", tetMask ) ;
00139   esumMaskResults.fillVariable( "GCT_MET_MASK", metMask ) ;
00140   esumMaskResults.fillVariable( "GCT_HT_MASK", htMask ) ;
00141   esumMaskResults.fillVariable( "GCT_MHT_MASK", mhtMask ) ;
00142 
00143   for (int ieta=0; ieta<22; ieta++) {
00144     if ((tetMask & (1<<ieta)) != 0) masks->maskTotalEt(ieta);  
00145     if ((metMask & (1<<ieta)) != 0) masks->maskMissingEt(ieta);  
00146     if ((htMask & (1<<ieta)) != 0) masks->maskTotalHt(ieta);  
00147     if ((mhtMask & (1<<ieta)) != 0) masks->maskMissingHt(ieta);  
00148   }
00149     
00150   return masks;
00151   
00152 }
00153 
00154 DEFINE_FWK_EVENTSETUP_MODULE(L1GctChannelMaskOnlineProd);