Changes between Version 65 and Version 66 of DatabaseBasedAnalysis
- Timestamp:
- 08/06/18 15:30:17 (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DatabaseBasedAnalysis
v65 v66 16 16 17 17 * 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=419218 * MAN page of the mysql client: `man mysql` 19 * `rootifysql --help` and https://www.fact-project.org/logbook/showthread.php?tid=4192 20 20 * PHP MySQL API: http://php.net/manual/en/book.mysql.php 21 21 * MySQL++: https://tangentsoft.com/mysqlpp/home … … 23 23 == Installing FACT++ == 24 24 25 If you want to install {{{rootifysql}}}, you find a description here: [[InstallingFACT++]]25 If you want to install `rootifysql`, you find a description here: [[InstallingFACT++]] 26 26 27 27 == Connecting to the Database == … … 33 33 === mysql === 34 34 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.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. 36 36 37 37 === rootifysql === 38 38 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.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. 42 42 43 43 Some more detailed instructions can be found at [[DatabaseBasedAnalysis/rootifysql]]. … … 94 94 So 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). 95 95 96 Taking only good data by adding " {{{AND fR750Cor/fR750Ref>0.9}}}" to the WHERE-clause gives us96 Taking only good data by adding "`AND fR750Cor/fR750Ref>0.9`" to the WHERE-clause gives us 97 97 {{{ 98 98 +----------+-------------+-------+-------+---------+---------+ … … 104 104 }}} 105 105 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 yields106 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 107 107 {{{ 108 108 +----------+-------------+-------+-------+---------+---------+ … … 148 148 #!/path/to/rootifysql --config=/path/to/resources.rc 149 149 }}} 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 directly150 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 151 151 {{{ 152 152 ./query.sql -n -w Crab.txt … … 198 198 }}} 199 199 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: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: 201 201 {{{ 202 202 ------------------------ Rootify SQL ------------------------- … … 285 285 }}} 286 286 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.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. 292 292 293 293 {{{#!cpp … … 448 448 SELECT 240 AS Angle UNION ALL 449 449 SELECT 300 AS Angle 450 ) Wobble 450 ) Wobble60deg 451 451 WHERE 452 452 fSourceKey=5 … … 461 461 }}} 462 462 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.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. 466 466 467 467 A simple macro just applying all the cuts would then be enough to do a theta-square plot