ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/macros/makePressureGraphWithErr.py
Revision: 1.1
Committed: Mon Aug 27 10:26:40 2012 UTC (12 years, 8 months ago) by cwiok
Content type: text/x-python
Branch: MAIN
CVS Tags: Artur_11_07_2013_B, Artur_11_07_2013_A, Artur_11_07_2013, Artur_28_06_2013, Mikolaj_cmssw533, HEAD
Log Message:
Updated scripts for making the plots

File Contents

# Content
1 #!/usr/bin/env python
2
3 import os, commands, sys
4 from array import array
5 import ROOT
6
7 if __name__ == "__main__":
8 if len(sys.argv[1:]) != 1:
9 print "\nUsage "+sys.argv[0]+" <file>"
10 print "where <file> is a text file with 2 columns:"
11 print "RUN_NUMBER PRESSURE[mbar] PRESSURE_err[mbar]\n"
12 exit()
13
14 ###Read data from txt file
15 #file = open('pressure_twiki_160406-172268.dat')
16 file = open(sys.argv[1])
17 counter = 0
18 runs = []
19 pressure = []
20 pressureErr = []
21 dummyErr = []
22 for line in file:
23 print line.split()
24 dummyErr.append(0.0)
25 runs.append(float(line.split()[0]))
26 if(len(line.split())>1):
27 pressure.append(float(line.split()[1]))
28 if(len(line.split())>2):
29 pressureErr.append(float(line.split()[2]))
30 else:
31 pressureErr.append(0.0)
32 else:
33 pressure.append(0.0)
34 pressureErr.append(0.0)
35 counter+=1
36
37 x = array("d",runs)
38 y = array("d",pressure)
39 ex = array("d",dummyErr)
40 ey = array("d",pressureErr)
41
42 ###Define efficiency map histogram
43 myFile = ROOT.TFile("PressureGraph.root","RECREATE")
44 myGraph = ROOT.TGraphErrors(len(runs),x,y,ex,ey)
45 myGraph.SetName("Graph")
46
47 myGraph.Write()
48 myFile.Write()
49 myFile.Close()