better defaults
[u/mrichter/AliRoot.git] / PWG2 / runProtonAnalysisQA.C
CommitLineData
9e2392b0 1void runProtonAnalysisQA(const char *analysisType = "TPC") {
2 //Macro to run the proton QA analysis tested for local, proof & GRID.
3 //Proof: Takes three arguments, the number of events, the dataset name
4 // and the analysis type
5 //Interactive: Takes two arguments, the name of the collection file with
6 // the event list for each file and the analysis type
7 //Analysis type can be one of the three: "TPC", "Hybrid", "Global"
7b59a00b 8 TStopwatch timer;
9 timer.Start();
10
9e2392b0 11 runProof(200000,"/COMMON/COMMON/LHC08c11_10TeV_0.5T",analysisType);
12 //runInteractive("wn.xml",analysisType);
7b59a00b 13
14 timer.Stop();
15 timer.Print();
16}
17
18//_________________________________________________//
9e2392b0 19void runInteractive(const char *collectionfile,
20 const char *analysisType) {
21 TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
22 outputFilename1 += ".root"; //main QA file
23 TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
24 outputFilename2 += ".root"; //MC process QA
25 TString outputFilename3 = "Protons.QA.Histograms.";
26 outputFilename3 += analysisType;
27 outputFilename3 += ".root"; //Accepted cut distributions
28 TString outputFilename4 = "Protons.Efficiency.";
29 outputFilename4 += analysisType;
30 outputFilename4 += ".root"; //Reco and PID efficiency
e2f97a75 31
32 TGrid::Connect("alien://");
33
34 //Setup the par files
35 setupPar("STEERBase");
36 gSystem->Load("libSTEERBase.so");
37 setupPar("ESD");
38 gSystem->Load("libESD.so");
39 setupPar("AOD");
40 gSystem->Load("libAOD.so");
41 setupPar("ANALYSIS");
42 gSystem->Load("libANALYSIS.so");
43 setupPar("ANALYSISalice");
44 gSystem->Load("libANALYSISalice.so");
45 setupPar("CORRFW");
46 gSystem->Load("libCORRFW.so");
47 setupPar("PWG2spectra");
48 gSystem->Load("libPWG2spectra.so");
49
50 gROOT->LoadMacro("AliAnalysisTaskProtonsQA.cxx+");
51 //____________________________________________//
52 //Usage of event tags
53 AliTagAnalysis *analysis = new AliTagAnalysis();
54 TChain *chain = 0x0;
55 chain = analysis->GetChainFromCollection(collectionfile,"esdTree");
56
57 //____________________________________________//
58 // Make the analysis manager
59 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
60 AliVEventHandler* esdH = new AliESDInputHandler;
61 mgr->SetInputEventHandler(esdH);
62 AliMCEventHandler *mc = new AliMCEventHandler();
63 mgr->SetMCtruthEventHandler(mc);
7b59a00b 64
e2f97a75 65 //____________________________________________//
66 // 1st Proton task
67 AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
5429dd65 68 taskProtonsQA->SetTriggerMode(AliAnalysisTaskProtonsQA::kMB2);
9e2392b0 69 switch(analysisType) {
70 case "TPC":
71 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kTPC);
72 break;
73 case "Hybrid":
74 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kHybrid);
75 break;
76 case "Global":
77 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kGlobal);
78 break;
79 default:
80 break;
81 }
5429dd65 82 taskProtonsQA->SetAcceptedVertexDiamond(5.,5.,15.);
e2f97a75 83 mgr->AddTask(taskProtonsQA);
84
85 // Create containers for input/output
8a546c82 86 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
e2f97a75 87 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList",
88 TList::Class(),
89 AliAnalysisManager::kOutputContainer,
90 outputFilename1.Data());
91 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("pdgCodeList",
92 TList::Class(),
93 AliAnalysisManager::kOutputContainer,
94 outputFilename2.Data());
95 AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("mcProcessList",
96 TList::Class(),
97 AliAnalysisManager::kOutputContainer,
98 outputFilename2.Data());
99 AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("acceptedCutList",
100 TList::Class(),
101 AliAnalysisManager::kOutputContainer,
102 outputFilename3.Data());
103 AliAnalysisDataContainer *coutput5 = mgr->CreateContainer("acceptedDCAList",
104 TList::Class(),
105 AliAnalysisManager::kOutputContainer,
106 outputFilename3.Data());
107 AliAnalysisDataContainer *coutput6 = mgr->CreateContainer("efficiencyList",
108 TList::Class(),
109 AliAnalysisManager::kOutputContainer,
110 outputFilename4.Data());
111
112 //____________________________________________//
113 mgr->ConnectInput(taskProtonsQA,0,cinput1);
114 mgr->ConnectOutput(taskProtonsQA,0,coutput1);
115 mgr->ConnectOutput(taskProtonsQA,1,coutput2);
116 mgr->ConnectOutput(taskProtonsQA,2,coutput3);
117 mgr->ConnectOutput(taskProtonsQA,3,coutput4);
118 mgr->ConnectOutput(taskProtonsQA,4,coutput5);
119 mgr->ConnectOutput(taskProtonsQA,5,coutput6);
120 if (!mgr->InitAnalysis()) return;
121 mgr->PrintStatus();
122 mgr->StartAnalysis("local",chain);
123}
124
125//_________________________________________________//
9e2392b0 126void runProof(Int_t stats = 0,
127 const char* dataset = 0x0,
128 const char *analysisType) {
129 TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
130 outputFilename1 += ".root"; //main QA file
131 TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
132 outputFilename2 += ".root"; //MC process QA
133 TString outputFilename3 = "Protons.QA.Histograms.";
134 outputFilename3 += analysisType;
135 outputFilename3 += ".root"; //Accepted cut distributions
136 TString outputFilename4 = "Protons.Efficiency.";
137 outputFilename4 += analysisType;
138 outputFilename4 += ".root"; //Reco and PID efficiency
7b59a00b 139
140 printf("****** Connect to PROOF *******\n");
96f84c25 141 TProof::Open("alicecaf.cern.ch");
7b59a00b 142 gProof->SetParallel();
143
144 // Enable the Analysis Package
145 gProof->UploadPackage("STEERBase.par");
146 gProof->EnablePackage("STEERBase");
147 gProof->UploadPackage("ESD.par");
148 gProof->EnablePackage("ESD");
149 gProof->UploadPackage("AOD.par");
150 gProof->EnablePackage("AOD");
151 gProof->UploadPackage("ANALYSIS.par");
152 gProof->EnablePackage("ANALYSIS");
153 gProof->UploadPackage("ANALYSISalice.par");
154 gProof->EnablePackage("ANALYSISalice");
f99662ca 155 gProof->UploadPackage("CORRFW.par");
156 gProof->EnablePackage("CORRFW");
7b59a00b 157 gProof->UploadPackage("PWG2spectra.par");
158 gProof->EnablePackage("PWG2spectra");
159
160 gProof->Load("AliAnalysisTaskProtonsQA.cxx++");
161
162 //____________________________________________//
163 // Make the analysis manager
164 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
165 AliVEventHandler* esdH = new AliESDInputHandler;
166 mgr->SetInputEventHandler(esdH);
167 AliMCEventHandler *mc = new AliMCEventHandler();
168 mgr->SetMCtruthEventHandler(mc);
169
170 //____________________________________________//
171 // 1st Proton task
172 AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
5429dd65 173 taskProtonsQA->SetTriggerMode(AliAnalysisTaskProtonsQA::kMB2);
9e2392b0 174 switch(analysisType) {
175 case "TPC":
176 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kTPC);
177 break;
178 case "Hybrid":
179 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kHybrid);
180 break;
181 case "Global":
182 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kGlobal);
183 break;
184 default:
185 break;
186 }
5429dd65 187 taskProtonsQA->SetAcceptedVertexDiamond(5.,5.,15.);
7b59a00b 188 mgr->AddTask(taskProtonsQA);
189
190 // Create containers for input/output
8a546c82 191 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
5b8133c7 192 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList",
f99662ca 193 TList::Class(),
194 AliAnalysisManager::kOutputContainer,
d4733690 195 outputFilename1.Data());
5b8133c7 196 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("pdgCodeList",
d4733690 197 TList::Class(),
198 AliAnalysisManager::kOutputContainer,
199 outputFilename2.Data());
5b8133c7 200 AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("mcProcessList",
d4733690 201 TList::Class(),
202 AliAnalysisManager::kOutputContainer,
0008a5a6 203 outputFilename2.Data());
5b8133c7 204 AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("acceptedCutList",
205 TList::Class(),
206 AliAnalysisManager::kOutputContainer,
207 outputFilename3.Data());
208 AliAnalysisDataContainer *coutput5 = mgr->CreateContainer("acceptedDCAList",
209 TList::Class(),
210 AliAnalysisManager::kOutputContainer,
211 outputFilename3.Data());
e2f97a75 212 AliAnalysisDataContainer *coutput6 = mgr->CreateContainer("efficiencyList",
213 TList::Class(),
214 AliAnalysisManager::kOutputContainer,
215 outputFilename4.Data());
7b59a00b 216
217 //____________________________________________//
218 mgr->ConnectInput(taskProtonsQA,0,cinput1);
219 mgr->ConnectOutput(taskProtonsQA,0,coutput1);
d4733690 220 mgr->ConnectOutput(taskProtonsQA,1,coutput2);
221 mgr->ConnectOutput(taskProtonsQA,2,coutput3);
5b8133c7 222 mgr->ConnectOutput(taskProtonsQA,3,coutput4);
223 mgr->ConnectOutput(taskProtonsQA,4,coutput5);
e2f97a75 224 mgr->ConnectOutput(taskProtonsQA,5,coutput6);
7b59a00b 225 if (!mgr->InitAnalysis()) return;
226 mgr->PrintStatus();
227
228 if(dataset)
229 mgr->StartAnalysis("proof",dataset,stats);
230 else {
231 // You should get this macro and the txt file from:
232 // http://aliceinfo.cern.ch/Offline/Analysis/CAF/
233 gROOT->LoadMacro("CreateESDChain.C");
234 TChain* chain = 0x0;
235 chain = CreateESDChain("ESD82XX_30K.txt",stats);
236 chain->SetBranchStatus("*Calo*",0);
237
238 mgr->StartAnalysis("proof",chain);
f99662ca 239 //mgr->StartAnalysis("local",chain);
7b59a00b 240 }
7b59a00b 241}
242
243//_________________________________________________//
244Int_t setupPar(const char* pararchivename) {
245 ///////////////////
246 // Setup PAR File//
247 ///////////////////
248 if (pararchivename) {
249 char processline[1024];
250 sprintf(processline,".! tar xvzf %s.par",pararchivename);
3e23254a 251 //gROOT->ProcessLine(processline);
7b59a00b 252 const char* ocwd = gSystem->WorkingDirectory();
253 gSystem->ChangeDirectory(pararchivename);
254
255 // check for BUILD.sh and execute
256 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
257 printf("*******************************\n");
258 printf("*** Building PAR archive ***\n");
259 printf("*******************************\n");
260
261 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
262 Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
263 return -1;
264 }
265 }
266 // check for SETUP.C and execute
267 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
268 printf("*******************************\n");
269 printf("*** Setup PAR archive ***\n");
270 printf("*******************************\n");
271 gROOT->Macro("PROOF-INF/SETUP.C");
272 }
273
274 gSystem->ChangeDirectory("../");
275 }
276 return 1;
277}