10def readInput(filename, nCellsList=20, bcfile=None, cutoff=0.1):
11
12
13 from ROOT import IdDictParser
15
16 xmlpath=None
17 for dd
in os.getenv(
'XMLPATH').
split(os.pathsep):
18 d=dd+"/IdDictParser/ATLAS_IDS.xml"
19 if os.access(d,os.R_OK):
20 xmlpath=dd
21 break
22 if not xmlpath:
23 print ("ERROR, unable to locate identifier dictionaries")
24 sys.exit(-1)
25
26
27 parser.register_external_entity("LArCalorimeter",xmlpath+"/IdDictParser/IdDictLArCalorimeter_DC3-05-Comm-01.xml")
28 idd = parser.parse(xmlpath+"/IdDictParser/ATLAS_IDS.xml")
29 from ROOT import LArOnlineID
31 stat=larID.initialize_from_dictionary(idd)
32 if stat==1:
33 print ("ERROR, failed to init LArOnlineID")
34 sys.exit(-1)
35
36
37
38 f=TFile.Open(filename)
39 if not f.IsOpen():
40 print(
"ERROR, failed to open input file",filename)
41 sys.exit(-1)
42
43 rundir=None
44 for d in f.GetListOfKeys():
45 mg=re.match("run_([0-9]*)",d.GetName())
46 rundir=mg.group(0)
47 break
48
49 print(
"Found run dir:",rundir)
50 runnbr=rundir[4:]
51
52 hist=f.Get(rundir+"/CaloMonitoring/CaloClusterCellMon/Summary/larhashPercent")
53
54 freq=[]
55 for idx in range(hist.GetNbinsX()):
56 freq.append((idx,hist.GetBinContent(idx)))
57
58 freq.sort(key=itemgetter(1),reverse=True)
59
60 for f in freq[:nCellsList]:
61 c=larID.channel_Id(f[0])
62 print ("Channel %s constributes to clusters in %.3f %% of events"% (larID.channel_name(c),f[1]))
63
64
65 if bcfile:
66 bcfile.write("#Bad channel list for run "+runnbr+"\n")
67 for (h,f) in freq:
68 if f<cutoff: break
69 c=larID.channel_Id(h)
70 bcfile.write("%i %i %i %i %i 0 highNoiseHG\n"% (larID.barrel_ec(c), larID.pos_neg(c), larID.feedthrough(c),
71 larID.slot(c), larID.channel(c)))
72
73 bcfile.close()
74
75
76
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")