runAnalysis.C 1.62 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)
Breno Rilho Lemos's avatar
Breno Rilho Lemos committed
10
11
{
    // Erase output txt files
12
13
14
15
    ofstream esd_detail, s_event, events_number;

    events_number.open ("events_number.dat");
    events_number.close();
Breno Rilho Lemos's avatar
Breno Rilho Lemos committed
16

17
18
19
    s_event.open ("s-event.dat");
    s_event << selected_event;
    s_event.close();
Breno Rilho Lemos's avatar
Breno Rilho Lemos committed
20

21
22
    esd_detail.open ("esd-detail.dat");
    esd_detail.close();
Breno Rilho Lemos's avatar
Breno Rilho Lemos committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

    // 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)
48
    chain->Add("AliESDs.root");
Breno Rilho Lemos's avatar
Breno Rilho Lemos committed
49
50
51
    // start the analysis locally, reading the events from the tchain
    mgr->StartAnalysis("local", chain);

52
    remove("s-event.dat");
Breno Rilho Lemos's avatar
Breno Rilho Lemos committed
53
54
55

    exit();
}