1 | #!/usr/bin/python -itt
|
---|
2 |
|
---|
3 | ##############################################
|
---|
4 | # by Q. Weitzel and T. Kraehenbuehl
|
---|
5 | # plot trigger rates for all runs of one night
|
---|
6 | # adapt base_path to select the night
|
---|
7 | # (and change title and zoom of the graph)
|
---|
8 | ##############################################
|
---|
9 |
|
---|
10 | from array import array
|
---|
11 | import os
|
---|
12 | import re
|
---|
13 |
|
---|
14 | from pyfact import SlowData
|
---|
15 |
|
---|
16 | from ROOT import TCanvas, TGraph
|
---|
17 | from ROOT import gROOT
|
---|
18 | from ROOT import gStyle
|
---|
19 |
|
---|
20 | gROOT.SetStyle("Plain")
|
---|
21 |
|
---|
22 | filelist = []
|
---|
23 | base_path = "/fact/aux/2012/04/16/"
|
---|
24 |
|
---|
25 | for base,subdirs,files in os.walk(base_path):
|
---|
26 | for filename in files:
|
---|
27 | #include only run files
|
---|
28 | regex = re.search(r'_\d\d\d\.FTM_CONTROL_TRIGGER_RATES',filename)
|
---|
29 | #include run files and also the nightly file
|
---|
30 | #regex = re.search(r'FTM_CONTROL_TRIGGER_RATES',filename)
|
---|
31 | if regex:
|
---|
32 | filelist.append(os.path.join(base,filename))
|
---|
33 |
|
---|
34 | #alternatively, select slow data files directly for the file list
|
---|
35 | #filelist = ["/fact/aux/2012/04/16/20120416_030.FTM_CONTROL_TRIGGER_RATES.fits",
|
---|
36 | # "/fact/aux/2012/04/16/20120416_040.FTM_CONTROL_TRIGGER_RATES.fits"]
|
---|
37 |
|
---|
38 | trigger_rate_array = array("d",[])
|
---|
39 | time_array = array("d",[])
|
---|
40 |
|
---|
41 | for filename in filelist:
|
---|
42 |
|
---|
43 | print filename
|
---|
44 |
|
---|
45 | file_handle = SlowData(filename)
|
---|
46 |
|
---|
47 | file_handle.register("TriggerRate")
|
---|
48 | file_handle.register("Time")
|
---|
49 | file_handle.register("FTMtimeStamp")
|
---|
50 |
|
---|
51 | ftm_ts_old = 1E10
|
---|
52 |
|
---|
53 | for row in file_handle:
|
---|
54 | if row.FTMtimeStamp>ftm_ts_old:#needed to remove negative rate in first report
|
---|
55 | trigger_rate_array.append(float(row.TriggerRate))
|
---|
56 | time_array.append(float(row.Time)*24*3600)
|
---|
57 | ftm_ts_old = row.FTMtimeStamp
|
---|
58 |
|
---|
59 | canv = TCanvas("canv","title",50,50,1500,800)
|
---|
60 | graph = TGraph(len(trigger_rate_array),time_array,trigger_rate_array)
|
---|
61 |
|
---|
62 | #change the time format to human readable
|
---|
63 | graph.GetXaxis().SetTimeDisplay(1);
|
---|
64 | #graph.GetXaxis().SetTimeFormat("%d.%m. %H:%M%F1970-01-01 00:00:00");
|
---|
65 | graph.GetXaxis().SetTimeFormat("%H:%M%F1970-01-01 00:00:00")
|
---|
66 |
|
---|
67 | graph.SetMarkerStyle(7)
|
---|
68 | graph.SetMarkerSize(1)
|
---|
69 | graph.SetMarkerColor(2)
|
---|
70 | graph.SetTitle("Night 16.04.2012")
|
---|
71 | graph.GetYaxis().SetRangeUser(0,250)#zoom to be adapted for each night
|
---|
72 | graph.GetXaxis().SetTitleOffset(1.2)
|
---|
73 | graph.GetXaxis().SetTitle("UTC+4h (hh:mm)")#for summer time
|
---|
74 | graph.GetYaxis().SetTitle("Trigger Rate (Hz)")
|
---|
75 | graph.Draw("ap")
|
---|