ROOT logo
void readTTree()
{

    // example macro to read data from a ttree and perform a flow analysis using the flow pacakge
    // author: Redmer Alexander Bertens (rbertens@cern.ch)
    // note: this macro can run in ROOT only provided libPWGflowBase.so is available

    // compile the relevant classes
    // include paths, necessary for compilation
    gSystem->AddIncludePath("-Wno-deprecated");
    gSystem->AddIncludePath("-I$ALICE_ROOT -I$ALICE_ROOT/include");
 
    // load libraries
    gSystem->Load("libCore.so");        
    gSystem->Load("libGeom.so");
    gSystem->Load("libVMC.so");
    gSystem->Load("libPhysics.so");
    gSystem->Load("libTree.so");
    gSystem->Load("libPWGflowBase.so");

    // comile the encapsulated classes
    gROOT->LoadMacro("../objects/AliFlowTTreeEvent.cxx+");
    gROOT->LoadMacro("../objects/AliFlowTTreeTrack.cxx+");
    gROOT->LoadMacro("../objects/AliFlowEventSimpleFromTTree.cxx+");
    
    TChain* myChain = new TChain("tree");
    myChain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/filtered/000167988.root");
    myChain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/filtered/000168066.root");

    // create pointers for the branches
    AliFlowTTreeEvent* event = 0x0;
    myChain->SetBranchAddress("event", &event);
    TClonesArray* tracks = 0x0;
    myChain->SetBranchAddress("track", &tracks);
    // and an example track
    AliFlowTTreeTrack* firstTrack = 0x0;

    // connection to the flow package
    AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
    qc->Init();
    AliFlowTrackSimpleCuts* cutsPOI = new AliFlowTrackSimpleCuts();
    cutsPOI->SetPtMin(0.2);
    cutsPOI->SetPtMin(2.);
    AliFlowTrackSimpleCuts* cutsRP = new AliFlowTrackSimpleCuts();

    // set how many events you want to analyze
    Int_t maxEvents = 10000;
    // event loop
    printf(" > %i events in chain, processing %i of them < \n", myChain->GetEntries(), maxEvents);
    for(Int_t i = 0; i < myChain->GetEntries(); i++) {
        cout << " > Parsing event " << i << "\r"; cout.flush();
        myChain->GetEntry(i);
        // pass info to flow package
        AliFlowEventSimple* flowevent = new AliFlowEventSimpleFromTTree(event, tracks, cutsPOI, cutsRP);
        qc->Make(flowevent);
        delete flowevent;
        maxEvents--;
        if(maxEvents < 1) break;
    }

    // wrap up analysis
    qc->Finish();

    // open a new file which will hold the final results of all methods:
    TString outputFileName = "qc_results.root";
    TFile *outputFile = new TFile(outputFileName.Data(),"RECREATE");
    const Int_t nMethods = 1;
    TString method[nMethods] = {"QC"};
    TDirectoryFile *dirFileFinal[nMethods] = {NULL};
    TString fileName[nMethods];
    for(Int_t i=0; i<nMethods; i++)
    {
        // form a file name for each method:
        fileName[i]+="output";
        fileName[i]+=method[i].Data();
        fileName[i]+="analysis";
        dirFileFinal[i] = new TDirectoryFile(fileName[i].Data(),fileName[i].Data());
    }

    // store the final results
    qc->WriteHistograms(dirFileFinal[0]);
    outputFile->Close();
}

 readTTree.C:1
 readTTree.C:2
 readTTree.C:3
 readTTree.C:4
 readTTree.C:5
 readTTree.C:6
 readTTree.C:7
 readTTree.C:8
 readTTree.C:9
 readTTree.C:10
 readTTree.C:11
 readTTree.C:12
 readTTree.C:13
 readTTree.C:14
 readTTree.C:15
 readTTree.C:16
 readTTree.C:17
 readTTree.C:18
 readTTree.C:19
 readTTree.C:20
 readTTree.C:21
 readTTree.C:22
 readTTree.C:23
 readTTree.C:24
 readTTree.C:25
 readTTree.C:26
 readTTree.C:27
 readTTree.C:28
 readTTree.C:29
 readTTree.C:30
 readTTree.C:31
 readTTree.C:32
 readTTree.C:33
 readTTree.C:34
 readTTree.C:35
 readTTree.C:36
 readTTree.C:37
 readTTree.C:38
 readTTree.C:39
 readTTree.C:40
 readTTree.C:41
 readTTree.C:42
 readTTree.C:43
 readTTree.C:44
 readTTree.C:45
 readTTree.C:46
 readTTree.C:47
 readTTree.C:48
 readTTree.C:49
 readTTree.C:50
 readTTree.C:51
 readTTree.C:52
 readTTree.C:53
 readTTree.C:54
 readTTree.C:55
 readTTree.C:56
 readTTree.C:57
 readTTree.C:58
 readTTree.C:59
 readTTree.C:60
 readTTree.C:61
 readTTree.C:62
 readTTree.C:63
 readTTree.C:64
 readTTree.C:65
 readTTree.C:66
 readTTree.C:67
 readTTree.C:68
 readTTree.C:69
 readTTree.C:70
 readTTree.C:71
 readTTree.C:72
 readTTree.C:73
 readTTree.C:74
 readTTree.C:75
 readTTree.C:76
 readTTree.C:77
 readTTree.C:78
 readTTree.C:79
 readTTree.C:80
 readTTree.C:81
 readTTree.C:82
 readTTree.C:83
 readTTree.C:84
 readTTree.C:85