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