#include <TH1.h>
#include <TH3.h>
#include <TList.h>
+#include <TTree.h>
+#include <TBranch.h>
+#include <TLeaf.h>
#include <AliHeader.h>
#include <AliStack.h>
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);
+ }
+ }
+}
class TH3;
class AliHeader;
class AliStack;
+class TTree;
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)
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());
Printf("Writting results to trackCuts.root.");
- return;
-
- fTrackCuts->DrawHistograms();
+ fTrackCuts->DrawHistograms();
new TCanvas;
fVertex->Draw();