diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcConfig.py b/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcConfig.py
index 8a108582a6093884666b4e048c3b4785434e11f5..a7b711829a18077c2c97e154d3fb31363de8ef06 100755
--- a/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcConfig.py
+++ b/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcConfig.py
@@ -62,6 +62,33 @@ class DefaultHLTConfigSvc( TrigConf__HLTConfigSvc ):
     def __init__( self, name="HLTConfigSvc" ):
         super( DefaultHLTConfigSvc, self ).__init__( name )  #
 
+    def getAlgorithmsRun2(self):
+        """Produces pair of lists with algorithms scheduled for  L2 and EF"""
+
+        mlog = logging.getLogger("TrigConfigSvcConfig.py")
+        from TriggerJobOpts.TriggerFlags import TriggerFlags
+        if TriggerFlags.readMenuFromTriggerDb():
+            from TrigConfigSvc.TrigConfigSvcUtils import getAlgorithmsForMenuRun2
+            mlog.info("Will load algos from DB")
+            allalgs = getAlgorithmsForMenuRun2(TriggerFlags.triggerDbConnection(),TriggerFlags.triggerDbKeys()[0])
+        else:
+            mlog.info("Will load algos from xml")
+            allalgs = []
+            doc = ET.parse(self.XMLMenuFile)
+            algs = self.getAllAlgorithms(doc)
+            l2TEs, efTEs = self.getTEsByLevel(doc)
+            
+            for te in l2TEs:
+                if te in algs.keys():
+                    allalgs += algs[te]
+
+            for te in efTEs:
+                if te in algs.keys():
+                    allalgs += algs[te]
+                    
+        return allalgs
+
+
 
     def getAlgorithmsByLevel(self):
         """Produces pair of lists with algorithms scheduled for  L2 and EF"""
diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcUtils.py b/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcUtils.py
index b6f8a5a1f3b0357b59218391e1b9e6b0f53b0033..aaf843518b7d2247e45964b7c1da67505c618562 100644
--- a/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcUtils.py
+++ b/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcUtils.py
@@ -235,7 +235,7 @@ def interpretConnection(connection, debug=False, resolveAlias=True):
             break
         elif server=='atlas_dd': continue
         else:
-            oracleconnections = [conn for conn in connectionServices if conn.startswith("oracle://%s/" % server)]
+            oracleconnections = [conn for conn in connectionServices if conn.lower().startswith("oracle://%s/" % server.lower())]
             if len(oracleconnections) == 0:
                 log.debug("Oracle connection not defined for server %s in dblookup" % server )
                 continue
@@ -369,6 +369,45 @@ def getAlgorithmsForMenu(connection, smk):
 
     return l2algs, efalgs
 
+
+
+
+def getAlgorithmsForMenuRun2(connection, smk):
+    cursor,schemaname = getTriggerDBCursor(connection)
+
+    output = [ 'C.HCP_NAME', 'C.HCP_ALIAS' ]
+    
+    tables = {}
+    tables['SM']    = 'SUPER_MASTER_TABLE'
+    tables['HM']    = 'HLT_MASTER_TABLE'
+    tables['TM']    = 'HLT_TRIGGER_MENU'
+    tables['M2C']   = 'HLT_TM_TO_TC'
+    tables['TC']    = 'HLT_TRIGGER_CHAIN'
+    tables['C2S']   = 'HLT_TC_TO_TS'
+    tables['S2TE']  = 'HLT_TS_TO_TE'
+    tables['TE2C']  = 'HLT_TE_TO_CP'
+    tables['TE2TE'] = 'HLT_TE_TO_TE'
+    tables['C']     = 'HLT_COMPONENT'
+
+    condition = [ "SM.SMT_ID = '%i'" % smk,
+                  'SM.SMT_HLT_MASTER_TABLE_ID = HM.HMT_ID',
+                  'HM.HMT_TRIGGER_MENU_ID = M2C.HTM2TC_TRIGGER_MENU_ID',
+                  'M2C.HTM2TC_TRIGGER_CHAIN_ID = TC.HTC_ID',
+                  'M2C.HTM2TC_TRIGGER_CHAIN_ID = C2S.HTC2TS_TRIGGER_CHAIN_ID',
+                  'C2S.HTC2TS_TRIGGER_SIGNATURE_ID = S2TE.HTS2TE_TRIGGER_SIGNATURE_ID',
+                  'S2TE.HTS2TE_TRIGGER_ELEMENT_ID = TE2C.HTE2CP_TRIGGER_ELEMENT_ID',
+                  'TE2C.HTE2CP_COMPONENT_ID = C.HCP_ID' ]
+
+    res = executeQuery(cursor, output, condition, schemaname, tables)
+
+    allalgs=[]
+    for x in res:        
+        allalgs += ["%s/%s" % (x[0],x[1])]
+
+    return allalgs
+
+
+
 def getPropertyFromDB(connection, smk, component, parameter):
     """Get property value from DB. smk can be a single SMK or a list/tuple of SMKs.
     SQL wildcards (%) can be used in both component and parameter names.
@@ -419,6 +458,8 @@ def getMenuNameFromDB(connection, hltprescalekey):
 
     # now we need to do some logic, related to the 
 
+    print res
+
     hltpsName = str(res[0][0])
 
     # temporarily here, but should use the function from TMP
@@ -743,10 +784,21 @@ def test():
     
 
 
-#if __name__ == "__main__":
-#    print "Prescales and pass-throughs for PSK 7417\n",getHLTPrescales("TRIGGERDB",7417)
-#    print "Express stream prescales for PSK 7417\n",getExpressStreamPrescales("TRIGGERDB",7417)
+
+def test2():
+    log = logging.getLogger( "TrigConfigSvcUtils.py" )
+    log.setLevel(logging.DEBUG)
+
+    connection = "TRIGGERDB_JOERG"
+    hltpsk = 1
+    
+    #connection = "TRIGGERDBMC"
+    #hltpsk = 1
+    
+
+    getMenuNameFromDB(connection,hltpsk)
+
 
 if __name__=="__main__":
     import sys
-    sys.exit(test())
+    sys.exit(test2())
diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/src/DSConfigSvc.cxx b/Trigger/TrigConfiguration/TrigConfigSvc/src/DSConfigSvc.cxx
index c221d1e0378ccc83641e2944b06a118469773185..3446cbdb9d926efe5e97f62589fa044d7cadee64 100644
--- a/Trigger/TrigConfiguration/TrigConfigSvc/src/DSConfigSvc.cxx
+++ b/Trigger/TrigConfiguration/TrigConfigSvc/src/DSConfigSvc.cxx
@@ -2,7 +2,7 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-// $Id: DSConfigSvc.cxx 592654 2014-04-11 18:33:06Z fpastore $
+// $Id: DSConfigSvc.cxx 645890 2015-02-11 00:40:56Z stelzer $
 
 #include "GaudiKernel/IIncidentSvc.h"
 #include "GaudiKernel/Incident.h"
@@ -280,21 +280,20 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
       ATH_MSG_INFO( "Updating trigger configuration: HLT keys" );
 
       uint32_t old_masterkey = m_masterKey;
-      //uint32_t old_hltPsKey = m_hltPsKey;
 
-      readHltConfigKeys( *keysAtrList,
-                                                           m_masterKey, m_hltPsKey, m_configSrc );
+      readHltConfigKeys( *keysAtrList, m_masterKey, m_hltPsKey, m_configSrc );
 
       ATH_MSG_INFO( "  Configuration key : " << m_masterKey );
       ATH_MSG_INFO( "  Run-bound HLT prescale key (old style): " << m_hltPsKey );
       ATH_MSG_INFO( "  Original source   : " << m_configSrc );
 
       updated_HLTMenu |= ( old_masterkey != m_masterKey );
-      //updated_HLTPs = ( old_hltPsKey != m_hltPsKey );
       if( m_masterKey == 0 ) updated_HLTMenu = true;
-      //if( m_hltPsKey == 0 )  updated_HLTPs   = true;
    }
 
+
+
+
    // read the LVL1 Menu object
    if( update_LVL1MENU ) {
 
@@ -328,6 +327,7 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
       }
    }
 
+
    // read the LVL1 PITs
    if( update_LVL1PIT ) {
 
@@ -379,21 +379,6 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
 
          nChains++;;
       }
-//       CondAttrListCollection::size_type nCh = hltMenuAtrColl->size();
-//       for( CondAttrListCollection::ChanNum ch = 0; ch != nCh; ++ch ) {
-
-//          // the attributeList for this channel (a channel corresponds to a chain)
-
-//          CondAttrListCollection::const_iterator attrListIt = hltMenuAtrColl->chanAttrListPair( ch );
-
-//          if( attrListIt == hltMenuAtrColl->end() )
-//             continue;
-
-//          CondAttrListCollection::AttributeList atrList =
-//             hltMenuAtrColl->chanAttrListPair( ch )->second;
-//          m_hltFrame.theHLTChainList().addHLTChain( createHLTChain( atrList, &m_hltFrame.theHLTSequenceList() ) );
-         
-//       }
       ATH_MSG_INFO( "  Number of chains: " << nChains );
       ATH_MSG_DEBUG( m_hltFrame.chains() );
 
@@ -449,9 +434,9 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
          float ps, pt, rrps;
          readHltPrescale( atrList, ps, pt, rrps);
          TrigConf::HLTLevel level = (mergedHLT ? HLT :( ( ch % 2 ==0 ) ? L2 : EF));
-	 unsigned int cc = ch;
-	 if (! mergedHLT ) cc /= 2;
-	 else cc -= 20000;
+         unsigned int cc = ch;
+         if (! mergedHLT ) cc /= 2;
+         else cc -= 20000;
 
          if( ( level == L2 ) && ( ps > 0.0 ) ) ++npositivepsL2;
          if( ( level == EF ) && ( ps > 0.0 ) ) ++npositivepsEF;
@@ -470,7 +455,7 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
 
       updated_newHLTPs = true;
       if( msgLvl( MSG::DEBUG ) ) {
-	  m_prescaleSet->print();
+         m_prescaleSet->print();
       }
    }
 
@@ -545,6 +530,7 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
       ATH_MSG_INFO( "  Number of groups: " << nGroups );
    }
 
+
    if( update_LVL1THR ) {
 
       const DataHandle< CondAttrListCollection > l1thrAtrColl;
@@ -555,10 +541,36 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
 
       ATH_MSG_INFO( "  Number of thresholds: " << nCh );
       
+      vector<TriggerThreshold*> tmpThrVector;
+
+
       for( CondAttrListCollection::ChanNum ch = 0; ch != nCh; ++ch ) {
-         CondAttrListCollection::AttributeList atrList =
-            l1thrAtrColl->chanAttrListPair( ch )->second;
-         TrigConf::TriggerThreshold* thr = createLvl1Threshold( atrList );
+
+         CondAttrListCollection::AttributeList atrList = l1thrAtrColl->chanAttrListPair( ch )->second;
+         tmpThrVector.push_back(createLvl1Threshold( atrList ) );
+      }
+
+
+      /**
+       * a unpleasant hack so we can figure out if this Run1 (CTPVersion 3) or Run2 (CTPVersion 4)
+       * we use the fact that in Run2 the cable names were different
+       */
+      bool isRun2 = false;
+      for(TriggerThreshold * thr : tmpThrVector) {
+         if( thr->cableName()=="EM1" || thr->cableName()=="EM2" || 
+             thr->cableName()=="JET1" || thr->cableName()=="JET2" || 
+             thr->cableName()=="TOPO1" || thr->cableName()=="TOPO2" || 
+             thr->cableName()=="TAU1" || thr->cableName()=="TAU2") {
+            isRun2 = true;
+            break;
+         }
+      }
+      m_ctpConfig.setCTPVersion(isRun2 ? 4 : 3);
+      m_ctpConfig.setL1Version(isRun2 ? 1 : 0);
+      L1DataDef::setMaxThresholdsFromL1Version( m_ctpConfig.l1Version() );
+      ATH_MSG_INFO( "  Determined format " << (isRun2 ? "Run 2" : "Run 1") );
+
+      for(TriggerThreshold * thr : tmpThrVector) {
 
          // special cases of JetWeights and METSigParams
          if( thr->name() == "METSigParams" ) {
@@ -575,15 +587,16 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
                const_cast< TrigConf::CaloInfo& >( thresholdConfig()->caloInfo() );
             caloInfo.metSigParam().setValues( xsSigmaScale, xsSigmaOffset,
                                               xeMin, xeMax, teSqrtMin, teSqrtMax );
-
+            
          } else if( thr->name() == "JetWeights" ) {
-
-            string jws = thr->cableName();
-            std::vector< std::string > jwv = TrigConf::split( jws, "," );
-            TrigConf::CaloInfo& caloInfo =
-               const_cast< TrigConf::CaloInfo& >( thresholdConfig()->caloInfo() );
-            for(const string& s: jwv)
-               caloInfo.addJetWeight( lexical_cast< int, std::string >( s ) );
+            if(!isRun2) { // only run 1 has JetWeights, for run2 this will crash
+               string jws = thr->cableName();
+               std::vector< std::string > jwv = TrigConf::split( jws, "," );
+               TrigConf::CaloInfo& caloInfo =
+                  const_cast< TrigConf::CaloInfo& >( thresholdConfig()->caloInfo() );
+               for(const string& s: jwv)
+                  caloInfo.addJetWeight( lexical_cast< int, std::string >( s ) );
+            }
 
          } else {
             m_ctpConfig.menu().addTriggerThreshold( thr );
@@ -616,6 +629,8 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
       ATH_MSG_INFO( "  Number of items: " << l1itemdefAtrColl->size() );
    }
 
+
+
    // Bunchgroup keys
    if( update_LVL1BGK ) {
 
@@ -628,10 +643,12 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
       ATH_MSG_INFO( "  LVL1 bunchgroup key : " << m_lvl1BgKey );
       m_bunchGroupSet->setId( m_lvl1BgKey ); // Update the BunchGroupSet object with the ID
       updated_LVL1BG |= ( old_lvl1BgKey != m_lvl1BgKey );
-
       if( ! m_lvl1BgKey ) updated_LVL1BG = true;
    }
 
+
+
+
    // Bunchgroup description
    if( update_LVL1BGD ) {
 
@@ -644,15 +661,13 @@ TrigConf::DSConfigSvc::update( IOVSVC_CALLBACK_ARGS_K( keys ) ) {
          readLvl1BGDesc( *bgdesclist );
 
       // A little sanity check:
-      if( bgdesc.first.size() != 8 ) {
-         REPORT_MESSAGE( MSG::FATAL )
-            << "The bunchgroup descriptions are not in the expected format";
-         return StatusCode::FAILURE;
-      }
+      ATH_MSG_INFO( "  Number of bunch groups : " << bgdesc.first.size() );
 
-      // the 8 BG names
+      
+      // the 8 or 16 BG names
       std::vector< std::string >& m_bgnames = bgdesc.first;
 
+      // TODO
       for( int i = 0; i < 8; ++i ) {
          m_bunchGroupSet->setBGName( i, m_bgnames[ i ] );
       }