4 // example macro to read data from a ttree and perform a flow analysis using the flow pacakge
5 // author: Redmer Alexander Bertens (rbertens@cern.ch)
6 // note: this macro can run in ROOT only provided libPWGflowBase.so is available
8 // compile the relevant classes
9 // include paths, necessary for compilation
10 gSystem->AddIncludePath("-Wno-deprecated");
11 gSystem->AddIncludePath("-I$ALICE_ROOT -I$ALICE_ROOT/include");
14 gSystem->Load("libCore");
15 gSystem->Load("libGeom");
16 gSystem->Load("libVMC");
17 gSystem->Load("libPhysics");
18 gSystem->Load("libTree");
19 gSystem->Load("libPWGflowBase");
21 // comile the encapsulated classes
22 gROOT->LoadMacro("../objects/AliFlowTTreeEvent.cxx+");
23 gROOT->LoadMacro("../objects/AliFlowTTreeTrack.cxx+");
24 gROOT->LoadMacro("../objects/AliFlowEventSimpleFromTTree.cxx+");
26 TChain* myChain = new TChain("tree");
27 myChain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/filtered/000167988.root");
28 myChain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/filtered/000168066.root");
30 // create pointers for the branches
31 AliFlowTTreeEvent* event = 0x0;
32 myChain->SetBranchAddress("event", &event);
33 TClonesArray* tracks = 0x0;
34 myChain->SetBranchAddress("track", &tracks);
35 // and an example track
36 AliFlowTTreeTrack* firstTrack = 0x0;
38 // connection to the flow package
39 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
41 AliFlowTrackSimpleCuts* cutsPOI = new AliFlowTrackSimpleCuts();
42 cutsPOI->SetPtMin(0.2);
43 cutsPOI->SetPtMin(2.);
44 AliFlowTrackSimpleCuts* cutsRP = new AliFlowTrackSimpleCuts();
46 // set how many events you want to analyze
47 Int_t maxEvents = 10000;
49 printf(" > %i events in chain, processing %i of them < \n", myChain->GetEntries(), maxEvents);
50 for(Int_t i = 0; i < myChain->GetEntries(); i++) {
51 cout << " > Parsing event " << i << "\r"; cout.flush();
53 // pass info to flow package
54 AliFlowEventSimple* flowevent = new AliFlowEventSimpleFromTTree(event, tracks, cutsPOI, cutsRP);
58 if(maxEvents < 1) break;
64 // open a new file which will hold the final results of all methods:
65 TString outputFileName = "qc_results.root";
66 TFile *outputFile = new TFile(outputFileName.Data(),"RECREATE");
67 const Int_t nMethods = 1;
68 TString method[nMethods] = {"QC"};
69 TDirectoryFile *dirFileFinal[nMethods] = {NULL};
70 TString fileName[nMethods];
71 for(Int_t i=0; i<nMethods; i++)
73 // form a file name for each method:
74 fileName[i]+="output";
75 fileName[i]+=method[i].Data();
76 fileName[i]+="analysis";
77 dirFileFinal[i] = new TDirectoryFile(fileName[i].Data(),fileName[i].Data());
80 // store the final results
81 qc->WriteHistograms(dirFileFinal[0]);