- processed events + QA plots on vtx and dndeta added in Event Cuts - small bugfix...
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / TestAOD / runAODProof.C
1 void runAODProof(Int_t c=2, const char * proofMode = "full")
2 { //1 data AOD049
3   //2 MC AOD048
4   //3 data AOD086
5   //4 MC AOD090
6   
7   //  gEnv->SetValue("XSec.GSI.DelegProxy", "2");
8   
9   gSystem->Load("libTree.so");
10   gSystem->Load("libGeom.so");
11    gSystem->Load("libVMC.so");
12    gSystem->Load("libPhysics.so");
13    gSystem->Load("libSTEERBase.so");
14    gSystem->Load("libESD.so");
15    gSystem->Load("libAOD.so");
16    gSystem->Load("libANALYSIS.so");
17    gSystem->Load("libOADB.so");
18    gSystem->Load("libANALYSISalice.so");
19    gSystem->AddIncludePath("-I$ALICE_ROOT/include");
20
21    AliAnalysisAlien * handler = new AliAnalysisAlien("test");
22    handler->SetOverwriteMode();
23    handler->SetRunMode(proofMode);
24    handler->SetProofReset(0);
25    //handler->SetROOTVersion("v5-33-02a");
26    //handler->SetAliROOTVersion("v5-03-11-AN");
27    handler->SetAliROOTVersion("v5-03-17-AN");
28    
29    //handler->SetNproofWorkers(5);
30    //handler->SetNproofWorkersPerSlave(5);
31    //handler->SetProofCluster(Form("%s@alice-caf.cern.ch", gSystem->Getenv("CAFUSER")));
32    handler->SetProofCluster(Form("%s@skaf.saske.sk",gSystem->Getenv("CAFUSER")));
33    // Set handler for Real DATA:
34    if (c == 1){
35      //handler->SetProofDataSet("/alice/data/LHC10h_000138653_p2_AOD049#aodTree");
36      handler->SetProofDataSet("/alice/data/LHC10h_000138653_p2_AOD049#aodTree|/alice/data/LHC10h_000138662_p2_AOD049#aodTree|/alice/data/LHC10h_000138666_p2_AOD049#aodTree|/alice/data/LHC10h_000138795_p2_AOD049#aodTree|/alice/data/LHC10h_000139107_p2_AOD049#aodTree|/alice/data/LHC10h_000139110_p2_AOD049#aodTree");
37    }
38    if (c == 2){
39      handler->SetProofDataSet("/alice/sim/LHC11a10a_000138653_AOD048#aodTree|/alice/sim/LHC11a10a_000138662_AOD048#aodTree|/alice/sim/LHC11a10a_000138666_AOD048#aodTree|/alice/sim/LHC11a10a_000138795_AOD048#aodTree|/alice/sim/LHC11a10a_000139107_AOD048#aodTree|/alice/sim/LHC11a10a_000139110_AOD048#aodTree");      
40    }
41    if (c == 3){
42      handler->SetProofDataSet("/default/lmilano/LHC10h_000138653_AOD086_p2#aodTree|/default/lmilano/LHC10h_000138662_AOD086_p2#aodTree|/default/lmilano/LHC10h_000138666_AOD086_p2#aodTree|/default/lmilano/LHC10h_000139107_AOD086_p2#aodTree");      
43    }
44    if (c == 4){
45      handler->SetProofDataSet("/default/lmilano/LHC11a10a_bis_138653_AOD090#aodTree|/default/lmilano/LHC11a10a_bis_138662_AOD090#aodTree|/default/lmilano/LHC11a10a_bis_138666_AOD090#aodTree|/default/lmilano/LHC11a10a_bis_139107_AOD090#aodTree");      
46    }
47    
48    gROOT->LoadMacro("AliSpectraAODTrackCuts.cxx+g");
49    gROOT->LoadMacro("AliSpectraAODEventCuts.cxx+g");
50    gROOT->LoadMacro("AliSpectraAODHistoManager.cxx+g");
51    gROOT->LoadMacro("AliSpectraAODPID.cxx+g");
52    gROOT->LoadMacro("AliAnalysisTaskSpectraAOD.cxx+g");
53
54    handler->SetAliRootMode("default");
55    handler->SetAdditionalLibs("AliSpectraAODHistoManager.cxx AliSpectraAODHistoManager.h AliSpectraAODPID.cxx AliSpectraAODPID.h AliSpectraAODTrackCuts.cxx AliSpectraAODTrackCuts.h AliSpectraAODEventCuts.cxx AliSpectraAODEventCuts.h AliAnalysisTaskSpectraAOD.cxx AliAnalysisTaskSpectraAOD.h");
56    handler->SetAnalysisSource("Histograms.h HistogramNames.h AliSpectraAODHistoManager.cxx+ AliSpectraAODTrackCuts.cxx+ AliSpectraAODEventCuts.cxx+ AliSpectraAODPID.cxx+ AliAnalysisTaskSpectraAOD.cxx+");
57    //   handler->SetFileForTestMode("filelist.txt"); // list of local files for testing
58    //  handler->SetAliRootMode("");
59    handler->SetClearPackages();
60    
61    AliAnalysisManager *mgr = new AliAnalysisManager("testAnalysis");
62    mgr->SetGridHandler(handler);
63    AliAODInputHandler* aodH = new AliAODInputHandler();
64    mgr->SetInputEventHandler(aodH);
65    
66    // Add PID task
67    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
68    Bool_t isMC = kFALSE;
69    if (c == 2 || c == 4) isMC = kTRUE;   
70    AliAnalysisTask * taskPID = AddTaskPIDResponse(isMC);
71    mgr->AddTask(taskPID);
72    
73    //LOOP OVER SELECTION
74    Double_t CentCutMin[4]={0,0,20,20};
75    Double_t CentCutMax[4]={100,5,40,40};
76    Double_t QvecCutMin[4]={0,0,0,3};
77    Double_t QvecCutMax[4]={100,100,2,100};
78    // Double_t CentCutMin[4]={5,10,20,30};
79    // Double_t CentCutMax[4]={10,20,30,40};
80    // Double_t QvecCutMin[4]={0,0,0,0};
81    // Double_t QvecCutMax[4]={100,100,100,100};
82    using namespace AliSpectraNameSpace;
83    AliSpectraAODPID *pid = new AliSpectraAODPID(kNSigmaTPCTOF); 
84    pid->SetNSigmaCut(3.);
85    
86    for(Int_t iCut=1;iCut<2;iCut++){
87      AliAnalysisTaskSpectraAOD *task = new AliAnalysisTaskSpectraAOD("TaskAODExercise");
88      mgr->AddTask(task);
89      //physics selection
90      task->SelectCollisionCandidates();     
91      // set pid object
92      task->SetPID(pid);
93      // Set the cuts
94      AliSpectraAODEventCuts * vcuts = new AliSpectraAODEventCuts("Event Cuts");
95      AliSpectraAODTrackCuts  * tcuts = new AliSpectraAODTrackCuts("Track Cuts");
96      //if(c==1 || c==2)tcuts->SetTrackType(5); //AOD 046 & 047. Standard Cut with loose DCA
97      if(c==1 || c==2)tcuts->SetTrackType(6); //AOD 046 & 047. Standard Cut with tight DCA
98      if(c==3 || c==4)tcuts->SetTrackType(10); //AOD 086 & 090. Standard Raa cut
99      tcuts->SetEta(.8);
100      //tcuts->SetDCA(.1);
101      tcuts->SetPt(5);
102      tcuts->SetY(.5);
103      tcuts->SetPtTOFMatching(0.6);   
104      tcuts->SetQvecMin(QvecCutMin[iCut]);   
105      tcuts->SetQvecMax(QvecCutMax[iCut]);    
106      vcuts->SetCentralityCutMax(CentCutMax[iCut]);  
107      vcuts->SetCentralityCutMin(CentCutMin[iCut]);
108      task->SetEventCuts(vcuts);
109      task->SetTrackCuts(tcuts);
110      vcuts->PrintCuts();
111      tcuts->PrintCuts();
112      
113      // check for MC or real data
114      if (c == 2 || c == 4)
115        {
116          task->SetIsMC(kTRUE);
117          AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
118          AliAnalysisDataContainer *coutputpt1 = mgr->CreateContainer(Form("chistpt%d",iCut), AliSpectraAODHistoManager::Class(),  AliAnalysisManager::kOutputContainer, 
119                                                                      Form("Pt.AOD.1._MC_Cent%.0fto%.0f_QVec%.1fto%.1f.root",CentCutMin[iCut],CentCutMax[iCut],QvecCutMin[iCut],QvecCutMax[iCut]));
120          AliAnalysisDataContainer *coutputpt2 = mgr->CreateContainer(Form("cvcutpt%d",iCut), AliSpectraAODEventCuts::Class(),    AliAnalysisManager::kOutputContainer, 
121                                                                      Form("Pt.AOD.1._MC_Cent%.0fto%.0f_QVec%.1fto%.1f.root",CentCutMin[iCut],CentCutMax[iCut],QvecCutMin[iCut],QvecCutMax[iCut]));
122          AliAnalysisDataContainer *coutputpt3 = mgr->CreateContainer(Form("ctcutpt%d",iCut), AliSpectraAODTrackCuts::Class(),     AliAnalysisManager::kOutputContainer, 
123                                                                      Form("Pt.AOD.1._MC_Cent%.0fto%.0f_QVec%.1fto%.1f.root",CentCutMin[iCut],CentCutMax[iCut],QvecCutMin[iCut],QvecCutMax[iCut]));
124          AliAnalysisDataContainer *coutputpt4 = mgr->CreateContainer(Form("cpidpt%d",iCut),  AliSpectraAODPID::Class(),     AliAnalysisManager::kOutputContainer, 
125                                                                      Form("Pt.AOD.1._MC_Cent%.0fto%.0f_QVec%.1fto%.1f.root",CentCutMin[iCut],CentCutMax[iCut],QvecCutMin[iCut],QvecCutMax[iCut]));
126        }
127      if (c == 1 || c==3)
128        {
129          AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
130          AliAnalysisDataContainer *coutputpt1 = mgr->CreateContainer(Form("chistpt%d",iCut), AliSpectraAODHistoManager::Class(),  AliAnalysisManager::kOutputContainer, 
131                                                                      Form("Pt.AOD.1._data_ptcut_Cent%.0fto%.0f_QVec%.1fto%.1f.root",CentCutMin[iCut],CentCutMax[iCut],QvecCutMin[iCut],QvecCutMax[iCut]));
132          AliAnalysisDataContainer *coutputpt2 = mgr->CreateContainer(Form("cvcutpt%d",iCut), AliSpectraAODEventCuts::Class(),    AliAnalysisManager::kOutputContainer, 
133                                                                      Form("Pt.AOD.1._data_ptcut_Cent%.0fto%.0f_QVec%.1fto%.1f.root",CentCutMin[iCut],CentCutMax[iCut],QvecCutMin[iCut],QvecCutMax[iCut]));
134          AliAnalysisDataContainer *coutputpt3 = mgr->CreateContainer(Form("ctcutpt%d",iCut), AliSpectraAODTrackCuts::Class(),     AliAnalysisManager::kOutputContainer, 
135                                                                      Form("Pt.AOD.1._data_ptcut_Cent%.0fto%.0f_QVec%.1fto%.1f.root",CentCutMin[iCut],CentCutMax[iCut],QvecCutMin[iCut],QvecCutMax[iCut]));
136          AliAnalysisDataContainer *coutputpt4 = mgr->CreateContainer(Form("cpidpt%d",iCut),  AliSpectraAODPID::Class(),     AliAnalysisManager::kOutputContainer, 
137                                                                      Form("Pt.AOD.1._data_ptcut_Cent%.0fto%.0f_QVec%.1fto%.1f.root",CentCutMin[iCut],CentCutMax[iCut],QvecCutMin[iCut],QvecCutMax[iCut]));
138          
139        }
140      mgr->ConnectInput(task, 0, cinput);
141      mgr->ConnectOutput(task, 1, coutputpt1);
142      mgr->ConnectOutput(task, 2, coutputpt2);
143      mgr->ConnectOutput(task, 3, coutputpt3);
144      mgr->ConnectOutput(task, 4, coutputpt4);
145    }
146    mgr->SetDebugLevel(2);
147    
148    if (!mgr->InitAnalysis()) return;
149    mgr->PrintStatus();
150    mgr->StartAnalysis("proof");
151 }