af2d01518d0195e5b9d559203a81d21e089d2b16
[u/mrichter/AliRoot.git] / PWGLF / totEt / macros / runHadEt.C
1 //Create by Christine Nattrass, Rebecca Scott, Irakli Martashvili
2 //University of Tennessee at Knoxville
3
4 //by default this runs locally
5 //With the argument true this submits jobs to the grid
6 //As written this requires an xml script tag.xml in the ~/et directory on the grid to submit jobs
7 void runHadEt(bool submit = false, bool data = false, Int_t dataset = 20100, Int_t test = 1, Int_t material = 0, Bool_t altV0Scale = kFALSE, bool runCompiledVersion = kFALSE, int simflag = 0) {
8     TStopwatch timer;
9     timer.Start();
10     gSystem->Load("libTree");
11     gSystem->Load("libGeom");
12     gSystem->Load("libVMC");
13     gSystem->Load("libPhysics");
14     gSystem->Load("libXMLIO");
15
16     gSystem->Load("libSTEERBase");
17     gSystem->Load("libESD");
18     gSystem->Load("libAOD");
19
20     gSystem->Load("libANALYSIS");
21     gSystem->Load("libOADB");
22     gSystem->Load("libANALYSISalice");
23     gSystem->Load("libPWGUDbase");
24
25     gSystem->AddIncludePath("-I$ALICE_ROOT/include");
26     gSystem->AddIncludePath("-I$ALICE_ROOT/PWGUD/base");
27     if(runCompiledVersion){
28       cout<<"Using compiled version"<<endl;
29       gSystem->Load("libPWGLFtotEt");
30     }
31     else{
32       cout<<"Not using compiled version"<<endl;
33       gROOT->ProcessLine(".L AliAnalysisEtCuts.cxx+g");
34       gROOT->ProcessLine(".L AliAnalysisHadEtCorrections.cxx+g");
35       gROOT->ProcessLine(".L AliAnalysisEtCommon.cxx+g");
36       gROOT->ProcessLine(".L AliAnalysisHadEt.cxx+g");
37       gROOT->ProcessLine(".L AliAnalysisHadEtMonteCarlo.cxx+g");
38       gROOT->ProcessLine(".L AliAnalysisHadEtReconstructed.cxx+g");
39       gROOT->ProcessLine(".L AliAnalysisTaskTransverseEnergy.cxx+g");
40       gROOT->ProcessLine(".L AliAnalysisTaskHadEt.cxx+g");
41     }
42
43   char *kTreeName = "esdTree" ;
44   TChain * chain   = new TChain(kTreeName,"myESDTree") ;
45   if(submit){      
46     gSystem->Load("libNetx") ;
47     gSystem->Load("libgapiUI");
48     gSystem->Load("libRAliEn");
49     TGrid::Connect("alien://") ;
50   }
51   bool PbPb = false;
52   if(dataset ==20100 || dataset==2011){
53     bool PbPb = true;
54     if(data){
55       chain->Add("/data/LHC10h/pass2_rev15/10000137366041.860/AliESDs.root");//Data Pb+Pb
56       chain->Add("/data/LHC10h/pass2_rev15/10000137366041.870/AliESDs.root");//Data Pb+Pb
57       chain->Add("/data/LHC10h/pass2_rev15/10000137366041.880/AliESDs.root");//Data Pb+Pb
58       chain->Add("/data/LHC10h/pass2_rev15/10000137366041.890/AliESDs.root");//Data Pb+Pb
59       chain->Add("/data/LHC10h/pass2_rev15/10000137366041.900/AliESDs.root");//Data Pb+Pb
60     }
61     else{
62       //chain->Add("/data/LHC12d3/168464/201/AliESDs.root");//HIJING with embedded signals - works, full acceptance
63       //chain->Add("/data/LHC10h2/137161/001/AliESDs.root");//DPMJET
64       chain->Add("/data/LHC11a9a/137366/001/AliESDs.root");//AMPT
65 //       chain->Add("/data/LHC10h8/137161/999/AliESDs.root");//Hijing Pb+Pb
66 //       chain->Add("/data/LHC10h8/137161/111/AliESDs.root");//Hijing Pb+Pb
67 //       chain->Add("/data/LHC10h8/137161/222/AliESDs.root");//Hijing Pb+Pb
68       //chain->Add("/data/LHC11a4_bis/137161/999/AliESDs.root");//Hijing Pb+Pb
69       //chain->Add("/data/LHC10h12/999/AliESDs.root");//Hijing Pb+Pb
70     }
71   } 
72   else{
73      if(dataset==2013){//pPb 5 TeV
74        if(data){
75          chain->Add("/data/LHC13b/13000195483082.95/AliESDs.root");
76        }
77        else{
78          //cout<<"Yes I am analyzing the correct file"<<endl;
79          //chain->Add("/data/LHC12c1b/111/AliESDs.root");
80          chain->Add("/data/LHC13b3/9999/AliESDs.root");
81        }
82      }
83      else{
84        if(data){
85          //chain->Add("/data/LHC10dpass2/10000126403050.70/AliESDs.root");//data
86          //chain->Add("/data/LHC11a/11000146856042.90/AliESDs.root");//data pp 2.76 TeV w/SDD pass 2
87          //chain->Add("/data/LHC11a/11000146860043.90/AliESDs.root");//data pp 2.76 TeV w/SDD pass 3
88          chain->Add("/data/LHC10c/10000120683048.90/AliESDs.root");//Data Pb+Pb
89        }
90        else{
91          cerr<<"Hello I am here 75"<<endl;
92          //chain->Add("/data/LHC10d15/1821/AliESDs.root");//simulation p+p
93          chain->Add("/data/LHC11b10a/001/AliESDs.root");
94        }
95      }
96   }
97
98   // Make the analysis manager
99   AliAnalysisManager *mgr = new AliAnalysisManager("TotEtManager");
100   if(submit){
101
102     gROOT->LoadMacro("CreateAlienHandlerHadEt.C");
103     AliAnalysisGrid *alienHandler = CreateAlienHandlerHadEt(dataset,data,test,material,altV0Scale,runCompiledVersion,simflag);//integer dataset, boolean isData, bool submit-in-test-mode, bool use alternatve V0 scaling
104       if (!alienHandler) return;
105       mgr->SetGridHandler(alienHandler);
106   }
107
108   cerr<<"Hello I am here 91"<<endl;
109   AliVEventHandler* esdH = new AliESDInputHandler;
110   mgr->SetInputEventHandler(esdH);
111   AliMCEventHandler* handler = new AliMCEventHandler;
112   if(!data){
113     handler->SetReadTR(kFALSE);
114     mgr->SetMCtruthEventHandler(handler);
115   }
116
117
118   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
119   AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(!data);
120   if(!physSelTask) { Printf("no physSelTask"); return; }
121   AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection();
122   //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769");
123   //physSelTask->AddCollisionTriggerClass("kMB");// #3119 #769");
124
125   cerr<<"Hello I am here 108"<<endl;
126
127   gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C");
128
129   AliCentralitySelectionTask *centTask;
130   
131   if(PbPb){
132     AliCentralitySelectionTask *centTask = AddTaskCentrality();
133    if(!data){
134      cout<<"Setting up centrality for MC"<<endl;
135      centTask->SetMCInput();
136    }
137    else{
138      cout<<"Setting up centrality for data"<<endl;
139    }
140   }
141   Int_t pass = 2;
142    if(dataset==20100){//PbPb 2.76 TeV
143      if(simflag==0){
144        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.ForData.root","corrections.root",kTRUE);}
145        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.ForSimulations.root","corrections.root",kTRUE);}
146        if(material==11){//AMPT only available for this run
147          cout<<"Running AMPT"<<endl;
148          gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.137366.ForData.root","corrections.root",kTRUE);
149        }
150      }
151      if(simflag==1){
152        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138442.ForData.root","corrections.root",kTRUE);}
153        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138442.ForSimulations.root","corrections.root",kTRUE);}
154      }
155      if(simflag==2){
156        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138364.ForData.root","corrections.root",kTRUE);}
157        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138364.ForSimulations.root","corrections.root",kTRUE);}
158      }
159      if(simflag==3){
160        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138396.ForData.root","corrections.root",kTRUE);}
161        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138396.ForSimulations.root","corrections.root",kTRUE);}
162      }
163      if(simflag==4){
164        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137722.ForData.root","corrections.root",kTRUE);}
165        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137722.ForSimulations.root","corrections.root",kTRUE);}
166      }
167      if(simflag==5){
168        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137366.ForData.root","corrections.root",kTRUE);}
169        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137366.ForSimulations.root","corrections.root",kTRUE);}
170      }
171      if(simflag==6){
172        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137161.ForData.root","corrections.root",kTRUE);}
173        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137161.ForSimulations.root","corrections.root",kTRUE);}
174      }
175      gSystem->CopyFile("ConfigHadEtMonteCarloPbPb.C","ConfigHadEtMonteCarlo.C",kTRUE);
176      gSystem->CopyFile("ConfigHadEtReconstructedPbPb.C","ConfigHadEtReconstructed.C",kTRUE);
177      if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.ForData.root","corrections.root",kTRUE);}
178      else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.ForSimulations.root","corrections.root",kTRUE);}
179      pass = 2;
180      //centTask->SetPass(1);
181    }
182    else{
183      if(dataset==2011){//PbPb 2.76 TeV 2011
184        gSystem->CopyFile("ConfigHadEtMonteCarloPbPb2011.C","ConfigHadEtMonteCarlo.C",kTRUE);
185        gSystem->CopyFile("ConfigHadEtReconstructedPbPb2011.C","ConfigHadEtReconstructed.C",kTRUE);
186        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC13e1abc.PbPb.168464.ForData.root","corrections.root",kTRUE);}
187        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC13e1abc.PbPb.168464.ForSimulations.root","corrections.root",kTRUE);}
188      }
189      if(dataset==2009){//pp 900 GeV
190        gSystem->CopyFile("ConfigHadEtMonteCarlopp900GeV.C","ConfigHadEtMonteCarlo.C",kTRUE);
191        gSystem->CopyFile("ConfigHadEtReconstructedpp900GeV.C","ConfigHadEtReconstructed.C",kTRUE);
192        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11b1a.pp.ForData.root","corrections.root",kTRUE);}
193        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11b1a.pp.ForSimulations.root","corrections.root",kTRUE);}
194        pass = 3;
195      }
196      if(dataset==20111){//pp 2.76 TeV
197        if(altV0Scale)gSystem->CopyFile("ConfigHadEtMonteCarlopp276TeVAlt.C","ConfigHadEtMonteCarlo.C",kTRUE);
198        else{gSystem->CopyFile("ConfigHadEtMonteCarlopp276TeV.C","ConfigHadEtMonteCarlo.C",kTRUE);}
199        gSystem->CopyFile("ConfigHadEtReconstructedpp276TeV.C","ConfigHadEtReconstructed.C",kTRUE);
200        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11b10a.pp.ForData.root","corrections.root",kTRUE);}
201        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11b10a.pp.ForSimulations.root","corrections.root",kTRUE);}
202        pass = 4;
203      }
204      if(dataset==2010){//pp 7 TeV
205        gSystem->CopyFile("ConfigHadEtMonteCarlopp7TeV.C","ConfigHadEtMonteCarlo.C",kTRUE);
206        gSystem->CopyFile("ConfigHadEtReconstructedpp7TeV.C","ConfigHadEtReconstructed.C",kTRUE);
207        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC10e20.pp.ForData.root","corrections.root",kTRUE);}
208        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC10e20.pp.ForSimulations.root","corrections.root",kTRUE);}
209        pass = 2;
210      }
211      if(dataset==2012){//pp 8 TeV
212        gSystem->CopyFile("ConfigHadEtMonteCarlopp8TeV.C","ConfigHadEtMonteCarlo.C",kTRUE);
213        gSystem->CopyFile("ConfigHadEtReconstructedpp8TeV.C","ConfigHadEtReconstructed.C",kTRUE);
214        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC12c1b.pp.ForData.root","corrections.root",kTRUE);}
215        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC12c1b.pp.ForSimulations.root","corrections.root",kTRUE);}
216        pass = 1;
217      }
218      if(dataset==2013){//pPb 5 TeV
219        gSystem->CopyFile("ConfigHadEtMonteCarlopPb5TeV.C","ConfigHadEtMonteCarlo.C",kTRUE);
220        gSystem->CopyFile("ConfigHadEtReconstructedpPb5TeV.C","ConfigHadEtReconstructed.C",kTRUE);
221        if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC13b3.pPb.ForData.root","corrections.root",kTRUE);}
222        else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC13b3.pPb.ForSimulations.root","corrections.root",kTRUE);}
223        pass = 3;
224      }
225    }
226    
227    
228    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
229   cerr<<"I am adding PID response task 169"<<endl;
230   //AliAnalysisTask *AddTaskPIDResponse(Bool_t isMC=kFALSE, Bool_t autoMCesd=kTRUE,
231 //                                     Bool_t tuneOnData=kFALSE, Int_t recoPass=2,
232 //                                     Bool_t cachePID=kFALSE, TString detResponse="",
233 //                                     Bool_t useTPCEtaCorrection = kFALSE);
234   AliAnalysisTaskPIDResponse *taskPID=AddTaskPIDResponse(!data,kTRUE,kTRUE,pass);
235   //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
236   //AddTaskPIDqa();
237
238    AliAnalysisTaskHadEt *task2 = new AliAnalysisTaskHadEt("TaskHadEt",!data);//,recoFile,mcFile);
239    if(!data) task2->SetMcData();
240    //Add thing here to select collision type!!
241      if(dataset==2013){//pPb 5 TeV
242        //task2->SelectCollisionCandidates(AliVEvent::kAnyINT ) ;
243        task2->SelectCollisionCandidates(AliVEvent::kINT7 ) ;
244      }
245      else{   if(dataset!=20100){task2->SelectCollisionCandidates(AliVEvent::kMB ) ;}}
246    //if(dataset!=20100){task2->SelectCollisionCandidates(AliVEvent::kMB ) ;}
247    mgr->AddTask(task2);
248   AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
249    AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("out2", TList::Class(), AliAnalysisManager::kOutputContainer,"Et.ESD.new.sim.root");
250 //    mgr->ConnectInput(task2,0,cinput1);
251 //    mgr->ConnectOutput(task2,1,coutput2);
252    mgr->ConnectInput(task2,0,cinput1);
253    mgr->ConnectOutput(task2,1,coutput2);
254    
255   mgr->SetDebugLevel(0);
256   
257   if (!mgr->InitAnalysis()) return;
258   mgr->PrintStatus();
259   if(submit){
260     mgr->StartAnalysis("grid");
261   }
262   else{
263     mgr->StartAnalysis("local",chain);
264   }
265
266   timer.Stop();
267   timer.Print();
268 }