ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/macros/makePressureGraph.py
(Generate patch)

Comparing UserCode/L1RpcTriggerAnalysis/macros/makePressureGraph.py (file contents):
Revision 1.1 by akalinow, Tue Jul 26 20:00:50 2011 UTC vs.
Revision 1.2 by cwiok, Sat Sep 10 15:14:22 2011 UTC

# Line 1 | Line 1
1   #!/usr/bin/env python
2  
3 < import os, commands
3 > import os, commands, sys
4   from array import array
5   import ROOT
6  
7 <
8 < ###Read data from txt file
9 < file = open('pressure_twiki_160406-171484.dat')
10 < counter = 0
11 < runs = []
12 < pressure = []
13 < for line in file:
14 <    print line.split()
15 <    runs.append(float(line.split()[0]))
16 <    if(len(line.split())>1):              
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]\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 >    for line in file:
21 >        print line.split()
22 >        runs.append(float(line.split()[0]))
23 >        if(len(line.split())>1):              
24                 pressure.append(float(line.split()[1]))
25 <    else:
25 >        else:
26                 pressure.append(0.0)              
27 <    counter+=1
27 >               counter+=1
28  
29 < x = array("d",runs)
30 < y = array("d",pressure)
29 >    x = array("d",runs)
30 >    y = array("d",pressure)
31  
32 < ###Define efficiency map histogram
33 < myFile = ROOT.TFile("PressureGraph.root","RECREATE")
34 < myGraph = ROOT.TGraph(len(runs),x,y)
35 <
36 < myGraph.Write()
37 < myFile.Write()
38 < myFile.Close()
32 >    ###Define efficiency map histogram
33 >    myFile = ROOT.TFile("PressureGraph.root","RECREATE")
34 >    myGraph = ROOT.TGraph(len(runs),x,y)
35 >
36 >    myGraph.Write()
37 >    myFile.Write()
38 >    myFile.Close()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines