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 = "local", // local, proof or grid
13 const char *gridmode = "test", // 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 = 50000000, // 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("libOADB.so");
42 gSystem->Load("libANALYSISalice.so");
44 // add aliroot indlude path
45 gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT")));
46 gROOT->SetStyle("Plain");
49 AliAnalysisManager* mgr = new AliAnalysisManager(taskname);
51 // create the alien handler and attach it to the manager
52 AliAnalysisGrid *plugin = CreateAlienHandler(taskname, gridmode, proofcluster, proofdataset);
53 mgr->SetGridHandler(plugin);
55 // AliVEventHandler* iH = new AliESDInputHandler();
56 AliAODInputHandler* iH = new AliAODInputHandler();
57 // iH->SetInactiveBranches("tracks. vertices. v0s. cascades. jets. caloClusters. fmdClusters. pmdClusters. dimuons. AliAODZDC");
58 iH->SetInactiveBranches("*");
59 // iH->SetCheckStatistics(kTRUE);
60 mgr->SetInputEventHandler(iH);
62 // mc event handlerrunEx01.C
64 AliMCEventHandler* mchandler = new AliMCEventHandler();
65 // Not reading track references
66 mchandler->SetReadTR(kFALSE);
67 mgr->SetMCtruthEventHandler(mchandler);
70 // === Physics Selection Task ===
72 // In SelectCollisionCandidate(), default is kMB, so the task UserExec()
73 // function is only called for these events.
75 // kMB Minimum Bias trigger
76 // kMBNoTRD Minimum bias trigger where the TRD is not read out
78 // kHighMult High-Multiplicity Trigger
79 // kUserDefined For manually defined trigger selection
81 // Multiple options possible with the standard AND/OR operators && and ||
82 // These all have the usual offline SPD or V0 selections performed.
84 // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(),
85 // one can manually set the selected and background classes using:
86 // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL")
87 // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL");
89 // One can also specify multiple classes at once, or require a class to NOT
91 // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL");
93 // NOTE that manually setting the physics selection overrides the standard
94 // selection, so it must be done in completeness.
96 // ALTERNATIVELY, one can make the physics selection inside the task
98 // For this case, comment out the task->SelectCol.... line,
99 // and see AliBasicTask.cxx UserExec() function for details on this.
101 // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
102 // AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel);
103 // if(!physSelTask) { Printf("no physSelTask"); return; }
104 //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection();
105 //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769");
108 gROOT->LoadMacro("AliAnalysisTaskEx01.cxx+g");
109 AliAnalysisTaskSE* task = new AliAnalysisTaskEx01(taskname);
110 task->SelectCollisionCandidates(AliVEvent::kMB); // if physics selection performed in UserExec(), this line should be commented
113 // set output root file name for different analysis
114 TString outfilename = Form("list.%s.root",runtype);
116 // create containers for input/output
117 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
118 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("coutput1", TList::Class(), AliAnalysisManager::kOutputContainer, outfilename);
120 // connect input/output
121 mgr->ConnectInput(task, 0, cinput);
122 mgr->ConnectOutput(task, 1, coutput1);
124 // enable debug printouts
125 mgr->SetDebugLevel(2);
126 mgr->SetNSysInfo(100);
127 if (!mgr->InitAnalysis()) return;
131 Printf("Starting Analysis....");
132 mgr->StartAnalysis(runtype,nentries,firstentry);
135 //______________________________________________________________________________
136 AliAnalysisGrid* CreateAlienHandler(const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset)
138 AliAnalysisAlien *plugin = new AliAnalysisAlien();
139 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
140 plugin->SetRunMode(gridmode);
142 // Set versions of used packages
143 plugin->SetAPIVersion("V1.1x");
144 plugin->SetROOTVersion("v5-28-00d");
145 plugin->SetAliROOTVersion("v4-21-25-AN-1");
147 // Declare input data to be processed.
148 plugin->SetCheckCopy(kFALSE);
150 // Method 1: Create automatically XML collections using alien 'find' command.
151 // Define production directory LFN
152 plugin->SetGridDataDir("/alice/data/2010/LHC10b");
153 // On real reconstructed data:
154 // plugin->SetGridDataDir("/alice/data/2009/LHC09d");
155 // Set data search pattern
156 //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES
157 // Data pattern for reconstructed data
158 // plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
159 plugin->SetDataPattern("ESDs/pass2/AOD038/*AliAOD.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
160 plugin->SetRunPrefix("000"); // real data
161 // ...then add run numbers to be considered
162 Int_t runlist[15]={117039, 146859, 146858, 146856, 146824, 146817, 146806, 146805, 146804, 146803, 146802, 146801, 146748, 146747, 146746};
163 for (Int_t ind=0; ind<1; ind++) {
164 // plugin->AddRunNumber(138275);
165 plugin->AddRunNumber(runlist[ind]);
167 //plugin->SetRunRange(114917,115322);
168 plugin->SetNrunsPerMaster(10); // 1
169 plugin->SetOutputToRunNo();
170 // comment out the next line when using the "terminate" option, unless
171 // you want separate merged files for each run
172 plugin->SetMergeViaJDL();
174 // Method 2: Declare existing data files (raw collections, xml collections, root file)
175 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
176 // XML collections added via this method can be combined with the first method if
177 // the content is compatible (using or not tags)
178 // plugin->AddDataFile("tag.xml");
179 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
181 // Define alien work directory where all files will be copied. Relative to alien $HOME.
182 plugin->SetGridWorkingDir(taskname);
184 // Declare alien output directory. Relative to working directory.
185 plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out
187 // Declare the analysis source files names separated by blancs. To be compiled runtime
188 // using ACLiC on the worker nodes.
189 plugin->SetAnalysisSource("AliAnalysisTaskEx01.cxx");
191 // Declare all libraries (other than the default ones for the framework. These will be
192 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
193 plugin->SetAdditionalLibs("AliAnalysisTaskEx01.h AliAnalysisTaskEx01.cxx");
195 // Declare the output file names separated by blancs.
196 // (can be like: file.root or file.root@ALICE::Niham::File)
197 // To only save certain files, use SetDefaultOutputs(kFALSE), and then
198 // SetOutputFiles("list.root other.filename") to choose which files to save
199 plugin->SetDefaultOutputs();
200 //plugin->SetOutputFiles("list.root");
202 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
203 plugin->SetAnalysisMacro(Form("%s.C",taskname));
205 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
206 plugin->SetSplitMaxInputFileNumber(100);
208 // Optionally modify the executable name (default analysis.sh)
209 plugin->SetExecutable(Form("%s.sh",taskname));
211 // set number of test files to use in "test" mode
212 plugin->SetNtestFiles(10);
214 // Optionally resubmit threshold.
215 plugin->SetMasterResubmitThreshold(90);
217 // Optionally set time to live (default 30000 sec)
218 plugin->SetTTL(30000);
220 // Optionally set input format (default xml-single)
221 plugin->SetInputFormat("xml-single");
223 // Optionally modify the name of the generated JDL (default analysis.jdl)
224 plugin->SetJDLName(Form("%s.jdl",taskname));
226 // Optionally modify job price (default 1)
229 // Optionally modify split mode (default 'se')
230 plugin->SetSplitMode("se");
232 //----------------------------------------------------------
233 //--- PROOF MODE SPECIFIC SETTINGS ------------
234 //----------------------------------------------------------
236 plugin->SetProofCluster(proofcluster);
237 // Dataset to be used
238 plugin->SetProofDataSet(proofdataset);
239 // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard
240 plugin->SetProofReset(0);
241 // May limit number of workers
242 plugin->SetNproofWorkers(0);
243 // May limit the number of workers per slave
244 plugin->SetNproofWorkersPerSlave(1);
245 // May use a specific version of root installed in proof
246 plugin->SetRootVersionForProof("current");
247 // May set the aliroot mode. Check http://aaf.cern.ch/node/83
248 plugin->SetAliRootMode("default"); // Loads AF libs by default
249 // May request ClearPackages (individual ClearPackage not supported)
250 plugin->SetClearPackages(kFALSE);
251 // Plugin test mode works only providing a file containing test file locations, used in "local" mode also
252 plugin->SetFileForTestMode("filesaod.txt"); // file should contain path name to a local directory containg *ESDs.root etc
253 // Request connection to alien upon connection to grid
254 plugin->SetProofConnectGrid(kFALSE);
255 // Other PROOF specific parameters
256 plugin->SetProofParameter("PROOF_UseMergers","-1");
257 printf("Using: PROOF_UseMergers : %s\n", plugin->GetProofParameter("PROOF_UseMergers"));