CondTools/L1TriggerExt/plugins/L1CondDBPayloadWriterExt.cc
// ------------ method called to for each event  ------------
method called to for each event
method called to for each event
void L1CondDBPayloadWriterExt::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  using namespace edm;
  L1TriggerKeyListExt oldKeyList;
  l1t::DataWriterExt& m_writer = *m_rcdToWriterMap.at("L1TriggerKeyExtRcd@L1TriggerKeyExt");
  if (not(m_newL1TriggerKeyListExt or m_writer.fillLastTriggerKeyList(oldKeyList)))
    edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyListExt";
  L1TriggerKeyListExt* keyList = nullptr;
  std::string token;
  L1TriggerKeyExt key;
  bool triggerKeyOK = true;
  try {
    key = iSetup.getData(theL1TriggerKeyExtToken_);
    if (!m_overwriteKeys) {
      triggerKeyOK = oldKeyList.token(key.tscKey()).empty();
    }
  } catch (l1t::DataAlreadyPresentException& ex) {
    triggerKeyOK = false;
    edm::LogVerbatim("L1-O2O") << ex.what();
  }
  if (triggerKeyOK and m_writeL1TriggerKeyExt) {
    edm::LogVerbatim("L1-O2O") << "Object key for L1TriggerKeyExtRcd@L1TriggerKeyExt: " << key.tscKey()
                               << " (about to run writePayload)";
    token = m_writer.writePayload(iSetup);
  }
  if (token.empty() and m_writeL1TriggerKeyExt) {
    edm::LogInfo("L1CondDBPayloadWriterExt::analyze") << " token = " << token;
    return;
  }
  if (m_writeL1TriggerKeyExt) {
    keyList = new L1TriggerKeyListExt(oldKeyList);
    if (not keyList->addKey(key.tscKey(), token, m_overwriteKeys))
      throw cond::Exception("L1CondDBPayloadWriter: TSC key " + key.tscKey() + " already in L1TriggerKeyListExt");
  }
  if (not m_writeConfigData) {
    if (keyList)
      m_writer.writeKeyList(keyList, 0, m_logTransactions);
    return;
  }
  bool throwException = false;
  for (const auto& it : key.recordToKeyMap()) {
    if (m_rcdToWriterMap.find(it.first) == m_rcdToWriterMap.end())
      continue;
    if (it.second == L1TriggerKeyExt::kNullKey) {
      edm::LogVerbatim("L1-O2O") << "L1CondDBPayloadWriter: null object key for " << it.first
                                 << "; skipping this record.";
      continue;
    }
    if (oldKeyList.token(it.first, it.second).empty() || m_overwriteKeys) {
      if (!oldKeyList.token(it.first, it.second).empty()) {
        edm::LogVerbatim("L1-O2O") << "*** Overwriting payload: object key for " << it.first << ": " << it.second;
      } else {
        edm::LogVerbatim("L1-O2O") << "object key for " << it.first << ": " << it.second;
      }
      try {
        edm::LogVerbatim("L1-O2O") << "about to run writePayload for " << it.first;
        token = m_rcdToWriterMap.at(it.first)->writePayload(iSetup);
      } catch (l1t::DataInvalidException& ex) {
        edm::LogVerbatim("L1-O2O") << ex.what() << " Skipping to next record.";
        throwException = true;
        continue;
      }
      if (!token.empty()) {
        if (!keyList)
          keyList = new L1TriggerKeyListExt(oldKeyList);
        if (!(keyList->addKey(it.first, it.second, token, m_overwriteKeys)))
          throw cond::Exception("L1CondDBPayloadWriter")
              << "subsystem key " << it.second << " for " << it.first << " already in L1TriggerKeyListExt";
      }
    } else
      edm::LogVerbatim("L1-O2O") << "L1CondDBPayloadWriter: object key " << it.second << " for " << it.first
                                 << " already in L1TriggerKeyListExt";
  }  
  if (keyList)  
    m_writer.writeKeyList(keyList, 0, m_logTransactions);
  if (throwException)
    throw l1t::DataInvalidException("Payload problem found.");
}
void L1CondDBPayloadWriterExt :: analyze ( const edm :: Event & iEvent , const edm :: EventSetup & iSetup ) { using namespace edm ; L1TriggerKeyListExt oldKeyList ; l1t :: DataWriterExt & m_writer = * m_rcdToWriterMap . at ( " " ) ; if ( not ( m_newL1TriggerKeyListExt or m_writer . fillLastTriggerKeyList ( oldKeyList ) ) ) edm :: LogError ( " " ) << " " ; L1TriggerKeyListExt * keyList = nullptr ; std :: string token ; L1TriggerKeyExt key ; bool triggerKeyOK = true ; try { key = iSetup . getData ( theL1TriggerKeyExtToken_ ) ; if ( ! m_overwriteKeys ) { triggerKeyOK = oldKeyList . token ( key . tscKey ( ) ) . empty ( ) ; } } catch ( l1t :: DataAlreadyPresentException & ex ) { triggerKeyOK = false ; edm :: LogVerbatim ( " " ) << ex . what ( ) ; } if ( triggerKeyOK and m_writeL1TriggerKeyExt ) { edm :: LogVerbatim ( " " ) << " " << key . tscKey ( ) << " " ; token = m_writer . writePayload ( iSetup ) ; } if ( token . empty ( ) and m_writeL1TriggerKeyExt ) { edm :: LogInfo ( " " ) << " " << token ; return ; } if ( m_writeL1TriggerKeyExt ) { keyList = new L1TriggerKeyListExt ( oldKeyList ) ; if ( not keyList -> addKey ( key . tscKey ( ) , token , m_overwriteKeys ) ) throw cond :: Exception ( " " + key . tscKey ( ) + " " ) ; } if ( not m_writeConfigData ) { if ( keyList ) m_writer . writeKeyList ( keyList , 0 , m_logTransactions ) ; return ; } bool throwException = false ; for ( const auto & it : key . recordToKeyMap ( ) ) { if ( m_rcdToWriterMap . find ( it . first ) == m_rcdToWriterMap . end ( ) ) continue ; if ( it . second == L1TriggerKeyExt :: kNullKey ) { edm :: LogVerbatim ( " " ) << " " << it . first << " " ; continue ; } if ( oldKeyList . token ( it . first , it . second ) . empty ( ) || m_overwriteKeys ) { if ( ! oldKeyList . token ( it . first , it . second ) . empty ( ) ) { edm :: LogVerbatim ( " " ) << " " << it . first << " " << it . second ; } else { edm :: LogVerbatim ( " " ) << " " << it . first << " " << it . second ; } try { edm :: LogVerbatim ( " " ) << " " << it . first ; token = m_rcdToWriterMap . at ( it . first ) -> writePayload ( iSetup ) ; } catch ( l1t :: DataInvalidException & ex ) { edm :: LogVerbatim ( " " ) << ex . what ( ) << " " ; throwException = true ; continue ; } if ( ! token . empty ( ) ) { if ( ! keyList ) keyList = new L1TriggerKeyListExt ( oldKeyList ) ; if ( ! ( keyList -> addKey ( it . first , it . second , token , m_overwriteKeys ) ) ) throw cond :: Exception ( " " ) << " " << it . second << " " << it . first << " " ; } } else edm :: LogVerbatim ( " " ) << " " << it . second << " " << it . first << " " ; } if ( keyList ) m_writer . writeKeyList ( keyList , 0 , m_logTransactions ) ; if ( throwException ) throw l1t :: DataInvalidException ( " " ) ; }
method called to for each event
method called to for each event
// Get L1TriggerKeyListExt and make a copy // Write L1TriggerKeyExt to ORCON with no IOV // Before calling writePayload(), check if TSC key is already in // L1TriggerKeyListExt.  writePayload() will not catch this situation in // the case of dummy configurations. // Get L1TriggerKeyExt // If L1TriggerKeyExt is invalid (empty), then all configuration data is already in DB // m_writeL1TriggerKeyExt the naming is misleading, // the bool is used to say to the module whether it runs or not to update a L1TriggerKeyExtRcd // (so if no payload for L1TriggerKeyExtRcd AND you run for updating L1TriggerKeyExtRcd ==> you have nothing to update) // Record token in L1TriggerKeyListExt // Write L1TriggerKeyListExt to ORCON // Loop over record@type in L1TriggerKeyExt // (as before make writers, try to write payload and if needed handle exceptions) // this is not needed maps have implemented begin and end methods for their iterators // L1TriggerKeyExt::RecordToKey::const_iterator it = key.recordToKeyMap().begin(); // L1TriggerKeyExt::RecordToKey::const_iterator end = key.recordToKeyMap().end(); // for (; it != end; ++it) { // If there isn't any WriterProxyT constructed for this rcd, continue // (the missing rcds are left out for a reason - those are static that throw exceptions that cannot be handled in 12_3) // Do nothing if object key is null. // (Panos) this might not be working as the "empty" keys are L1TriggerKeyExt::kEmptyKey (std::string("")) // Check key is new before writing // Write data to ORCON with no IOV // Record token in L1TriggerKeyListExt // The following should never happen because of the check // above, but just in case.... // for rcds from keys // Write L1TriggerKeyListExt to ORCON