ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/L1RpcTriggerAnalysis/macros/makeClusterSizeGraph.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

# User Rev Content
1 cwiok 1.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 at least 6 columns:"
11     print "RUN_NUMBER PRESSURE EFF_B EFF_E CSIZE_B CSIZE_E PERCENT_MASKED_B PERCENT_MASKED_E\n"
12     exit()
13    
14     ###Read data from txt file
15     file = open(sys.argv[1])
16     counter = 0
17     runsP = []
18     runsCB = []
19     runsCE = []
20     pressure = []
21     csizeBarrel = []
22     csizeEndcap = []
23     for line in file:
24     print line.split()
25     if(line[0]=="#"):
26     print "Line skipped"
27     continue
28     if(len(line.split())>5):
29     r = float(line.split()[0])
30     p = float(line.split()[1])
31     cb = float(line.split()[4])
32     ce = float(line.split()[5])
33     if(r>0 and p>0):
34     runsP.append(r);
35     pressure.append(p);
36     if(r>0 and cb>0):
37     runsCB.append(r);
38     csizeBarrel.append(cb);
39     if(r>0 and ce>0):
40     runsCE.append(r);
41     csizeEndcap.append(ce);
42    
43     x1 = array("d",runsP)
44     x2 = array("d",runsCB)
45     x3 = array("d",runsCE)
46     y1 = array("d",pressure)
47     y2 = array("d",csizeBarrel)
48     y3 = array("d",csizeEndcap)
49    
50     #myFile1 = ROOT.TFile("PressureGraph.root","RECREATE")
51     #myGraph1 = ROOT.TGraph(len(runsP),x1,y1)
52     #myGraph1.SetName("Graph");
53     #myGraph1.SetTitle("Pressure vs Run number;Run;Pressure [mbar]");
54     #myGraph1.Write()
55     #myFile1.Write()
56     #myFile1.Close()
57    
58     myFile2 = ROOT.TFile("ClusterSizeGraph_Barrel.root","RECREATE")
59     myGraph2 = ROOT.TGraph(len(runsCB),x2,y2)
60     myGraph2.SetName("Graph");
61     myGraph2.SetTitle("Barrel cluster size vs Run number;Run;Cluster size [strips]");
62     myGraph2.Write()
63     myFile2.Write()
64     myFile2.Close()
65    
66     myFile3 = ROOT.TFile("ClusterSizeGraph_Endcap.root","RECREATE")
67     myGraph3 = ROOT.TGraph(len(runsCE),x3,y3)
68     myGraph3.SetName("Graph");
69     myGraph3.SetTitle("Endcap cluster size vs Run number;Run;Cluster size [strips]");
70     myGraph3.Write()
71     myFile3.Write()
72     myFile3.Close()