]>
Commit | Line | Data |
---|---|---|
509f84fa | 1 | /* |
2bfe5463 | 2 | Macros to run PWGPP train: |
509f84fa | 3 | |
2bfe5463 | 4 | void runPWGPPTrain(const char *macros = "AddTask*.C", const char *fname="AliESDs.root"); |
509f84fa | 5 | //Parameters: |
6 | // macros: run the train for selected tasks | |
7 | // tasks are expected to be in the working directory | |
8 | // fname : name of the input file or input list | |
9 | ||
876d7f48 | 10 | |
2bfe5463 | 11 | .L $ALICE_ROOT/PWGPP/PWGPPmacros/runPWGPPTrain.C |
876d7f48 | 12 | |
13 | ||
509f84fa | 14 | */ |
15 | ||
16 | void LoadTrainLibs(){ | |
17 | // | |
18 | // load libraries needed for train | |
19 | // | |
2bfe5463 | 20 | gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT -I$ALICE_ROOT/TRD -I$ALICE_ROOT/PWGPP/TRD/macros/ "); |
509f84fa | 21 | gSystem->Load("libANALYSIS.so"); |
22 | gSystem->Load("libANALYSISalice.so"); | |
23 | gSystem->Load("libTENDER.so"); | |
24 | gSystem->Load("libCORRFW.so"); | |
25 | gSystem->Load("libPWG0base.so"); | |
26 | gSystem->Load("libPWG0dep.so"); | |
27 | gSystem->Load("libPWG0selectors.so"); | |
2bfe5463 | 28 | gSystem->Load("libPWGPP.so"); |
509f84fa | 29 | gSystem->Load("libPWG2.so"); |
40a0a69c | 30 | gSystem->Load("libPWGmuon.so"); |
31 | gSystem->Load("libPWGmuondep.so"); | |
509f84fa | 32 | gSystem->Load("libPWG2forward.so"); |
33 | gSystem->Load("libPWG4PartCorrBase.so"); | |
34 | gSystem->Load("libPWG4PartCorrDep.so"); | |
35 | } | |
36 | ||
876d7f48 | 37 | void TestConfig(){ |
38 | ||
39 | } | |
40 | ||
509f84fa | 41 | void AddMacros(const char *addmacros){ |
42 | // | |
43 | // add tasks from selected macros - * convention can be used | |
44 | // Macro expected to be in the working directory | |
45 | // Macros has to be without arguments | |
46 | // | |
47 | // | |
876d7f48 | 48 | TString macroList = gSystem->GetFromPipe(Form("cat ConfigTask.txt |grep %s",addmacros)); |
509f84fa | 49 | TObjArray * array = macroList.Tokenize("\n"); |
50 | ||
51 | if (!array) { printf("No task specified"); return;} | |
52 | if (array->GetEntries()==0) { | |
53 | printf("Empty list of tasks"); | |
54 | return; | |
55 | } | |
56 | for (Int_t itask=0; itask<array->GetEntries(); itask++){ | |
57 | gROOT->Macro(array->At(itask)->GetName()); | |
58 | } | |
59 | } | |
60 | ||
61 | void AddToChain(TChain * chain, TString inputList){ | |
62 | // | |
63 | // add the files form inputList into chain | |
64 | // | |
65 | ifstream in; | |
66 | in.open(inputList.Data()); | |
67 | Int_t counter=0; | |
68 | TString currentFile; | |
69 | while(in.good()) { | |
70 | in >> currentFile; | |
71 | if (!currentFile.Contains(".root")) continue; | |
72 | chain->Add(currentFile.Data()); | |
73 | printf("%d\t%s\n",counter,currentFile.Data()); | |
74 | counter++; | |
75 | } | |
76 | } | |
77 | ||
78 | void PrintSysInfo(){ | |
79 | // | |
80 | // print sysinfo | |
81 | // | |
82 | TF1 f1("f1","pol1"); | |
83 | TTree * tree = AliSysInfo::MakeTree("syswatch.log"); | |
84 | Int_t entries=0; | |
85 | TGraph *gr = 0; | |
86 | entries=tree->Draw("VM:id0","id0>10","goff"); | |
87 | gr=new TGraph(entries, tree->GetV2(),tree->GetV1()); | |
88 | gr->Fit(&f1); | |
89 | gr->Draw("alp"); | |
90 | printf("SysInfoMem:\t%f\n",f1->GetParameter(1)); | |
91 | // | |
92 | entries=tree->Draw("T:id0","id0>10","goff"); | |
93 | gr=new TGraph(entries, tree->GetV2(),tree->GetV1()); | |
94 | gr->Fit(&f1); | |
95 | gr->Draw("alp"); | |
96 | printf("SysInfoTime:\t%f\n",f1->GetParameter(1)); | |
97 | } | |
98 | ||
2bfe5463 | 99 | void runPWGPPTrain(const char *macros = "AddTask*.C", TString inputList ="esd.list", Int_t debugLevel=0) { |
509f84fa | 100 | //Parameters: |
101 | // macros: run the train for selected tasks | |
102 | // tasks are expected to be in the working directory | |
103 | // fname : name of the input file or input list | |
104 | TStopwatch timer; | |
105 | timer.Start(); | |
106 | LoadTrainLibs(); | |
107 | ||
108 | //____________________________________________ | |
109 | // Make the analysis manager | |
110 | // | |
111 | AliAnalysisManager *mgr = new AliAnalysisManager("TestManager"); | |
112 | mgr->SetDebugLevel(debugLevel); | |
113 | ||
114 | AliInputEventHandler* esdH = new AliESDInputHandlerRP(); | |
115 | esdH->SetActiveBranches("ESDfriend"); | |
116 | mgr->SetInputEventHandler(esdH); | |
117 | // | |
118 | // make chain | |
119 | // | |
120 | TChain* chain = new TChain("esdTree"); | |
121 | if (inputList.Contains(".root")){ | |
122 | chain->AddFile(inputList); | |
123 | } | |
124 | if (inputList.Contains(".list")){ | |
125 | AddToChain(chain, inputList); | |
126 | } | |
127 | chain->Lookup(); | |
128 | // | |
129 | // | |
130 | // Init | |
131 | AddMacros(macros); | |
132 | mgr->SetNSysInfo(1000); | |
133 | if (!mgr->InitAnalysis()) | |
134 | mgr->PrintStatus(); | |
135 | mgr->PrintStatus(); | |
136 | // Run on dataset | |
137 | // | |
138 | mgr->StartAnalysis("local", chain); | |
139 | PrintSysInfo(); | |
140 | ||
141 | timer.Stop(); | |
142 | timer.Print(); | |
143 | } | |
144 |