Updating macros for running code
[u/mrichter/AliRoot.git] / PWGLF / totEt / macros / runCaloEt.C
CommitLineData
4998bf42 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
8df12228 7void runCaloEt(bool submit = false, // true or false
f6e609f6 8 const char *dataType="simPbPb", // "sim" or "real" etc.
9a365626 9 const char *pluginRunMode="test", // "test" or "full" or "terminate"
10 const char *det = "EMCal",int production = 1, Bool_t withtender = kTRUE, Int_t runnum = 0, Bool_t withNonlinearity = kTRUE, Bool_t withReclusterizing = kFALSE, Int_t trackmatchcuts==0) // "PHOS" or "EMCAL" or EMCalDetail
99a6613d 11{
8df12228 12 TStopwatch timer;
13 timer.Start();
14 gSystem->Load("libTree");
15 gSystem->Load("libGeom");
16 gSystem->Load("libVMC");
17 gSystem->Load("libPhysics");
8df12228 18 gSystem->Load("libMinuit");
19
20 gSystem->AddIncludePath("-I$ALICE_ROOT/include");
21 gSystem->AddIncludePath("-I. -I$ALICE_ROOT/EMCAL -I$ALICE_ROOT/ANALYSIS");
22
23 gSystem->Load("libSTEERBase");
24 gSystem->Load("libESD");
25 gSystem->Load("libAOD");
26
27 gSystem->Load("libANALYSIS");
28 gSystem->Load("libANALYSISalice");
29 gSystem->Load("libCORRFW");
30
058989e8 31
32
8df12228 33 if (!submit) {
34 cout << "local - no submitting" << endl;
35 }
36 else {
37 cout << "submitting to grid" << endl;
38 }
39
40 gROOT->ProcessLine(".L AliAnalysisEtCuts.cxx+g");
41 gROOT->ProcessLine(".L AliAnalysisHadEtCorrections.cxx+g");
42 gROOT->ProcessLine(".L AliAnalysisEtCommon.cxx+g");
fe71c343 43 gROOT->ProcessLine(".L AliAnalysisEtSelector.cxx+g");
44 gROOT->ProcessLine(".L AliAnalysisEtSelectorPhos.cxx+g");
45 gROOT->ProcessLine(".L AliAnalysisEtSelectorEmcal.cxx+g");
c5b9a3cd 46 gROOT->ProcessLine(".L AliAnalysisEtTrackMatchCorrections.cxx+g");
47 gROOT->ProcessLine(".L AliAnalysisEtRecEffCorrection.cxx+g");
8df12228 48 gROOT->ProcessLine(".L AliAnalysisEt.cxx+g");
49 gROOT->ProcessLine(".L AliAnalysisEtMonteCarlo.cxx+g");
50 gROOT->ProcessLine(".L AliAnalysisEtMonteCarloPhos.cxx+g");
51 gROOT->ProcessLine(".L AliAnalysisEtMonteCarloEmcal.cxx+g");
52 gROOT->ProcessLine(".L AliAnalysisEtReconstructed.cxx+g");
53 gROOT->ProcessLine(".L AliAnalysisEtReconstructedPhos.cxx+g");
54 gROOT->ProcessLine(".L AliAnalysisEtReconstructedEmcal.cxx+g");
fe71c343 55 //gROOT->ProcessLine(".L AliAnalysisEtSelectionContainer.cxx+g");
56 //gROOT->ProcessLine(".L AliAnalysisEtSelectionHandler.cxx+g");
8df12228 57 gROOT->ProcessLine(".L AliAnalysisTaskTransverseEnergy.cxx+g");
fe71c343 58 gROOT->ProcessLine(".L AliAnalysisEmEtMonteCarlo.cxx+g");
59 gROOT->ProcessLine(".L AliAnalysisEmEtReconstructed.cxx+g");
8df12228 60 gROOT->ProcessLine(".L AliAnalysisTaskTotEt.cxx+g");
61
f6e609f6 62 TString detStr(det);
63 TString dataStr(dataType);
64 if ( detStr.Contains("PHOS") ) {
65 gSystem->CopyFile("calocorrections.PHOS.root","calocorrections.root",kTRUE);
66 if ( dataStr.Contains("sim") ) {
67 gSystem->CopyFile("ConfigEtMonteCarlo.PHOS.C","ConfigEtMonteCarlo.C",kTRUE);
68 }
69 else{
70 gSystem->CopyFile("ConfigEtMonteCarlo.PHOS.data.C","ConfigEtMonteCarlo.C",kTRUE);
71 }
72 }
73 else{
74 gSystem->CopyFile("calocorrections.EMCAL.root","calocorrections.root",kTRUE);
75 if ( dataStr.Contains("sim") ) {
76 gSystem->CopyFile("ConfigEtMonteCarlo.EMCAL.C","ConfigEtMonteCarlo.C",kTRUE);
77 }
78 else{
79 gSystem->CopyFile("ConfigEtMonteCarlo.EMCAL.data.C","ConfigEtMonteCarlo.C",kTRUE);
80 }
81 }
82
4cb06159 83
8df12228 84 char *kTreeName = "esdTree" ;
85 TChain * chain = new TChain(kTreeName,"myESDTree") ;
86
87 if(submit){
88 gSystem->Load("libNetx") ;
89 gSystem->Load("libgapiUI");
90 gSystem->Load("libRAliEn");
91 TGrid::Connect("alien://") ;
92 }
93
94 // Make the analysis manager
95 AliAnalysisManager *mgr = new AliAnalysisManager("TotEtManager");
96
8df12228 97 TString taskName = "TaskTotEt" + detStr;
8df12228 98 TString dataStrName(dataType);
99 dataStrName.ReplaceAll("/",".");
95c06714 100 Bool_t isPb = kFALSE;
101 if ( dataStr.Contains("PbPb") ) { isPb = kTRUE;}
102 TString suffix = "";
103 if(!withtender){
104 suffix = "WithoutTender";
105 }
106 if(!isPb){
107 suffix = "pp"+suffix;
108 }
8df12228 109 TString outputName = "Et.ESD." + dataStrName + "." + detStr + ".root";
95c06714 110 TString outputDir = "totEt" + dataStr + detStr+suffix;
9a365626 111 if(!withNonlinearity){
112 outputDir +="NoNonlinearity";
113 }
114 if(withReclusterizing){
115 outputDir +="WithReclusterizing";
116 }
117 if(trackmatchcuts!=0){
118 outputDir +=Form("TrackMatchCut%i",trackmatchcuts);
119 }
8df12228 120
121 cout << " taskName " << taskName
122 << " outputName " << outputName
123 << " outputDir (alien) " << outputDir << endl;
1a331f88 124 mgr->SetCommonFileName(outputName.Data());
125 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("out1", TList::Class(), AliAnalysisManager::kOutputContainer, outputName);
9a365626 126 if(!isPb){ cout<<"I am not PbPb!!"<<endl;}
8df12228 127 if (submit) {
128 gROOT->LoadMacro("CreateAlienHandlerCaloEtSim.C");
9a365626 129 AliAnalysisGrid *alienHandler = CreateAlienHandlerCaloEtSim(outputDir, outputName, pluginRunMode, production,detStr.Contains("PHOS"),!isPb,dataStr.Contains("real"),runnum);
8df12228 130 if (!alienHandler) return;
131 mgr->SetGridHandler(alienHandler);
132 }
133
134 AliVEventHandler* esdH = new AliESDInputHandler;
135 mgr->SetInputEventHandler(esdH);
136 AliMCEventHandler* handler = new AliMCEventHandler;
137 Bool_t isMc = kTRUE;
8df12228 138 if ( dataStr.Contains("sim") ) {
139 cout << " MC " << endl;
140 if ( dataStr.Contains("PbPb") ) { // a la: simPbPb/LHC10e18a
141 cout << " PbPb " << endl;
f6e609f6 142 TString fileLocation = "/data/LHC10h8/137161/999/AliESDs.root";//"/home/dsilverm/data/E_T/" + dataStr + "/dir/AliESDs.root";
8df12228 143 cout << "fileLocation " << fileLocation.Data() << endl;
95c06714 144// chain->Add(fileLocation.Data()); // link to local test file
9a365626 145// chain->Add("/data/LHC10h8/137161/999/AliESDs.root");//Hijing Pb+Pb
146// chain->Add("/data/LHC10h8/137161/111/AliESDs.root");//Hijing Pb+Pb
147// chain->Add("/data/LHC10h8/137161/222/AliESDs.root");//Hijing Pb+Pb
148chain->Add("/data/LHC11a10a_bis/139465/001/AliESDs.root");
149chain->Add("/data/LHC11a10a_bis/139465/002/AliESDs.root");
d45a33b8 150// chain->Add("/data/LHC11a10a_bis/139465/003/AliESDs.root");
151// chain->Add("/data/LHC11a10a_bis/139465/004/AliESDs.root");
152// chain->Add("/data/LHC11a10a_bis/139465/006/AliESDs.root");
153// chain->Add("/data/LHC11a10a_bis/139465/007/AliESDs.root");
154// chain->Add("/data/LHC11a10a_bis/139465/008/AliESDs.root");
155// chain->Add("/data/LHC11a10a_bis/139465/009/AliESDs.root");
156// chain->Add("/data/LHC11a10a_bis/139465/010/AliESDs.root");
157// chain->Add("/data/LHC11a10a_bis/139465/011/AliESDs.root");
158// chain->Add("/data/LHC11a10a_bis/139465/012/AliESDs.root");
159// chain->Add("/data/LHC11a10a_bis/139465/013/AliESDs.root");
160// chain->Add("/data/LHC11a10a_bis/139465/014/AliESDs.root");
161// chain->Add("/data/LHC11a10a_bis/139465/015/AliESDs.root");
162// chain->Add("/data/LHC11a10a_bis/139465/016/AliESDs.root");
163// chain->Add("/data/LHC11a10a_bis/139465/017/AliESDs.root");
164// chain->Add("/data/LHC11a10a_bis/139465/018/AliESDs.root");
165// chain->Add("/data/LHC11a10a_bis/139465/019/AliESDs.root");
166// chain->Add("/data/LHC11a10a_bis/139465/020/AliESDs.root");
167// chain->Add("/data/LHC11a10a_bis/139465/021/AliESDs.root");
168// chain->Add("/data/LHC11a10a_bis/139465/022/AliESDs.root");
169// chain->Add("/data/LHC11a10a_bis/139465/023/AliESDs.root");
170// chain->Add("/data/LHC11a10a_bis/139465/024/AliESDs.root");
171// chain->Add("/data/LHC11a10a_bis/139465/025/AliESDs.root");
172// chain->Add("/data/LHC11a10a_bis/139465/026/AliESDs.root");
173// chain->Add("/data/LHC11a10a_bis/139465/027/AliESDs.root");
174// chain->Add("/data/LHC11a10a_bis/139465/028/AliESDs.root");
175// chain->Add("/data/LHC11a10a_bis/139465/029/AliESDs.root");
176// chain->Add("/data/LHC11a10a_bis/139465/030/AliESDs.root");
177// chain->Add("/data/LHC11a10a_bis/139465/031/AliESDs.root");
178// chain->Add("/data/LHC11a10a_bis/139465/032/AliESDs.root");
179// chain->Add("/data/LHC11a10a_bis/139465/033/AliESDs.root");
180// chain->Add("/data/LHC11a10a_bis/139465/034/AliESDs.root");
181// chain->Add("/data/LHC11a10a_bis/139465/035/AliESDs.root");
182// chain->Add("/data/LHC11a10a_bis/139465/036/AliESDs.root");
183// chain->Add("/data/LHC11a10a_bis/139465/037/AliESDs.root");
184// chain->Add("/data/LHC11a10a_bis/139465/038/AliESDs.root");
185// chain->Add("/data/LHC11a10a_bis/139465/039/AliESDs.root");
186// chain->Add("/data/LHC11a10a_bis/139465/040/AliESDs.root");
187// chain->Add("/data/LHC11a10a_bis/139465/041/AliESDs.root");
188// chain->Add("/data/LHC11a10a_bis/139465/042/AliESDs.root");
189// chain->Add("/data/LHC11a10a_bis/139465/043/AliESDs.root");
190// chain->Add("/data/LHC11a10a_bis/139465/044/AliESDs.root");
191// chain->Add("/data/LHC11a10a_bis/139465/045/AliESDs.root");
192// chain->Add("/data/LHC11a10a_bis/139465/046/AliESDs.root");
193// chain->Add("/data/LHC11a10a_bis/139465/047/AliESDs.root");
194// chain->Add("/data/LHC11a10a_bis/139465/048/AliESDs.root");
195// chain->Add("/data/LHC11a10a_bis/139465/049/AliESDs.root");
196// chain->Add("/data/LHC11a10a_bis/139465/050/AliESDs.root");
197// chain->Add("/data/LHC11a10a_bis/139465/051/AliESDs.root");
198// chain->Add("/data/LHC11a10a_bis/139465/052/AliESDs.root");
199// chain->Add("/data/LHC11a10a_bis/139465/053/AliESDs.root");
200// chain->Add("/data/LHC11a10a_bis/139465/054/AliESDs.root");
201// chain->Add("/data/LHC11a10a_bis/139465/055/AliESDs.root");
202// chain->Add("/data/LHC11a10a_bis/139465/056/AliESDs.root");
203// chain->Add("/data/LHC11a10a_bis/139465/057/AliESDs.root");
204// chain->Add("/data/LHC11a10a_bis/139465/058/AliESDs.root");
205// chain->Add("/data/LHC11a10a_bis/139465/059/AliESDs.root");
206// chain->Add("/data/LHC11a10a_bis/139465/060/AliESDs.root");
207// chain->Add("/data/LHC11a10a_bis/139465/061/AliESDs.root");
208// chain->Add("/data/LHC11a10a_bis/139465/062/AliESDs.root");
9a365626 209
99a6613d 210 }
8df12228 211 else { // pp
058989e8 212 cout<<"adding pp simulation file"<<endl;
9a365626 213 chain->Add("/data/LHC11b1b/999/AliESDs.root");
214 //chain->Add("/data/LHC11b1a/999/AliESDs.root");
215 //chain->Add("/data/LHC10d15/1821/AliESDs.root");
8df12228 216 //chain->Add("/data/LHC10dpass2/10000126403050.70/AliESDs.root");//data
217 //chain->Add("/home/dsilverm/data/E_T/sim/LHC10d1/117222/100/AliESDs.root"); // link to local test file
13b0d3c1 218 }
8df12228 219 handler->SetReadTR(kFALSE);
220 mgr->SetMCtruthEventHandler(handler);
221 }
222 else { // real data
95c06714 223 cout<<"Hello there! I am data."<<endl;
8df12228 224 isMc = kFALSE;
95c06714 225 chain->Add("/data/LHC10h/pass2_rev15/10000137366041.860/AliESDs.root");
226 chain->Add("/data/LHC10h/pass2_rev15/10000137366041.870/AliESDs.root");
227 chain->Add("/data/LHC10h/pass2_rev15/10000137366041.880/AliESDs.root");
228 chain->Add("/data/LHC10h/pass2_rev15/10000137366041.890/AliESDs.root");
229 chain->Add("/data/LHC10h/pass2_rev15/10000137366041.900/AliESDs.root");
230// chain->Add("/data/LHC10dpass2/10000126403050.70/AliESDs.root");//data
058989e8 231 //chain->Add("/home/dsilverm/data/E_T/data/2010/LHC10b/000117222/ESDs/pass2/10000117222021.30/AliESDs.root"); // link to local test file
8df12228 232 cout << " not MC " << endl;
233 }
234
058989e8 235
f6e609f6 236 //if(!isMc && detStr.Contains("EMC")){
237 if(detStr.Contains("EMC")){
058989e8 238 cout<<"You are running over EMCal data and using the tender supply"<<endl;
239 gSystem->Load("libTENDER.so");
240 gSystem->Load("libTENDERSupplies.so");
241 gROOT->ProcessLine(".include $ALICE_ROOT/Tender/");
242 gSystem->AddIncludePath("-I$ALICE_ROOT/ANALYSIS ");
69008885 243 //this macro is downloaded from the EMCal tender supply twiki
244 //hopefully it will be replaced by something checked in to aliroot
245 //I have added the function from GetOCDBRecParam.C in Jiri's example to this so that we don't add gobs of macros to the code
246 //I set the defaults to the golden run for PbPb because we are focusing on the golden run, however, this should be thought through!!
247 gROOT->LoadMacro("AddTaskEMCALTenderForEtAnalysis.C");
248 cout<<"WARNING: YOU ARE USING CALIBRATION FACTORS FROM PbPb RUN 137161!!"<<endl;
249// // get reco params from grid OCDB
250// gROOT->LoadMacro("./GetOCDBRecParam.C");
251// // run num, data type pp/PbPb, from grid
252//Gets calibration factors from grid if jobs are to be submitted to the grid
f6e609f6 253// AliEMCALRecParam* pars = GetOCDBRecParam( 137161, "PbPb", submit);
69008885 254
9a365626 255 AliTender *tender = AddTaskEMCALTender( "EMCAL_COMPLETEV1", 0,withNonlinearity,withReclusterizing,trackmatchcuts);
69008885 256 //this also likely needs modification
f6e609f6 257// tender->SelectCollisionCandidates( AliVEvent::kMB | AliVEvent::kEMCEGA | AliVEvent::kEMC1 | AliVEvent::kEMC7 );
258// if(submit){tender->SetDefaultCDBStorage("raw://");} //uncomment if you work on grid
259// else{tender->SetDefaultCDBStorage("local://$ALICE_ROOT/OCDB");} //uncomment if you work local
69008885 260
1a331f88 261 if(submit){
262 cout<<"Setting tender to run on grid"<<endl;
263 tender->SetDefaultCDBStorage("raw://"); //uncomment if you work on grid
264 }
265 else{
266 cout<<"Setting tender to run locally"<<endl;
267 tender->SetDefaultCDBStorage("local://$ALICE_ROOT/OCDB"); //uncomment if you work local
268 }
269 // one can sellect what collision candidates to use
270 // triggered sample only: L1 = AliVEvent::kEMCEGA, AliVEvent::kEMCEJE; L0 = AliVEvent::kEMC1, AliVEvent::kEMC7
271 tender->SelectCollisionCandidates( AliVEvent::kAny );
69008885 272 tender->SetDebugLevel(2);
1a331f88 273
274 //AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("histosTrgContam", TList::Class(), AliAnalysisManager::kOutputContainer,"AnalysisResults.root");
275 //mgr->ConnectOutput(tender,1,coutput3);
276 cout<<"Output container name "<<AliAnalysisManager::GetCommonFileName()<<endl;
058989e8 277 }
278
279 if(isMc) cout<<"I am a MC"<<endl;
8df12228 280 gROOT->ProcessLine(".L $ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
281
282 AliPhysicsSelectionTask *physicsSelectionTask = AddTaskPhysicsSelection(isMc);//isMC is true when processing monte carlo
283 if(isPb){
058989e8 284 cout<<"Adding centrality selection task"<<endl;
50f29788 285 gROOT->ProcessLine(".L $ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
fe71c343 286 //gROOT->ProcessLine(".L AliCentralitySelectionTask.cxx++g");
50f29788 287 AliCentralitySelectionTask *centTask = AddTaskCentrality();
95c06714 288 if(isMc){
289 cout<<"Setting up centrality for MC"<<endl;
290 centTask->SetMCInput();
291 }
292 else{
293 cout<<"Setting up centrality for data"<<endl;
294 }
8df12228 295 }
296
9a365626 297 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
298 //AliAnalysisTask *AddTaskPIDResponse(Bool_t isMC=kFALSE, Bool_t autoMCesd=kTRUE,
299// Bool_t tuneOnData=kFALSE, Int_t recoPass=2,
300// Bool_t cachePID=kFALSE, TString detResponse="",
301// Bool_t useTPCEtaCorrection = kFALSE);
302 AliAnalysisTaskPIDResponse *taskPID=AddTaskPIDResponse(isMc,kTRUE,kTRUE,2);
303 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
304 AddTaskPIDqa();
058989e8 305
306 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
307
308
309
310
311
8df12228 312 AliAnalysisTaskTotEt *task1 = new AliAnalysisTaskTotEt(taskName);
0adfc269 313 task1->SetMcData(isMc);//necessary to tell the task to basically accept all MC events.
9a365626 314 task1->SelectCollisionCandidates(AliVEvent::kMB ) ;
8df12228 315 mgr->AddTask(task1);
316
8df12228 317
318 //____________________________________________//
319 mgr->ConnectInput(task1,0,cinput1);
320 mgr->ConnectOutput(task1,1,coutput1);
058989e8 321
322
8df12228 323
324 mgr->SetDebugLevel(0);
325
326 if (!mgr->InitAnalysis()) return;
327 mgr->PrintStatus();
328 if(submit){
329 mgr->StartAnalysis("grid");
330 }
331 else{
332 mgr->StartAnalysis("local",chain);
333 }
334
335 timer.Stop();
336 timer.Print();
4998bf42 337}