Skip to content

Commit

Permalink
Add possibility to parse multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
fgrosa committed May 6, 2021
1 parent 624c0bf commit ebeff72
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions femto/ProjectMassFromFemtoTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
help='suffix for directory inside task output file')
parser.add_argument('--HFsuffix', metavar='text', default='',
help='HF suffix for directory inside task output file')
parser.add_argument('--inFileNameAdd', action='append', default=None,
help='additional root input file name')
args = parser.parse_args()

with open(args.cutSetFileName, 'r') as ymlCutSetFile:
Expand All @@ -30,15 +32,28 @@

dirName = f'{args.prefix}_CharmFemto_{args.HFsuffix}DChargedQA{args.suffix}'
listName = f'{dirName}/{args.prefix}_CharmFemto_{args.HFsuffix}DChargedQA{args.suffix}'
print(f'Read input file: {args.inFileName}')

inFileNames = [args.inFileName]
if args.inFileNameAdd is not None:
for fileName in args.inFileNameAdd:
inFileNames.append(fileName)

hDminusMassVsPt, hDplusMassVsPt = None, None
for iFile, fileName in enumerate(inFileNames):
inFile = TFile.Open(fileName)
inList = inFile.Get(listName)
if iFile == 0:
hDminusMassVsPt = inList.FindObject('fHistDminusInvMassPt')
hDplusMassVsPt = inList.FindObject('fHistDplusInvMassPt')
else:
hDminusMassVsPt.Add(inList.FindObject('fHistDminusInvMassPt'))
hDplusMassVsPt.Add(inList.FindObject('fHistDplusInvMassPt'))
print(f'Read input file: {fileName}')
print(f' dir: {dirName}')
print(f' list: {listName}')

inFile = TFile.Open(args.inFileName)
inList = inFile.Get(listName)
hDminusMassVsPt = inList.FindObject('fHistDminusInvMassPt')
hDplusMassVsPt = inList.FindObject('fHistDplusInvMassPt')
hMassVsPt = hDminusMassVsPt.Clone()
if hDminusMassVsPt.GetYaxis().GetXmin() == hDplusMassVsPt.GetXaxis().GetXmin():
hMassVsPt = hDminusMassVsPt.Clone('hMassVsPt')
if hDminusMassVsPt.GetXaxis().GetXmin() == hDplusMassVsPt.GetXaxis().GetXmin():
hMassVsPt.Add(hDplusMassVsPt)
else:
print('WARNING: using only D- because of different binning between D+ and D- histograms!')
Expand Down

0 comments on commit ebeff72

Please sign in to comment.