3 from __future__
import print_function
8 wheelStr =
'W' +
str(wheel)
9 stationStr =
'St' +
str(station)
10 sectorStr =
'Sec' +
str(sector)
11 name =
"hRPhiVDriftCorr_" + wheelStr +
"_" + stationStr +
"_" + sectorStr
17 histWheelSector =
None
18 for station
in range(1,5):
19 if sector
in (13,14)
and station != 4:
continue
23 print(
"Adding",hist.GetName())
24 if not histWheelSector: histWheelSector = hist.Clone(
"h_W%d_Sec%d" % (wheel,sector) )
25 else: histWheelSector.Add(hist)
27 return histWheelSector
32 if station == 4: sectors.extend([13,14])
33 histWheelStation =
None
34 for sector
in sectors:
38 print(
"Adding",hist.GetName())
39 if not histWheelStation: histWheelStation = hist.Clone(
"h_W%d_St%d" % (wheel,station) )
40 else: histWheelStation.Add(hist)
42 return histWheelStation
44 if __name__ ==
'__main__':
46 parser = optparse.OptionParser (
"Usage: %prog [--options]")
48 parser.add_option(
"-f",
"--file", dest=
"file", help=
"Input file name")
49 parser.add_option(
"-o",
"--out", dest=
"out", default=
"merged.root", help=
"Output file name")
50 (options, args) = parser.parse_args()
53 parser.error(
'must set an input file')
55 file = ROOT.TFile(options.file,
"READ")
63 for station
in stations:
64 print(
"Merging histos from Wheel %d, Station %d" % (wheel,station))
69 outputFile = ROOT.TFile(options.out,
"RECREATE")
72 wheelStr =
'W' +
str(wheel)
73 for station
in stations:
74 stationStr =
'St' +
str(station)
75 for sector
in sectors:
76 if sector
in (13,14)
and station != 4:
continue
77 sectorStr =
'Sec' +
str(sector)
78 name =
"hRPhiVDriftCorr_" + wheelStr +
"_" + stationStr +
"_" + sectorStr
80 histos[(wheel,station)].Clone(name).Write()