Test task for Nano and standard AOD
[u/mrichter/AliRoot.git] / PWG / DevNanoAOD / runAllCh.C
CommitLineData
9d6172fe 1// run.C
2//
3// Template run macro for AliBasicTask.cxx/.h with example layout of
4// physics selections and options, in macro and task.
5//
6// Author: Arvinder Palaha
7//
8class AliAnalysisGrid;
9
10//______________________________________________________________________________
11void runAllCh(
12 Bool_t isNano = 1,
13 const char* runtype = "local", // local, proof or grid
14 const char *gridmode = "test", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof
15 const bool bMCtruth = 1, // 1 = MCEvent handler is on (MC truth), 0 = MCEvent handler is off (MC reconstructed/real data)
16 const bool bMCphyssel = 0, // 1 = looking at MC truth or reconstructed, 0 = looking at real data
17 const Long64_t nentries = 2000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events.
18 const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode
19 const char *proofdataset = "/alice/data/LHC10c_000120821_p1", // path to dataset on proof cluster, for proof analysis
20 const char *proofcluster = "alice-caf.cern.ch", // which proof cluster to use in proof mode
21 const char *taskname = "example_task" // sets name of grid generated macros
22 )
23{
24 // check run type
25 if(runtype != "local" && runtype != "proof" && runtype != "grid"){
26 Printf("\n\tIncorrect run option, check first argument of run macro");
27 Printf("\tint runtype = local, proof or grid\n");
28 return;
29 }
30 Printf("%s analysis chosen",runtype);
31
32 // load libraries
33 gSystem->Load("libCore.so");
34 gSystem->Load("libGeom.so");
35 gSystem->Load("libPhysics.so");
36 gSystem->Load("libVMC");
37 gSystem->Load("libTree");
38 gSystem->Load("libProof");
39 gSystem->Load("libMatrix");
40 gSystem->Load("libMinuit");
41 gSystem->Load("libSTEERBase");
42 gSystem->Load("libESD");
43 gSystem->Load("libAOD");
44 gSystem->Load("libANALYSIS");
45 // return;
46 gSystem->Load("libOADB");
47 gSystem->Load("libANALYSISalice");
48 gSystem->Load("libTENDER");
49 gSystem->Load("libCORRFW");
50 // gSystem->Load("libPWG0base");
51 gSystem->Load("libMinuit");
52 gSystem->Load("libPWGTools");
53 gSystem->Load("libPWGLFspectra");
54 gSystem->Load("libPWGLFthermalfits");
55 gSystem->Load("libPWGDevNanoAOD.so");
56
57
58 // add aliroot indlude path
59 gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT")));
60 gROOT->SetStyle("Plain");
61
62 // analysis manager
63 AliAnalysisManager* mgr = new AliAnalysisManager(taskname);
64
65 // create the alien handler and attach it to the manager
66 AliAnalysisGrid *plugin = CreateAlienHandler(taskname, gridmode, proofcluster, proofdataset);
67 mgr->SetGridHandler(plugin);
68
69 AliInputEventHandler* iH = new AliAODInputHandler();
70 if(isNano) {
71 iH->SetEventSelection(new AliAnalysisNanoAODTrackCuts); // FIXME: we need this, otherwise we crash in AliAODInputHandler::BeginEvent where fIsSelectedResult = fEvent->GetHeader()->GetOfflineTrigger(). This is a temporary hack. In the future, it will be solved by using AliVHeader in the AliAODInputHandler.
72 }
73
74// AliAODInputHandler* iH = new AliAODInputHandler();
75// iH->SetInactiveBranches("tracks. vertices. v0s. cascades. jets. caloClusters. fmdClusters. pmdClusters. dimuons. AliAODZDC");
76// iH->SetInactiveBranches("*");
77// iH->SetCheckStatistics(kTRUE);
78 mgr->SetInputEventHandler(iH);
79
80 // mc event handlerrunEx01.C
81 if(bMCtruth) {
82 AliMCEventHandler* mchandler = new AliMCEventHandler();
83 // Not reading track references
84 mchandler->SetReadTR(kFALSE);
85 mgr->SetMCtruthEventHandler(mchandler);
86 }
87
88 // === Physics Selection Task ===
89 //
90 // In SelectCollisionCandidate(), default is kMB, so the task UserExec()
91 // function is only called for these events.
92 // Options are:
93 // kMB Minimum Bias trigger
94 // kMBNoTRD Minimum bias trigger where the TRD is not read out
95 // kMUON Muon trigger
96 // kHighMult High-Multiplicity Trigger
97 // kUserDefined For manually defined trigger selection
98 //
99 // Multiple options possible with the standard AND/OR operators && and ||
100 // These all have the usual offline SPD or V0 selections performed.
101 //
102 // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(),
103 // one can manually set the selected and background classes using:
104 // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL")
105 // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL");
106 //
107 // One can also specify multiple classes at once, or require a class to NOT
108 // trigger, for e.g.
109 // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL");
110 //
111 // NOTE that manually setting the physics selection overrides the standard
112 // selection, so it must be done in completeness.
113 //
114 // ALTERNATIVELY, one can make the physics selection inside the task
115 // UserExec().
116 // For this case, comment out the task->SelectCol.... line,
117 // and see AliBasicTask.cxx UserExec() function for details on this.
118
119// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
120// AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel);
121// if(!physSelTask) { Printf("no physSelTask"); return; }
122 //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection();
123 //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769");
124
125 // PID RESPONSE
126 if(!isNano){
127 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
128 AliAnalysisTaskPIDResponse *taskPID=AddTaskPIDResponse(bMCtruth);
129 taskPID->SetUseTPCEtaCorrection(kTRUE);
130 taskPID->SetUserDataRecoPass(2);
131 }
132
133
134 // create task
135 gROOT->LoadMacro("AddTaskSpectraAllChNanoAOD.C");
136 //load calibration object for LHC10h
137 AliAnalysisTaskSpectraAllChNanoAOD* task = AddTaskSpectraAllChAOD(bMCtruth, // MC
138 0, // cent min
139 100, //cent max
140 -999999., // q min
141 999999., // q max
142 -0.8, // eta min
143 0.8, // eta max
144 15.0, // pt max
145 0.6, // pt tof
146 1024, // trkbit
147 100000, // dca
148 70, // tpc cls
149 3.0, // nsigma
150 2, // pid type, 2 = nsigma TPC TOF
151 "_EvtOnly_F1024_VZEROA");
152 TFile * fCalib=TFile::Open("calibV0New.root");
153 task->GetEventCuts()->SetCalibFile(fCalib);
154 task->GetEventCuts()->SetIsLHC10h(kTRUE);
155 task->GetEventCuts()->SetCentralityMethod("V0M");
156
157 task->SetVZEROside(0); //0: VZERO-A 1: VZERO-C
158
159 task->SetFillOnlyEvents(0);
160 task->SetnCentBins(100);
161 task->SetnQvecBins(400);
162 task->SetnNchBins(1);
163
164 // task->SelectCollisionCandidates(AliVEvent::kMB); // if physics selection performed in UserExec(), this line should be commented
165 mgr->AddTask(task);
166
167 // set output root file name for different analysis
168 // TString outfilename = Form("list.%s.root",runtype);
169
170 // create containers for input/output
171 // AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
172 // AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("coutput1", TList::Class(), AliAnalysisManager::kOutputContainer, outfilename);
173
174 // connect input/output
175 // mgr->ConnectInput(task, 0, cinput);
176 // mgr->ConnectOutput(task, 1, coutput1);
177
178 // enable debug printouts
179 mgr->SetDebugLevel(10);
180 // mgr->SetNSysInfo(100);
181 if (!mgr->InitAnalysis()) return;
182 mgr->PrintStatus();
183
184 // start analysis
185 Printf("Starting Analysis....");
186 mgr->StartAnalysis(runtype,nentries,firstentry);
187}
188
189//______________________________________________________________________________
190AliAnalysisGrid* CreateAlienHandler(const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset)
191{
192 AliAnalysisAlien *plugin = new AliAnalysisAlien();
193 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
194 plugin->SetRunMode(gridmode);
195
196 // Set versions of used packages
197 plugin->SetAPIVersion("V1.1x");
198 plugin->SetROOTVersion("v5-34-08-5");
199 plugin->SetAliROOTVersion("vAN-20140317");
200
201 // Declare input data to be processed.
202// plugin->SetCheckCopy(kFALSE);
203
204 // Method 1: Create automatically XML collections using alien 'find' command.
205 // Define production directory LFN
206 plugin->SetGridDataDir("/alice/data/2010/LHC10b");
207 // On real reconstructed data:
208 // plugin->SetGridDataDir("/alice/data/2009/LHC09d");
209 // Set data search pattern
210 //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES
211 // Data pattern for reconstructed data
212 plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
213 // plugin->SetDataPattern("ESDs/pass2/AOD038/*AliAOD.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
214 plugin->SetRunPrefix("000"); // real data
215 // ...then add run numbers to be considered
216 Int_t runlist[15]={117039, 146859, 146858, 146856, 146824, 146817, 146806, 146805, 146804, 146803, 146802, 146801, 146748, 146747, 146746};
217 for (Int_t ind=0; ind<1; ind++) {
218// plugin->AddRunNumber(138275);
219 plugin->AddRunNumber(runlist[ind]);
220 }
221 //plugin->SetRunRange(114917,115322);
222 plugin->SetNrunsPerMaster(10); // 1
223 plugin->SetOutputToRunNo();
224 // comment out the next line when using the "terminate" option, unless
225 // you want separate merged files for each run
226 plugin->SetMergeViaJDL();
227
228 // Method 2: Declare existing data files (raw collections, xml collections, root file)
229 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
230 // XML collections added via this method can be combined with the first method if
231 // the content is compatible (using or not tags)
232 // plugin->AddDataFile("tag.xml");
233 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
234
235 // Define alien work directory where all files will be copied. Relative to alien $HOME.
236 plugin->SetGridWorkingDir(taskname);
237
238 // Declare alien output directory. Relative to working directory.
239 plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out
240
241 // Declare the analysis source files names separated by blancs. To be compiled runtime
242 // using ACLiC on the worker nodes.
243 plugin->SetAnalysisSource("AliAnalysisTaskEx01.cxx");
244
245 // Declare all libraries (other than the default ones for the framework. These will be
246 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
247 plugin->SetAdditionalLibs("AliAnalysisTaskEx01.h AliAnalysisTaskEx01.cxx");
248
249 // Declare the output file names separated by blancs.
250 // (can be like: file.root or file.root@ALICE::Niham::File)
251 // To only save certain files, use SetDefaultOutputs(kFALSE), and then
252 // SetOutputFiles("list.root other.filename") to choose which files to save
253 plugin->SetDefaultOutputs();
254 //plugin->SetOutputFiles("list.root");
255
256 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
257 plugin->SetAnalysisMacro(Form("%s.C",taskname));
258
259 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
260 plugin->SetSplitMaxInputFileNumber(100);
261
262 // Optionally modify the executable name (default analysis.sh)
263 plugin->SetExecutable(Form("%s.sh",taskname));
264
265 // set number of test files to use in "test" mode
266 plugin->SetNtestFiles(10);
267
268 // Optionally resubmit threshold.
269 plugin->SetMasterResubmitThreshold(90);
270
271 // Optionally set time to live (default 30000 sec)
272 plugin->SetTTL(30000);
273
274 // Optionally set input format (default xml-single)
275 plugin->SetInputFormat("xml-single");
276
277 // Optionally modify the name of the generated JDL (default analysis.jdl)
278 plugin->SetJDLName(Form("%s.jdl",taskname));
279
280 // Optionally modify job price (default 1)
281 plugin->SetPrice(1);
282
283 // Optionally modify split mode (default 'se')
284 plugin->SetSplitMode("se");
285
286 //----------------------------------------------------------
287 //--- PROOF MODE SPECIFIC SETTINGS ------------
288 //----------------------------------------------------------
289 // Proof cluster
290 plugin->SetProofCluster(proofcluster);
291 // Dataset to be used
292 plugin->SetProofDataSet(proofdataset);
293 // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard
294 plugin->SetProofReset(0);
295 // May limit number of workers
296 plugin->SetNproofWorkers(0);
297 // May limit the number of workers per slave
298 plugin->SetNproofWorkersPerSlave(1);
299 // May use a specific version of root installed in proof
300 plugin->SetRootVersionForProof("current");
301 // May set the aliroot mode. Check http://aaf.cern.ch/node/83
302 plugin->SetAliRootMode("default"); // Loads AF libs by default
303 // May request ClearPackages (individual ClearPackage not supported)
304 plugin->SetClearPackages(kFALSE);
305 // Plugin test mode works only providing a file containing test file locations, used in "local" mode also
306 plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc
307 // Request connection to alien upon connection to grid
308 plugin->SetProofConnectGrid(kFALSE);
309 // Other PROOF specific parameters
310 plugin->SetProofParameter("PROOF_UseMergers","-1");
311 printf("Using: PROOF_UseMergers : %s\n", plugin->GetProofParameter("PROOF_UseMergers"));
312 return plugin;
313}
314