Functions | Variables
plot_xsec_1d Namespace Reference

Functions

def get_genie_universes (basefn)
 
def get_ppfx_universes (fppfx_other)
 
def do_multiverse_1bin (isys, univ_vals)
 
def do_focusing_1bin (isys, sstart, nsys)
 
def do_up_down_1bin (isys, upidx, dwidx)
 
def do_single_shift_1bin (isys, idx)
 
def setUncer1D (hIn, ihist)
 

Variables

string infp = './'
 
list syst_names
 
list fu_names = ['Flux_HP','GENIE','Light','Calibration','Cherenkov','CalibShape','MuEScale','Normalization','Focusing']
 
list final_fu = ['Flux (HP)','GENIE','Light','Calibration','Cherenkov','Calib. Shape','Mu Energy Scale','Normalization','Focusing']
 
list col_fe = [2,4,2,4,8,8,kOrange-3,kOrange-3,1]
 
list col_st = [1,1,2,2,1,2,1,2,2]
 
 parser = argparse.ArgumentParser()
 
 action
 
 help
 
 args = parser.parse_args()
 
 use_data = args.data
 
list fgenie = []
 
 fmc = TFile(os.path.join(infp, 'nominal_xsec.root'))
 
 fppfx_other = TFile(os.path.join(infp, 'ppfx_others_v2.root'))
 
list hgenie = []
 
list hppfx = []
 
list hother = []
 
 hmc = fmc.Get('hXS1Dsec_nominal')
 
 hdt = fppfx_other.Get('xs_nominal/hXS1Dsec_cv')
 
 nfu = len(fu_names)
 
list lhup = [hmc.Clone('hUp_{}'.format(i)) for i in range(nfu)]
 
list lhdw = [hmc.Clone('hDw_{}'.format(i)) for i in range(nfu)]
 
list lhfu = [hmc.Clone('hFU_{}'.format(i)) for i in range(nfu)]
 
 Nbins = hdt.GetNbinsX()
 
 cv = hdt.GetBinContent(b)
 
float fe_norm = 0.028422526
 
int fu = 0
 
string out_subdir = 'real_data'
 
 dest_path = os.path.join('output1d', out_subdir)
 
 cfu = TCanvas()
 
 lfu = TLegend(0.2,0.5,0.45,0.88)
 

Function Documentation

def plot_xsec_1d.do_focusing_1bin (   isys,
  sstart,
  nsys 
)

Definition at line 71 of file plot_xsec_1d.py.

References cet::sqlite.max(), PandAna.Demos.demo1.range, SetBinContent(), and sum.

71 def do_focusing_1bin(isys, sstart, nsys):
72 
73  up_shifts = [0 for k in range(nsys)]
74  dw_shifts = [0 for k in range(nsys)]
75  for k in range(nsys):
76  dwshift = cv - hother[sstart+k*2].GetBinContent(i)
77  upshift = hother[sstart+k*2+1].GetBinContent(i) - cv
78 
79  if upshift > 0 and dwshift > 0:
80  up_shifts[k] = upshift
81  dw_shifts[k] = dwshift
82  elif upshift <= 0 and dwshift <= 0: # up down flip
83  up_shifts[k] = -dwshift
84  dw_shifts[k] = -upshift
85  elif upshift > 0 and dwshift <= 0:
86  up_shifts[k] = upshift
87  else:
88  dw_shifts[k] = dwshift
89 
90  up_shift = math.sqrt(sum([x**2 for x in up_shifts]))
91  dw_shift = math.sqrt(sum([x**2 for x in dw_shifts]))
92  lhup[isys].SetBinContent(b, up_shift)
93  lhdw[isys].SetBinContent(b, dw_shift)
94 
95  fu = 0 if cv <= 0 else max(up_shift, dw_shift)/cv
96  lhfu[isys].SetBinContent(b, fu)
97 
98 
def do_focusing_1bin(isys, sstart, nsys)
Definition: plot_xsec_1d.py:71
cout<< "--"<< endl;for(Int_t iP=1;iP<=hyz->GetNbinsX();iP++){for(Int_t iC=1;iC<=hyz->GetNbinsY();iC++){if(hyv->GetBinContent(iP, iC)>-999){goal_hyv-> SetBinContent(iP, iC,-(dy[iP-1][iC-1]))
Double_t sum
Definition: plot.C:31
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
def plot_xsec_1d.do_multiverse_1bin (   isys,
  univ_vals 
)

Definition at line 54 of file plot_xsec_1d.py.

References makeTrainCVSamples.int, cet::sqlite.max(), and SetBinContent().

54 def do_multiverse_1bin(isys, univ_vals):
55 
56  sorted_list = sorted(univ_vals)
57  cv_pos = bisect(sorted_list, cv)
58  nlist = len(univ_vals)
59  up_pos = nlist-1 if cv_pos >= nlist else int((nlist - cv_pos)*.68 + cv_pos)
60  dw_pos = 0 if cv_pos <= 0 else int(cv_pos - cv_pos*.68)
61 
62  up_shift = sorted_list[up_pos] - cv
63  dw_shift = cv - sorted_list[dw_pos]
64 
65  lhup[isys].SetBinContent(b, up_shift)
66  lhdw[isys].SetBinContent(b, dw_shift)
67  fu = 0 if cv <= 0 else max(up_shift, dw_shift)/cv
68  lhfu[isys].SetBinContent(b, fu)
69 
70 
def do_multiverse_1bin(isys, univ_vals)
Definition: plot_xsec_1d.py:54
cout<< "--"<< endl;for(Int_t iP=1;iP<=hyz->GetNbinsX();iP++){for(Int_t iC=1;iC<=hyz->GetNbinsY();iC++){if(hyv->GetBinContent(iP, iC)>-999){goal_hyv-> SetBinContent(iP, iC,-(dy[iP-1][iC-1]))
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
def plot_xsec_1d.do_single_shift_1bin (   isys,
  idx 
)
Each bin is initialized to 0 to allow one-sided error bars.

Definition at line 128 of file plot_xsec_1d.py.

References abs(), and SetBinContent().

128 def do_single_shift_1bin(isys, idx):
129  '''
130  Each bin is initialized to 0 to allow one-sided error bars.
131  '''
132 
133  lhup[isys].SetBinContent(b, 0)
134  lhdw[isys].SetBinContent(b, 0)
135  shift = hother[idx].GetBinContent(b)-cv
136  if shift > 0:
137  lhup[isys].SetBinContent(b, shift)
138  else:
139  lhdw[isys].SetBinContent(b, -shift)
140 
141  fu = 0 if cv <= 0 else abs(shift)/cv
142  lhfu[isys].SetBinContent(b, fu)
143 
144 
void abs(TH1 *hist)
cout<< "--"<< endl;for(Int_t iP=1;iP<=hyz->GetNbinsX();iP++){for(Int_t iC=1;iC<=hyz->GetNbinsY();iC++){if(hyv->GetBinContent(iP, iC)>-999){goal_hyv-> SetBinContent(iP, iC,-(dy[iP-1][iC-1]))
def do_single_shift_1bin(isys, idx)
def plot_xsec_1d.do_up_down_1bin (   isys,
  upidx,
  dwidx 
)
It could happen that in some regions both systematics go the same direction.
In that case we take the larger value for that direction and asign zero to the other.

Definition at line 99 of file plot_xsec_1d.py.

References abs(), cet::sqlite.max(), and SetBinContent().

99 def do_up_down_1bin(isys, upidx, dwidx):
100  '''
101  It could happen that in some regions both systematics go the same direction.
102  In that case we take the larger value for that direction and asign zero to the other.
103  '''
104 
105  # initialize
106  lhup[isys].SetBinContent(b, 0)
107  lhdw[isys].SetBinContent(b, 0)
108 
109  upshift = hother[upidx].GetBinContent(b)-cv
110  dwshift = cv-hother[dwidx].GetBinContent(b)
111  larger = max(abs(upshift), abs(dwshift))
112 
113  if upshift > 0 and dwshift > 0:
114  lhup[isys].SetBinContent(b, upshift)
115  lhdw[isys].SetBinContent(b, dwshift)
116  elif upshift <= 0 and dwshift <= 0: # up down flip
117  lhup[isys].SetBinContent(b, -dwshift)
118  lhdw[isys].SetBinContent(b, -upshift)
119  elif upshift > 0 and dwshift <= 0:
120  lhup[isys].SetBinContent(b, upshift)
121  else:
122  lhdw[isys].SetBinContent(b, dwshift)
123 
124  fu = 0 if cv <= 0 else larger/cv
125  lhfu[isys].SetBinContent(b, fu)
126 
127 
void abs(TH1 *hist)
cout<< "--"<< endl;for(Int_t iP=1;iP<=hyz->GetNbinsX();iP++){for(Int_t iC=1;iC<=hyz->GetNbinsY();iC++){if(hyv->GetBinContent(iP, iC)>-999){goal_hyv-> SetBinContent(iP, iC,-(dy[iP-1][iC-1]))
def do_up_down_1bin(isys, upidx, dwidx)
Definition: plot_xsec_1d.py:99
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
def plot_xsec_1d.get_genie_universes (   basefn)

Definition at line 31 of file plot_xsec_1d.py.

References novadaq::HexUtils.format(), Get, makeTrainCVSamples.int, and PandAna.Demos.demo1.range.

31 def get_genie_universes(basefn):
32 
33  hl = []
34  fn = os.path.join(infp, basefn)
35  fgenie.append(TFile(fn))
36  # find the genie universe IDs from filename
37  sIdx = int(basefn.split('_')[1])
38  eIdx = int(basefn.split('_')[2])+1
39  for i in range(sIdx,eIdx):
40  hl.append(fgenie[len(fgenie)-1].Get('xs_nominal/hXS1Dsec_genie{}'.format(i)))
41 
42  return hl
43 
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
def get_genie_universes(basefn)
Definition: plot_xsec_1d.py:31
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
def plot_xsec_1d.get_ppfx_universes (   fppfx_other)

Definition at line 44 of file plot_xsec_1d.py.

References novadaq::HexUtils.format(), and PandAna.Demos.demo1.range.

44 def get_ppfx_universes(fppfx_other):
45 
46  hl = []
47  # by default we have 100 ppfx universes
48  for i in range(0,100):
49  hl.append(fppfx_other.Get('xs_nominal/hXS1Dsec_ppfx{}'.format(i)))
50 
51  return hl
52 
53 
def get_ppfx_universes(fppfx_other)
Definition: plot_xsec_1d.py:44
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
def plot_xsec_1d.setUncer1D (   hIn,
  ihist 
)

Definition at line 145 of file plot_xsec_1d.py.

145 def setUncer1D(hIn, ihist):
146  hIn.SetLineColor(col_fe[ihist])
147  hIn.SetLineWidth(3)
148  hIn.SetLineStyle(col_st[ihist])
149  hIn.SetStats(0)
150 
151 
def setUncer1D(hIn, ihist)

Variable Documentation

plot_xsec_1d.action

Definition at line 157 of file plot_xsec_1d.py.

plot_xsec_1d.args = parser.parse_args()

Definition at line 158 of file plot_xsec_1d.py.

plot_xsec_1d.cfu = TCanvas()

Definition at line 279 of file plot_xsec_1d.py.

list plot_xsec_1d.col_fe = [2,4,2,4,8,8,kOrange-3,kOrange-3,1]

Definition at line 28 of file plot_xsec_1d.py.

list plot_xsec_1d.col_st = [1,1,2,2,1,2,1,2,2]

Definition at line 29 of file plot_xsec_1d.py.

plot_xsec_1d.cv = hdt.GetBinContent(b)

Definition at line 213 of file plot_xsec_1d.py.

plot_xsec_1d.dest_path = os.path.join('output1d', out_subdir)

Definition at line 255 of file plot_xsec_1d.py.

float plot_xsec_1d.fe_norm = 0.028422526

Definition at line 242 of file plot_xsec_1d.py.

list plot_xsec_1d.fgenie = []

Definition at line 163 of file plot_xsec_1d.py.

list plot_xsec_1d.final_fu = ['Flux (HP)','GENIE','Light','Calibration','Cherenkov','Calib. Shape','Mu Energy Scale','Normalization','Focusing']

Definition at line 27 of file plot_xsec_1d.py.

plot_xsec_1d.fmc = TFile(os.path.join(infp, 'nominal_xsec.root'))

Definition at line 164 of file plot_xsec_1d.py.

plot_xsec_1d.fppfx_other = TFile(os.path.join(infp, 'ppfx_others_v2.root'))

Definition at line 169 of file plot_xsec_1d.py.

int plot_xsec_1d.fu = 0

Definition at line 245 of file plot_xsec_1d.py.

list plot_xsec_1d.fu_names = ['Flux_HP','GENIE','Light','Calibration','Cherenkov','CalibShape','MuEScale','Normalization','Focusing']

Definition at line 26 of file plot_xsec_1d.py.

plot_xsec_1d.hdt = fppfx_other.Get('xs_nominal/hXS1Dsec_cv')

Definition at line 181 of file plot_xsec_1d.py.

Referenced by PlotSyst(), and PlotSysts().

plot_xsec_1d.help

Definition at line 157 of file plot_xsec_1d.py.

list plot_xsec_1d.hgenie = []

Definition at line 174 of file plot_xsec_1d.py.

Referenced by demo6().

plot_xsec_1d.hmc = fmc.Get('hXS1Dsec_nominal')
list plot_xsec_1d.hother = []

Definition at line 176 of file plot_xsec_1d.py.

list plot_xsec_1d.hppfx = []

Definition at line 175 of file plot_xsec_1d.py.

string plot_xsec_1d.infp = './'

Definition at line 14 of file plot_xsec_1d.py.

plot_xsec_1d.lfu = TLegend(0.2,0.5,0.45,0.88)

Definition at line 280 of file plot_xsec_1d.py.

list plot_xsec_1d.lhdw = [hmc.Clone('hDw_{}'.format(i)) for i in range(nfu)]

Definition at line 203 of file plot_xsec_1d.py.

list plot_xsec_1d.lhfu = [hmc.Clone('hFU_{}'.format(i)) for i in range(nfu)]

Definition at line 204 of file plot_xsec_1d.py.

list plot_xsec_1d.lhup = [hmc.Clone('hUp_{}'.format(i)) for i in range(nfu)]

Definition at line 202 of file plot_xsec_1d.py.

plot_xsec_1d.Nbins = hdt.GetNbinsX()
plot_xsec_1d.nfu = len(fu_names)

Definition at line 201 of file plot_xsec_1d.py.

string plot_xsec_1d.out_subdir = 'real_data'

Definition at line 254 of file plot_xsec_1d.py.

plot_xsec_1d.parser = argparse.ArgumentParser()

Definition at line 156 of file plot_xsec_1d.py.

list plot_xsec_1d.syst_names
Initial value:
1 = [
2  'lightdown','lightup','ckv','calibneg','calibpos','calibshape','MuES_onlyMuKEDw','MuES_onlyMuKEUp',
3  '2kA_Dw','2kA_Up','02mmBeamSpotSize_Dw','02mmBeamSpotSize_Up','1mmBeamShiftX_Dw','1mmBeamShiftX_Up',
4  '1mmBeamShiftY_Dw','1mmBeamShiftY_Up','3mmHorn1X_Dw','3mmHorn1X_Up','3mmHorn1Y_Dw','3mmHorn1Y_Up',
5  '3mmHorn2X_Dw','3mmHorn2X_Up','3mmHorn2Y_Dw','3mmHorn2Y_Up','7mmTargetZ_Dw','7mmTargetZ_Up',
6  'MagneticFieldinDecayPipe_Dw','MagneticFieldinDecayPipe_Up','1mmHornWater_Dw','1mmHornWater_Up'
7 ]

Definition at line 17 of file plot_xsec_1d.py.

Referenced by ana::NusSystematicsMaker.SaveTo().

plot_xsec_1d.use_data = args.data

Definition at line 159 of file plot_xsec_1d.py.