source: fact/tools/pyscripts/sandbox/weitzel/plot_trigger_rate.py@ 13449

Last change on this file since 13449 was 13409, checked in by weitzel, 13 years ago
python script added to plot the trigger rates of one night
  • Property svn:executable set to *
File size: 2.3 KB
Line 
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
10from array import array
11import os
12import re
13
14from factfits import FactFits
15
16from ROOT import TCanvas, TGraph
17from ROOT import gROOT
18from ROOT import gStyle
19
20gROOT.SetStyle("Plain")
21
22filelist = []
23base_path = "/fact/aux/2012/04/16/"
24
25for 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
38trigger_rate_array = array("d",[])
39time_array = array("d",[])
40
41for filename in filelist:
42
43 print filename
44
45 file_handle = FactFits(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
59canv = TCanvas("canv","title",50,50,1500,800)
60graph = TGraph(len(trigger_rate_array),time_array,trigger_rate_array)
61
62#change the time format to human readable
63graph.GetXaxis().SetTimeDisplay(1);
64#graph.GetXaxis().SetTimeFormat("%d.%m. %H:%M%F1970-01-01 00:00:00");
65graph.GetXaxis().SetTimeFormat("%H:%M%F1970-01-01 00:00:00")
66
67graph.SetMarkerStyle(7)
68graph.SetMarkerSize(1)
69graph.SetMarkerColor(2)
70graph.SetTitle("Night 16.04.2012")
71graph.GetYaxis().SetRangeUser(0,250)#zoom to be adapted for each night
72graph.GetXaxis().SetTitleOffset(1.2)
73graph.GetXaxis().SetTitle("UTC+4h (hh:mm)")#for summer time
74graph.GetYaxis().SetTitle("Trigger Rate (Hz)")
75graph.Draw("ap")
Note: See TracBrowser for help on using the repository browser.