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