]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliFileMerger.cxx
TRD nSigma OADB related new codes and modifications and OADB root file -- Xianguo Lu
[u/mrichter/AliRoot.git] / ANALYSIS / AliFileMerger.cxx
index 720a628223f31d30915d4050cf16f066fa5eb6cc..3c07be87cc871000dbf22d81a8b640bff1eab23f 100644 (file)
@@ -352,6 +352,20 @@ Bool_t AliFileMerger::IsAccepted(TString name){
   return accept;
 }
 
+Bool_t AliFileMerger::IsRejected(TString name){
+  //
+  // check is the name is explicitly in the rejection list
+  //  if fRejectMask speciefied  - entry with name speciief in the list are rejected 
+  //
+  Bool_t reject=kFALSE;
+  if (fRejectMask){
+    //
+    for (Int_t ireject=0; ireject<fRejectMask->GetEntries(); ireject++){
+      if (name.Contains(fRejectMask->At(ireject)->GetName())) {reject=kTRUE; break;}   // entry was rejected
+    }
+  }
+  return reject;
+}
 
 
 
@@ -373,7 +387,7 @@ void AliFileMerger::AddAccept(const char *accept){
 }
 
 //___________________________________________________________________________
-int AliFileMerger::MergeRootfile( TDirectory *target, TList *sourcelist)
+int AliFileMerger::MergeRootfile( TDirectory *target, TList *sourcelist, Bool_t nameFiltering)
 {
   // Merge all objects in a directory
   // modified version of root's hadd.cxx
@@ -418,7 +432,7 @@ int AliFileMerger::MergeRootfile( TDirectory *target, TList *sourcelist)
       //
       // check if we don't reject this name
       TString nameK(key->GetName());
-      if (!IsAccepted(nameK)) {
+      if ((!IsAccepted(nameK) && nameFiltering) || (!nameFiltering && IsRejected(nameK))) {
        if (!counterF) printf("Object %s is in rejection list, skipping...\n",nameK.Data());
        continue;
       }
@@ -433,12 +447,16 @@ int AliFileMerger::MergeRootfile( TDirectory *target, TList *sourcelist)
             << key->GetName() << " title: " << key->GetTitle() << endl;
        continue;
       }
+      printf("Merging object %s, anchor directory: %s\n",key->GetName(),key->GetMotherDir()->GetPath());
       allNames.Add(new TObjString(key->GetName()));
       AliSysInfo::AddStamp(nameK.Data(),1,++counterK,counterF++); 
       // read object from first source file
       //current_sourcedir->cd();
 
+      TDirectory* currDir = gDirectory;
+      key->GetMotherDir()->cd();
       TObject *obj = key->ReadObj();
+      currDir->cd();
       if (!obj) {
        AliError(Form("Failed to get the object with key %s from %s",key->GetName(),current_sourcedir->GetFile()->GetName()));
        continue;
@@ -489,7 +507,7 @@ int AliFileMerger::MergeRootfile( TDirectory *target, TList *sourcelist)
        // newdir is now the starting point of another round of merging
        // newdir still knows its depth within the target file via
        // GetPath(), so we can still figure out where we are in the recursion
-       status = MergeRootfile( newdir, sourcelist);
+       status = MergeRootfile( newdir, sourcelist, kFALSE);
        if (status) return status;
        
       } else if ( obj->InheritsFrom(TObject::Class())