From 9cd015f7ddfa9e5583b7f4bca7ae5f5ea5c4bcee Mon Sep 17 00:00:00 2001 From: jgrosseo Date: Fri, 11 Jan 2008 16:23:56 +0000 Subject: [PATCH] added function from Christian to enable branches with new ESD format --- PWG0/AliPWG0Helper.cxx | 42 ++++++++++++++++++++++++++++++++ PWG0/AliPWG0Helper.h | 3 +++ PWG0/esdTrackCuts/AliCutTask.cxx | 23 +++++++---------- 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/PWG0/AliPWG0Helper.cxx b/PWG0/AliPWG0Helper.cxx index 99c24a633ca..51432eabc78 100644 --- a/PWG0/AliPWG0Helper.cxx +++ b/PWG0/AliPWG0Helper.cxx @@ -7,6 +7,9 @@ #include #include #include +#include +#include +#include #include #include @@ -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;iUncheckedAt(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); + } + } +} diff --git a/PWG0/AliPWG0Helper.h b/PWG0/AliPWG0Helper.h index 1e008fab257..04fb01db8aa 100644 --- a/PWG0/AliPWG0Helper.h +++ b/PWG0/AliPWG0Helper.h @@ -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) diff --git a/PWG0/esdTrackCuts/AliCutTask.cxx b/PWG0/esdTrackCuts/AliCutTask.cxx index bbf4ca2cbef..f64b40d1d76 100644 --- a/PWG0/esdTrackCuts/AliCutTask.cxx +++ b/PWG0/esdTrackCuts/AliCutTask.cxx @@ -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 (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(); -- 2.43.0