]>
Commit | Line | Data |
---|---|---|
335dcaa5 | 1 | |
2 | class AliAnalysisGrid; | |
3 | ||
4 | //______________________________________________________________________________ | |
5 | void runFPexample( | |
6 | const char* runtype = "grid", // local, proof or grid | |
7 | const bool useRealData = true, // run the proof with data or MC | |
8 | const char *gridMode = "full", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof | |
9 | const char *taskname = "give_task_name_for_grid_analysis", // the unique name of our task *must be a valid c identifier* | |
10 | const Int_t gridRun = -1, // the run to analyse *must be set for grid mode* | |
11 | const char *gridDirData = "/alice/data/2010/LHC10d", // the location of the data for grid analysis | |
12 | const char *gridDirMC = "/alice/sim/LHC10f6a", // the location of the MC for grid analysis | |
13 | const Long64_t proofNentries = 2000000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events. | |
14 | const Long64_t proofFirstEntry = 0, // for local and proof mode, ignored in grid mode | |
15 | ) | |
16 | { | |
17 | // check run type | |
18 | if(runtype != "local" && runtype != "proof" && runtype != "grid"){ | |
19 | Printf("\n\tIncorrect run option, check first argument of run macro"); | |
20 | Printf("\tint runtype = local, proof or grid\n"); | |
21 | return; | |
22 | } | |
23 | Printf("%s analysis chosen", runtype); | |
24 | ||
25 | const bool bMCtruth = !useRealData; | |
26 | bool bMCphyssel = false; | |
27 | ||
28 | const char *proofRealDataSet = "/default/kimb/LHC10d_000126405"; | |
29 | const char *proofMCDataSet = "/alice/sim/LHC11b1a_000118558"; | |
30 | ||
31 | char *proofdataset; | |
32 | if (useRealData) { | |
33 | proofdataset = proofRealDataSet; | |
34 | bMCphyssel = false; | |
35 | Printf("Using REAL DATA (TM) for analysis"); | |
36 | } else { | |
37 | proofdataset = proofMCDataSet; | |
38 | bMCphyssel = true; | |
39 | Printf("Using MC for analysis"); | |
40 | } | |
41 | const char *proofcluster = "alice-caf.cern.ch"; // which proof cluster to use in proof mode | |
42 | ||
43 | // load libraries | |
4070f709 | 44 | gSystem->Load("libCore"); |
45 | gSystem->Load("libGeom"); | |
46 | gSystem->Load("libVMC"); | |
47 | gSystem->Load("libPhysics"); | |
48 | gSystem->Load("libTree"); | |
49 | gSystem->Load("libSTEERBase"); | |
50 | gSystem->Load("libESD"); | |
51 | gSystem->Load("libAOD"); | |
52 | gSystem->Load("libANALYSIS"); | |
53 | gSystem->Load("libANALYSISalice"); | |
335dcaa5 | 54 | |
55 | // add aliroot indlude path | |
56 | gROOT->ProcessLine(TString::Format(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT"))); | |
57 | gROOT->SetStyle("Plain"); | |
58 | ||
59 | // analysis manager | |
60 | AliAnalysisManager* mgr = new AliAnalysisManager(taskname); | |
61 | ||
62 | // create the alien handler and attach it to the manager | |
63 | AliAnalysisAlien *plugin = new AliAnalysisAlien(); | |
64 | mgr->SetGridHandler(plugin); | |
65 | ||
66 | AliVEventHandler* esdH = new AliESDInputHandler(); | |
67 | mgr->SetInputEventHandler(esdH); | |
68 | ||
69 | // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") | |
70 | plugin->SetRunMode(gridMode); | |
71 | ||
72 | gROOT->LoadMacro("AddTaskFPexample.C"); | |
73 | AddTaskFPexample(mgr, plugin, runtype, useRealData, taskname, gridRun); | |
74 | ||
75 | // Define alien work directory where all files will be copied. Relative to alien $HOME. | |
76 | plugin->SetGridWorkingDir(TString::Format("%s/%d/%s", taskname, gridRun, useRealData ? "data" : "sim").Data()); | |
77 | ||
78 | // Declare alien output directory. Relative to working directory. | |
79 | plugin->SetGridOutputDir("output"); | |
80 | ||
81 | // Declare the analysis source files names separated by blancs. To be compiled runtime | |
82 | // using ACLiC on the worker nodes. | |
83 | // the upload order matters on PROOF! if A.cxx depends on B.h then put B.cxx first (my experience) | |
84 | plugin->SetAnalysisSource("AliAnalysisTaskFirstPhysics.cxx AliAnalysisHistosVertex.cxx AliAnalysisTaskFPexample.cxx"); | |
85 | ||
86 | // Declare all libraries (other than the default ones for the framework. These will be | |
87 | // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. | |
88 | plugin->SetAdditionalLibs("AliAnalysisTaskFirstPhysics.h AliAnalysisTaskFirstPhysics.cxx AliAnalysisHistosVertex.h AliAnalysisHistosVertex.cxx AliAnalysisTaskFPexample.h AliAnalysisTaskFPexample.cxx"); | |
89 | ||
90 | // Set versions of used packages | |
91 | plugin->SetAPIVersion("V1.1x"); | |
92 | plugin->SetROOTVersion("v5-28-00c"); | |
93 | plugin->SetAliROOTVersion("v4-21-22-AN"); | |
94 | ||
95 | // Declare input data to be processed. | |
96 | ||
97 | // Method 1: Create automatically XML collections using alien 'find' command. | |
98 | // Define production directory LFN | |
99 | if (useRealData) { | |
100 | plugin->SetGridDataDir(gridDirData); | |
101 | } else { | |
102 | plugin->SetGridDataDir(gridDirMC); | |
103 | } | |
104 | ||
105 | // Set data search pattern | |
106 | if (useRealData) { | |
107 | plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH | |
108 | plugin->SetRunPrefix("000"); // real data | |
109 | } else { | |
110 | plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES | |
111 | } | |
112 | // ...then add run numbers to be considered | |
113 | plugin->AddRunNumber(gridRun); | |
114 | //plugin->SetNrunsPerMaster(1); | |
115 | plugin->SetOutputToRunNo(); | |
116 | // comment out the next line when using the "terminate" option, unless | |
117 | // you want separate merged files for each run | |
118 | plugin->SetMergeViaJDL(); | |
119 | ||
120 | // Method 2: Declare existing data files (raw collections, xml collections, root file) | |
121 | // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir()) | |
122 | // XML collections added via this method can be combined with the first method if | |
123 | // the content is compatible (using or not tags) | |
124 | // plugin->AddDataFile("tag.xml"); | |
125 | // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root"); | |
126 | ||
127 | ||
128 | // Declare the output file names separated by blancs. | |
129 | // (can be like: file.root or file.root@ALICE::Niham::File) | |
130 | // To only save certain files, use SetDefaultOutputs(kFALSE), and then | |
131 | // SetOutputFiles("list.root other.filename") to choose which files to save | |
132 | plugin->SetDefaultOutputs(kFALSE); | |
133 | ||
134 | // Optionally set a name for the generated analysis macro (default MyAnalysis.C) | |
135 | plugin->SetAnalysisMacro(TString::Format("%s_%d.C", taskname, gridRun).Data()); | |
136 | ||
137 | // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) | |
138 | if (useRealData) { | |
139 | plugin->SetSplitMaxInputFileNumber(100); | |
140 | } else { | |
141 | plugin->SetSplitMaxInputFileNumber(300); | |
142 | } | |
143 | ||
144 | // Optionally modify the executable name (default analysis.sh) | |
145 | plugin->SetExecutable(TString::Format("%s_%d.sh", taskname, gridRun).Data()); | |
146 | ||
147 | // set number of test files to use in "test" mode | |
148 | plugin->SetNtestFiles(10); | |
149 | ||
150 | // Optionally resubmit threshold. | |
151 | plugin->SetMasterResubmitThreshold(90); | |
152 | ||
153 | // Optionally set time to live (default 30000 sec) | |
154 | plugin->SetTTL(30000); | |
155 | ||
156 | // Optionally set input format (default xml-single) | |
157 | plugin->SetInputFormat("xml-single"); | |
158 | ||
159 | // Optionally modify the name of the generated JDL (default analysis.jdl) | |
160 | plugin->SetJDLName(TString::Format("%s_%d.jdl", taskname, gridRun).Data()); | |
161 | ||
162 | // Optionally modify job price (default 1) | |
163 | plugin->SetPrice(1); | |
164 | ||
165 | // Optionally modify split mode (default 'se') | |
166 | plugin->SetSplitMode("se"); | |
167 | ||
168 | // Proof cluster | |
169 | plugin->SetProofCluster(proofcluster); | |
170 | // Dataset to be used | |
171 | plugin->SetProofDataSet(proofdataset); | |
172 | // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard | |
173 | plugin->SetProofReset(0); | |
174 | // May limit number of workers | |
175 | plugin->SetNproofWorkers(0); | |
176 | // May limit the number of workers per slave | |
177 | // plugin->SetNproofWorkersPerSlave(1); | |
178 | // May use a specific version of root installed in proof | |
179 | plugin->SetRootVersionForProof("current"); | |
180 | // May set the aliroot mode. Check http://aaf.cern.ch/node/83 | |
181 | plugin->SetAliRootMode("default"); // Loads AF libs by default | |
182 | // May request ClearPackages (individual ClearPackage not supported) | |
183 | plugin->SetClearPackages(kFALSE); | |
184 | // Plugin test mode works only providing a file containing test file locations, used in "local" mode also | |
185 | plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc | |
186 | // Request connection to alien upon connection to grid | |
187 | plugin->SetProofConnectGrid(kFALSE); | |
188 | ||
189 | // mc event handler | |
190 | if (bMCtruth) { | |
191 | AliMCEventHandler* mchandler = new AliMCEventHandler(); | |
192 | // Not reading track references | |
193 | mchandler->SetReadTR(kFALSE); | |
194 | mgr->SetMCtruthEventHandler(mchandler); | |
195 | } | |
196 | ||
197 | // === Physics Selection Task === | |
198 | // | |
199 | // In SelectCollisionCandidate(), default is kMB, so the task UserExec() | |
200 | // function is only called for these events. | |
201 | // Options are: | |
202 | // kMB Minimum Bias trigger | |
203 | // kMBNoTRD Minimum bias trigger where the TRD is not read out | |
204 | // kMUON Muon trigger | |
205 | // kHighMult High-Multiplicity Trigger | |
206 | // kUserDefined For manually defined trigger selection | |
207 | // | |
208 | // Multiple options possible with the standard AND/OR operators && and || | |
209 | // These all have the usual offline SPD or V0 selections performed. | |
210 | // | |
211 | // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(), | |
212 | // one can manually set the selected and background classes using: | |
213 | // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL") | |
214 | // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL"); | |
215 | // | |
216 | // One can also specify multiple classes at once, or require a class to NOT | |
217 | // trigger, for e.g. | |
218 | // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL"); | |
219 | // | |
220 | // NOTE that manually setting the physics selection overrides the standard | |
221 | // selection, so it must be done in completeness. | |
222 | // | |
223 | // ALTERNATIVELY, one can make the physics selection inside the task | |
224 | // UserExec(). | |
225 | // For this case, comment out the task->SelectCol.... line, | |
226 | // and see AliBasicTask.cxx UserExec() function for details on this. | |
227 | ||
228 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); | |
229 | AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel); | |
230 | if (!physSelTask) { | |
231 | Printf("no physSelTask"); | |
232 | return; | |
233 | } | |
234 | //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection(); | |
235 | //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769"); | |
236 | ||
237 | // enable debug printouts | |
238 | mgr->SetDebugLevel(2); | |
239 | if (!mgr->InitAnalysis()) return; | |
240 | mgr->PrintStatus(); | |
241 | ||
242 | // start analysis | |
243 | Printf("Starting Analysis...."); | |
244 | mgr->StartAnalysis(runtype, proofNentries, proofFirstEntry); | |
245 | } |