8 from ROOT.Belle2
import ARICHDatabaseImporter
10 from optparse
import OptionParser
13 def GetChannelMask(h):
16 xlow = h.GetBinLowEdge(1)
17 xup = h.GetBinLowEdge(nbins + 1)
18 mf = ROOT.TF1(
'mf',
'pol0')
21 hmask = ROOT.TH1S(
"ARICHChannelMask",
"ARICHChannelMask", nbins, xlow, xup)
24 maxHits = int(mf.GetParameter(0) * 20)
26 for bin
in range(nbins + 1):
28 if (h.GetBinContent(bin) > maxHits):
31 if (h.GetBinContent(bin) < minHits):
34 hmask.SetBinContent(bin, value)
35 print(
'<mean>{}</mean>'.format(mf.GetParameter(0)))
36 print(
'<max>{}</max>'.format(h.GetMaximum()))
37 print(
'<rms>{}</rms>'.format(h.GetRMS()))
38 print(
'<maxHits>{}<maxHits>'.format(maxHits))
39 print(
'<minHits>{}</minHits>'.format(minHits))
40 print(
'<nall>{}</nall>'.format(nbins))
41 print(
'<nhot>{}</nhot>'.format(nhot))
42 print(
'<ndead>{}</ndead>'.format(ndead))
47 parser = OptionParser()
48 parser.add_option(
'-f',
'--file', dest=
'filename', default=
'DQMhistograms.root')
49 parser.add_option(
'--hname', dest=
'hname', default=
'ARICHDQM/chHit')
50 parser.add_option(
'-e',
'--firstexp', dest=
'firstexp', default=0, type=
"int", help=
"IntevalOfValidity first experiment")
51 parser.add_option(
'--lastexp', dest=
'lastexp', default=-1, type=
"int", help=
"IntevalOfValidity last experiment")
52 parser.add_option(
'-r',
'--firstrun', dest=
'firstrun', default=0, type=
"int", help=
"IntevalOfValidity first run")
53 parser.add_option(
'--lastrun', dest=
'lastrun', default=-1, type=
"int", help=
"IntevalOfValidity last run")
54 parser.add_option(
'-d',
'--dryrun', dest=
'dryrun', default=0, type=
"int", help=
"do not export to database")
55 (options, args) = parser.parse_args()
58 use_local_database(
"localdb/database.txt",
"localdb", 0, LogLevel.INFO)
61 print(
'<run>{}</run>'.format(options.firstrun))
62 print(
'<exp>{}</exp>'.format(options.firstexp))
63 print(
'<fname>{}</fname>'.format(options.filename))
67 f = ROOT.TFile(options.filename)
68 h = f.Get(options.hname)
72 hmask = GetChannelMask(h)
75 if (options.dryrun == 0):
76 ARICHDatabaseImporter().
importChannelMask(hmask, options.firstexp, options.firstrun, options.lastexp, options.lastrun)