Changes between Version 13 and Version 14 of DatabaseBasedAnalysis


Ignore:
Timestamp:
08/03/18 20:38:25 (6 years ago)
Author:
tbretz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DatabaseBasedAnalysis

    v13 v14  
    170170}}}
    171171
     172== Data statistics ==
     173
     174Now we want to get some statistics about the Crab data between 01/11/2013 and 06/11/2013 and see if we can do simple plots. For this we write the table into a root file.
     175
     176{{{rootifysql [...] --query " \
     177   SELECT               \
     178      *                 \
     179   FROM                 \
     180      RunInfo           \
     181   WHERE                \
     182      fSourceKey=5      \
     183   AND                  \
     184      fRunTypeKey=1     \
     185   AND                  \
     186      FileId BETWEEN 131101000 AND 131107000 \
     187   AND                  \
     188      fR750Ref/fR750Cor>0.9 \
     189   AND                  \
     190      fZenithDistanceMax<35 \
     191"
     192}}}}
     193 
     194If the file already exists, either give it a different name (see --help for details) or overwrite it with --force.
     195
     196The output should look similar to this
     197{{{
     198Reading global  options from 'fact++.rc'.
     199Reading default options from 'rootifysql.rc'.
     200
     201------------------------ Rootify SQL -------------------------
     202Connecting to database...
     203Client Version: 5.7.23
     204Server Version: 5.7.23-0ubuntu0.18.04.1
     205Requesting data...
     206Opening file 'rootify.root' [compression=1]...
     207Trying to setup 120 branches...
     208Configured 115 branches.
     209Filling branches...
     210317 rows fetched.
     211317 rows skipped due to NULL field.
     2120 rows filled into tree.
     21310 kB written to disk.
     214File closed.
     215Execution time: 0.0537751s (169.6 us/row)
     216--------------------------------------------------------------
     217}}}
     218
     219Per 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:
     220{{{
     221Reading global  options from 'fact++.rc'.
     222Reading default options from 'rootifysql.rc'.
     223
     224------------------------ Rootify SQL -------------------------
     225Connecting to database...
     226Client Version: 5.7.23
     227Server Version: 5.7.23-0ubuntu0.18.04.1
     228Requesting data...
     229Opening file 'rootify.root' [compression=1]...
     230Trying to setup 120 branches...
     231Configured 115 branches.
     232Filling branches...
     233317 rows fetched.
     234317 rows filled into tree.
     23586 kB written to disk.
     236File closed.
     237Execution time: 0.072247s (227.9 us/row)
     238--------------------------------------------------------------
     239}}}
     240
     241Now we can open the file in root and do plots. The easiest ist to use the tree viewer:
     242{{{
     243root rootify.root
     244root [0]
     245Attaching file rootify.root as _file0...
     246root [1] TTree *T = (TTree*)_file0->Get("Result");
     247root [2] T->StartViewer();
     248root [3]
     249}}}
     250
     251Or plot the zenith angle distribution directly:
     252{{{
     253root rootify.root
     254root [0]
     255Attaching file rootify.root as _file0...
     256root [1] TTree *T = (TTree*)_file0->Get("Result");
     257root [2] T->Draw("fZenithDistanceMean");
     258root [3]
     259}}}
     260
     261or zenith angle versus time (Hint: DATETIME columns are converted to Unix-time in seconds):
     262
     263{{{
     264root rootify.root
     265root [0]
     266Attaching file rootify.root as _file0...
     267root [1] TTree *T = (TTree*)_file0->Get("Result");
     268root [2] T->Draw("fZenithDistanceMean:fRunStart");
     269root [3]
     270}}}
     271
     272
     273
     274
     275
     276
     277
    172278
    173279