From 2ff46ad5e87272cb395095299c827d47375637b4 Mon Sep 17 00:00:00 2001
From: Adrien Matta <matta@lpccaen.in2p3.fr>
Date: Mon, 10 May 2021 17:55:20 +0200
Subject: [PATCH] * Detector not supporting splitting are now gathered in the
 _global tree   when splitting is requested by the user

---
 NPLib/Core/RootOutput.cxx | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/NPLib/Core/RootOutput.cxx b/NPLib/Core/RootOutput.cxx
index 023353dd8..d5fab575b 100644
--- a/NPLib/Core/RootOutput.cxx
+++ b/NPLib/Core/RootOutput.cxx
@@ -58,7 +58,8 @@ RootOutput::RootOutput(std::string fileNameBase, std::string treeNameBase,bool s
   cout << "Initializing ouput trees and files ";
   if(pSplit)
     cout << "in split mode (one tree per detector)" << endl;
-  
+  else
+    cout << endl;
   pTreeName=treeNameBase;
   pCurrentDirectory= gDirectory;
   bool analysis=false;
@@ -150,15 +151,15 @@ RootOutput::RootOutput(std::string fileNameBase, std::string treeNameBase,bool s
 void RootOutput::CreateTreeAndFile(std::string name){
   // Create the tree only if does not exist already
   string file_name=pBaseName;
-  if(name!="global"){
-   string  strip= pBaseName.substr(pBaseName.rfind("/"));
-   strip = strip.substr(0,strip.rfind(".root"));
-   string  insertion= "_"+name;
-   file_name.insert(file_name.rfind(".root"),insertion);
-   file_name.insert(file_name.rfind("/"),strip);
-  }
 
   if(pRootFiles.find(name)==pRootFiles.end()){
+    if(pSplit){
+      string  strip= pBaseName.substr(pBaseName.rfind("/"));
+      strip = strip.substr(0,strip.rfind(".root"));
+      string  insertion= "_"+name;
+      file_name.insert(file_name.rfind(".root"),insertion);
+      file_name.insert(file_name.rfind("/"),strip);
+    }
     cout << " - Creating output file " << file_name.c_str() << endl;
     pRootFiles[name] = new TFile(file_name.c_str(), "RECREATE");
     pRootTrees[name] = new TTree(pTreeName.c_str(), "Data created / analysed with the nptool package");
-- 
GitLab