]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/STRANGENESS/LambdaK0PbPb/AnalysisStrange.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / LambdaK0PbPb / AnalysisStrange.C
1 const char *anatype = "ESD";
2
3 void AnalysisStrange()
4 {
5 // Analysis using ESD data
6 // Automatically generated analysis steering macro executed in grid subjobs
7
8    TStopwatch timer;
9    timer.Start();
10
11 // Set temporary merging directory to current one
12    gSystem->Setenv("TMPDIR", gSystem->pwd());
13
14 // Set temporary compilation directory to current one
15    gSystem->SetBuildDir(gSystem->pwd(), kTRUE);
16
17 // Reset existing include path and add current directory first in the search
18    gSystem->SetIncludePath("-I.");
19 // load base root libraries
20    gSystem->Load("libTree");
21    gSystem->Load("libGeom");
22    gSystem->Load("libVMC");
23    gSystem->Load("libPhysics");
24
25    gSystem->Load("libMinuit");
26
27 // Load analysis framework libraries
28    gSystem->Load("libSTEERBase");
29    gSystem->Load("libESD");
30    gSystem->Load("libAOD");
31    gSystem->Load("libANALYSIS");
32    gSystem->Load("libANALYSISalice");
33    gSystem->Load("libCORRFW");
34
35 // include path
36    TString intPath = gInterpreter->GetIncludePath();
37    TObjArray *listpaths = intPath.Tokenize(" ");
38    TIter nextpath(listpaths);
39    TObjString *pname;
40    while ((pname=(TObjString*)nextpath())) {
41       TString current = pname->GetName();
42       if (current.Contains("AliRoot") || current.Contains("ALICE_ROOT")) continue;
43       gSystem->AddIncludePath(current);
44    }
45    if (listpaths) delete listpaths;
46    gROOT->ProcessLine(".include $ALICE_ROOT/include");
47    printf("Include path: %s\n", gSystem->GetIncludePath());
48
49 // Add aditional AliRoot libraries
50
51 // analysis source to be compiled at runtime (if any)
52    gROOT->ProcessLine(".L AliAnalysisCentralitySelector.cxx+g");
53    gROOT->ProcessLine(".L AliAnalysisTaskPerformanceStrange.cxx+g");
54
55 // connect to AliEn and make the chain
56    if (!TGrid::Connect("alien://")) return;
57 // read the analysis manager from file
58    TFile *file = TFile::Open("analysis.root");
59    if (!file) return;
60    TIter nextkey(file->GetListOfKeys());
61    AliAnalysisManager *mgr = 0;
62    TKey *key;
63    while ((key=(TKey*)nextkey())) {
64       if (!strcmp(key->GetClassName(), "AliAnalysisManager"))
65          mgr = (AliAnalysisManager*)file->Get(key->GetName());
66    };
67    if (!mgr) {
68       ::Error("AnalysisStrange", "No analysis manager found in file analysis.root");
69       return;
70    }
71
72    mgr->PrintStatus();
73    AliLog::SetGlobalLogLevel(AliLog::kError);
74    TChain *chain = CreateChain("wn.xml", anatype);
75
76    mgr->StartAnalysis("localfile", chain);
77    timer.Stop();
78    timer.Print();
79 }
80
81 //________________________________________________________________________________
82 TChain* CreateChain(const char *xmlfile, const char *type="ESD")
83 {
84 // Create a chain using url's from xml file
85    TString filename;
86    Int_t run = 0;
87    TString treename = type;
88    treename.ToLower();
89    treename += "Tree";
90    printf("***************************************\n");
91    printf("    Getting chain of trees %s\n", treename.Data());
92    printf("***************************************\n");
93    TAlienCollection *coll = TAlienCollection::Open(xmlfile);
94    if (!coll) {
95       ::Error("CreateChain", "Cannot create an AliEn collection from %s", xmlfile);
96       return NULL;
97    }
98    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
99    TChain *chain = new TChain(treename);
100    coll->Reset();
101    while (coll->Next()) {
102       filename = coll->GetTURL();
103       if (mgr) {
104          Int_t nrun = AliAnalysisManager::GetRunFromAlienPath(filename);
105          if (nrun && nrun != run) {
106             printf("### Run number detected from chain: %d\n", nrun);
107             mgr->SetRunFromPath(nrun);
108             run = nrun;
109          }
110       }
111       chain->Add(filename);
112    }
113    if (!chain->GetNtrees()) {
114       ::Error("CreateChain", "No tree found from collection %s", xmlfile);
115       return NULL;
116    }
117    return chain;
118 }
119