]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis/RunManager.C
615eed50b5c281343ff5b1171fab6174297bf52a
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis / RunManager.C
1 //
2 // Run an analysis job 
3 // 
4 void RunManager(const char* esddir=".", 
5                 Int_t       nEvents=1000,
6                 Float_t     cmsGeV=900.,
7                 const char* col="p-p",
8                 Float_t     bkG=5., 
9                 Bool_t      proof=false)
10 {
11   gSystem->Load("libVMC");
12   gSystem->Load("libTree");
13   
14   gSystem->Load("libSTEERBase");
15   
16   gSystem->Load("libESD") ;
17   gSystem->Load("libAOD") ;
18   gSystem->Load("libANALYSIS");
19   gSystem->Load("libANALYSISalice");
20   
21   gSystem->Load("libPhysics");
22   gSystem->Load("libPWG0base");
23   gSystem->Load("libPWG0dep");
24   gSystem->Load("libPWG2forward");
25
26   // --- Check for proof mode, and possibly upload pars --------------
27   if (proof) { 
28     TProof::Open("workers=2");
29     const char* pkgs[] = { "STEERBase", "ESD", "AOD", "ANALYSIS", 
30                            "ANALYSISalice", "PWG2forward", 0};
31     const char** pkg = pkgs;
32     while (*pkg) { 
33       gProof->UploadPackage(Form("${ALICE_ROOT}/%s.par",*pkg));
34       gProof->EnablePackage(*pkg);    
35       pkg++;
36     }
37   }
38
39   
40   // --- Our data chain ----------------------------------------------
41   TChain* chain = new TChain("esdTree");
42
43   // --- Get list of ESDs --------------------------------------------
44   // Open source directory, and make sure we go back to were we were 
45   TString oldDir(gSystem->WorkingDirectory());
46   TSystemDirectory d(esddir, esddir);
47   TList* files = d.GetListOfFiles();
48   gSystem->ChangeDirectory(oldDir);
49
50   // Sort list of files and check if we should add it 
51   files->Sort();
52   TIter next(files);
53   TSystemFile* file = 0;
54   while ((file = static_cast<TSystemFile*>(next()))) {
55     if (file->IsDirectory()) continue;
56     TString name(file->GetName());
57     if (!name.EndsWith(".root")) continue;
58     if (!name.Contains("AliESDs")) continue;
59     TString esd(Form("%s/%s", file->GetTitle(), name.Data()));
60     Info("RunManager", "Adding %s to chain", esd.Data());
61     chain->Add(esd);
62   }  
63   
64   // --- Creating the manager and handlers ---------------------------
65   AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", 
66                                                     "The Analysis Train");
67   AliESDInputHandler *esdHandler = new AliESDInputHandler();
68   esdHandler->SetInactiveBranches("AliESDACORDE "
69                                   "AliRawDataErrorLogs "
70                                   "CaloClusters "
71                                   "Cascades "
72                                   "EMCALCells "
73                                   "EMCALTrigger "
74                                   "Kinks "
75                                   "Cascades "
76                                   "MuonTracks "
77                                   "TrdTracks "
78                                   "CaloClusters "
79                                   "HLTGlobalTrigger");
80   mgr->SetInputEventHandler(esdHandler);      
81
82   AliMCEventHandler* mcHandler = new AliMCEventHandler();
83   mgr->SetMCtruthEventHandler(mcHandler);
84   //mcHandler->SetReadTR(readTR);    
85   
86   AliAODHandler* aodHandler   = new AliAODHandler();
87   mgr->SetOutputEventHandler(aodHandler);
88   aodHandler->SetOutputFileName("AliAODs.root");
89     
90   // --- Add our task -----------------------------------------------
91   gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis/AddTaskFMD.C");
92   AliFMDAnalysisTaskSE *fmdtask = AddTaskFMD(energy, col, bkG);
93   
94   // --- Run the analysis --------------------------------------------
95   TStopwatch t;
96   if (!mgr->InitAnalysis()) {
97     Error("RunManager", "Failed to initialize analysis train!");
98     return;
99   }
100   // Some informative output 
101   mgr->PrintStatus();
102   // mgr->SetDebugLevel(3);
103   if (mgr->GetDebugLevel() < 1 && !proof) 
104     mgr->SetUseProgressBar(kTRUE);
105
106   // Run the train 
107   t.Start();
108   mgr->StartAnalysis(proof ? "proof" : "local", chain, nEvents);
109   t.Stop();
110   t.Print();
111 }
112 //
113 // EOF
114 //