7 wheelStr =
'W' +
str(wheel)
8 stationStr =
'St' +
str(station)
9 sectorStr =
'Sec' +
str(sector)
10 name =
"hRPhiVDriftCorr_" + wheelStr +
"_" + stationStr +
"_" + sectorStr
16 histWheelSector =
None 17 for station
in range(1,5):
18 if sector
in (13,14)
and station != 4:
continue 22 print "Adding",hist.GetName()
23 if not histWheelSector: histWheelSector = hist.Clone(
"h_W%d_Sec%d" % (wheel,sector) )
24 else: histWheelSector.Add(hist)
26 return histWheelSector
31 if station == 4: sectors.extend([13,14])
32 histWheelStation =
None 33 for sector
in sectors:
37 print "Adding",hist.GetName()
38 if not histWheelStation: histWheelStation = hist.Clone(
"h_W%d_St%d" % (wheel,station) )
39 else: histWheelStation.Add(hist)
41 return histWheelStation
43 if __name__ ==
'__main__':
45 parser = optparse.OptionParser (
"Usage: %prog [--options]")
47 parser.add_option(
"-f",
"--file", dest=
"file", help=
"Input file name")
48 parser.add_option(
"-o",
"--out", dest=
"out", default=
"merged.root", help=
"Output file name")
49 (options, args) = parser.parse_args()
52 parser.error(
'must set an input file')
54 file = ROOT.TFile(options.file,
"READ")
62 for station
in stations:
63 print "Merging histos from Wheel %d, Station %d" % (wheel,station)
68 outputFile = ROOT.TFile(options.out,
"RECREATE")
71 wheelStr =
'W' +
str(wheel)
72 for station
in stations:
73 stationStr =
'St' +
str(station)
74 for sector
in sectors:
75 if sector
in (13,14)
and station != 4:
continue 76 sectorStr =
'Sec' +
str(sector)
77 name =
"hRPhiVDriftCorr_" + wheelStr +
"_" + stationStr +
"_" + sectorStr
79 histos[(wheel,station)].Clone(name).Write()
def mergeHistosWheelStation(file, wheel, station)
def getHistoName(wheel, station, sector)
def mergeHistosWheelSector(file, wheel, sector)