Split: fix refs to AddTaskCentrality.C
[u/mrichter/AliRoot.git] / PWGLF / totEt / macros / runCaloEt.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 runCaloEt(bool submit = false, // true or false 
8                const char *dataType="simPbPb", // "sim" or "real" etc.
9                // const char *dataType="realPbPb", // "sim" or "real" etc.
10                const char *pluginRunMode="test", // "test" or "full" or "terminate"
11                const char *det = "EMCal",//"EMCal",
12                int production = 1, Bool_t withtender = kTRUE, Int_t runnum = 0, Bool_t withNonlinearity = kTRUE, Bool_t withReclusterizing = kFALSE, Int_t trackmatchcuts=0, Bool_t is2011 = kFALSE, Bool_t jethad = kFALSE) // "PHOS" or "EMCAL" or EMCalDetail
13 {
14   bool runCompiledVersion = kTRUE;
15   class AliAnalysisEtCuts;
16   TStopwatch timer;
17   timer.Start();
18   gSystem->Load("libTree");
19   gSystem->Load("libGeom");
20   gSystem->Load("libVMC");
21   gSystem->Load("libPhysics");
22   gSystem->Load("libMinuit");
23
24   gSystem->AddIncludePath("-I$ALICE_ROOT/include");
25   gSystem->AddIncludePath("-I. -I$ALICE_ROOT/EMCAL -I$ALICE_ROOT/ANALYSIS");
26
27   gSystem->Load("libSTEERBase");
28   gSystem->Load("libESD");
29   gSystem->Load("libAOD");
30   
31   gSystem->Load("libANALYSIS");
32   gSystem->Load("libANALYSISalice");
33   gSystem->Load("libCORRFW");
34
35     gSystem->Load("libTender");
36     gSystem->Load("libTenderSupplies");
37     gSystem->Load("libPWGTools");
38     gSystem->Load("libPWGEMCAL");
39     gROOT->ProcessLine(".include $ALICE_ROOT/Tender/"); 
40     //gSystem->AddIncludePath("-I$ALICE_ROOT/ANALYSIS "); 
41
42
43   if (!submit) { 
44     cout << "local - no submitting" << endl;
45   }
46   else { 
47     cout << "submitting to grid" << endl;
48   }
49    
50   if(runCompiledVersion){
51     gSystem->Load("libPWGLFtotEt");
52   }
53   else{
54     gROOT->ProcessLine(".L AliAnalysisEtCuts.cxx+g");
55     gROOT->ProcessLine(".L AliAnalysisHadEtCorrections.cxx+g");
56     gROOT->ProcessLine(".L AliAnalysisEtCommon.cxx+g");
57     gROOT->ProcessLine(".L AliAnalysisEtSelector.cxx+g");
58     gROOT->ProcessLine(".L AliAnalysisEtSelectorPhos.cxx+g");
59     gROOT->ProcessLine(".L AliAnalysisEtSelectorEmcal.cxx+g");
60     gROOT->ProcessLine(".L AliAnalysisEtTrackMatchCorrections.cxx+g");
61     gROOT->ProcessLine(".L AliAnalysisEtRecEffCorrection.cxx+g");
62     gROOT->ProcessLine(".L AliAnalysisEt.cxx+g");
63     gROOT->ProcessLine(".L AliAnalysisEtMonteCarlo.cxx+g");
64     gROOT->ProcessLine(".L AliAnalysisEtMonteCarloPhos.cxx+g");
65     gROOT->ProcessLine(".L AliAnalysisEtMonteCarloEmcal.cxx+g");
66     gROOT->ProcessLine(".L AliAnalysisEtReconstructed.cxx+g");
67     gROOT->ProcessLine(".L AliAnalysisEtReconstructedPhos.cxx+g");
68     gROOT->ProcessLine(".L AliAnalysisEtReconstructedEmcal.cxx+g");  
69     //gROOT->ProcessLine(".L AliAnalysisEtSelectionContainer.cxx+g");
70     //gROOT->ProcessLine(".L AliAnalysisEtSelectionHandler.cxx+g");
71     gROOT->ProcessLine(".L AliAnalysisTaskTransverseEnergy.cxx+g");
72     gROOT->ProcessLine(".L AliAnalysisEmEtMonteCarlo.cxx+g");
73     gROOT->ProcessLine(".L AliAnalysisEmEtReconstructed.cxx+g");
74     gROOT->ProcessLine(".L AliAnalysisTaskTotEt.cxx+g");
75   }
76   TString detStr(det);
77   TString dataStr(dataType);
78   if ( detStr.Contains("PHOS") ) {
79     if(is2011){
80       gSystem->CopyFile("calocorrections.2011.PHOS.root","calocorrections.root",kTRUE);
81     }
82     else{
83       gSystem->CopyFile("calocorrections.PHOS.root","calocorrections.root",kTRUE);
84     }
85     if ( dataStr.Contains("sim") ) {
86       gSystem->CopyFile("ConfigEtMonteCarlo.PHOS.C","ConfigEtMonteCarlo.C",kTRUE);
87     }
88     else{
89       gSystem->CopyFile("ConfigEtMonteCarlo.PHOS.data.C","ConfigEtMonteCarlo.C",kTRUE);
90     }
91   }
92   else{
93     if(is2011){
94       gSystem->CopyFile("calocorrections.2011.EMCAL.root","calocorrections.root",kTRUE);
95     }
96     else{
97       gSystem->CopyFile("calocorrections.EMCAL.root","calocorrections.root",kTRUE);
98     }
99     if(is2011){
100       if ( dataStr.Contains("sim") ) {
101         gSystem->CopyFile("ConfigEtMonteCarlo.EMCAL.2011.C","ConfigEtMonteCarlo.C",kTRUE);
102       }
103       else{
104         gSystem->CopyFile("ConfigEtMonteCarlo.EMCAL.2011.data.C","ConfigEtMonteCarlo.C",kTRUE);
105       }
106     }
107     else{
108       if ( dataStr.Contains("sim") ) {
109         gSystem->CopyFile("ConfigEtMonteCarlo.EMCAL.C","ConfigEtMonteCarlo.C",kTRUE);
110       }
111       else{
112         gSystem->CopyFile("ConfigEtMonteCarlo.EMCAL.data.C","ConfigEtMonteCarlo.C",kTRUE);
113       }
114     }
115   }
116
117   if(is2011){
118       gSystem->CopyFile("ConfigEtReconstructed.2011.C","ConfigEtReconstructed.C",kTRUE);
119   }
120   else{
121       gSystem->CopyFile("ConfigEtReconstructed.2010.C","ConfigEtReconstructed.C",kTRUE);
122   }
123
124   char *kTreeName = "esdTree" ;
125   TChain * chain   = new TChain(kTreeName,"myESDTree") ;
126   
127   if(submit){      
128     gSystem->Load("libNetx") ; 
129     gSystem->Load("libgapiUI");
130     gSystem->Load("libRAliEn"); 
131     TGrid::Connect("alien://") ;
132   }
133   
134   // Make the analysis manager
135   AliAnalysisManager *mgr = new AliAnalysisManager("TotEtManager");
136   
137   TString taskName = "TaskTotEt" + detStr;
138   TString dataStrName(dataType);
139   dataStrName.ReplaceAll("/",".");
140   Bool_t isPb = kFALSE;
141   if ( dataStr.Contains("PbPb") ) { isPb = kTRUE;}
142   TString suffix = "";
143   if(!withtender){
144     suffix = "WithoutTender";
145   }
146   if(!isPb){
147     suffix = "pp"+suffix;
148   }
149   TString outputName = "Et.ESD." + dataStrName + "." + detStr + ".root";
150   TString outputDir = "totEt" + dataStr + detStr+suffix;
151   if(!withNonlinearity){
152     outputDir +="NoNonlinearity";
153   }
154   if(withReclusterizing){
155     outputDir +="WithReclusterizing";
156   }
157   if(trackmatchcuts!=0){
158     outputDir +=Form("TrackMatchCut%i",trackmatchcuts);
159   }
160   if(jethad) outputDir+="WithJetHadronMethod";
161
162   cout << " taskName " << taskName
163        << " outputName " << outputName 
164        << " outputDir (alien) " << outputDir << endl;
165   mgr->SetCommonFileName(outputName.Data());
166   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("out1", TList::Class(), AliAnalysisManager::kOutputContainer, outputName);
167   if(!isPb){ cout<<"I am not PbPb!!"<<endl;}
168   if (submit) {
169     gROOT->LoadMacro("CreateAlienHandlerCaloEtSim.C");
170     cout<<"Passing in production number "<<production<<endl;
171     AliAnalysisGrid *alienHandler = CreateAlienHandlerCaloEtSim(outputDir, outputName, pluginRunMode, production,detStr.Contains("PHOS"),!isPb,dataStr.Contains("real"),runnum,runCompiledVersion);  
172     if (!alienHandler) return;
173     mgr->SetGridHandler(alienHandler);
174   }
175
176   AliVEventHandler* esdH = new AliESDInputHandler;
177   mgr->SetInputEventHandler(esdH);
178   AliMCEventHandler* handler = new AliMCEventHandler;
179   Bool_t isMc = kTRUE;
180   if ( dataStr.Contains("sim") ) {
181     cout << " MC " << endl;
182     if ( dataStr.Contains("PbPb") ) { // a la: simPbPb/LHC10e18a
183       cout << " PbPb " << endl;
184       TString fileLocation = "/data/LHC10h8/137161/999/AliESDs.root";//"/home/dsilverm/data/E_T/" + dataStr + "/dir/AliESDs.root";
185       cout << "fileLocation " << fileLocation.Data() << endl; 
186 //       chain->Add(fileLocation.Data()); // link to local test file
187 //      chain->Add("/data/tmp/3682/AliESDs.root");
188 //      chain->Add("/data/tmp/2782/AliESDs.root");
189 //       chain->Add("/data/LHC10h8/137161/999/AliESDs.root");//Hijing Pb+Pb
190 //       chain->Add("/data/LHC10h8/137161/111/AliESDs.root");//Hijing Pb+Pb
191 //       chain->Add("/data/LHC10h8/137161/222/AliESDs.root");//Hijing Pb+Pb
192 //      chain->Add("/data/LHC14a6/168464/605/AliESDs.root");
193 //chain->Add("/data/LHC11a10a_bis/139465/001/AliESDs.root");
194 //      chain->Add("/data/LHC14a6/168464/605/AliESDs.root");//HIJING with embedded signals
195       chain->Add("/data/LHC12d3/168464/201/AliESDs.root");//HIJING with embedded signals - works, full acceptance
196       //chain->Add("/data/LHC14a6/168464/888/AliESDs.root");//HIJING with embedded signals
197 //   chain->Add("/data/LHC11a10a_bis/139465/002/AliESDs.root");
198 //   chain->Add("/data/LHC11a10a_bis/139465/003/AliESDs.root");
199 //  chain->Add("/data/LHC11a10a_bis/139465/004/AliESDs.root");
200 //  chain->Add("/data/LHC11a10a_bis/139465/006/AliESDs.root");
201 //  chain->Add("/data/LHC11a10a_bis/139465/007/AliESDs.root");
202 //  chain->Add("/data/LHC11a10a_bis/139465/008/AliESDs.root");
203 //  chain->Add("/data/LHC11a10a_bis/139465/009/AliESDs.root");
204 //  chain->Add("/data/LHC11a10a_bis/139465/010/AliESDs.root");
205 // chain->Add("/data/LHC11a10a_bis/139465/011/AliESDs.root");
206 // chain->Add("/data/LHC11a10a_bis/139465/012/AliESDs.root");
207 // chain->Add("/data/LHC11a10a_bis/139465/013/AliESDs.root");
208 // chain->Add("/data/LHC11a10a_bis/139465/014/AliESDs.root");
209 // chain->Add("/data/LHC11a10a_bis/139465/015/AliESDs.root");
210 // chain->Add("/data/LHC11a10a_bis/139465/016/AliESDs.root");
211 // chain->Add("/data/LHC11a10a_bis/139465/017/AliESDs.root");
212 // chain->Add("/data/LHC11a10a_bis/139465/018/AliESDs.root");
213 // chain->Add("/data/LHC11a10a_bis/139465/019/AliESDs.root");
214 // chain->Add("/data/LHC11a10a_bis/139465/020/AliESDs.root");
215 // chain->Add("/data/LHC11a10a_bis/139465/021/AliESDs.root");
216 // chain->Add("/data/LHC11a10a_bis/139465/022/AliESDs.root");
217 // chain->Add("/data/LHC11a10a_bis/139465/023/AliESDs.root");
218 // chain->Add("/data/LHC11a10a_bis/139465/024/AliESDs.root");
219 // chain->Add("/data/LHC11a10a_bis/139465/025/AliESDs.root");
220 // chain->Add("/data/LHC11a10a_bis/139465/026/AliESDs.root");
221 // chain->Add("/data/LHC11a10a_bis/139465/027/AliESDs.root");
222 // chain->Add("/data/LHC11a10a_bis/139465/028/AliESDs.root");
223 // chain->Add("/data/LHC11a10a_bis/139465/029/AliESDs.root");
224 // chain->Add("/data/LHC11a10a_bis/139465/030/AliESDs.root");
225 // chain->Add("/data/LHC11a10a_bis/139465/031/AliESDs.root");
226 // chain->Add("/data/LHC11a10a_bis/139465/032/AliESDs.root");
227 // chain->Add("/data/LHC11a10a_bis/139465/033/AliESDs.root");
228 // chain->Add("/data/LHC11a10a_bis/139465/034/AliESDs.root");
229 // chain->Add("/data/LHC11a10a_bis/139465/035/AliESDs.root");
230 // chain->Add("/data/LHC11a10a_bis/139465/036/AliESDs.root");
231 // chain->Add("/data/LHC11a10a_bis/139465/037/AliESDs.root");
232 // chain->Add("/data/LHC11a10a_bis/139465/038/AliESDs.root");
233 // chain->Add("/data/LHC11a10a_bis/139465/039/AliESDs.root");
234 // chain->Add("/data/LHC11a10a_bis/139465/040/AliESDs.root");
235 // chain->Add("/data/LHC11a10a_bis/139465/041/AliESDs.root");
236 // chain->Add("/data/LHC11a10a_bis/139465/042/AliESDs.root");
237 // chain->Add("/data/LHC11a10a_bis/139465/043/AliESDs.root");
238 // chain->Add("/data/LHC11a10a_bis/139465/044/AliESDs.root");
239 // chain->Add("/data/LHC11a10a_bis/139465/045/AliESDs.root");
240 // chain->Add("/data/LHC11a10a_bis/139465/046/AliESDs.root");
241 // chain->Add("/data/LHC11a10a_bis/139465/047/AliESDs.root");
242 // chain->Add("/data/LHC11a10a_bis/139465/048/AliESDs.root");
243 // chain->Add("/data/LHC11a10a_bis/139465/049/AliESDs.root");
244 // chain->Add("/data/LHC11a10a_bis/139465/050/AliESDs.root");
245 // chain->Add("/data/LHC11a10a_bis/139465/051/AliESDs.root");
246 // chain->Add("/data/LHC11a10a_bis/139465/052/AliESDs.root");
247 // chain->Add("/data/LHC11a10a_bis/139465/053/AliESDs.root");
248 // chain->Add("/data/LHC11a10a_bis/139465/054/AliESDs.root");
249 // chain->Add("/data/LHC11a10a_bis/139465/055/AliESDs.root");
250 // chain->Add("/data/LHC11a10a_bis/139465/056/AliESDs.root");
251 // chain->Add("/data/LHC11a10a_bis/139465/057/AliESDs.root");
252 // chain->Add("/data/LHC11a10a_bis/139465/058/AliESDs.root");
253 // chain->Add("/data/LHC11a10a_bis/139465/059/AliESDs.root");
254 // chain->Add("/data/LHC11a10a_bis/139465/060/AliESDs.root");
255 // chain->Add("/data/LHC11a10a_bis/139465/061/AliESDs.root");
256 // chain->Add("/data/LHC11a10a_bis/139465/062/AliESDs.root");
257
258     }
259     else { // pp
260       cout<<"adding pp simulation file"<<endl;
261       chain->Add("/data/LHC11b1b/999/AliESDs.root");
262       //chain->Add("/data/LHC11b1a/999/AliESDs.root");
263       //chain->Add("/data/LHC10d15/1821/AliESDs.root");
264       //chain->Add("/data/LHC10dpass2/10000126403050.70/AliESDs.root");//data
265       //chain->Add("/home/dsilverm/data/E_T/sim/LHC10d1/117222/100/AliESDs.root"); // link to local test file
266     }
267     handler->SetReadTR(kFALSE);
268     mgr->SetMCtruthEventHandler(handler);
269   }
270   else { // real data
271     cout<<"Hello there!  I am data."<<endl;
272     isMc = kFALSE;
273
274     //      chain->Add("/data/tmp/10000139465010.600/AliESDs.root");
275
276       chain->Add("/data/LHC11h/pass2/000168464/11000168464082.94/AliESDs.root");
277       //chain->Add("/data/LHC10h/pass2_rev15/10000137366041.860/AliESDs.root");
278 //       chain->Add("/data/LHC10h/pass2_rev15/10000137366041.870/AliESDs.root");
279 //       chain->Add("/data/LHC10h/pass2_rev15/10000137366041.880/AliESDs.root");
280 //       chain->Add("/data/LHC10h/pass2_rev15/10000137366041.890/AliESDs.root");
281 //       chain->Add("/data/LHC10h/pass2_rev15/10000137366041.900/AliESDs.root");
282 //     chain->Add("/data/LHC10dpass2/10000126403050.70/AliESDs.root");//data
283     //chain->Add("/home/dsilverm/data/E_T/data/2010/LHC10b/000117222/ESDs/pass2/10000117222021.30/AliESDs.root"); // link to local test file
284     cout << " not MC " << endl;
285   }
286
287
288   //if(!isMc && detStr.Contains("EMC")){
289     if(detStr.Contains("EMC")){
290   //if(0){
291     cout<<"You are running over EMCal data and using the tender supply"<<endl;
292     //this macro is downloaded from the EMCal tender supply twiki 
293     //hopefully it will be replaced by something checked in to aliroot
294     //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
295     //I set the defaults to the golden run for PbPb because we are focusing on the golden run, however, this should be thought through!!
296     //AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(geoname);
297
298     gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEmcalSetup.C");
299     AliEmcalSetupTask *setupTask = AddTaskEmcalSetup();
300     setupTask->SetGeoPath("$ALICE_ROOT/OADB/EMCAL");
301     setupTask->SetOcdbPath(""); 
302
303 //     gROOT->LoadMacro("AddTaskEMCALTenderForEtAnalysis.C");
304 //     //cout<<"WARNING: YOU ARE USING CALIBRATION FACTORS FROM PbPb RUN 137161!!"<<endl;
305 // //   // get reco params from grid OCDB
306 // //    gROOT->LoadMacro("./GetOCDBRecParam.C");
307 // //   // run num, data type pp/PbPb, from grid
308 // //Gets calibration factors from grid if jobs are to be submitted to the grid
309 // //           AliEMCALRecParam* pars = GetOCDBRecParam( 137161, "PbPb", submit);
310 // //EMCAL_FIRSTYEARV1 F-
311 //     //AliTender *tender = AddTaskEMCALTender( "EMCAL_COMPLETEV1", 0,withNonlinearity,withReclusterizing,trackmatchcuts);
312 // AliTender *tender = AddTaskEMCALTender( "EMCAL_FIRSTYEARV1", 0,withNonlinearity,withReclusterizing,trackmatchcuts);
313 //     //this also likely needs modification
314 // //     tender->SelectCollisionCandidates( AliVEvent::kMB | AliVEvent::kEMCEGA | AliVEvent::kEMC1 | AliVEvent::kEMC7 );
315 // //     if(submit){tender->SetDefaultCDBStorage("raw://");} //uncomment if you work on grid
316 // //     else{tender->SetDefaultCDBStorage("local://$ALICE_ROOT/OCDB");} //uncomment if you work local
317
318 //     if(submit){
319 //       cout<<"Setting tender to run on grid"<<endl;
320 //       tender->SetDefaultCDBStorage("raw://"); //uncomment if you work on grid
321 //     }
322 //     else{
323 //       cout<<"Setting tender to run locally"<<endl;
324 //       tender->SetDefaultCDBStorage("local://$ALICE_ROOT/OCDB"); //uncomment if you work local
325 //     }
326
327
328     gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/AddTaskEMCALTender.C");//tendertasks
329     TString runPeriod = "LHC10h";
330   Bool_t distBC         = kTRUE;   //distance to bad channel
331   Bool_t recalibClus    = kTRUE;   //recalibrate cluster energy
332   Bool_t recalcClusPos  = kTRUE;   //recalculate cluster position
333   Bool_t nonLinearCorr  = kTRUE;   //apply non-linearity
334   Bool_t remExotic      = kTRUE;   //remove exotic cells
335   Bool_t fidRegion      = kTRUE;  //apply fiducial cuts -->  different from defaults
336   Bool_t calibEnergy    = kTRUE;   //calibrate energy
337   Bool_t calibTime      = kTRUE;   //calibrate timing
338   Bool_t remBC          = kTRUE;   //remove bad channels
339   UInt_t nonLinFunct    = AliEMCALRecoUtils::kBeamTestCorrected;
340   Bool_t reclusterize   = kFALSE;   //reclusterize --> different from defaults
341   Float_t seedthresh    = 0.100;   //seed threshold
342   Float_t cellthresh    = 0.050;   //cell threshold
343   UInt_t clusterizer    = AliEMCALRecParam::kClusterizerv2;
344   Bool_t trackMatch     = kTRUE;   //track matching
345   Bool_t updateCellOnly = kFALSE;  //only change if you run your own clusterizer task
346   Float_t timeMin       = 100e-9;  //minimum time of physical signal in a cell/digit (s)
347   Float_t timeMax       = 900e-9;  //maximum time of physical signal in a cell/digit (s)
348   Float_t timeCut       = 900e-9;  //maximum time difference between the digits inside EMC cluster (s)
349     const char *pass      = 0 ;       //string defining pass (use none if figured out from path)
350     //AliAnalysisTaskSE *tender = AddTaskEMCALTender();
351     AliAnalysisTaskSE *tender = AddTaskEMCALTender(distBC, recalibClus, recalcClusPos, nonLinearCorr, remExotic, 
352                                                    fidRegion, calibEnergy, calibTime, remBC, nonLinFunct, reclusterize, seedthresh, 
353                                                    cellthresh, clusterizer, trackMatch, updateCellOnly, timeMin, timeMax, timeCut);
354     
355
356
357     // one can sellect what collision candidates to use
358     // triggered sample only: L1 = AliVEvent::kEMCEGA, AliVEvent::kEMCEJE; L0 = AliVEvent::kEMC1, AliVEvent::kEMC7
359     tender->SelectCollisionCandidates( AliVEvent::kAny );
360     //tender->SetDebugLevel(2);
361
362     //AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("histosTrgContam", TList::Class(), AliAnalysisManager::kOutputContainer,"AnalysisResults.root");
363     //mgr->ConnectOutput(tender,1,coutput3);
364     cout<<"Output container name "<<AliAnalysisManager::GetCommonFileName()<<endl;
365   }
366
367   if(isMc) cout<<"I am a MC"<<endl;
368   gROOT->ProcessLine(".L $ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
369   
370   AliPhysicsSelectionTask *physicsSelectionTask = AddTaskPhysicsSelection(isMc);//isMC is true when processing monte carlo
371   if(isPb){      
372     cout<<"Adding centrality selection task"<<endl;
373     gROOT->ProcessLine(".L $ALICE_ROOT/OADB/macros/AddTaskCentrality.C");
374     //gROOT->ProcessLine(".L AliCentralitySelectionTask.cxx++g");
375     AliCentralitySelectionTask *centTask = AddTaskCentrality();
376     if(isMc){
377      cout<<"Setting up centrality for MC"<<endl;
378      centTask->SetMCInput();
379    }
380     else{
381      cout<<"Setting up centrality for data"<<endl;
382    }
383   }
384
385   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
386   //AliAnalysisTask *AddTaskPIDResponse(Bool_t isMC=kFALSE, Bool_t autoMCesd=kTRUE,
387 //                                     Bool_t tuneOnData=kFALSE, Int_t recoPass=2,
388 //                                     Bool_t cachePID=kFALSE, TString detResponse="",
389 //                                     Bool_t useTPCEtaCorrection = kFALSE);
390 //  AliAnalysisTask *AddTaskPIDResponse(Bool_t isMC=kFALSE, Bool_t autoMCesd=kTRUE,
391 //                                  Bool_t tuneOnData=kFALSE, Int_t recoPass=2,
392 //                                  Bool_t cachePID=kFALSE, TString detResponse="",
393 //                                  Bool_t useTPCEtaCorrection = kTRUE,
394 //                                  Bool_t useTPCMultiplicityCorrection = kFALSE
395 //                                  Int_t  userDataRecoPass = -1)
396
397   AliAnalysisTask *taskPID;
398   if(submit){
399     taskPID=AddTaskPIDResponse(isMc);//,kTRUE,kTRUE,2,kFALSE,"",kTRUE,kFALSE,2);
400   }
401   else{
402     cout<<"Not submitting so forcing pass number locally so it doesn't crash"<<endl;
403     taskPID=AddTaskPIDResponse(isMc,kTRUE,kTRUE,2,kFALSE,"",kTRUE,kFALSE,2);
404   }
405   //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
406   //AddTaskPIDqa();
407
408   AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
409
410
411
412
413
414   AliAnalysisTaskTotEt *task1 = new AliAnalysisTaskTotEt(taskName);
415   task1->SetMcData(isMc);//necessary to tell the task to basically accept all MC events.
416   task1->SelectCollisionCandidates(AliVEvent::kMB ) ;
417   mgr->AddTask(task1);
418
419   
420   //____________________________________________//
421   mgr->ConnectInput(task1,0,cinput1);
422   mgr->ConnectOutput(task1,1,coutput1);
423
424
425   
426   mgr->SetDebugLevel(0);
427   
428   if (!mgr->InitAnalysis()) return;
429   mgr->PrintStatus();
430   if(submit){
431     mgr->StartAnalysis("grid");
432   }
433   else{
434     mgr->StartAnalysis("local",chain);
435   }
436   
437   timer.Stop();
438   timer.Print();
439 }