From eb5b020928e9462111067765087ea7e350856f66 Mon Sep 17 00:00:00 2001
From: Nicola Orlando <orlando@lxplus086.cern.ch>
Date: Sun, 11 Dec 2016 17:41:22 +0100
Subject: [PATCH 1/2] Simple, perhaps tmp fix for #39

---
 python/merge_regions.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/python/merge_regions.py b/python/merge_regions.py
index dd1d7aa..d597bfb 100755
--- a/python/merge_regions.py
+++ b/python/merge_regions.py
@@ -85,6 +85,21 @@ def main():
             master_histo.SetDirectory(output_file)
             for h in other_histos:
                 master_histo.Add(h)
+            splitted_name=master_histo.GetName().split("_")
+            new_name=target_region
+            new_name_fragments=''
+            counter=0
+            for name_fragment in splitted_name[1:]:
+                if name_fragment== 'e' or name_fragment== 'mu' :
+                    continue
+                if counter == 0 :
+                    new_name_fragments+=name_fragment
+                else : 
+                    new_name_fragments+='_'+name_fragment
+                counter=counter+1
+            #Redefinition of the histos name
+            new_name=new_name+'_'+new_name_fragments
+            master_histo.SetName(new_name)
             master_histo.Write()
             counter_regions_read += len(input_regions)
             counter_regions_write += 1
-- 
GitLab


From 2a03dc514e6a5e63aec965400a071d5fcb219f85 Mon Sep 17 00:00:00 2001
From: Davide Gerbaudo <davide.gerbaudo@gmail.com>
Date: Mon, 12 Dec 2016 16:23:10 +0100
Subject: [PATCH 2/2] set name of output histo

Details:
same result as in the solution proposed by @orlando, but shorter.
---
 python/merge_regions.py | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/python/merge_regions.py b/python/merge_regions.py
index d597bfb..42035c0 100755
--- a/python/merge_regions.py
+++ b/python/merge_regions.py
@@ -82,24 +82,10 @@ def main():
         for hn in histonames:
             master_histo = input_file.Get(hn)
             other_histos = [input_file.Get(hn.replace(master_region, r)) for r in other_regions]
+            master_histo.SetName(master_histo.GetName().replace(master_region, target_region))
             master_histo.SetDirectory(output_file)
             for h in other_histos:
                 master_histo.Add(h)
-            splitted_name=master_histo.GetName().split("_")
-            new_name=target_region
-            new_name_fragments=''
-            counter=0
-            for name_fragment in splitted_name[1:]:
-                if name_fragment== 'e' or name_fragment== 'mu' :
-                    continue
-                if counter == 0 :
-                    new_name_fragments+=name_fragment
-                else : 
-                    new_name_fragments+='_'+name_fragment
-                counter=counter+1
-            #Redefinition of the histos name
-            new_name=new_name+'_'+new_name_fragments
-            master_histo.SetName(new_name)
             master_histo.Write()
             counter_regions_read += len(input_regions)
             counter_regions_write += 1
-- 
GitLab