CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

L1CondDBIOVWriter Class Reference

#include <CondTools/L1Trigger/interface/L1CondDBIOVWriter.h>

Inheritance diagram for L1CondDBIOVWriter:
edm::EDAnalyzer

List of all members.

Public Member Functions

 L1CondDBIOVWriter (const edm::ParameterSet &)
 ~L1CondDBIOVWriter ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void endJob ()

Private Attributes

bool m_forceUpdate
bool m_ignoreTriggerKey
bool m_logKeys
bool m_logTransactions
std::vector< std::string > m_recordTypes
std::string m_tscKey
l1t::DataWriter m_writer

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 38 of file L1CondDBIOVWriter.h.


Constructor & Destructor Documentation

L1CondDBIOVWriter::L1CondDBIOVWriter ( const edm::ParameterSet iConfig) [explicit]

Definition at line 48 of file L1CondDBIOVWriter.cc.

References edm::ParameterSet::getParameter(), m_recordTypes, and record.

   : m_tscKey( iConfig.getParameter<std::string> ("tscKey") ),
     m_ignoreTriggerKey( iConfig.getParameter<bool> ("ignoreTriggerKey") ),
     m_logKeys( iConfig.getParameter<bool>( "logKeys" ) ),
     m_logTransactions( iConfig.getParameter<bool>( "logTransactions" ) ),
     m_forceUpdate( iConfig.getParameter<bool>( "forceUpdate" ) )
{
   //now do what ever initialization is needed
   typedef std::vector<edm::ParameterSet> ToSave;
   ToSave toSave = iConfig.getParameter<ToSave> ("toPut");
   for (ToSave::const_iterator it = toSave.begin (); it != toSave.end (); it++)
   {
      std::string record = it->getParameter<std::string> ("record");
      std::string type = it->getParameter<std::string> ("type");
      m_recordTypes.push_back( record  + "@" + type ) ;
   }
}
L1CondDBIOVWriter::~L1CondDBIOVWriter ( )

Definition at line 67 of file L1CondDBIOVWriter.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

void L1CondDBIOVWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 82 of file L1CondDBIOVWriter.cc.

References end, Exception, funct::false, edm::EventSetup::get(), edm::EventBase::id(), combine::key, L1TriggerKey::kNullKey, funct::log(), m_forceUpdate, m_ignoreTriggerKey, m_logKeys, m_logTransactions, m_recordTypes, m_tscKey, m_writer, l1t::DataWriter::readObject(), ecalTPGAnalyzer_cfg::recordName, L1TriggerKey::recordToKeyMap(), linker::replace(), edm::EventID::run(), DTTTrigCorrFirst::run, cond::throwException(), funct::true, and l1t::DataWriter::updateIOV().

{
   using namespace edm;

   // Get L1TriggerKeyList
   L1TriggerKeyList keyList ;
   l1t::DataWriter dataWriter ;
   if( !dataWriter.fillLastTriggerKeyList( keyList ) )
     {
       edm::LogError( "L1-O2O" )
         << "Problem getting last L1TriggerKeyList" ;
     }

   unsigned long long run = iEvent.id().run() ;

   L1TriggerKey::RecordToKey recordTypeToKeyMap ;

   bool triggerKeyIOVUpdated = true ;

   // Start log string, convert run number into string
   std::stringstream ss ;
   ss << run ;
   std::string log = "KEYLOG runNumber=" + ss.str() ;
   bool logRecords = true ;

   if( !m_ignoreTriggerKey )
     {
       if( !m_tscKey.empty() )
         {
           edm::LogVerbatim( "L1-O2O" )
             << "Object key for L1TriggerKey@L1TriggerKeyRcd: "
             << m_tscKey ;

           // Use TSC key and L1TriggerKeyList to find next run's
           // L1TriggerKey token
           std::string keyToken = keyList.token( m_tscKey ) ;

           // Update IOV sequence for this token with since-time = new run 
           triggerKeyIOVUpdated =
             m_writer.updateIOV( "L1TriggerKeyRcd", keyToken, run, m_logTransactions ) ;

           // Read current L1TriggerKey directly from ORCON using token
           L1TriggerKey key ;
           m_writer.readObject( keyToken, key ) ;

           recordTypeToKeyMap = key.recordToKeyMap() ;

           // Replace spaces in key with ?s.  Do reverse substitution when
           // making L1TriggerKey.
           std::string tmpKey = m_tscKey ;
           replace( tmpKey.begin(), tmpKey.end(), ' ', '?' ) ;
           log += " tscKey=" + tmpKey ;
           logRecords = false ;
         }
       else
         {
           // For use with Run Settings, no corresponding L1TrigerKey in
           // ORCON.

           // Get L1TriggerKey from EventSetup
           ESHandle< L1TriggerKey > esKey ;
           iSetup.get< L1TriggerKeyRcd >().get( esKey ) ;

           recordTypeToKeyMap = esKey->recordToKeyMap() ;
         }
     }
   else
     {
       std::vector<std::string >::const_iterator
         recordTypeItr = m_recordTypes.begin() ;
       std::vector<std::string >::const_iterator
         recordTypeEnd = m_recordTypes.end() ;

       for( ; recordTypeItr != recordTypeEnd ; ++recordTypeItr )
         {
           recordTypeToKeyMap.insert(
             std::make_pair( *recordTypeItr, m_tscKey ) ) ;
         }
     }

   // If L1TriggerKey IOV was already up to date, then so are all its
   // sub-records.
   bool throwException = false ;

   if( triggerKeyIOVUpdated || m_forceUpdate )
     {
       // Loop over record@type in L1TriggerKey
       L1TriggerKey::RecordToKey::const_iterator itr =
         recordTypeToKeyMap.begin() ;
       L1TriggerKey::RecordToKey::const_iterator end =
         recordTypeToKeyMap.end() ;

       for( ; itr != end ; ++itr )
         {
           std::string recordType = itr->first ;
           std::string objectKey = itr->second ;

           std::string recordName( recordType,
                                   0, recordType.find_first_of("@") ) ;

           if( logRecords )
             {
               // Replace spaces in key with ?s.  Do reverse substitution when
               // making L1TriggerKey.
               std::string tmpKey = objectKey ;
               replace( tmpKey.begin(), tmpKey.end(), ' ', '?' ) ;
               log += " " + recordName + "Key=" + tmpKey ;
             }

           // Do nothing if object key is null.
           if( objectKey == L1TriggerKey::kNullKey )
             {
               edm::LogVerbatim( "L1-O2O" )
                 << "L1CondDBIOVWriter: null object key for "
                 << recordType << "; skipping this record." ;
             }
           else
             {
               // Find payload token
               edm::LogVerbatim( "L1-O2O" )
                 << "Object key for "
                 << recordType << ": " << objectKey ;

               std::string payloadToken = keyList.token( recordType,
                                                         objectKey ) ;
               if( payloadToken.empty() )
                 {
                   edm::LogVerbatim( "L1-O2O" )
                     << "L1CondDBIOVWriter: empty payload token for " +
                     recordType + ", key " + objectKey ;

                   throwException = true ;
                 }
               else
                 {
                   m_writer.updateIOV( recordName,
                                       payloadToken,
                                       run,
                                       m_logTransactions ) ;
                 }
             }
         }
     }

   if( m_logKeys )
     {
       edm::LogVerbatim( "L1-O2O" ) << log ;
     }

   if( throwException )
     {
       throw cond::Exception( "L1CondDBIOVWriter: empty payload tokens" ) ;
     }
}
void L1CondDBIOVWriter::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 240 of file L1CondDBIOVWriter.cc.

{
}
void L1CondDBIOVWriter::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 246 of file L1CondDBIOVWriter.cc.

                          {
}

Member Data Documentation

Definition at line 68 of file L1CondDBIOVWriter.h.

Referenced by analyze().

Definition at line 62 of file L1CondDBIOVWriter.h.

Referenced by analyze().

Definition at line 64 of file L1CondDBIOVWriter.h.

Referenced by analyze().

Definition at line 66 of file L1CondDBIOVWriter.h.

Referenced by analyze().

std::vector< std::string > L1CondDBIOVWriter::m_recordTypes [private]

Definition at line 55 of file L1CondDBIOVWriter.h.

Referenced by analyze(), and L1CondDBIOVWriter().

std::string L1CondDBIOVWriter::m_tscKey [private]

Definition at line 51 of file L1CondDBIOVWriter.h.

Referenced by analyze().

Definition at line 50 of file L1CondDBIOVWriter.h.

Referenced by analyze().