Changes between Version 5 and Version 6 of DatabaseBasedAnalysis


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

--

Legend:

Unmodified
Added
Removed
Modified
  • DatabaseBasedAnalysis

    v5 v6  
    99First, you need a user. For the moment, a user 'fact' is available with the standard password. The user 'fact' is allowed to connect from everywhere if an encrypted connection is used. Usually, all reasonably recent mysql clients are using encrypted connections. So in most cases, a simple should be enough
    1010
    11 {{{> mysql -C -h ihp-pc45.ethz.ch -u fact -p}}}
     11{{{> mysql -C -h ihp-pc45.ethz.ch -u fact -p factdata}}}
    1212
    1313To enforce encryption, --ssl (oder clients) or --ssl-mode=REQUIRED can be used. If you have problems with the connection, you can also try --protocol=TCP.
     
    2929The mysql call would now look like
    3030
    31 {{{> mysql -h 127.0.0.1 -P 10000 -u fact -p}}}
     31{{{> mysql -h 127.0.0.1 -P 10000 -u fact -p factdata}}}
    3232
    3333Note that you need to use the IP address instead of localhost, otherwise the mysql client tries to use a socket connection (which will fail). You could also use --protocol=TCP.
     
    4747You can now do
    4848
    49 {{{ISDC> mysql -h localhost -P 10000 -u fact -p}}}
     49{{{ISDC> mysql -h localhost -P 10000 -u fact -p factdata}}}
    5050
    5151Note that you need to use the IP address instead of localhost, otherwise the mysql client tries to use a socket connection (which will fail). You could also use --protocol=TCP.
     
    5656
    5757A convenient way to retrieve data is the ''rootifysql'' tool which is part of the FACT++ package. More details can be found either calling it with the --help option or at https://www.fact-project.org/logbook/showthread.php?tid=4192. The same access rules as if the native mysql client is used apply.
     58
     59To simplify the usage, it is wise to write a rootifysql.rc file with the following contents:
     60
     61{{{uri=fact:password@iph-pc45.ethz.ch/factdata}}}
     62
     63The following tutorial assumes that such a file exists.
    5864
    5965== Other alternatives ==
     
    7177For data selection only run-wise information should be relevant which are stored in the table '''RunInfo'''. The reason is that if you select data on a more fine grained level (e.g. event-wise zenith angle), right now there is no easy method to determine the corresponding observation time. So whenever data is selected event-wise make sure that you do not cut the data in a variable which cuts out events systematically and not randomly. For example, an event-wise cut in zenith angel usually keeps or discards two consecutive events because their zenith angle is correlated. For a cut in any image parameter (Width, Length, Size, ...), the result on two consecutive events is random because their image parameters are not correlated.
    7278
     79As an example we analyse the Crab data from our public sample (01/11/2013 - 06/11/2013).
     80
     81Let's first have a look at the total observation time of all Crab data in this period:
     82
     83{{{
     84SELECT
     85   COUNT(*),
     86   SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn/3600) AS EffOnTime,
     87   MIN(fZenithDistanceMin) AS ZdMin,
     88   MAX(fZenithDistanceMax) AS ZdMax
     89FROM
     90   RunInfo
     91WHERE
     92   fSourceKey=5
     93AND
     94   fRunTypeKey=1
     95AND
     96   FileId BETWEEN 131101000 AND 131107000
     97}}}
     98
     99The result (in mysql) is
     100{{{
     101+----------+-------------+-------+-------+
     102| COUNT(*) | EffOnTime   | ZdMin | ZdMax |
     103+----------+-------------+-------+-------+
     104|      435 | 32.53992354 |  6.36 | 67.89 |
     105+----------+-------------+-------+-------+
     1061 row in set (0.01 sec)
     107}}}
     108
     109So we have 435 data runs from Crab with a total effective observation time of 32.5 hrs in a zenith angle range between 6° and 68°.
     110
     111
    73112== Data retrieval ==
    74113