]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
added function from Christian to enable branches with new ESD format
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Jan 2008 16:23:56 +0000 (16:23 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Jan 2008 16:23:56 +0000 (16:23 +0000)
PWG0/AliPWG0Helper.cxx
PWG0/AliPWG0Helper.h
PWG0/esdTrackCuts/AliCutTask.cxx

index 99c24a633ca554cd2cb247e7b1105b4d9961740e..51432eabc78c59c7aa4fcb0a1e402dce15b2aedd 100644 (file)
@@ -7,6 +7,9 @@
 #include <TH1.h>
 #include <TH3.h>
 #include <TList.h>
+#include <TTree.h>
+#include <TBranch.h>
+#include <TLeaf.h>
 
 #include <AliHeader.h>
 #include <AliStack.h>
@@ -354,3 +357,42 @@ Int_t AliPWG0Helper::FindPrimaryMotherLabel(AliStack* stack, Int_t label)
 
   return label;
 }
+
+void AliPWG0Helper::SetBranchStatusRecursive(TTree* tree, char *bname, Bool_t status, Bool_t debug)
+{
+  // Function  to switch on/off all data members of a top level branch
+  // this is needed for branches without a trailing dot ".", for those
+  // the root functionality with regular expressions does not work.
+  // Usage e.g.
+  // chain->SetBranchStatus("*", 0); 
+  // SetBranchStatusRecursive(chain,"SPDVertex",1);
+  // You need to give the full name of the top level branch zou want to access
+  //==========================================================================
+  // Author Christian.Klein-Boesing@cern.ch
+
+  if (!tree)
+    return;
+
+  TBranch *br = tree->GetBranch(bname);
+  if(!br) {
+    Printf("AliPWG0Helper::SetBranchStatusRecursive: Branch %s not found", bname);
+  }
+
+  TObjArray *leaves = tree->GetListOfLeaves();
+  Int_t nleaves = leaves->GetEntries();
+  TLeaf *leaf = 0;
+  TBranch *branch = 0;
+  TBranch *mother = 0;
+  for (Int_t i=0;i<nleaves;i++)  {
+    // the matched entry e.g. SPDVertex is its own Mother
+    leaf = (TLeaf*)leaves->UncheckedAt(i);
+    branch = (TBranch*)leaf->GetBranch();
+    mother = branch->GetMother();
+    if (mother==br){
+      if (debug)
+        Printf(">>>> AliPWG0Helper::SetBranchStatusRecursive: Setting status %s %s to %d", mother->GetName(), leaf->GetName(), status);
+      if (status) branch->ResetBit(kDoNotProcess);
+      else        branch->SetBit(kDoNotProcess);
+    }
+  }
+}
index 1e008fab2579d12950a3b5928a3cd161ed634ba2..04fb01db8aa7aaa267c1f7fd1926eaa1a5239eff 100644 (file)
@@ -13,6 +13,7 @@ class TParticle;
 class TH3;
 class AliHeader;
 class AliStack;
+class TTree;
 
 class AliPWG0Helper : public TObject
 {
@@ -33,6 +34,8 @@ class AliPWG0Helper : public TObject
     static void CreateDividedProjections(TH3* hist, TH3* hist2, const char* axis = 0, Bool_t putErrors = kFALSE, Bool_t save = kFALSE);
     static const char* GetAxisTitle(TH3* hist, const char axis);
 
+    static void SetBranchStatusRecursive(TTree* tree, char *bname, Bool_t status, Bool_t debug = kFALSE);
+
   protected:
     ClassDef(AliPWG0Helper, 0)
 
index bbf4ca2cbefcb9e69c8c7a83cd6fa9145a7966e7..f64b40d1d7622a269ae63a10846186676976ebcb 100644 (file)
@@ -50,21 +50,18 @@ void AliCutTask::ConnectInputData(Option_t *)
     Printf("ERROR: Could not read chain from input slot 0");
   } else {
     // Disable all branches and enable only the needed ones
-    //tree->SetBranchStatus("*", kFALSE);
-    //tree->SetBranchStatus("*Calo*", kFALSE);
-
-    tree->SetBranchStatus("fTracks.*", kTRUE);
-    tree->SetBranchStatus("Tracks.*", kTRUE);
+    tree->SetBranchStatus("*", kFALSE);
 
+    // old esd
     tree->SetBranchStatus("fTriggerMask", kTRUE);
-    tree->SetBranchStatus("AliESDHeader", kTRUE);
-
+    tree->SetBranchStatus("fTracks.*", kTRUE);
     tree->SetBranchStatus("fSPDVertex*", kTRUE);
 
-    // unclear how to enable vertex branch with new ESD format
-    tree->SetBranchStatus("SPDVertex.*", kTRUE);
-    tree->SetBranchStatus("*fPosition*", kTRUE);
-    tree->SetBranchStatus("*fPosition[3]", kTRUE);
+    // new esd
+    tree->SetBranchStatus("TriggerMask", kTRUE);
+    tree->SetBranchStatus("AliESDHeader", kTRUE);
+    AliPWG0Helper::SetBranchStatusRecursive(tree, "Tracks", kTRUE);
+    AliPWG0Helper::SetBranchStatusRecursive(tree, "SPDVertex", kTRUE);
 
     AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
 
@@ -266,9 +263,7 @@ void AliCutTask::Terminate(Option_t *)
   
   Printf("Writting results to trackCuts.root.");
   
-  return;
-
-       fTrackCuts->DrawHistograms();
+  fTrackCuts->DrawHistograms();
 
   new TCanvas;
   fVertex->Draw();