decay.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from ROOT import TH1F, TH2F, TFile
4 from math import *
5 
6 hists1D = [
7  ("ndecay", 16, -0.5, 15.5),
8  ("ntype", 31, -15.5, 15.5),
9  ("ptype", 7000, -3500., 3500.),
10  ("nimpwt",100, 0., 50.),
11  ("vz", 1000, -10000.0, 90000.0)
12 ]
13 hists2D = [
14  ("vx_vs_vy", 100, -500.0, 500., 100, -500.0, 500.0),
15  ("pdpz_vs_pdpt",100, 0, 60., 100, 0, 1.0),
16  ("pppz_vs_pppt",100, 0, 60., 100, 0, 1.0),
17 ]
18 hists = hists1D + hists2D
19 
20 class Decay(object):
21  def __init__(self,root_file,det):
22  self.idxdet = self.GetIdxDet(det)
23  self.thistag = "decay_" + det
24  root_file.mkdir(self.thistag)
25  self.thisgroup = self.book_hists()
26  return
27 
28  ##########################################
29 
30  def fill(self, thisentry):
31  wgt = (thisentry.dk2nu.decay.nimpwt)*(thisentry.dk2nu.nuray[self.idxdet].wgt)
32  #1D:
33  self.thisgroup[0].Fill(thisentry.dk2nu.decay.ndecay, wgt)
34  self.thisgroup[1].Fill(thisentry.dk2nu.decay.ntype, wgt)
35  self.thisgroup[2].Fill(thisentry.dk2nu.decay.ptype, wgt)
36  self.thisgroup[3].Fill(thisentry.dk2nu.decay.nimpwt,wgt)
37  self.thisgroup[4].Fill(thisentry.dk2nu.decay.vz,wgt)
38  #2D:
39  self.thisgroup[5].Fill(thisentry.dk2nu.decay.vx,thisentry.dk2nu.decay.vy,wgt)
40  pdpt = sqrt( thisentry.dk2nu.decay.pdpx* thisentry.dk2nu.decay.pdpx +
41  thisentry.dk2nu.decay.pdpy * thisentry.dk2nu.decay.pdpy )
42  self.thisgroup[6].Fill(thisentry.dk2nu.decay.pdpz,pdpt, wgt)
43  pppt = thisentry.dk2nu.decay.pppz * sqrt( thisentry.dk2nu.decay.ppdxdz* thisentry.dk2nu.decay.ppdxdz +
44  thisentry.dk2nu.decay.ppdydz* thisentry.dk2nu.decay.ppdydz )
45  self.thisgroup[7].Fill(thisentry.dk2nu.decay.pppz,pppt, wgt)
46 
47  return
48 
49  ##########################################
50 
51  def save(self,root_file):
52  root_file.cd(self.thistag)
53  for i in self.thisgroup:
54  i.Write()
55  return
56 
57  ##########################################
58 
59  def book_hists(self):
60  hist_group = []
61  for i in hists1D:
62  hist_group.append(TH1F("{}_{}".format(self.thistag, i[0]), ";{};".format(i[0]), i[1], i[2], i[3]))
63  for i in hists2D:
64  hist_group.append(TH2F("{}_{}".format(self.thistag, i[0]), ";{};".format(i[0]), i[1], i[2], i[3], i[4], i[5], i[6]))
65  return hist_group
66 
67  ##########################################
68 
69  def GetIdxDet(self,detname):
70  idx = -1
71  if detname == "random":
72  idx = 0
73  elif detname == "minosnd":
74  idx = 2
75  elif detname == "novand":
76  idx = 3
77  elif detname == "minosfd":
78  idx = 8
79  elif detname == "novafd":
80  idx = 9
81  else:
82  print "Bad input, no detector found!"
83  exit (1)
84  return idx
def __init__(self, root_file, det)
Definition: decay.py:21
T sqrt(T number)
Definition: d0nt_math.hpp:156
def save(self, root_file)
Definition: decay.py:51
Definition: novas.h:112
correl_yv Fill(-(dy[iP-1][iC-1]), hyv->GetBinContent(iP, iC))
def fill(self, thisentry)
Definition: decay.py:30
def GetIdxDet(self, detname)
Definition: decay.py:69
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
def book_hists(self)
Definition: decay.py:59