]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/UNICOR/runAsTask.C
.so cleanup: removed from gSystem->Load()
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / UNICOR / runAsTask.C
1 //=============================================================================
2 void runAsTask(int grid=0) {
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");
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   }
21
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();
27
28   mgr->InitAnalysis();
29   mgr->PrintStatus(); 
30   mgr->StartAnalysis("local",tr);
31
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   }
42 }
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;
69 }
70 //=============================================================================