#!/usr/bin/python # This script fixes a cable swap for 2 TAGH counters. # 1. TAGH-T-3 was plugged into counter 5. # 2. TAGH-T-5 was plugged into counter 3. # The fADC cables were connected to the correct counters. # These counters were incorrectly cabled on March 13, 2015. # The cabling was corrected on June 1, 2016. # The TAGH discriminator and TDC chanid's for these 2 counters, # 3 and 5, should be swapped in the TT for offline analysis of # runs 2642 to 11680. As of June 1, 2016, the fix has been applied # in the ccdb for runs 10000 to 11680. The corresponding database file # has not been committed to the repository since these changes are only # relevant to runs 2642 to 11680, not to future runs. import sqlite3 as lite import sys if len(sys.argv) != 2: print "You must supply a sqlite file (e.g. tt.db)" sys.exit(0); con = lite.connect(sys.argv[1]) with con: global cur # Specify that next cursor should be "dictionary" # (i.e. python's hash map) so columns can be indexed # by name con.row_factory = lite.Row # Create Cursor cur = con.cursor() # Swap disc_chanid and tdc_chanid for TAGH ids 3 and 5 cur.execute("UPDATE TAGH SET disc_chanid='885' WHERE id='3'") cur.execute("UPDATE TAGH SET tdc_chanid='629' WHERE id='3'") cur.execute("UPDATE TAGH SET disc_chanid='883' WHERE id='5'") cur.execute("UPDATE TAGH SET tdc_chanid='627' WHERE id='5'") # Update channel names cur.execute("UPDATE Channel SET name='TAGH-T-3' WHERE chanid='885'") cur.execute("UPDATE Channel SET name='TAGH-T-3' WHERE chanid='629'") cur.execute("UPDATE Channel SET name='TAGH-T-5' WHERE chanid='883'") cur.execute("UPDATE Channel SET name='TAGH-T-5' WHERE chanid='627'") print "Done."