]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
added method to merge files listed in a xml collection
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 16 Mar 2009 14:16:42 +0000 (14:16 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 16 Mar 2009 14:16:42 +0000 (14:16 +0000)
STEER/AliQAManager.cxx
STEER/AliQAManager.h

index 673205e86a11021670bc05d0018875e8a97a375d..4c0bce11e20f860d561a5d5f01c779ce5ad8ee6a 100644 (file)
@@ -31,6 +31,9 @@
 #include <TKey.h>
 #include <TFile.h>
 #include <TFileMerger.h>
+#include <TGrid.h>
+#include <TGridCollection.h>
+#include <TGridResult.h>
 #include <TPluginManager.h>
 #include <TROOT.h>
 #include <TString.h>
@@ -714,7 +717,67 @@ Bool_t AliQAManager::Merge(const Int_t runNumber) const
  return rv ; 
 }
        
-       
+//______________________________________________________________________
+Bool_t AliQAManager::MergeXML(const char * collectionFile, const char * subFile, const char * outFile) 
+{
+  // merges files listed in a xml collection 
+  // usage Merge(collection, outputFile))
+  //              collection: is a xml collection  
+  
+  Bool_t rv = kFALSE ; 
+  
+  if ( strstr(collectionFile, ".xml") == 0 ) {
+    AliError("Input collection file must be an \".xml\" file\n") ; 
+    return kFALSE ; 
+  }
+    
+ if ( !gGrid ) 
+   TGrid::Connect("alien://"); 
+ if ( !gGrid ) 
+   return kFALSE ; 
+  // Open the file collection 
+  printf("*** Create Collection       ***\n");
+  printf("***  Wk-Dir = |%s|             \n",gSystem->WorkingDirectory());
+  printf("***  Coll   = |%s|             \n",collectionFile);                  
+  
+  TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)",collectionFile));
+  TGridResult* result = collection->GetGridResult("", 0, 0);
+  
+  Int_t index = 0  ;
+  const char * turl ;
+  TFileMerger merger ; 
+  if (!outFile) {
+    TString tempo(collectionFile) ; 
+    if ( subFile) 
+      tempo.ReplaceAll(".xml", subFile) ; 
+    else 
+      tempo.ReplaceAll(".xml", "_Merged.root") ; 
+    outFile = tempo.Data() ; 
+  }
+  merger.OutputFile(outFile) ; 
+  
+  while ( (turl = result->GetKey(index, "turl")) ) {
+    char * file ;
+    if ( subFile )
+      file = Form("%s#%s", turl, subFile) ; 
+    else 
+      file = Form("%s", turl) ; 
+    
+    AliInfo(Form("%s\n", file)) ; 
+    merger.AddFile(file) ; 
+    index++ ;  
+  }
+  
+  if (index) 
+    merger.Merge() ; 
+  
+  AliInfo(Form("Files merged into %s\n", outFile)) ;
+  
+  rv = kFALSE;
+  return rv ;
+}
+
 //_____________________________________________________________________________
 Bool_t AliQAManager::MergeData(const Int_t runNumber) const
 {
index c7622895667e03ef541d7c98ca70e8875b35ba0b..8921521379b8c1e698a358f288d45bc822a53319 100644 (file)
@@ -51,6 +51,7 @@ public:
        void        Increment() ;
        void        InitQADataMaker(UInt_t run, TObjArray * detArray=0x0) ;
        Bool_t      Merge(const Int_t runNumber = -1 ) const ;  
+  Bool_t      MergeXML(const char * collection, const char * subFile = 0, const char * outFile = 0) ; 
   static      AliQAManager * QAManager(const Char_t * mode="", TMap *entryCache = NULL, Int_t run = -1) ;
        void        Reset(const Bool_t sameCycle = kFALSE) ;  
        TString     Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex=AliQA::kNULLTASKINDEX, Bool_t const sameCycle = kFALSE, const char * fileName = NULL) ;