]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis/RunManager.C
Transition PWG2/FORWARD -> PWGLF
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis / RunManager.C
CommitLineData
601f27d9 1//
2// Run an analysis job
3//
4void 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)
0f3a5aa9 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");
601f27d9 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
0f3a5aa9 39
601f27d9 40 // --- Our data chain ----------------------------------------------
0f3a5aa9 41 TChain* chain = new TChain("esdTree");
601f27d9 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 }
0f3a5aa9 63
601f27d9 64 // --- Creating the manager and handlers ---------------------------
65 AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train",
66 "The Analysis Train");
0f3a5aa9 67 AliESDInputHandler *esdHandler = new AliESDInputHandler();
601f27d9 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");
0f3a5aa9 80 mgr->SetInputEventHandler(esdHandler);
601f27d9 81
0f3a5aa9 82 AliMCEventHandler* mcHandler = new AliMCEventHandler();
83 mgr->SetMCtruthEventHandler(mcHandler);
0f3a5aa9 84 //mcHandler->SetReadTR(readTR);
85
0f3a5aa9 86 AliAODHandler* aodHandler = new AliAODHandler();
87 mgr->SetOutputEventHandler(aodHandler);
88 aodHandler->SetOutputFileName("AliAODs.root");
89
601f27d9 90 // --- Add our task -----------------------------------------------
0f3a5aa9 91 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis/AddTaskFMD.C");
601f27d9 92 AliFMDAnalysisTaskSE *fmdtask = AddTaskFMD(energy, col, bkG);
0f3a5aa9 93
601f27d9 94 // --- Run the analysis --------------------------------------------
0f3a5aa9 95 TStopwatch t;
601f27d9 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();
0f3a5aa9 111}
601f27d9 112//
113// EOF
114//