1 void runProtonAnalysis(const char* esdAnalysisType = "TPC",) {
2 //Macro to run the proton analysis tested for local, proof & GRID.
3 //Local: Takes three arguments, the analysis mode, the type of the ESD
4 // analysis and the path where the tag and ESD or AOD files reside.
5 //Interactive: Takes three arguments, the analysis mode, the type of the ESD
6 // analysis and the name of the collection of tag files.
7 //Batch: Takes three arguments, the analysis mode, the type of the ESD
8 // analysis and the name of the collection file with the event list
10 //Proof: Takes four arguments, the analysis mode, the number of events,
11 // the dataset name and the analysis type in case of ESD.
13 //Analysis mode can be: "MC", "ESD", "AOD"
14 //ESD analysis type can be one of the three: "TPC", "Hybrid", "Global"
18 //runLocal("ESD",esdAnalysisType,"/home/pchrist/ALICE/Alien/Tutorial/November2007/Tags");
19 //runInteractive("ESD",esdAnalysisType,"tag.xml");
20 //runBatch("ESD",esdAnalysisType,"wn.xml");
23 "/COMMON/COMMON/LHC08c11_10TeV_0.5T",
30 //_________________________________________________//
31 void runLocal(const char* mode = "ESD",
32 const char* analysisType = 0x0,
33 const char* path = "/home/pchrist/ALICE/Alien/Tutorial/November2007/Tags") {
38 TString outputFilename = "Protons."; outputFilename += mode;
40 outputFilename += "."; outputFilename += analysisType;
42 outputFilename += ".root";
44 //____________________________________________________//
45 //_____________Setting up the par files_______________//
46 //____________________________________________________//
47 setupPar("STEERBase");
48 gSystem->Load("libSTEERBase.so");
50 gSystem->Load("libVMC.so");
51 gSystem->Load("libESD.so");
53 gSystem->Load("libAOD.so");
55 gSystem->Load("libANALYSIS.so");
56 setupPar("ANALYSISalice");
57 gSystem->Load("libANALYSISalice.so");
58 setupPar->UploadPackage("CORRFW.par");
59 gSystem->EnablePackage("CORRFW");
60 setupPar("PWG2spectra");
61 gSystem->Load("libPWG2spectra.so");
62 //____________________________________________________//
64 //____________________________________________//
65 AliTagAnalysis *tagAnalysis = new AliTagAnalysis("ESD");
66 tagAnalysis->ChainLocalTags(path);
68 AliRunTagCuts *runCuts = new AliRunTagCuts();
69 AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
70 AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
71 AliEventTagCuts *evCuts = new AliEventTagCuts();
74 chain = tagAnalysis->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
75 chain->SetBranchStatus("*Calo*",0);
77 //____________________________________________//
78 gROOT->LoadMacro("AliAnalysisTaskProtons.cxx++");
79 //____________________________________________//
80 // Make the analysis manager
81 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
82 AliVEventHandler* esdH = new AliESDInputHandler;
83 mgr->SetInputEventHandler(esdH);
85 AliMCEventHandler *mc = new AliMCEventHandler();
86 mgr->SetMCtruthEventHandler(mc);
89 //____________________________________________//
91 AliAnalysisTaskProtons *taskProtons = new AliAnalysisTaskProtons("TaskProtons");
92 taskProtons->SetType(mode);
93 taskProtons->SetTriggerMode(AliAnalysisTaskProtons::kMB2);
94 switch(analysisType) {
96 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kTPC);
99 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kHybrid);
102 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kGlobal);
107 taskProtons->SetAcceptedVertexDiamond(5.,5.,15.);
108 //Momentum dependent priors
109 /*TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
110 TF1 *fitElectrons = (TF1 *)f->Get("fitElectrons");
111 TF1 *fitMuons = (TF1 *)f->Get("fitMuons");
112 TF1 *fitPions = (TF1 *)f->Get("fitPions");
113 TF1 *fitKaons = (TF1 *)f->Get("fitKaons");
114 TF1 *fitProtons = (TF1 *)f->Get("fitProtons");
115 taskProtons->SetPriorProbabilityFunctions(fitElectrons,
120 mgr->AddTask(taskProtons);
122 // Create containers for input/output
123 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
124 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("outputList1",
126 AliAnalysisManager::kOutputCont
127 outputFilename.Data());
129 //____________________________________________//
130 mgr->ConnectInput(taskProtons,0,cinput1);
131 mgr->ConnectOutput(taskProtons,0,coutput1);
132 if (!mgr->InitAnalysis()) return;
134 mgr->StartAnalysis("local",chain);
140 //_________________________________________________//
141 void runInteractive(const char* mode = "ESD",
142 const char* analysisType = 0x0,
143 const char* collectionName = "tag.xml") {
146 gSystem->Load("libProofPlayer.so");
148 TString smode = mode;
149 TString outputFilename = "Protons."; outputFilename += mode;
151 outputFilename += "."; outputFilename += analysisType;
153 outputFilename += ".root";
155 printf("*** Connect to AliEn ***\n");
156 TGrid::Connect("alien://");
158 //____________________________________________________//
159 //_____________Setting up the par files_______________//
160 //____________________________________________________//
161 setupPar("STEERBase");
162 gSystem->Load("libSTEERBase.so");
164 gSystem->Load("libVMC.so");
165 gSystem->Load("libESD.so");
167 gSystem->Load("libAOD.so");
168 setupPar("ANALYSIS");
169 gSystem->Load("libANALYSIS.so");
170 setupPar("ANALYSISalice");
171 gSystem->Load("libANALYSISalice.so");
172 setupPar->UploadPackage("CORRFW.par");
173 gSystem->EnablePackage("CORRFW");
174 setupPar("PWG2spectra");
175 gSystem->Load("libPWG2spectra.so");
176 //____________________________________________________//
178 //____________________________________________//
179 AliTagAnalysis *tagAnalysis = new AliTagAnalysis("ESD");
181 AliRunTagCuts *runCuts = new AliRunTagCuts();
182 AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
183 AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
184 AliEventTagCuts *evCuts = new AliEventTagCuts();
187 TAlienCollection* coll = TAlienCollection::Open(collectionName);
188 TGridResult* TagResult = coll->GetGridResult("",0,0);
189 tagAnalysis->ChainGridTags(TagResult);
191 chain = tagAnalysis->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
192 chain->SetBranchStatus("*Calo*",0);
194 //____________________________________________//
195 gROOT->LoadMacro("AliAnalysisTaskProtons.cxx++");
196 //____________________________________________//
197 // Make the analysis manager
198 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
199 AliVEventHandler* esdH = new AliESDInputHandler;
200 mgr->SetInputEventHandler(esdH);
202 AliMCEventHandler *mc = new AliMCEventHandler();
203 mgr->SetMCtruthEventHandler(mc);
206 //____________________________________________//
208 AliAnalysisTaskProtons *taskProtons = new AliAnalysisTaskProtons("TaskProtons");
209 taskProtons->SetType(mode);
210 taskProtons->SetTriggerMode(AliAnalysisTaskProtons::kMB2);
211 switch(analysisType) {
213 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kTPC);
216 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kHybrid);
219 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kGlobal);
224 taskProtons->SetAcceptedVertexDiamond(5.,5.,15.);
225 //Momentum dependent priors
226 /*TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
227 TF1 *fitElectrons = (TF1 *)f->Get("fitElectrons");
228 TF1 *fitMuons = (TF1 *)f->Get("fitMuons");
229 TF1 *fitPions = (TF1 *)f->Get("fitPions");
230 TF1 *fitKaons = (TF1 *)f->Get("fitKaons");
231 TF1 *fitProtons = (TF1 *)f->Get("fitProtons");
232 taskProtons->SetPriorProbabilityFunctions(fitElectrons,
237 mgr->AddTask(taskProtons);
239 // Create containers for input/output
240 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
241 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("outputList1",
243 AliAnalysisManager::kOutputCont
244 outputFilename.Data());
246 //____________________________________________//
247 mgr->ConnectInput(taskProtons,0,cinput1);
248 mgr->ConnectOutput(taskProtons,0,coutput1);
249 if (!mgr->InitAnalysis()) return;
251 mgr->StartAnalysis("local",chain);
257 //_________________________________________________//
258 void runBatch(const char* mode = "ESD",
259 const char* analysisType = 0x0,
260 const char *collectionfile = "wn.xml") {
264 TString smode = mode;
265 TString outputFilename = "Protons."; outputFilename += mode;
267 outputFilename += "."; outputFilename += analysisType;
269 outputFilename += ".root";
271 printf("*** Connect to AliEn ***\n");
272 TGrid::Connect("alien://");
273 gSystem->Load("libProofPlayer.so");
275 //____________________________________________________//
276 //_____________Setting up the par files_______________//
277 //____________________________________________________//
278 setupPar("STEERBase");
279 gSystem->Load("libSTEERBase.so");
281 gSystem->Load("libVMC.so");
282 gSystem->Load("libESD.so");
284 gSystem->Load("libAOD.so");
285 setupPar("ANALYSIS");
286 gSystem->Load("libANALYSIS.so");
287 setupPar("ANALYSISalice");
288 gSystem->Load("libANALYSISalice.so");
289 setupPar->UploadPackage("CORRFW.par");
290 gSystem->EnablePackage("CORRFW");
291 setupPar("PWG2spectra");
292 gSystem->Load("libPWG2spectra.so");
293 //____________________________________________________//
295 //____________________________________________//
296 //Usage of event tags
297 AliTagAnalysis *tagAnalysis = new AliTagAnalysis();
299 chain = tagAnalysis->GetChainFromCollection(collectionfile,"esdTree");
300 chain->SetBranchStatus("*Calo*",0);
302 //____________________________________________//
303 gROOT->LoadMacro("AliAnalysisTaskProtons.cxx++");
304 //____________________________________________//
305 // Make the analysis manager
306 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
307 AliVEventHandler* esdH = new AliESDInputHandler;
308 mgr->SetInputEventHandler(esdH);
310 AliMCEventHandler *mc = new AliMCEventHandler();
311 mgr->SetMCtruthEventHandler(mc);
314 //____________________________________________//
316 AliAnalysisTaskProtons *taskProtons = new AliAnalysisTaskProtons("TaskProtons");
317 taskProtons->SetType(mode);
318 taskProtons->SetTriggerMode(AliAnalysisTaskProtons::kMB2);
319 switch(analysisType) {
321 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kTPC);
324 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kHybrid);
327 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kGlobal);
332 taskProtons->SetAcceptedVertexDiamond(5.,5.,15.);
333 //Momentum dependent priors
334 /*TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
335 TF1 *fitElectrons = (TF1 *)f->Get("fitElectrons");
336 TF1 *fitMuons = (TF1 *)f->Get("fitMuons");
337 TF1 *fitPions = (TF1 *)f->Get("fitPions");
338 TF1 *fitKaons = (TF1 *)f->Get("fitKaons");
339 TF1 *fitProtons = (TF1 *)f->Get("fitProtons");
340 taskProtons->SetPriorProbabilityFunctions(fitElectrons,
345 mgr->AddTask(taskProtons);
347 // Create containers for input/output
348 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
349 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("outputList1",
350 TList::Class(),AliAnalysisManager::kOutputCont
351 outputFilename.Data());
353 //____________________________________________//
354 mgr->ConnectInput(taskProtons,0,cinput1);
355 mgr->ConnectOutput(taskProtons,0,coutput1);
356 if (!mgr->InitAnalysis()) return;
358 mgr->StartAnalysis("grid",chain);
364 //_________________________________________________//
365 void runProof(const char* mode = "ESD",
367 const char* dataset = 0x0,
368 const char* analysisType = 0x0) {
372 TString smode = mode;
373 TString outputFilename = "Protons."; outputFilename += mode;
375 outputFilename += "."; outputFilename += analysisType;
377 outputFilename += ".root";
379 printf("****** Connect to PROOF *******\n");
380 TProof::Open("alicecaf.cern.ch");
381 gProof->SetParallel();
383 // Enable the Analysis Package
384 gProof->UploadPackage("STEERBase.par");
385 gProof->EnablePackage("STEERBase");
386 gProof->UploadPackage("ESD.par");
387 gProof->EnablePackage("ESD");
388 gProof->UploadPackage("AOD.par");
389 gProof->EnablePackage("AOD");
390 gProof->UploadPackage("ANALYSIS.par");
391 gProof->EnablePackage("ANALYSIS");
392 gProof->UploadPackage("ANALYSISalice.par");
393 gProof->EnablePackage("ANALYSISalice");
394 gProof->UploadPackage("CORRFW.par");
395 gProof->EnablePackage("CORRFW");
396 gProof->UploadPackage("PWG2spectra.par");
397 gProof->EnablePackage("PWG2spectra");
399 //____________________________________________//
400 gProof->Load("AliAnalysisTaskProtons.cxx++");
401 //____________________________________________//
403 //____________________________________________//
404 // Make the analysis manager
405 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
406 AliVEventHandler* esdH = new AliESDInputHandler;
407 mgr->SetInputEventHandler(esdH);
409 AliMCEventHandler *mc = new AliMCEventHandler();
410 mgr->SetMCtruthEventHandler(mc);
412 //____________________________________________//
414 AliAnalysisTaskProtons *taskProtons = new AliAnalysisTaskProtons("TaskProtons");
415 taskProtons->SetType(mode);
416 taskProtons->SetTriggerMode(AliAnalysisTaskProtons::kMB2);
417 switch(analysisType) {
419 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kTPC);
422 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kHybrid);
425 taskProtons->SetAnalysisMode(AliAnalysisTaskProtons::kGlobal);
430 taskProtons->SetAcceptedVertexDiamond(5.,5.,15.);
431 //Momentum dependent priors
432 /*TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
433 TF1 *fitElectrons = (TF1 *)f->Get("fitElectrons");
434 TF1 *fitMuons = (TF1 *)f->Get("fitMuons");
435 TF1 *fitPions = (TF1 *)f->Get("fitPions");
436 TF1 *fitKaons = (TF1 *)f->Get("fitKaons");
437 TF1 *fitProtons = (TF1 *)f->Get("fitProtons");
438 taskProtons->SetPriorProbabilityFunctions(fitElectrons,
443 mgr->AddTask(taskProtons);
445 // Create containers for input/output
446 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
447 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("outputList1",
449 AliAnalysisManager::kOutputContainer,
450 outputFilename.Data());
452 //____________________________________________//
453 mgr->ConnectInput(taskProtons,0,cinput1);
454 mgr->ConnectOutput(taskProtons,0,coutput1);
455 if (!mgr->InitAnalysis()) return;
459 mgr->StartAnalysis("proof",dataset,stats);
461 // You should get this macro and the txt file from:
462 // http://aliceinfo.cern.ch/Offline/Analysis/CAF/
463 gROOT->LoadMacro("CreateESDChain.C");
465 chain = CreateESDChain("ESD82XX_30K.txt",stats);
466 chain->SetBranchStatus("*Calo*",0);
468 mgr->StartAnalysis("proof",chain);
475 //_________________________________________________//
476 Int_t setupPar(const char* pararchivename) {
480 if (pararchivename) {
481 char processline[1024];
482 sprintf(processline,".! tar xvzf %s.par",pararchivename);
483 gROOT->ProcessLine(processline);
484 const char* ocwd = gSystem->WorkingDirectory();
485 gSystem->ChangeDirectory(pararchivename);
487 // check for BUILD.sh and execute
488 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
489 printf("*******************************\n");
490 printf("*** Building PAR archive ***\n");
491 printf("*******************************\n");
493 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
494 Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
498 // check for SETUP.C and execute
499 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
500 printf("*******************************\n");
501 printf("*** Setup PAR archive ***\n");
502 printf("*******************************\n");
503 gROOT->Macro("PROOF-INF/SETUP.C");
506 gSystem->ChangeDirectory("../");