Changes to the DEtaDPhi corr fun (making 0 in the center of the bin in the histogram...
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisAlien.h
c57f56b7 1#ifndef ALIANALYSISALIEN_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
6// Author: Mihaela Gheata, 01/09/2008
9// AliAnalysisAlien - AliEn utility class. Provides interface for creating
10// a personalized JDL, finding and creating a dataset.
14#include "AliAnalysisGrid.h"
17#ifndef ROOT_TString
18#include <TString.h>
149d288c 21#ifndef ROOT_TMath
22#include <TMath.h>
28ce6c9c 25#ifndef ROOT_TMap
26#include <TMap.h>
105631b5 29class AliAnalysisManager;
77f34eae 30class AliAnalysisTaskCfg;
c57f56b7 31class TGridJDL;
33class AliAnalysisAlien : public AliAnalysisGrid {
37 AliAnalysisAlien();
38 AliAnalysisAlien(const char *name);
39 virtual ~AliAnalysisAlien();
40 AliAnalysisAlien(const AliAnalysisAlien& other);
41 AliAnalysisAlien& operator=(const AliAnalysisAlien& other);
42// Setters
37d21c01 43 virtual void AddAdditionalLibrary(const char *name);
f965131e 44 virtual void AddIncludePath(const char *path);
c57f56b7 45 virtual void AddRunNumber(Int_t run);
ee75cfc3 46 virtual void AddRunNumber(const char *run);
98690895 47 virtual void AddRunList(const char *runList);
c57f56b7 48 virtual void AddDataFile(const char *lfn);
648174cf 49 virtual void AddExternalPackage(const char *name);
c57f56b7 50 virtual void SetExecutable(const char *name="") {fExecutable = name;}
0a1c1f7f 51 virtual void SetExecutableCommand(const char *command="root -b -q") {fExecutableCommand = command;}
c57f56b7 52 virtual void SetArguments(const char *name="") {fArguments = name;}
631c0b05 53 virtual void SetExecutableArgs(const char *name="") {fExecutableArgs = name;}
c57f56b7 54 virtual void SetAnalysisMacro(const char *name="myAnalysis.C") {fAnalysisMacro = name;}
55 virtual void SetAnalysisSource(const char *name="myAnalysisClass.cxx") {fAnalysisSource = name;}
d3b18c4c 56 virtual void SetValidationScript(const char *name="") {fValidationScript = name;}
c57f56b7 57 virtual void SetAdditionalLibs(const char *list) {fAdditionalLibs = list;}
d5c6455a 58 virtual void SetAdditionalRootLibs(const char *list) {fAdditionalRootLibs = list;}
c57f56b7 59 virtual void SetPrice(Int_t price=1) {fPrice = price;}
a8739e8a 60 virtual void SetRunRange(Int_t min, Int_t max) {fRunRange[0] = min; fRunRange[1] = max;}
c6cb3634 61 virtual void SetJobTag(const char *tag="") {fJobTag = tag;}
319593fb 62 virtual void SetNrunsPerMaster(Int_t nruns=1) {fNrunsPerMaster = nruns;}
16a4353c 63 virtual void SetMaxMergeFiles(Int_t nfiles) {fMaxMergeFiles = nfiles;}
b3e07543 64 virtual void SetMaxMergeStages(Int_t nstages) {fMaxMergeStages = nstages;}
c57f56b7 65 virtual void SetSplitMode(const char *type="se") {fSplitMode = type;}
66 virtual void SetSplitMaxInputFileNumber(Int_t nfiles=100) {fSplitMaxInputFileNumber = nfiles;}
149d288c 67 virtual void SetAPIVersion(const char *version) {fAPIVersion = version;}
68 virtual void SetROOTVersion(const char *version) {fROOTVersion = version;}
69 virtual void SetAliROOTVersion(const char *version) {fAliROOTVersion=version;}
c57f56b7 70 virtual void SetUser(const char *user) {fUser = user;}
71 virtual void SetTTL(Int_t ttl=30000) {fTTL = ttl;}
72 virtual void SetGridWorkingDir(const char *name="workdir") {fGridWorkingDir = name;}
73 virtual void SetGridDataDir(const char *name) {fGridDataDir = name;}
b098b6ab 74 void SetGeneratorLibs(const char *libs) {fGeneratorLibs = libs;}
c57f56b7 75 virtual void SetDataPattern(const char *pattern="*AliESDs.root") {fDataPattern = pattern;}
a41b2882 76 virtual void SetFriendChainName(const char *name="", const char *libnames="");
bb885a9e 77 virtual void SetDefaultOutputs(Bool_t flag);
c57f56b7 78 virtual void SetGridOutputDir(const char *name="output") {fGridOutputDir = name;}
149d288c 79 virtual void SetOutputArchive(const char *list="*@disk=1*.root@disk=2");
80 virtual void SetOutputFiles(const char *list);
cd11251e 81 virtual void SetOutputToRunNo(Int_t mode=1) {fOutputToRunNo = mode;}
c57f56b7 82 virtual void SetInputFormat(const char *format="xml-single") {fInputFormat = format;}
83 virtual void SetMaxInitFailed(Int_t nfail=5) {fMaxInitFailed = nfail;}
d3b18c4c 84 virtual void SetTerminateFiles(const char *list) {fTerminateFiles = list;}
bb885a9e 85 virtual void SetMergeExcludes(const char *list) {fMergeExcludes = list;};
0f389141 86 virtual void SetMergeViaJDL(Bool_t on=kTRUE) {fMergeViaJDL = on ? 1 : 0;}
f47d5cb4 87 virtual void SetMergeDirName(const char *name) {fMergeDirName = name;}
c57f56b7 88 virtual void SetMasterResubmitThreshold(Int_t percentage) {fMasterResubmitThreshold = percentage;}
715da79c 89 void SetMCLoop(Bool_t flag=kTRUE) {fMCLoop = flag;}
bb885a9e 90 virtual void SetNtestFiles(Int_t nfiles) {fNtestFiles = nfiles;}
149d288c 91 virtual void SetNumberOfReplicas(Int_t ncopies) {fNreplicas = TMath::Min(ncopies,4);}
c57f56b7 92 virtual void SetJDLName(const char *name="analysis.jdl") {fJDLName = name;}
149d288c 93 virtual void SetPreferedSE(const char *se);
a3e84053 94 virtual void SetProductionMode(Int_t mode=1) {fProductionMode = mode;}
37d21c01 95 virtual void SetRegisterExcludes(const char *list) {fRegisterExcludes = list;}
74013535 96 virtual void SetRunPrefix(const char *prefix);
648174cf 97 virtual void SetOutputSingleFolder(const char *folder) {fOutputSingle = folder; fSplitMode="file"; fSplitMaxInputFileNumber=1;}
0f389141 98 virtual void SetFastReadOption(Bool_t on=kTRUE) {fFastReadOption = on ? 1 : 0;}
99 virtual void SetOverwriteMode(Bool_t on=kTRUE) {fOverwriteMode = on ? 1 : 0;}
d88e4159 100 virtual void SetDropToShell(Bool_t drop=true) {fDropToShell = drop;}
780ec36d 101 virtual void SetTreeName(const char *name) {fTreeName = name;}
c57f56b7 102
0f389141 103 TGridJDL *GetGridJDL() const {return fGridJDL;}
104 TGridJDL *GetMergingJDL() const {return fMergingJDL;}
5513444a 105 const char *GetGridOutputDir() const {return fGridOutputDir;}
715da79c 106 Int_t GetNMCevents() const {return fNMCevents;}
107 Int_t GetNMCjobs() const {return fNMCjobs;}
108 void SetNMCevents(Int_t nevents) {fNMCevents = nevents;}
109 void SetNMCjobs(Int_t njobs) {fNMCjobs = njobs;}
c57f56b7 110//Utilities
77f34eae 111 void AddModule(AliAnalysisTaskCfg *module);
112 void AddModules(TObjArray *list);
3e40fd4c 113 AliAnalysisManager *CreateAnalysisManager(const char *name, const char *filename="");
77f34eae 114 Int_t GetNmodules() const;
115 AliAnalysisTaskCfg *GetModule(const char *name);
116 Bool_t LoadModules();
a41b2882 117 Bool_t LoadFriendLibs() const;
21ca8e59 118 Bool_t GenerateTest(const char *name, const char *modname="");
139fe6ba 119 Bool_t GenerateTrain(const char *name);
c57f56b7 120 virtual Bool_t CreateDataset(const char *pattern);
4a8b667c 121 Int_t CopyLocalDataset(const char *griddir, const char *pattern, Int_t nfiles, const char *output="data.txt", const char *archivefile="", const char *outputdir="data");
c57f56b7 122 virtual Bool_t CreateJDL();
4e5c5506 123 virtual void EnablePackage(const char *package);
923e2ca5 124 static Bool_t DirectoryExists(const char *lfn);
5513444a 125 static Bool_t FileExists(const char *lfn);
a03be957 126 static const char *GetJobStatus(Int_t jobidstart, Int_t lastid, Int_t &nrunning, Int_t &nwaiting, Int_t &nerror, Int_t &ndone);
f790bc1b 127 const char *GetListOfFiles(const char *type);
b3e07543 128 Bool_t CheckMergedFiles(const char *filename, const char *aliendir, Int_t nperchunk, const char *jdl="");
105631b5 129 static AliAnalysisManager *LoadAnalysisManager(const char *fname);
ec5acdce 130 static Bool_t MergeInfo(const char *output, const char *collection);
b3e07543 131 static Bool_t MergeOutput(const char *output, const char *basedir, Int_t nmaxmerge, Int_t stage=0);
c57f56b7 132 virtual Bool_t MergeOutputs();
16a4353c 133 virtual void Print(Option_t *option="") const;
715da79c 134 static Long64_t RunMacroAndExtractLibs(const char* macro, const char *args, TString &libs);
5513444a 135 virtual Bool_t StartAnalysis(Long64_t nentries=123456789, Long64_t firstentry=0);
0f389141 136 static Bool_t SetupPar(const char *package);
a03be957 137 virtual Bool_t Submit();
138 virtual Bool_t SubmitMerging();
7c2cd90a 139 static Int_t SubmitSingleJob(const char *query);
c57f56b7 140 virtual void WriteAnalysisFile();
141 virtual void WriteAnalysisMacro();
0f389141 142 virtual void WriteMergingMacro();
143 virtual void WriteMergeExecutable();
c57f56b7 144 virtual void WriteExecutable();
5513444a 145 virtual Bool_t WriteJDL(Bool_t copy);
146 virtual void WriteProductionFile(const char *filename) const;
0f389141 147 virtual void WriteValidationScript(Bool_t merge=kFALSE);
c57f56b7 148
3bdcb562 149// PROOF mode
150 virtual void SetProofCluster(const char *cluster) {fProofCluster = cluster;}
151 virtual void SetProofDataSet(const char *dataset) {fProofDataSet = dataset;}
152 virtual const char *GetProofDataSet() const {return fProofDataSet.Data();}
28ce6c9c 153 virtual void SetProofParameter(const char *pname, const char *value);
154 const char *GetProofParameter(const char *pname) const;
3bdcb562 155 virtual void SetProofReset(Int_t mode) {fProofReset = mode;}
156 virtual void SetNproofWorkers(Int_t nworkers) {fNproofWorkers = nworkers;}
27734f0e 157 virtual void SetNproofWorkersPerSlave(Int_t nworkers) {fNproofWorkersPerSlave = nworkers;}
874de7ea 158 virtual void SetRootVersionForProof(const char *version);
3bdcb562 159 virtual void SetAliRootMode(const char *mode) {fAliRootMode = mode;}
d88e4159 160 virtual void SetProofProcessOpt(const char *proofOpt="") {fProofProcessOpt = proofOpt;}
161 virtual TString GetProofProcessOpt() {return fProofProcessOpt;}
3bdcb562 162 // .txt file containing the list of files to be chained in test mode
163 virtual void SetFileForTestMode(const char *filename) {fFileForTestMode = filename;}
164 virtual TChain *GetChainForTestMode(const char *treeName) const;
0ad3ea1f 165 virtual const TString& GetGridJobIDs() const { return fGridJobIDs; }
166 virtual const TString& GetGridStages() const { return fGridStages; }
c57f56b7 167protected:
168 void CdWork();
169 Bool_t CheckInputData();
170 void CheckDataType(const char *lfn, Bool_t &is_collection, Bool_t &is_xml, Bool_t &use_tags);
171 virtual Bool_t Connect();
172 virtual void SetDefaults();
a03be957 173 Bool_t SubmitNext();
c57f56b7 174
c57f56b7 175 Bool_t IsCollection(const char *lfn) const;
715da79c 176 Bool_t IsMCLoop() const {return fMCLoop;}
fe2d7fc2 177 virtual Bool_t IsSingleOutput() const;
c57f56b7 178 Bool_t IsUsingTags() const {return TObject::TestBit(AliAnalysisGrid::kUseTags);}
77f34eae 179 Bool_t LoadModule(AliAnalysisTaskCfg *mod);
180 Bool_t CheckDependencies();
b5ae4fe0 181 Bool_t CheckFileCopy(const char *alienpath);
c57f56b7 182
184 TGridJDL *fGridJDL; //! JDL maker
0f389141 185 TGridJDL *fMergingJDL; //! JDL maker
c57f56b7 186 Int_t fPrice; // Grid price for the job;
187 Int_t fTTL; // Time to live.
188 Int_t fSplitMaxInputFileNumber; // Maximum number of files to be processed per subjob
189 Int_t fMaxInitFailed; // Maximum initial consecutive subjobs accepted to fail
190 Int_t fMasterResubmitThreshold; // Failed jobs will be resubmitted until this DONE ratio
bb885a9e 191 Int_t fNtestFiles; // Number of files used in the testing case
a8739e8a 192 Int_t fRunRange[2]; // Run range
319593fb 193 Int_t fNrunsPerMaster; // Number of runs per masterjob
16a4353c 194 Int_t fMaxMergeFiles; // Maximum number of files to be merged in one chunk
b3e07543 195 Int_t fMaxMergeStages; // Maximum number of merging stages
d2a409b2 196 Int_t fNsubmitted; // Number of jobs submitted
a3e84053 197 Int_t fProductionMode; // Production mode (0-off, 1-on)
cd11251e 198 Int_t fOutputToRunNo; // Use run number as output directory
0f389141 199 Int_t fMergeViaJDL; // Enable merging via automatic JDL
200 Int_t fFastReadOption; // Use xrootd tweaks to reduce timeouts in file access
201 Int_t fOverwriteMode; // Overwrite existing files if any
149d288c 202 Int_t fNreplicas; // Number of replicas for the output files
3bdcb562 203 Int_t fNproofWorkers; // Number of workers in proof mode
27734f0e 204 Int_t fNproofWorkersPerSlave; // Max number of workers per slave in proof mode
3bdcb562 205 Int_t fProofReset; // Proof reset mode: 0=no reset, 1=soft, 2=hard
715da79c 206 Int_t fNMCevents; // Number of MC events in MC loop mode
207 Int_t fNMCjobs; // Number of MC jobs in MC loop mode
c57f56b7 208 TString fRunNumbers; // List of runs to be processed
209 TString fExecutable; // Executable script for AliEn job
0a1c1f7f 210 TString fExecutableCommand; // Command(s) to be executed in the executable script
c57f56b7 211 TString fArguments; // Arguments for the executable script
631c0b05 212 TString fExecutableArgs; // arguments added to the executable script after the analysis macro
c57f56b7 213 TString fAnalysisMacro; // Root macro steering the analysis
214 TString fAnalysisSource; // User analysis implementation (.cxx) file(s)
d3b18c4c 215 TString fValidationScript; // Name of the validation script
d5c6455a 216 TString fAdditionalRootLibs; // List (separated by blacs) of additional libraries needed for/before analysis libs/par file compilation
217 TString fAdditionalLibs; // List (separated by blacs) of additional libraries needed for the analysis loaded AFTER all par files
715da79c 218 TString fGeneratorLibs; // Extra libraries needed by the generator
c57f56b7 219 TString fSplitMode; // Job split mode
220 TString fAPIVersion; // API version
221 TString fROOTVersion; // ROOT version
222 TString fAliROOTVersion; // AliROOT version
648174cf 223 TString fExternalPackages; // External packages
c57f56b7 224 TString fUser; // AliEn user name
225 TString fGridWorkingDir; // AliEn directory containing the input packages
226 TString fGridDataDir; // AliEn data production directory
227 TString fDataPattern; // Data pattern for 'find' command
228 TString fGridOutputDir; // AliEn directory (wrt work dir) where the output should be written
229 TString fOutputArchive; // List of output archives separated by blancs
230 TString fOutputFiles; // List of output files separated by blancs
231 TString fInputFormat; // Input format (xml-single)
232 TString fDatasetName; // Dataset xml file to be created
233 TString fJDLName; // JDL file to be generated
d3b18c4c 234 TString fTerminateFiles; // List of output files produced during Terminate
bb885a9e 235 TString fMergeExcludes; // List of output files excluded from merging
37d21c01 236 TString fRegisterExcludes; // List of liles not to be registered/merged
f965131e 237 TString fIncludePath; // Include path
bb885a9e 238 TString fCloseSE; // Preffered storage element. Taken from alien_CLOSE_SE environment.
0df6ccf2 239 TString fFriendChainName; // File name to construct friend chain (for AOD)
c6cb3634 240 TString fJobTag; // Job tag
648174cf 241 TString fOutputSingle; // Directory name for the output when split is per file
5fce53f4 242 TString fRunPrefix; // Run prefix to be applied to run numbers
3bdcb562 243 TString fProofCluster; // Proof cluster name
244 TString fProofDataSet; // Proof dataset to be used
245 TString fFileForTestMode; // .txt file for the chain to be used in PROOF test mode
3bdcb562 246 TString fAliRootMode; // AliRoot mode among the list supported by the proof cluster
d88e4159 247 TString fProofProcessOpt; // Option passed to proof process
f47d5cb4 248 TString fMergeDirName; // Name of the directory that should be added to the output directory
c57f56b7 249 TObjArray *fInputFiles; // List of input files to be processed by the job
4e5c5506 250 TObjArray *fPackages; // List of packages to be used
77f34eae 251 TObjArray *fModules; // List of AliAnalysisTaskCfg modules
28ce6c9c 252 TMap fProofParam; // Key-value pairs for proof mode
d88e4159 253 Bool_t fDropToShell; // If true, execute aliensh on start
715da79c 254 Bool_t fMCLoop; // MC loop flag
0ad3ea1f 255 TString fGridJobIDs; // List of last committed jobs
256 TString fGridStages; // List of last committed jobs
a41b2882 257 TString fFriendLibs; // List of libs (separated by blacs) needed for friends processing
780ec36d 258 TString fTreeName; // Name of the tree to be analyzed
0ad3ea1f 259
715da79c 260 ClassDef(AliAnalysisAlien, 26) // Class providing some AliEn utilities
c57f56b7 261};