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