runAnalysis.C 1.74 KB
Newer Older
Breno Rilho Lemos's avatar
Breno Rilho Lemos committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
void runAnalysis()
{
    // Erase output txt files
    ofstream s_detail, m_detail, l_detail;

    s_detail.open ("s-esd-detail.dat");
    s_detail << " " << endl;
    s_detail.close();

    m_detail.open ("m-esd-detail.dat");
    m_detail << " " << endl;
    m_detail.close();

    l_detail.open ("l-esd-detail.dat");
    l_detail << " " << endl;
    l_detail.close();

    // 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)
    chain->Add("AliESDs.root"); // Breno put it on the same directory that was cloned from Pezzi's 					// repository: AliESD_Example
    chain->Add("AliESDs2.root");

    //chain->Add("../root_files/AliAOD.Muons2.root");
    //chain->Add("../root_files/AliAOD.Muons3.root");
    //chain->Add("../root_files/AliAOD.Muons4.root");

    // start the analysis locally, reading the events from the tchain
    mgr->StartAnalysis("local", chain);


    exit();
}