ROOT logo
void runFlowOnDataExample() {
    // example macro of running a flow analysis on local 
    // data
    //
    // all steps are explained in detail in
    // chapter 3.4.3 of the flow package manual
    // $ALICE_ROOT/PWGCF/FLOW/Documentation/FlowPackageManual.pdf
    // which is also available on the twiki page
    // https://twiki.cern.ch/twiki/bin/viewauth/ALICE/FlowPAGFlowPackageManual
    //
    // author: Redmer Alexander Bertens, Utrecht University
    // rbertens@cern.ch , rbertens@nikhef.nl , r.a.bertens@uu.nl

  // load libraries
  gSystem->Load("libCore.so");        
  gSystem->Load("libGeom.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libPhysics.so");
  gSystem->Load("libTree.so");
  gSystem->Load("libSTEERBase.so");
  gSystem->Load("libESD.so");
  gSystem->Load("libAOD.so");
  gSystem->Load("libANALYSIS.so");
  gSystem->Load("libANALYSISalice.so");
  gSystem->Load("libEventMixing.so");
  gSystem->Load("libCORRFW.so");
  gSystem->Load("libPWGTools.so");
  gSystem->Load("libPWGCFebye.so");
  gSystem->Load("libPWGflowBase.so");
  gSystem->Load("libPWGflowTasks.so");

    // create the analysis manager
  AliAnalysisManager* mgr = new AliAnalysisManager("MyManager");

  // create a tchain which will point to an aod tree
  TChain* chain = new TChain("aodTree");
  // add a few files to the chain (change this so that your local files are added)
  chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0003/AliAOD.root");
  chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0003/AliAOD.root");
  chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0004/AliAOD.root");
  chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0005/AliAOD.root");
  chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0006/AliAOD.root");
  chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0007/AliAOD.root");
  chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0008/AliAOD.root");
  chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0009/AliAOD.root");
  chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0010/AliAOD.root");
  // create an input handler
  AliVEventHandler* inputH = new AliAODInputHandler();
  // and connect it to the manager
  mgr->SetInputEventHandler(inputH);

   // the manager is static, so get the existing manager via the static method
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
      printf("No analysis manager to connect to!\n");
      return NULL;
  }
        
  // just to see if all went well, check if the input event handler has been connected
  if (!mgr->GetInputEventHandler()) {
      printf("This task requires an input event handler!\n");
      return NULL;
    }

  // create instance of the class. because possible qa plots are added in a second ouptut slot,
  // the flow analysis task must know if you want to save qa plots at the time of class construction
  Bool_t doQA = kTRUE;
  // craete instance of the class
  AliAnalysisTaskFlowEvent* taskFE = new AliAnalysisTaskFlowEvent("FlowEventTask", "", doQA);
  // add the task to the manager
  mgr->AddTask(taskFE);
  // set the trigger selection
  taskFE->SelectCollisionCandidates(AliVEvent::kMB);

    // define the event cuts object
  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("EventCuts");
  // configure some event cuts, starting with centrality
  cutsEvent->SetCentralityPercentileRange(20., 30.);
  // method used for centrality determination
  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
  // vertex-z cut
  cutsEvent->SetPrimaryVertexZrange(-10.,10.);
  // enable the qa plots
  cutsEvent->SetQA(doQA);
  // explicit multiplicity outlier cut
  cutsEvent->SetCutTPCmultiplicityOutliersAOD(kTRUE);
  cutsEvent->SetLHC10h(kTRUE);
  
  
  // and, last but not least, pass these cuts to your flow event task
  taskFE->SetCutsEvent(cutsEvent);

  //create the track cuts object using a static function of AliFlowTrackCuts
  AliFlowTrackCuts* cutsRP = AliFlowTrackCuts::GetAODTrackCutsForFilterBit(1, "RP_cuts");
  // specify the pt range
  cutsRP->SetPtRange(0.2, 5.);
  // specify eta range
  cutsRP->SetEtaRange(-0.8, 0.8);
  // specify track type
  cutsRP->SetParamType(AliFlowTrackCuts::kAODFilterBit);
  // enable saving qa histograms
  cutsRP->SetQA(kTRUE);

    //create the track cuts object using a static function of AliFlowTrackCuts
  AliFlowTrackCuts* cutsPOI = AliFlowTrackCuts::GetAODTrackCutsForFilterBit(1, "pion selection");
  // specify the pt range
  cutsPOI->SetPtRange(0.2, 5.);
  // specify eta range
  cutsPOI->SetEtaRange(-0.8, 0.8);
  // specify the track type
  cutsPOI->SetParamType(AliFlowTrackCuts::kAODFilterBit);
  // enable saving qa histograms
  cutsPOI->SetQA(kTRUE);

    // which particle do we want to identify ?
  AliPID::EParticleType particleType=AliPID::kPion;
  // specify the pid method that we want to use  
  AliFlowTrackCuts::PIDsource sourcePID=AliFlowTrackCuts::kTOFbayesian;
  // define the probability (between 0 and 1) 
  Double_t probability = .9;
  // pass these variables to the track cut object
  cutsPOI->SetPID(particleType, sourcePID, probability);
  // the bayesian pid routine uses priors tuned to an average centrality
  cutsPOI->SetPriors(35.);

    // connect the RP's to the flow event task
  taskFE->SetCutsRP(cutsRP);
  // connect the POI's to the flow event task
  taskFE->SetCutsPOI(cutsPOI);

    // get the default name of the output file ("AnalysisResults.root")
  TString file = AliAnalysisManager::GetCommonFileName();
  // get the common input container from the analysis manager
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
   // create a data container for the output of the flow event task  
   // the output of the task is the AliFlowEventSimle class which will
   // be passed to the flow analysis tasks. note that we use a kExchangeContainer here,
   // which exchanges data between classes of the analysis chain, but is not
   // written to the output file
  AliAnalysisDataContainer *coutputFE = mgr->CreateContainer(
      "FlowEventContainer",
      AliFlowEventSimple::Class(),
      AliAnalysisManager::kExchangeContainer);
  // connect the input data to the flow event task
  mgr->ConnectInput(taskFE,0,cinput);
  // and connect the output to the flow event task
  mgr->ConnectOutput(taskFE,1,coutputFE);
  // create an additional container for the QA output of the flow event task
  // the QA histograms will be stored in a sub-folder of the output file called 'QA'
  TString taskFEQAname = file;
  taskFEQAname += ":QA";
  AliAnalysisDataContainer* coutputFEQA = mgr->CreateContainer(
      "FlowEventContainerQA",
       TList::Class(),
       AliAnalysisManager::kOutputContainer,
       taskFEQAname.Data()       
       );
  // and connect the qa output container to the flow event. 
  // this container will be written to the output file
  mgr->ConnectOutput(taskFE,2,coutputFEQA);

    // declare necessary pointers
  AliAnalysisDataContainer *coutputQC[3];
  AliAnalysisTaskQCumulants *taskQC[3];

  // the tasks will be creaated and added to the manager in a loop
  for(Int_t i = 0; i < 3; i++) {
      // create the flow analysis tasks
      taskQC[i] = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_n=%i", i+2));
      // set the triggers 
      taskQC[i]->SelectCollisionCandidates(AliVEvent::kMB);
      // and set the correct harmonic n
      taskQC[i]->SetHarmonic(i+2);

      // connect the task to the analysis manager
      mgr->AddTask(taskQC[i]);

      // create and connect the output containers
      TString outputQC = file;
      // create a sub-folder in the output file for each flow analysis task's output
      outputQC += Form(":QC_output_for_n=%i", i+2);
      /// create the output containers
      coutputQC[i] = mgr->CreateContainer(
          outputQC.Data(),
          TList::Class(),
          AliAnalysisManager::kOutputContainer,
          outputQC);
      // connect the output of the flow event task to the flow analysis task
      mgr->ConnectInput(taskQC[i], 0, coutputFE);
      // and connect the output of the flow analysis task to the output container
      // which will be written to the output file
      mgr->ConnectOutput(taskQC[i], 1, coutputQC[i]);
  }
  
  // check if we can initialize the manager
  if(!mgr->InitAnalysis()) return;   
  // print the status of the manager to screen 
  mgr->PrintStatus();
  // print to screen how the analysis is progressing
  mgr->SetUseProgressBar(1, 25);
  // start the analysis locally, reading the events from the tchain
  mgr->StartAnalysis("local", chain);

  
}
 runFlowOnDataExample.C:1
 runFlowOnDataExample.C:2
 runFlowOnDataExample.C:3
 runFlowOnDataExample.C:4
 runFlowOnDataExample.C:5
 runFlowOnDataExample.C:6
 runFlowOnDataExample.C:7
 runFlowOnDataExample.C:8
 runFlowOnDataExample.C:9
 runFlowOnDataExample.C:10
 runFlowOnDataExample.C:11
 runFlowOnDataExample.C:12
 runFlowOnDataExample.C:13
 runFlowOnDataExample.C:14
 runFlowOnDataExample.C:15
 runFlowOnDataExample.C:16
 runFlowOnDataExample.C:17
 runFlowOnDataExample.C:18
 runFlowOnDataExample.C:19
 runFlowOnDataExample.C:20
 runFlowOnDataExample.C:21
 runFlowOnDataExample.C:22
 runFlowOnDataExample.C:23
 runFlowOnDataExample.C:24
 runFlowOnDataExample.C:25
 runFlowOnDataExample.C:26
 runFlowOnDataExample.C:27
 runFlowOnDataExample.C:28
 runFlowOnDataExample.C:29
 runFlowOnDataExample.C:30
 runFlowOnDataExample.C:31
 runFlowOnDataExample.C:32
 runFlowOnDataExample.C:33
 runFlowOnDataExample.C:34
 runFlowOnDataExample.C:35
 runFlowOnDataExample.C:36
 runFlowOnDataExample.C:37
 runFlowOnDataExample.C:38
 runFlowOnDataExample.C:39
 runFlowOnDataExample.C:40
 runFlowOnDataExample.C:41
 runFlowOnDataExample.C:42
 runFlowOnDataExample.C:43
 runFlowOnDataExample.C:44
 runFlowOnDataExample.C:45
 runFlowOnDataExample.C:46
 runFlowOnDataExample.C:47
 runFlowOnDataExample.C:48
 runFlowOnDataExample.C:49
 runFlowOnDataExample.C:50
 runFlowOnDataExample.C:51
 runFlowOnDataExample.C:52
 runFlowOnDataExample.C:53
 runFlowOnDataExample.C:54
 runFlowOnDataExample.C:55
 runFlowOnDataExample.C:56
 runFlowOnDataExample.C:57
 runFlowOnDataExample.C:58
 runFlowOnDataExample.C:59
 runFlowOnDataExample.C:60
 runFlowOnDataExample.C:61
 runFlowOnDataExample.C:62
 runFlowOnDataExample.C:63
 runFlowOnDataExample.C:64
 runFlowOnDataExample.C:65
 runFlowOnDataExample.C:66
 runFlowOnDataExample.C:67
 runFlowOnDataExample.C:68
 runFlowOnDataExample.C:69
 runFlowOnDataExample.C:70
 runFlowOnDataExample.C:71
 runFlowOnDataExample.C:72
 runFlowOnDataExample.C:73
 runFlowOnDataExample.C:74
 runFlowOnDataExample.C:75
 runFlowOnDataExample.C:76
 runFlowOnDataExample.C:77
 runFlowOnDataExample.C:78
 runFlowOnDataExample.C:79
 runFlowOnDataExample.C:80
 runFlowOnDataExample.C:81
 runFlowOnDataExample.C:82
 runFlowOnDataExample.C:83
 runFlowOnDataExample.C:84
 runFlowOnDataExample.C:85
 runFlowOnDataExample.C:86
 runFlowOnDataExample.C:87
 runFlowOnDataExample.C:88
 runFlowOnDataExample.C:89
 runFlowOnDataExample.C:90
 runFlowOnDataExample.C:91
 runFlowOnDataExample.C:92
 runFlowOnDataExample.C:93
 runFlowOnDataExample.C:94
 runFlowOnDataExample.C:95
 runFlowOnDataExample.C:96
 runFlowOnDataExample.C:97
 runFlowOnDataExample.C:98
 runFlowOnDataExample.C:99
 runFlowOnDataExample.C:100
 runFlowOnDataExample.C:101
 runFlowOnDataExample.C:102
 runFlowOnDataExample.C:103
 runFlowOnDataExample.C:104
 runFlowOnDataExample.C:105
 runFlowOnDataExample.C:106
 runFlowOnDataExample.C:107
 runFlowOnDataExample.C:108
 runFlowOnDataExample.C:109
 runFlowOnDataExample.C:110
 runFlowOnDataExample.C:111
 runFlowOnDataExample.C:112
 runFlowOnDataExample.C:113
 runFlowOnDataExample.C:114
 runFlowOnDataExample.C:115
 runFlowOnDataExample.C:116
 runFlowOnDataExample.C:117
 runFlowOnDataExample.C:118
 runFlowOnDataExample.C:119
 runFlowOnDataExample.C:120
 runFlowOnDataExample.C:121
 runFlowOnDataExample.C:122
 runFlowOnDataExample.C:123
 runFlowOnDataExample.C:124
 runFlowOnDataExample.C:125
 runFlowOnDataExample.C:126
 runFlowOnDataExample.C:127
 runFlowOnDataExample.C:128
 runFlowOnDataExample.C:129
 runFlowOnDataExample.C:130
 runFlowOnDataExample.C:131
 runFlowOnDataExample.C:132
 runFlowOnDataExample.C:133
 runFlowOnDataExample.C:134
 runFlowOnDataExample.C:135
 runFlowOnDataExample.C:136
 runFlowOnDataExample.C:137
 runFlowOnDataExample.C:138
 runFlowOnDataExample.C:139
 runFlowOnDataExample.C:140
 runFlowOnDataExample.C:141
 runFlowOnDataExample.C:142
 runFlowOnDataExample.C:143
 runFlowOnDataExample.C:144
 runFlowOnDataExample.C:145
 runFlowOnDataExample.C:146
 runFlowOnDataExample.C:147
 runFlowOnDataExample.C:148
 runFlowOnDataExample.C:149
 runFlowOnDataExample.C:150
 runFlowOnDataExample.C:151
 runFlowOnDataExample.C:152
 runFlowOnDataExample.C:153
 runFlowOnDataExample.C:154
 runFlowOnDataExample.C:155
 runFlowOnDataExample.C:156
 runFlowOnDataExample.C:157
 runFlowOnDataExample.C:158
 runFlowOnDataExample.C:159
 runFlowOnDataExample.C:160
 runFlowOnDataExample.C:161
 runFlowOnDataExample.C:162
 runFlowOnDataExample.C:163
 runFlowOnDataExample.C:164
 runFlowOnDataExample.C:165
 runFlowOnDataExample.C:166
 runFlowOnDataExample.C:167
 runFlowOnDataExample.C:168
 runFlowOnDataExample.C:169
 runFlowOnDataExample.C:170
 runFlowOnDataExample.C:171
 runFlowOnDataExample.C:172
 runFlowOnDataExample.C:173
 runFlowOnDataExample.C:174
 runFlowOnDataExample.C:175
 runFlowOnDataExample.C:176
 runFlowOnDataExample.C:177
 runFlowOnDataExample.C:178
 runFlowOnDataExample.C:179
 runFlowOnDataExample.C:180
 runFlowOnDataExample.C:181
 runFlowOnDataExample.C:182
 runFlowOnDataExample.C:183
 runFlowOnDataExample.C:184
 runFlowOnDataExample.C:185
 runFlowOnDataExample.C:186
 runFlowOnDataExample.C:187
 runFlowOnDataExample.C:188
 runFlowOnDataExample.C:189
 runFlowOnDataExample.C:190
 runFlowOnDataExample.C:191
 runFlowOnDataExample.C:192
 runFlowOnDataExample.C:193
 runFlowOnDataExample.C:194
 runFlowOnDataExample.C:195
 runFlowOnDataExample.C:196
 runFlowOnDataExample.C:197
 runFlowOnDataExample.C:198
 runFlowOnDataExample.C:199
 runFlowOnDataExample.C:200
 runFlowOnDataExample.C:201
 runFlowOnDataExample.C:202
 runFlowOnDataExample.C:203
 runFlowOnDataExample.C:204
 runFlowOnDataExample.C:205
 runFlowOnDataExample.C:206