Index: trunk/Mars/hawc/processing/extract-aux-data.sh
===================================================================
--- trunk/Mars/hawc/processing/extract-aux-data.sh	(revision 20030)
+++ trunk/Mars/hawc/processing/extract-aux-data.sh	(revision 20031)
@@ -1,3 +1,7 @@
 #!/bin/bash
+
+# Specify the telescope for which to run the script. Replace '1' 
+# by $1 if the telesocpe number is supplied as an option to the script
+TELESCOPE=1
 
 # The base directory of the aux-files
@@ -7,4 +11,6 @@
 # The path (relative to your Mars/build directory where the processing macros are stored
 MACROS=../hawc/processing
+# File to which the queries are written
+OUTPUT="insert-aux.sql"
 
 # Open the query-file with the create table statement
@@ -13,4 +19,5 @@
 CREATE TABLE AuxData
 (
+   Telescope       TINYINT   UNSIGNED  NOT NULL,
    NIGHT           INT       UNSIGNED  NOT NULL,
    RUNID           MEDIUMINT UNSIGNED  NOT NULL,
@@ -48,9 +55,9 @@
    RateSum0        FLOAT,
    RateSum1        FLOAT,
-   PRIMARY KEY(NIGHT, RUNID)
+   PRIMARY KEY(Telescope, NIGHT, RUNID)
 ) 
 SELECT * FROM 
 ( VALUES
-"\ > insert-data.sql
+"\ > ${OUTPUT}
 
 # Get all available runs and their start and stop time
@@ -61,5 +68,7 @@
     NIGHT, RUNID, TSTARTI+TSTARTF, TSTOPI+TSTOPF
 FROM 
-    RawData\
+    RawData
+WHERE
+    Telescope=${TELESCOPE}\
 "\
  |  mysql \
@@ -129,12 +138,12 @@
 
   # Write the result as one row to the query file
-  echo "/* "${FNAME}" */" >> insert-data.sql
-  echo "ROW(" >> insert-data.sql
-  echo " "${NIGHT}, ${RUNID}, >> insert-data.sql
-  echo " "${DRS_TEMP},        >> insert-data.sql
-  echo " "${BIAS_DATA},       >> insert-data.sql
-  echo " "${FTU_DATA},        >> insert-data.sql
-  echo " "${FTM_DATA}         >> insert-data.sql
-  echo ")," >> insert-data.sql
+  echo "/* "${FNAME}" */"                   >> ${OUTPUT}
+  echo "ROW("                               >> ${OUTPUT}
+  echo " "${TELESCOPE], ${NIGHT}, ${RUNID}, >> ${OUTPUT}
+  echo " "${DRS_TEMP},                      >> ${OUTPUT}
+  echo " "${BIAS_DATA},                     >> ${OUTPUT}
+  echo " "${FTU_DATA},                      >> ${OUTPUT}
+  echo " "${FTM_DATA}                       >> ${OUTPUT}
+  echo "),"                                 >> ${OUTPUT}
 
 done
@@ -144,5 +153,5 @@
 AS
 (
-   NIGHT, RUNID,
+   Telescope, NIGHT, RUNID,
    TavgDRS, TrmsDRS,
    Umed, Uavg, Udev, Urms,
@@ -156,3 +165,3 @@
    RateSum0, RateSum1
 )\ 
-" >> insert-data.sql
+" >> ${OUTPUT}
Index: trunk/Mars/hawc/processing/extract-raw-headers.sh
===================================================================
--- trunk/Mars/hawc/processing/extract-raw-headers.sh	(revision 20030)
+++ trunk/Mars/hawc/processing/extract-raw-headers.sh	(revision 20031)
@@ -1,3 +1,7 @@
 #/bin/bash
+
+# Specify the telescope for which to run the script. Replace '1' 
+# by $1 if the telesocpe number is supplied as an option to the script
+TELESCOPE=1
 
 # This is the directory in which to serach for files
@@ -6,8 +10,52 @@
 FITSDUMP=~/FACT++/build/fitsdump
 # File to which the queries are written
-OUTPUT="insert-queries.sql"
+OUTPUT="insert-raw.sql"
 
-# Remove an existing file with queries
-rm -f ${OUTPUT}
+echo \
+"\
+CREATE TABLE RawData  IF NOT EXIST 
+(
+  Telescope tinyint UNSIGNED NOT NULL,
+  NIGHT int UNSIGNED NOT NULL,
+  RUNID mediumint UNSIGNED NOT NULL,
+  DATE-OBS datetime(6) NOT NULL,
+  DATE-END datetime(6) NOT NULL,
+  RUNTYPE tinyint UNSIGNED NOT NULL,
+  DRSSTEP tinyint UNSIGNED DEFAULT NULL,
+  NROI mediumint UNSIGNED NOT NULL,
+  ZNAXIS2 bigint UNSIGNED NOT NULL,
+  NTRG int UNSIGNED NOT NULL,
+  NTRGMISC int UNSIGNED NOT NULL,
+  NTRGPED int UNSIGNED NOT NULL,
+  REFCLK float NOT NULL,
+  ZRATIO float NOT NULL,
+  DAC0 mediumint UNSIGNED NOT NULL,
+  DAC1 mediumint UNSIGNED NOT NULL,
+  DAC2 mediumint UNSIGNED NOT NULL,
+  DAC3 mediumint UNSIGNED NOT NULL,
+  DAC4 mediumint UNSIGNED NOT NULL,
+  DAC5 mediumint UNSIGNED NOT NULL,
+  DAC6 mediumint UNSIGNED NOT NULL,
+  DAC7 mediumint UNSIGNED NOT NULL,
+  DATE timestamp NOT NULL,
+  DRSCALIB tinyint(1) NOT NULL,
+  NTRGEXT1 int UNSIGNED NOT NULL,
+  NTRGEXT2 int UNSIGNED NOT NULL,
+  NTRGLPE int UNSIGNED NOT NULL,
+  NTRGLPI int UNSIGNED NOT NULL,
+  NTRGTIM int UNSIGNED NOT NULL,
+  TSTARTF double NOT NULL,
+  TSTARTI mediumint UNSIGNED NOT NULL,
+  TSTOPF double NOT NULL,
+  TSTOPI mediumint UNSIGNED NOT NULL,
+  DNA0 bigint UNSIGNED NOT NULL,
+  DNA1 bigint UNSIGNED NOT NULL,
+  FWVER0 mediumint UNSIGNED NOT NULL,
+  FWVER1 mediumint UNSIGNED NOT NULL,
+  PRIMARY KEY (Telescope, NIGHT, RUNID),
+  KEY (RUNTYPE)
+); 
+"\ > ${OUTPUT}
+
 
 # Loop over all tokens returned by the given bash extension
@@ -58,5 +106,6 @@
       then
           echo "INSERT INTO RawData SET" >> ${OUTPUT}
-          echo ${RESULT}                 >> ${OUTPUT}
+          echo Telescope=${TELESCOPE},   >> ${OUTPUT}
+	  echo ${RESULT}                 >> ${OUTPUT}
           echo ";"                       >> ${OUTPUT}                                     
       fi
Index: trunk/Mars/hawc/processing/find-calibration-files.sql
===================================================================
--- trunk/Mars/hawc/processing/find-calibration-files.sql	(revision 20030)
+++ trunk/Mars/hawc/processing/find-calibration-files.sql	(revision 20031)
@@ -8,9 +8,10 @@
       SELECT
          -- NIGHT and RUNID of the data file
-         R1.NIGHT AS NIGHT,
-         R1.RUNID AS RUNID,
+         R1.Telescope AS Telescope,
+         R1.NIGHT     AS NIGHT,
+         R1.RUNID     AS RUNID,
          -- NIGHT and RUNID of the DRS file
-         R2.NIGHT AS DrsNight,
-         R2.RUNID AS DrsRunID,
+         R2.NIGHT     AS DrsNight,
+         R2.RUNID     AS DrsRunID,
          -- Time difference between the two
          LEAST(
@@ -40,6 +41,9 @@
          DoNotUse ON (R2.NIGHT=DoNotUse.NIGHT AND R2.RUNID=DoNotUse.RUNID)
       WHERE
+         -- Of course claibration must be from the same telescope
+         R1.Telescope=R2.Telescope
+      AND
          -- Select all combinations that have a data file in R1 and a drs file (at step 1) in R2
-         ISNULL(R1.DRSSTEP) AND R2.DRSSTEP=1 
+         ISNULL(R1.DRSSTEP) AND R2.DRSSTEP=1
       AND 
          -- Only DRS files with 100 events and the correct ROI are considered
@@ -51,7 +55,11 @@
       -- AND ABS(UNIX_TIMESTAMP(R2.`DATE-OBS`)-UNIX_TIMESTAMP(R1.`DATE-OBS`))<78*3600
       ORDER BY
-     R1.NIGHT, R1.RUNID, DeltaT
+         R1.Telescope,
+         R1.NIGHT,
+         R1.RUNID,
+         DeltaT
     )
     SELECT
+       Telescope,
        NIGHT,
        RUNID,
Index: trunk/Mars/hawc/processing/root2sql-callisto.rc
===================================================================
--- trunk/Mars/hawc/processing/root2sql-callisto.rc	(revision 20030)
+++ trunk/Mars/hawc/processing/root2sql-callisto.rc	(revision 20031)
@@ -1,14 +1,25 @@
+# link to database
 uri=hawcwrite:password@ihp-pc45.ethz.ch/hawcdata
 
-# Table's name, will be created if it is not existing already
-create=yes
-delete=yes
 # Tree's name
 tree=Events
 
+# Table's name, will be created if it is not existing already
+#table=Callisto
+
+# Create if not yet existing
+create=yes
+# Delete entries corresponding to consts
+delete=yes
+
+# Consts
+primary=Telescope
 primary=NIGHT
 primary=RUNID
+# Event ID
 primary=DAQEvtNumber
 
+# Manual specification of type for const columns
+sql-type=Telescope/TINYINT UNSIGNED NOT NULL
 sql-type=NIGHT/INT UNSIGNED NOT NULL
 sql-type=RUNID/MEDIUMINT UNSIGNED NOT NULL
Index: trunk/Mars/hawc/processing/root2sql-star.rc
===================================================================
--- trunk/Mars/hawc/processing/root2sql-star.rc	(revision 20030)
+++ trunk/Mars/hawc/processing/root2sql-star.rc	(revision 20031)
@@ -1,13 +1,25 @@
+# link to database
 uri=hawcwrite:password@ihp-pc45.ethz.ch/hawcdata
 
+# Tree's name
 tree=Events
 
+# Table's name, will be created if it is not existing already
+#table=Star
+
+# Create if not yet existing
 create=yes
+# Delete entries corresponding to consts
 delete=yes
 
+# Consts
+primary=Telescope
 primary=NIGHT
 primary=RUNID
+# Event ID
 primary=DAQEvtNumber
 
+# Manual specification of type for const columns
+sql-type=Telescope/TINYINT UNSIGNED NOT NULL
 sql-type=NIGHT/INT UNSIGNED NOT NULL
 sql-type=RUNID/MEDIUMINT UNSIGNED NOT NULL
Index: trunk/Mars/hawc/processing/run-callisto.sh
===================================================================
--- trunk/Mars/hawc/processing/run-callisto.sh	(revision 20030)
+++ trunk/Mars/hawc/processing/run-callisto.sh	(revision 20031)
@@ -1,3 +1,7 @@
 #!/bin/bash
+
+# Specify the telescope for which to run the script. Replace '1' 
+# by $1 if the telesocpe number is supplied as an option to the script
+TELESCOPE=1
 
 # The data is expected to be found in /data/raw and data/callisto
@@ -20,4 +24,6 @@
 FROM 
     Calibration
+WHERE
+    Telescope=${TELESCOPE}
 ORDER BY
     NIGHT, RUNID\
Index: trunk/Mars/hawc/processing/run-root2sql.sh
===================================================================
--- trunk/Mars/hawc/processing/run-root2sql.sh	(revision 20030)
+++ trunk/Mars/hawc/processing/run-root2sql.sh	(revision 20031)
@@ -1,3 +1,7 @@
 #/bin/bash
+
+# Specify the telescope for which to run the script. Replace '1' 
+# by $1 if the telesocpe number is supplied as an option to the script
+TELESCOPE=1
 
 # Path where the data is stored... can be callisto or star
@@ -61,4 +65,5 @@
          -C ${RESOURCE} \
          --table=${TABLE} \
+         --const.Telescope=${TELESCOPE} \
          --const.NIGHT=${NIGHT} \
          --const.RUNID=${RUNID} \
Index: trunk/Mars/hawc/processing/run-star.sh
===================================================================
--- trunk/Mars/hawc/processing/run-star.sh	(revision 20030)
+++ trunk/Mars/hawc/processing/run-star.sh	(revision 20031)
@@ -1,3 +1,8 @@
 #!/bin/bash
+
+
+# Specify the telescope for which to run the script. Replace '1' 
+# by $1 if the telesocpe number is supplied as an option to the script
+TELESCOPE=1
 
 # The data is expected to be found in /data/raw and data/callisto
@@ -19,5 +24,7 @@
     NIGHT, RUNID
 FROM 
-    Calibration_new
+    Calibration
+WHERE
+    Telescope=${TELESCOPE}
 ORDER BY
     NIGHT, RUNID\
Index: trunk/Mars/hawc/processing/software-trigger.sql
===================================================================
--- trunk/Mars/hawc/processing/software-trigger.sql	(revision 20030)
+++ trunk/Mars/hawc/processing/software-trigger.sql	(revision 20031)
@@ -3,18 +3,20 @@
 CREATE TABLE SoftwareTrigger
 (
-    NIGHT   INT       UNSIGNED NOT NULL,
-    RUNID   MEDIUMINT UNSIGNED NOT NULL,
-    Cnt500  INT       UNSIGNED NOT NULL,
-    Cnt750  INT       UNSIGNED NOT NULL,
-    Cnt1000 INT       UNSIGNED NOT NULL,
-    Cnt1250 INT       UNSIGNED NOT NULL,
-    Cnt1500 INT       UNSIGNED NOT NULL,
-    Cnt2000 INT       UNSIGNED NOT NULL,
-    Cnt5000 INT       UNSIGNED NOT NULL,
-    PRIMARY KEY (NIGHT, RUNID)
+    Telescope TINYINT   UNSIGNED NOT NULL,
+    NIGHT     INT       UNSIGNED NOT NULL,
+    RUNID     MEDIUMINT UNSIGNED NOT NULL,
+    Cnt500    INT       UNSIGNED NOT NULL,
+    Cnt750    INT       UNSIGNED NOT NULL,
+    Cnt1000   INT       UNSIGNED NOT NULL,
+    Cnt1250   INT       UNSIGNED NOT NULL,
+    Cnt1500   INT       UNSIGNED NOT NULL,
+    Cnt2000   INT       UNSIGNED NOT NULL,
+    Cnt5000   INT       UNSIGNED NOT NULL,
+    PRIMARY KEY (Telescope, NIGHT, RUNID)
 ) 
 AS
 (
     SELECT
+        Telescope,
     	NIGHT,
     	RUNID,
@@ -29,4 +31,9 @@
     	`Callisto`
     GROUP BY
+        Telescope,
+    	NIGHT,
+    	RUNID
+    ORDER BY
+        Telescope,
     	NIGHT,
     	RUNID
Index: trunk/Mars/hawc/processing/summary-aux-data.rc
===================================================================
--- trunk/Mars/hawc/processing/summary-aux-data.rc	(revision 20030)
+++ trunk/Mars/hawc/processing/summary-aux-data.rc	(revision 20031)
@@ -19,11 +19,11 @@
    RawData
 LEFT JOIN
-   AuxData USING (NIGHT, RUNID)
+   AuxData USING (Telescope, NIGHT, RUNID)
 LEFT JOIN
-   SoftwareTrigger USING (NIGHT, RUNID)
+   SoftwareTrigger USING (Telescope, NIGHT, RUNID)
 LEFT JOIN
-   DoNotUse USING (NIGHT, RUNID)
+   DoNotUse USING (Telescope, NIGHT, RUNID)
 HAVING
    ObsTime>0
 ORDER BY
-   NIGHT, RUNID
+   Telescope, NIGHT, RUNID
Index: trunk/Mars/hawc/processing/summary-callisto.sql
===================================================================
--- trunk/Mars/hawc/processing/summary-callisto.sql	(revision 20030)
+++ trunk/Mars/hawc/processing/summary-callisto.sql	(revision 20031)
@@ -1,5 +1,7 @@
 #!/usr/bin/env -S rootifysql
 SELECT
+   Telescope,
    NIGHT,
+   RUNID,
    (TSTARTI+TSTARTF) AS ObsStart,
    RUNTYPE,
@@ -11,7 +13,7 @@
    `Callisto` Callisto
 LEFT JOIN
-   RawData USING(NIGHT, RUNID)
+   RawData USING(Telescope, NIGHT, RUNID)
 LEFT JOIN
-   AuxData USING(NIGHT, RUNID)
+   AuxData USING(Telescope, NIGHT, RUNID)
 ORDER BY
-   NIGHT, RUNID
+   Telesscope, NIGHT, RUNID
Index: trunk/Mars/hawc/processing/summary-star.sql
===================================================================
--- trunk/Mars/hawc/processing/summary-star.sql	(revision 20030)
+++ trunk/Mars/hawc/processing/summary-star.sql	(revision 20031)
@@ -8,4 +8,7 @@
    `Star` Star
 LEFT JOIN
-   RawData USING(NIGHT, RUNID)
-
+   RawData USING(Telescope, NIGHT, RUNID)
+ORDER BY
+   Telescope,
+   NIGHT,
+   RUNID
