]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/IdentifiedHighPt/grid/macro_HighPtDeDx_lhc10b_Data_ESDs.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / IdentifiedHighPt / grid / macro_HighPtDeDx_lhc10b_Data_ESDs.C
1 const char *anatype = "ESD";
2
3 void macro_HighPtDeDx_lhc10b_Data_ESDs()
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 analysis framework libraries
20    gSystem->Load("libANALYSIS");
21    gSystem->Load("libOADB");
22    gSystem->Load("libANALYSISalice");
23    gSystem->Load("libCORRFW");
24
25 // include path
26    TString intPath = gInterpreter->GetIncludePath();
27    TObjArray *listpaths = intPath.Tokenize(" ");
28    TIter nextpath(listpaths);
29    TObjString *pname;
30    while ((pname=(TObjString*)nextpath())) {
31       TString current = pname->GetName();
32       if (current.Contains("AliRoot") || current.Contains("ALICE_ROOT")) continue;
33       gSystem->AddIncludePath(current);
34    }
35    if (listpaths) delete listpaths;
36    gSystem->AddIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include ");
37    gROOT->ProcessLine(".include $ALICE_ROOT/include");
38    printf("Include path: %s\n", gSystem->GetIncludePath());
39
40 // Add aditional AliRoot libraries
41
42 // analysis source to be compiled at runtime (if any)
43    gROOT->ProcessLine(".L DebugClasses.C+g");
44    gROOT->ProcessLine(".L AliAnalysisTaskHighPtDeDx.cxx+g");
45    gROOT->ProcessLine(".L AliAnalysisTaskHighPtDeDxV0.cxx+g");
46
47 // fast xrootd reading enabled
48    printf("!!! You requested FastRead option. Using xrootd flags to reduce timeouts. Note that this may skip some files that could be accessed !!!");
49    gEnv->SetValue("XNet.ConnectTimeout",50);
50    gEnv->SetValue("XNet.RequestTimeout",50);
51    gEnv->SetValue("XNet.MaxRedirectCount",2);
52    gEnv->SetValue("XNet.ReconnectTimeout",50);
53    gEnv->SetValue("XNet.FirstConnectMaxCnt",1);
54
55 // connect to AliEn and make the chain
56    if (!TGrid::Connect("alien://")) return;
57 // read the analysis manager from file
58    AliAnalysisManager *mgr = AliAnalysisAlien::LoadAnalysisManager("HighPtDeDx_lhc10b_Data_ESDs.root");
59    if (!mgr) return;
60    mgr->PrintStatus();
61    AliLog::SetGlobalLogLevel(AliLog::kError);
62    TChain *chain = CreateChain("wn.xml", anatype);
63
64    mgr->StartAnalysis("localfile", chain);
65    timer.Stop();
66    timer.Print();
67 }
68
69 //________________________________________________________________________________
70 TChain* CreateChain(const char *xmlfile, const char *type="ESD")
71 {
72 // Create a chain using url's from xml file
73    TString filename;
74    Int_t run = 0;
75    TString treename = type;
76    treename.ToLower();
77    treename += "Tree";
78    printf("***************************************\n");
79    printf("    Getting chain of trees %s\n", treename.Data());
80    printf("***************************************\n");
81    TAlienCollection *coll = TAlienCollection::Open(xmlfile);
82    if (!coll) {
83       ::Error("CreateChain", "Cannot create an AliEn collection from %s", xmlfile);
84       return NULL;
85    }
86    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
87    TChain *chain = new TChain(treename);
88    coll->Reset();
89    while (coll->Next()) {
90       filename = coll->GetTURL();
91       if (mgr) {
92          Int_t nrun = AliAnalysisManager::GetRunFromAlienPath(filename);
93          if (nrun && nrun != run) {
94             printf("### Run number detected from chain: %d\n", nrun);
95             mgr->SetRunFromPath(nrun);
96             run = nrun;
97          }
98       }
99       chain->Add(filename);
100    }
101    if (!chain->GetNtrees()) {
102       ::Error("CreateChain", "No tree found from collection %s", xmlfile);
103       return NULL;
104    }
105    return chain;
106 }
107