Index: trunk/FACT++/src/spectrum.cc
===================================================================
--- trunk/FACT++/src/spectrum.cc	(revision 19985)
+++ trunk/FACT++/src/spectrum.cc	(revision 19986)
@@ -153,5 +153,5 @@
         ("analysis",    var<string>("analysis.sql"),   "File with the analysis query. A default file is created automatically in the <prefix> directory it does not exist.")
         ("source-key", var<uint16_t>(5),          "Source key to be used in data file selection.")
-        ("selector",   vars<string>(),            "WHERE clause to be used in data file selection.")
+        ("selector",   vars<string>()->required(),"WHERE clause to be used in data file selection.")
         ("selsim",     vars<string>(),            "WHERE clause to be used in monte carlo file selection.")
         ("estimator",  var<string>()->required(), "Energy estimator to be used.")
@@ -648,6 +648,6 @@
 
     const uint16_t source_key = conf.Get<uint16_t>("source-key");
-    const string   where      = boost::join(conf.Vec<string>("selector"), " AND\n      ");
-    const string   where_sim  = boost::join(conf.Vec<string>("selsim"), " AND\n      ");
+    const string   where      = boost::join(conf.Vec<string>("selector"), ") AND\n      (");
+    const string   where_sim  = boost::join(conf.Vec<string>("selsim"),   ") AND\n      (");
     const string   estimator  = conf.Get<string>("estimator");
     const string   spectrum   = conf.Get<string>("spectrum");
@@ -787,5 +787,5 @@
         "   WHERE\n"
         "      fRunTypeKEY=1 AND fSourceKEY=%100:source AND\n"
-        "      %101:where\n"
+        "      (%101:where)\n"
         "   ORDER BY\n"
         "      FileId\n"  // In order: faster
@@ -906,5 +906,5 @@
     //    query3.template_defaults[it->first.c_str()] = it->second.c_str();
 
-    query3.template_defaults["where"] = where_sim.empty()? "" : ("AND\n      "+where_sim).c_str();
+    query3.template_defaults["where"] = where_sim.empty()? "" : ("AND\n      ("+where_sim+")").c_str();
 
     if (print_queries)
