Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:54

0001 # Script to extract the gain used by ES providing the TAG of the run key.
0002 # I needs in this order:
0003 # - the tag name
0004 
0005 __author__ = 'Giacomo Cucciati'
0006 
0007 import sys
0008 import cx_Oracle
0009 
0010 import CondTools.Ecal.db_credentials as auth
0011 
0012 db_target_account = 'CMS_ES_CONF'
0013 db_service,db_user,db_pwd = auth.get_db_credentials( db_target_account )
0014 conn_str = u'%s/%s@%s' %(db_user,db_pwd,db_service)
0015 def main(argv):
0016  
0017   if len(argv) !=2:
0018     print("Wrong number of parameters")
0019     return
0020   
0021   runKey_tag = argv[1]
0022   conn = cx_Oracle.connect(conn_str)
0023   conn.current_schema = db_target_account
0024   c = conn.cursor()
0025 
0026   sql_query = "select max(version) from ES_RUN_CONFIGURATION_DAT where tag='"
0027   sql_query += runKey_tag + "'"
0028   c.execute(sql_query)
0029   print_row = []
0030   for row in c:
0031     print_row.append(str(row[0]))
0032   runKey_max_version = ', '.join(print_row)
0033  
0034   sql_query  = "select ES_SEQUENCE_DAT.SEQUENCE_ID from ES_SEQUENCE_DAT "
0035   sql_query += "inner join ES_RUN_CONFIGURATION_DAT on ES_SEQUENCE_DAT.ES_CONFIG_ID=ES_RUN_CONFIGURATION_DAT.CONFIG_ID "
0036   sql_query += "and ES_RUN_CONFIGURATION_DAT.tag='" + runKey_tag + "' and version=" + runKey_max_version;
0037   c.execute(sql_query)
0038   print_row = []
0039   for row in c:
0040     print_row.append(str(row[0]))
0041   sequence_id = ', '.join(print_row)
0042 
0043   sql_query  = "select ES_CCS_CONFIGURATION.GAIN from ES_CCS_CONFIGURATION "
0044   sql_query += "inner join ES_CYCLE_DAT on ES_CCS_CONFIGURATION.CCS_CONFIGURATION_ID=ES_CYCLE_DAT.CCS_CONFIGURATION_ID "
0045   sql_query += "and ES_CYCLE_DAT.SEQUENCE_ID=" + sequence_id;
0046   c.execute(sql_query)
0047   print_row = []
0048   for row in c:
0049     print_row.append(str(row[0]))
0050   gain = ', '.join(print_row)
0051   print(gain)
0052 
0053   conn.close()
0054 
0055 if __name__ == "__main__":
0056   main(sys.argv)
0057