Makefile for merging ROOT files with “hadd”
-
24-06-2021 - |
質問
I am currently writing a Makefile that has several nearly identical rules/recipes to merge .root
files using hadd
. Is there a good way to condense these into fewer rules? I'm not sure how useful %
can be for the cases data[4-6].done
since the numbers 4-6 do not match the 1-4 in the directory path.
Many Thanks
[Makefile]
DIR=/hdfs/store/user/$(USER)
DATA.root : data1.done data2.done data3.done data4.done data5.done data6.done
hadd DATA.root $(addsuffix .root,$(basename $^))
rm $(addsuffix .root,$(basename $^))
rm $^
data1.done :
hadd data1.root $(DIR)/de2012A_loose2Aug-DATA/1/*.root
touch data1.done
data2.done :
hadd data2.root $(DIR)/de2012A_loose2Aug-DATA/2/*.root
touch data2.done
data3.done :
hadd data3.root $(DIR)/de2012B_loose2Aug-DATA/1/*.root
touch data3.done
data4.done :
hadd data4.root $(DIR)/de2012B_loose2Aug-DATA/2/*.root
touch data4.done
data5.done :
hadd data5.root $(DIR)/de2012B_loose2Aug-DATA/3/*.root
touch data5.done
data6.done :
hadd data6.root $(DIR)/de2012B_loose2Aug-DATA/4/*.root
touch data6.done
解決
I'll take a crack at it, but you might reconsider your design.
DIR=/hdfs/store/user/$(USER)
DATA.root : data[1-6].done
hadd DATA.root $(^:.done=.root)
rm $(^:.done=.root)
rm $^
data1.done data2.done : PATHLEFT=A
data3.done data4.done data5.done data6.done : PATHLEFT=B
data1.done : PATHRIGHT=1
data2.done : PATHRIGHT=2
data3.done : PATHRIGHT=1
data4.done : PATHRIGHT=2
data5.done : PATHRIGHT=3
data6.done : PATHRIGHT=4
data%.done :
hadd data1.root $(DIR)/de2012$(PATHLEFT)_loose2Aug-DATA/$(PATHRIGHT)/*.root
touch $@
(Yes, I know, I could squeeze two or three more lines out, but I don't want to make it too cryptic.)
所属していません StackOverflow