| 172 | == Data statistics == |
| 173 | |
| 174 | Now 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 | |
| 194 | If the file already exists, either give it a different name (see --help for details) or overwrite it with --force. |
| 195 | |
| 196 | The output should look similar to this |
| 197 | {{{ |
| 198 | Reading global options from 'fact++.rc'. |
| 199 | Reading default options from 'rootifysql.rc'. |
| 200 | |
| 201 | ------------------------ Rootify SQL ------------------------- |
| 202 | Connecting to database... |
| 203 | Client Version: 5.7.23 |
| 204 | Server Version: 5.7.23-0ubuntu0.18.04.1 |
| 205 | Requesting data... |
| 206 | Opening file 'rootify.root' [compression=1]... |
| 207 | Trying to setup 120 branches... |
| 208 | Configured 115 branches. |
| 209 | Filling branches... |
| 210 | 317 rows fetched. |
| 211 | 317 rows skipped due to NULL field. |
| 212 | 0 rows filled into tree. |
| 213 | 10 kB written to disk. |
| 214 | File closed. |
| 215 | Execution time: 0.0537751s (169.6 us/row) |
| 216 | -------------------------------------------------------------- |
| 217 | }}} |
| 218 | |
| 219 | 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: |
| 220 | {{{ |
| 221 | Reading global options from 'fact++.rc'. |
| 222 | Reading default options from 'rootifysql.rc'. |
| 223 | |
| 224 | ------------------------ Rootify SQL ------------------------- |
| 225 | Connecting to database... |
| 226 | Client Version: 5.7.23 |
| 227 | Server Version: 5.7.23-0ubuntu0.18.04.1 |
| 228 | Requesting data... |
| 229 | Opening file 'rootify.root' [compression=1]... |
| 230 | Trying to setup 120 branches... |
| 231 | Configured 115 branches. |
| 232 | Filling branches... |
| 233 | 317 rows fetched. |
| 234 | 317 rows filled into tree. |
| 235 | 86 kB written to disk. |
| 236 | File closed. |
| 237 | Execution time: 0.072247s (227.9 us/row) |
| 238 | -------------------------------------------------------------- |
| 239 | }}} |
| 240 | |
| 241 | Now we can open the file in root and do plots. The easiest ist to use the tree viewer: |
| 242 | {{{ |
| 243 | root rootify.root |
| 244 | root [0] |
| 245 | Attaching file rootify.root as _file0... |
| 246 | root [1] TTree *T = (TTree*)_file0->Get("Result"); |
| 247 | root [2] T->StartViewer(); |
| 248 | root [3] |
| 249 | }}} |
| 250 | |
| 251 | Or plot the zenith angle distribution directly: |
| 252 | {{{ |
| 253 | root rootify.root |
| 254 | root [0] |
| 255 | Attaching file rootify.root as _file0... |
| 256 | root [1] TTree *T = (TTree*)_file0->Get("Result"); |
| 257 | root [2] T->Draw("fZenithDistanceMean"); |
| 258 | root [3] |
| 259 | }}} |
| 260 | |
| 261 | or zenith angle versus time (Hint: DATETIME columns are converted to Unix-time in seconds): |
| 262 | |
| 263 | {{{ |
| 264 | root rootify.root |
| 265 | root [0] |
| 266 | Attaching file rootify.root as _file0... |
| 267 | root [1] TTree *T = (TTree*)_file0->Get("Result"); |
| 268 | root [2] T->Draw("fZenithDistanceMean:fRunStart"); |
| 269 | root [3] |
| 270 | }}} |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |