]>
Commit | Line | Data |
---|---|---|
0cb187ff | 1 | void readTTree() |
2 | { | |
3 | ||
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 | |
7 | ||
8 | // compile the relevant classes | |
9 | // include paths, necessary for compilation | |
10 | gSystem->AddIncludePath("-Wno-deprecated"); | |
dc64e91a | 11 | gSystem->AddIncludePath("-I$ALICE_ROOT -I$ALICE_ROOT/include"); |
0cb187ff | 12 | |
13 | // load libraries | |
4070f709 | 14 | gSystem->Load("libCore"); |
15 | gSystem->Load("libGeom"); | |
16 | gSystem->Load("libVMC"); | |
17 | gSystem->Load("libPhysics"); | |
18 | gSystem->Load("libTree"); | |
19 | gSystem->Load("libPWGflowBase"); | |
0cb187ff | 20 | |
21 | // comile the encapsulated classes | |
22 | gROOT->LoadMacro("../objects/AliFlowTTreeEvent.cxx+"); | |
23 | gROOT->LoadMacro("../objects/AliFlowTTreeTrack.cxx+"); | |
24 | gROOT->LoadMacro("../objects/AliFlowEventSimpleFromTTree.cxx+"); | |
25 | ||
0f675049 | 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"); | |
0cb187ff | 29 | |
30 | // create pointers for the branches | |
31 | AliFlowTTreeEvent* event = 0x0; | |
0f675049 | 32 | myChain->SetBranchAddress("event", &event); |
0cb187ff | 33 | TClonesArray* tracks = 0x0; |
0f675049 | 34 | myChain->SetBranchAddress("track", &tracks); |
0cb187ff | 35 | // and an example track |
36 | AliFlowTTreeTrack* firstTrack = 0x0; | |
37 | ||
38 | // connection to the flow package | |
39 | AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants(); | |
40 | qc->Init(); | |
41 | AliFlowTrackSimpleCuts* cutsPOI = new AliFlowTrackSimpleCuts(); | |
42 | cutsPOI->SetPtMin(0.2); | |
43 | cutsPOI->SetPtMin(2.); | |
44 | AliFlowTrackSimpleCuts* cutsRP = new AliFlowTrackSimpleCuts(); | |
45 | ||
0f675049 | 46 | // set how many events you want to analyze |
47 | Int_t maxEvents = 10000; | |
0cb187ff | 48 | // event loop |
0f675049 | 49 | printf(" > %i events in chain, processing %i of them < \n", myChain->GetEntries(), maxEvents); |
50 | for(Int_t i = 0; i < myChain->GetEntries(); i++) { | |
0cb187ff | 51 | cout << " > Parsing event " << i << "\r"; cout.flush(); |
0f675049 | 52 | myChain->GetEntry(i); |
0cb187ff | 53 | // pass info to flow package |
54 | AliFlowEventSimple* flowevent = new AliFlowEventSimpleFromTTree(event, tracks, cutsPOI, cutsRP); | |
55 | qc->Make(flowevent); | |
56 | delete flowevent; | |
57 | maxEvents--; | |
58 | if(maxEvents < 1) break; | |
59 | } | |
60 | ||
0cb187ff | 61 | // wrap up analysis |
62 | qc->Finish(); | |
63 | ||
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++) | |
72 | { | |
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()); | |
78 | } | |
79 | ||
80 | // store the final results | |
81 | qc->WriteHistograms(dirFileFinal[0]); | |
82 | outputFile->Close(); | |
83 | } | |
84 |