4 from ROOT
import TChain, TH1D
5 import os, sys, subprocess
11 from utilities
import *
24 oldfolder =
'/net/cms2/cms2r0/babymaker/babies/2016_01_11/mc/T1tttt/skim_abcd/' 25 newfolder =
'/net/cms26/cms26r0/babymaker/2016_04_29/normalized/T1tttt/skim_abcd/' 27 oldfolder =
'/net/cms2/cms2r0/babymaker/babies/2016_01_11/mc/T1tttt/' 28 newfolder =
'/net/cms26/cms26r0/babymaker/2016_04_29/normalized/T1tttt/' 30 newfolder =
'/net/cms27/cms27r0/babymaker/2016_04_29/mc/skim_met100nb2nj4nl0' 31 oldfolder =
'/net/cms27/cms27r0/babymaker/2016_04_29/mc/merged_met100nb2nj4nl0' 33 oldfolder =
'/net/cms2/cms2r0/babymaker/babies/2015_11_28/mc/skim_1lht500met200' 34 newfolder =
'/net/cms27/cms27r0/babymaker/2016_04_29/mc/merged_1lht500met200' 36 oldfolder =
'/net/cms2/cms2r0/babymaker/babies/2016_04_29/mc/unskimmed/' 37 newfolder =
'/net/cms29/cms29r0/babymaker/babies/2016_08_10/mc/unskimmed/' 39 oweight =
"weight/w_toppt/eff_trig" 40 nweight =
"weight/w_isr/w_pu" 45 print '\nOLD FOLDER: '+oldfolder
46 print 'NEW FOLDER: '+newfolder
47 print 'OLD WEIGHT "'+oweight+
'" - NEW WEIGHT "'+nweight
49 print '\n{:>40}'.format(
' Ntuple name ')+
'{:>16}'.format(
'Difference')+
'{:>17}'.format(
'Old yield'),
50 print '{:>17}'.format(
'New yield')+
'{:>17}'.format(
'Old entries')+
'{:>17}'.format(
'New entries')
56 histo = TH1D(
"histo",
"",10,0,10)
57 for ifile
in sortedfiles:
58 ochain = TChain(
"tree")
59 oldntuples = oldfolder+
"/*"+ifile+
'*root' 60 no = ochain.Add(oldntuples)
62 not_in_old.append(ifile)
64 nchain = TChain(
"tree")
65 newntuples = newfolder+
"/*"+ifile+
'*root' 66 nn = nchain.Add(newntuples)
68 not_in_new.append(ifile)
71 no = ochain.Draw(
"1>>histo",oweight,
"goff")
72 oldtot = histo.Integral()
73 nn = nchain.Draw(
"1>>histo",nweight,
"goff")
74 newtot = histo.Integral()
76 if oldtot != 0 : diff = (newtot-oldtot)*100/oldtot
77 elif newtot == 0 : diff = 0
83 if abs(diff) > 150/math.sqrt(no+1)
and abs(diff) > 150/math.sqrt(nn+1):
84 rows.append([ifile, abs(diff), oldtot, newtot, no, nn])
86 posttag = bcolors.ENDC
88 print pretag+
'{:>40}'.format(ifile)+
'{:>14.2f}'.format(diff)+
' %'+
'{:>17.2f}'.format(oldtot),
89 print '{:>17.2f}'.format(newtot)+
'{:>17}'.format(no)+
'{:>17}'.format(nn)+posttag
97 print bcolors.FAIL +
"\nSamples off by more than 1.5 sigma"+ bcolors.ENDC
98 print '\n{:>40}'.format(
' Ntuple name ')+
'{:>16}'.format(
'Difference')+
'{:>17}'.format(
'Old yield'),
99 print '{:>17}'.format(
'New yield')+
'{:>17}'.format(
'Old entries')+
'{:>17}'.format(
'New entries')
101 rows = sorted(rows, key=
lambda rows: rows[1])
112 print '{:>40}'.format(ifile)+
'{:>14.2f}'.format(diff)+
' %'+
'{:>17.2f}'.format(oldtot),
113 print '{:>17.2f}'.format(newtot)+
'{:>17}'.format(no)+
'{:>17}'.format(nn)
119 if len(not_in_old) > 0:
120 print bcolors.BOLD +
'\nNtuples not found in '+oldfolder+
':'+ bcolors.ENDC
121 for ntu
in not_in_old:
123 if len(not_in_new) > 0:
124 print bcolors.BOLD +
'\nNtuples not found in '+newfolder+
':'+ bcolors.ENDC
125 for ntu
in not_in_new:
def findBaseSampleNames(folder)
Finding basename for each dataset.