Changeset 19980 for trunk/FACT++


Ignore:
Timestamp:
08/10/20 17:02:20 (4 years ago)
Author:
tbretz
Message:
Improve some error output (red), added the possibility for MC file selection, added writing of a fit to the root macro.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/spectrum.cc

    r19974 r19980  
    154154        ("source-key", var<uint16_t>(5),          "Source key to be used in data file selection.")
    155155        ("selector",   vars<string>(),            "WHERE clause to be used in data file selection.")
     156        ("selsim",     vars<string>(),            "WHERE clause to be used in monte carlo file selection.")
    156157        ("estimator",  var<string>()->required(), "Energy estimator to be used.")
    157158        ("spectrum",   var<string>()->required(), "Spectral shape for re-weighting of simulated 'Energy'")
     
    190191        "Usage: spectrum [-u URI] [options]\n"
    191192        "\n"
     193        "Note that default analysis query is built into the executable. If a changed "
     194        "query should be used, it is not enough to just change the file, but the "
     195        "--analysis command line option has to be explicitly specified.\n"
    192196        ;
    193197    cout << endl;
     
    547551        catch (const mysqlpp::BadConversion &b)
    548552        {
    549             cerr << b.what() << endl;
     553            cerr << "\033[31m" << b.what() << "\033[0m" << endl;
    550554        }
    551555    }
     
    636640    Binning binning_impact = conf.Get<Binning>("impact");
    637641
    638     cout << '\n';
     642    cout << "\nIt is " << start.Iso() << "\n\n";
     643
    639644    cout << "Binning 'theta':  " << binning_theta.str()  << endl;
    640645    cout << "Binning 'dense':  " << binning_dense.str()  << endl;
     
    644649    const uint16_t source_key = conf.Get<uint16_t>("source-key");
    645650    const string   where      = boost::join(conf.Vec<string>("selector"), " AND\n      ");
     651    const string   where_sim  = boost::join(conf.Vec<string>("selsim"), " AND\n      ");
    646652    const string   estimator  = conf.Get<string>("estimator");
    647653    const string   spectrum   = conf.Get<string>("spectrum");
     
    888894        "   ON\n"
    889895        "      (ThetaMin>=lo AND ThetaMin<hi) OR (ThetaMax>lo AND ThetaMax<=hi)\n"
     896        "   LEFT JOIN\n"
     897        "      factmc.SetInfo USING (SetKEY, PartId)\n"
    890898        "   WHERE\n"
    891         "      PartId=1 AND\n"
    892         "      FileId%%2=0\n"
     899        "      PartId=1 %101:where\n"
    893900        "   ORDER BY\n"
    894901        "      FileId\n" // In order: faster
     
    898905    //for (auto it=env.cbegin(); it!=env.cend(); it++)
    899906    //    query3.template_defaults[it->first.c_str()] = it->second.c_str();
     907
     908    if (!where_sim.empty())
     909        query3.template_defaults["where"] = ("AND\n      "+where_sim).c_str();
    900910
    901911    if (print_queries)
     
    10981108        "      OnTime,\n"
    10991109        "      OnTime/CountN AS ZdWeight,\n"
     1110        /*                             1s per 300s  1/CountN = [sqrt(CountN)/CountN]^2  */
    11001111        "      (OnTime/CountN)*SQRT(POW(1/300, 2) + 1/CountN) AS ErrZdWeight\n"
    11011112        "   FROM\n"
     
    23322343        "mg.DrawClone(\"A\");\n\n"
    23332344        "gPad->SetLogx();\n"
    2334         "gPad->SetLogy();\n";
     2345        "gPad->SetLogy();\n"
     2346        "\n"
     2347        "TF1 f(\"Power Law\", \"[0]*(x/1000)^[1]\", g->GetX()[0], g->GetX()[g->GetN()-1]);\n"
     2348        "f.SetParameter(0, 1e-11);\n"
     2349        "f.SetParameter(1, -2.6);\n"
     2350        "g->Fit(&f, \"\", \"NOQ\");\n"
     2351        "f.SetLineColor(kBlue);\n"
     2352        "f.DrawCopy(\"same\");\n"
     2353        "\n"
     2354        "cout << \"\\nChi^2/NDF:   \" << f.GetChisquare() << \" / \" << f.GetNDF() << '\\n';\n"
     2355        "cout << \"Probability: \" << f.GetProb() << '\\n' << endl;\n";
     2356
    23352357    mlog << indent(0) << "}" << endl;
    23362358
Note: See TracChangeset for help on using the changeset viewer.