]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/macros/examples/simpleAODtrainJETAN.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGJE / macros / examples / simpleAODtrainJETAN.C
1 AliAnalysisGrid* CreateAlienHandler(const Char_t *mode);
2
3 void simpleAODtrainJETAN(const Char_t *mode="full"){
4   //
5   //  Run analysis, mode can be "full", "test", "submit" or "terminate",
6   //           see CreateAlienHandler for details.
7   //
8
9   // Load common libraries
10   gSystem->Load("libCore");
11   gSystem->Load("libTree");
12   gSystem->Load("libGeom");
13   gSystem->Load("libVMC");
14   gSystem->Load("libPhysics");
15   gSystem->Load("libSTEERBase");
16   gSystem->Load("libESD");
17   gSystem->Load("libAOD");
18   gSystem->Load("libANALYSIS");
19   gSystem->Load("libANALYSISalice");   
20
21   gSystem->Load("libCORRFW");
22   gSystem->Load("libJETAN");
23   gSystem->Load("libfastjet");
24   gSystem->Load("libSISConePlugin");
25   gSystem->Load("libFASTJETAN");
26   gSystem->Load("libPWGTools");
27   gSystem->Load("libPWGJE");
28
29   // Use AliRoot includes to compile our task
30   gSystem->AddIncludePath("-I$ALICE_ROOT/include -I$ALICE_ROOT/JETAN -I$ALICE_ROOT/PWG4/JetTasks");
31
32   // Create and configure the alien handler plugin
33   AliAnalysisGrid *alienHandler = CreateAlienHandler(mode);  
34   if (!alienHandler) return;
35
36   // Create the analysis manager
37   AliAnalysisManager *mgr = new AliAnalysisManager("testAnalysis");
38
39   // Connect plug-in to the analysis manager
40   mgr->SetGridHandler(alienHandler);
41
42   // Standard train runs on ESD; AOD may not work?
43   AliAODInputHandler* aodH = new AliAODInputHandler();
44   mgr->SetInputEventHandler(aodH);
45
46   // Need output handler, but tree is not filled...
47   gROOT->LoadMacro(gSystem->ExpandPathName("$ALICE_ROOT/ANALYSIS/macros/train/AddAODOutputHandler.C"));
48   AliVEventHandler* handler = AddAODOutputHandler();
49   //handler->SetFillAODForRun(kFALSE);
50
51   mgr->SetCommonFileName("AnalysisResult.root");
52
53   // Only for ESD?
54   //gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C");
55   //AddTaskPhysicsSelection(kFALSE, kTRUE);
56
57
58   // gROOT->Macro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C"); // Only for ESD
59
60   gROOT->Macro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
61
62   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/ConfigLegoTrainPWGJE.C");
63   ConfigLegoTrainPWGJE(1108); // For DeltaAODName; LHC11h settings
64
65   const Int_t kHighPtFilterMask = 768;  // LHC11h
66   const Int_t kHighPtFilterMaskBest = 256; // LHC11h
67   const Float_t kR = 0.3;
68
69   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/AddTaskJetCluster.C");
70   jetclu = AddTaskJetCluster("AOD","",kHighPtFilterMask,AliVEvent::kAny,"ANTIKT",kR,0,kTRUE, AliAnalysisManager::GetGlobalStr("kJetDeltaAODName",gDebug),0.15,0.9,10,0);
71
72   jetclu->SetEventSelection(kTRUE); 
73   jetclu->SetJetTypes(1<<0|1<<2|1<<3);
74   jetclu->SetNRandomCones(1);
75   jetclu->SetCentralityCut(0.,80.);
76   jetclu->SetJetOutputMinPt(0);
77   jetclu->SetFilterMaskBestPt(kHighPtFilterMaskBest);
78   //jetclu->SetDebugLevel(1);
79
80   // output dir: PWGJE_cluster_AOD__ANTIKT03_B0_Filter00272_Cut00150_Skip00
81
82   jetclukt = AddTaskJetCluster("AOD","",kHighPtFilterMask,AliVEvent::kAny,"KT",kR,0,kTRUE,AliAnalysisManager::GetGlobalStr("kJetDeltaAODName",gDebug),0.15,0.9,10,0);
83   jetclukt->SetBackgroundCalc(kTRUE);
84   jetclukt->SetEventSelection(kTRUE); 
85   jetclukt->SetCentralityCut(0.,80.);
86   jetclukt->SetJetOutputMinPt(0);
87   jetclukt->SetFilterMaskBestPt(kHighPtFilterMaskBest);
88   //jetclukt->SetDebugLevel(1);
89
90   AliAnalysisManager::SetGlobalInt("kPhysicsSelectionFlag",AliVEvent::kMB|AliVEvent::kCentral|AliVEvent::kSemiCentral|AliVEvent::kEMCEJE|AliVEvent::kEMCEGA|AliVEvent::kEMC1);
91
92   Int_t kRpar = Int_t(10*kR + 0.001);
93   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/AddTaskJetBackgroundSubtract.C");
94   jetbkg = AddTaskJetBackgroundSubtract(TString(Form("clustersAOD_ANTIKT%02d_B0_Filter%05d_Cut00150_Skip00",kRpar,kHighPtFilterMask)),2);
95   jetbkg->SetBackgroundBranch(Form("jeteventbackground_clustersAOD_KT%02d_B0_Filter%05d_Cut00150_Skip00",kRpar,kHighPtFilterMask));
96   jetbkg->SelectCollisionCandidates(AliAnalysisManager::GetGlobalInt("kPhysicsSelectionFlag", gDebug));
97   jetbkg->SetKeepJets(kTRUE);
98   jetbkg->SetNonStdOutputFile(AliAnalysisManager::GetGlobalStr("kJetDeltaAODName",gDebug));
99   //jetbkg->SetDebugLevel(1);
100
101   // Looking for input dir: clustersAOD_ANTIKT03_B2_Filter00768_Cut00150_Skip00
102   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/AddTaskFragmentationFunction.C");
103   Int_t kEvtClass = 1; // Central events
104
105   // Need to add 'type = AOD' as third argument -- only for MC...
106   fftask = AddTaskFragmentationFunction("clustersAOD_ANTIKT", "", "", "", "", kHighPtFilterMask, kR,2,150.,kEvtClass, "_Skip00");
107   //fftask->SetPhiCorrHistoBins(); 
108   fftask->SetEventSelectionMask(AliVEvent::kMB|AliVEvent::kCentral|AliVEvent::kSemiCentral);
109   fftask->UseAODInputJets(kFALSE);  // to pick up jets from the output AOD
110   //fftask->SetDebugLevel(1);
111
112
113   if (!mgr->InitAnalysis())
114     return;
115
116   mgr->PrintStatus();
117
118   // Start analysis via AlienPlugin; test runs etc are handled via flag to CreateAlienHandler
119   mgr->StartAnalysis("grid"); 
120 };
121
122
123 AliAnalysisGrid* CreateAlienHandler(const Char_t *mode)
124 {
125
126    AliAnalysisAlien *plugin = new AliAnalysisAlien();
127    plugin->SetOverwriteMode();
128 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
129    plugin->SetRunMode(mode); //terminate");
130 // Set versions of used packages
131    plugin->SetAPIVersion("V1.1x");
132    plugin->SetROOTVersion("v5-34-08");
133    plugin->SetAliROOTVersion("v5-05-11-AN");
134    plugin->AddExternalPackage("cgal::v3.6 fastjet::v2.4.2");
135
136    // Declare input data to be processed.
137    // Method 1: Create automatically XML collections using alien 'find' command.
138    // Define production directory LFN
139    // One file:
140    //plugin->SetGridDataDir("/alice/data/2011/LHC11h_2/000170081/ESDs/pass2/AOD115/0829/");
141    // One run:
142    plugin->SetGridDataDir("/alice/data/2011/LHC11h_2/000170081/ESDs/pass2/AOD115/");
143    // Set data search pattern
144    plugin->SetDataPattern("*AOD.root");
145
146    // Can be extended to multiple runs:
147    //
148    //   plugin->SetRunPrefix("000");   // real data
149    // ...then add run numbers to be considered
150    //plugin->AddRunNumber(191027);
151    //   plugin->AddRunNumber(104065);  // real data
152    //   plugin->SetOutputSingleFolder("output");
153    //   plugin->SetOutputToRunNo();
154
155    
156    // Method 2: Declare existing data files (raw collections, xml collections, root file)
157    // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
158    // XML collections added via this method can be combined with the first method if
159    // the content is compatible (using or not tags)
160    //   plugin->AddDataFile("tag.xml");
161    //   plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
162
163
164    // Define alien work directory where all files will be copied. Relative to alien $HOME.
165    plugin->SetGridWorkingDir("AOD_jets_PbPb");
166    // Declare alien output directory. Relative to working directory.
167    plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output
168    // Declare the analysis source files names separated by blancs. To be compiled runtime
169    // using ACLiC on the worker nodes.
170    // plugin->SetAnalysisSource("AliAnalysisAODJetHists.cxx");
171    // Declare all libraries (other than the default ones for the framework. These will be
172    // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
173    plugin->SetAdditionalLibs("libCORRFW.so libJETAN.so libCGAL.so libfastjet.so libSISConePlugin.so libFASTJETAN.so libPWGTools.so libPWGJE.so");
174    plugin->AddIncludePath("-I$ALICE_ROOT/JETAN -I$ALICE_ROOT/PWGJE");
175    // Declare the output file names separated by blancs.
176    // (can be like: file.root or file.root@ALICE::Niham::File)
177    //   plugin->SetOutputFiles("Pt.ESD.1.root");
178    plugin->SetDefaultOutputs(kFALSE);
179    plugin->SetOutputFiles("AnalysisResult.root EventStat_temp.root");
180    //plugin->SetDefaultOutputs();
181    // Optionally define the files to be archived.
182    //   plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:*.root@ALICE::NIHAM::File");
183    //   plugin->SetOutputArchive("log_archive.zip:stdout,stderr");
184    // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
185    plugin->SetAnalysisMacro("AODJetsPbPb.C");
186    // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
187    plugin->SetSplitMaxInputFileNumber(100);
188    // Optionally modify the executable name (default analysis.sh)
189    plugin->SetExecutable("AODJetsPbPb.sh");
190    // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
191    //   plugin->SetMaxInitFailed(5);
192    // Optionally resubmit threshold.
193    //   plugin->SetMasterResubmitThreshold(90);
194    // Optionally set time to live (default 30000 sec)
195    plugin->SetTTL(30000);
196    // Optionally set input format (default xml-single)
197    plugin->SetInputFormat("xml-single");
198    // Optionally modify the name of the generated JDL (default analysis.jdl)
199    plugin->SetJDLName("AODJetsPbPb.jdl");
200    // Optionally modify job price (default 1)
201    plugin->SetPrice(1);      
202    // Optionally modify split mode (default 'se')    
203    plugin->SetSplitMode("se");
204    return plugin;
205 }