ROOT logo
//Create by Christine Nattrass, Rebecca Scott, Irakli Martashvili
//University of Tennessee at Knoxville

//by default this runs locally
//With the argument true this submits jobs to the grid
//As written this requires an xml script tag.xml in the ~/et directory on the grid to submit jobs
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) {
    TStopwatch timer;
    timer.Start();
    gSystem->Load("libTree.so");
    gSystem->Load("libGeom.so");
    gSystem->Load("libVMC.so");
    gSystem->Load("libPhysics.so");
    gSystem->Load("libXMLIO.so");

    gSystem->Load("libSTEERBase.so");
    gSystem->Load("libESD.so");
    gSystem->Load("libAOD.so");

    gSystem->Load("libANALYSIS");
    gSystem->Load("libOADB.so");
    gSystem->Load("libANALYSISalice");
    gSystem->Load("libPWGUDbase.so");

    gSystem->AddIncludePath("-I$ALICE_ROOT/include");
    gSystem->AddIncludePath("-I$ALICE_ROOT/PWGUD/base");
    if(runCompiledVersion){
      cout<<"Using compiled version"<<endl;
      gSystem->Load("libPWGLFtotEt.so");
    }
    else{
      cout<<"Not using compiled version"<<endl;
      gROOT->ProcessLine(".L AliAnalysisEtCuts.cxx+g");
      gROOT->ProcessLine(".L AliAnalysisHadEtCorrections.cxx+g");
      gROOT->ProcessLine(".L AliAnalysisEtCommon.cxx+g");
      gROOT->ProcessLine(".L AliAnalysisHadEt.cxx+g");
      gROOT->ProcessLine(".L AliAnalysisHadEtMonteCarlo.cxx+g");
      gROOT->ProcessLine(".L AliAnalysisHadEtReconstructed.cxx+g");
      gROOT->ProcessLine(".L AliAnalysisTaskTransverseEnergy.cxx+g");
      gROOT->ProcessLine(".L AliAnalysisTaskHadEt.cxx+g");
    }

  char *kTreeName = "esdTree" ;
  TChain * chain   = new TChain(kTreeName,"myESDTree") ;
  if(submit){      
    gSystem->Load("libNetx.so") ; 
    gSystem->Load("libgapiUI.so");
    gSystem->Load("libRAliEn.so"); 
    TGrid::Connect("alien://") ;
  }
  bool PbPb = false;
  if(dataset ==20100 || dataset==2011){
    bool PbPb = true;
    if(data){
      chain->Add("/data/LHC10h/pass2_rev15/10000137366041.860/AliESDs.root");//Data Pb+Pb
      chain->Add("/data/LHC10h/pass2_rev15/10000137366041.870/AliESDs.root");//Data Pb+Pb
      chain->Add("/data/LHC10h/pass2_rev15/10000137366041.880/AliESDs.root");//Data Pb+Pb
      chain->Add("/data/LHC10h/pass2_rev15/10000137366041.890/AliESDs.root");//Data Pb+Pb
      chain->Add("/data/LHC10h/pass2_rev15/10000137366041.900/AliESDs.root");//Data Pb+Pb
    }
    else{
      //chain->Add("/data/LHC12d3/168464/201/AliESDs.root");//HIJING with embedded signals - works, full acceptance
      //chain->Add("/data/LHC10h2/137161/001/AliESDs.root");//DPMJET
      chain->Add("/data/LHC11a9a/137366/001/AliESDs.root");//AMPT
//       chain->Add("/data/LHC10h8/137161/999/AliESDs.root");//Hijing Pb+Pb
//       chain->Add("/data/LHC10h8/137161/111/AliESDs.root");//Hijing Pb+Pb
//       chain->Add("/data/LHC10h8/137161/222/AliESDs.root");//Hijing Pb+Pb
      //chain->Add("/data/LHC11a4_bis/137161/999/AliESDs.root");//Hijing Pb+Pb
      //chain->Add("/data/LHC10h12/999/AliESDs.root");//Hijing Pb+Pb
    }
  } 
  else{
     if(dataset==2013){//pPb 5 TeV
       if(data){
	 chain->Add("/data/LHC13b/13000195483082.95/AliESDs.root");
       }
       else{
	 //cout<<"Yes I am analyzing the correct file"<<endl;
	 //chain->Add("/data/LHC12c1b/111/AliESDs.root");
	 chain->Add("/data/LHC13b3/9999/AliESDs.root");
       }
     }
     else{
       if(data){
	 //chain->Add("/data/LHC10dpass2/10000126403050.70/AliESDs.root");//data
	 //chain->Add("/data/LHC11a/11000146856042.90/AliESDs.root");//data pp 2.76 TeV w/SDD pass 2
	 //chain->Add("/data/LHC11a/11000146860043.90/AliESDs.root");//data pp 2.76 TeV w/SDD pass 3
	 chain->Add("/data/LHC10c/10000120683048.90/AliESDs.root");//Data Pb+Pb
       }
       else{
	 cerr<<"Hello I am here 75"<<endl;
	 //chain->Add("/data/LHC10d15/1821/AliESDs.root");//simulation p+p
	 chain->Add("/data/LHC11b10a/001/AliESDs.root");
       }
     }
  }

  // Make the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("TotEtManager");
  if(submit){

    gROOT->LoadMacro("CreateAlienHandlerHadEt.C");
    AliAnalysisGrid *alienHandler = CreateAlienHandlerHadEt(dataset,data,test,material,altV0Scale,runCompiledVersion,simflag);//integer dataset, boolean isData, bool submit-in-test-mode, bool use alternatve V0 scaling
      if (!alienHandler) return;
      mgr->SetGridHandler(alienHandler);
  }

  cerr<<"Hello I am here 91"<<endl;
  AliVEventHandler* esdH = new AliESDInputHandler;
  mgr->SetInputEventHandler(esdH);
  AliMCEventHandler* handler = new AliMCEventHandler;
  if(!data){
    handler->SetReadTR(kFALSE);
    mgr->SetMCtruthEventHandler(handler);
  }


  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
  AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(!data);
  if(!physSelTask) { Printf("no physSelTask"); return; }
  AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection();
  //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769");
  //physSelTask->AddCollisionTriggerClass("kMB");// #3119 #769");

  cerr<<"Hello I am here 108"<<endl;

  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");

  AliCentralitySelectionTask *centTask;
  
  if(PbPb){
    AliCentralitySelectionTask *centTask = AddTaskCentrality();
   if(!data){
     cout<<"Setting up centrality for MC"<<endl;
     centTask->SetMCInput();
   }
   else{
     cout<<"Setting up centrality for data"<<endl;
   }
  }
  Int_t pass = 2;
   if(dataset==20100){//PbPb 2.76 TeV
     if(simflag==0){
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.ForSimulations.root","corrections.root",kTRUE);}
       if(material==11){//AMPT only available for this run
	 cout<<"Running AMPT"<<endl;
	 gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.137366.ForData.root","corrections.root",kTRUE);
       }
     }
     if(simflag==1){
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138442.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138442.ForSimulations.root","corrections.root",kTRUE);}
     }
     if(simflag==2){
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138364.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138364.ForSimulations.root","corrections.root",kTRUE);}
     }
     if(simflag==3){
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138396.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run138396.ForSimulations.root","corrections.root",kTRUE);}
     }
     if(simflag==4){
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137722.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137722.ForSimulations.root","corrections.root",kTRUE);}
     }
     if(simflag==5){
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137366.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137366.ForSimulations.root","corrections.root",kTRUE);}
     }
     if(simflag==6){
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137161.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.Run137161.ForSimulations.root","corrections.root",kTRUE);}
     }
     gSystem->CopyFile("ConfigHadEtMonteCarloPbPb.C","ConfigHadEtMonteCarlo.C",kTRUE);
     gSystem->CopyFile("ConfigHadEtReconstructedPbPb.C","ConfigHadEtReconstructed.C",kTRUE);
     if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.ForData.root","corrections.root",kTRUE);}
     else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11a10a_bis.PbPb.ForSimulations.root","corrections.root",kTRUE);}
     pass = 2;
     //centTask->SetPass(1);
   }
   else{
     if(dataset==2011){//PbPb 2.76 TeV 2011
       gSystem->CopyFile("ConfigHadEtMonteCarloPbPb2011.C","ConfigHadEtMonteCarlo.C",kTRUE);
       gSystem->CopyFile("ConfigHadEtReconstructedPbPb2011.C","ConfigHadEtReconstructed.C",kTRUE);
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC13e1abc.PbPb.168464.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC13e1abc.PbPb.168464.ForSimulations.root","corrections.root",kTRUE);}
     }
     if(dataset==2009){//pp 900 GeV
       gSystem->CopyFile("ConfigHadEtMonteCarlopp900GeV.C","ConfigHadEtMonteCarlo.C",kTRUE);
       gSystem->CopyFile("ConfigHadEtReconstructedpp900GeV.C","ConfigHadEtReconstructed.C",kTRUE);
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11b1a.pp.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11b1a.pp.ForSimulations.root","corrections.root",kTRUE);}
       pass = 3;
     }
     if(dataset==20111){//pp 2.76 TeV
       if(altV0Scale)gSystem->CopyFile("ConfigHadEtMonteCarlopp276TeVAlt.C","ConfigHadEtMonteCarlo.C",kTRUE);
       else{gSystem->CopyFile("ConfigHadEtMonteCarlopp276TeV.C","ConfigHadEtMonteCarlo.C",kTRUE);}
       gSystem->CopyFile("ConfigHadEtReconstructedpp276TeV.C","ConfigHadEtReconstructed.C",kTRUE);
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC11b10a.pp.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC11b10a.pp.ForSimulations.root","corrections.root",kTRUE);}
       pass = 4;
     }
     if(dataset==2010){//pp 7 TeV
       gSystem->CopyFile("ConfigHadEtMonteCarlopp7TeV.C","ConfigHadEtMonteCarlo.C",kTRUE);
       gSystem->CopyFile("ConfigHadEtReconstructedpp7TeV.C","ConfigHadEtReconstructed.C",kTRUE);
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC10e20.pp.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC10e20.pp.ForSimulations.root","corrections.root",kTRUE);}
       pass = 2;
     }
     if(dataset==2012){//pp 8 TeV
       gSystem->CopyFile("ConfigHadEtMonteCarlopp8TeV.C","ConfigHadEtMonteCarlo.C",kTRUE);
       gSystem->CopyFile("ConfigHadEtReconstructedpp8TeV.C","ConfigHadEtReconstructed.C",kTRUE);
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC12c1b.pp.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC12c1b.pp.ForSimulations.root","corrections.root",kTRUE);}
       pass = 1;
     }
     if(dataset==2013){//pPb 5 TeV
       gSystem->CopyFile("ConfigHadEtMonteCarlopPb5TeV.C","ConfigHadEtMonteCarlo.C",kTRUE);
       gSystem->CopyFile("ConfigHadEtReconstructedpPb5TeV.C","ConfigHadEtReconstructed.C",kTRUE);
       if(data){gSystem->CopyFile("rootFiles/corrections/corrections.LHC13b3.pPb.ForData.root","corrections.root",kTRUE);}
       else{gSystem->CopyFile("rootFiles/corrections/corrections.LHC13b3.pPb.ForSimulations.root","corrections.root",kTRUE);}
       pass = 3;
     }
   }
   
   
   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
  cerr<<"I am adding PID response task 169"<<endl;
  //AliAnalysisTask *AddTaskPIDResponse(Bool_t isMC=kFALSE, Bool_t autoMCesd=kTRUE,
//                                     Bool_t tuneOnData=kFALSE, Int_t recoPass=2,
//                                     Bool_t cachePID=kFALSE, TString detResponse="",
//                                     Bool_t useTPCEtaCorrection = kFALSE);
  AliAnalysisTaskPIDResponse *taskPID=AddTaskPIDResponse(!data,kTRUE,kTRUE,pass);
  //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
  //AddTaskPIDqa();

   AliAnalysisTaskHadEt *task2 = new AliAnalysisTaskHadEt("TaskHadEt",!data);//,recoFile,mcFile);
   if(!data) task2->SetMcData();
   //Add thing here to select collision type!!
     if(dataset==2013){//pPb 5 TeV
       //task2->SelectCollisionCandidates(AliVEvent::kAnyINT ) ;
       task2->SelectCollisionCandidates(AliVEvent::kINT7 ) ;
     }
     else{   if(dataset!=20100){task2->SelectCollisionCandidates(AliVEvent::kMB ) ;}}
   //if(dataset!=20100){task2->SelectCollisionCandidates(AliVEvent::kMB ) ;}
   mgr->AddTask(task2);
  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("out2", TList::Class(), AliAnalysisManager::kOutputContainer,"Et.ESD.new.sim.root");
//    mgr->ConnectInput(task2,0,cinput1);
//    mgr->ConnectOutput(task2,1,coutput2);
   mgr->ConnectInput(task2,0,cinput1);
   mgr->ConnectOutput(task2,1,coutput2);
   
  mgr->SetDebugLevel(0);
  
  if (!mgr->InitAnalysis()) return;
  mgr->PrintStatus();
  if(submit){
    mgr->StartAnalysis("grid");
  }
  else{
    mgr->StartAnalysis("local",chain);
  }

  timer.Stop();
  timer.Print();
}
 runHadEt.C:1
 runHadEt.C:2
 runHadEt.C:3
 runHadEt.C:4
 runHadEt.C:5
 runHadEt.C:6
 runHadEt.C:7
 runHadEt.C:8
 runHadEt.C:9
 runHadEt.C:10
 runHadEt.C:11
 runHadEt.C:12
 runHadEt.C:13
 runHadEt.C:14
 runHadEt.C:15
 runHadEt.C:16
 runHadEt.C:17
 runHadEt.C:18
 runHadEt.C:19
 runHadEt.C:20
 runHadEt.C:21
 runHadEt.C:22
 runHadEt.C:23
 runHadEt.C:24
 runHadEt.C:25
 runHadEt.C:26
 runHadEt.C:27
 runHadEt.C:28
 runHadEt.C:29
 runHadEt.C:30
 runHadEt.C:31
 runHadEt.C:32
 runHadEt.C:33
 runHadEt.C:34
 runHadEt.C:35
 runHadEt.C:36
 runHadEt.C:37
 runHadEt.C:38
 runHadEt.C:39
 runHadEt.C:40
 runHadEt.C:41
 runHadEt.C:42
 runHadEt.C:43
 runHadEt.C:44
 runHadEt.C:45
 runHadEt.C:46
 runHadEt.C:47
 runHadEt.C:48
 runHadEt.C:49
 runHadEt.C:50
 runHadEt.C:51
 runHadEt.C:52
 runHadEt.C:53
 runHadEt.C:54
 runHadEt.C:55
 runHadEt.C:56
 runHadEt.C:57
 runHadEt.C:58
 runHadEt.C:59
 runHadEt.C:60
 runHadEt.C:61
 runHadEt.C:62
 runHadEt.C:63
 runHadEt.C:64
 runHadEt.C:65
 runHadEt.C:66
 runHadEt.C:67
 runHadEt.C:68
 runHadEt.C:69
 runHadEt.C:70
 runHadEt.C:71
 runHadEt.C:72
 runHadEt.C:73
 runHadEt.C:74
 runHadEt.C:75
 runHadEt.C:76
 runHadEt.C:77
 runHadEt.C:78
 runHadEt.C:79
 runHadEt.C:80
 runHadEt.C:81
 runHadEt.C:82
 runHadEt.C:83
 runHadEt.C:84
 runHadEt.C:85
 runHadEt.C:86
 runHadEt.C:87
 runHadEt.C:88
 runHadEt.C:89
 runHadEt.C:90
 runHadEt.C:91
 runHadEt.C:92
 runHadEt.C:93
 runHadEt.C:94
 runHadEt.C:95
 runHadEt.C:96
 runHadEt.C:97
 runHadEt.C:98
 runHadEt.C:99
 runHadEt.C:100
 runHadEt.C:101
 runHadEt.C:102
 runHadEt.C:103
 runHadEt.C:104
 runHadEt.C:105
 runHadEt.C:106
 runHadEt.C:107
 runHadEt.C:108
 runHadEt.C:109
 runHadEt.C:110
 runHadEt.C:111
 runHadEt.C:112
 runHadEt.C:113
 runHadEt.C:114
 runHadEt.C:115
 runHadEt.C:116
 runHadEt.C:117
 runHadEt.C:118
 runHadEt.C:119
 runHadEt.C:120
 runHadEt.C:121
 runHadEt.C:122
 runHadEt.C:123
 runHadEt.C:124
 runHadEt.C:125
 runHadEt.C:126
 runHadEt.C:127
 runHadEt.C:128
 runHadEt.C:129
 runHadEt.C:130
 runHadEt.C:131
 runHadEt.C:132
 runHadEt.C:133
 runHadEt.C:134
 runHadEt.C:135
 runHadEt.C:136
 runHadEt.C:137
 runHadEt.C:138
 runHadEt.C:139
 runHadEt.C:140
 runHadEt.C:141
 runHadEt.C:142
 runHadEt.C:143
 runHadEt.C:144
 runHadEt.C:145
 runHadEt.C:146
 runHadEt.C:147
 runHadEt.C:148
 runHadEt.C:149
 runHadEt.C:150
 runHadEt.C:151
 runHadEt.C:152
 runHadEt.C:153
 runHadEt.C:154
 runHadEt.C:155
 runHadEt.C:156
 runHadEt.C:157
 runHadEt.C:158
 runHadEt.C:159
 runHadEt.C:160
 runHadEt.C:161
 runHadEt.C:162
 runHadEt.C:163
 runHadEt.C:164
 runHadEt.C:165
 runHadEt.C:166
 runHadEt.C:167
 runHadEt.C:168
 runHadEt.C:169
 runHadEt.C:170
 runHadEt.C:171
 runHadEt.C:172
 runHadEt.C:173
 runHadEt.C:174
 runHadEt.C:175
 runHadEt.C:176
 runHadEt.C:177
 runHadEt.C:178
 runHadEt.C:179
 runHadEt.C:180
 runHadEt.C:181
 runHadEt.C:182
 runHadEt.C:183
 runHadEt.C:184
 runHadEt.C:185
 runHadEt.C:186
 runHadEt.C:187
 runHadEt.C:188
 runHadEt.C:189
 runHadEt.C:190
 runHadEt.C:191
 runHadEt.C:192
 runHadEt.C:193
 runHadEt.C:194
 runHadEt.C:195
 runHadEt.C:196
 runHadEt.C:197
 runHadEt.C:198
 runHadEt.C:199
 runHadEt.C:200
 runHadEt.C:201
 runHadEt.C:202
 runHadEt.C:203
 runHadEt.C:204
 runHadEt.C:205
 runHadEt.C:206
 runHadEt.C:207
 runHadEt.C:208
 runHadEt.C:209
 runHadEt.C:210
 runHadEt.C:211
 runHadEt.C:212
 runHadEt.C:213
 runHadEt.C:214
 runHadEt.C:215
 runHadEt.C:216
 runHadEt.C:217
 runHadEt.C:218
 runHadEt.C:219
 runHadEt.C:220
 runHadEt.C:221
 runHadEt.C:222
 runHadEt.C:223
 runHadEt.C:224
 runHadEt.C:225
 runHadEt.C:226
 runHadEt.C:227
 runHadEt.C:228
 runHadEt.C:229
 runHadEt.C:230
 runHadEt.C:231
 runHadEt.C:232
 runHadEt.C:233
 runHadEt.C:234
 runHadEt.C:235
 runHadEt.C:236
 runHadEt.C:237
 runHadEt.C:238
 runHadEt.C:239
 runHadEt.C:240
 runHadEt.C:241
 runHadEt.C:242
 runHadEt.C:243
 runHadEt.C:244
 runHadEt.C:245
 runHadEt.C:246
 runHadEt.C:247
 runHadEt.C:248
 runHadEt.C:249
 runHadEt.C:250
 runHadEt.C:251
 runHadEt.C:252
 runHadEt.C:253
 runHadEt.C:254
 runHadEt.C:255
 runHadEt.C:256
 runHadEt.C:257
 runHadEt.C:258
 runHadEt.C:259
 runHadEt.C:260
 runHadEt.C:261
 runHadEt.C:262
 runHadEt.C:263
 runHadEt.C:264
 runHadEt.C:265
 runHadEt.C:266
 runHadEt.C:267
 runHadEt.C:268
 runHadEt.C:269