]>
Commit | Line | Data |
---|---|---|
61e4657c | 1 | //============================================================================= |
2 | void runAsTask(int grid=0) { | |
4070f709 | 3 | gSystem->Load("libPhysics"); |
4 | gSystem->Load("libEG"); | |
5 | gSystem->Load("libTree"); | |
6 | gSystem->Load("libVMC"); | |
7 | gSystem->Load("libSTEERBase"); | |
8 | gSystem->Load("libESD"); | |
9 | gSystem->Load("libAOD"); | |
61e4657c | 10 | gSystem->Load("libANALYSIS"); |
11 | gSystem->Load("libANALYSISalice"); | |
12 | gSystem->Load("libPWG2unicor"); | |
13 | ||
14 | if (grid) { | |
15 | if (!TGrid::Connect("alien://")) return; | |
16 | TChain *tr = CreateChainFromTags("wn.xml", "ESD"); | |
17 | } else { | |
18 | gROOT->LoadMacro("makechain.C"); | |
19 | tr = makechain("esdTree","filelist.txt"); | |
20 | } | |
3310f801 | 21 | |
61e4657c | 22 | AliAnalysisManager *mgr = new AliAnalysisManager("TestManager"); |
23 | AliVEventHandler* esdH = new AliESDInputHandler; | |
24 | mgr->SetInputEventHandler(esdH); | |
25 | gROOT->LoadMacro("$ALICE_ROOT/PWG2/UNICOR/AddTaskUnicor.C"); | |
26 | AliAnalysisTaskUnicor *mytask = AddTaskUnicor(); | |
3310f801 | 27 | |
61e4657c | 28 | mgr->InitAnalysis(); |
29 | mgr->PrintStatus(); | |
30 | mgr->StartAnalysis("local",tr); | |
3310f801 | 31 | |
61e4657c | 32 | TFile::Open("AnalysisResults.root","read"); |
33 | gDirectory->Cd("PWG2UNICOR"); | |
34 | TList *list = (TList *) gDirectory->Get("unilis"); | |
35 | char *outfil = "unicor-result-as-anal.root"; | |
36 | for (int i=0; i<list->GetEntries(); i++) { | |
37 | AliUnicorAnal *an = (AliUnicorAnal *) list->At(i); | |
38 | if (i==0) an->Save(outfil,"recreate"); | |
39 | else an->Save(outfil); | |
40 | delete an; | |
41 | } | |
360f2169 | 42 | } |
61e4657c | 43 | //============================================================================= |
44 | TChain* CreateChainFromTags(const char *xmlfile, const char *type="ESD") | |
45 | { | |
46 | // Create a chain using tags from the xml file. | |
47 | TAlienCollection* coll = TAlienCollection::Open(xmlfile); | |
48 | if (!coll) { | |
49 | ::Error("CreateChainFromTags", "Cannot create an AliEn collection from %s", xmlfile); | |
50 | return NULL; | |
51 | } | |
52 | TGridResult* tagResult = coll->GetGridResult("",kFALSE,kFALSE); | |
53 | AliTagAnalysis *tagAna = new AliTagAnalysis(type); | |
54 | tagAna->ChainGridTags(tagResult); | |
55 | ||
56 | AliRunTagCuts *runCuts = new AliRunTagCuts(); | |
57 | AliLHCTagCuts *lhcCuts = new AliLHCTagCuts(); | |
58 | AliDetectorTagCuts *detCuts = new AliDetectorTagCuts(); | |
59 | AliEventTagCuts *evCuts = new AliEventTagCuts(); | |
60 | // Check if the cuts configuration file was provided | |
61 | if (!gSystem->AccessPathName("ConfigureCuts.C")) { | |
62 | gROOT->LoadMacro("ConfigureCuts.C"); | |
63 | ConfigureCuts(runCuts, lhcCuts, detCuts, evCuts); | |
64 | } | |
65 | TChain *chain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evCuts); | |
66 | if (!chain || !chain->GetNtrees()) return NULL; | |
67 | chain->ls(); | |
68 | return chain; | |
621688e4 | 69 | } |
61e4657c | 70 | //============================================================================= |