runAnalysis.C 1.43 KB
Newer Older
1 2 3 4 5 6 7 8 9
// Run:
//
// $ aliroot -q -b "runAnalysis.C(selected-event)"
//
// 'selected-event' is the desired event number inside the ESD file
// Leaving it blank will select event 0
//

int runAnalysis(int selected_event=0)
10
{
11
    ofstream s_event;
12

13 14 15
    s_event.open ("s-event.dat");
    s_event << selected_event;
    s_event.close();
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

    // since we will compile a class, tell root where to look for headers
    gROOT->ProcessLine(".include $ROOTSYS/include");
    gROOT->ProcessLine(".include $ALICE_ROOT/include");

    // create the analysis manager
    AliAnalysisManager *mgr = new AliAnalysisManager("testAnalysis");
    AliESDInputHandler *esdH = new AliESDInputHandler();
    mgr->SetInputEventHandler(esdH);

    // compile the class (locally)
    gROOT->LoadMacro("AliAnalysisTaskMyTask.cxx++g");
    // load the addtask macro
    gROOT->LoadMacro("AddMyTask.C");
    // create an instance of your analysis task
    AliAnalysisTaskMyTask *task = AddMyTask();

    if(!mgr->InitAnalysis()) return;
    mgr->SetDebugLevel(2);
    mgr->PrintStatus();
    mgr->SetUseProgressBar(1, 25);

    // if you want to run locally, we need to define some input
    TChain* chain = new TChain("esdTree");
    // add a few files to the chain (change this so that your local files are added)
41
    chain->Add("AliESDs.root");
42 43 44
    // start the analysis locally, reading the events from the tchain
    mgr->StartAnalysis("local", chain);

45
    remove("s-event.dat");
46 47 48

    exit();
}