]> Creatis software - clitk.git/blob - tests_dav/GateMergeManager.hh
switched to gjm merger for pet
[clitk.git] / tests_dav / GateMergeManager.hh
1 /*----------------------
2    GATE version name: gate_v...
3
4    Copyright (C): OpenGATE Collaboration
5
6 This software is distributed under the terms
7 of the GNU Lesser General  Public Licence (LGPL)
8 See GATE/LICENSE.txt for further details
9 ----------------------*/
10
11
12 #ifndef GateMergeManager_h
13 #define GateMergeManager_h 1
14 #include <iostream>
15 #include <string>
16 #include <vector>
17 #include <TFile.h>
18 #include <TChain.h>
19 #include <cstdlib>
20
21 using namespace std;
22
23 class GateMergeManager
24 {
25 public:
26
27   GateMergeManager(bool fastMerge,int verboseLevel,bool forced,Long64_t maxRoot,string outDir){
28      m_verboseLevel = verboseLevel;
29      m_forced       =       forced;
30      m_maxRoot      =      maxRoot;
31      m_outDir       =       outDir;
32      m_CompLevel    =            1;
33      m_fastMerge    =    fastMerge;
34   };
35   ~GateMergeManager()
36   {
37           for (std::vector<TFile*>::const_iterator iter=filearr.begin(); iter!=filearr.end(); iter++)
38           {
39                   (*iter)->Close();
40                   delete *iter;
41           }
42   }
43
44
45   void StartMerging(string splitfileName);
46   void ReadSplitFile(string splitfileName);
47   bool MergeTree(string name);
48   bool MergeGate(TChain* chain);
49   bool MergeSing(TChain* chain);
50   bool MergeCoin(TChain* chain);
51
52   // the cleanup after succesful merging
53   void StartCleaning(string splitfileName,bool test);
54
55   // the merging methods
56   void MergeRoot();
57
58 private:
59   void FastMergeRoot(); 
60   bool FastMergeGate(string name);
61   bool FastMergeSing(string name);
62   bool FastMergeCoin(string name); 
63   bool           m_forced;             // if to overwrite existing files
64   int      m_verboseLevel;  
65   std::vector<TFile*>         filearr;
66   Long64_t      m_maxRoot;             // maximum size of root output file
67   int         m_CompLevel;             // compression level for root output
68   string         m_outDir;             // where to save the output files
69   int            m_Nfiles;             // number of files to mergw
70   vector<int> m_lastEvents;            // latestevent from al files
71   vector<string> m_vRootFileNames;     // names of root files to merge
72   TFile*         m_RootTarget;         // root output file
73   string         m_RootTargetName;     // name of target i.e. root output file
74   bool           m_fastMerge;          // fast merge option, corrects the eventIDs locally
75 };
76
77
78 #endif