3 // Template run macro for AliBasicTask.cxx/.h with example layout of
4 // physics selections and options, in macro and task.
6 // Author: Arvinder Palaha
10 //______________________________________________________________________________
12 const char* runtype = "proof", // local, proof or grid
13 const char *gridmode = "full", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof
14 const bool bMCtruth = 0, // 1 = MCEvent handler is on (MC truth), 0 = MCEvent handler is off (MC reconstructed/real data)
15 const bool bMCphyssel = 0, // 1 = looking at MC truth or reconstructed, 0 = looking at real data
16 const Long64_t nentries = 2000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events.
17 const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode
18 const char *proofdataset = "/alice/data/LHC10c_000120821_p1", // path to dataset on proof cluster, for proof analysis
19 const char *proofcluster = "alice-caf.cern.ch", // which proof cluster to use in proof mode
20 const char *taskname = "example_task" // sets name of grid generated macros
24 if(runtype != "local" && runtype != "proof" && runtype != "grid"){
25 Printf("\n\tIncorrect run option, check first argument of run macro");
26 Printf("\tint runtype = local, proof or grid\n");
29 Printf("%s analysis chosen",runtype);
32 gSystem->Load("libCore.so");
33 gSystem->Load("libGeom.so");
34 gSystem->Load("libVMC.so");
35 gSystem->Load("libPhysics.so");
36 gSystem->Load("libTree.so");
37 gSystem->Load("libSTEERBase.so");
38 gSystem->Load("libESD.so");
39 gSystem->Load("libAOD.so");
40 gSystem->Load("libANALYSIS.so");
41 gSystem->Load("libANALYSISalice.so");
43 // add aliroot indlude path
44 gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT")));
45 gROOT->SetStyle("Plain");
48 AliAnalysisManager* mgr = new AliAnalysisManager(taskname);
50 // create the alien handler and attach it to the manager
51 AliAnalysisGrid *plugin = CreateAlienHandler(taskname, gridmode, proofcluster, proofdataset);
52 mgr->SetGridHandler(plugin);
54 AliVEventHandler* esdH = new AliESDInputHandler();
55 mgr->SetInputEventHandler(esdH);
59 AliMCEventHandler* mchandler = new AliMCEventHandler();
60 // Not reading track references
61 mchandler->SetReadTR(kFALSE);
62 mgr->SetMCtruthEventHandler(mchandler);
65 // === Physics Selection Task ===
67 // In SelectCollisionCandidate(), default is kMB, so the task UserExec()
68 // function is only called for these events.
70 // kMB Minimum Bias trigger
71 // kMBNoTRD Minimum bias trigger where the TRD is not read out
73 // kHighMult High-Multiplicity Trigger
74 // kUserDefined For manually defined trigger selection
76 // Multiple options possible with the standard AND/OR operators && and ||
77 // These all have the usual offline SPD or V0 selections performed.
79 // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(),
80 // one can manually set the selected and background classes using:
81 // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL")
82 // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL");
84 // One can also specify multiple classes at once, or require a class to NOT
86 // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL");
88 // NOTE that manually setting the physics selection overrides the standard
89 // selection, so it must be done in completeness.
91 // ALTERNATIVELY, one can make the physics selection inside the task
93 // For this case, comment out the task->SelectCol.... line,
94 // and see AliBasicTask.cxx UserExec() function for details on this.
96 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
97 AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel);
98 if(!physSelTask) { Printf("no physSelTask"); return; }
99 //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection();
100 //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769");
103 gROOT->LoadMacro("AliAnalysisTaskEx01.cxx++g");
104 AliAnalysisTaskSE* task = new AliAnalysisTaskEx01(taskname);
105 task->SelectCollisionCandidates(AliVEvent::kMB); // if physics selection performed in UserExec(), this line should be commented
108 // set output root file name for different analysis
109 TString outfilename = Form("list.%s.root",runtype);
111 // create containers for input/output
112 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
113 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("coutput1", TList::Class(), AliAnalysisManager::kOutputContainer, outfilename);
115 // connect input/output
116 mgr->ConnectInput(task, 0, cinput);
117 mgr->ConnectOutput(task, 1, coutput1);
119 // enable debug printouts
120 mgr->SetDebugLevel(2);
121 if (!mgr->InitAnalysis()) return;
125 Printf("Starting Analysis....");
126 mgr->StartAnalysis(runtype,nentries,firstentry);
129 //______________________________________________________________________________
130 AliAnalysisGrid* CreateAlienHandler(const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset)
132 AliAnalysisAlien *plugin = new AliAnalysisAlien();
133 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
134 plugin->SetRunMode(gridmode);
136 // Set versions of used packages
137 plugin->SetAPIVersion("V1.1x");
138 plugin->SetROOTVersion("v5-27-06b");
139 plugin->SetAliROOTVersion("v4-21-08-AN");
141 // Declare input data to be processed.
143 // Method 1: Create automatically XML collections using alien 'find' command.
144 // Define production directory LFN
145 plugin->SetGridDataDir("/alice/data/2010/LHC10b");
146 // On real reconstructed data:
147 // plugin->SetGridDataDir("/alice/data/2009/LHC09d");
148 // Set data search pattern
149 //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES
150 // Data pattern for reconstructed data
151 plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
152 plugin->SetRunPrefix("000"); // real data
153 // ...then add run numbers to be considered
154 plugin->AddRunNumber(115514);
155 //plugin->SetRunRange(114917,115322);
156 plugin->SetNrunsPerMaster(1);
157 plugin->SetOutputToRunNo();
158 // comment out the next line when using the "terminate" option, unless
159 // you want separate merged files for each run
160 plugin->SetMergeViaJDL();
162 // Method 2: Declare existing data files (raw collections, xml collections, root file)
163 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
164 // XML collections added via this method can be combined with the first method if
165 // the content is compatible (using or not tags)
166 // plugin->AddDataFile("tag.xml");
167 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
169 // Define alien work directory where all files will be copied. Relative to alien $HOME.
170 plugin->SetGridWorkingDir(taskname);
172 // Declare alien output directory. Relative to working directory.
173 plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out
175 // Declare the analysis source files names separated by blancs. To be compiled runtime
176 // using ACLiC on the worker nodes.
177 plugin->SetAnalysisSource("AliAnalysisTaskEx01.cxx");
179 // Declare all libraries (other than the default ones for the framework. These will be
180 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
181 plugin->SetAdditionalLibs("AliAnalysisTaskEx01.h AliAnalysisTaskEx01.cxx");
183 // Declare the output file names separated by blancs.
184 // (can be like: file.root or file.root@ALICE::Niham::File)
185 // To only save certain files, use SetDefaultOutputs(kFALSE), and then
186 // SetOutputFiles("list.root other.filename") to choose which files to save
187 plugin->SetDefaultOutputs();
188 //plugin->SetOutputFiles("list.root");
190 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
191 plugin->SetAnalysisMacro(Form("%s.C",taskname));
193 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
194 plugin->SetSplitMaxInputFileNumber(100);
196 // Optionally modify the executable name (default analysis.sh)
197 plugin->SetExecutable(Form("%s.sh",taskname));
199 // set number of test files to use in "test" mode
200 plugin->SetNtestFiles(10);
202 // Optionally resubmit threshold.
203 plugin->SetMasterResubmitThreshold(90);
205 // Optionally set time to live (default 30000 sec)
206 plugin->SetTTL(30000);
208 // Optionally set input format (default xml-single)
209 plugin->SetInputFormat("xml-single");
211 // Optionally modify the name of the generated JDL (default analysis.jdl)
212 plugin->SetJDLName(Form("%s.jdl",taskname));
214 // Optionally modify job price (default 1)
217 // Optionally modify split mode (default 'se')
218 plugin->SetSplitMode("se");
220 //----------------------------------------------------------
221 //--- PROOF MODE SPECIFIC SETTINGS ------------
222 //----------------------------------------------------------
224 plugin->SetProofCluster(proofcluster);
225 // Dataset to be used
226 plugin->SetProofDataSet(proofdataset);
227 // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard
228 plugin->SetProofReset(0);
229 // May limit number of workers
230 plugin->SetNproofWorkers(0);
231 // May limit the number of workers per slave
232 plugin->SetNproofWorkersPerSlave(1);
233 // May use a specific version of root installed in proof
234 plugin->SetRootVersionForProof("current");
235 // May set the aliroot mode. Check http://aaf.cern.ch/node/83
236 plugin->SetAliRootMode("default"); // Loads AF libs by default
237 // May request ClearPackages (individual ClearPackage not supported)
238 plugin->SetClearPackages(kFALSE);
239 // Plugin test mode works only providing a file containing test file locations, used in "local" mode also
240 plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc
241 // Request connection to alien upon connection to grid
242 plugin->SetProofConnectGrid(kFALSE);