Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025
00026 #include "CondTools/L1Trigger/plugins/L1CondDBPayloadWriter.h"
00027
00028 #include "CondFormats/L1TObjects/interface/L1TriggerKey.h"
00029 #include "CondFormats/DataRecord/interface/L1TriggerKeyRcd.h"
00030 #include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
00031 #include "CondFormats/DataRecord/interface/L1TriggerKeyListRcd.h"
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 L1CondDBPayloadWriter::L1CondDBPayloadWriter(const edm::ParameterSet& iConfig)
00049 : m_writeL1TriggerKey( iConfig.getParameter< bool >( "writeL1TriggerKey" )),
00050 m_writeConfigData( iConfig.getParameter< bool >( "writeConfigData" ) ),
00051 m_overwriteKeys( iConfig.getParameter< bool >( "overwriteKeys" ) ),
00052 m_logTransactions( iConfig.getParameter<bool>( "logTransactions" ) ),
00053 m_newL1TriggerKeyList( iConfig.getParameter< bool >( "newL1TriggerKeyList" ) )
00054 {
00055
00056
00057 }
00058
00059
00060 L1CondDBPayloadWriter::~L1CondDBPayloadWriter()
00061 {
00062
00063
00064
00065
00066 }
00067
00068
00069
00070
00071
00072
00073
00074 void
00075 L1CondDBPayloadWriter::analyze(const edm::Event& iEvent,
00076 const edm::EventSetup& iSetup)
00077 {
00078 using namespace edm;
00079
00080
00081 L1TriggerKeyList oldKeyList ;
00082
00083 if( !m_newL1TriggerKeyList )
00084 {
00085 if( !m_writer.fillLastTriggerKeyList( oldKeyList ) )
00086 {
00087 edm::LogError( "L1-O2O" )
00088 << "Problem getting last L1TriggerKeyList" ;
00089 }
00090 }
00091
00092 L1TriggerKeyList* keyList = 0 ;
00093
00094
00095 std::string token ;
00096 ESHandle< L1TriggerKey > key ;
00097
00098
00099
00100
00101 bool triggerKeyOK = true ;
00102 try
00103 {
00104
00105 iSetup.get< L1TriggerKeyRcd >().get( key ) ;
00106
00107 if( !m_overwriteKeys )
00108 {
00109 triggerKeyOK = oldKeyList.token( key->tscKey() ) == "" ;
00110 }
00111 }
00112 catch( l1t::DataAlreadyPresentException& ex )
00113 {
00114 triggerKeyOK = false ;
00115 edm::LogVerbatim( "L1-O2O" ) << ex.what() ;
00116 }
00117
00118 if( triggerKeyOK && m_writeL1TriggerKey )
00119 {
00120 edm::LogVerbatim( "L1-O2O" )
00121 << "Object key for L1TriggerKeyRcd@L1TriggerKey: "
00122 << key->tscKey() ;
00123 token = m_writer.writePayload( iSetup,
00124 "L1TriggerKeyRcd@L1TriggerKey" ) ;
00125 }
00126
00127
00128 bool throwException = false ;
00129
00130 if( !token.empty() || !m_writeL1TriggerKey )
00131 {
00132
00133 if( m_writeL1TriggerKey )
00134 {
00135 keyList = new L1TriggerKeyList( oldKeyList ) ;
00136 if( !( keyList->addKey( key->tscKey(),
00137 token,
00138 m_overwriteKeys ) ) )
00139 {
00140 throw cond::Exception( "L1CondDBPayloadWriter: TSC key "
00141 + key->tscKey()
00142 + " already in L1TriggerKeyList" ) ;
00143 }
00144 }
00145
00146 if( m_writeConfigData )
00147 {
00148
00149 L1TriggerKey::RecordToKey::const_iterator it =
00150 key->recordToKeyMap().begin() ;
00151 L1TriggerKey::RecordToKey::const_iterator end =
00152 key->recordToKeyMap().end() ;
00153
00154 for( ; it != end ; ++it )
00155 {
00156
00157 if( it->second == L1TriggerKey::kNullKey )
00158 {
00159 edm::LogVerbatim( "L1-O2O" )
00160 << "L1CondDBPayloadWriter: null object key for "
00161 << it->first << "; skipping this record." ;
00162 }
00163 else
00164 {
00165
00166 if( oldKeyList.token( it->first, it->second ) == "" ||
00167 m_overwriteKeys )
00168 {
00169
00170 if( oldKeyList.token( it->first, it->second ) != "" )
00171 {
00172 edm::LogVerbatim( "L1-O2O" )
00173 << "*** Overwriting payload: object key for "
00174 << it->first << ": " << it->second ;
00175 }
00176 else
00177 {
00178 edm::LogVerbatim( "L1-O2O" )
00179 << "object key for "
00180 << it->first << ": " << it->second ;
00181 }
00182
00183 try
00184 {
00185 token = m_writer.writePayload( iSetup, it->first ) ;
00186 }
00187 catch( l1t::DataInvalidException& ex )
00188 {
00189 edm::LogVerbatim( "L1-O2O" )
00190 << ex.what()
00191 << " Skipping to next record." ;
00192
00193 throwException = true ;
00194
00195 continue ;
00196 }
00197
00198 if( !token.empty() )
00199 {
00200
00201 if( !keyList )
00202 {
00203 keyList = new L1TriggerKeyList( oldKeyList ) ;
00204 }
00205
00206 if( !( keyList->addKey( it->first,
00207 it->second,
00208 token,
00209 m_overwriteKeys ) ) )
00210 {
00211
00212
00213 throw cond::Exception(
00214 "L1CondDBPayloadWriter: subsystem key "
00215 + it->second + " for " + it->first
00216 + " already in L1TriggerKeyList" ) ;
00217 }
00218 }
00219 }
00220 else
00221 {
00222 edm::LogVerbatim( "L1-O2O" )
00223 << "L1CondDBPayloadWriter: object key "
00224 << it->second << " for " << it->first
00225 << " already in L1TriggerKeyList" ;
00226 }
00227 }
00228 }
00229 }
00230 }
00231
00232 if( keyList )
00233 {
00234
00235 m_writer.writeKeyList( keyList, 0, m_logTransactions ) ;
00236 }
00237
00238 if( throwException )
00239 {
00240 throw l1t::DataInvalidException( "Payload problem found." ) ;
00241 }
00242 }
00243
00244
00245
00246 void
00247 L1CondDBPayloadWriter::beginJob()
00248 {
00249 }
00250
00251
00252 void
00253 L1CondDBPayloadWriter::endJob() {
00254 }
00255
00256
00257