Index: trunk/DataCheck/Tools/get_data.sh
===================================================================
--- trunk/DataCheck/Tools/get_data.sh	(revision 19037)
+++ trunk/DataCheck/Tools/get_data.sh	(revision 19038)
@@ -37,4 +37,6 @@
 # - use get_data.sh for download*.php instead of Send_Data*.sh
 #   -> add policy 
+#   -> make datacheck switchable
+# - no datacheck for external
 # - update function for correction
 # - update CU for QLA
@@ -179,5 +181,5 @@
    # details see https://www.fact-project.org/logbook/showthread.php?tid=5790
    #dch=" AND fR750Cor/fR750Ref >0.93 "
-   dch=" AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "
+   dchstd=" AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "
    
    # put together where-clause of query
@@ -191,5 +193,17 @@
    # th cut
    where=$where" AND fThresholdMedian < "$thmax
-   where=$where" "$dch
+   querybase=$from$where
+
+   if [ "$usedch" == "yes" ]
+   then
+      if [ "$dch" == "" ]
+      then 
+         querydch=$dchstd
+      else
+         echo "you are using for datacheck: "$dch
+         querydch=$dch
+      fi
+   fi
+   
    
    if [ $bin -le 0 ]
@@ -207,11 +221,10 @@
       
       # final part of the query
-      querybase=$from$where
-      querybase=$querybase" GROUP BY num "
+      queryend=" GROUP BY num "
       if [ "$ontimelimit" = "" ]
       then 
-         querybase=$querybase" HAVING SUM("$ontimeif")>1200 ORDER BY num " # 20 min
+         queryend=$queryend" HAVING SUM("$ontimeif")>1200 ORDER BY num " # 20 min
       else
-         querybase=$querybase" HAVING SUM("$ontimeif")>"$ontimelimit" ORDER BY num "
+         queryend=$queryend" HAVING SUM("$ontimeif")>"$ontimelimit" ORDER BY num "
       fi
       
@@ -227,5 +240,5 @@
       queryint=$queryint" MIN("$thresh") AS thmin, MAX("$thresh") AS thmax, "
       queryint=$queryint" ROUND(AVG("$cufactor"), 1) AS cufactor, ROUND(AVG(fR750Cor), 2) AS R750cor,  ROUND(AVG(fR750Ref), 2) AS R750ref "
-      queryint=$queryint" "$querybase
+      queryint=$queryint" "$querybase" "$querydch" "$queryend
       
       # for collaborators
@@ -235,8 +248,9 @@
       querycol=$querycol" "$excrateerr", "$correxcrateerr", "$cuerr", "$fluxerr", "
       querycol=$querycol" "$significance
-      querycol=$querycol" "$querybase
+      querycol=$querycol" "$querybase" "$querydch" "$queryend
       
       # external
-      queryext=$querystart" "$excrate", "$deltat", "$excrateerr" "$querybase
+      # no datacheck applied for external files
+      queryext=$querystart" "$excrate", "$deltat", "$excrateerr" "$querybase" "$queryend
       
    else
@@ -248,5 +262,5 @@
       # final part of the query
       querybase=" FROM (SELECT fNight, fZenithDistanceMin AS zdmin, fZenithDistanceMax AS zdmax, "$thresh" AS th, "
-      querybase=$querybase" fR750Cor as R750cor, fR750Ref as R750ref, "$cufactor" AS cufactor, "
+      querybase=$querybase" fR750Cor AS R750cor, fR750Ref AS R750ref, "$cufactor" AS cufactor, "
       querybase=$querybase" @ot:="$ontimeif" AS ot, fRunStart AS start, fRunStop AS stop, "
       querybase=$querybase" fNumSigEvts AS sigevts, fNumBgEvts AS bgevts, "$correvts" AS corevts, "
@@ -287,5 +301,7 @@
       echo "creating "$fileint" ..."
       echo "# This file was created at "`date` > $fileint
-      # add query and policy here
+      echo "# The following query was used: " >> $fileint
+      echo "# "$queryint >> $fileint
+      # add policy here
    fi
    headerint="# "$num" time["$timeunit"] start["$timeunit"] stop["$timeunit"] excrate[evts/h] corr.excrate[evts/h] flux[CU] flux[e-11/cm2/s] delta_time["$timeunit"] ontime[min]"
@@ -302,5 +318,7 @@
       echo "creating "$filecol" ..."
       echo "# This file was created at "`date` > $filecol
-      # add query and policy here
+      echo "# The following query was used: " >> $filecol
+      echo "# "$querycol >> $filecol
+      # add policy here
    fi
    headercol="# "$num" time["$timeunit"] start["$timeunit"] stop["$timeunit"] excrate[evts/h] corr.excrate[evts/h] flux[CU] flux[e-11/cm2/s] delta_time["$timeunit"] ontime[min]"
@@ -319,5 +337,5 @@
          echo "creating "$fileext" ..."
          echo "# This file was created at "`date` > $fileext
-         # add query and policy here
+         # add policy here
       fi
       headerext="# "$num" time["$timeunit"] start["$timeunit"] stop["$timeunit"] excrate[evts/h] delta_time["$timeunit"] excrate_err[evts/h] "
@@ -391,4 +409,10 @@
 #ontimelimit=30 # 30 min
 ontimelimit= # default 20 min
+# data quality selection
+# if you explicitely don't want a datacheck, you can comment the following line
+usedch="yes" 
+# use your own datacheck instead
+#   use a line like the following defining your own data quality selection cut
+#dch=" AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "
 
 # -------------------------------------------------------------------------------------- #
