]>
Commit | Line | Data |
---|---|---|
c38e3b95 | 1 | //===================== ANALYSIS TRAIN ========================================= |
2 | // To use: copy this macro to your work directory, modify the global part to match | |
3 | // your needs, then run root. | |
4 | // root[0] .L AnalysisTrain.C | |
5 | // Grid full mode as below (other modes: test, offline, submit, terminate) | |
121e4bd5 | 6 | // root[1] AnalysisTrainPWG-244Jets("grid", "full") |
c38e3b95 | 7 | // CAF mode (requires root v5-23-02 + aliroot v4-16-Rev08) |
8 | // root[2] AnalysisTrainPWG4Jets("proof") | |
9 | // Local mode requires AliESds.root or AliAOD.root in ./data directory | |
10 | // root[3] AnalysisTrainPWG4Jets("local") | |
11 | // In proof and grid modes, a token is needed and sourcing the produced environment file. | |
12 | // | |
13 | // If 'saveTrain' flag is set, the train will generate a directory name and run | |
14 | // in this directory. A configuration file 'ConfigTrain.C' will be generated. | |
15 | // One can replay at any time the train via: | |
16 | // root[1] AnalysisTrainPWG4Jets(ana_mode, plugin_mode, "train_default_<date>/ConfigTrain.C") | |
17 | ||
18 | // For Usage with fastjet run in "offline" first and then "submit" | |
19 | // jdl and analysismacro are automatically patched after "offline" mode | |
20 | ||
21 | // ============================================================================= | |
22 | // ### General Steering variables | |
23 | // ============================================================================= | |
24 | //== general setup variables | |
25 | TString kTrainName = "testAnalysis"; // *CHANGE ME* (no blancs or special characters) | |
26 | TString kJobTag = "PWG4 Jet Tasks analysis train configured"; // *CHANGE ME* | |
27 | ||
28 | // Usage of par files ONLY in grid mode and ONLY if the code is not available | |
29 | // in the deployed AliRoot versions. Par file search path: local dir, if not there $ALICE_ROOT. | |
30 | // To refresh par files, remove the ones in the workdir, then do "make <target.par>" in | |
31 | // AliRoot. | |
32 | Bool_t kUsePAR = kFALSE; // use par files for extra libs | |
33 | Bool_t kUseCPAR = kFALSE; // use par files for common libs | |
34 | Bool_t kFillAOD = kFALSE; // switch of AOD filling for on the fly analysis | |
4721d8c5 | 35 | Int_t kSaveAOD = 8; // Bit switch 1 = Full AOD 2 = Jet AOD , 4 = PartCorr, 8 = JCORRAN |
c38e3b95 | 36 | //== general input and output variables |
9a5c5b1e | 37 | |
c38e3b95 | 38 | Int_t iAODanalysis = 1; // Analysis on input AOD's |
39 | Int_t iAODhandler = 1; // Analysis produces an AOD or dAOD's | |
f4132e7d | 40 | Int_t iCentralitySelection = 0; // Use the centrality |
c38e3b95 | 41 | Int_t iESDfilter = 0; // ESD to AOD filter (barrel + muon tracks) |
e84da0a5 | 42 | Int_t iPhysicsSelection = 1; // ESD to AOD filter (barrel + muon tracks) |
39e7e8ab | 43 | UInt_t iPhysicsSelectionFlag = 0; // set by pyshics selection and passed to the task, kMB, kUserDefined etc |
cfd02305 | 44 | Bool_t useTender = kFALSE; // use tender wagon |
c38e3b95 | 45 | Bool_t kUseKinefilter = kFALSE; // use Kinematics filter |
46 | Bool_t kUseMuonfilter = kFALSE; // use Kinematics filter | |
47 | TString kCommonOutputFileName = "PWG4_JetTasksOutput.root"; | |
9748e967 | 48 | TString kCaloQAOutputFileName = "PWG4_CaloQAOutput.root"; |
c38e3b95 | 49 | |
50 | ||
51 | //== general process variables | |
52 | ||
53 | // ### Other flags to steer the analysis | |
54 | //============================================================================== | |
9a5c5b1e | 55 | Bool_t kSkipTerminate = kTRUE; // Do not call Teminate |
c38e3b95 | 56 | Bool_t kUseDate = kFALSE; // use date in train name |
57 | Bool_t kUseDebug = kTRUE; // activate debugging | |
46534866 | 58 | Int_t kErrorIgnoreLevel = -1; // takes the errror print level from .rootrc |
59 | // From TError.h: | |
60 | // const Int_t kUnset = -1; | |
61 | // const Int_t kPrint = 0; | |
62 | // const Int_t kInfo = 1000; | |
63 | // const Int_t kWarning = 2000; | |
64 | // const Int_t kError = 3000; | |
65 | // const Int_t kBreak = 4000; | |
66 | // const Int_t kSysError = 5000; | |
67 | // const Int_t kFatal = 6000; | |
68 | Int_t kUseSysInfo = 0; // activate debugging | |
ebad39a9 | 69 | Long64_t kNumberOfEvents = 1234567890; // number of events to process from the chain |
c38e3b95 | 70 | Bool_t kUseMC = kTRUE; // use MC info |
71 | Bool_t kIsMC = kTRUE; // is MC info, if false it overwrites Use(AOD)MC | |
72 | Bool_t kUseAODMC = kTRUE; // use MC infA | |
73 | Bool_t kUseESDTags = kFALSE; // use ESD tags for selection | |
74 | Bool_t kUseTR = kFALSE; // use track references | |
75 | Bool_t kUseAODTags = kFALSE; // use AOD tags | |
76 | Bool_t kSaveTrain = kFALSE; // save train configuration as: | |
f4132e7d | 77 | Bool_t kIsPbPb = kFALSE; // Pb+Pb |
c38e3b95 | 78 | |
9a5c5b1e | 79 | |
c38e3b95 | 80 | // ### Analysis modules to be included. Some may not be yet fully implemented. |
81 | //============================================================================== | |
82 | Int_t iJETAN = 1; // Jet analysis (PWG4) // 1 write standard 2 write non-standard jets, 3 wrtie both | |
83 | Int_t iDIJETAN = 1; | |
e6993a52 | 84 | Int_t iJETANLib = 1; |
c38e3b95 | 85 | Int_t iPWG1QASym = 0; // Eva's QA task compiled on the fly... |
86 | Int_t iPWG4JetTasks = 0; // all jet tasks flag for lib laoding | |
87 | Int_t iPWG4JetServices = 0; // jet spectrum analysis | |
88 | Int_t iPWG4JetSpectrum = 0; // jet spectrum analysis | |
58ef946c | 89 | Int_t iPWG4JCORRAN = 0; // JCORRAN module |
c38e3b95 | 90 | Int_t iPWG4UE = 0; // Underlying Event analysis |
e0c120d9 | 91 | Int_t iPWG4LeadingUE = 0; // Underlying Event analysis |
92 | Int_t iPWG4CorrectionsUE = 0; // Underlying Event analysis | |
c166d299 | 93 | Int_t iPWG4TmpSourceSara = 0; // Underlying Event analysis not in svn |
aba42fcb | 94 | Int_t iPWG4Fragmentation = 0; // Official Fragmentation |
9f77f0ce | 95 | Int_t iPWG4JetChem = 0; // Jet chemistry |
c38e3b95 | 96 | Int_t iPWG4PtQAMC = 0; // Marta's QA tasks |
97 | Int_t iPWG4PtSpectra = 0; // Marta's QA tasks | |
98 | Int_t iPWG4PtQATPC = 0; // Marta's QA tasks | |
4721d8c5 | 99 | Int_t iPWG4Cosmics = 0; // Marta's Cosmics Taks |
c38e3b95 | 100 | Int_t iPWG4ThreeJets = 0; // Sona's thrust task |
cc636095 | 101 | Int_t iPWG4QGSep = 0; // Sona's QG Separation task |
102 | Int_t iPWG4Minijet = 0; // Eva's Mini Jet Task cluster task | |
b53f2e4f | 103 | Int_t iPWG4KMeans = 0; // Andreas' KMeans task |
d2e6cdd5 | 104 | Int_t iPWG4Cluster = 0; // CKB cluster task |
4721d8c5 | 105 | Int_t iEMCUtilLibs = 0; // Flag to satisfy dependence on EMC utils |
911a740f | 106 | Int_t iPWG4PartCorrLibs = 0; // Gustavo's part corr analysis |
c38e3b95 | 107 | Int_t iPWG4PartCorr = 0; // Gustavo's part corr analysis |
d2e6cdd5 | 108 | Int_t iPWG4CaloQA = 0; // Gustavo's part corr analysis |
109 | Int_t iPWG4JetCorr = 0; // Paul's jet corr analysis | |
911a740f | 110 | Int_t iPWG4Tagged = 0; // Gustavo's part corr analysis |
121e4bd5 | 111 | Int_t iPWG4omega3pi = 0; // Omega to 3 pi analysis (PWG4) |
17d96675 | 112 | Int_t iPWG4GammaConvLib = 0; // Gamma Conversio |
53c63663 | 113 | Int_t iPWG4GammaConv = 0; // Gamma Conversio |
17d96675 | 114 | Int_t iPWG4CaloConv = 0; // Gamma Conversio |
22e3ae6c | 115 | Int_t kHighPtFilterMask = 32; // change depending on the used AOD Filter |
e6993a52 | 116 | TString kDeltaAODJetName = "AliAOD.Jets.root"; |
4721d8c5 | 117 | TString kDeltaAODJCORRANName = "AliAOD.JCORRAN.root"; |
f4132e7d | 118 | TString kDeltaAODPartCorrName = "AliAOD.PartCorr.root"; |
c38e3b95 | 119 | |
120 | ||
121 | //============================================================================== | |
122 | // ### PROOF Steering varibales | |
123 | //============================================================================== | |
124 | //== proof setup variables | |
125 | TString kProofCluster = "alicecaf.cern.ch"; | |
126 | Bool_t kProofUseAFPAR = kFALSE; // use AF special par file | |
127 | TString kProofAFversion = "AF-v4-17"; | |
128 | //== proof input and output variables | |
129 | TString kProofDataSet = "/COMMON/COMMON/LHC09a4_run8100X#/esdTree"; | |
130 | Bool_t kProofSaveToAlien = kFALSE; // save proof outputs in AliEn train_[trainName]_ddMonthyyyy_time.C | |
131 | TString kProofOutdir = ""; | |
132 | Bool_t kProofClearPackages = kFALSE; | |
133 | Int_t kProofEvents = 10000; | |
134 | Int_t kProofOffset = 0; | |
135 | //== proof process variables | |
136 | ||
137 | ||
138 | //============================================================================== | |
139 | // ### Grid plugin Steering varibiables | |
140 | //============================================================================== | |
141 | //== grid plugin setup variables | |
142 | Bool_t kPluginUse = kTRUE; // do not change | |
143 | Bool_t kPluginUseProductionMode = kFALSE; // use the plugin in production mode | |
39e7e8ab | 144 | TString kPluginRootVersion = "v5-27-06b"; // *CHANGE ME IF MORE RECENT IN GRID* |
d3af0232 | 145 | TString kPluginAliRootVersion = "v4-19-15-AN"; // *CHANGE ME IF MORE RECENT IN GRID* |
9a5c5b1e | 146 | Bool_t kPluginMergeViaJDL = kTRUE; // merge via JDL |
147 | Bool_t kPluginFastReadOption = kFALSE; // use xrootd tweaks | |
148 | Bool_t kPluginOverwriteMode = kTRUE; // overwrite existing collections | |
dc6a7461 | 149 | Int_t kPluginOutputToRunNumber = 1; // write the output to subdirs named after run number |
c38e3b95 | 150 | // TString kPluginExecutableCommand = "root -b -q"; |
151 | TString kPluginExecutableCommand = "source /Users/kleinb/setup_32bit_aliroot_trunk_clean_root_trunk.sh; alienroot -b -q "; | |
9a5c5b1e | 152 | |
c38e3b95 | 153 | // == grid plugin input and output variables |
154 | TString kGridDatadir = "/alice/sim/PDC_08b/LHC09a1/AOD/"; | |
9748e967 | 155 | Int_t kGridMaxRunsFromList = 999999999; |
4d16db9c | 156 | Int_t kGridOffsetRunFromList = 0; // skip the first n runs from the list |
c38e3b95 | 157 | TString kGridLocalRunList = ""; |
158 | TString kGridOutdir = ""; // AliEn output directory. If blank will become output_<kTrainName> | |
3878a941 | 159 | TString kGridDataSet = ""; // sub working directory not to confuse different run xmls |
9748e967 | 160 | Int_t kGridRunRange[2] = {0, -1}; // Set the run range |
c38e3b95 | 161 | TString kGridRunPattern = "%03d"; // important for leading zeroes!! |
162 | TString kGridPassPattern = ""; | |
163 | TString kGridExtraFiles = ""; // files that will be added to the input list in the JDL... | |
9748e967 | 164 | Int_t kGridMaxMergeFiles = 12; // Number of files merged in a chunk grid run range |
c38e3b95 | 165 | TString kGridMergeExclude = "AliAOD.root"; // Files that should not be merged |
6408fe42 | 166 | TString kGridOutputStorages = "disk=2"; // Make replicas on the storages |
c38e3b95 | 167 | // == grid process variables |
c28abe00 | 168 | Int_t kGridRunsPerMaster = 100; // Number of runs per master job |
e84da0a5 | 169 | Int_t kGridFilesPerJob = 100; // Maximum number of files per job (gives size of AOD) |
c38e3b95 | 170 | |
171 | //============================================================================== | |
172 | // ### Local Steering variables | |
173 | //============================================================================== | |
174 | //== local setup variables | |
175 | //== local input and output variables | |
176 | TString kLocalXMLDataset = ""; // Change local xml dataset for local interactive analysis | |
177 | TString kLocalDataList = "local_deltaaod.txt"; // Change local xml dataset for local interactive analysis | |
178 | // == local process variables | |
179 | ||
8ecf60e0 | 180 | TString kPluginMode; |
c38e3b95 | 181 | |
182 | ||
183 | // Temporaries. | |
184 | TString anaPars = ""; | |
185 | TString anaLibs = ""; | |
e84da0a5 | 186 | TString anaLibsExtra = ""; |
c38e3b95 | 187 | TString anaSources = ""; |
188 | // Function signatures | |
189 | class AliAnalysisAlien; | |
190 | ||
191 | //______________________________________________________________________________ | |
192 | void AnalysisTrainPWG4Jets(const char *analysis_mode="local", | |
193 | const char *plugin_mode="", | |
4d16db9c | 194 | const char *config_file="",Int_t iOffset = 0,Int_t iTotal = 0) |
c38e3b95 | 195 | { |
196 | // Main analysis train macro. If a configuration file is provided, all parameters | |
197 | // are taken from there but may be altered by CheckModuleFlags. | |
3878a941 | 198 | |
8ecf60e0 | 199 | // these flag may be needed by the config file |
200 | kPluginMode = plugin_mode; | |
201 | ||
202 | if (strlen(config_file) && !LoadConfig(config_file)) return; | |
4d16db9c | 203 | if(iTotal>0)kGridMaxRunsFromList = iTotal; // overwrites the settings from config file |
204 | if(iOffset)kGridOffsetRunFromList = iOffset; | |
205 | if(iOffset)kProofOffset = iOffset; | |
206 | ||
3878a941 | 207 | |
c38e3b95 | 208 | TString smode(analysis_mode); |
209 | smode.ToUpper(); | |
210 | if (kSaveTrain)WriteConfig(); | |
8ecf60e0 | 211 | // Check compatibility of selected modules |
c38e3b95 | 212 | CheckModuleFlags(smode); |
ebad39a9 | 213 | // gROOT->ProcessLine(".trace"); |
c38e3b95 | 214 | |
215 | printf("==================================================================\n"); | |
216 | printf("=========== RUNNING ANALYSIS TRAIN %s IN %s MODE ==========\n", kTrainName.Data(),smode.Data()); | |
217 | printf("==================================================================\n"); | |
9748e967 | 218 | printf("= Configuring analysis train for: =\n"); |
c38e3b95 | 219 | if (iAODanalysis) printf("= AOD analysis =\n"); |
9748e967 | 220 | else printf("= ESD analysis =\n"); |
221 | if (iPhysicsSelection) printf("= Physics selection =\n"); | |
f4132e7d | 222 | if(iCentralitySelection)printf("= Centrality selection =\n"); |
cfd02305 | 223 | if (useTender) printf("= Using tender =\n"); |
c38e3b95 | 224 | if (iESDfilter) printf("= ESD filter =\n"); |
225 | if (iJETAN) printf("= Jet analysis =\n"); | |
226 | printf("==================================================================\n"); | |
9748e967 | 227 | |
228 | char *printMask = ":: %20s %10d\n"; | |
229 | printf(printMask,"Fill AOD",(UInt_t)kFillAOD); | |
230 | printf(printMask,"Save AOD", (UInt_t)kSaveAOD); | |
231 | printf(printMask,"MC truth", (UInt_t)kUseMC); | |
232 | printf(printMask,"KINE filter", (UInt_t)kUseKinefilter); | |
233 | printf(printMask,"track refs", (UInt_t)kUseTR); | |
234 | printf(printMask,"tags", (UInt_t)kUseESDTags); | |
235 | printf(printMask,"AOD tags", (UInt_t)kUseAODTags); | |
236 | printf(printMask,"debugging", (UInt_t)kUseDebug); | |
237 | printf(printMask,"PAR files", (UInt_t)kUsePAR); | |
238 | printf(printMask,"AliEn plugin", (UInt_t)kPluginUse); | |
239 | printf(printMask,"PWG1 QA sym", iPWG1QASym); | |
240 | printf(printMask,"PWG4 Source Sara",iPWG4TmpSourceSara); | |
aba42fcb | 241 | printf(printMask,"PWG4 Fragmentation",iPWG4Fragmentation); |
9748e967 | 242 | printf(printMask,"PWG4 Jet Chem",iPWG4JetChem); |
243 | printf(printMask,"PWG4 Jet tasks",iPWG4JetTasks); | |
244 | printf(printMask,"PWG4 Jet Services",iPWG4JetServices); | |
245 | printf(printMask,"PWG4 Jet Spectrum",iPWG4JetSpectrum); | |
246 | printf(printMask,"PWG4 JCORRAN",iPWG4JCORRAN); | |
247 | printf(printMask,"PWG4 UE",iPWG4UE); | |
e0c120d9 | 248 | printf(printMask,"PWG4 Leading UE",iPWG4LeadingUE); |
9748e967 | 249 | printf(printMask,"PWG4 Corrections UE",iPWG4CorrectionsUE); |
250 | printf(printMask,"PWG4 Pt QA MC",iPWG4PtQAMC); | |
251 | printf(printMask,"PWG4 Pt Spectra",iPWG4PtSpectra); | |
252 | printf(printMask,"PWG4 Pt QA TPC",iPWG4PtQATPC); | |
253 | printf(printMask,"PWG4 Cosmics",iPWG4Cosmics); | |
254 | printf(printMask,"PWG4 Three Jets",iPWG4ThreeJets); | |
cc636095 | 255 | printf(printMask,"PWG4 QGSep",iPWG4QGSep); |
256 | printf(printMask,"PWG4 Minijet",iPWG4Minijet); | |
9748e967 | 257 | printf(printMask,"PWG4 KMeans",iPWG4KMeans); |
258 | printf(printMask,"PWG4 Cluster",iPWG4Cluster); | |
259 | printf(printMask,"PWG4 Part Corr",iPWG4PartCorr); | |
260 | printf(printMask,"PWG4 Calo QA",iPWG4CaloQA); | |
261 | printf(printMask,"PWG4 Jet Corr",iPWG4JetCorr); | |
262 | printf(printMask,"PWG4 JCORRAN",iPWG4JCORRAN); | |
263 | printf(printMask,"PWG4 Tagged",iPWG4Tagged); | |
264 | printf(printMask,"PWG4 omega to 3 pi ",iPWG4omega3pi); | |
265 | printf(printMask,"PWG4 Gamma Conv",iPWG4GammaConv); | |
17d96675 | 266 | printf(printMask,"PWG4 Calo Conv",iPWG4CaloConv); |
9748e967 | 267 | printf(printMask,"HighPt FilterMask",kHighPtFilterMask); |
3878a941 | 268 | |
c38e3b95 | 269 | //========================================================================== |
270 | // Connect to back-end system | |
271 | if (!Connect(smode)) { | |
272 | ::Error("AnalysisTrain", "Could not connect to %s back-end", analysis_mode); | |
273 | return; | |
274 | } | |
275 | ||
276 | // Load common libraries and set include path | |
277 | if (!LoadCommonLibraries(smode)) { | |
278 | ::Error("AnalysisTrain", "Could not load common libraries"); | |
279 | return; | |
280 | } | |
3878a941 | 281 | |
282 | ||
c38e3b95 | 283 | |
284 | // Make the analysis manager and connect event handlers | |
e84da0a5 | 285 | AliAnalysisManager *mgr = new AliAnalysisManager("PWG4Train", "pwg4 mini train"); |
c38e3b95 | 286 | if (kCommonOutputFileName.Length()>0)mgr->SetCommonFileName(kCommonOutputFileName.Data()); |
287 | if (kProofSaveToAlien) mgr->SetSpecialOutputLocation(kProofOutdir); | |
4a6f59cb | 288 | mgr->SetNSysInfo(0); |
c38e3b95 | 289 | if (!strcmp(plugin_mode, "test")) mgr->SetNSysInfo(1); |
53c63663 | 290 | if (kUseSysInfo)mgr->SetNSysInfo(kUseSysInfo); |
9a5c5b1e | 291 | mgr->SetSkipTerminate(kSkipTerminate); |
4a6f59cb | 292 | |
c38e3b95 | 293 | // Load analysis specific libraries |
294 | if (!LoadAnalysisLibraries(smode)) { | |
295 | ::Error("AnalysisTrain", "Could not load analysis libraries"); | |
296 | return; | |
297 | } | |
298 | ||
299 | // Create input handler (input container created automatically) | |
300 | if (iAODanalysis) { | |
301 | // AOD input handler | |
302 | AliAODInputHandler *aodH = new AliAODInputHandler(); | |
303 | mgr->SetInputEventHandler(aodH); | |
e6993a52 | 304 | if (iPWG4JetTasks) aodH->AddFriend(Form("deltas/%s",kDeltaAODJetName.Data())); |
305 | if (iPWG4PartCorr) aodH->AddFriend(Form("deltas/%s"kDeltaAODJetName.Data())); | |
c38e3b95 | 306 | } else { |
307 | // ESD input handler | |
308 | AliESDInputHandler *esdHandler = new AliESDInputHandler(); | |
309 | if (kUseESDTags) esdHandler->SetReadTags(); | |
c166d299 | 310 | esdHandler->SetReadFriends(kFALSE); |
c38e3b95 | 311 | mgr->SetInputEventHandler(esdHandler); |
4a6f59cb | 312 | // if(iPWG4PtQATPC&& !kTrainName.Contains("pass5"))esdHandler->SetActiveBranches("ESDfriend"); |
c166d299 | 313 | |
c38e3b95 | 314 | } |
f4d11ac8 | 315 | |
c38e3b95 | 316 | // Monte Carlo handler |
317 | if (kUseMC && !iAODanalysis) { | |
318 | AliMCEventHandler* mcHandler = new AliMCEventHandler(); | |
319 | mgr->SetMCtruthEventHandler(mcHandler); | |
320 | mcHandler->SetReadTR(kUseTR); | |
321 | } | |
322 | // AOD output container, created automatically when setting an AOD handler | |
323 | if (iAODhandler) { | |
324 | // AOD output handler | |
325 | AliAODHandler* aodHandler = new AliAODHandler(); | |
326 | aodHandler->SetOutputFileName("AliAOD.root"); | |
6408fe42 | 327 | aodHandler->SetFillAODforRun(kFillAOD); |
121e4bd5 | 328 | // |
f4132e7d | 329 | mgr->SetOutputEventHandler(aodHandler); |
c38e3b95 | 330 | AliAnalysisDataContainer * cout_aod = mgr->GetCommonOutputContainer(); |
331 | cout_aod->SetSpecialOutput(); | |
332 | } | |
333 | // Debugging if needed | |
b03b08a3 | 334 | |
3878a941 | 335 | if (kUseDebug){ |
336 | mgr->SetDebugLevel(3); | |
337 | } | |
4721d8c5 | 338 | if(kUseSysInfo>0){ |
339 | mgr->RegisterExtraFile("syswatch.root"); | |
340 | if(kGridMergeExclude.Length())kGridMergeExclude += " "; | |
341 | kGridMergeExclude += "syswatch.root"; | |
342 | } | |
b03b08a3 | 343 | else{ |
344 | AliLog::SetGlobalLogLevel(AliLog::kError); | |
345 | } | |
46534866 | 346 | |
347 | ||
c38e3b95 | 348 | //========================================================================== |
349 | // Create the chain. In this example it is created only from ALIEN files but | |
350 | // can be done to work in batch or grid mode as well. | |
351 | TChain *chain = CreateChain(smode, plugin_mode); | |
352 | ||
353 | //========================================================================== | |
354 | // Load the tasks configuration macros for all wagons. These files are supposed now to be | |
355 | // in the current workdir, but in AliEn they will be in the file catalog, | |
356 | // mapped from AliRoot and pecified in the jdl input list. | |
357 | ||
358 | // For now connection to top input container and common AOD output container | |
359 | // is done in this macro, but in future these containers will be connected | |
360 | // from each task configuration macro. | |
cfd02305 | 361 | |
362 | // | |
363 | // Tender and supplies. Needs to be called for every event. | |
364 | // | |
365 | if (useTender) { | |
366 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/TenderSupplies/AddTaskTender.C"); | |
367 | AliAnalysisTaskSE *tender = AddTaskTender(kTRUE); | |
368 | // tender->SelectCollisionCandidates(); | |
369 | tender->SetDebugLevel(2); | |
370 | } | |
371 | ||
372 | ||
373 | ||
e84da0a5 | 374 | if(iPhysicsSelection && !iAODanalysis){ |
d2e6cdd5 | 375 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); |
39e7e8ab | 376 | Int_t iTriggerHIC = 0; |
377 | Bool_t rejectBkg = true; | |
f4132e7d | 378 | if(kIsPbPb){ |
39e7e8ab | 379 | iTriggerHIC = 2; |
380 | rejectBkg = false; // for the moment... | |
381 | } | |
382 | AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kIsMC,rejectBkg); | |
383 | iPhysicsSelectionFlag = AliVEvent::kMB; | |
e84da0a5 | 384 | } |
385 | ||
f4132e7d | 386 | if(iCentralitySelection){ |
387 | ||
388 | // has to run before AOD filter | |
389 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCentralitySelection.C"); | |
390 | const char* file1="$ALICE_ROOT/ANALYSIS/macros/AliCentralityBy1D_137161_v4.root"; | |
391 | const char* file2="$ALICE_ROOT/ANALYSIS/macros/AliCentralityBy1D_137161_v4.root"; | |
392 | AliCentralitySelectionTask *taskC = AddTaskCentralitySelection(file1,file2); | |
393 | if (!taskC) ::Warning("AnalysisTrainPWG4Jets", "AliCentralitySelectionTask cannot run for this train conditions - EXCLUDED"); | |
394 | } | |
395 | ||
c38e3b95 | 396 | if (iESDfilter && !iAODanalysis) { |
397 | // ESD filter task configuration. | |
ebad39a9 | 398 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskESDFilterPWG4Train.C"); |
c38e3b95 | 399 | AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(kUseKinefilter,kUseMuonfilter); |
17d96675 | 400 | taskesdfilter->SetEnableFillAOD(kFALSE); |
f4132e7d | 401 | |
4721d8c5 | 402 | if(kIsMC){ |
403 | mgr->RegisterExtraFile("pyxsec_hists.root"); | |
404 | if(kGridMergeExclude.Length())kGridMergeExclude += " "; | |
405 | kGridMergeExclude += "pyxsec_hists.root"; | |
406 | ||
407 | } | |
c38e3b95 | 408 | } |
409 | ||
410 | // AOD tags | |
411 | if (kUseAODTags) { | |
412 | AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator"); | |
413 | mgr->AddTask(tagTask); | |
414 | AliAnalysisDataContainer *coutTags = mgr->CreateContainer("cTag", TTree::Class(), | |
415 | AliAnalysisManager::kOutputContainer, "AOD.tag.root"); | |
416 | mgr->ConnectInput (tagTask, 0, mgr->GetCommonInputContainer()); | |
417 | mgr->ConnectOutput(tagTask, 1, coutTags); | |
418 | } | |
419 | ||
420 | // Jet analysis | |
421 | if (iJETAN) { | |
422 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJets.C"); | |
423 | AliAnalysisTaskJets *taskjets = 0; | |
424 | if(iJETAN&1)taskjets = AddTaskJets(kHighPtFilterMask); | |
b53f2e4f | 425 | if(iJETAN&2){ |
426 | UInt_t selection = 0; | |
17d96675 | 427 | if(!kFillAOD){ |
428 | selection = 0xffffff&~(1<<13)&~(1<<5)&~(1<<6); // switch OFF DA and all R = 0.7 to save processing time | |
429 | selection &= ~(1<<1)&~(1<<2)&~(1<<4)&~(1<<6)&~(1<<8)&~(1<<10)&~(1<<12); | |
430 | } | |
431 | else { | |
432 | selection = 0xffffff&~(1<<13)&~(1<<5)&~(1<<6); // switch OFF DA and all R = 0.7 to save processing time; | |
433 | selection &= ~(1<<1)&~(1<<2)&~(1<<4)&~(1<<6)&~(1<<8)&~(1<<10)&~(1<<12); | |
434 | } | |
b53f2e4f | 435 | AddTaskJetsDelta(kDeltaAODJetName.Data(),kHighPtFilterMask,kUseAODMC,selection); |
e0c120d9 | 436 | AddTaskJets("AOD","FASTKT",0.2,kHighPtFilterMask); |
b53f2e4f | 437 | } |
c38e3b95 | 438 | if (!taskjets) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED"); |
f4132e7d | 439 | if(kDeltaAODJetName.Length()>0)mgr->RegisterExtraFile(kDeltaAODJetName.Data()); |
c38e3b95 | 440 | } |
441 | ||
bd80a748 | 442 | if(iPWG4Cluster){ |
443 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetCluster.C"); | |
444 | AliAnalysisTaskJetCluster *taskCl = 0; | |
445 | if(iPWG4Cluster&1){ | |
f4132e7d | 446 | |
447 | if(kIsPbPb){ | |
448 | taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.2,0,1, kDeltaAODJetName.Data()); // this one is for the background random jets | |
449 | taskCl->SetBackgroundCalc(kTRUE); | |
450 | taskCl->SetGhostEtamax(0.9); | |
451 | taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.4,0,1, kDeltaAODJetName.Data()); // this one is for the background random jets | |
452 | taskCl->SetBackgroundCalc(kTRUE); | |
453 | taskCl->SetGhostEtamax(0.9); | |
454 | } | |
455 | else{ | |
456 | taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.6,0,1,kDeltaAODJetName.Data()); // this one is for the background jets | |
457 | taskCl->SetBackgroundCalc(kTRUE); | |
458 | } | |
459 | ||
460 | taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelectionFlag,"ANTIKT",0.2,0,1,kDeltaAODJetName.Data()); | |
461 | taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelectionFlag,"ANTIKT",0.4,0,1,kDeltaAODJetName.Data()); | |
d4e8abc5 | 462 | |
463 | if(kUseAODMC){ | |
f4132e7d | 464 | taskCl = AddTaskJetCluster("AODMC","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.6,0,1,kDeltaAODJetName.Data()); // this one is for the background jets |
465 | taskCl = AddTaskJetCluster("AODMC2","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.6,0,1,kDeltaAODJetName.Data()); // this one is for the background jets | |
466 | taskCl = AddTaskJetCluster("AODMC","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.4,0,1,kDeltaAODJetName.Data()); // this one is for the background random jets | |
467 | taskCl = AddTaskJetCluster("AODMC2","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.4,0,1,kDeltaAODJetName.Data()); // this one is for the background random jets | |
d4e8abc5 | 468 | } |
8ecf60e0 | 469 | |
bd80a748 | 470 | if (!taskCl) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskCluster cannot run for this train conditions - EXCLUDED"); |
471 | } | |
472 | if(iPWG4Cluster&2){ | |
473 | UInt_t selection = 0; | |
474 | if(!iAODanalysis) selection = 0xffffff; | |
475 | else selection = 1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<7|1<<8|1<<9; | |
f4132e7d | 476 | if(kIsPbPb){ |
477 | selection&=~(1<<2); // exluded R = .04 already the dafault | |
478 | selection&=~(1<<4); // exluded R = .04 already the dafault | |
479 | } | |
480 | else{ | |
481 | selection&=~(1<<6); // exluded R = .04 already the dafault | |
482 | } | |
39e7e8ab | 483 | AddTaskJetClusterDelta(kHighPtFilterMask,kUseAODMC,iPhysicsSelectionFlag,"KT",selection); |
bd80a748 | 484 | } |
485 | if(iPWG4Cluster&4){ | |
486 | UInt_t selection = 0; | |
487 | if(!iAODanalysis){ | |
488 | selection = 0xffffff; | |
489 | selection &= ~(1<<1)&~(1<<3)&~(1<<5)&~(1<<7)&~(1<<9); | |
490 | } | |
491 | else selection = 1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<7|1<<8|1<<9; | |
f4132e7d | 492 | selection&=~(1<<2); // exluded R = .04 already the dafault |
d4e8abc5 | 493 | selection&=~(1<<4); // exluded R = .04 already the dafault |
39e7e8ab | 494 | AddTaskJetClusterDelta(kHighPtFilterMask,kUseAODMC,iPhysicsSelectionFlag,"ANTIKT",selection); |
8ecf60e0 | 495 | // AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelection,"ANTIKT",0.4,0,1); |
bd80a748 | 496 | |
497 | } | |
498 | } | |
499 | ||
c38e3b95 | 500 | if (iDIJETAN) { |
501 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskDiJets.C"); | |
502 | AliAnalysisTaskDiJets *taskdijets = 0; | |
82ebd295 | 503 | if(iDIJETAN&1)taskdijets = AddTaskDiJets(); |
c38e3b95 | 504 | if (!taskdijets) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED"); |
82ebd295 | 505 | if(iDIJETAN&2){ |
506 | taskdijets = AddTaskDiJets("jetsAOD_CDF07"); | |
507 | taskdijets = AddTaskDiJets("jetsAOD_DA07"); | |
508 | taskdijets = AddTaskDiJets("jetsAOD_FASTJET07"); | |
509 | taskdijets = AddTaskDiJets("jetsAOD_FASTKT07"); | |
510 | taskdijets = AddTaskDiJets("jetsAOD_SISCONE07"); | |
511 | taskdijets = AddTaskDiJets("jetsAOD_UA107"); | |
512 | } | |
c38e3b95 | 513 | } |
514 | ||
c38e3b95 | 515 | if(iPWG1QASym){ |
5dbdc61f | 516 | gROOT->LoadMacro("$ALICE_ROOT/PWG1/PilotTrain/AddTaskQAsym.C"); |
c38e3b95 | 517 | AliAnalysisTaskQASym *taskQASym = AddTaskQAsym(-1); |
518 | if (!taskQASym) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQASym cannot run for this train conditions - EXCLUDED"); | |
121e4bd5 | 519 | } |
c38e3b95 | 520 | |
121e4bd5 | 521 | |
522 | ||
523 | if(iPWG4TmpSourceSara){ | |
524 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskEta.C"); | |
525 | AliAnalysisTaskEta *taskEta = AddTaskEta(); | |
526 | if (!taskEta) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskEta cannot run for this train conditions - EXCLUDED"); | |
c38e3b95 | 527 | } |
528 | ||
aba42fcb | 529 | if(iPWG4Fragmentation){ |
530 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskFragmentationFunction.C"); | |
8be7acf2 | 531 | AliAnalysisTaskFragmentationFunction *taskFrag = 0; |
532 | if(kUseAODMC){ | |
533 | taskFrag = AddTaskFragmentationFunction(1<<1,kHighPtFilterMask); | |
534 | taskFrag = AddTaskFragmentationFunction(1<<2,kHighPtFilterMask); | |
5fde4a38 | 535 | // taskFrag = AddTaskFragmentationFunction(1<<3,kHighPtFilterMask); |
cfd02305 | 536 | taskFrag = AddTaskFragmentationFunction(1<<5,kHighPtFilterMask); |
537 | taskFrag = AddTaskFragmentationFunction(1<<11); // w/o acceptance cuts | |
c2658535 | 538 | taskFrag = AddTaskFragmentationFunction(1<<12); // with acceptance cuts |
539 | // anti-kt | |
540 | taskFrag = AddTaskFragmentationFunction(1<<21); // w/o acceptance cuts | |
541 | taskFrag = AddTaskFragmentationFunction(1<<22); // with acceptance cuts | |
542 | ||
8be7acf2 | 543 | } |
544 | else{ | |
545 | taskFrag = AddTaskFragmentationFunction(1<<0,kHighPtFilterMask); | |
c2658535 | 546 | taskFrag = AddTaskFragmentationFunction(1<<10,kHighPtFilterMask); |
547 | taskFrag = AddTaskFragmentationFunction(1<<20,kHighPtFilterMask); | |
8be7acf2 | 548 | } |
549 | ||
aba42fcb | 550 | if (!taskFrag) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskFragmentationFunction cannot run for this train conditions - EXCLUDED"); |
c166d299 | 551 | } |
552 | ||
c580ebbb | 553 | |
9f77f0ce | 554 | if(iPWG4JetChem){ |
555 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetChem.C"); | |
f4132e7d | 556 | AliAnalysisTask *taskChem = AddTaskJetChem(kHighPtFilterMask); |
c580ebbb | 557 | if (!taskChem) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetChem cannot run for this train conditions - EXCLUDED"); |
558 | } | |
559 | ||
560 | ||
c38e3b95 | 561 | if(iPWG4JetServices){ |
562 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetServices.C"); | |
563 | AliAnalysisTaskJetServices *taskjetServ = 0; | |
564 | taskjetServ = AddTaskJetServices(); | |
565 | if (!taskjetServ) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetServices cannot run for this train conditions - EXCLUDED"); | |
53c63663 | 566 | if(kGridRunRange[0]>0)taskjetServ->SetRunRange(kGridRunRange[0],kGridRunRange[1]); |
27cdf9c4 | 567 | else taskjetServ->SetRunRange(110000,160000); |
568 | taskjetServ->SetMCData(kIsMC); | |
dc6a7461 | 569 | taskjetServ->SetUsePhysicsSelection((Bool_t)iPhysicsSelection); |
39e7e8ab | 570 | taskjetServ->SetPhysicsSelectionFlag(iPhysicsSelectionFlag); // |
9f77f0ce | 571 | taskjetServ->SetDebugLevel(0); |
f4132e7d | 572 | taskjetServ->SetNonStdFile(kDeltaAODJetName.Data()); |
573 | if(kIsPbPb){ | |
574 | taskjetServ->SetFilterAODCollisions(kTRUE); | |
575 | } | |
c38e3b95 | 576 | } |
577 | ||
c38e3b95 | 578 | if(iPWG4JetSpectrum){ |
579 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetSpectrum2.C"); | |
580 | AliAnalysisTaskJetSpectrum2 *taskjetSpectrum = 0; | |
17d96675 | 581 | |
f4132e7d | 582 | TString cBack; |
583 | if(kIsPbPb){ | |
584 | cBack = "jeteventbackground_clustersAOD_KT04"; | |
585 | } | |
586 | else{ | |
587 | cBack = "jeteventbackground_clustersAOD_KT06"; | |
588 | } | |
589 | ||
6bd3fdae | 590 | if(iPWG4JetSpectrum&1){ |
f4132e7d | 591 | // add the dfault jet finders with R = 0.4 |
592 | UInt_t iSelection = 0xfffff; | |
593 | taskJetSpectrum = AddTaskJetSpectrum2Delta(kHighPtFilterMask,kUseAODMC,iPhysicsSelectionFlag,iSelection,0,kTRUE,cBack.Data()); // bug fixed 10.11.10 | |
b53f2e4f | 594 | } |
e6993a52 | 595 | if(iPWG4JetSpectrum&2){ |
6bd3fdae | 596 | if(kIsMC){ |
597 | UInt_t eventSelection = AliAnalysisHelperJetTasks::kIsPileUp|AliAnalysisHelperJetTasks::kVertexIn; | |
598 | if(iPhysicsSelection)eventSelection |= AliAnalysisHelperJetTasks::kPhysicsSelection; | |
39e7e8ab | 599 | taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC_FASTJET04","",kHighPtFilterMask,iPhysicsSelectionFlag,eventSelection); |
600 | taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC2_FASTJET04","",kHighPtFilterMask,iPhysicsSelectionFlag,eventSelection); | |
6bd3fdae | 601 | |
602 | eventSelection = AliAnalysisHelperJetTasks::kIsCosmic|AliAnalysisHelperJetTasks::kVertexIn; | |
603 | if(iPhysicsSelection)eventSelection |= AliAnalysisHelperJetTasks::kPhysicsSelection; | |
39e7e8ab | 604 | taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC_FASTJET04","",kHighPtFilterMask,iPhysicsSelectionFlag,eventSelection); |
6bd3fdae | 605 | |
606 | eventSelection = AliAnalysisHelperJetTasks::kNone; | |
39e7e8ab | 607 | taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC2_FASTJET04","",kHighPtFilterMask,iPhysicsSelectionFlag,eventSelection); |
608 | taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC_FASTJET04","",kHighPtFilterMask,iPhysicsSelectionFlag,eventSelection); | |
f4132e7d | 609 | taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC_FASTJET04","",kHighPtFilterMask,iPhysicsSelectionFlag,eventSelection); |
17d96675 | 610 | } |
6bd3fdae | 611 | else{ |
612 | UInt_t eventSelection = AliAnalysisHelperJetTasks::kIsPileUp|AliAnalysisHelperJetTasks::kVertexIn; | |
613 | if(iPhysicsSelection)eventSelection |= AliAnalysisHelperJetTasks::kPhysicsSelection; | |
39e7e8ab | 614 | taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","","",kHighPtFilterMask,iPhysicsSelectionFlag,eventSelection); |
6bd3fdae | 615 | eventSelection = AliAnalysisHelperJetTasks::kIsCosmic|AliAnalysisHelperJetTasks::kVertexIn; |
616 | if(iPhysicsSelection)eventSelection |= AliAnalysisHelperJetTasks::kPhysicsSelection; | |
39e7e8ab | 617 | taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","","",kHighPtFilterMask,iPhysicsSelectionFlag,eventSelection); |
6bd3fdae | 618 | } |
619 | } | |
39e7e8ab | 620 | if(iPWG4JetSpectrum&4){ |
f4132e7d | 621 | // central events backgrounds... just for testing... |
622 | if(kIsPbPb){ | |
623 | taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","",cBack.Data(),kHighPtFilterMask,iPhysicsSelectionFlag,0,kTRUE,1,1); | |
624 | taskjetSpectrum->SetDebugLevel(10); | |
625 | } | |
e6993a52 | 626 | } |
6bd3fdae | 627 | if (!taskjetSpectrum) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetSpectrum2 cannot run for this train conditions - EXCLUDED"); |
f4132e7d | 628 | |
c38e3b95 | 629 | } |
6bd3fdae | 630 | |
631 | ||
58ef946c | 632 | if(iPWG4JCORRAN){ |
633 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJCORRANTask.C"); | |
4721d8c5 | 634 | AliJCORRANTask* corran = AddTaskJCORRAN(kDeltaAODJCORRANName.Data(),0); |
58ef946c | 635 | if(!corran)::Warning("AnalysisTrainPWG4Jets", "AliJCORRANTask cannot run for this train conditions - EXCLUDED"); |
4721d8c5 | 636 | else{ |
637 | if(kDeltaAODJCORRANName.Length()>0)mgr->RegisterExtraFile(kDeltaAODJCORRANName.Data()); | |
638 | } | |
58ef946c | 639 | } |
640 | ||
c38e3b95 | 641 | if(iPWG4UE){ |
642 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskUE.C"); | |
643 | AliAnalysisTaskUE *taskUE = 0; | |
644 | if(iPWG4UE&1)taskUE = AddTaskUE(); | |
645 | if(iPWG4UE&2){ | |
94ee88d4 | 646 | taskUE =AddTaskUE("jetsAOD_CDF04","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train |
17d96675 | 647 | // taskUE =AddTaskUE("jetsAOD_CDF07","CDF", "LJ", "TRANSV","MSP"); |
94ee88d4 | 648 | taskUE =AddTaskUE("jetsAOD_SISCONE04","CDF", "LJ", "TRANSV","MSP"); |
17d96675 | 649 | // taskUE =AddTaskUE("jetsAOD_SISCONE07","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train |
94ee88d4 | 650 | taskUE =AddTaskUE("jetsAOD_ICDF","CDF","LJ","TRANSV","MSP"); |
651 | taskUE =AddTaskUE("jetsAOD_FASTKT04","CDF", "LJ", "TRANSV","MSP"); | |
17d96675 | 652 | // taskUE =AddTaskUE("jetsAOD_FASTKT07","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train |
58ef946c | 653 | taskUE =AddTaskUE("jetsAOD_NONE","CDF", "MP_eta05", "TRANSV","MSP"); |
654 | taskUE =AddTaskUE("jetsAOD_NONE","CDF", "MP_eta09", "TRANSV","MSP"); | |
c38e3b95 | 655 | } |
2bb1f4ca | 656 | |
c38e3b95 | 657 | if (!taskUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskUE cannot run for this train conditions - EXCLUDED"); |
658 | } | |
e0c120d9 | 659 | |
660 | if(iPWG4LeadingUE){ | |
661 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskLeadingTrackUE.C"); | |
662 | AliAnalysisTaskLeadingTrackUE *taskLeadingUE = AddTaskLeadingTrackUE(kUseMC); | |
663 | if (!taskLeadingUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTasLeadingTrackkUE cannot run for this train conditions - EXCLUDED"); | |
27cdf9c4 | 664 | // taskLeadingUE->SetFilterBit(64); |
e0c120d9 | 665 | } |
666 | ||
667 | ||
9748e967 | 668 | if(iPWG4CorrectionsUE){ |
669 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCorrectionsUE.C"); | |
670 | AliAnalysisTaskCorrectionsUE *taskCorrectionsUE = 0; | |
671 | if(iPWG4CorrectionsUE&1)taskCorrectionsUE = AddTaskCorrectionsUE("jetsAOD_NONE","CDF","MP_eta05","TRANSV","MSP",kFALSE); | |
672 | if (!taskCorrectionsUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskCorrectionsUE cannot run for this train conditions - EXCLUDED"); | |
673 | } | |
c38e3b95 | 674 | |
675 | if(iPWG4ThreeJets){ | |
676 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskThreeJets.C"); | |
677 | AliAnalysisTaskThreeJets *taskThree = AddTaskThreeJets(); | |
678 | if(!taskThree)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskThreets cannot run for this train conditions - EXCLUDED"); | |
679 | } | |
cc636095 | 680 | if(iPWG4QGSep){ |
681 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskQGSep.C"); | |
682 | AliAnalysisTaskQGSep *taskQGSep = AddTaskQGSep(kUseMC,iAODanalysis); | |
683 | if(!taskQGSep)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQGSep cannot run for this train conditions - EXCLUDED"); | |
684 | } | |
685 | ||
686 | ||
687 | if(iPWG4Minijet){ | |
688 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskMinijet.C"); | |
4d16db9c | 689 | AliAnalysisTaskMinijet *taskMini = AddTaskMinijet(-1,"esd",kUseMC,kGridDataSet); |
cc636095 | 690 | // if we ha highmult trigger add another task |
691 | if(!taskMini)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskMinjet cannot run for this train conditions - EXCLUDED"); | |
692 | } | |
693 | ||
694 | ||
c38e3b95 | 695 | if(iPWG4PtQAMC){ |
696 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQAMC.C"); | |
f87effcf | 697 | AliPWG4HighPtQAMC *taskQAMC = 0; |
698 | if(kUseMC){ | |
699 | if(iPWG4PtQAMC&1)taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data(),0); | |
700 | if(iPWG4PtQAMC&1)taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data(),1); | |
701 | } | |
c38e3b95 | 702 | if (!taskQAMC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQAMC cannot run for this train conditions - EXCLUDED"); |
703 | } | |
704 | ||
705 | if(iPWG4PtQATPC){ | |
706 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQATPConly.C"); | |
10295ac3 | 707 | AliPWG4HighPtQATPConly *taskQATPC = 0; |
b1cd0099 | 708 | if(iPWG4PtQATPC&1)taskQATPC = AddTaskPWG4HighPtQATPConly(kGridDataSet.Data(),1); |
709 | if(iPWG4PtQATPC&2)taskQATPC = AddTaskPWG4HighPtQATPConly(kGridDataSet.Data(),2); | |
10295ac3 | 710 | |
711 | if (!taskQATPC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQATPC cannot run for this train conditions - EXCLUDED"); | |
c38e3b95 | 712 | } |
3878a941 | 713 | |
1f329128 | 714 | if(iPWG4Cosmics){ |
715 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4CosmicCandidates.C"); | |
716 | ||
717 | AliPWG4CosmicCandidates *taskPWG4CosmicCandidates = AddTaskPWG4CosmicCandidates(0); | |
718 | taskPWG4CosmicCandidates = AddTaskPWG4CosmicCandidates(1); | |
719 | ||
720 | if (!taskPWG4CosmicCandidates) ::Warning("AnalysisTrainPWG4Jets", "AddTaskPWG4CosmicCandidates cannot run for this train conditions - EXCLUDED"); | |
721 | } | |
722 | ||
723 | ||
c38e3b95 | 724 | if(iPWG4PtSpectra){ |
725 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtSpectra.C"); | |
b1cd0099 | 726 | AliPWG4HighPtSpectra *taskPtSpectra = AddTaskPWG4HighPtSpectra(kGridDataSet.Data()); |
c38e3b95 | 727 | if (!taskPtSpectra) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskPtSpectra cannot run for this train conditions - EXCLUDED"); |
728 | } | |
b53f2e4f | 729 | if(iPWG4KMeans){ |
730 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskKMeans.C"); | |
731 | AliAnalysisTaskKMeans *taskKMeans = AddTaskKMeans(); | |
732 | if (!taskKMeans) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskKMenans cannot run for this train conditions - EXCLUDED"); | |
733 | } | |
734 | ||
c38e3b95 | 735 | if(iPWG4PartCorr){ |
736 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C"); | |
14526afb | 737 | AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS",kFALSE,kIsMC); |
c38e3b95 | 738 | if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED"); |
14526afb | 739 | AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL",kFALSE,kIsMC); |
c38e3b95 | 740 | if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED"); |
4721d8c5 | 741 | if(kDeltaAODPartCorrName.Length()>0)mgr->RegisterExtraFile(kDeltaAODPartCorrName.Data()); |
121e4bd5 | 742 | } |
743 | ||
d2e6cdd5 | 744 | if(iPWG4CaloQA){ |
745 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/QA/AddTaskCalorimeterQA.C"); | |
9748e967 | 746 | AliAnalysisTaskParticleCorrelation *taskcaloQA = AddTaskCalorimeterQA("ESD",kFALSE,kIsMC,kCaloQAOutputFileName.Data()); |
d2e6cdd5 | 747 | if(!taskcaloQA)::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation QA cannot run - EXCLUDED"); |
aba42fcb | 748 | // if(kCaloQAOutputFileName.Length()>0)mgr->RegisterExtraFile(kCaloQAOutputFileName.Data()); |
d2e6cdd5 | 749 | } |
750 | ||
d2e6cdd5 | 751 | if(iPWG4JetCorr){ |
752 | // using namespace JetCorrelHD; | |
d3af0232 | 753 | TString cdir = gSystem->WorkingDirectory(); |
754 | gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/")); | |
d2e6cdd5 | 755 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetCorrel.C"); |
756 | AliAnalysisTaskJetCorrel *taskjetcorr = AddTaskJetCorrel(); | |
d3af0232 | 757 | gSystem->ChangeDirectory(cdir); |
c166d299 | 758 | if (!taskjetcorr) ::Warning("AnalysisTrainNew", "AliAnalysisTaskJetCorrel cannot run for this train conditions - EXCLUDED"); |
d2e6cdd5 | 759 | } |
760 | ||
911a740f | 761 | if(iPWG4Tagged){ |
762 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskTaggedPhotons.C"); | |
763 | AliAnalysisTaskTaggedPhotons * taskTagged = AddTaskTaggedPhotons(kFALSE); // EMCAL | |
58ef946c | 764 | taskTagged = AddTaskTaggedPhotons(kTRUE); // PHOS |
911a740f | 765 | if (!taskTagged) ::Warning("AnalysisTrainNew", "AliAnalysisTaskTaggedPhotons cannot run for this train conditions - EXCLUDED"); |
766 | } | |
121e4bd5 | 767 | if (iPWG4omega3pi) { |
768 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskomega3pi.C"); | |
769 | AliAnalysisTaskOmegaPi0PiPi *taskomega3pi = AddTaskomega3pi(); | |
770 | if (!taskomega3pi) ::Warning("AnalysisTrainNew", "AliAnalysisTaskomega3pi cannot run\ | |
771 | for these train conditions - EXCLUDED"); | |
772 | } | |
773 | ||
53c63663 | 774 | // PWG4 gamma conversion analysis |
775 | if (iPWG4GammaConv) { | |
776 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskGammaConversion.C"); | |
777 | TString cdir = gSystem->WorkingDirectory(); | |
778 | gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/")); | |
779 | // TString gcArguments = "-run-on-train -run-jet -run-chic -run-neutralmeson -run-cf"; | |
58ef946c | 780 | // TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz"; |
781 | // TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz"; | |
b0a36f28 | 782 | TString gcArguments = "-run-on-train -run-jet -run-omega-meson -use-own-xyz -run-neutralmeson -no-aod"; |
27cdf9c4 | 783 | // TString kGCAnalysisCutSelectionId="9003562000100310"; |
cfd02305 | 784 | // TString kGCAnalysisCutSelectionId="9003562000100312"; |
785 | // gcArguments.Append(Form(" -set-cut-selection %s ",kGCAnalysisCutSelectionId.Data())); | |
53c63663 | 786 | if(!kIsMC)gcArguments += " -mc-off"; |
787 | AliAnalysisTaskGammaConversion * taskGammaConversion = AddTaskGammaConversion(gcArguments,mgr->GetCommonInputContainer()); | |
788 | gSystem->ChangeDirectory(cdir); | |
121e4bd5 | 789 | taskGammaConversion->SelectCollisionCandidates(); |
53c63663 | 790 | if (!taskGammaConversion) ::Warning("AnalysisTrainNew", "AliAnalysisTaskGammaConversion cannot run for these train conditions - EXCLUDED"); |
791 | } | |
792 | ||
17d96675 | 793 | if (iPWG4CaloConv) { |
794 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCaloConv.C"); | |
795 | AliAnalysisTaskCaloConv * taskCaloConv = AddTaskCaloConv(); | |
796 | if (!taskCaloConv) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCaloConv cannot run for these train conditions - EXCLUDED"); | |
797 | } | |
798 | ||
799 | ||
3878a941 | 800 | |
c38e3b95 | 801 | //========================================================================== |
802 | // FOR THE REST OF THE TASKS THE MACRO AddTaskXXX() is not yet implemented/ | |
803 | // Run the analysis | |
804 | // | |
805 | if (kPluginUse) { | |
806 | AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode); | |
807 | AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler); | |
808 | } | |
809 | ||
810 | if (mgr->InitAnalysis()) { | |
811 | mgr->PrintStatus(); | |
812 | // if (kSaveTrain || strlen(config_file)) gSystem->ChangeDirectory(kTrainName); | |
e84da0a5 | 813 | if (!strcmp(plugin_mode,"submit")&&smode=="GRID"){ |
c38e3b95 | 814 | TString alien_workdir = gGrid->GetHomeDirectory(); |
815 | if (iAODanalysis) alien_workdir += "analysisAOD"; | |
816 | else alien_workdir += "analysisESD"; | |
3878a941 | 817 | if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data()); |
c38e3b95 | 818 | AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler(); |
e84da0a5 | 819 | printf("=== AnalysisTrainPWG4Jets:: Registering jdl in the work directory alien://%s/%s, should be done by the manager! ===\n", |
c38e3b95 | 820 | alien_workdir.Data(),gridhandler->GetGridOutputDir()); |
58ef946c | 821 | |
822 | TString dest; | |
823 | dest = Form("%s/%s/%s.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data()); | |
824 | if(AliAnalysisAlien::FileExists(dest.Data())){ | |
825 | // Printf("%s exist on grid removing...",dest.Data()); | |
826 | // gGrid->Rm(dest.Data()); | |
827 | } | |
828 | TFile::Cp(Form("file:%s.jdl",kTrainName.Data()),Form("alien://%s",dest.Data())); | |
4721d8c5 | 829 | |
830 | ||
831 | TString dest; | |
832 | dest = Form("%s/%s/%s_merge.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data()); | |
833 | if(AliAnalysisAlien::FileExists(dest.Data())){ | |
834 | // Printf("%s exist on grid removing...",dest.Data()); | |
835 | // gGrid->Rm(dest.Data()); | |
836 | } | |
837 | TFile::Cp(Form("file:%s_merge.jdl",kTrainName.Data()),Form("alien://%s",dest.Data())); | |
838 | ||
58ef946c | 839 | |
73b7619a | 840 | dest = Form("%s/rootfiles/STEER/LQ1dRef_v1.root",gGrid->GetHomeDirectory()); |
58ef946c | 841 | if(AliAnalysisAlien::FileExists(dest.Data())){ |
842 | Printf("%s exist on grid removing...",dest.Data()); | |
843 | gGrid->Rm(dest.Data()); | |
844 | } | |
845 | TFile::Cp(Form("file:%s/STEER/LQ1dRef_v1.root", | |
9748e967 | 846 | gSystem->ExpandPathName("$ALICE_ROOT")),Form("alien://%s",dest.Data())); |
c38e3b95 | 847 | } |
3878a941 | 848 | AliLog::SetGlobalLogLevel(AliLog::kError); |
c166d299 | 849 | if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){ |
850 | TFile * fM = TFile::Open("manager_local.root","RECREATE"); | |
851 | mgr->Write(); | |
852 | fM->Close(); | |
853 | } | |
46534866 | 854 | |
855 | // grmpf, aliroot error handler overwrites root | |
856 | gErrorIgnoreLevel = kErrorIgnoreLevel; | |
857 | if(gErrorIgnoreLevel>3000) AliLog::SetGlobalLogLevel(AliLog::kFatal); | |
c38e3b95 | 858 | StartAnalysis(smode, chain); |
4a6f59cb | 859 | if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){ |
860 | for(int i = 0;i < mgr->GetTopTasks()->GetEntries();i++){ | |
861 | mgr->ProfileTask(i); | |
862 | } | |
863 | } | |
c38e3b95 | 864 | if (!strcmp(plugin_mode, "offline")&&smode=="GRID"){ |
e84da0a5 | 865 | // Offline mode path files |
866 | // PatchJDL(); | |
867 | PatchAnalysisMacro(); | |
868 | } | |
c38e3b95 | 869 | |
e84da0a5 | 870 | if (kSaveTrain && smode=="GRID") { |
871 | AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler(); | |
872 | TString alien_workdir = gGrid->GetHomeDirectory(); | |
873 | if (iAODanalysis) alien_workdir += "analysisAOD"; | |
3878a941 | 874 | else alien_workdir += "analysisESD"; |
875 | if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data()); | |
e84da0a5 | 876 | // kGridOutdir = gridhandler->GetGridOutputDir(); |
877 | printf("=== Registering ConfigTrain.C in the work directory <%s> ===\n", | |
c38e3b95 | 878 | alien_workdir.Data()); |
e84da0a5 | 879 | if (AliAnalysisAlien::FileExists(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()))) |
880 | gGrid->Rm(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data())); | |
881 | if (strcmp(plugin_mode, "test")) | |
882 | TFile::Cp(Form("file:%sConfig.C",kTrainName.Data()), Form("alien://%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data())); | |
883 | } | |
884 | } | |
c38e3b95 | 885 | } |
886 | ||
887 | //______________________________________________________________________________ | |
888 | void StartAnalysis(const char *mode, TChain *chain) { | |
889 | // Start analysis. | |
890 | Int_t imode = -1; | |
891 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
892 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
893 | if (!strcmp(mode, "PROOF")) imode = 1; | |
894 | if (!strcmp(mode, "GRID")) imode = 2; | |
895 | switch (imode) { | |
896 | case 0: | |
897 | if (!chain) { | |
898 | ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain"); | |
899 | return; | |
900 | } | |
82ebd295 | 901 | mgr->StartAnalysis(mode, chain,kNumberOfEvents); |
c38e3b95 | 902 | return; |
903 | case 1: | |
904 | if (!kProofDataSet.Length()) { | |
905 | ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "kProofDataSet is empty"); | |
906 | return; | |
907 | } | |
908 | mgr->StartAnalysis(mode, kProofDataSet, kProofEvents,kProofOffset); | |
909 | return; | |
910 | case 2: | |
911 | if (kPluginUse) { | |
912 | if (!mgr->GetGridHandler()) { | |
913 | ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Grid plugin not initialized"); | |
914 | return; | |
915 | } | |
ebad39a9 | 916 | mgr->StartAnalysis("grid",chain,kNumberOfEvents); |
c38e3b95 | 917 | } else { |
918 | if (!chain) { | |
919 | ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain"); | |
920 | return; | |
921 | } | |
922 | mgr->StartAnalysis(mode, chain); | |
ebad39a9 | 923 | mgr->StartAnalysis(mode, chain,kNumberOfEvents); |
c38e3b95 | 924 | } |
925 | return; | |
926 | } | |
927 | } | |
928 | ||
929 | //______________________________________________________________________________ | |
930 | void CheckModuleFlags(const char *mode) { | |
931 | // Checks selected modules and insure compatibility | |
932 | Int_t imode = -1; | |
933 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
934 | if (!strcmp(mode, "PROOF")) imode = 1; | |
935 | if (!strcmp(mode, "GRID")) imode = 2; | |
936 | ||
937 | ||
e84da0a5 | 938 | if (kUseCPAR) { |
939 | kPluginAliRootVersion = ""; // NO aliroot if we use CPAR | |
940 | } | |
c38e3b95 | 941 | |
942 | if (imode==1) { | |
943 | if (!kUsePAR) { | |
944 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis"); | |
945 | kUsePAR = kTRUE; | |
946 | } | |
947 | } | |
948 | if (imode != 2) { | |
949 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode"); | |
950 | kPluginUse = kFALSE; | |
951 | } | |
952 | ||
953 | ||
954 | if(!kIsMC){ | |
955 | // switch off anthin related to MC | |
956 | kUseMC = 0; | |
957 | kUseAODMC = 0; | |
958 | kUseTR = kFALSE; | |
959 | } | |
960 | ||
f4132e7d | 961 | // Decide if we have PbPb |
962 | if(kGridDataSet.CompareTo("LHC10h")==0) { | |
963 | kIsPbPb = true; | |
964 | } | |
965 | ||
966 | ||
967 | ||
c38e3b95 | 968 | if (iAODanalysis) { |
969 | // AOD analysis | |
970 | if (kUseMC) | |
971 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's"); | |
972 | if (kUseAODTags) | |
973 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's"); | |
974 | kUseMC = kFALSE; | |
975 | kUseTR = kFALSE; | |
976 | kUseAODTags = kFALSE; | |
977 | if (iESDfilter) | |
978 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's"); | |
979 | iESDfilter = 0; | |
e84da0a5 | 980 | if (iPhysicsSelection) |
981 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "Physics Selection disabled in analysis on AOD's"); | |
982 | iPhysicsSelection = 0; | |
c38e3b95 | 983 | if (!iAODhandler) { |
984 | if (iJETAN) | |
985 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler"); | |
986 | iJETAN = 0; | |
987 | iDIJETAN = 0; | |
988 | } | |
989 | // Disable tasks that do not work yet on AOD data | |
58ef946c | 990 | if(iPWG4JCORRAN)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 JCORRAN disabled in analysis on AOD's"); |
4d62ae1a | 991 | iPWG4JCORRAN = 0; |
c38e3b95 | 992 | if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's"); |
993 | iPWG4PtQAMC = 0; | |
994 | if( iPWG4PtQATPC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtTPC disabled in analysis on AOD's"); | |
995 | iPWG4PtQATPC = 0; | |
1f329128 | 996 | if( iPWG4Cosmics)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Comics disabled in analysis on AOD's"); |
997 | iPWG4Cosmics = 0; | |
998 | ||
c38e3b95 | 999 | if( iPWG4PtSpectra)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's"); |
1000 | iPWG4PtSpectra = 0; | |
b53f2e4f | 1001 | if(iPWG4KMeans)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4KMeans disabled on AOD's"); |
1002 | iPWG4KMeans = 0; | |
d2e6cdd5 | 1003 | if (iPWG4JetCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4Jetcorr disabled on AOD's"); |
1004 | iPWG4JetCorr = 0; | |
c38e3b95 | 1005 | if (iPWG4PartCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4partcorr disabled on AOD's"); |
1006 | iPWG4PartCorr = 0; | |
d2e6cdd5 | 1007 | if (iPWG4CaloQA)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4CaloQA disabled on AOD's"); |
1008 | iPWG4CaloQA = 0; | |
911a740f | 1009 | if (iPWG4Tagged)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4tagged disabled on AOD's"); |
1010 | iPWG4Tagged = 0; | |
121e4bd5 | 1011 | if (iPWG4omega3pi) |
1012 | ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4omega3pi disabled on AOD's"); | |
1013 | iPWG4omega3pi = 0; | |
c38e3b95 | 1014 | if(iPWG1QASym)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG1 QA Sym disabled in analysis on AOD's"); |
53c63663 | 1015 | if (iPWG4GammaConv)::Info("AnalysisPWG4Jets.C::CheckModuleFlags", "PWG4gammaconv disabled on AOD's"); |
1016 | iPWG4GammaConv = 0; | |
c38e3b95 | 1017 | iPWG1QASym = 0; |
f4132e7d | 1018 | iCentralitySelection = 0; |
c38e3b95 | 1019 | } else { |
1020 | // ESD analysis | |
f4132e7d | 1021 | |
1022 | if(kIsPbPb){ | |
1023 | iCentralitySelection = 1; | |
1024 | } | |
1025 | ||
c38e3b95 | 1026 | if (!kUseMC){ |
1027 | kUseTR = kFALSE; | |
1028 | ||
1029 | if(kUseKinefilter)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Kine Filter disabled in analysis without MC"); | |
1030 | kUseKinefilter = kFALSE; | |
1031 | if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis without MC"); | |
1032 | iPWG4PtQAMC = 0; | |
9748e967 | 1033 | if( iPWG4CorrectionsUE)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 CorrectionsUE disabled in analysis without MC"); |
1034 | iPWG4CorrectionsUE = 0; | |
c38e3b95 | 1035 | } |
1036 | if (!kUseTR) { | |
c166d299 | 1037 | if(iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "iPWG4QATPCMC disabled if not reading track references"); |
b03b08a3 | 1038 | iPWG4PtQAMC = 0; |
c38e3b95 | 1039 | } |
e84da0a5 | 1040 | if (iJETAN){ |
1041 | iESDfilter=1; | |
1042 | } | |
c38e3b95 | 1043 | if (!iESDfilter){ |
1044 | kUseKinefilter = kFALSE; | |
1045 | kUseMuonfilter = kFALSE; | |
1046 | } | |
1047 | if(!iJETAN){ | |
cc636095 | 1048 | iPWG4JetSpectrum = iPWG4UE = iPWG4CorrectionsUE = iPWG4ThreeJets = iPWG4QGSep = iDIJETAN = 0; |
c38e3b95 | 1049 | } |
1050 | } | |
cc636095 | 1051 | iPWG4JetTasks = iPWG4JetServices||iPWG4JetSpectrum||iPWG4UE||iPWG4LeadingUE||iPWG4PtQAMC||iPWG4PtSpectra||iPWG4PtQATPC||iPWG4Cosmics||iPWG4ThreeJets||iPWG4QGSep||iPWG4JetChem||iPWG4Minijet||iPWG4Fragmentation; |
d2e6cdd5 | 1052 | iPWG4PartCorrLibs = iPWG4PartCorr||iPWG4Tagged||iPWG4CaloQA; |
17d96675 | 1053 | iPWG4GammaConvLib = iPWG4GammaConv||iPWG4CaloConv; |
1054 | ||
1055 | ||
1056 | iEMCUtilLibs = iPWG4PartCorrLibs||iPWG4JCORRAN||iPWG4GammaConvLib; | |
e6993a52 | 1057 | iJETANLib = iPWG4JetTasks||iJETAN||iDIJETAN; |
17d96675 | 1058 | |
c38e3b95 | 1059 | if (iESDfilter) {iAODhandler=1;} |
1060 | if (kUseKinefilter && !kUseMC) kUseKinefilter = kFALSE; | |
1061 | if (kUseAODTags && !iAODhandler) kUseAODTags = kFALSE; | |
1062 | ||
1063 | ||
1064 | ||
1065 | } | |
1066 | ||
1067 | //______________________________________________________________________________ | |
1068 | Bool_t Connect(const char *mode) { | |
1069 | // Connect <username> to the back-end system. | |
1070 | Int_t imode = -1; | |
1071 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
1072 | if (!strcmp(mode, "PROOF")) imode = 1; | |
1073 | if (!strcmp(mode, "GRID")) imode = 2; | |
1074 | TString username = gSystem->Getenv("alien_API_USER"); | |
1075 | switch (imode) { | |
1076 | case 0: | |
1077 | break; | |
1078 | case 1: | |
1079 | if (!username.Length()) { | |
1080 | ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \ | |
1081 | 1. Have called: alien-token-init <username>\n \ | |
1082 | 2. Have called: >source /tmp/gclient_env_$UID"); | |
1083 | return kFALSE; | |
1084 | } | |
1085 | ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to PROOF cluster <%s>", | |
1086 | username.Data(), kProofCluster.Data()); | |
1087 | gEnv->SetValue("XSec.GSI.DelegProxy", "2"); | |
1088 | // TProof::Open(Form("%s@%s:31093", username.Data(), kProofCluster.Data())); | |
1089 | TProof::Open(Form("%s@%s", username.Data(), kProofCluster.Data())); | |
1090 | if (!gProof) { | |
1091 | if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch")) | |
1092 | ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch"); | |
1093 | return kFALSE; | |
1094 | } | |
1095 | if(kProofClearPackages)gProof->ClearPackages(); | |
1096 | ||
1097 | if(kProofSaveToAlien){ | |
1098 | TGrid::Connect("alien://"); | |
1099 | if (gGrid) { | |
1100 | TString homedir = gGrid->GetHomeDirectory(); | |
1101 | TString workdir = homedir + kTrainName; | |
1102 | if (!gGrid->Cd(workdir)) { | |
1103 | gGrid->Cd(homedir); | |
1104 | if (gGrid->Mkdir(workdir)) { | |
1105 | gGrid->Cd(kTrainName); | |
1106 | ::Info("AnalysisTrainPWG4Jets::Connect()", "Directory %s created", gGrid->Pwd()); | |
1107 | } | |
1108 | } | |
1109 | gGrid->Mkdir("proof_output"); | |
1110 | gGrid->Cd("proof_output"); | |
1111 | kProofOutdir = Form("alien://%s", gGrid->Pwd()); | |
1112 | } | |
1113 | } | |
1114 | break; | |
1115 | case 2: | |
1116 | if (!username.Length()) { | |
1117 | ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \ | |
1118 | 1. Have called: alien-token-init <username>\n \ | |
1119 | 2. Have called: >source /tmp/gclient_env_$UID"); | |
1120 | return kFALSE; | |
1121 | } | |
1122 | if (kPluginUse && !gSystem->Getenv("alien_CLOSE_SE")) { | |
1123 | ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), | |
1124 | "When using the AliEn plugin it is preferable to define the \ | |
1125 | variable alien_CLOSE_SE in your environment."); | |
1126 | return kFALSE; | |
1127 | } | |
1128 | ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to AliEn ...", | |
1129 | username.Data()); | |
1130 | TGrid::Connect("alien://"); | |
1131 | if (!gGrid || !gGrid->IsConnected()) return kFALSE; | |
1132 | break; | |
1133 | default: | |
1134 | ::Error("AnalysisTrainPWG4Jets.C::Connect", "Unknown run mode: %s", mode); | |
1135 | return kFALSE; | |
1136 | } | |
1137 | ::Info("AnalysisTrainPWG4Jets.C::Connect","Connected in %s mode", mode); | |
1138 | return kTRUE; | |
1139 | } | |
1140 | ||
1141 | //______________________________________________________________________________ | |
1142 | Bool_t LoadCommonLibraries(const char *mode) | |
1143 | { | |
1144 | // Load common analysis libraries. | |
1145 | Int_t imode = -1; | |
1146 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
1147 | if (!strcmp(mode, "PROOF")) imode = 1; | |
1148 | if (!strcmp(mode, "GRID")) imode = 2; | |
1149 | if (!gSystem->Getenv("ALICE_ROOT")) { | |
ebad39a9 | 1150 | ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Analysis train requires that ALICE_ROOT is set to pick up Configurations"); |
c38e3b95 | 1151 | return kFALSE; |
1152 | } | |
1153 | Bool_t success = kTRUE; | |
1154 | // ROOT libraries | |
1155 | gSystem->Load("libTree.so"); | |
1156 | gSystem->Load("libGeom.so"); | |
1157 | gSystem->Load("libVMC.so"); | |
1158 | gSystem->Load("libPhysics.so"); | |
1159 | ||
1160 | // Load framework classes. Par option ignored here. | |
1161 | switch (imode) { | |
1162 | case 0: | |
1163 | case 2: | |
1164 | if (kUseCPAR) { | |
1165 | success &= LoadLibrary("STEERBase", mode, kTRUE); | |
1166 | success &= LoadLibrary("ESD", mode, kTRUE); | |
1167 | success &= LoadLibrary("AOD", mode, kTRUE); | |
1168 | success &= LoadLibrary("ANALYSIS", mode, kTRUE); | |
1169 | success &= LoadLibrary("ANALYSISalice", mode, kTRUE); | |
1170 | success &= LoadLibrary("CORRFW", mode, kTRUE); | |
1171 | } else { | |
1172 | success &= LoadLibrary("libSTEERBase.so", mode); | |
1173 | success &= LoadLibrary("libESD.so", mode); | |
1174 | success &= LoadLibrary("libAOD.so", mode); | |
1175 | success &= LoadLibrary("libANALYSIS.so", mode); | |
1176 | success &= LoadLibrary("libANALYSISalice.so", mode); | |
1177 | success &= LoadLibrary("libCORRFW.so", mode); | |
1178 | gROOT->ProcessLine(".include $ALICE_ROOT/include"); | |
1179 | } | |
1180 | break; | |
1181 | case 1: | |
1182 | Int_t ires = -1; | |
1183 | if (kProofUseAFPAR && !gSystem->AccessPathName(kProofAFversion)) ires = gProof->UploadPackage(kProofAFversion); | |
1184 | if (ires < 0) { | |
1185 | success &= LoadLibrary("STEERBase", mode); | |
1186 | success &= LoadLibrary("ESD", mode); | |
1187 | success &= LoadLibrary("AOD", mode); | |
1188 | success &= LoadLibrary("ANALYSIS", mode); | |
1189 | success &= LoadLibrary("ANALYSISalice", mode); | |
1190 | success &= LoadLibrary("CORRFW", mode); | |
1191 | } else { | |
1192 | ires = gProof->EnablePackage(kProofAFversion); | |
1193 | if (ires<0) success = kFALSE; | |
1194 | success &= LoadLibrary("CORRFW", mode); | |
1195 | } | |
1196 | break; | |
1197 | default: | |
1198 | ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Unknown run mode: %s", mode); | |
1199 | return kFALSE; | |
1200 | } | |
1201 | if (success) { | |
1202 | ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: SUCCESS"); | |
1203 | ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s", | |
1204 | gSystem->GetIncludePath()); | |
1205 | } else { | |
1206 | ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: FAILED"); | |
1207 | } | |
1208 | ||
1209 | return success; | |
1210 | } | |
1211 | ||
1212 | //______________________________________________________________________________ | |
1213 | Bool_t LoadAnalysisLibraries(const char *mode) | |
1214 | { | |
1215 | // Load common analysis libraries. | |
9748e967 | 1216 | Bool_t success = kTRUE; |
cfd02305 | 1217 | if (useTender) { |
1218 | if (!LoadLibrary("TENDER", mode, kTRUE) || | |
1219 | !LoadLibrary("TENDERSupplies", mode, kTRUE)) return kFALSE; | |
1220 | } | |
c38e3b95 | 1221 | if (iESDfilter) { |
b0a36f28 | 1222 | /* |
c38e3b95 | 1223 | if (!LoadLibrary("PWG3base", mode, kTRUE) || |
1224 | !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE; | |
b0a36f28 | 1225 | */ |
c38e3b95 | 1226 | } |
1227 | // JETAN | |
e6993a52 | 1228 | if (iJETANLib) { |
b53f2e4f | 1229 | // this part needs some rework in case we do not need the fastjed finders for processing |
1230 | if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE; | |
c38e3b95 | 1231 | if (!strcmp(mode, "PROOF")){ |
ef1e462f | 1232 | gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libCGAL.so\"\)", kTRUE); |
c38e3b95 | 1233 | gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libfastjet.so\"\)", kTRUE); |
1234 | // problem when loading siscone copiled with different gcc version?? | |
1235 | // gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libsiscone.so\"\)", kTRUE); | |
1236 | gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libSISConePlugin.so\"\)", kTRUE); | |
1237 | } | |
b53f2e4f | 1238 | if(!kUsePAR){ |
e84da0a5 | 1239 | if (!LoadLibrary("CGAL", mode, kTRUE)) return kFALSE; |
1240 | if (!LoadLibrary("fastjet", mode, kTRUE)) return kFALSE; | |
1241 | if (!LoadLibrary("siscone", mode, kTRUE)) return kFALSE; | |
1242 | if (!LoadLibrary("SISConePlugin", mode, kTRUE)) return kFALSE; | |
1243 | } | |
1244 | else{ | |
1245 | // par files plus FASTJET needs some extra work... need to change | |
1246 | // the loading sequence in the auto generated .C file | |
1247 | if (!LoadLibrary("libCGAL.so", mode, kTRUE)) return kFALSE; | |
1248 | if (!LoadLibrary("libfastjet.so", mode, kTRUE)) return kFALSE; | |
1249 | if (!LoadLibrary("libsiscone.so", mode, kTRUE)) return kFALSE; | |
1250 | if (!LoadLibrary("libSISConePlugin.so", mode, kTRUE)) return kFALSE; | |
1251 | } | |
c38e3b95 | 1252 | if (!LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE; |
1253 | } | |
1254 | if(iPWG4JetTasks){ | |
c38e3b95 | 1255 | if (!LoadLibrary("PWG4JetTasks", mode, kTRUE)) return kFALSE; |
1256 | } | |
58ef946c | 1257 | |
c38e3b95 | 1258 | if(iPWG1QASym){ |
99bfd7f7 | 1259 | if (!LoadSource(Form("%s/PWG1/AliAnalysisTaskQASym.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE; |
c38e3b95 | 1260 | } |
121e4bd5 | 1261 | if(iPWG4TmpSourceSara){ |
c166d299 | 1262 | if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!! |
121e4bd5 | 1263 | if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskEta.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE; |
1264 | } | |
58ef946c | 1265 | |
9f77f0ce | 1266 | /* |
1267 | if(iPWG4JetChem){ | |
c580ebbb | 1268 | if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!! |
1269 | if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskJetChem.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE; | |
1270 | } | |
9f77f0ce | 1271 | */ |
c166d299 | 1272 | |
4721d8c5 | 1273 | if(iEMCUtilLibs){ |
1274 | if (!LoadLibrary("EMCALUtils", mode, kTRUE) || | |
1275 | !LoadLibrary("PHOSUtils", mode, kTRUE)) return kFALSE; | |
1276 | } | |
1277 | ||
911a740f | 1278 | if (iPWG4PartCorrLibs) { |
4721d8c5 | 1279 | if (!LoadLibrary("PWG4PartCorrBase", mode, kTRUE) || |
c38e3b95 | 1280 | !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE; |
1281 | } | |
4721d8c5 | 1282 | if(iPWG4JCORRAN){ |
1283 | // PWG4 particle correlations | |
1284 | if(!LoadLibrary("PWG4JCORRAN",mode,kTRUE))return kFALSE; | |
1285 | } | |
d2e6cdd5 | 1286 | if (iPWG4JetCorr) { |
1287 | if (!LoadLibrary("PWG4JetCorrel", mode, kTRUE)) return kFALSE; | |
1288 | } | |
121e4bd5 | 1289 | if (iPWG4omega3pi) { |
1290 | if (!LoadLibrary("PWG4omega3pi", mode, kTRUE)) return kFALSE; | |
1291 | } | |
17d96675 | 1292 | if (iPWG4GammaConvLib) { |
53c63663 | 1293 | if (!LoadLibrary("PWG4GammaConv", mode, kTRUE)) return kFALSE; |
1294 | } | |
c38e3b95 | 1295 | |
1296 | ::Info("AnalysisTrainPWG4Jets.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS"); | |
1297 | return kTRUE; | |
1298 | } | |
1299 | ||
1300 | //______________________________________________________________________________ | |
1301 | Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE) | |
1302 | { | |
1303 | // Load a module library in a given mode. Reports success. | |
1304 | Int_t imode = -1; | |
1305 | Int_t result; | |
1306 | TString smodule(module); | |
1307 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
1308 | if (!strcmp(mode, "PROOF")) imode = 1; | |
1309 | if (!strcmp(mode, "GRID")) imode = 2; | |
1310 | TString mod(module); | |
1311 | if (!mod.Length()) { | |
1312 | ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Empty module name"); | |
1313 | return kFALSE; | |
1314 | } | |
1315 | // If a library is specified, just load it | |
1316 | if (smodule.EndsWith(".so")) { | |
1317 | mod.Remove(mod.Index(".so")); | |
1318 | result = gSystem->Load(mod); | |
1319 | if (result < 0) { | |
1320 | ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load library %s", module); | |
1321 | return kFALSE; | |
1322 | } | |
1323 | if (rec) anaLibs += Form("%s.so ",mod.Data()); | |
e84da0a5 | 1324 | if (rec) anaLibsExtra += Form("%s.so ",mod.Data()); |
c38e3b95 | 1325 | return kTRUE; |
1326 | } | |
1327 | // Check if the library is already loaded | |
1328 | if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0) | |
1329 | return kTRUE; | |
1330 | switch (imode) { | |
1331 | case 0: | |
1332 | case 2: | |
1333 | if (kUsePAR) { | |
1334 | result = SetupPar(module); | |
1335 | if (rec) anaPars += Form("%s.par ", module); | |
1336 | } else { | |
1337 | result = gSystem->Load(Form("lib%s.so", module)); | |
1338 | if (rec) anaLibs += Form("lib%s.so ", module); | |
1339 | } | |
1340 | break; | |
1341 | case 1: | |
1342 | if(!gSystem->AccessPathName(module)){ | |
1343 | ::Info("AnalysisTrainPWG4Jets.C::LoadLibrary", "Removing directory %s",module); | |
1344 | gSystem->Exec(Form("rm -rf %s",module)); | |
1345 | } | |
1346 | result = gProof->UploadPackage(module); | |
1347 | if (result<0) { | |
1348 | result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module))); | |
1349 | if (result<0) { | |
1350 | ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module); | |
1351 | return kFALSE; | |
1352 | } | |
1353 | } | |
1354 | result = gProof->EnablePackage(module); | |
1355 | break; | |
1356 | default: | |
1357 | return kFALSE; | |
1358 | } | |
1359 | if (result < 0) { | |
1360 | ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load module %s", module); | |
1361 | return kFALSE; | |
1362 | } | |
1363 | return kTRUE; | |
1364 | } | |
1365 | ||
1366 | ||
1367 | ||
1368 | //______________________________________________________________________________ | |
1369 | Bool_t LoadSource(const char *source, const char *mode, Bool_t rec=kFALSE) | |
1370 | { | |
1371 | // Load a module library in a given mode. Reports success. | |
1372 | Int_t imode = -1; | |
1373 | Int_t result = -1; | |
1374 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
1375 | if (!strcmp(mode, "PROOF")) imode = 1; | |
1376 | if (!strcmp(mode, "GRID")) imode = 2; | |
1377 | TString ssource(source); | |
1378 | TString basename = gSystem->BaseName(ssource.Data()); | |
1379 | if (!ssource.Length()) { | |
1380 | ::Error("AnalysisTrainPWG4Jets.C::LoadSource", "Empty task name"); | |
1381 | return kFALSE; | |
1382 | } | |
4d62ae1a | 1383 | // we have a source code so compile it |
c38e3b95 | 1384 | if (ssource.EndsWith(".cxx")) { |
1385 | // need to copy it here other wise the path is also used on grid... | |
1386 | ssource.Remove(ssource.Index(".cxx")); | |
1387 | basename.Remove(basename.Index(".cxx")); | |
1388 | Printf("LoadSources:: Copying... path %s{cxx,h}",ssource.Data()); | |
1389 | gSystem->Exec(Form("cp %s.cxx . ",ssource.Data())); | |
1390 | gSystem->Exec(Form("cp %s.h . ",ssource.Data())); | |
1391 | // Path to code | |
1392 | // only needed for local compilation, in grid and proof mode | |
1393 | // the task headers are uploaded | |
1394 | // path.Remove(path.Index(gSystem->BaseName(path.Data()))); | |
1395 | // Printf("LoadSources:: Including path %s",path.Data()); | |
1396 | // if(path.Length()>0)gROOT->ProcessLine(Form(".include %s",path.Data())); | |
1397 | Printf("LoadSources:: Loading... path %s",basename.Data()); | |
1398 | switch (imode) { | |
1399 | case 0: | |
b53f2e4f | 1400 | result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data())); |
c38e3b95 | 1401 | break; |
1402 | case 1: | |
b53f2e4f | 1403 | result = gProof->LoadMacro(Form("%s.cxx++g",basename.Data())); |
c38e3b95 | 1404 | break; |
1405 | case 2: | |
b53f2e4f | 1406 | result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data())); |
c38e3b95 | 1407 | if (rec){ |
1408 | // what we want to compile | |
1409 | anaSources += Form("%s.cxx ",basename.Data()); | |
1410 | // what we need as input... | |
1411 | anaLibs += Form("%s.cxx %s.h ",basename.Data(),basename.Data()); | |
1412 | } | |
1413 | break; | |
1414 | default: | |
1415 | return kFALSE; | |
1416 | } | |
1417 | } | |
1418 | if (result < 0) { | |
1419 | ::Error("AnalysisTrainPWG4Jets.C::LoadSources", "Could not load source %s", source); | |
1420 | return kFALSE; | |
1421 | } | |
1422 | return kTRUE; | |
1423 | } | |
1424 | ||
1425 | ||
1426 | //______________________________________________________________________________ | |
1427 | TChain *CreateChain(const char *mode, const char *plugin_mode) | |
1428 | { | |
1429 | // Create the input chain | |
1430 | Int_t imode = -1; | |
1431 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
1432 | if (!strcmp(mode, "PROOF")) imode = 1; | |
1433 | if (!strcmp(mode, "GRID")) imode = 2; | |
1434 | TChain *chain = NULL; | |
1435 | // Local chain | |
1436 | switch (imode) { | |
1437 | case 0: | |
1438 | if (iAODanalysis) { | |
1439 | if (!kLocalXMLDataset.Length()) { | |
1440 | // Local AOD | |
1441 | chain = new TChain("aodTree"); | |
1442 | TString line; | |
1443 | ifstream in; | |
1444 | in.open(kLocalDataList.Data()); | |
1445 | while (in.good()) { | |
1446 | in >> line; | |
1447 | if (line.Length() == 0) continue; | |
1448 | // cout << " line = " << line << endl; | |
1449 | chain->Add(line.Data()); | |
1450 | } | |
1451 | } else { | |
1452 | // Interactive AOD | |
1453 | chain = CreateChainSingle(kLocalXMLDataset, "aodTree"); | |
1454 | } | |
1455 | } else { | |
1456 | if (!kLocalXMLDataset.Length()) { | |
1457 | // Local ESD | |
1458 | chain = new TChain("esdTree"); | |
1459 | TString line; | |
1460 | ifstream in; | |
1461 | in.open(kLocalDataList.Data()); | |
1462 | while (in.good()) { | |
1463 | in >> line; | |
1464 | if (line.Length() == 0) continue; | |
1465 | cout << " line = " << line << endl; | |
1466 | chain->Add(line.Data()); | |
1467 | } | |
1468 | } else { | |
1469 | // Interactive ESD | |
1470 | chain = CreateChainSingle(kLocalXMLDataset, "esdTree"); | |
1471 | } | |
1472 | } | |
1473 | break; | |
1474 | case 1: | |
1475 | break; | |
1476 | case 2: | |
1477 | if (kPluginUse) { | |
1478 | // AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode); | |
1479 | // AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler); | |
1480 | } else { | |
1481 | TString treeName = "esdTree"; | |
1482 | if (iAODanalysis) treeName = "aodTree"; | |
1483 | chain = CreateChainSingle("wn.xml", treeName); | |
1484 | } | |
1485 | break; | |
1486 | default: | |
1487 | } | |
1488 | if (chain && chain->GetNtrees()) return chain; | |
1489 | return NULL; | |
1490 | } | |
1491 | ||
1492 | //______________________________________________________________________________ | |
1493 | TChain* CreateChainSingle(const char* xmlfile, const char *treeName) | |
1494 | { | |
1495 | printf("*******************************\n"); | |
1496 | printf("*** Getting the ESD Chain ***\n"); | |
1497 | printf("*******************************\n"); | |
1498 | TAlienCollection * myCollection = TAlienCollection::Open(xmlfile); | |
1499 | ||
1500 | if (!myCollection) { | |
1501 | ::Error("AnalysisTrainPWG4Jets.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ; | |
1502 | return NULL ; | |
1503 | } | |
1504 | ||
1505 | TChain* chain = new TChain(treeName); | |
1506 | myCollection->Reset() ; | |
1507 | while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ; | |
1508 | chain->ls(); | |
1509 | return chain; | |
1510 | } | |
1511 | ||
1512 | //______________________________________________________________________________ | |
1513 | Int_t SetupPar(char* pararchivename) | |
1514 | { | |
1515 | if (!pararchivename || !strlen(pararchivename)) return -1; | |
1516 | char processline[1024]; | |
1517 | if (gSystem->AccessPathName(Form("%s.par", pararchivename))) { | |
1518 | if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) { | |
1519 | ::Info("AnalysisTrainPWG4Jets.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename); | |
9748e967 | 1520 | TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)), |
1521 | Form("%s.par",pararchivename)); | |
c38e3b95 | 1522 | } else { |
1523 | ::Error("AnalysisTrainPWG4Jets.C::SetupPar", "Cannot find %s.par", pararchivename); | |
1524 | return -1; | |
1525 | } | |
1526 | } | |
1527 | if (kPluginUse && kSaveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, kTrainName.Data())); | |
1528 | gSystem->Exec(Form("tar xvzf %s.par", pararchivename)); | |
1529 | ||
1530 | TString ocwd = gSystem->WorkingDirectory(); | |
1531 | if (!gSystem->ChangeDirectory(pararchivename)) return -1; | |
1532 | ||
1533 | // check for BUILD.sh and execute | |
1534 | if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { | |
1535 | printf("*******************************\n"); | |
1536 | printf("*** Building PAR archive ***\n"); | |
1537 | printf("*******************************\n"); | |
1538 | if (gSystem->Exec("PROOF-INF/BUILD.sh")) { | |
1539 | Error("runProcess","Cannot Build the PAR Archive! - Abort!"); | |
1540 | return -1; | |
1541 | } | |
1542 | } | |
1543 | ||
1544 | // check for SETUP.C and execute | |
1545 | if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { | |
1546 | printf("*******************************\n"); | |
1547 | printf("*** Setup PAR archive ***\n"); | |
1548 | printf("*******************************\n"); | |
1549 | gROOT->Macro("PROOF-INF/SETUP.C"); | |
1550 | } | |
1551 | if (!gSystem->ChangeDirectory(ocwd.Data())) return -1; | |
1552 | return 0; | |
1553 | } | |
1554 | ||
1555 | //______________________________________________________________________________ | |
1556 | AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode) | |
1557 | { | |
1558 | // Check if user has a valid token, otherwise make one. This has limitations. | |
1559 | // One can always follow the standard procedure of calling alien-token-init then | |
1560 | // source /tmp/gclient_env_$UID in the current shell. | |
c8fb37dd | 1561 | // if (!AliAnalysisGrid::CreateToken()) return NULL; |
c38e3b95 | 1562 | AliAnalysisAlien *plugin = new AliAnalysisAlien(); |
1563 | // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") | |
1564 | plugin->SetRunMode(plugin_mode); | |
1565 | if (kPluginUseProductionMode) plugin->SetProductionMode(); | |
1566 | plugin->SetJobTag(kJobTag); | |
e0c120d9 | 1567 | plugin->SetNtestFiles(1); |
c38e3b95 | 1568 | // plugin->SetPreferedSE("ALICE::NIHAM::File"); |
1569 | // Set versions of used packages | |
e84da0a5 | 1570 | plugin->SetAPIVersion("V1.1x"); |
1571 | // plugin->SetAPIVersion("V1.0x"); | |
1572 | // plugin->SetAPIVersion("V2.4"); | |
c38e3b95 | 1573 | plugin->SetROOTVersion(kPluginRootVersion); |
1574 | plugin->SetAliROOTVersion(kPluginAliRootVersion); | |
1575 | // Declare input data to be processed. | |
1576 | // Method 1: Create automatically XML collections using alien 'find' command. | |
1577 | // Define production directory LFN | |
1578 | plugin->SetGridDataDir(kGridDatadir.Data()); | |
1579 | // Set data search pattern | |
1580 | if (iAODanalysis) plugin->SetDataPattern(" *AliAOD.root"); | |
c8fb37dd | 1581 | // else plugin->SetDataPattern(Form(" %s/*/*ESD.tag.root",kGridPassPattern.Data())); |
1582 | else plugin->SetDataPattern(Form(" %s/*/*AliESDs.root",kGridPassPattern.Data())); | |
c38e3b95 | 1583 | // ...then add run numbers to be considered |
1584 | // plugin->SetRunRange(kGridRunRange[0], kGridRunRange[1]); | |
1585 | for (Int_t i=kGridRunRange[0]; i<=kGridRunRange[1]; i++) { | |
1586 | Printf("AnalysisTrainPWG4Jets Adding run number %s", Form(kGridRunPattern.Data(),i)); | |
1587 | plugin->AddRunNumber(Form(kGridRunPattern.Data(),i)); | |
1588 | } | |
1589 | ||
1590 | if(kGridLocalRunList.Length()>0){ | |
1591 | ifstream in1; | |
1592 | in1.open(kGridLocalRunList.Data()); | |
1593 | int iRun; | |
4d16db9c | 1594 | int icount = 0; |
9a5c5b1e | 1595 | /* |
e84da0a5 | 1596 | char c; |
1597 | char cLine[250]; | |
1598 | while(!in1.eof()){ | |
1599 | c = in1.get(); | |
1600 | if ( (c >= '0') && (c <= '9') ) | |
1601 | { | |
1602 | in1.putback (c); | |
1603 | in1>>iRun; | |
1604 | Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun)); | |
1605 | plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun)); | |
1606 | } | |
1607 | else | |
1608 | { | |
1609 | in1.putback (c); | |
1610 | in1.getline(cLine,250); | |
9a5c5b1e | 1611 | |
1612 | } | |
1613 | } | |
1614 | */ | |
9748e967 | 1615 | |
1616 | Int_t nRun = 0; | |
9a5c5b1e | 1617 | |
1618 | // just use run numbers, negatives will be excluded | |
1619 | while(in1>>iRun){ | |
4d16db9c | 1620 | if(iRun>= kGridOffsetRunFromList&&(nRun<kGridMaxRunsFromList)){ |
9a5c5b1e | 1621 | Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun)); |
1622 | plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun)); | |
9748e967 | 1623 | nRun++; |
9a5c5b1e | 1624 | } |
1625 | else{ | |
1626 | Printf("AnalysisTrainPWG4Jets Skipping run number from File %d", iRun); | |
e84da0a5 | 1627 | } |
c38e3b95 | 1628 | } |
1629 | } | |
1630 | ||
1631 | // Method 2: Declare existing data files (raw collections, xml collections, root file) | |
1632 | // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir()) | |
1633 | // XML collections added via this method can be combined with the first method if | |
1634 | // the content is compatible (using or not tags) | |
1635 | // plugin->AddDataFile("tag.xml"); | |
1636 | // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root"); | |
1637 | // Define alien work directory where all files will be copied. Relative to alien $HOME. | |
3878a941 | 1638 | TString alien_workdir = ""; |
1639 | ||
1640 | if (iAODanalysis) alien_workdir += "analysisAOD"; | |
1641 | else alien_workdir += "analysisESD"; | |
1642 | if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data()); | |
1643 | plugin->SetGridWorkingDir(alien_workdir.Data()); | |
1644 | ||
c38e3b95 | 1645 | // Declare alien output directory. Relative to working directory. |
1646 | if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data()); | |
1647 | plugin->SetGridOutputDir(kGridOutdir); | |
1648 | ||
1649 | // Add external packages | |
1650 | if (iJETAN||iDIJETAN) { | |
23adcac8 | 1651 | plugin->AddExternalPackage("boost::v1_43_0"); |
1652 | plugin->AddExternalPackage("cgal::v3.6"); | |
1653 | plugin->AddExternalPackage("fastjet::v2.4.2"); | |
c38e3b95 | 1654 | } |
1655 | ||
1656 | ||
1657 | // set extra libs before par file compilation | |
1658 | anaLibs += kGridExtraFiles; | |
1659 | anaLibs = anaLibs.Strip(); | |
e84da0a5 | 1660 | Printf("anaLibs %s",anaLibs.Data()); |
1661 | Printf("anaLibsExtra %s",anaLibsExtra.Data()); | |
1662 | ||
1663 | if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs.Data()); | |
1664 | if (anaLibsExtra.Length()) plugin->SetAdditionalRootLibs(anaLibsExtra.Data()); | |
c38e3b95 | 1665 | |
1666 | TString ana_sources = ""; | |
1667 | TString ana_add = ""; | |
1668 | if (kUsePAR && anaPars.Length()) { | |
1669 | printf("%s\n", anaPars.Data()); | |
1670 | TObjArray *arr; | |
1671 | TObjString *objstr; | |
1672 | arr = anaPars.Tokenize(" "); | |
1673 | TIter next(arr); | |
1674 | while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString()); | |
1675 | delete arr; | |
1676 | } | |
1677 | ||
1678 | // Declare the analysis source files names separated by blancs. To be compiled runtime | |
1679 | // using ACLiC on the worker nodes. | |
1680 | ana_sources = anaSources.Strip(); | |
1681 | // Declare all libraries (other than the default ones for the framework. These will be | |
1682 | // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. | |
1683 | ||
1684 | if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources); | |
1685 | plugin->SetExecutableCommand(kPluginExecutableCommand.Data()); | |
4721d8c5 | 1686 | // Declare the output file names separated by blancs. |
1687 | // (can be like: file.root or file.root@ALICE::Niham::File) | |
c38e3b95 | 1688 | plugin->SetMergeExcludes(kGridMergeExclude); |
1689 | plugin->SetMaxMergeFiles(kGridMaxMergeFiles); | |
1690 | plugin->SetNrunsPerMaster(kGridRunsPerMaster); | |
9a5c5b1e | 1691 | plugin->SetMergeViaJDL(kPluginMergeViaJDL); |
4721d8c5 | 1692 | // Use fastread option |
9a5c5b1e | 1693 | plugin->SetFastReadOption(kPluginFastReadOption); |
4721d8c5 | 1694 | // UseOverwrite mode |
9a5c5b1e | 1695 | plugin->SetOverwriteMode(kPluginOverwriteMode); |
4721d8c5 | 1696 | // Optionally define the files to be archived. |
1697 | // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File"); | |
dc6a7461 | 1698 | plugin->SetOutputToRunNo(kPluginOutputToRunNumber); // write the output to subdirs named after run number |
c38e3b95 | 1699 | |
1700 | // Put default output files to archive | |
1701 | TString listhists = ""; | |
1702 | TString listaods = ""; | |
1703 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
1704 | TIter next(mgr->GetOutputs()); | |
1705 | AliAnalysisDataContainer *output; | |
1706 | while ((output=(AliAnalysisDataContainer*)next())) { | |
1707 | const char *filename = output->GetFileName(); | |
1708 | if (!(strcmp(filename, "default"))) { | |
53c63663 | 1709 | if (!mgr->GetOutputEventHandler()) continue; |
c38e3b95 | 1710 | filename = mgr->GetOutputEventHandler()->GetOutputFileName(); |
e84da0a5 | 1711 | if (listaods.Length()) listaods += " "; |
c38e3b95 | 1712 | listaods += filename; |
c38e3b95 | 1713 | } else { |
e84da0a5 | 1714 | if(!listhists.Contains(filename)){ |
1715 | if (listhists.Length()) listhists += " "; | |
c38e3b95 | 1716 | listhists += filename; |
1717 | } | |
1718 | } | |
1719 | } | |
53c63663 | 1720 | |
53c63663 | 1721 | if (mgr->GetExtraFiles().Length()) { |
e84da0a5 | 1722 | if (listaods.Length()) listaods += " "; |
53c63663 | 1723 | listaods += mgr->GetExtraFiles(); |
c38e3b95 | 1724 | } |
53c63663 | 1725 | |
1726 | // if we do not fill the aod we do not need to store it | |
4721d8c5 | 1727 | // kGridMergeExclude = listaods; |
e84da0a5 | 1728 | |
4721d8c5 | 1729 | if(kSaveAOD!=0){ |
1730 | TString outputFiles = ""; | |
1731 | outputFiles += mgr->GetExtraFiles(); | |
1732 | if (listhists.Length()) outputFiles += " "; | |
1733 | outputFiles += listhists; | |
e84da0a5 | 1734 | plugin->SetDefaultOutputs(kFALSE); |
4721d8c5 | 1735 | Printf("%s:%d Starting with the files %s",(char*)__FILE__,__LINE__,outputFiles.Data()); |
1736 | // remove | |
1737 | // no harm done when we try to remove something that is not there :) | |
1738 | if(!(kSaveAOD&(1<<0))){ | |
1739 | outputFiles.ReplaceAll("AliAOD.root ",""); | |
1740 | listaods.ReplaceAll("AliAOD.root ",""); | |
1741 | } | |
1742 | if(!(kSaveAOD&(1<<1))){ | |
1743 | if(kDeltaAODJetName.Length())outputFiles.ReplaceAll(kDeltaAODJetName.Data(),""); | |
1744 | if(kDeltaAODJetName.Length())listaods.ReplaceAll(kDeltaAODJetName.Data(),""); | |
1745 | ||
1746 | } | |
1747 | if(!(kSaveAOD&(1<<2))){ | |
1748 | if(kDeltaAODPartCorrName.Length())outputFiles.ReplaceAll(kDeltaAODPartCorrName.Data(),""); | |
1749 | if(kDeltaAODPartCorrName.Length())listaods.ReplaceAll(kDeltaAODPartCorrName.Data(),""); | |
1750 | } | |
1751 | if(!(kSaveAOD&(1<<3))){ | |
1752 | if(kDeltaAODJCORRANName.Length())outputFiles.ReplaceAll(kDeltaAODJCORRANName.Data(),""); | |
1753 | if(kDeltaAODJCORRANName.Length())listaods.ReplaceAll(kDeltaAODJCORRANName.Data(),""); | |
1754 | } | |
1755 | ||
1756 | // | |
1757 | Printf("%s:%d Saving the files %s",(char*)__FILE__,__LINE__,outputFiles.Data()); | |
1758 | plugin->SetOutputFiles(outputFiles.Data()); | |
e84da0a5 | 1759 | } |
53c63663 | 1760 | |
4721d8c5 | 1761 | TString outputArchive; |
4d5d766e | 1762 | outputArchive = Form("log_archive.zip:std*@%s","disk=1"); |
e84da0a5 | 1763 | listaods.ReplaceAll(" ", ","); |
1764 | listhists.ReplaceAll(" ", ","); | |
4d5d766e | 1765 | if (listhists.Length()){ |
1766 | outputArchive += " "; | |
1767 | outputArchive += "root_archive.zip:"; | |
1768 | outputArchive += listhists; | |
1769 | if (listaods.Length()){ | |
1770 | outputArchive += ","; | |
1771 | outputArchive += listaods; | |
1772 | } | |
1773 | outputArchive += Form("@%s", kGridOutputStorages.Data()); | |
1774 | } | |
1775 | else{ | |
1776 | ||
1777 | if (listaods.Length()){ | |
1778 | // we have only aod'ish output | |
1779 | outputArchive += " "; | |
1780 | outputArchive += "root_archive.zip:"; | |
1781 | outputArchive += listaods; | |
1782 | outputArchive += Form("@%s", kGridOutputStorages.Data()); | |
1783 | } | |
1784 | else{ | |
1785 | // no other outputs than std.. | |
c38e3b95 | 1786 | ::Fatal("AnalysisTrainPWG4Jets", "No task output !"); |
4d5d766e | 1787 | } |
c38e3b95 | 1788 | } |
4d5d766e | 1789 | |
17d96675 | 1790 | plugin->SetDefaultOutputs(kFALSE); |
c38e3b95 | 1791 | plugin->SetOutputArchive(outputArchive); |
17d96675 | 1792 | |
4721d8c5 | 1793 | |
4d5d766e | 1794 | // Optionally set a name for the generated analysis macro (default MyAnalysis.C) |
c38e3b95 | 1795 | plugin->SetAnalysisMacro(Form("%s.C", kTrainName.Data())); |
4d5d766e | 1796 | // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) |
c38e3b95 | 1797 | plugin->SetSplitMaxInputFileNumber(kGridFilesPerJob); |
4d5d766e | 1798 | // Optionally set number of failed jobs that will trigger killing waiting sub-jobs. |
27cdf9c4 | 1799 | // plugin->SetMaxInitFailed(5); |
4d5d766e | 1800 | // Optionally resubmit threshold. |
c8fb37dd | 1801 | // plugin->SetMasterResubmitThreshold(90); |
4d5d766e | 1802 | // Optionally set time to live (default 30000 sec) |
d4e8abc5 | 1803 | plugin->SetTTL(54000); // 15h... |
4d5d766e | 1804 | // Optionally set input format (default xml-single) |
c38e3b95 | 1805 | plugin->SetInputFormat("xml-single"); |
4d5d766e | 1806 | // Optionally modify the name of the generated JDL (default analysis.jdl) |
c38e3b95 | 1807 | plugin->SetJDLName(Form("%s.jdl", kTrainName.Data())); |
4d5d766e | 1808 | // Optionally modify the executable name (default analysis.sh) |
c38e3b95 | 1809 | plugin->SetExecutable(Form("%s.sh", kTrainName.Data())); |
4d5d766e | 1810 | // Optionally modify job price (default 1) |
c38e3b95 | 1811 | plugin->SetPrice(1); |
4d5d766e | 1812 | // Optionally modify split mode (default 'se') |
c38e3b95 | 1813 | plugin->SetSplitMode("se"); |
1814 | return plugin; | |
1815 | } | |
1816 | ||
1817 | //______________________________________________________________________________ | |
1818 | void WriteConfig() | |
1819 | { | |
1820 | // Write train configuration in a file. The file name has the format: | |
1821 | // train_[trainName]_ddMonthyyyy_time.C | |
1822 | if (kUseDate) { | |
1823 | gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp"); | |
1824 | ifstream fdate("date.tmp"); | |
1825 | if (!fdate.is_open()) { | |
1826 | ::Error("AnalysisTrainPWG4Jets.C::Export","Could not generate file name"); | |
1827 | return; | |
1828 | } | |
1829 | const char date[64]; | |
1830 | fdate.getline(date,64); | |
1831 | fdate.close(); | |
1832 | gSystem->Exec("rm date.tmp"); | |
1833 | kTrainName = Form("train_%s_%s", kTrainName.Data(), date); | |
1834 | } else { | |
1835 | kTrainName = Form("train_%s", kTrainName.Data()); | |
1836 | } | |
1837 | TString cdir = gSystem->WorkingDirectory(); | |
1838 | gSystem->MakeDirectory(kTrainName); | |
1839 | gSystem->ChangeDirectory(kTrainName); | |
1840 | ofstream out; | |
1841 | out.open(Form("%sConfig.C",kTrainName.Data()), ios::out); | |
1842 | if (out.bad()) { | |
1843 | ::Error("AnalysisTrainPWG4Jets.C::Export", "Cannot open ConfigTrain.C for writing"); | |
1844 | return; | |
1845 | } | |
1846 | out << "{" << endl; | |
1847 | out << " kTrainName = " << "\"" << kTrainName.Data() << "\";" << endl; | |
1848 | out << " kProofCluster = " << "\"" << kProofCluster.Data() << "\";" << endl; | |
1849 | out << " kProofUseAFPAR = " << kProofUseAFPAR << ";" << endl; | |
1850 | if (kProofUseAFPAR) | |
1851 | out << " kProofAFversion = " << kProofAFversion.Data() << ";" << endl; | |
1852 | out << " kProofDataSet = " << "\"" << kProofDataSet.Data() << "\";" << endl; | |
1853 | out << " kPluginUse = " << kPluginUse << ";" << endl; | |
1854 | out << " kUsePAR = " << kUsePAR << ";" << endl; | |
1855 | out << " kUseCPAR = " << kUseCPAR << ";" << endl; | |
1856 | out << " kPluginRootVersion = " << "\"" << kPluginRootVersion.Data() << "\";" << endl; | |
1857 | out << " kPluginAliRootVersion = " << "\"" << kPluginAliRootVersion.Data() << "\";" << endl; | |
1858 | out << " kGridDatadir = " << "\"" << kGridDatadir.Data() << "\";" << endl; | |
1859 | if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data()); | |
1860 | out << " kGridOutdir = " << "\"" << kGridOutdir.Data() << "\";" << endl; | |
1861 | out << " kGridMaxMergeFiles = " << kGridMaxMergeFiles << ";" << endl; | |
1862 | out << " kGridMergeExclude = " << "\"" << kGridMergeExclude.Data() << "\";" << endl; | |
1863 | out << " kGridRunsPerMaster = " << kGridRunsPerMaster << ";" << endl; | |
1864 | out << " kGridFilesPerJob = " << kGridFilesPerJob << ";" << endl; | |
1865 | out << " kGridRunRange[0] = " << kGridRunRange[0] << ";" << endl; | |
1866 | out << " kGridRunRange[1] = " << kGridRunRange[1] << ";" << endl; | |
1867 | out << " kUseDebug = " << kUseDebug << ";" << endl; | |
1868 | out << " kUseMC = " << kUseMC << ";" << endl; | |
1869 | out << " kUseESDTags = " << kUseESDTags << ";" << endl; | |
1870 | out << " kUseKinefilter = " << kUseKinefilter << ";" << endl; | |
1871 | out << " kUseTR = " << kUseTR << ";" << endl; | |
1872 | out << " kUseAODTags = " << kUseAODTags << ";" << endl; | |
1873 | out << " kSaveTrain = " << "kFALSE;" << endl << endl; | |
1874 | out << " // Analysis modules" << endl; | |
1875 | out << " iAODanalysis = " << iAODanalysis << ";" << endl; | |
1876 | out << " iAODhandler = " << iAODhandler << ";" << endl; | |
1877 | out << " iESDfilter = " << iESDfilter << ";" << endl; | |
1878 | out << " iJETAN = " << iJETAN << ";" << endl; | |
1879 | out << "// Configuration fot the wagons" << endl; | |
1880 | out << "}" << endl; | |
1881 | ::Info("AnalysisTrainPWG4Jets.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", kTrainName.Data())); | |
1882 | gSystem->ChangeDirectory(cdir); | |
1883 | } | |
1884 | ||
1885 | //______________________________________________________________________________ | |
1886 | Bool_t LoadConfig(const char *filename) | |
1887 | { | |
1888 | // Read train configuration from file | |
1889 | if (gSystem->AccessPathName(filename)) { | |
1890 | ::Error("AnalysisTrainPWG4Jets.C::LoadConfig", "Config file name not found"); | |
1891 | return kFALSE; | |
1892 | } | |
1893 | gROOT->ProcessLine(Form(".x %s", filename)); | |
1894 | ::Info("AnalysisTrainPWG4Jets.C::LoadConfig", "Train configuration loaded from file %s", filename); | |
1895 | return kTRUE; | |
1896 | } | |
1897 | ||
1898 | Bool_t PatchJDL(){ | |
1899 | Printf(">>> Patching JDL"); | |
1900 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
1901 | AliAnalysisAlien* gridHandler = (AliAnalysisAlien*)mgr->GetGridHandler(); | |
1902 | TGridJDL *jdl = gridHandler->GetGridJDL(); | |
1903 | if(iJETAN)jdl->AddToPackages("fastjet","v2.4.0"); | |
1904 | gridHandler->WriteJDL(kFALSE); | |
0971dabc | 1905 | Printf("<<< Patching JDL"); |
c38e3b95 | 1906 | return kTRUE; |
1907 | } | |
1908 | ||
1909 | Bool_t PatchAnalysisMacro(){ | |
4721d8c5 | 1910 | Printf(">>> Patching AnalysisMacro"); |
1911 | gSystem->Exec(Form("mv %s.C %s.C_tmp",kTrainName.Data(),kTrainName.Data())); | |
c38e3b95 | 1912 | |
1913 | ifstream in1; | |
1914 | in1.open(Form("%s.C_tmp", kTrainName.Data())); | |
1915 | char cLine[250]; | |
1916 | TString st; | |
1917 | while(in1.getline(cLine,250)){ | |
1918 | st += cLine; | |
1919 | st += "\n"; | |
1920 | } | |
4721d8c5 | 1921 | Int_t index= -1; |
c38e3b95 | 1922 | index = st.Index("gSystem->Load(\"libPhysics\");"); |
1923 | index += strlen("gSystem->Load(\"libPhysics\");"); | |
4721d8c5 | 1924 | /* |
c38e3b95 | 1925 | TObjArray *arr; |
1926 | TObjString *objstr; | |
1927 | arr = anaLibs.Tokenize(" "); | |
1928 | TIter next(arr); | |
4721d8c5 | 1929 | |
c38e3b95 | 1930 | add += "\n\n // added by CKB \n"; |
1931 | while ((objstr=(TObjString*)next())){ | |
e84da0a5 | 1932 | if(objstr->GetString().Contains("PWG3"))continue; |
c38e3b95 | 1933 | if(objstr->GetString().EndsWith(".so"))add += Form("gSystem->Load(\"%s\");\n",objstr->GetString().Data()); |
1934 | } | |
1935 | delete arr; | |
4721d8c5 | 1936 | */ |
3878a941 | 1937 | // add += Form("AliLog::SetGlobalLogLevel(%d);\n",AliLog::GetGlobalLogLevel()); |
4721d8c5 | 1938 | TString add = ""; |
1939 | ||
1940 | if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__); | |
1941 | add += "\n\n // added by CKB \n"; | |
46534866 | 1942 | if(kErrorIgnoreLevel>0)add += Form("gErrorIgnoreLevel = %d;\n",kErrorIgnoreLevel); |
23adcac8 | 1943 | add += "\n gSystem->AddIncludePath(\"./\"); \n"; |
f4132e7d | 1944 | add += "\n gSystem->SetFPEMask(); \n"; |
1945 | ||
1946 | ||
4721d8c5 | 1947 | if(gGrid&&kPluginAliRootVersion.Length()==0){ |
1948 | add += "\n // Dirty hack for TRD reference data \n"; | |
1949 | add += "\n gSystem->Setenv(\"ALICE_ROOT\",\""; | |
1950 | add += Form("alien://%s/rootfiles/",gGrid->GetHomeDirectory()); | |
1951 | add += "\"); \n"; | |
c38e3b95 | 1952 | } |
4721d8c5 | 1953 | add += "// BKC \n\n"; |
1954 | st.Insert(index,add.Data()); | |
e84da0a5 | 1955 | |
1956 | if(kUseDebug){ | |
23adcac8 | 1957 | // st.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n"); |
e84da0a5 | 1958 | } |
1959 | ||
4721d8c5 | 1960 | if(kUseCPAR&&kPluginAliRootVersion.Length()==0){ |
1961 | index = st.Index("gSystem->AddIncludePath(\"-I$"); // uncommen $ALICE_ROOT include for par files | |
1962 | if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__); | |
1963 | st.Insert(index,"// CKB comment out whehn no aliroot is provided \n //"); | |
1964 | } | |
c166d299 | 1965 | |
46534866 | 1966 | if(AliLog::GetGlobalLogLevel()==AliLog::kFatal){ |
1967 | index = st.Index("AliLog::SetGlobal"); // ncomment setting of log level, do my own | |
1968 | if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__); | |
1969 | st.Insert(index,"AliLog::SetGlobalLogLevel(AliLog::kFatal);// CKB \n // CKB comment out for own setting \n //"); | |
1970 | } | |
1971 | ||
c38e3b95 | 1972 | ofstream out; |
1973 | out.open(Form("%s.C", kTrainName.Data())); | |
1974 | if (out.bad()) { | |
1975 | return kFALSE; | |
1976 | } | |
1977 | out << st << endl; | |
1978 | Printf("<<< Patching AnalysisMacro"); | |
4721d8c5 | 1979 | |
1980 | ||
1981 | ||
1982 | ||
1983 | ||
1984 | Printf(">>> Patching Merge Macro"); | |
1985 | gSystem->Exec(Form("mv %s_merge.C %s_merge.C_tmp",kTrainName.Data(),kTrainName.Data())); | |
1986 | ||
1987 | ifstream in2; | |
1988 | in2.open(Form("%s_merge.C_tmp", kTrainName.Data())); | |
1989 | TString st2; | |
1990 | while(in2.getline(cLine,250)){ | |
1991 | st2 += cLine; | |
1992 | st2 += "\n"; | |
1993 | } | |
1994 | index = st2.Index("gSystem->Load(\"libPhysics\");"); | |
1995 | index += strlen("gSystem->Load(\"libPhysics\");"); | |
1996 | TString add2 = ""; | |
23adcac8 | 1997 | add2 += "\n gSystem->AddIncludePath(\"./\"); \n"; |
4721d8c5 | 1998 | if(gGrid&&kPluginAliRootVersion.Length()==0){ |
1999 | add2 += "\n // Dirty hack for TRD reference data \n"; | |
2000 | add2 += "\n gSystem->Setenv(\"ALICE_ROOT\",\""; | |
2001 | add2 += Form("alien://%s/rootfiles/",gGrid->GetHomeDirectory()); | |
2002 | add2 += "\"); \n"; | |
2003 | } | |
2004 | add2 += "// BKC \n\n"; | |
2005 | if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__); | |
2006 | st2.Insert(index,add.Data()); | |
2007 | ||
2008 | ||
2009 | if(kUseDebug){ | |
23adcac8 | 2010 | // st2.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n"); |
4721d8c5 | 2011 | } |
2012 | ||
2013 | if(kUseCPAR&&kPluginAliRootVersion.Length()==0){ | |
46534866 | 2014 | index = st2.Index("gSystem->AddIncludePath(\"-I$"); // uncomment $ALICE_ROOT include for par files |
4721d8c5 | 2015 | if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__); |
2016 | st2.Insert(index,"// CKB comment out whehn no aliroot is provided \n //"); | |
2017 | } | |
2018 | ||
2019 | // do not exclude the extra files from merign, this is done explicitly in this train script | |
92d850d5 | 2020 | // index = st2.Index("mergeExcludes +="); // uncommen $ALICE_ROOT include for par files |
2021 | // if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__); | |
2022 | // st2.Insert(index,"// CKB comment out, handled explicitly by the train macro \n //"); | |
4721d8c5 | 2023 | |
2024 | ||
2025 | ofstream out2; | |
2026 | out2.open(Form("%s_merge.C", kTrainName.Data())); | |
2027 | if (out2.bad()) { | |
2028 | return kFALSE; | |
2029 | } | |
2030 | out2 << st2 << endl; | |
2031 | Printf("<<< Patching Merging Macro"); | |
2032 | ||
2033 | ||
2034 | ||
c38e3b95 | 2035 | return kTRUE; |
2036 | ||
2037 | } |