16 from ROOT.Belle2
import ARICHDatabaseImporter
18 from optparse
import OptionParser
21 def GetChannelMask(h):
24 xlow = h.GetBinLowEdge(1)
25 xup = h.GetBinLowEdge(nbins + 1)
26 mf = ROOT.TF1(
'mf',
'pol0')
29 hmask = ROOT.TH1S(
"ARICHChannelMask",
"ARICHChannelMask", nbins, xlow, xup)
32 maxHits = int(mf.GetParameter(0) * 20)
34 for bin
in range(nbins + 1):
36 if (h.GetBinContent(bin) > maxHits):
39 if (h.GetBinContent(bin) < minHits):
42 hmask.SetBinContent(bin, value)
43 print(
'<mean>{}</mean>'.format(mf.GetParameter(0)))
44 print(
'<max>{}</max>'.format(h.GetMaximum()))
45 print(
'<rms>{}</rms>'.format(h.GetRMS()))
46 print(
'<maxHits>{}<maxHits>'.format(maxHits))
47 print(
'<minHits>{}</minHits>'.format(minHits))
48 print(
'<nall>{}</nall>'.format(nbins))
49 print(
'<nhot>{}</nhot>'.format(nhot))
50 print(
'<ndead>{}</ndead>'.format(ndead))
55 parser = OptionParser()
56 parser.add_option(
'-f',
'--file', dest=
'filename', default=
'DQMhistograms.root')
57 parser.add_option(
'--hname', dest=
'hname', default=
'ARICHDQM/chHit')
58 parser.add_option(
'-e',
'--firstexp', dest=
'firstexp', default=0, type=
"int", help=
"IntevalOfValidity first experiment")
59 parser.add_option(
'--lastexp', dest=
'lastexp', default=-1, type=
"int", help=
"IntevalOfValidity last experiment")
60 parser.add_option(
'-r',
'--firstrun', dest=
'firstrun', default=0, type=
"int", help=
"IntevalOfValidity first run")
61 parser.add_option(
'--lastrun', dest=
'lastrun', default=-1, type=
"int", help=
"IntevalOfValidity last run")
62 parser.add_option(
'-d',
'--dryrun', dest=
'dryrun', default=0, type=
"int", help=
"do not export to database")
63 (options, args) = parser.parse_args()
66 b2.use_local_database(
"localdb/database.txt",
"localdb", 0, b2.LogLevel.INFO)
69 print(
'<run>{}</run>'.format(options.firstrun))
70 print(
'<exp>{}</exp>'.format(options.firstexp))
71 print(
'<fname>{}</fname>'.format(options.filename))
75 f = ROOT.TFile(options.filename)
76 h = f.Get(options.hname)
80 hmask = GetChannelMask(h)
83 if (options.dryrun == 0):
84 ARICHDatabaseImporter().
importChannelMask(hmask, options.firstexp, options.firstrun, options.lastexp, options.lastrun)