update of iPhysicsSelection supporting histograms for all trigger types
[u/mrichter/AliRoot.git] / PWG0 / eventStats / run.C
CommitLineData
296dd262 1void Load(const char* taskName, Bool_t debug)
2{
3 TString compileTaskName;
4 compileTaskName.Form("%s.cxx++", taskName);
5 if (debug)
6 compileTaskName += "g";
7
8 if (gProof) {
9 gProof->Load(compileTaskName);
10 } else
11 gROOT->Macro(compileTaskName);
12
13 // Enable debug printouts
14 if (debug)
15 {
16 AliLog::SetClassDebugLevel(taskName, AliLog::kDebug+2);
17 }
18 else
19 AliLog::SetClassDebugLevel(taskName, AliLog::kWarning);
20}
21
22void run(const Char_t* data, Int_t nRuns=20, Int_t offset=0, Bool_t aDebug = kFALSE, Int_t aProof = kFALSE, const char* option = "")
23{
24 // aProof option: 0 no proof
25 // 1 proof with chain
26 // 2 proof with dataset
27 //
28 // option is passed to the task(s)
29
30 if (nRuns < 0)
31 nRuns = 1234567890;
32
33 if (aProof > 0)
34 {
35 TProof::Open("alicecaf");
36 //gProof->SetParallel(2);
37
38 // Enable the needed package
39 if (1)
40 {
41 gProof->UploadPackage("$ALICE_ROOT/STEERBase");
42 gProof->EnablePackage("$ALICE_ROOT/STEERBase");
43 gProof->UploadPackage("$ALICE_ROOT/ESD");
44 gProof->EnablePackage("$ALICE_ROOT/ESD");
45 gProof->UploadPackage("$ALICE_ROOT/AOD");
46 gProof->EnablePackage("$ALICE_ROOT/AOD");
47 gProof->UploadPackage("$ALICE_ROOT/ANALYSIS");
48 gProof->EnablePackage("$ALICE_ROOT/ANALYSIS");
49 gProof->UploadPackage("$ALICE_ROOT/ANALYSISalice");
50 gProof->EnablePackage("$ALICE_ROOT/ANALYSISalice");
51 }
52 else
53 {
54 gProof->UploadPackage("$ALICE_ROOT/AF-v4-18-12-AN.par");
55 gProof->EnablePackage("AF-v4-18-12-AN");
56 }
57
58 gProof->UploadPackage("$ALICE_ROOT/PWG0base");
59 gProof->EnablePackage("$ALICE_ROOT/PWG0base");
60 }
61 else
62 {
63 gSystem->AddIncludePath("-I${ALICE_ROOT}/include/ -I${ALICE_ROOT}/PWG0/ -I${ALICE_ROOT}/PWG0/dNdEta/");
64 gSystem->Load("libVMC");
65 gSystem->Load("libTree");
66 gSystem->Load("libProof");
67 gSystem->Load("libSTEERBase");
68 gSystem->Load("libESD");
69 gSystem->Load("libAOD");
70 gSystem->Load("libANALYSIS");
71 gSystem->Load("libANALYSISalice");
72 gSystem->Load("libPWG0base");
73 gSystem->Load("libPWG0dep");
74 }
75
76 // Create the analysis manager
77 mgr = new AliAnalysisManager;
78
79 // Add ESD handler
80 AliESDInputHandler* esdH = new AliESDInputHandler;
81 esdH->SetInactiveBranches("AliRawDataErrorLogs CaloClusters Cascades EMCALCells EMCALTrigger ESDfriend Kinks Kinks Cascades AliESDTZERO MuonTracks TrdTracks CaloClusters");
82 mgr->SetInputEventHandler(esdH);
83
84 cInput = mgr->GetCommonInputContainer();
85
86 Load("AliEventStatsTask", aDebug);
87 TString optStr(option);
88
89 // remove SAVE option if set
90 Bool_t save = kFALSE;
91 if (optStr.Contains("SAVE"))
92 {
93 optStr = optStr(0,optStr.Index("SAVE")) + optStr(optStr.Index("SAVE")+4, optStr.Length());
94 save = kTRUE;
95 }
96
97 task = new AliEventStatsTask(optStr);
98
99 mgr->AddTask(task);
100
101 // Attach input
102 mgr->ConnectInput(task, 0, cInput);
103
104 // Attach output
105 cOutput = mgr->CreateContainer("cOutput", TList::Class(), AliAnalysisManager::kOutputContainer);
106 mgr->ConnectOutput(task, 1, cOutput);
107
108 // Enable debug printouts
109 if (aDebug)
110 mgr->SetDebugLevel(2);
111
112 // Run analysis
113 mgr->InitAnalysis();
114 mgr->PrintStatus();
115
116 if (aProof == 2)
117 {
118 // process dataset
119
120 mgr->StartAnalysis("proof", data, nRuns, offset);
121
122 if (save)
123 {
124 TString path("maps/");
125 path += TString(data).Tokenize("/")->Last()->GetName();
126
127 gSystem->mkdir(path, kTRUE);
128 gSystem->Rename("event_stats.root", path + "/event_stats.root");
129
130 Printf(">>>>> Moved files to %s", path.Data());
131 }
132 }
133 else if (aProof == 3)
134 {
135 gROOT->ProcessLine(".L CreateChainFromDataSet.C");
136 ds = gProof->GetDataSet(data)->GetStagedSubset();
137 file = TFile::Open("dataset.root", "RECREATE");
138 ds->Write("dataset");
139 file->Close();
140 chain = CreateChainFromDataSet(ds);
141 mgr->StartAnalysis("local", chain, nRuns, offset);
142 }
143 else if (aProof == -1)
144 {
145 gROOT->ProcessLine(".L CreateChainFromDataSet.C");
146 TFile::Open("dataset.root");
147 ds = (TFileCollection*) gFile->Get("dataset");
148 chain = CreateChainFromDataSet(ds);
149 mgr->StartAnalysis("local", chain, nRuns, offset);
150 }
151 else
152 {
153 // Create chain of input files
154 gROOT->LoadMacro("../CreateESDChain.C");
155
156 chain = CreateESDChain(data, nRuns, offset);
157 //chain = CreateChain("TE", data, nRuns, offset);
158
159 mgr->StartAnalysis((aProof > 0) ? "proof" : "local", chain);
160 }
161
162}