getBrightness.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import ROOT
3 import argparse
4 
5 
6 if __name__=='__main__':
7 
8  parser = argparse.ArgumentParser(description='Process fiber brightness files')
9  parser.add_argument('-fd', '--far-detector', action='store_true')
10  parser.add_argument('-nd', '--near-detector', action='store_true')
11  parser.add_argument('-p', '--plane-number', type=int, required=True)
12  parser.add_argument('-c', '--cell-number', type=int, required=True)
13  args = parser.parse_args()
14 
15  if args.far_detector and args.near_detector:
16  print "Can only set --fd or --nd!"
17  exit(1)
18 
19  if not args.far_detector and not args.near_detector:
20  print "Must set either --fd or --nd!"
21  exit(1)
22 
23  if args.far_detector:
24  fInName = "fdBrightness.root"
25  if args.near_detector:
26  fInName = "ndBrightness.root"
27 
28  plane = args.plane_number
29  cell = args.cell_number
30  infile = ROOT.TFile(fInName, "READ")
31 
32  bmap = infile.Get("BrightnessByBin")
33  bvalue = infile.Get("BrightnessValue")
34 
35  ibin = bmap.GetBinContent(plane+1, cell+1)
36 
37  br = bvalue.GetBinContent(int(ibin))
38 
39  print "Brightness level for plane {}, cell {} is {} in bin {}".format(plane, cell, br, ibin)
40 
41  for i in range(bvalue.GetNbinsX()+2):
42  print "Brightness Bin: {} value {}".format(i, bvalue.GetBinContent(i))
43 
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
exit(0)