コード例 #1
0
ファイル: runCPVAnalysis.C プロジェクト: ktf/AliPhysics
void runCPVAnalysis(const char *runmode = "full")
{
    // set if you want to run the analysis locally (kTRUE), or on grid (kFALSE)
    // Bool_t local = kFALSE;
     Bool_t local = kTRUE;
    // if you run on grid, specify test mode (kTRUE) or full grid model (kFALSE)
    // Bool_t gridTest = kTRUE;
    Bool_t gridTest = kFALSE;
    
    // since we will compile a class, tell root where to look for headers  
    gROOT->ProcessLine(".include $ROOTSYS/include");
    gROOT->ProcessLine(".include $ALICE_ROOT/include");

    // create the analysis manager
    AliAnalysisManager *mgr = new AliAnalysisManager("AnalysisTaskCPV");
    AliESDInputHandler *esdH = new AliESDInputHandler();
    mgr->SetInputEventHandler(esdH);


    //PID task
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
    AliAnalysisTask *taskPID =  AddTaskPIDResponse(/*Bool_t isMC=*/ kFALSE, /*Bool_t autoMCesd=*/kTRUE,
						   /*Bool_t tuneOnData=*/kTRUE);
    
    // // Add physics selection
    gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
    AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
    physSelTask->GetPhysicsSelection()->SetUseBXNumbers(kFALSE);// ---> ???
    
    // load the addtask macro
    gROOT->LoadMacro("AddTaskCPV.C");
    // create an instance of your analysis task
    AliAnalysisTaskCPV *task = AddTaskCPV();
    task->SetRCPV(428.3);
    task->SelectCollisionCandidates(AliVEvent::kINT7);

    if(!mgr->InitAnalysis()) return;
    mgr->SetDebugLevel(2);
    mgr->PrintStatus();
    mgr->SetUseProgressBar(1, 25);

    if(local) {
        // if you want to run locally, we need to define some input
        TChain* chain = new TChain("esdTree");
        // add a few files to the chain (change this so that your local files are added)
        TGrid::Connect("alien://");
        chain->Add("alien:///alice/data/2015/LHC15n/000244340/pass2/15000244340020.100/AliESDs.root");
        // start the analysis locally, reading the events from the tchain
        mgr->StartAnalysis("local", chain);
    } else {
        // if we want to run on grid, we create and configure the plugin
        AliAnalysisAlien *alienHandler = new AliAnalysisAlien();
	alienHandler->SetCheckCopy(kFALSE);
        // also specify the include (header) paths on grid
        alienHandler->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_PHYSICS/include");
        // select the aliphysics version. all other packages
        // are LOADED AUTOMATICALLY!
        alienHandler->SetAliPhysicsVersion("vAN-20170215-1");
        // set the Alien API version
        alienHandler->SetAPIVersion("V1.1x");
        // select the input data
        alienHandler->SetGridDataDir("/alice/data/2015/LHC15n");
        alienHandler->SetDataPattern("/pass2/*/AliESDs.root");

	const Int_t runList[] = {244340, 244343};
	const Int_t nRuns = 2;
	// const Int_t runList[] = {244340, 244343, 244351, 244355, 244359, 
	// 			 244364, 244377, 244411, 244416, 244418, 
	// 			 244421, 244453, 244480, 244481, 244482, 
	// 			 244483, 244484, 244531, 244540, 244542, 
	// 			 244617, 244618, 244627, 244628};
	// const Int_t nRuns = 24;
        // MC has no prefix, data has prefix 000
        alienHandler->SetRunPrefix("000");
        // runnumber
	for (Int_t iRun=0; iRun<nRuns; iRun++) {
	  alienHandler->AddRunNumber(runList[iRun]);
	}
        // number of files per subjob
        alienHandler->SetSplitMaxInputFileNumber(50);
        alienHandler->SetExecutable("CPVTask.sh");
        // specify how many seconds your job may take
        alienHandler->SetTTL(36000);
        alienHandler->SetJDLName("CPVTask.jdl");

        alienHandler->SetOutputToRunNo(kTRUE);
        alienHandler->SetKeepLogs(kTRUE);
        // merging: run with kTRUE to merge on grid
        // after re-running the jobs in SetRunMode("terminate") 
        // (see below) mode, set SetMergeViaJDL(kFALSE) 
        // to collect final results
        alienHandler->SetMaxMergeStages(2);
        alienHandler->SetMergeViaJDL(kTRUE);

        // define the output folders
        alienHandler->SetGridWorkingDir("CPVWorkingDir");
        alienHandler->SetGridOutputDir("CPVOutputDir_R428");

        // connect the alien plugin to the manager
        mgr->SetGridHandler(alienHandler);
        if(gridTest) {
            // speficy on how many files you want to run
            alienHandler->SetNtestFiles(1);
            // and launch the analysis
            alienHandler->SetRunMode("test");
            mgr->StartAnalysis("grid");
        } else {
            // else launch the full grid analysis
            alienHandler->SetRunMode(runmode);
            mgr->StartAnalysis("grid");
        }
    }
}
コード例 #2
0
ファイル: RunMacro.C プロジェクト: gyronaut/utaustin
void RunMacro(){
//     check the function for asymmetric TPC cut in ConfigHFEemcalMod....the rest is still necessary????

   // Firstly, set some variables
   const char* launch = "grid"; // grid, local (if your data is on your local machine, doesn't connect at all)
   const char*  mode = "test"; //test, full, terminate  (test= connect to grid but run locally, full= run on grid, terminate= merge output on grid)
   Bool_t pre_final_stage = kTRUE; //TRUE = merging done on grid, FALSE = merge happens locally   
   Int_t cyclenumber = 1;
   Bool_t debug = kTRUE;
   char* work_dir = "PhiCorrelations_LHC16q_0_20_noveto";
   char* output_dir = "output_2018_10_22_FAST";
   Int_t ttl = 50000;
   Int_t noffiles = 40;
   Int_t runcycle[]={0,1,31};
   //Int_t runcycle[]={0,16,31};
   Bool_t UseParfiles = kFALSE;

   // load libraries
   LoadLibraries();

// create and customize the alien handler
  AliAnalysisAlien *alienHandler = new AliAnalysisAlien();
      
    alienHandler->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/EMCAL -I$ALICE_ROOT/PYTHIA6 -I$ALICE_ROOT/ANALYSIS -I$ALICE_PHYSICS/PWGGA -I$ALICE_PHYSICS/PWGHF -I$ALICE_PHYSICS/PWGHF/hfe -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER/STEER -I$ALICE_ROOT/STEER/STEERBase -I$ALICE_ROOT/STEER/ESD -I$ALICE_ROOT/STEER/AOD -I$ALICE_PHYSICS/OADB -I$ALICE_PHYSICS/PWGHF/base  -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS  -I$ALICE_PHYSICS/OADB/macros -I$ALICE_PHYSICS/PWGCF/Correlations -I$ALICE_PHYSICS/PWGCF -I$ALICE_PHYSICS/PWGCF/Correlations/Base -I$ALICE_PHYSICS/include -g");
    
    alienHandler->SetAdditionalLibs("AliAnalysisTaskHadronPhiCorr_current.cxx AliAnalysisTaskHadronPhiCorr_current.h AddTaskHadronPhiCorr_current.C libpythia6.so libEGPythia6.so libAliPythia6.so libPWGHFhfe.so libCDB.so libSTEER.so libCORRFW.so libPWGflowBase.so libPWGflowTasks.so libGui.so libProof.so libMinuit.so libXMLParser.so libRAWDatabase.so libRAWDatarec.so libCDB.so libSTEERBase.so libSTEER.so libTPCbase.so libTOFbase.so libTOFrec.so libTRDbase.so libVZERObase.so libVZEROrec.so libT0base.so libT0rec.so libPWGTools.so libPWGCFCorrelationsBase.so");
    
  alienHandler->SetAnalysisSource("AliAnalysisTaskHadronPhiCorr_current.cxx");
  //alienHandler->SetOverwriteMode();
  alienHandler->SetRunMode(mode);
  alienHandler->SetNtestFiles(2);
  //alienHandler->SetAPIVersion("V1.1x");
  alienHandler->SetAliPhysicsVersion("vAN-20170731-1");
  //alienHandler->SetFileForTestMode("File_LHC12dPass1.txt");  //txt file that tells where to look for local files if launch=local
  //alienHandler->SetGridDataDir("/alice/sim/LHC10d4/");
  //alienHandler->SetDataPattern("*ESDs.root");
  alienHandler->SetGridDataDir("//alice/data/2016/LHC16q/");
  alienHandler->SetDataPattern("*/pass1_FAST/AOD/*/*AOD.root");
  //alienHandler->SetDataPattern("*/pass4/AOD/*AOD.root");
  alienHandler->SetRunPrefix("000"); // IMPORTANT! Only need for real data, comment this line out for MC data

   
//LHC12d   
    //Int_t runArray[] = {186320, 186319, 186318, 186229, 186208, 186205, 186200, 186167, 186165, 186164, 186163, 185912, 185909, 185784, 185778, 185776, 185775, 185768, 185765, 185764, 185757, 185756, 185738, 185735, 185734, 185701, 185699, 185698, 185697, 185695, 185687, 185680, 185589, 185588, 185583, 185582, 185581, 185580, 185578};
  //Int_t runArray[] = {186320, 186319, 186318, 186229, 186208, 186205, 186200, 186167, 186165, 186164, 186163, 185912, 185909, 185784, 185778, 185776, 185775, 185768, 185765, 185764, 185757, 185756, 185738, 185735, 185734, 185701, 185699, 185698, 185697, 185695, 185687, 185680, 185589, 185588, 185583, 185582, 185581, 185580, 185578, 185575, 185574, 185565, 185563, 185474, 185465, 185461, 185457, 185375, 185371, 185363, 185362, 185361, 185360, 185359, 185356, 185351, 185350, 185349, 185303, 185302, 185300, 185299, 185296, 185293, 185292, 185291, 185289, 185288, 185284, 185282, 185221, 185217, 185208, 185206, 185203, 185198, 185196, 185189};

 //LHC13b
    //Int_t runArray[] = {195483, 195482, 195481, 195480, 195479, 195478, 195391, 195389, 195351, 195346, 195344}; 

 //LHC13c
    //Int_t runArray[] = {195529, 195531, 195566, 195567, 195568, 195592, 195593, 195596, 195633, 195635, 195644, 195673, 195675, 195677};

//LHC10d4 - MC Data
    //Int_t runArray[] = {119159, 119161, 119163, 119841, 119842, 119844, 119845, 119846, 119849, 119853, 119856, 119859, 119862, 120067, 120069, 120072, 120073, 120076, 120079, 120244, 120503, 120504, 120505, 120616, 120617, 120671, 120741, 120750, 120758, 120820, 120821, 120822, 120823, 120824, 120825, 120829};
   // Int_t runArray[] = {120073}; //for testing why files were being opened but not closed

//LHC16r - 8 TeV pPb data
    //Int_t runArray[] = {266318, 266317, 266316, 266305, 266304, 266300, 266299, 266296, 266208, 266197, 266196, 266193, 266190, 266189, 266187, 266117, 266086, 266085, 266084, 266083, 266081, 266076, 266074, 266034, 265797, 265795, 265789, 265788, 265756, 265754, 265746, 265744, 265742, 265741, 265714, 265713,265709, 265705, 265701, 265700, 265698, 265697, 265696, 265607, 265596, 265594};
   //Int_t runArray[] = {266318, 266317, 266316, 266208, 266197, 266196, 266187, 265754, 265744, 265607, 265596, 265594};

//LHC16q - 5 TeV pPb data
   Int_t runArray[] = {265525, 265521, 265501, 265500, 265499, 265435, 265427, 265426, 265425, 265424, 265422, 265421, 265420, 265419, 265388, 265387, 265385, 265384, 265383, 265381, 265378, 265377, 265344, 265343, 265342, 265339, 265338, 265336, 265334, 265332, 265309};  
    
  
  for (Int_t i =  runcycle[cyclenumber - 1]; i < runcycle[cyclenumber] ; i++)
   {
    if (i == sizeof(runArray) / sizeof(runArray[1])) break;
    alienHandler->AddRunNumber(runArray[i]);
   }

   printf("\n\nSetting Up alienHandler.\n\n");
   alienHandler->SetGridWorkingDir(work_dir);
   alienHandler->SetGridOutputDir(output_dir);
   alienHandler->SetDefaultOutputs(kTRUE);
   alienHandler->SetAnalysisMacro("PhiInvMass.C");
   alienHandler->SetSplitMaxInputFileNumber(noffiles);
   alienHandler->SetExecutable("PhiInvMass.sh");
   alienHandler->SetExecutableCommand("aliroot -b -q");
   alienHandler->SetTTL(ttl); //10000
   alienHandler->SetInputFormat("xml-single");
   alienHandler->SetJDLName("PhiInvMass.jdl");
   alienHandler->SetPrice(1);
   alienHandler->SetSplitMode("se");
   alienHandler->SetMasterResubmitThreshold(10);
   alienHandler->SetMergeExcludes("EventStat_temp.root");
   alienHandler->SetOutputToRunNo(kTRUE);
   alienHandler->SetKeepLogs(kTRUE);
   alienHandler->SetMaxMergeFiles(15);
   alienHandler->SetMaxMergeStages(7);
   alienHandler->SetMergeViaJDL(pre_final_stage);
//    alienHandler->SetOneStageMerging(kFALSE);   //???????????????????????????????-------------------
    if (!alienHandler) return;

    
// load the necessary macros
   //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
   //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
// Use AliRoot includes to compile our task
   gROOT->ProcessLine(".include $ALICE_ROOT/include");
   gROOT->ProcessLine(".include $ALICE_ROOT/EMCAL");
   gROOT->ProcessLine(".include $ALICE_PHYSICS/include");
   gROOT->ProcessLine(".include $ALICE_ROOT/ANALYSIS/");
   gROOT->ProcessLine(".include $PWD/.");

   gSystem->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/EMCAL -I$ALICE_ROOT/PYTHIA6 -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER/STEER -I$ALICE_ROOT/STEER/STEERBase -I$ALICE_ROOT/STEER/ESD -I$ALICE_ROOT/STEER/AOD -I$ALICE_PHYSICS/OADB -I$ALICE_PHYSICS/PWGHF/base  -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS  -I$ALICE_PHYSICS/OADB -I$ALICE_ROOT/PWG/FLOW/Base -I$ALICE_PHYSICS/PWGCF/Correlations/Base -I$ALICE_PHYSICS/PWGCF/Correlations -g ");
   // gSystem->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/macros -I$ALICE_PHYSICS/include -g");

   //printf("\n!!!!!!!!!!!!!!!!!!!!!!\n AliAnalysis Manager \n\n");
   AliAnalysisManager *mgr = new AliAnalysisManager("PhiAnalysis");
   mgr->SetGridHandler(alienHandler);

   AliAODInputHandler* aodH = new AliAODInputHandler();
   mgr->SetInputEventHandler(aodH);
//   AliESDInputHandler* esdH = new AliESDInputHandler();
//   mgr->SetInputEventHandler(esdH);

//    AliMCEventHandler* mcH = new AliMCEventHandler();
//    mgr->SetMCtruthEventHandler(mcH);   
//    mcH->SetReadTR(kFALSE);

   //gROOT->LoadMacro("AddTaskPhiCorr.C");
   gROOT->LoadMacro("./AliAnalysisTaskHadronPhiCorr.cxx++g");
   //gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
   //gROOT->LoadMacro("$ALICE_PHYSICS/OADB/COMMON/MULTIPLICITY/macros/AddTaskMultSelection.C");
   //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");


    //switch on aliphysicsselection
    gInterpreter->ProcessLine(Form(".x %s", gSystem->ExpandPathName("$ALICE_PHYSICS/OADB/COMMON/MULTIPLICITY/macros/AddTaskMultSelection.C")));
    AliPhysicsSelectionTask* physSelTask = reinterpret_cast<AliPhysicsSelectionTask*>(gInterpreter->ProcessLine(Form(".x %s(kFALSE, kTRUE)", gSystem->ExpandPathName("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C")))); 
    //Only set true for MC
    Bool_t isMC = kFALSE;
    gInterpreter->ProcessLine(Form(".x %s(kFALSE)", gSystem->ExpandPathName("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C")));

    //create a task
    AliAnalysisTaskHadronPhiCorr_current *task1 = reinterpret_cast<AliAnalysisTaskHadronPhiCorr_current*>(gInterpreter->ProcessLine(Form(".x %s(kFALSE, 0.0, 20.0)", gSystem->ExpandPathName("AddTaskHadronPhiCorr_current.C"))));
    //AliAnalysisTaskHadronPhiCorr_current *task2 = reinterpret_cast<AliAnalysisTaskHadronPhiCorr_current*>(gInterpreter->ProcessLine(Form(".x %s(true, 10.0, 20.0)", gSystem->ExpandPathName("AddTaskHadronPhiCorr_current.C"))));
    //AliAnalysisTaskHadronPhiCorr_current *task3 = reinterpret_cast<AliAnalysisTaskHadronPhiCorr_current*>(gInterpreter->ProcessLine(Form(".x %s(kFALSE, 20.0, 40.0)", gSystem->ExpandPathName("AddTaskHadronPhiCorr_current.C"))));
    //AliAnalysisTaskHadronPhiCorr_current *task4 = reinterpret_cast<AliAnalysisTaskHadronPhiCorr_current*>(gInterpreter->ProcessLine(Form(".x %s(kTRUE, 40.0, 90.0)", gSystem->ExpandPathName("AddTaskHadronPhiCorr_current.C"))));

    task1->SetKaonEtaCut(0.8);
    task1->SetKaonTPCCut(3.0);
    task1->SetKaonTOFCut(3.0);
    task1->SetTOFVeto(kFALSE);
    task1->SetKaonTrkBit(1024);
    task1->SetAssocTrkBit(1024);
    task1->SetTrigTrkBit(AliAODTrack::kIsHybridGCG);
    task1->SetZVertexMin(-10.0);
    task1->SetZVertexMax(10.0);
    task1->SetZVertexNbins(10);
    task1->SetCentEstimator("V0A");


   if (!mgr->InitAnalysis())
     return;

   mgr->PrintStatus();
   //fprintf(stdout, "\n!!!!!!!!!!!!!\nAbout to launch analysis... \n");
   // Start analysis in grid.
   mgr->StartAnalysis(launch);
   //printf("\n!!!!!!!!!!!!!\nDone with StartAnalysis(launch)\n");
   fflush(stdout);
}
コード例 #3
0
AliAnalysisGrid* CreateAlienHandlerHadEt(Int_t dataset, Bool_t data, Int_t test, Int_t material, Bool_t altV0Scale = kFALSE, bool runCompiledVersion = kFALSE, int simflag = 0)
{
  // Check if user has a valid token, otherwise make one. This has limitations.
  // One can always follow the standard procedure of calling alien-token-init then
  //   source /tmp/gclient_env_$UID in the current shell.
  //if (!AliAnalysisGrid::CreateToken()) return NULL;
  AliAnalysisAlien *plugin = new AliAnalysisAlien();

  // Overwrite all generated files, datasets and output results from a previous session
  plugin->SetOverwriteMode();
  // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
  if(test==1){
    plugin->SetRunMode("test");  // VERY IMPORTANT - DECRIBED BELOW
  }
  else{
    if(test==0){
      plugin->SetRunMode("full");  // VERY IMPORTANT - DECRIBED BELOW
    }
    else{
      plugin->SetRunMode("terminate");  // VERY IMPORTANT - DECRIBED BELOW
    }
  }
  //needed for local testing?
  //plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc
  // Set versions of used packages 
   plugin->SetAPIVersion("V1.1x");
   plugin->SetROOTVersion("v5-34-08-6");
   plugin->SetAliROOTVersion("vAN-20140624");
  // Declare input data to be processed.

   plugin->AddIncludePath("-I$ALICE_ROOT/PWGUD/base  -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/PWGPP -I$ALICE_ROOT/PWGPP/ITS");
  // Method 1: Create automatically XML collections using alien 'find' command.
  // Define production directory LFN
  //   plugin->SetGridDataDir("/alice/sim/LHC10a18");
  // Set data search pattern
  //   plugin->SetDataPattern("*ESDs.root");  // simulated, tags not used
  //   plugin->SetDataPattern("*ESDs/pass4/*ESDs.root"); // real data check reco pass and data base directory
  //   plugin->SetRunPrefix("000");   // real data
  //   plugin->SetDataPattern("*tag.root");  // Use ESD tags (same applies for AOD's)
  // ...then add run numbers to be considered
  //   plugin->AddRunNumber(125020);    // simulated
  //   plugin->AddRunNumber(104065);  // real data

  // Method 2: Declare existing data files (raw collections, xml collections, root file)
  // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
  // XML collections added via this method can be combined with the first method if
  // the content is compatible (using or not tags)
  //plugin->AddDataFile("tag.xml");
  //   plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
   TString outputdir = "etPbPbSim";
   if(data)outputdir = "etPbPbData";
  if(dataset==20100){//PbPb 2.76 TeV
    if(data){//185 jobs
      cout<<"Running over data"<<endl;
      plugin->SetGridDataDir("/alice/data/2010/LHC10h");//PbPb data
      plugin->SetDataPattern("*ESDs/pass2/*ESDs.root");
      plugin->SetRunPrefix("000");   // real data

    }
    else{
      cout<<"Running over MC"<<endl;
      if(material==0){
	  plugin->SetGridDataDir("/alice/sim/LHC11a10a_bis");
	//plugin->SetGridDataDir("/alice/sim/LHC11a4_bis");//PbPb simulation
      }
      if(material==1){//7% more material
	plugin->SetGridDataDir("/alice/sim/LHC10h9");//PbPb simulation
      }
      if(material==-1){//7% less material
	plugin->SetGridDataDir("/alice/sim/LHC10h10");//PbPb simulation
      }
      if(material==10){//OK it's a cheat but this runs on DPM jet
	plugin->SetGridDataDir("/alice/sim/LHC10h2");//PbPb simulation
      }
      if(material==11){//OK it's a cheat but this runs on AMPT
	plugin->SetGridDataDir(" /alice/sim/LHC11a9a");//PbPb simulation
	plugin->AddRunNumber(137366);
      }
      plugin->SetDataPattern("*ESDs.root");
      //plugin->SetGridWorkingDir("etPbPbSim");
    }
    if(simflag==0){//not really using it as a simflag but that way I don't need a new argument...
      plugin->AddRunNumber(139465);
      outputdir += "139465";
    }
    if(simflag==1){//not really using it as a simflag but that way I don't need a new argument...
      outputdir += "138442";
      plugin->AddRunNumber(138442);
    }
    if(simflag==2){//not really using it as a simflag but that way I don't need a new argument...
      outputdir += "138364";
      plugin->AddRunNumber(138364);
    }
    if(simflag==3){//not really using it as a simflag but that way I don't need a new argument...
      outputdir += "138396";
      plugin->AddRunNumber(138396);
    }
    if(simflag==4){//not really using it as a simflag but that way I don't need a new argument...
      outputdir += "137722";
      plugin->AddRunNumber(137722);
    }
    if(simflag==5){//not really using it as a simflag but that way I don't need a new argument...
      outputdir += "137366";
      plugin->AddRunNumber(137366);
    }
    if(simflag==6){//not really using it as a simflag but that way I don't need a new argument...
      outputdir += "137161";
      plugin->AddRunNumber(137161);
    }
    cout<<"writing to "<<outputdir.Data()<<endl;
  }
  else{
    if(dataset==2011){//PbPb 2.76 TeV
      if(data){//185 jobs
	cout<<"Running over data"<<endl;
	 plugin->SetGridDataDir("/alice/data/2011/LHC11h_2");//PbPb data
	 plugin->SetDataPattern("*ESDs/pass2/*ESDs.root");
	 plugin->SetRunPrefix("000");   // real data
      }
      else{
	cout<<"Running over MC"<<endl;
	if(simflag==0){//2011 production - 0-10%
	  cout<<"I am here setting grid data dir"<<endl;
// 	  outputDir = outputDir + "LHC13e1a";
	  plugin->SetGridDataDir("/alice/sim/2013/LHC13e1a");
	}
	if(simflag==1){//2011 production - 0-10%
	  cout<<"I am here setting grid data dir"<<endl;
// 	  outputDir = outputDir + "LHC13e1a";
	  plugin->SetGridDataDir("/alice/sim/2013/LHC13e1b");
	}
	if(simflag==2){//2011 production - 0-10%
	  cout<<"I am here setting grid data dir"<<endl;
// 	  outputDir = outputDir + "LHC13e1a";
	  plugin->SetGridDataDir("/alice/sim/2013/LHC13e1b");
	}
      }
      plugin->AddRunNumber(168464);
    }
    if(dataset==2009){//pp 900 GeV
      if(data){//only 233 jobs!
	cout<<"Running over data"<<endl;
	plugin->SetGridDataDir("/alice/data/2010/LHC10c");//PbPb data
	//plugin->SetDataPattern("*ESDs/pass3/*ESDs.root");
	plugin->SetDataPattern("*ESDs/pass3/*ESDs.root");
	plugin->SetRunPrefix("000");   // real data
      }
      else{//sim over 1500 jobs, some get killed because it's above quota
	cout<<"Running over MC"<<endl;
	if(simflag==0){
	  if(material==0){
	    plugin->SetGridDataDir("/alice/sim/LHC11b1a");//PbPb simulation
	  }
	  if(material==1){//10% more material budget
	    plugin->SetGridDataDir("/alice/sim/LHC11b1b");//PbPb simulation
	  }
	  if(material==-1){//10% less material budget
	    plugin->SetGridDataDir("/alice/sim/LHC11b1c");//PbPb simulation
	  }
	}
	if(simflag==1)	plugin->SetGridDataDir("/alice/sim/2011/LHC11h1a");//PYTHIA
	if(simflag==2)	plugin->SetGridDataDir("/alice/sim/2011/LHC11h1b");//PHOJET
	if(simflag==3)	plugin->SetGridDataDir("/alice/sim/2011/LHC11h1c");//PYTHIA Flat
	plugin->SetDataPattern("*ESDs.root");
      }
      plugin->AddRunNumber(118506);
//       plugin->AddRunNumber(121040);
//       plugin->AddRunNumber(121039);
//       plugin->AddRunNumber(118561);
//       plugin->AddRunNumber(118560);
//       plugin->AddRunNumber(118558);
//       plugin->AddRunNumber(118557);
//       plugin->AddRunNumber(118556);
//       plugin->AddRunNumber(118518);
//       plugin->AddRunNumber(118512);
//       plugin->AddRunNumber(118507);
//       plugin->AddRunNumber(118506);
//if(data){
// 	plugin->AddRunNumber(118504);
// 	plugin->AddRunNumber(118503);
//    }
    }
  
    if(dataset==20111){//pp 2.76 TeV 
      if(data){//257 jobs
	cout<<"Running over data"<<endl;
	plugin->SetGridDataDir("/alice/data/2011/LHC11a");//
	plugin->SetDataPattern("*ESDs/pass4_with_SDD/*ESDs.root");
	plugin->SetRunPrefix("000");   // real data
      }
      else{//sim - 332 jobs
	cout<<"Running over MC"<<endl;
	if(simflag==0)	plugin->SetGridDataDir("/alice/sim/LHC11b10a");//
	if(simflag==1)	plugin->SetGridDataDir("/alice/sim/2011/LHC11h5a");//PYTHIA
	if(simflag==2)	plugin->SetGridDataDir("/alice/sim/2011/LHC11h5b");//PHOJET
	if(simflag==3)	plugin->SetGridDataDir("/alice/sim/2011/LHC11h5c");//PYTHIA Flat
	plugin->SetDataPattern("*ESDs.root");
      }
//       plugin->AddRunNumber(146860);
//       plugin->AddRunNumber(146859);
//       plugin->AddRunNumber(146856);
//       plugin->AddRunNumber(146824);
//       plugin->AddRunNumber(146817);
//       plugin->AddRunNumber(146806);
//       plugin->AddRunNumber(146805);
//       plugin->AddRunNumber(146804);
//       plugin->AddRunNumber(146803);
//       plugin->AddRunNumber(146802);
//       plugin->AddRunNumber(146801);
//       plugin->AddRunNumber(146748);
//       plugin->AddRunNumber(146747);
//       plugin->AddRunNumber(146746);

  //     plugin->AddRunNumber(146860);
//       plugin->AddRunNumber(146859);
//       plugin->AddRunNumber(146858);
//       plugin->AddRunNumber(146857);
//       plugin->AddRunNumber(146856);
      //        plugin->AddRunNumber(146824);
      //        if(data){//these productions are not yet done for MC
      // 	 plugin->AddRunNumber(146817);
      // 	 plugin->AddRunNumber(146807);
      // 	 plugin->AddRunNumber(146806);
      // 	 plugin->AddRunNumber(146805);
      // 	 plugin->AddRunNumber(146804);
      // 	 plugin->AddRunNumber(146803);
      // 	 plugin->AddRunNumber(146802);
      //        }
      plugin->AddRunNumber(146805);

    }
    if(dataset==2010){//pp 7 TeV
      if(data){//data - 569 jobs
	cout<<"Running over 7 TeV data"<<endl;
	plugin->SetGridDataDir("/alice/data/2010/LHC10e");//PbPb data
	plugin->SetDataPattern("*ESDs/pass2/*ESDs.root");
	cout<<"Setting run prefix to be 000"<<endl;
	plugin->SetRunPrefix("000");   // real data
      }
      else{//sim- 346 jobs
	if(simflag==0)	plugin->SetGridDataDir("/alice/sim/LHC10e20");//
	if(simflag==1)	plugin->SetGridDataDir("/alice/sim/2011/LHC11h4a");//PYTHIA
	if(simflag==2)	plugin->SetGridDataDir("/alice/sim/2011/LHC11h4b");//PHOJET
	if(simflag==3)	plugin->SetGridDataDir("/alice/sim/2011/LHC11h4c");//PYTHIA Flat
	plugin->SetDataPattern("*ESDs.root");
      }
      plugin->AddRunNumber("130795");
// 	plugin->AddRunNumber("130840");
// 	plugin->AddRunNumber("130834");
// 	plugin->AddRunNumber("130833");
// 	plugin->AddRunNumber("130831");
// 	plugin->AddRunNumber("130804");
// 	plugin->AddRunNumber("130803");
// 	plugin->AddRunNumber("130802");
// 	plugin->AddRunNumber("130799");
// 	plugin->AddRunNumber("130798");
// 	plugin->AddRunNumber("130795");
    }

    if(dataset==2012){//pp 8 TeV
      if(data){//data - 569 jobs
	cout<<"Running over 8 TeV data"<<endl;
	plugin->SetGridDataDir("/alice/data/2012/LHC12b");//PbPb data
	plugin->SetDataPattern("*ESDs/pass1/*ESDs.root");
	cout<<"Setting run prefix to be 000"<<endl;
	plugin->SetRunPrefix("000");   // real data
      }
      else{//sim- 346 jobs
	plugin->SetGridDataDir("/alice/sim/2012/LHC12c1b");//
      }
      //plugin->AddRunNumber("177799");
      plugin->AddRunNumber("178030");
    }
    if(dataset==2013){//pPb 
      if(data){//data - 569 jobs
	cout<<"Running over pPb data"<<endl;
	plugin->SetGridDataDir("/alice/data/2013/LHC13b");//PbPb data
	plugin->SetDataPattern("*ESDs/pass3/*ESDs.root");
	cout<<"Setting run prefix to be 000"<<endl;
	plugin->SetRunPrefix("000");   // real data
      }
      else{//sim- 346 jobs
	plugin->SetGridDataDir("/alice/sim/2013/LHC13b3");//
      }
      plugin->AddRunNumber("195483");
    }
  }


  if(dataset==20100){//PbPb 2.76 TeV
    if(data){
      //plugin->SetGridWorkingDir("etPbPbData");
      plugin->SetGridWorkingDir(outputdir.Data());
    }
    else{
      if(material==0){plugin->SetGridWorkingDir(outputdir.Data());}
      if(material==-1) plugin->SetGridWorkingDir("etPbPbSimMatBudLow");
      if(material==1) plugin->SetGridWorkingDir("etPbPbSimMatBudHigh");
      if(material==10)  plugin->SetGridWorkingDir("etPbPbSimDPMJET");
       if(material==11)  plugin->SetGridWorkingDir("etPbPbSimAMPT");
    }
  }
  else{
    if(dataset==2011){//PbPb 2.76 TeV
      if(data){
	plugin->SetGridWorkingDir("etPbPbData2011");
      }
      else{
	if(simflag==0){plugin->SetGridWorkingDir("etPbPbSim2011LHC13e1a");}
	if(simflag==1){plugin->SetGridWorkingDir("etPbPbSim2011LHC13e1b");}
	if(simflag==2){plugin->SetGridWorkingDir("etPbPbSim2011LHC13e1c");}
      }
    }
    if(dataset==2009){//pp 900 GeV
      if(data){
	plugin->SetGridWorkingDir("etpp900GeVData");
      }
      else{
	if(simflag==0){
	  if(material==0) plugin->SetGridWorkingDir("etpp900GeVSim");
	  if(material==-1) plugin->SetGridWorkingDir("etpp900GeVSimMatBudLow");
	  if(material==1) plugin->SetGridWorkingDir("etpp900GeVSimMatBudHigh");
	}
	if(simflag==1)	plugin->SetGridWorkingDir("etpp900GeVSimPYTHIA");//PYTHIA
	if(simflag==2)	plugin->SetGridWorkingDir("etpp900GeVSimPHOJET");//PHOJET
	if(simflag==3)	plugin->SetGridWorkingDir("etpp900GeVSimPYTHIAFLAT");//PYTHIA Flat
      }
    }
    if(dataset==20111){//pp 2.76 TeV
      if(data){
	//plugin->SetGridWorkingDir("etpp276TeVData");
      }
      else{
	if(altV0Scale) plugin->SetGridWorkingDir("etpp276TeVSimAlt");
	else{
	  // plugin->SetGridWorkingDir("etpp276TeVSim");
	  
	  if(simflag==0)	plugin->SetGridWorkingDir("etpp276TeVSim");//
	  if(simflag==1)	plugin->SetGridWorkingDir("etpp276TeVSimPYTHIA");//PYTHIA
	  if(simflag==2)	plugin->SetGridWorkingDir("etpp276TeVSimPHOJET");//PHOJET
	  if(simflag==3)	plugin->SetGridWorkingDir("etpp276TeVSimPYTHIAFLAT");//PYTHIA Flat
	}
      }
    }
    if(dataset==2010){//pp 7 TeV
      if(data){
	plugin->SetGridWorkingDir("etpp7TeVData");
      }
      else{
	if(simflag==0)	plugin->SetGridWorkingDir("etpp7TeVSim");//
	if(simflag==1)	plugin->SetGridWorkingDir("etpp7TeVSimPYTHIA");//PYTHIA
	if(simflag==2)	plugin->SetGridWorkingDir("etpp7TeVSimPHOJET");//PHOJET
	if(simflag==3)	plugin->SetGridWorkingDir("etpp7TeVSimPYTHIAFLAT");//PYTHIA Flat
      }
    }
    if(dataset==2012){//pp 8 TeV
      if(data){
	plugin->SetGridWorkingDir("etpp8TeVData");
      }
      else{
	plugin->SetGridWorkingDir("etpp8TeVSim");
      }
    }
    if(dataset==2013){//pPb
      if(data){
	plugin->SetGridWorkingDir("etpPb5TeVData");
      }
      else{
	plugin->SetGridWorkingDir("etpPb5TeVSim");
      }
    }
  }

    cout<<"writing to "<<outputdir.Data()<<endl;

  // Define alien work directory where all files will be copied. Relative to alien $HOME.
  //plugin->SetGridWorkingDir("et");
  // Declare alien output directory. Relative to working directory.
  plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output
  // Declare the analysis source files names separated by blancs. To be compiled runtime IN THE SAME ORDER THEY ARE LISTED
  // using ACLiC on the worker nodes.
  //plugin->SetAnalysisSource("AliAnalysisTaskHadEt.cxx");
  //plugin->SetAnalysisSource("AliAnalysisEt.cxx AliAnalysisEtMonteCarlo.cxx AliAnalysisEtMonteCarloPhos.cxx AliAnalysisEtReconstructed.cxx AliAnalysisEtReconstructedPhos.cxx AliAnalysisHadEt.cxx AliAnalysisHadEtMonteCarlo.cxx AliAnalysisHadEtReconstructed.cxx AliAnalysisTaskHadEt.cxx AliAnalysisTaskTotEt.cxx");
  //TString sourcefiles = "AliAnalysisEtCuts.cxx AliAnalysisHadEtCorrections.cxx AliAnalysisEtCommon.cxx AliAnalysisHadEt.cxx AliAnalysisHadEtMonteCarlo.cxx AliAnalysisHadEtReconstructed.cxx AliAnalysisEtSelectionContainer.cxx AliAnalysisEtSelectionHandler.cxx AliAnalysisTaskTransverseEnergy.cxx AliAnalysisTaskHadEt.cxx";
  //plugin->SetAnalysisSource(sourcefiles.Data());
  if(!runCompiledVersion){
    plugin->SetAnalysisSource("AliAnalysisEtCuts.cxx AliAnalysisHadEtCorrections.cxx AliAnalysisEtCommon.cxx AliAnalysisHadEt.cxx AliAnalysisHadEtMonteCarlo.cxx AliAnalysisHadEtReconstructed.cxx AliAnalysisTaskTransverseEnergy.cxx AliAnalysisTaskHadEt.cxx");
  }
   
  //cout<<"Setting source files "<<sourcefiles<<endl;
  // Declare all libraries (other than the default ones for the framework. These will be
  // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
  //TString additionallibs = "AliAnalysisEtCuts.h AliAnalysisEtCuts.cxx AliAnalysisHadEtCorrections.h AliAnalysisHadEtCorrections.cxx  AliAnalysisEtSelectionContainer.cxx AliAnalysisEtSelectionHandler.cxx AliAnalysisTaskTransverseEnergy.cxx AliAnalysisEtCommon.h AliAnalysisEtCommon.cxx AliAnalysisHadEt.cxx AliAnalysisHadEtMonteCarlo.cxx AliAnalysisHadEtReconstructed.cxx AliAnalysisTaskHadEt.cxx AliAnalysisHadEt.h AliAnalysisHadEtMonteCarlo.h AliAnalysisHadEtReconstructed.h AliAnalysisTaskHadEt.h  AliAnalysisEtSelectionContainer.h AliAnalysisEtSelectionHandler.h AliAnalysisTaskTransverseEnergy.h corrections.root ConfigHadEtAnalysis.C ConfigHadEtMonteCarlo.C ConfigHadEtReconstructed.C physicsSelections.root";
  //TString additionallibs = "AliAnalysisEtCuts.h AliAnalysisEtCuts.cxx AliAnalysisHadEtCorrections.h AliAnalysisHadEtCorrections.cxx  AliAnalysisEtSelectionContainer.cxx AliAnalysisEtSelectionHandler.cxx AliAnalysisTaskTransverseEnergy.cxx AliAnalysisEtCommon.h AliAnalysisEtCommon.cxx AliAnalysisHadEt.cxx AliAnalysisHadEtMonteCarlo.cxx AliAnalysisHadEtReconstructed.cxx AliAnalysisTaskHadEt.cxx AliAnalysisHadEt.h AliAnalysisHadEtMonteCarlo.h AliAnalysisHadEtReconstructed.h AliAnalysisTaskHadEt.h  AliAnalysisEtSelectionContainer.h AliAnalysisEtSelectionHandler.h AliAnalysisTaskTransverseEnergy.h physicsSelections.root ConfigHadEtMonteCarlo.C  ConfigHadEtReconstructed.C corrections.root";
  //plugin->SetAdditionalLibs(additionallibs.Data());
  if(!runCompiledVersion){//
    plugin->SetAdditionalLibs( "libPWGUDbase.so AliAnalysisEtCuts.h AliAnalysisEtCuts.cxx AliAnalysisHadEtCorrections.h AliAnalysisHadEtCorrections.cxx AliAnalysisTaskTransverseEnergy.cxx AliAnalysisEtCommon.h AliAnalysisEtCommon.cxx AliAnalysisHadEt.cxx AliAnalysisHadEtMonteCarlo.cxx AliAnalysisHadEtReconstructed.cxx AliAnalysisTaskHadEt.cxx AliAnalysisHadEt.h AliAnalysisHadEtMonteCarlo.h AliAnalysisHadEtReconstructed.h AliAnalysisTaskHadEt.h AliAnalysisTaskTransverseEnergy.h ConfigHadEtMonteCarlo.C  ConfigHadEtReconstructed.C corrections.root");
  }
  else{
    plugin->SetAdditionalLibs( "ConfigHadEtMonteCarlo.C  ConfigHadEtReconstructed.C corrections.root libPWGUDbase.so libPWGLFtotEt.so");
  }
  // No need for output file names. Procedure is automatic. <-- not true
  //plugin->SetDefaultOutputs(kFALSE);
  //plugin->SetOutputFiles("Et.ESD.new.sim.root");
  // No need define the files to be archived. Note that this is handled automatically by the plugin.
  //   plugin->SetOutputArchive("log_archive.zip:stdout,stderr");
  // Set a name for the generated analysis macro (default MyAnalysis.C) Make this unique !
  plugin->SetAnalysisMacro("ChristinesEtAnalysis.C");
  // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore). The optimum for an analysis
  // is correlated with the run time - count few hours TTL per job, not minutes !
  plugin->SetSplitMaxInputFileNumber(50);
  if(dataset==2013){//pPb 
    plugin->SetSplitMaxInputFileNumber(20);
    }
  // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
  //plugin->SetMaxInitFailed(5);
  // Optionally resubmit threshold.
  //plugin->SetMasterResubmitThreshold(90);
  // Optionally set time to live (default 30000 sec)
  plugin->SetTTL(20000);
  // Optionally set input format (default xml-single)
  plugin->SetInputFormat("xml-single");
  // Optionally modify the name of the generated JDL (default analysis.jdl)
  plugin->SetJDLName("TaskEt.jdl");
  // Optionally modify job price (default 1)
  plugin->SetPrice(1); 
  // Optionally modify split mode (default 'se')    
  plugin->SetSplitMode("se");
  plugin->SetTerminateFiles("event_stat.root") ;
  plugin->SetKeepLogs();
  plugin->SetMergeViaJDL();
  return plugin;
}