Changes between Version 65 and Version 66 of DatabaseBasedAnalysis


Ignore:
Timestamp:
08/06/18 15:30:17 (6 years ago)
Author:
tbretz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DatabaseBasedAnalysis

    v65 v66  
    1616
    1717* MySQL Manual: https://dev.mysql.com/doc/refman/5.7/en/
    18 * MAN page of the mysql client: {{{man mysql}}}
    19 * {{{rootifysql --help}}} and https://www.fact-project.org/logbook/showthread.php?tid=4192
     18* MAN page of the mysql client: `man mysql`
     19* `rootifysql --help` and https://www.fact-project.org/logbook/showthread.php?tid=4192
    2020* PHP MySQL API: http://php.net/manual/en/book.mysql.php
    2121* MySQL++: https://tangentsoft.com/mysqlpp/home
     
    2323== Installing FACT++ ==
    2424
    25 If you want to install {{{rootifysql}}}, you find a description here: [[InstallingFACT++]]
     25If you want to install `rootifysql`, you find a description here: [[InstallingFACT++]]
    2626
    2727== Connecting to the Database ==
     
    3333=== mysql ===
    3434
    35 The mysql-client is the classical way to connect to the database and get data. Data is retrieved from a MySQl database always as pure ascii. {{{mysql}}} can print the ascii table to the console either as a nicely formatted text or as a machine readable ascii table.
     35The mysql-client is the classical way to connect to the database and get data. Data is retrieved from a MySQl database always as pure ascii. `mysql` can print the ascii table to the console either as a nicely formatted text or as a machine readable ascii table.
    3636
    3737=== rootifysql ===
    3838
    39 A convenient way to retrieve data is the ''rootifysql'' tool which is part of the FACT++ package. As the name suggests, it writes the data into root files (but can also write the data into ascii files as the mysql-client). More details can be found either calling it with the {{{--help}}} option or at https://www.fact-project.org/logbook/showthread.php?tid=4192.
    40 
    41 To build only the FACT++ tools (fitsdump, root2sql, fits2sql, rootifysql) you can use {{{cmake -DTOOLS_ONLY=1}}}. You can create a debian and package and a tar file then with {{{make package}}}. You will certainly need the development packages of curses, libnova, libmysql-client, libmysql++ and libopenssl. In addition, you need help2man and groff.
     39A convenient way to retrieve data is the ''rootifysql'' tool which is part of the FACT++ package. As the name suggests, it writes the data into root files (but can also write the data into ascii files as the mysql-client). More details can be found either calling it with the `--help` option or at https://www.fact-project.org/logbook/showthread.php?tid=4192.
     40
     41To build only the FACT++ tools (fitsdump, root2sql, fits2sql, rootifysql) you can use `cmake -DTOOLS_ONLY=1`. You can create a debian and package and a tar file then with `make package`. You will certainly need the development packages of curses, libnova, libmysql-client, libmysql++ and libopenssl. In addition, you need help2man and groff.
    4242
    4343Some more detailed instructions can be found at [[DatabaseBasedAnalysis/rootifysql]].
     
    9494So we have 435 data runs from Crab with a total effective observation time of 32.5 hours in a zenith angle range between 6° and 68° and a bad weather factor between 0.01 (really bad) to 1.1 (extremely good).
    9595
    96 Taking only good data by adding "{{{AND fR750Cor/fR750Ref>0.9}}}" to the WHERE-clause gives us
     96Taking only good data by adding "`AND fR750Cor/fR750Ref>0.9`" to the WHERE-clause gives us
    9797{{{
    9898+----------+-------------+-------+-------+---------+---------+
     
    104104}}}
    105105
    106 But we also want to restrict ourselves to "good" zenith angles (zenith angles at which there is no significant efficiency loss). So we add "{{{AND fZenithDistanceMax<35}}}" to the WHERE-clause which yields
     106But we also want to restrict ourselves to "good" zenith angles (zenith angles at which there is no significant efficiency loss). So we add "`AND fZenithDistanceMax<35`" to the WHERE-clause which yields
    107107{{{
    108108+----------+-------------+-------+-------+---------+---------+
     
    148148#!/path/to/rootifysql --config=/path/to/resources.rc
    149149}}}
    150 in the first line of your query.sql. Make it executable "{{{chmod u+x query.sql}}}" and put your credentials (uri=) into resources.rc. Now you can call it directly
     150in the first line of your query.sql. Make it executable "`chmod u+x query.sql`" and put your credentials (uri=) into resources.rc. Now you can call it directly
    151151{{{
    152152./query.sql -n -w Crab.txt
     
    198198}}}
    199199
    200 Per default rows which contain any NULL are not written to the file because all values are converted to a DOUBLE and there is no representation for a NULL-value in double. So, we need to force the output with {{{--ignore-null}}} and will get something like:
     200Per default rows which contain any NULL are not written to the file because all values are converted to a DOUBLE and there is no representation for a NULL-value in double. So, we need to force the output with `--ignore-null` and will get something like:
    201201{{{
    202202------------------------ Rootify SQL -------------------------
     
    285285}}}
    286286
    287 using {{{--list.MyList=Crab.txt}}} as command-line option to rootifysql. Both queries are similar in execution time.
    288 
    289 Let's assume the output file is ''crab-data-only.root'' ({{{rootifysql --out=crab-data-only.root}}}). Requesting the data and writing the file took me about 60s.
    290 
    291 To run an analysis on the data you can use the following root macro "''analysis.C''". It produces a theta-square plot. Its execution took about five seconds ({{{root analysis.C++}}}). The {{{++}}} behind the macro name forces root to compile the macro before execution (might not be necessary anymore with root 6) to increase performance.
     287using `--list.MyList=Crab.txt` as command-line option to rootifysql. Both queries are similar in execution time.
     288
     289Let's assume the output file is ''crab-data-only.root'' (`rootifysql --out=crab-data-only.root`). Requesting the data and writing the file took me about 60s.
     290
     291To run an analysis on the data you can use the following root macro "''analysis.C''". It produces a theta-square plot. Its execution took about five seconds (`root analysis.C++`). The `++` behind the macro name forces root to compile the macro before execution (might not be necessary anymore with root 6) to increase performance.
    292292
    293293{{{#!cpp
     
    448448   SELECT 240 AS Angle UNION ALL
    449449   SELECT 300 AS Angle
    450 ) Wobble
     450) Wobble60deg
    451451WHERE
    452452   fSourceKey=5
     
    461461}}}
    462462
    463 Or you use the existing table for the standard 60° Wobble positions and do just {{{CROSS JOIN Wobble}}}.
    464 
    465 This will give you all you need in ''crab.root'' ({{{rootifysql --out=crab.root}}}), but significantly increases computing time and the output file will be about six times larger.
     463Or you use the existing table for the standard 60° Wobble positions and do just `CROSS JOIN Wobble`.
     464
     465This will give you all you need in ''crab.root'' (`rootifysql --out=crab.root`), but significantly increases computing time and the output file will be about six times larger.
    466466
    467467A simple macro just applying all the cuts would then be enough to do a theta-square plot