]> Creatis software - clitk.git/blobdiff - tests_dav/clitkMergeRootFiles.cxx
switched to gjm merger for pet
[clitk.git] / tests_dav / clitkMergeRootFiles.cxx
index 86887f0322526f58c9d12ad5561d52cccebc6efb..ac1158087fdb45b8a831d356a23eed7ffc362e49 100644 (file)
 
 #include "clitkMergeRootFiles_ggo.h"
 #include "clitkCommon.h"
+#include "GateMergeManager.hh"
 #include <string> 
 #include <TROOT.h>
 #include <TPluginManager.h>
 #include <TFile.h>
+#include <TKey.h>
 #include <TFileMerger.h>
 #include <TTree.h>
+#include <TChain.h>
+#include <TH1.h>
+#include <TH2.h>
 #include <iostream>
 
 using std::endl;
 using std::cout;
 
+typedef std::list<std::string> Strings;
+
+
 //-----------------------------------------------------------------------------
 int main(int argc, char * argv[]) {
 
@@ -35,21 +43,33 @@ int main(int argc, char * argv[]) {
     FATAL("Error, please provide at least two inputs files");
   }
 
-  // Detect Pet output
-  bool all_pet_output = true;
-  for (uint i=0; i<args_info.input_given; i++) 
-  {
-         const char* filename = args_info.input_arg[i];
-         TFile* handle = TFile::Open(filename,"READ");
-         TTree* hits = dynamic_cast<TTree*>(handle->Get("Hits"));
-         TTree* singles = dynamic_cast<TTree*>(handle->Get("Singles"));
-         const bool is_pet_output = (hits!=NULL) && (singles!=NULL);
-         cout << "testing " << filename << " is_pet_output " << is_pet_output << endl;
-         handle->Close();
-         delete handle;
-         all_pet_output &= is_pet_output;
+  { // Detect Pet output
+         bool all_pet_output = true;
+         Strings input_filenames;
+         for (uint i=0; i<args_info.input_given; i++) 
+         {
+                 const char* filename = args_info.input_arg[i];
+                 input_filenames.push_back(filename);
+                 TFile* handle = TFile::Open(filename,"READ");
+                 assert(handle);
+                 TTree* hits = dynamic_cast<TTree*>(handle->Get("Hits"));
+                 TTree* singles = dynamic_cast<TTree*>(handle->Get("Singles"));
+                 const bool is_pet_output = (hits!=NULL) && (singles!=NULL);
+                 cout << "testing " << filename << " is_pet_output " << is_pet_output << endl;
+                 handle->Close();
+                 delete handle;
+                 all_pet_output &= is_pet_output;
+         }
+         cout << "all_pet_output " << all_pet_output << endl;
+
+         if (all_pet_output)
+         {
+                 GateMergeManager* manager = new GateMergeManager(args_info.fastmerge_given,args_info.verbose_arg,true,0,".");
+                 delete manager;
+                 return 0;
+         }
   }
-  cout << "all_pet_output " << all_pet_output << endl;
+
 
   // Merge
   TFileMerger * merger = new TFileMerger;