ROOT logo
// run.C
//
// Template run macro for AliAnalysisTaskLukeAOD.cxx/.h with example layout of
// physics selections and options, in macro and task.
//
// Author: Arvinder Palaha
// Edited by Luke Hanratty for AODSLukeAOD
//
class AliAnalysisGrid;

//______________________________________________________________________________
void runLukeAOD(
				const char* runtype = "proof", // local, proof or grid
				const char *gridmode = "full", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof
				const bool bMCtruth = 0, // 1 = MCEvent handler is on (MC truth), 0 = MCEvent handler is off (MC reconstructed/real data)
				const bool bMCphyssel = 0, // 1 = looking at MC truth or reconstructed, 0 = looking at real data
				const Long64_t nentries = 10000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events.
				const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode
				const char *proofdataset/*CAF*/ = "/alice/data/LHC10h_000139037_p2_AOD073", //"/alice/sim/LHC11a10a_000138795_AOD048", //"/alice/data/LHC10h_000139507_p2_AOD049", //"/alice/data/LHC10e_000130375_p2", //"/alice/data/LHC10c_000120821_p1", // path to dataset on proof cluster, for proof analysis
				//const char *proofdataset/*SKAF*/ = "/alice/data/LHC10h_000139510_AOD086_p2", //"/alice/sim/LHC11a10a_000138795_AOD048", //"/alice/data/LHC10h_000139507_p2_AOD049", //"/alice/data/LHC10e_000130375_p2", //"/alice/data/LHC10c_000120821_p1", // path to dataset on proof cluster, for proof analysis
				const char *proofcluster/*CAF*/ = "hanratty@alice-caf.cern.ch", //"alice-caf.cern.ch", //"hanratty@skaf.saske.sk", //"alice-caf.cern.ch", // which proof cluster to use in proof mode
				//const char *proofcluster/*SKAF*/ = "hanratty@skaf.saske.sk", //"alice-caf.cern.ch", //"hanratty@skaf.saske.sk", //"alice-caf.cern.ch", // which proof cluster to use in proof mode
				const char *taskname = "example_task" // sets name of grid generated macros
				)
{
    // check run type
    if(runtype != "local" && runtype != "proof" && runtype != "grid"){
        Printf("\n\tIncorrect run option, check first argument of run macro");
        Printf("\tint runtype = local, proof or grid\n");
        return;
    }
    Printf("%s analysis chosen",runtype);
	
    // load libraries
    gSystem->Load("libCore.so");        
    gSystem->Load("libGeom.so");
    gSystem->Load("libVMC.so");
    gSystem->Load("libPhysics.so");
    gSystem->Load("libTree.so");
    gSystem->Load("libSTEERBase.so");
    gSystem->Load("libESD.so");
    gSystem->Load("libAOD.so");
    gSystem->Load("libANALYSIS.so");
    gSystem->Load("libANALYSISalice.so");
	
    // add aliroot indlude path
    gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT")));
    gROOT->SetStyle("Plain");
	
    // analysis manager
    AliAnalysisManager* mgr = new AliAnalysisManager(taskname);
    
    // create the alien handler and attach it to the manager
    AliAnalysisGrid *plugin = CreateAlienHandler(taskname, gridmode, proofcluster, proofdataset); 
    mgr->SetGridHandler(plugin);
    
    AliVEventHandler* aodH = new AliAODInputHandler();
    mgr->SetInputEventHandler(aodH);
    
	gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
    AliAnalysisTask *PIDTask = AddTaskPIDResponse(bMCtruth,kTRUE);
    if(!PIDTask) { Printf("no PIDtask"); return; }
	
	
	bool isMonteCarlo = bMCtruth;
	
	double cutCosPa(0.998);
	double cutcTauMin(-999);
	double cutNcTauMax(3.0);
	double cutBetheBloch(3.0);
	double cutMinNClustersTPC(70);
	double cutRatio(0.8);
	double cutEta(0.8);
	double cutRapidity(0.5);
	double cutArmenteros(0.2);
	
	
    // create task
    gROOT->LoadMacro("AliAnalysisTaskLukeAOD.cxx++g");
	gROOT->ProcessLine(".L AddTaskLukeAOD.C");
	AddTaskLukeAOD("lambdak0TEST",isMonteCarlo,  cutCosPa,  cutcTauMin,  cutNcTauMax,  cutBetheBloch, 	cutMinNClustersTPC,  cutRatio, 	cutEta,  cutRapidity,  cutArmenteros); 	
	
    // enable debug printouts
    mgr->SetDebugLevel(2);
    if (!mgr->InitAnalysis()) return;
    mgr->PrintStatus();
	
    // start analysis
    Printf("Starting Analysis....");
    mgr->StartAnalysis(runtype,nentries,firstentry);
}

//______________________________________________________________________________
AliAnalysisGrid* CreateAlienHandler(const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset)
{
    AliAnalysisAlien *plugin = new AliAnalysisAlien();
    // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
    plugin->SetRunMode(gridmode);
	
    // Set versions of used packages
    plugin->SetAPIVersion("V1.1X");
    plugin->SetROOTVersion("v5-33-02b");
    plugin->SetAliROOTVersion("v5-03-29-AN");
	
    // Declare input data to be processed.
	
    // Method 1: Create automatically XML collections using alien 'find' command.
    // Define production directory LFN
    plugin->SetGridDataDir("/alice/data/2010/LHC10b");
    // On real reconstructed data:
    // plugin->SetGridDataDir("/alice/data/2009/LHC09d");
    // Set data search pattern
    //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES
    // Data pattern for reconstructed data
    plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
    plugin->SetRunPrefix("000");   // real data
    // ...then add run numbers to be considered
    plugin->AddRunNumber(115514);
    //plugin->SetRunRange(114917,115322);
    plugin->SetNrunsPerMaster(1);
    plugin->SetOutputToRunNo();
    // comment out the next line when using the "terminate" option, unless
    // you want separate merged files for each run
    plugin->SetMergeViaJDL();
	
    // 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");
	
    // Define alien work directory where all files will be copied. Relative to alien $HOME.
    plugin->SetGridWorkingDir(taskname);
	
    // Declare alien output directory. Relative to working directory.
    plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out
	
    // Declare the analysis source files names separated by blancs. To be compiled runtime
    // using ACLiC on the worker nodes.
    plugin->SetAnalysisSource("AliAnalysisTaskLukeAOD.cxx");
	
    // 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.
    plugin->SetAdditionalLibs("AliAnalysisTaskLukeAOD.h AliAnalysisTaskLukeAOD.cxx");
	
    // Declare the output file names separated by blancs.
    // (can be like: file.root or file.root@ALICE::Niham::File)
    // To only save certain files, use SetDefaultOutputs(kFALSE), and then
    // SetOutputFiles("list.root other.filename") to choose which files to save
    plugin->SetDefaultOutputs();
    //plugin->SetOutputFiles("list.root");
	
    // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
    plugin->SetAnalysisMacro(Form("%s.C",taskname));
	
    // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
    plugin->SetSplitMaxInputFileNumber(100);
	
    // Optionally modify the executable name (default analysis.sh)
    plugin->SetExecutable(Form("%s.sh",taskname));
	
    // set number of test files to use in "test" mode
    plugin->SetNtestFiles(10);
	
    // Optionally resubmit threshold.
    plugin->SetMasterResubmitThreshold(90);
	
    // Optionally set time to live (default 30000 sec)
    plugin->SetTTL(30000);
	
    // Optionally set input format (default xml-single)
    plugin->SetInputFormat("xml-single");
	
    // Optionally modify the name of the generated JDL (default analysis.jdl)
    plugin->SetJDLName(Form("%s.jdl",taskname));
	
    // Optionally modify job price (default 1)
    plugin->SetPrice(1);      
	
    // Optionally modify split mode (default 'se')    
    plugin->SetSplitMode("se");
    
    //----------------------------------------------------------
    //---      PROOF MODE SPECIFIC SETTINGS         ------------
    //---------------------------------------------------------- 
    // Proof cluster
    plugin->SetProofCluster(proofcluster);
    // Dataset to be used   
    plugin->SetProofDataSet(proofdataset);
    // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard
    plugin->SetProofReset(0);
    // May limit number of workers
    plugin->SetNproofWorkers(10);
    // May limit the number of workers per slave
    plugin->SetNproofWorkersPerSlave(1);   
    // May use a specific version of root installed in proof
    plugin->SetRootVersionForProof("VO_ALICE@ROOT::v5-33-02b");
    // May set the aliroot mode. Check http://aaf.cern.ch/node/83 
    plugin->SetAliRootMode("default"); // Loads AF libs by default
    // May request ClearPackages (individual ClearPackage not supported)
    plugin->SetClearPackages(kFALSE);
    // Plugin test mode works only providing a file containing test file locations, used in "local" mode also
    plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc
    // Request connection to alien upon connection to grid
    plugin->SetProofConnectGrid(kFALSE);
	
    return plugin;
}

 runLukeAOD.C:1
 runLukeAOD.C:2
 runLukeAOD.C:3
 runLukeAOD.C:4
 runLukeAOD.C:5
 runLukeAOD.C:6
 runLukeAOD.C:7
 runLukeAOD.C:8
 runLukeAOD.C:9
 runLukeAOD.C:10
 runLukeAOD.C:11
 runLukeAOD.C:12
 runLukeAOD.C:13
 runLukeAOD.C:14
 runLukeAOD.C:15
 runLukeAOD.C:16
 runLukeAOD.C:17
 runLukeAOD.C:18
 runLukeAOD.C:19
 runLukeAOD.C:20
 runLukeAOD.C:21
 runLukeAOD.C:22
 runLukeAOD.C:23
 runLukeAOD.C:24
 runLukeAOD.C:25
 runLukeAOD.C:26
 runLukeAOD.C:27
 runLukeAOD.C:28
 runLukeAOD.C:29
 runLukeAOD.C:30
 runLukeAOD.C:31
 runLukeAOD.C:32
 runLukeAOD.C:33
 runLukeAOD.C:34
 runLukeAOD.C:35
 runLukeAOD.C:36
 runLukeAOD.C:37
 runLukeAOD.C:38
 runLukeAOD.C:39
 runLukeAOD.C:40
 runLukeAOD.C:41
 runLukeAOD.C:42
 runLukeAOD.C:43
 runLukeAOD.C:44
 runLukeAOD.C:45
 runLukeAOD.C:46
 runLukeAOD.C:47
 runLukeAOD.C:48
 runLukeAOD.C:49
 runLukeAOD.C:50
 runLukeAOD.C:51
 runLukeAOD.C:52
 runLukeAOD.C:53
 runLukeAOD.C:54
 runLukeAOD.C:55
 runLukeAOD.C:56
 runLukeAOD.C:57
 runLukeAOD.C:58
 runLukeAOD.C:59
 runLukeAOD.C:60
 runLukeAOD.C:61
 runLukeAOD.C:62
 runLukeAOD.C:63
 runLukeAOD.C:64
 runLukeAOD.C:65
 runLukeAOD.C:66
 runLukeAOD.C:67
 runLukeAOD.C:68
 runLukeAOD.C:69
 runLukeAOD.C:70
 runLukeAOD.C:71
 runLukeAOD.C:72
 runLukeAOD.C:73
 runLukeAOD.C:74
 runLukeAOD.C:75
 runLukeAOD.C:76
 runLukeAOD.C:77
 runLukeAOD.C:78
 runLukeAOD.C:79
 runLukeAOD.C:80
 runLukeAOD.C:81
 runLukeAOD.C:82
 runLukeAOD.C:83
 runLukeAOD.C:84
 runLukeAOD.C:85
 runLukeAOD.C:86
 runLukeAOD.C:87
 runLukeAOD.C:88
 runLukeAOD.C:89
 runLukeAOD.C:90
 runLukeAOD.C:91
 runLukeAOD.C:92
 runLukeAOD.C:93
 runLukeAOD.C:94
 runLukeAOD.C:95
 runLukeAOD.C:96
 runLukeAOD.C:97
 runLukeAOD.C:98
 runLukeAOD.C:99
 runLukeAOD.C:100
 runLukeAOD.C:101
 runLukeAOD.C:102
 runLukeAOD.C:103
 runLukeAOD.C:104
 runLukeAOD.C:105
 runLukeAOD.C:106
 runLukeAOD.C:107
 runLukeAOD.C:108
 runLukeAOD.C:109
 runLukeAOD.C:110
 runLukeAOD.C:111
 runLukeAOD.C:112
 runLukeAOD.C:113
 runLukeAOD.C:114
 runLukeAOD.C:115
 runLukeAOD.C:116
 runLukeAOD.C:117
 runLukeAOD.C:118
 runLukeAOD.C:119
 runLukeAOD.C:120
 runLukeAOD.C:121
 runLukeAOD.C:122
 runLukeAOD.C:123
 runLukeAOD.C:124
 runLukeAOD.C:125
 runLukeAOD.C:126
 runLukeAOD.C:127
 runLukeAOD.C:128
 runLukeAOD.C:129
 runLukeAOD.C:130
 runLukeAOD.C:131
 runLukeAOD.C:132
 runLukeAOD.C:133
 runLukeAOD.C:134
 runLukeAOD.C:135
 runLukeAOD.C:136
 runLukeAOD.C:137
 runLukeAOD.C:138
 runLukeAOD.C:139
 runLukeAOD.C:140
 runLukeAOD.C:141
 runLukeAOD.C:142
 runLukeAOD.C:143
 runLukeAOD.C:144
 runLukeAOD.C:145
 runLukeAOD.C:146
 runLukeAOD.C:147
 runLukeAOD.C:148
 runLukeAOD.C:149
 runLukeAOD.C:150
 runLukeAOD.C:151
 runLukeAOD.C:152
 runLukeAOD.C:153
 runLukeAOD.C:154
 runLukeAOD.C:155
 runLukeAOD.C:156
 runLukeAOD.C:157
 runLukeAOD.C:158
 runLukeAOD.C:159
 runLukeAOD.C:160
 runLukeAOD.C:161
 runLukeAOD.C:162
 runLukeAOD.C:163
 runLukeAOD.C:164
 runLukeAOD.C:165
 runLukeAOD.C:166
 runLukeAOD.C:167
 runLukeAOD.C:168
 runLukeAOD.C:169
 runLukeAOD.C:170
 runLukeAOD.C:171
 runLukeAOD.C:172
 runLukeAOD.C:173
 runLukeAOD.C:174
 runLukeAOD.C:175
 runLukeAOD.C:176
 runLukeAOD.C:177
 runLukeAOD.C:178
 runLukeAOD.C:179
 runLukeAOD.C:180
 runLukeAOD.C:181
 runLukeAOD.C:182
 runLukeAOD.C:183
 runLukeAOD.C:184
 runLukeAOD.C:185
 runLukeAOD.C:186
 runLukeAOD.C:187
 runLukeAOD.C:188
 runLukeAOD.C:189
 runLukeAOD.C:190
 runLukeAOD.C:191
 runLukeAOD.C:192
 runLukeAOD.C:193
 runLukeAOD.C:194
 runLukeAOD.C:195
 runLukeAOD.C:196
 runLukeAOD.C:197
 runLukeAOD.C:198
 runLukeAOD.C:199
 runLukeAOD.C:200
 runLukeAOD.C:201
 runLukeAOD.C:202
 runLukeAOD.C:203
 runLukeAOD.C:204
 runLukeAOD.C:205
 runLukeAOD.C:206
 runLukeAOD.C:207
 runLukeAOD.C:208
 runLukeAOD.C:209
 runLukeAOD.C:210
 runLukeAOD.C:211