CMS 3D CMS Logo

makePlotsFromDump.py
Go to the documentation of this file.
1 import os.path, glob, sys
2 import ROOT
3 
4 arch = sys.argv[1]
5 sample = sys.argv[2]
6 build = sys.argv[3]
7 suffix = sys.argv[4]
8 
9 g = ROOT.TFile("test_"+arch+"_"+sample+"_"+build+"_"+suffix+".root","recreate")
10 
11 # declare hists: reco only
12 h_MXNH = ROOT.TH1F("h_MXNH_"+suffix, "nHits/Track", 35, 0, 35)
13 h_MXPT = ROOT.TH1F("h_MXPT_"+suffix, "p_{T}^{mkFit}", 100, 0, 100)
14 h_MXETA = ROOT.TH1F("h_MXETA_"+suffix, "#eta^{mkFit}", 25, -2.5, 2.5)
15 h_MXPHI = ROOT.TH1F("h_MXPHI_"+suffix, "#phi^{mkFit}", 32, -3.2, 3.2)
16 
17 h_MXNH.Sumw2()
18 h_MXPT.Sumw2()
19 h_MXETA.Sumw2()
20 h_MXPHI.Sumw2()
21 
22 # declare hists: diffs
23 h_DCNH = ROOT.TH1F("h_DCNH_"+suffix, "#DeltanHits(mkFit,CMSSW)", 46, -20.5, 25.5)
24 h_DCPT = ROOT.TH1F("h_DCPT_"+suffix, "#Deltap_{T}(mkFit,CMSSW)", 63, -2.5, 2.5)
25 h_DCETA = ROOT.TH1F("h_DCETA_"+suffix, "#Delta#eta(mkFit,CMSSW)", 45, -0.5, 0.5)
26 h_DCPHI = ROOT.TH1F("h_DCPHI_"+suffix, "#Delta#phi(mkFit,CMSSW)", 45, -0.5, 0.5)
27 
28 h_DCNH.Sumw2()
29 h_DCPT.Sumw2()
30 h_DCETA.Sumw2()
31 h_DCPHI.Sumw2()
32 
33 with open('log_'+arch+'_'+sample+'_'+build+'_'+suffix+'_DumpForPlots.txt') as f :
34  for line in f :
35  if "MX - found track with chi2" in line :
36  lsplit = line.split()
37 
38  NH = float(lsplit[8])
39  h_MXNH.Fill(NH)
40 
41  PT = float(lsplit[10])
42  h_MXPT.Fill(PT)
43 
44  ETA = float(lsplit[12])
45  h_MXETA.Fill(ETA)
46 
47  PHI = float(lsplit[14])
48  h_MXPHI.Fill(PHI)
49 
50  NHC = float(lsplit[24])
51  if NHC > 0 :
52  h_DCNH.Fill(NH-NHC)
53 
54  PTC = float(lsplit[26])
55  h_DCPT.Fill(PT-PTC)
56 
57  ETAC = float(lsplit[28])
58  h_DCETA.Fill(ETA-ETAC)
59 
60  PHIC = float(lsplit[30])
61  h_DCPHI.Fill(PHI-PHIC)
62 
63 g.Write()
64 g.Close()